Compare commits

...
52 Commits
Author SHA1 Message Date
Rounick 982766922a Merge pull request #26 from myzticbean/release/v2.0
Release/v2.0
2024-04-29 22:50:34 +05:30
Rounick 9de66d52dc Merge pull request #28 from myzticbean/feature/v2.0
feature/v2.0
2024-04-29 22:48:32 +05:30
Rounick 8a85043815 Merge pull request #27 from myzticbean/feature/23
2.0.6.0 to release
2024-04-29 22:46:28 +05:30
myzticbean 80e01b8d8c 2.0.6.0 to release 2024-04-29 22:44:18 +05:30
Rounick 28b582e5f3 Merge pull request #25 from myzticbean/feature/v2.0
Feature/v2.0
2024-04-22 21:04:10 +05:30
Rounick e73c28fe77 Merge pull request #24 from myzticbean/feature/23
Feature/23
2024-04-22 21:02:55 +05:30
myzticbean 59f42b423f changelog updated 2024-04-22 21:02:26 +05:30
myzticbean e60b266bf3 config updates to new format | added logic to ignore locked warps 2024-04-22 20:28:41 +05:30
myzticbean d574d1e3be Version bumped to snapshot 2.0.6.0 | Started changes related to feature req #23 2024-04-21 17:23:11 +05:30
Rounick 375669c990 Merge pull request #19 from myzticbean/release/v2.0
Release/v2.0
2024-04-20 11:16:08 +05:30
Rounick 7c89ed8ee6 Merge pull request #22 from myzticbean/feature/v2.0
simpapi version update
2024-04-20 11:14:08 +05:30
myzticbean 477d943c7f simpapi version update 2024-04-20 11:13:21 +05:30
Rounick fcd2440706 Merge pull request #21 from myzticbean/feature/v2.0
2.0.5.7 snapshot to release
2024-04-20 10:59:48 +05:30
myzticbean 7d6d88d012 2.0.5.7 snapshot to release 2024-04-20 10:59:01 +05:30
myzticbean e372eb5d7b 2.0.5.7 snapshot to release 2024-04-20 10:57:36 +05:30
Rounick 1526c01227 Merge pull request #20 from myzticbean/feature/v2.0
Shop search optimizations
2024-04-12 12:39:08 +05:30
myzticbean 52e346ef96 Shop search optimizations 2024-04-12 12:36:36 +05:30
Rounick 49acbcbbd1 Merge pull request #18 from myzticbean/feature/v2.0
Feature/v2.0
2024-03-30 14:11:10 +05:30
myzticbean 05fb5bf17b minor updates 2024-03-30 14:03:03 +05:30
Rounick 68bf709b0c Update pom.xml 2024-03-30 13:31:00 +05:30
Rounick 49212c2271 Update maven.yml 2024-03-30 13:28:21 +05:30
myzticbean 044dc87485 Attempted fix for issue #17 2024-03-27 21:20:14 +05:30
myzticbean ab054ced56 Version bumped to 2.0.5.7-SNAPSHOT | Fixed issue #13 2024-03-24 21:10:40 +05:30
Rounick d2712da754 Merge pull request #16 from myzticbean/release/v2.0
Release/v2.0
2024-03-24 14:40:19 +05:30
Rounick e37716f77a Merge pull request #15 from myzticbean/feature/v2.0
Fixed issue #12 | Updated PlayerWarps version
2024-03-24 14:39:12 +05:30
myzticbean b7d3b7310c Fixed issue #12 | Updated PlayerWarps version 2024-03-24 14:37:06 +05:30
Rounick 9dbb08accf Merge pull request #11 from myzticbean/release/v2.0
Release/v2.0
2024-03-10 17:31:32 +05:30
Rounick c879f29895 Merge pull request #10 from myzticbean/feature/v2.0
Fixed #9 | Added new config option | Bumped version to 2.0.5.6-SNAPSHOT
2024-03-10 17:29:00 +05:30
myzticbean de84d67cc6 Fixed #9 | Added new config option | Bumped version to 2.0.5.6-SNAPSHOT 2024-03-10 17:26:20 +05:30
Rounick 9f416d4435 Merge pull request #8 from myzticbean/release/v2.0
Release/v2.0
2024-02-29 10:56:20 +05:30
Rounick 9d54c57c00 Merge pull request #7 from myzticbean/feature/v2.0
Feature/v2.0
2024-02-29 10:51:03 +05:30
myzticbean 3bc4605194 Updated CHANGELOG.md | Changed 2.0.5.4 to RELEASE 2024-02-18 15:23:15 +05:30
myzticbean 41e3f4e695 Updated CHANGELOG.md | Removed commented code 2024-02-18 14:29:55 +05:30
myzticbean bc53521578 Updated CHANGELOG.md 2024-02-11 15:55:39 +05:30
myzticbean 9a47f30708 Stock space fetch compatibility with QS Hikari 6.0 | Fixed issue #5 2024-02-11 15:51:52 +05:30
myzticbean 299750e8c4 Commenting out ignoreAdminShop feature for now | Trying out a new ShopCache logic 2023-12-17 15:57:38 +05:30
myzticbean 8c1d1b66eb Added cached shop logic to Reremake impl 2023-12-10 17:24:58 +05:30
Rounick b7c3880c78 Merge pull request #4 from myzticbean/maven-integration
Create maven.yml
2023-12-09 13:32:38 +05:30
Rounick fdc96110b6 Create maven.yml 2023-12-09 13:31:57 +05:30
myzticbean 40b177afc4 Code refactoring | Added cached shop logic to Hikari impl 2023-12-09 13:18:55 +05:30
myzticbean ab4fa4834f Feature #3 changes | Version bump to 2.0.5.4 2023-12-08 00:11:13 +05:30
ronsane 3ab7e575c1 Merge branch 'release/v2.0' into 'master'
Release/v2.0

See merge request ronsane/QSFindItemAddOn!15
2023-11-19 09:35:28 +00:00
ronsane a4a66e7f4f Merge branch 'feature/v2.0' into 'release/v2.0'
Feature/v2.0

See merge request ronsane/QSFindItemAddOn!14
2023-11-19 09:34:09 +00:00
ronsane 0f2cf64f80 Issue #31 fix | Added shop TP delay feature 2023-11-19 12:57:50 +05:30
ronsane 09ac07568b Issue #31 fix 2023-11-02 13:07:04 +05:30
ronsane 22f93b7023 Merge branch 'release/v2.0' into 'master'
Release/v2.0

See merge request ronsane/QSFindItemAddOn!11
2023-09-25 16:06:05 +00:00
ronsane 1c18378d53 Merge branch 'master' into 'release/v2.0'
# Conflicts:
#   pom.xml
2023-09-25 16:00:28 +00:00
ronsane 1e5148fd7b Merge branch 'hikari-cyno-adapt' into 'master'
Fix QuickShop-Hikari and PlayerWraps hooks

See merge request ronsane/QSFindItemAddOn!12
2023-09-25 15:30:08 +00:00
Ghost_chu 90a2dab37d Fix the API instance get 2023-09-25 22:58:57 +08:00
Ghost_chu 54ec3988ad Fix QuickShop-Hikari and PlayerWraps hooks 2023-09-25 22:28:38 +08:00
ronsane 1e007981ad Merge branch 'release/v2.0' into 'master'
Release/v2.0

- Updated versions of 
  - spigot-api
  - paperlib
  - org.maxgamer.QuickShop
  - com.ghostchu.quickshop-bukkit
  - worldguard-bukkit
  - gson
  - annotations
  - lombok
- Added
  - commons-lang3 library
  - .gitlab-ci.yml for pipeline build configuration
- Updated nearest warp calculation algorithm from 2D plane to 3D plane.
- Fix for Issue #24
- Version bumped to **2.0.5.0-RELEASE**

See merge request ronsane/QSFindItemAddOn!8
2022-07-22 05:18:01 +00:00
ronsane a3263ec499 Merge branch 'release/v2.0' into 'master'
RELEASE_version_2.0

See merge request ronsane/QSFindItemAddOn!5
2022-06-18 12:15:47 +00:00
47 changed files with 1809 additions and 867 deletions

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Java CI with Maven
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean install
+70
View File
@@ -0,0 +1,70 @@
## Release 2.0.6.0
### Changes (Feature request [#23](https://github.com/myzticbean/QSFindItemAddOn/issues/23))
- Plugin updated for Minecraft version 1.20.5.
- Changed 15Min Scheduled Task to run in async thread (should help with lag).
- Deprecated QSReremakeAPIHandler. Reremake implementation will no longer be updated. Last support is for QS-Reremake v5.1.2.5.
- Changed logger statements to show Main/Async thread state.
- Structural changes in the config.yml, specifically for shop-gui related options.
- Fixed an issue with showing large numbers in currency.
- Added new feature to format currency format. For example: $10,210,100 will be shown as $10.21M. New config option to toggle it:
```yaml
shop-gui:
use-shorter-currency-format: true
```
- New config option added as below to toggle if players should be allowed to warp to locked warps (Only for PlayerWarps).
```yaml
player-shop-teleportation:
nearest-warp-tp-mode:
do-not-tp-if-warp-locked: true
```
- Config version is now 15.
## Release 2.0.5.7
### Bug fixes
- Fixed a bug where disabling hideshop/revealshop will not disable it for `/qs finditem` ([#13](https://github.com/myzticbean/QSFindItemAddOn/issues/13))
- Fixed stock/space not updating properly from QS cache ([#17](https://github.com/myzticbean/QSFindItemAddOn/issues/17))
## Release 2.0.5.6
### Bug fixes
- Fixed a code refactoring bug where search all shops would return no shops for Quickshop Reremake
- Added a INFO level logger to log time taken for a search process
- Fix the lag issue caused due to new QS-Hikari cache feature impl ([#12](https://github.com/myzticbean/QSFindItemAddOn/issues/12))
## Release 2.0.5.5
### Bug fixes
- Fixed /finditem command not working in some cases ([#9](https://github.com/myzticbean/QSFindItemAddOn/issues/9))
- Added a config option to disable the `/finditem {TO_BUY | TO_SELL} *`
## Release 2.0.5.4
### Features
- Added Go to First and Last page GUI buttons ([#3](https://github.com/myzticbean/QSFindItemAddOn/issues/3))
- Added new config option to include empty chests in the search result ([#3](https://github.com/myzticbean/QSFindItemAddOn/issues/3))
- Added compatibility with QS Hikari 6.* shop stock/space fetch from cache feature. This should help prevent massive lag spikes.
### Bug fixes
- Full/out of space chests will be excluded from `/finditem TO-SELL <item_name>` ([#3](https://github.com/myzticbean/QSFindItemAddOn/issues/3))
- Bug fix to prevent lag when during `/finditem TO_BUY *` on large servers (Only for QS Hikari)
- Fix for issue [#5](https://github.com/myzticbean/QSFindItemAddOn/issues/5)
## Release 2.0.5.3
### Features
- Added shop TP delay ([#28](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues/28))
### Bug fixes
- Fix for issue [#31](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues/31)
## Release 2.0.5.2
### Plugin updates
- Updated the addon to make it compatible with the recent QuickShop and other dependency updates.
## Release 2.0.5.1
### Plugin updates
- Updated QuickShop-Hikari dependency to v4.0.0.0
- Updated PlayerWarps dependency to v6.18.1
- Updated QuickShop-Reremake dependency to v5.1.1.2
### Bug fixes
- Fixed issue [#25](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues/25)
## Release 2.0.5.0
### Bug fixes
- Fix for Issue [#24](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues/24)
- Fixed a bug related to nearest warp teleportation algorithm
- Other minor bug fixes
+1 -1
View File
@@ -14,7 +14,7 @@ But, please don't increase the plugin version number.
**Compiling from source**
```shell
git clone https://gitlab.com/ronsane/QSFindItemAddOn.git
git clone https://github.com/myzticbean/QSFindItemAddOn.git
cd QSFindItemAddOn/
mvn clean install
```
+29 -14
View File
@@ -1,11 +1,13 @@
# Shop Search AddOn For QuickShop
### Version: 2.0.5.1-RELEASE
### Version: 2.0.6.0-RELEASE
An unofficial add-on for the QuickShop Reremake and Hikari spigot plugin.
An unofficial add-on for the QuickShop Hikari and Reremake spigot plugin.
Adds a `/finditem` command in game for searching through all the shops on the server.
![MC](https://img.shields.io/badge/Minecraft-Java%20Edition:%201.16.5%20--%201.19.3-brightgreen)
![Ver](https://img.shields.io/spiget/version/95104?label=Current%20Spigot%20Version)
[//]: # (![MC]&#40;https://img.shields.io/badge/Minecraft-Java%20Edition:%201.16.5%20--%201.20.4-brightgreen&#41;)
![ModrinthAvailableFor](https://img.shields.io/badge/dynamic/json?label=Minecraft%20Java%20Edition:&color=4bab62&query=version&url=https://api.blueish.dev/api/minecraft/version?id=asp13ugE)
![Ver](https://img.shields.io/spiget/version/95104?label=Latest%20Spigot%20Version)
![Build Status](https://github.com/myzticbean/QSFindItemAddOn/actions/workflows/maven.yml/badge.svg?branch=master)
## Features
- Search items based on buying/selling shops
@@ -23,7 +25,7 @@ Adds a `/finditem` command in game for searching through all the shops on the se
**QuickShop-Hikari Support**
- It supports both [QuickShop-Reremake](https://www.spigotmc.org/resources/62575/) and [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/).
- It supports both [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) and [QuickShop-Reremake](https://www.spigotmc.org/resources/62575/).
**Hexcode color support**
- All messages in the config.yml support hexcodes.
@@ -43,30 +45,43 @@ command-alias: []
## Integrations
- Supports [PlayerWarps](https://www.spigotmc.org/resources/66692/) (by Olzie-12) integration. It shows the nearest warp to each shop in the search result GUI.
- Supports EssentialsX Warps integration for fetching nearest warps.
- Global warps list for essentials is updated in batches every 15 minutes due to technical limitations, which is then used in every search query.
- If you added a new warp and want it to get updated immediately, run **/finditemadmin reload**
- Remember, this applies only to Essential Warps.
- Global warps list for essentials is updated in batches every 15 minutes due to technical limitations, which is then used in every search query.
- If you added a new warp and want it to get updated immediately, run **/finditemadmin reload**
- Remember, this applies only to Essential Warps.
- WorldGuard region support for fetching the WorldGuard region the shop is in (if overlapping regions, highest priority will be chosen)
>Check out the sample config.yml [here](https://gitlab.com/ronsane/QSFindItemAddOn/-/wikis/config.yml-%5BFor-QuickShopAddOn-v2.*%5D).
>Check out the sample config.yml [here](https://github.com/myzticbean/QSFindItemAddOn/wiki/Sample-config.yml).
## Requires
- [QuickShop Reremake](https://www.spigotmc.org/resources/62575/) 5.0 or higher (Use add-on v1.7 for QuickShop version 4.0.*)
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v6.0 or higher
OR
**OR**
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v4.0.0.0 or higher
- [QuickShop Reremake](https://www.spigotmc.org/resources/62575/) 5.1 or higher (Use add-on v1.7 for QuickShop version 4.0.*)
## Assumptions
- A compatible economy plugin is installed
- [Vault](https://www.spigotmc.org/resources/34315/) 1.7.3 or higher is installed
## Issue Tracking
Please create a new issue [here](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues) if you encounter any errors. Please try to explain in detail about your issue, and attach your console log if possible.
Please create a new issue [here](https://github.com/myzticbean/QSFindItemAddOn/issues) if you encounter any errors. Please try to explain in detail about your issue, and attach your console log if possible.
You can also find the list of features currently being worked on (if any) in the same link.
## How to contribute?
See more details [here](../../../CONTRIBUTING.md).
See more details [here](https://github.com/myzticbean/QSFindItemAddOn/blob/master/CONTRIBUTING.md).
## BStats Metrics
[![BigImage](https://bstats.org/signatures/bukkit/QSFindItemAddOn.svg)](https://bstats.org/plugin/bukkit/QSFindItemAddOn/12382)
## Demo
### How to use `/finditem`?
![/finditem_usage](https://cdn.modrinth.com/data/asp13ugE/images/bb37966809c9d7ab3201988ef58b2060688584f3.png)
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/878e9b703343a65c963d790d875ad5dbe6ac309d.png)
### Multiple search result pages:
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/33cb7d96cabb709bc630685c9e6fdc1b9cd7b3bb.png)
### Shows item enchantments:
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/8ac5643bc042b897e549400e29186d87024b3a71.png)
### Shows Potion colors and effects:
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/786ce10d42c5e92cbbd12b7f1ee81011796acbe0.png)
### Shows custom item names and lore:
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/0c30b767bfc9df1f4a79afef677c0fc262fa62c5.png)
+74 -16
View File
@@ -6,14 +6,15 @@
<groupId>io.myzticbean.FindItemAddOn</groupId>
<artifactId>QSFindItemAddOn</artifactId>
<version>2.0.5.1-RELEASE</version>
<version>2.0.6.0-RELEASE</version>
<packaging>jar</packaging>
<name>QSFindItemAddOn</name>
<properties>
<java.version>16</java.version>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spigot.version>1.20.5-R0.1-SNAPSHOT</spigot.version>
</properties>
<build>
@@ -49,9 +50,9 @@
<version>2.3.1</version>
<configuration>
<!-- Below path is where your plugin jar will be copied automatically upon build, comment out if on a Mac -->
<!-- <outputDirectory>E:\MCServer_1.18\plugins</outputDirectory> -->
<!--<outputDirectory>D:\${user.name}\MCServers\MCServer_1.20.1\plugins</outputDirectory>-->
<!-- Comment out if on a PC -->
<!-- <outputDirectory>/Users/${user.name}/IdeaProjects/MCServer_1.18/plugins</outputDirectory> -->
<!--<outputDirectory>/Users/${user.name}/IdeaProjects/MCServer_1.20.1/plugins</outputDirectory>-->
</configuration>
</plugin>
<plugin>
@@ -91,6 +92,10 @@
</build>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
@@ -124,8 +129,8 @@
<url>https://maven.enginehub.org/repo/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<id>central</id>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
@@ -133,7 +138,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -145,7 +150,7 @@
<dependency>
<groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId>
<version>5.1.1.2</version>
<version>5.1.2.5</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@@ -154,10 +159,46 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-api</artifactId>
<version>6.1.0.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
<exclusion>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.juliomarcopineda</groupId>
<artifactId>jdbc-stream</artifactId>
</exclusion>
<exclusion>
<groupId>one.util</groupId>
<artifactId>streamex</artifactId>
</exclusion>
<exclusion>
<groupId>tne.tne</groupId>
<artifactId>TheNewEconomy</artifactId>
</exclusion>
<exclusion>
<groupId>me.xanium</groupId>
<artifactId>GemsEconomy</artifactId>
</exclusion>
<exclusion>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-common</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>4.0.0.0</version>
<version>6.1.0.1</version>
<scope>provided</scope>
<classifier>shaded</classifier>
<exclusions>
@@ -185,6 +226,10 @@
<groupId>me.xanium</groupId>
<artifactId>GemsEconomy</artifactId>
</exclusion>
<exclusion>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-common</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
@@ -202,7 +247,7 @@
<dependency>
<groupId>com.olziedev</groupId>
<artifactId>playerwarps-api</artifactId>
<version>6.18.1</version>
<version>6.30.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@@ -274,12 +319,12 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
<version>2.10</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
<version>24.1.0</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
@@ -290,13 +335,13 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.KodySimpson</groupId>
<artifactId>SimpAPI</artifactId>
<version>4.3.2</version>
<version>4.5.5</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
@@ -307,12 +352,25 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<version>3.14.0</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.12.0</version>
<version>4.16.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>easysql-api</artifactId>
<version>0.4.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
+28 -13
View File
@@ -1,11 +1,13 @@
# Shop Search AddOn For QuickShop
### Version: ${project.version}
An unofficial add-on for the QuickShop Reremake and Hikari spigot plugin.
An unofficial add-on for the QuickShop Hikari and Reremake spigot plugin.
Adds a `/finditem` command in game for searching through all the shops on the server.
![MC](https://img.shields.io/badge/Minecraft-Java%20Edition:%201.16.5%20--%201.19.3-brightgreen)
![Ver](https://img.shields.io/spiget/version/95104?label=Current%20Spigot%20Version)
[//]: # (![MC]&#40;https://img.shields.io/badge/Minecraft-Java%20Edition:%201.16.5%20--%201.20.4-brightgreen&#41;)
![ModrinthAvailableFor](https://img.shields.io/badge/dynamic/json?label=Minecraft%20Java%20Edition:&color=4bab62&query=version&url=https://api.blueish.dev/api/minecraft/version?id=asp13ugE)
![Ver](https://img.shields.io/spiget/version/95104?label=Latest%20Spigot%20Version)
![Build Status](https://github.com/myzticbean/QSFindItemAddOn/actions/workflows/maven.yml/badge.svg?branch=master)
## Features
- Search items based on buying/selling shops
@@ -23,7 +25,7 @@ Adds a `/finditem` command in game for searching through all the shops on the se
**QuickShop-Hikari Support**
- It supports both [QuickShop-Reremake](https://www.spigotmc.org/resources/62575/) and [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/).
- It supports both [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) and [QuickShop-Reremake](https://www.spigotmc.org/resources/62575/).
**Hexcode color support**
- All messages in the config.yml support hexcodes.
@@ -43,30 +45,43 @@ command-alias: []
## Integrations
- Supports [PlayerWarps](https://www.spigotmc.org/resources/66692/) (by Olzie-12) integration. It shows the nearest warp to each shop in the search result GUI.
- Supports EssentialsX Warps integration for fetching nearest warps.
- Global warps list for essentials is updated in batches every 15 minutes due to technical limitations, which is then used in every search query.
- If you added a new warp and want it to get updated immediately, run **/finditemadmin reload**
- Remember, this applies only to Essential Warps.
- Global warps list for essentials is updated in batches every 15 minutes due to technical limitations, which is then used in every search query.
- If you added a new warp and want it to get updated immediately, run **/finditemadmin reload**
- Remember, this applies only to Essential Warps.
- WorldGuard region support for fetching the WorldGuard region the shop is in (if overlapping regions, highest priority will be chosen)
>Check out the sample config.yml [here](https://gitlab.com/ronsane/QSFindItemAddOn/-/wikis/config.yml-%5BFor-QuickShopAddOn-v2.*%5D).
>Check out the sample config.yml [here](https://github.com/myzticbean/QSFindItemAddOn/wiki/Sample-config.yml).
## Requires
- [QuickShop Reremake](https://www.spigotmc.org/resources/62575/) 5.0 or higher (Use add-on v1.7 for QuickShop version 4.0.*)
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v6.0 or higher
OR
**OR**
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v4.0.0.0 or higher
- [QuickShop Reremake](https://www.spigotmc.org/resources/62575/) 5.1 or higher (Use add-on v1.7 for QuickShop version 4.0.*)
## Assumptions
- A compatible economy plugin is installed
- [Vault](https://www.spigotmc.org/resources/34315/) 1.7.3 or higher is installed
## Issue Tracking
Please create a new issue [here](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues) if you encounter any errors. Please try to explain in detail about your issue, and attach your console log if possible.
Please create a new issue [here](https://github.com/myzticbean/QSFindItemAddOn/issues) if you encounter any errors. Please try to explain in detail about your issue, and attach your console log if possible.
You can also find the list of features currently being worked on (if any) in the same link.
## How to contribute?
See more details [here](../../../CONTRIBUTING.md).
See more details [here](https://github.com/myzticbean/QSFindItemAddOn/blob/master/CONTRIBUTING.md).
## BStats Metrics
[![BigImage](https://bstats.org/signatures/bukkit/QSFindItemAddOn.svg)](https://bstats.org/plugin/bukkit/QSFindItemAddOn/12382)
## Demo
### How to use `/finditem`?
![/finditem_usage](https://cdn.modrinth.com/data/asp13ugE/images/bb37966809c9d7ab3201988ef58b2060688584f3.png)
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/878e9b703343a65c963d790d875ad5dbe6ac309d.png)
### Multiple search result pages:
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/33cb7d96cabb709bc630685c9e6fdc1b9cd7b3bb.png)
### Shows item enchantments:
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/8ac5643bc042b897e549400e29186d87024b3a71.png)
### Shows Potion colors and effects:
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/786ce10d42c5e92cbbd12b7f1ee81011796acbe0.png)
### Shows custom item names and lore:
![alt text](https://cdn.modrinth.com/data/asp13ugE/images/0c30b767bfc9df1f4a79afef677c0fc262fa62c5.png)
@@ -3,7 +3,7 @@ package io.myzticbean.finditemaddon.Commands.QSSubCommands;
import com.ghostchu.quickshop.api.command.CommandHandler;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPermsEnum;
import me.kodysimpson.simpapi.colors.ColorTranslator;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Material;
@@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author ronsane
* @author myzticbean
*/
public class FindItemCmdHikariImpl implements CommandHandler<Player> {
@@ -26,6 +26,9 @@ public class FindItemCmdHikariImpl implements CommandHandler<Player> {
private final List<String> buyOrSellList = new ArrayList<>();
public FindItemCmdHikariImpl() {
if(FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_REMOVE_HIDE_REVEAL_SUBCMDS) {
}
if(StringUtils.isBlank(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
this.hideSubCommand = "hideshop";
}
@@ -50,7 +53,7 @@ public class FindItemCmdHikariImpl implements CommandHandler<Player> {
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
}
else if(args.length == 1) {
if(commandSender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
if(commandSender.hasPermission(PlayerPermsEnum.FINDITEM_HIDESHOP.value()) && !FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_REMOVE_HIDE_REVEAL_SUBCMDS) {
if(args[0].equalsIgnoreCase(hideSubCommand)) {
cmdExecutor.handleHideShop(commandSender);
} else if(args[0].equalsIgnoreCase(revealShopSubCommand)) {
@@ -91,7 +94,7 @@ public class FindItemCmdHikariImpl implements CommandHandler<Player> {
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
}
// hide
if(sender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
if(sender.hasPermission(PlayerPermsEnum.FINDITEM_HIDESHOP.value()) && !FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_REMOVE_HIDE_REVEAL_SUBCMDS) {
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE);
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE);
}
@@ -2,7 +2,7 @@ package io.myzticbean.finditemaddon.Commands.QSSubCommands;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPermsEnum;
import me.kodysimpson.simpapi.colors.ColorTranslator;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Material;
@@ -47,7 +47,7 @@ public class FindItemCmdReremakeImpl implements CommandHandler<Player> {
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
}
else if(args.length == 1) {
if(commandSender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
if(commandSender.hasPermission(PlayerPermsEnum.FINDITEM_HIDESHOP.value()) && !FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_REMOVE_HIDE_REVEAL_SUBCMDS) {
if(args[0].equalsIgnoreCase(hideSubCommand)) {
cmdExecutor.handleHideShop(commandSender);
} else if(args[0].equalsIgnoreCase(revealShopSubCommand)) {
@@ -88,7 +88,7 @@ public class FindItemCmdReremakeImpl implements CommandHandler<Player> {
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
}
// hide
if(sender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
if(sender.hasPermission(PlayerPermsEnum.FINDITEM_HIDESHOP.value()) && !FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_REMOVE_HIDE_REVEAL_SUBCMDS) {
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE);
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE);
}
@@ -14,7 +14,7 @@ import java.util.List;
/**
* Sub Command Handler for /finditem TO_BUY
* @author ronsane
* @author myzticbean
*/
public class BuySubCmd extends SubCommand {
@@ -11,7 +11,7 @@ import java.util.List;
/**
* Sub Command Handler for /finditem hideshop
* @author ronsane
* @author myzticbean
*/
public class HideShopSubCmd extends SubCommand {
@@ -9,7 +9,7 @@ import java.util.List;
/**
* Sub Command Handler for /finditemadmin reload
* @author ronsane
* @author myzticbean
*/
public class ReloadSubCmd extends SubCommand {
@@ -10,7 +10,7 @@ import java.util.List;
/**
* Sub Command Handler for /finditem restart
* @deprecated No longer used, will be removed in future versions
* @author ronsane
* @author myzticbean
*/
@Deprecated
public class RestartSubCmd extends SubCommand {
@@ -11,7 +11,7 @@ import java.util.List;
/**
* Sub Command Handler for /finditemadmin revealshop
* @author ronsane
* @author myzticbean
*/
public class RevealShopSubCmd extends SubCommand {
@@ -14,7 +14,7 @@ import java.util.List;
/**
* Sub Command Handler for /finditem TO_SELL
* @author ronsane
* @author myzticbean
*/
public class SellSubCmd extends SubCommand {
@@ -10,34 +10,47 @@ import java.util.List;
public class ConfigProvider {
private static final String FIND_ITEM_COMMAND = "find-item-command.";
private static final String PLAYER_SHOP_TELEPORTATION = "player-shop-teleportation.";
private static final String DIRECT_SHOP_TP_MODE = "direct-shop-tp-mode.";
private static final String NEAREST_WARP_TP_MODE = "nearest-warp-tp-mode.";
private static final String SHOP_GUI = "shop-gui.";
private static final String SHOP_GUI_NAVIGATION = "shop-navigation.";
private static final String SHOP_GUI_CMD = "custom-model-data.";
public final String PLUGIN_PREFIX = ColorTranslator.translateColorCodes(ConfigSetup.get().getString("plugin-prefix"));
public final List<String> FIND_ITEM_COMMAND_ALIAS = (List<String>) ConfigSetup.get().getList("find-item-command.command-alias");
public final String FIND_ITEM_TO_BUY_AUTOCOMPLETE = ConfigSetup.get().getString("find-item-command.to-buy-autocomplete");
public final String FIND_ITEM_TO_SELL_AUTOCOMPLETE = ConfigSetup.get().getString("find-item-command.to-sell-autocomplete");
public final String FIND_ITEM_HIDESHOP_AUTOCOMPLETE = ConfigSetup.get().getString("find-item-command.hideshop-autocomplete");
public final String FIND_ITEM_REVEALSHOP_AUTOCOMPLETE = ConfigSetup.get().getString("find-item-command.revealshop-autocomplete");
public final String FIND_ITEM_CMD_INCORRECT_USAGE_MSG = ConfigSetup.get().getString("find-item-command.incorrect-usage-message");
public final String FIND_ITEM_CMD_INVALID_MATERIAL_MSG = ConfigSetup.get().getString("find-item-command.invalid-material-message");
public final String FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG = ConfigSetup.get().getString("find-item-command.hiding-shop-owner-invalid-message");
public final String SHOP_SEARCH_LOADING_MSG = ConfigSetup.get().getString("find-item-command.shop-search-loading-message");
public final String NO_SHOP_FOUND_MSG = ConfigSetup.get().getString("find-item-command.no-shop-found-message");
public final String FIND_ITEM_CMD_NO_PERMISSION_MSG = ConfigSetup.get().getString("find-item-command.find-item-command-no-permission-message");
public final String FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG = ConfigSetup.get().getString("find-item-command.shop-hide-success-message");
public final String FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG = ConfigSetup.get().getString("find-item-command.shop-reveal-success-message");
public final String FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG = ConfigSetup.get().getString("find-item-command.shop-already-hidden-message");
public final String FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG = ConfigSetup.get().getString("find-item-command.shop-already-public-message");
public final String FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG = ConfigSetup.get().getString("find-item-command.invalid-shop-block-message");
public final List<String> FIND_ITEM_COMMAND_ALIAS = (List<String>) ConfigSetup.get().getList(FIND_ITEM_COMMAND + "command-alias");
public final String FIND_ITEM_TO_BUY_AUTOCOMPLETE = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "to-buy-autocomplete");
public final String FIND_ITEM_TO_SELL_AUTOCOMPLETE = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "to-sell-autocomplete");
public final String FIND_ITEM_HIDESHOP_AUTOCOMPLETE = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "hideshop-autocomplete");
public final String FIND_ITEM_REVEALSHOP_AUTOCOMPLETE = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "revealshop-autocomplete");
public final String FIND_ITEM_CMD_INCORRECT_USAGE_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "incorrect-usage-message");
public final String FIND_ITEM_CMD_INVALID_MATERIAL_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "invalid-material-message");
public final String SHOP_SEARCH_LOADING_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "shop-search-loading-message");
public final String NO_SHOP_FOUND_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "no-shop-found-message");
public final String FIND_ITEM_CMD_NO_PERMISSION_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "find-item-command-no-permission-message");
public final String FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "shop-hide-success-message");
public final String FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "shop-reveal-success-message");
public final String FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "shop-already-hidden-message");
public final String FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "shop-already-public-message");
public final String FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "invalid-shop-block-message");
public final String FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG = ConfigSetup.get().getString(FIND_ITEM_COMMAND + "hiding-shop-owner-invalid-message");
public final boolean FIND_ITEM_CMD_REMOVE_HIDE_REVEAL_SUBCMDS = ConfigSetup.get().getBoolean(FIND_ITEM_COMMAND + "remove-hideshop-revealshop-subcommands");
public final boolean FIND_ITEM_CMD_DISABLE_SEARCH_ALL_SHOPS = ConfigSetup.get().getBoolean(FIND_ITEM_COMMAND + "disable-search-all-shops");
public final int SHOP_SORTING_METHOD = ConfigSetup.get().getInt("shop-sorting-method");
public final boolean SEARCH_LOADED_SHOPS_ONLY = ConfigSetup.get().getBoolean("search-loaded-shops-only");
public final String SHOP_SEARCH_GUI_TITLE = ConfigSetup.get().getString("shop-search-gui-title");
public final int NEAREST_WARP_MODE = ConfigSetup.get().getInt("nearest-warp-mode");
public final List<String> SHOP_GUI_ITEM_LORE = (List<String>) ConfigSetup.get().getList("shop-gui-item-lore");
public final boolean TP_PLAYER_DIRECTLY_TO_SHOP = ConfigSetup.get().getBoolean("player-shop-teleportation.direct-shop-tp-mode.tp-player-directly-to-shop");
public final String CLICK_TO_TELEPORT_MSG = ConfigSetup.get().getString("player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message");
public final String SHOP_TP_NO_PERMISSION_MSG = ConfigSetup.get().getString("player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message");
public final String UNSAFE_SHOP_AREA_MSG = ConfigSetup.get().getString("player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message");
public final boolean TP_PLAYER_TO_NEAREST_WARP = ConfigSetup.get().getBoolean("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp");
public final String SHOP_GUI_BACK_BUTTON_MATERIAL = ConfigSetup.get().getString("shop-gui-back-button-material");
public final boolean TP_PLAYER_DIRECTLY_TO_SHOP = ConfigSetup.get().getBoolean(PLAYER_SHOP_TELEPORTATION + DIRECT_SHOP_TP_MODE + " tp-player-directly-to-shop");
public final String CLICK_TO_TELEPORT_MSG = ConfigSetup.get().getString(PLAYER_SHOP_TELEPORTATION + DIRECT_SHOP_TP_MODE + "click-to-teleport-message");
public final String SHOP_TP_NO_PERMISSION_MSG = ConfigSetup.get().getString(PLAYER_SHOP_TELEPORTATION + DIRECT_SHOP_TP_MODE + "shop-tp-no-permission-message");
public final String UNSAFE_SHOP_AREA_MSG = ConfigSetup.get().getString(PLAYER_SHOP_TELEPORTATION + DIRECT_SHOP_TP_MODE + "unsafe-shop-area-message");
public final String TP_DELAY_IN_SECONDS = ConfigSetup.get().getString(PLAYER_SHOP_TELEPORTATION + DIRECT_SHOP_TP_MODE + "tp-delay-in-seconds");
public final String TP_DELAY_MESSAGE = ConfigSetup.get().getString(PLAYER_SHOP_TELEPORTATION + DIRECT_SHOP_TP_MODE + "tp-delay-message");
public final String TP_TO_OWN_SHOP_NO_PERMISSION_MESSAGE = ConfigSetup.get().getString(PLAYER_SHOP_TELEPORTATION + DIRECT_SHOP_TP_MODE + "tp-to-own-shop-no-permission-message");
public final boolean TP_PLAYER_TO_NEAREST_WARP = ConfigSetup.get().getBoolean(PLAYER_SHOP_TELEPORTATION + NEAREST_WARP_TP_MODE + "tp-player-to-nearest-warp");
public final boolean DO_NOT_TP_IF_PLAYER_WARP_LOCKED = ConfigSetup.get().getBoolean(PLAYER_SHOP_TELEPORTATION + NEAREST_WARP_TP_MODE + "do-not-tp-if-warp-locked");
/*public final String SHOP_GUI_BACK_BUTTON_MATERIAL = ConfigSetup.get().getString("shop-gui-back-button-material");
public final String SHOP_GUI_BACK_BUTTON_TEXT = ConfigSetup.get().getString("shop-gui-back-button-text");
public final String SHOP_GUI_NEXT_BUTTON_MATERIAL = ConfigSetup.get().getString("shop-gui-next-button-material");
public final String SHOP_GUI_NEXT_BUTTON_TEXT = ConfigSetup.get().getString("shop-gui-next-button-text");
@@ -49,7 +62,33 @@ public class ConfigProvider {
public final String SHOP_GUI_CLOSE_BUTTON_CMD = ConfigSetup.get().getString("shop-gui-close-button-custom-model-data");
public final String SHOP_NAV_FIRST_PAGE_ALERT_MSG = ConfigSetup.get().getString("shop-navigation-first-page-alert-message");
public final String SHOP_NAV_LAST_PAGE_ALERT_MSG = ConfigSetup.get().getString("shop-navigation-last-page-alert-message");
public final String SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_MATERIAL = ConfigSetup.get().getString("shop-gui-goto-first-page-button-material");
public final String SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_TEXT = ConfigSetup.get().getString("shop-gui-goto-first-page-button-text");
public final String SHOP_GUI_GOTO_LAST_PAGE_BUTTON_MATERIAL = ConfigSetup.get().getString("shop-gui-goto-last-page-button-material");
public final String SHOP_GUI_GOTO_LAST_PAGE_BUTTON_TEXT = ConfigSetup.get().getString("shop-gui-goto-last-page-button-text");
public final String SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_CMD = ConfigSetup.get().getString("shop-gui-goto-first-page-button-custom-model-data");
public final String SHOP_GUI_GOTO_LAST_PAGE_BUTTON_CMD = ConfigSetup.get().getString("shop-gui-goto-last-page-button-custom-model-data");*/
public final String SHOP_GUI_BACK_BUTTON_MATERIAL = ConfigSetup.get().getString(SHOP_GUI + "back-button-material");
public final String SHOP_GUI_BACK_BUTTON_TEXT = ConfigSetup.get().getString(SHOP_GUI + "back-button-text");
public final String SHOP_GUI_NEXT_BUTTON_MATERIAL = ConfigSetup.get().getString(SHOP_GUI + "next-button-material");
public final String SHOP_GUI_NEXT_BUTTON_TEXT = ConfigSetup.get().getString(SHOP_GUI + "next-button-text");
public final String SHOP_GUI_FILLER_ITEM = ConfigSetup.get().getString(SHOP_GUI + "filler-item");
public final String SHOP_GUI_CLOSE_BUTTON_MATERIAL = ConfigSetup.get().getString(SHOP_GUI + "close-button-material");
public final String SHOP_GUI_CLOSE_BUTTON_TEXT = ConfigSetup.get().getString(SHOP_GUI + "close-button-text");
public final String SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_MATERIAL = ConfigSetup.get().getString(SHOP_GUI + "goto-first-page-button-material");
public final String SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_TEXT = ConfigSetup.get().getString(SHOP_GUI + "goto-first-page-button-text");
public final String SHOP_GUI_GOTO_LAST_PAGE_BUTTON_MATERIAL = ConfigSetup.get().getString(SHOP_GUI + "goto-last-page-button-material");
public final String SHOP_GUI_GOTO_LAST_PAGE_BUTTON_TEXT = ConfigSetup.get().getString(SHOP_GUI + "goto-last-page-button-text");
public final String SHOP_GUI_BACK_BUTTON_CMD = ConfigSetup.get().getString(SHOP_GUI + SHOP_GUI_CMD + "back-button-custom-model-data");
public final String SHOP_GUI_NEXT_BUTTON_CMD = ConfigSetup.get().getString(SHOP_GUI + SHOP_GUI_CMD + "next-button-custom-model-data");
public final String SHOP_GUI_CLOSE_BUTTON_CMD = ConfigSetup.get().getString(SHOP_GUI + SHOP_GUI_CMD + "close-button-custom-model-data");
public final String SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_CMD = ConfigSetup.get().getString(SHOP_GUI + SHOP_GUI_CMD + "goto-first-page-button-custom-model-data");
public final String SHOP_GUI_GOTO_LAST_PAGE_BUTTON_CMD = ConfigSetup.get().getString(SHOP_GUI + SHOP_GUI_CMD + "goto-last-page-button-custom-model-data");
public final String SHOP_NAV_FIRST_PAGE_ALERT_MSG = ConfigSetup.get().getString(SHOP_GUI + SHOP_GUI_NAVIGATION + "first-page-alert-message");
public final String SHOP_NAV_LAST_PAGE_ALERT_MSG = ConfigSetup.get().getString(SHOP_GUI + SHOP_GUI_NAVIGATION + "last-page-alert-message");
public final boolean SHOP_GUI_USE_SHORTER_CURRENCY_FORMAT = ConfigSetup.get().getBoolean(SHOP_GUI + "use-shorter-currency-format");
public final int SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES = ConfigSetup.get().getInt("shop-player-visit-cooldown-in-minutes");
public final boolean IGNORE_EMPTY_CHESTS = ConfigSetup.get().getBoolean("ignore-empty-chests");
public final List<String> BLACKLISTED_WORLDS = (List<String>) ConfigSetup.get().getList("blacklisted-worlds");
public final boolean DEBUG_MODE = ConfigSetup.get().getBoolean("debug-mode");
public final int CONFIG_VERSION = ConfigSetup.get().getInt("config-version");
@@ -15,7 +15,7 @@ public class ConfigSetup {
private static File configFile;
private static File sampleConfigFile;
private static FileConfiguration configFileConfiguration;
private static final int CURRENT_CONFIG_VERSION = 11;
private static final int CURRENT_CONFIG_VERSION = 15;
public static void setupConfig() {
configFile = new File(FindItemAddOn.getInstance().getDataFolder(), "config.yml");
@@ -114,6 +114,7 @@ public class ConfigSetup {
configFileConfiguration.set("config-version", CURRENT_CONFIG_VERSION);
}
else {
// Automatic Config upgrade process
// Config v10
if(configFileConfiguration.getInt("config-version") < 10) {
boolean allowDirectShopTp = configFileConfiguration.getBoolean("allow-direct-shop-tp");
@@ -171,11 +172,105 @@ public class ConfigSetup {
// Add option to configure player visit cooldown
configFileConfiguration.set("shop-player-visit-cooldown-in-minutes", 5);
}
boolean userDefinedDebugMode = configFileConfiguration.getBoolean("debug-mode");
configFileConfiguration.set("debug-mode", null);
configFileConfiguration.set("debug-mode", userDefinedDebugMode);
configFileConfiguration.set("config-version", null);
configFileConfiguration.set("config-version", CURRENT_CONFIG_VERSION);
// Config 12
if(configFileConfiguration.getInt("config-version") < 12) {
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.tp-delay-in-seconds", 0);
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.tp-delay-message", "&6You will be teleported in &c{DELAY} &6seconds...");
}
// Config 13
if(configFileConfiguration.getInt("config-version") < 13) {
configFileConfiguration.set("find-item-command.remove-hideshop-revealshop-subcommands", false);
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.tp-to-own-shop-no-permission-message", "&cYou cannot teleport to your own shop!");
configFileConfiguration.set("ignore-empty-chests", true);
configFileConfiguration.set("shop-gui-goto-first-page-button-material", "");
configFileConfiguration.set("shop-gui-goto-first-page-button-text", "&7&l« &cGo to First Page");
configFileConfiguration.set("shop-gui-goto-first-page-button-custom-model-data", "");
configFileConfiguration.set("shop-gui-goto-last-page-button-material", "");
configFileConfiguration.set("shop-gui-goto-last-page-button-text", "&aGo to Last Page &7&l»");
configFileConfiguration.set("shop-gui-goto-last-page-button-custom-model-data", "");
}
// Config 14
if(configFileConfiguration.getInt("config-version") < 14) {
configFileConfiguration.set("find-item-command.disable-search-all-shops", false);
}
// Config 15
if(configFileConfiguration.getInt("config-version") < 15) {
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.do-not-tp-if-warp-locked", true);
// capture old config data
String shopGuiBackButtonMaterial = configFileConfiguration.getString("shop-gui-back-button-material");
String shopGuiBackButtonText = configFileConfiguration.getString("shop-gui-back-button-text");
String shopGuiNextButtonMaterial = configFileConfiguration.getString("shop-gui-next-button-material");
String shopGuiNNextButtonText = configFileConfiguration.getString("shop-gui-next-button-text");
String shopGuiFillerItem = configFileConfiguration.getString("shop-gui-filler-item");
String shopGuiCloseButtonMaterial = configFileConfiguration.getString("shop-gui-close-button-material");
String shopGuiCloseButtonText = configFileConfiguration.getString("shop-gui-close-button-text");
String shopGuiGotoFirstPageButtonMaterial = configFileConfiguration.getString("shop-gui-goto-first-page-button-material");
String shopGuiGotoFirstPageButtonText = configFileConfiguration.getString("shop-gui-goto-first-page-button-text");
String shopGuiGotoLastPageButtonMaterial = configFileConfiguration.getString("shop-gui-goto-last-page-button-material");
String shopGuiGotoLastPageButtonText = configFileConfiguration.getString("shop-gui-goto-last-page-button-text");
String shopNavFirstPageAlertMsg = configFileConfiguration.getString("shop-navigation-first-page-alert-message");
String shopNavLastPageAlertMsg = configFileConfiguration.getString("shop-navigation-last-page-alert-message");
String shopGuiBackButtonCMD = configFileConfiguration.getString("shop-gui-back-button-custom-model-data");
String shopGuiNextButtonCMD = configFileConfiguration.getString("shop-gui-next-button-custom-model-data");
String shopGuiCloseButtonCMD = configFileConfiguration.getString("shop-gui-close-button-custom-model-data");
String shopGuiGotoFirstPageButtonCMD = configFileConfiguration.getString("shop-gui-goto-first-page-button-custom-model-data");
String shopGuiGotoLastPageButtonCMD = configFileConfiguration.getString("shop-gui-goto-last-page-button-custom-model-data");
// remove old config options
configFileConfiguration.set("shop-gui-back-button-material", null);
configFileConfiguration.set("shop-gui-back-button-text", null);
configFileConfiguration.set("shop-gui-next-button-material", null);
configFileConfiguration.set("shop-gui-next-button-text", null);
configFileConfiguration.set("shop-gui-filler-item", null);
configFileConfiguration.set("shop-gui-close-button-material", null);
configFileConfiguration.set("shop-gui-close-button-text", null);
configFileConfiguration.set("shop-gui-goto-first-page-button-material", null);
configFileConfiguration.set("shop-gui-goto-first-page-button-text", null);
configFileConfiguration.set("shop-gui-goto-last-page-button-material", null);
configFileConfiguration.set("shop-gui-goto-last-page-button-text", null);
configFileConfiguration.set("shop-navigation-first-page-alert-message", null);
configFileConfiguration.set("shop-navigation-last-page-alert-message", null);
configFileConfiguration.set("shop-gui-back-button-custom-model-data", null);
configFileConfiguration.set("shop-gui-next-button-custom-model-data", null);
configFileConfiguration.set("shop-gui-close-button-custom-model-data", null);
configFileConfiguration.set("shop-navigation-first-page-button-custom-model-data", null);
configFileConfiguration.set("shop-navigation-last-page-button-custom-model-data", null);
configFileConfiguration.set("shop-gui-goto-first-page-button-custom-model-data", null);
configFileConfiguration.set("shop-gui-goto-last-page-button-custom-model-data", null);
// add the new config properties and transfer the data
final String SHOP_GUI_OPTION = "shop-gui.";
final String SHOP_GUI_NAVIGATION_OPTION = "shop-navigation.";
final String SHOP_GUI_CMD_OPTION = "custom-model-data.";
configFileConfiguration.set(SHOP_GUI_OPTION + "back-button-material", shopGuiBackButtonMaterial);
configFileConfiguration.set(SHOP_GUI_OPTION + "back-button-text", shopGuiBackButtonText);
configFileConfiguration.set(SHOP_GUI_OPTION + "next-button-material", shopGuiNextButtonMaterial);
configFileConfiguration.set(SHOP_GUI_OPTION + "next-button-text", shopGuiNNextButtonText);
configFileConfiguration.set(SHOP_GUI_OPTION + "filler-item", shopGuiFillerItem);
configFileConfiguration.set(SHOP_GUI_OPTION + "close-button-material", shopGuiCloseButtonMaterial);
configFileConfiguration.set(SHOP_GUI_OPTION + "close-button-text", shopGuiCloseButtonText);
configFileConfiguration.set(SHOP_GUI_OPTION + "goto-first-page-button-material", shopGuiGotoFirstPageButtonMaterial);
configFileConfiguration.set(SHOP_GUI_OPTION + "goto-first-page-button-text", shopGuiGotoFirstPageButtonText);
configFileConfiguration.set(SHOP_GUI_OPTION + "goto-last-page-button-material", shopGuiGotoLastPageButtonMaterial);
configFileConfiguration.set(SHOP_GUI_OPTION + "goto-last-page-button-text", shopGuiGotoLastPageButtonText);
configFileConfiguration.set(SHOP_GUI_OPTION + SHOP_GUI_NAVIGATION_OPTION + "first-page-alert-message", shopNavFirstPageAlertMsg);
configFileConfiguration.set(SHOP_GUI_OPTION + SHOP_GUI_NAVIGATION_OPTION + "last-page-alert-message", shopNavLastPageAlertMsg);
configFileConfiguration.set(SHOP_GUI_OPTION + SHOP_GUI_CMD_OPTION + "back-button-custom-model-data", shopGuiBackButtonCMD);
configFileConfiguration.set(SHOP_GUI_OPTION + SHOP_GUI_CMD_OPTION + "next-button-custom-model-data", shopGuiNextButtonCMD);
configFileConfiguration.set(SHOP_GUI_OPTION + SHOP_GUI_CMD_OPTION + "close-button-custom-model-data", shopGuiCloseButtonCMD);
configFileConfiguration.set(SHOP_GUI_OPTION + SHOP_GUI_CMD_OPTION + "goto-first-page-button-custom-model-data", shopGuiGotoFirstPageButtonCMD);
configFileConfiguration.set(SHOP_GUI_OPTION + SHOP_GUI_CMD_OPTION + "goto-last-page-button-custom-model-data", shopGuiGotoLastPageButtonCMD);
configFileConfiguration.set(SHOP_GUI_OPTION + "use-shorter-currency-format", false);
}
// AT LAST
// Moving debug-mode and config-version to the last
final String DEBUG_MODE_OPTION = "debug-mode";
final String CONFIG_VERSION_OPTION = "config-version";
boolean userDefinedDebugMode = configFileConfiguration.getBoolean(DEBUG_MODE_OPTION);
configFileConfiguration.set(DEBUG_MODE_OPTION, null);
configFileConfiguration.set(DEBUG_MODE_OPTION, userDefinedDebugMode);
configFileConfiguration.set(CONFIG_VERSION_OPTION, null);
configFileConfiguration.set(CONFIG_VERSION_OPTION, CURRENT_CONFIG_VERSION);
}
}
@@ -191,20 +286,6 @@ public class ConfigSetup {
* Added in 2.0
*/
public static void copySampleConfig() {
FindItemAddOn.getInstance().saveResource("sample-config.yml", true);
// sampleConfigFile = new File(FindItemAddOn.getInstance().getDataFolder(), "sample-config.yml");
// if(!sampleConfigFile.exists()) {
// try {
// boolean isConfigGenerated = sampleConfigFile.createNewFile();
// if(isConfigGenerated) {
// LoggerUtils.logInfo("Generated a new config.yml");
// }
// }
// catch (IOException e) {
// LoggerUtils.logError("Error generating config.yml");
// }
// }
}
}
@@ -11,7 +11,7 @@ import java.util.List;
/**
* Hook for EssentialsX Plugin
* @author ronsane
* @author myzticbean
*/
public class EssentialsXPlugin {
@@ -38,7 +38,8 @@ public class EssentialsXPlugin {
public static List<EssentialWarpModel> getAllWarps() { return allWarpsList; }
public static void updateAllWarps() {
LoggerUtils.logInfo("Updating Essentials warps list...");
long start = System.currentTimeMillis();
// LoggerUtils.logInfo("Updating Essentials warps list...");
if(essAPI.isEnabled()) {
Collection<String> allWarps = EssentialsXPlugin.getAPI().getWarps().getList();
allWarpsList = new ArrayList<>();
@@ -51,7 +52,7 @@ public class EssentialsXPlugin {
} catch (Exception ignored) { }
});
}
LoggerUtils.logInfo("Update complete! Found " + getAllWarps().size() + " warps.");
LoggerUtils.logInfo("Update complete for Essentials warps list! Found " + getAllWarps().size() + " warps. Time took: " + (System.currentTimeMillis() - start) + "ms.");
}
}
@@ -1,8 +1,10 @@
package io.myzticbean.finditemaddon.Dependencies;
import com.olziedev.playerwarps.api.PlayerWarpsAPI;
import com.olziedev.playerwarps.api.events.warp.PlayerWarpTeleportEvent;
import com.olziedev.playerwarps.api.warp.Warp;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Utils.Defaults.NearestWarpModeEnum;
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -48,18 +50,19 @@ public class PlayerWarpsPlugin {
public static void updateAllWarpsFromAPI() {
if(isEnabled) {
LoggerUtils.logInfo("Updating Player warps list...");
long start = System.currentTimeMillis();
// LoggerUtils.logInfo("Updating Player warps list...");
// Issue #24 Fix: Changing api instance to callback
PlayerWarpsAPI.getInstance(api -> {
allWarpsList = api.getPlayerWarps(false);
LoggerUtils.logInfo("Update complete! Found " + getAllWarps().size() + " warps.");
LoggerUtils.logInfo("Update complete for PlayerWarps list! Found " + getAllWarps().size() + " warps. Time took: " + (System.currentTimeMillis() - start) + "ms.");
});
}
}
public static void updateWarpsOnEventCall(Warp warp, boolean isRemoved) {
LoggerUtils.logDebugInfo("Got a PlayerWarps event call... checking nearest-warp-mode");
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 2) {
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == NearestWarpModeEnum.PLAYER_WARPS.value()) {
LoggerUtils.logDebugInfo("'nearest-warp-mode' found set to 2");
if (getIsEnabled()) {
LoggerUtils.logDebugInfo("PlayerWarps plugin is enabled");
@@ -109,13 +112,20 @@ public class PlayerWarpsPlugin {
*/
public static void executeWarpPlayer(Player player, String warpName) {
PlayerWarpsAPI.getInstance(api -> {
Warp playerWarp = api.getPlayerWarp(warpName);
Warp playerWarp = api.getPlayerWarp(warpName, player);
if(playerWarp != null) {
playerWarp.getWarpLocation().teleportWarp(player);
playerWarp.getWarpLocation().teleportWarp(player, PlayerWarpTeleportEvent.Cause.PLAYER_WARP_MENU);
}
else {
LoggerUtils.logError("&e" + player.getName() + " &cis trying to teleport to a PlayerWarp that does not exist!");
}
});
}
public static boolean isWarpLocked(Player player, String warpName) {
Warp warp = playerWarpsAPI.getPlayerWarp(warpName, player);
if(warp == null)
return false;
return warp.isWarpLocked();
}
}
@@ -13,7 +13,7 @@ import io.myzticbean.finditemaddon.QuickShopHandler.QSApi;
import io.myzticbean.finditemaddon.QuickShopHandler.QSHikariAPIHandler;
import io.myzticbean.finditemaddon.QuickShopHandler.QSReremakeAPIHandler;
import io.myzticbean.finditemaddon.ScheduledTasks.Task15MinInterval;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPermsEnum;
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
import io.myzticbean.finditemaddon.Utils.UpdateChecker;
@@ -26,19 +26,29 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
public final class FindItemAddOn extends JavaPlugin {
// ONLY FOR SNAPSHOT BUILDS
// Change it to whenever you want your snapshot trial build to expire
private static final boolean ENABLE_TRIAL_PERIOD = false;
private static final int TRIAL_END_YEAR = 2024, TRIAL_END_MONTH = 5, TRIAL_END_DAY = 5;
private static Plugin plugin;
public FindItemAddOn() { plugin = this; }
public static Plugin getInstance() { return plugin; }
public static String serverVersion;
private final static int BS_PLUGIN_METRIC_ID = 12382;
private final static int SPIGOT_PLUGIN_ID = 95104;
private final static int REPEATING_TASK_SCHEDULE_MINS = 15*60*20;
private static final int BS_PLUGIN_METRIC_ID = 12382;
private static final int SPIGOT_PLUGIN_ID = 95104;
private static final int REPEATING_TASK_SCHEDULE_MINS = 15*60*20;
private static ConfigProvider configProvider;
private static boolean isPluginOutdated = false;
private static boolean qSReremakeInstalled = false;
@@ -49,19 +59,32 @@ public final class FindItemAddOn extends JavaPlugin {
@Override
public void onLoad() {
LoggerUtils.logInfo("A Shop Search AddOn for QuickShop developed by ronsane");
LoggerUtils.logInfo("A Shop Search AddOn for QuickShop developed by myzticbean");
// Show warning if it's a snapshot build
if(this.getDescription().getVersion().toLowerCase().contains("snapshot")) {
LoggerUtils.logWarning("This is a SNAPSHOT build! NOT recommended for production servers.");
LoggerUtils.logWarning("If you find any bugs, please report them here: https://gitlab.com/ronsane/QSFindItemAddOn/-/issues");
LoggerUtils.logWarning("If you find any bugs, please report them here: https://github.com/myzticbean/QSFindItemAddOn/issues");
}
}
@Override
public void onEnable() {
if(ENABLE_TRIAL_PERIOD) {
LoggerUtils.logWarning("THIS IS A TRIAL BUILD!!!");
LocalDateTime trialEndDate = LocalDate.of(TRIAL_END_YEAR, TRIAL_END_MONTH, TRIAL_END_DAY).atTime(LocalTime.MIDNIGHT);
LocalDateTime today = LocalDateTime.now();
Duration duration = Duration.between(trialEndDate, today);
boolean hasPassed = Duration.ofDays(ChronoUnit.DAYS.between(today, trialEndDate)).isNegative();
if(hasPassed) {
LoggerUtils.logError("Your trial has expired! Please contact the developer.");
getServer().getPluginManager().disablePlugin(this);
return;
} else {
LoggerUtils.logWarning("You have " + Math.abs(duration.toDays()) + " days remaining in your trial.");
}
}
if(!Bukkit.getPluginManager().isPluginEnabled("QuickShop")
&& !Bukkit.getPluginManager().isPluginEnabled("QuickShop-Hikari")) {
LoggerUtils.logInfo("Delaying QuickShop hook as they are not enabled yet");
@@ -98,43 +121,23 @@ public final class FindItemAddOn extends JavaPlugin {
if(qsApi != null) {
ShopSearchActivityStorageUtil.saveShopsToFile();
}
else {
LoggerUtils.logError("Uh oh! Looks like either this plugin has crashed or you don't have QuickShop or QuickShop-Hikari installed.");
else if(!ENABLE_TRIAL_PERIOD) {
LoggerUtils.logError("Uh oh! Looks like either this plugin has crashed or you don't have QuickShop-Hikari or QuickShop-Reremake installed.");
}
LoggerUtils.logInfo("Bye!");
}
private void runPluginStartupTasks() {
// if(!Bukkit.getPluginManager().isPluginEnabled("QuickShop")
// && !Bukkit.getPluginManager().isPluginEnabled("QuickShop-Hikari")) {
// LoggerUtils.logError("QuickShop is required to use this addon. Please install QuickShop and try again!");
// LoggerUtils.logError("Both QuickShop-Reremake and QuickShop-Hikari are supported by this addon.");
// LoggerUtils.logError("Download links:");
// LoggerUtils.logError("» QuickShop-Reremake: https://www.spigotmc.org/resources/62575");
// LoggerUtils.logError("» QuickShop-Hikari: https://www.spigotmc.org/resources/100125");
// getServer().getPluginManager().disablePlugin(this);
// return;
// }
// else if(Bukkit.getPluginManager().isPluginEnabled("QuickShop")) {
// qSReremakeInstalled = true;
// qsApi = new QSReremakeAPIHandler();
// LoggerUtils.logInfo("Found QuickShop-Reremake");
// }
// else if(Bukkit.getPluginManager().isPluginEnabled("QuickShop-Hikari")) {
// qSHikariInstalled = true;
// qsApi = new QSHikariAPIHandler();
// LoggerUtils.logInfo("Found QuickShop-Hikari");
// }
serverVersion = Bukkit.getServer().getVersion();
LoggerUtils.logInfo("Server version found: " + serverVersion);
if(!isQSReremakeInstalled() && !isQSHikariInstalled()) {
LoggerUtils.logError("QuickShop is required to use this addon. Please install QuickShop and try again!");
LoggerUtils.logError("Both QuickShop-Reremake and QuickShop-Hikari are supported by this addon.");
LoggerUtils.logError("Both QuickShop-Hikari and QuickShop-Reremake are supported by this addon.");
LoggerUtils.logError("Download links:");
LoggerUtils.logError("» QuickShop-Reremake: https://www.spigotmc.org/resources/62575");
LoggerUtils.logError("» QuickShop-Hikari: https://www.spigotmc.org/resources/100125");
LoggerUtils.logError("» QuickShop-Reremake (Support ending soon): https://www.spigotmc.org/resources/62575");
getServer().getPluginManager().disablePlugin(this);
return;
}
@@ -151,7 +154,7 @@ public final class FindItemAddOn extends JavaPlugin {
// Load all hidden shops from file
ShopSearchActivityStorageUtil.loadShopsFromFile();
// v2.0.0 - Migrating hiddenShops.json to shops.json
// v2.0.0.0 - Migrating hiddenShops.json to shops.json
ShopSearchActivityStorageUtil.migrateHiddenShopsToShopsJson();
PlayerWarpsPlugin.setup();
@@ -243,6 +246,17 @@ public final class FindItemAddOn extends JavaPlugin {
else {
alias = FindItemAddOn.getConfigProvider().FIND_ITEM_COMMAND_ALIAS;
}
Class<? extends SubCommand>[] subCommands;
if(FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_REMOVE_HIDE_REVEAL_SUBCMDS) {
subCommands = new Class[] {
SellSubCmd.class, BuySubCmd.class
};
} else {
subCommands = new Class[] {
SellSubCmd.class, BuySubCmd.class, HideShopSubCmd.class, RevealShopSubCmd.class
};
}
// Register the subcommands under a core command
try {
CommandManager.createCoreCommand(
@@ -260,20 +274,14 @@ public final class FindItemAddOn extends JavaPlugin {
}
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#b3b300Command alias:"));
alias.forEach(alias_i -> {
commandSender.sendMessage(ColorTranslator.translateColorCodes("&8&l» &#2db300/" + alias_i));
});
alias.forEach(alias_i -> commandSender.sendMessage(ColorTranslator.translateColorCodes("&8&l» &#2db300/" + alias_i)));
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
},
alias,
SellSubCmd.class,
BuySubCmd.class,
HideShopSubCmd.class,
RevealShopSubCmd.class);
subCommands);
LoggerUtils.logInfo("Registered /finditem command");
} catch (NoSuchFieldException | IllegalAccessException e) {
LoggerUtils.logError(e.getMessage());
e.printStackTrace();
LoggerUtils.logError(e);
}
}
@@ -288,8 +296,8 @@ public final class FindItemAddOn extends JavaPlugin {
(commandSender, subCommandList) -> {
if (
(commandSender.isOp())
|| (!commandSender.isOp() && (commandSender.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())
|| commandSender.hasPermission(PlayerPerms.FINDITEM_RELOAD.value())))
|| (!commandSender.isOp() && (commandSender.hasPermission(PlayerPermsEnum.FINDITEM_ADMIN.value())
|| commandSender.hasPermission(PlayerPermsEnum.FINDITEM_RELOAD.value())))
) {
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
commandSender.sendMessage(ColorTranslator.translateColorCodes("&7-----------------------------"));
@@ -301,9 +309,7 @@ public final class FindItemAddOn extends JavaPlugin {
}
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#b3b300Command alias:"));
alias.forEach(alias_i -> {
commandSender.sendMessage(ColorTranslator.translateColorCodes("&8&l» &#2db300/" + alias_i));
});
alias.forEach(alias_i -> commandSender.sendMessage(ColorTranslator.translateColorCodes("&8&l» &#2db300/" + alias_i)));
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
}
},
@@ -311,8 +317,7 @@ public final class FindItemAddOn extends JavaPlugin {
ReloadSubCmd.class);
LoggerUtils.logInfo("Registered /finditemadmin command");
} catch (NoSuchFieldException | IllegalAccessException e) {
LoggerUtils.logError(e.getMessage());
e.printStackTrace();
LoggerUtils.logError(e);
}
}
@@ -4,7 +4,7 @@ import io.myzticbean.finditemaddon.ConfigUtil.ConfigSetup;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Handlers.GUIHandler.Menus.FoundShopsMenu;
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPermsEnum;
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.HiddenShopStorageUtil;
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
import io.myzticbean.finditemaddon.Utils.WarpUtils.WarpUtils;
@@ -22,7 +22,7 @@ import java.util.List;
/**
* Handler for different parameters of /finditem command
* @author ronsane
* @author myzticbean
*/
public class CmdExecutorHandler {
@@ -38,12 +38,15 @@ public class CmdExecutorHandler {
}
else {
Player player = (Player) commandSender;
if(player.hasPermission(PlayerPerms.FINDITEM_USE.value())) {
if(player.hasPermission(PlayerPermsEnum.FINDITEM_USE.value())) {
// Show searching... message
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_SEARCH_LOADING_MSG)) {
player.sendMessage(ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
+ FindItemAddOn.getConfigProvider().SHOP_SEARCH_LOADING_MSG));
}
boolean isBuying;
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " ")) {
@@ -53,27 +56,27 @@ public class CmdExecutorHandler {
isBuying = buySellSubCommand.equalsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
}
if(itemArg.equalsIgnoreCase("*")) {
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().fetchAllItemsFromAllShops(isBuying, player);
if(searchResultList.size() > 0) {
if(itemArg.equalsIgnoreCase("*") && !FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_DISABLE_SEARCH_ALL_SHOPS) {
// If QS Hikari installed and Shop Cache feature available (>6), then run in async thread (Fix for Issue #12)
if(!FindItemAddOn.isQSReremakeInstalled() && FindItemAddOn.getQsApiInstance().isQSShopCacheImplemented()) {
LoggerUtils.logDebugInfo("Should run in async thread...");
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().fetchAllItemsFromAllShops(isBuying, player);
if(!searchResultList.isEmpty()) {
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
}
else {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG)) {
player.sendMessage(ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG));
}
}
});
}
else {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG)) {
player.sendMessage(ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG));
}
}
}
else {
Material mat = Material.getMaterial(itemArg.toUpperCase());
if(mat != null) {
LoggerUtils.logDebugInfo("Material found: " + mat.toString());
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().findItemBasedOnTypeFromAllShops(new ItemStack(mat), isBuying, player);
if(searchResultList.size() > 0) {
} else {
// Else run in MAIN thread
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().fetchAllItemsFromAllShops(isBuying, player);
if(!searchResultList.isEmpty()) {
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
@@ -86,20 +89,74 @@ public class CmdExecutorHandler {
}
}
}
}
else {
Material mat = Material.getMaterial(itemArg.toUpperCase());
if(mat != null) {
LoggerUtils.logDebugInfo("Material found: " + mat);
// If QS Hikari installed and Shop Cache feature available (>6), then run in async thread (Fix for Issue #12)
if(!FindItemAddOn.isQSReremakeInstalled() && FindItemAddOn.getQsApiInstance().isQSShopCacheImplemented()) {
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().findItemBasedOnTypeFromAllShops(new ItemStack(mat), isBuying, player);
if(!searchResultList.isEmpty()) {
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
}
else {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG)) {
player.sendMessage(ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG));
}
}
});
} else {
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().findItemBasedOnTypeFromAllShops(new ItemStack(mat), isBuying, player);
if(!searchResultList.isEmpty()) {
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
});
}
else {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG)) {
player.sendMessage(ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG));
}
}
}
}
else {
LoggerUtils.logDebugInfo("Material not found! Performing query based search..");
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().findItemBasedOnDisplayNameFromAllShops(itemArg, isBuying, player);
if(searchResultList.size() > 0) {
// If QS Hikari installed and Shop Cache feature available (>6), then run in async thread (Fix for Issue #12)
if(!FindItemAddOn.isQSReremakeInstalled() && FindItemAddOn.getQsApiInstance().isQSShopCacheImplemented()) {
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().findItemBasedOnDisplayNameFromAllShops(itemArg, isBuying, player);
if(!searchResultList.isEmpty()) {
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
}
else {
// Invalid Material
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG)) {
player.sendMessage(ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG));
}
}
});
}
else {
// Invalid Material
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG)) {
player.sendMessage(ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG));
} else {
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().findItemBasedOnDisplayNameFromAllShops(itemArg, isBuying, player);
if(!searchResultList.isEmpty()) {
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
});
}
else {
// Invalid Material
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG)) {
player.sendMessage(ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG));
}
}
}
}
@@ -122,8 +179,9 @@ public class CmdExecutorHandler {
}
else {
Player player = (Player) commandSender;
if(player.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
Block playerLookAtBlock = player.getTargetBlock(null, 100);
if(player.hasPermission(PlayerPermsEnum.FINDITEM_HIDESHOP.value())) {
Block playerLookAtBlock = player.getTargetBlock(null, 3);
LoggerUtils.logDebugInfo("TargetBlock found: " + playerLookAtBlock.getType());
if(FindItemAddOn.isQSReremakeInstalled()) {
hideShop((Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
}
@@ -147,13 +205,18 @@ public class CmdExecutorHandler {
}
else {
Player player = (Player) commandSender;
if(player.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
Block playerLookAtBlock = player.getTargetBlock(null, 100);
if(FindItemAddOn.isQSReremakeInstalled()) {
revealShop((Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
}
else {
revealShop((com.ghostchu.quickshop.api.shop.Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
if(player.hasPermission(PlayerPermsEnum.FINDITEM_HIDESHOP.value())) {
Block playerLookAtBlock = player.getTargetBlock(null, 5);
if(playerLookAtBlock != null) {
LoggerUtils.logDebugInfo("TargetBlock found: " + playerLookAtBlock.getType());
if(FindItemAddOn.isQSReremakeInstalled()) {
revealShop((Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
}
else {
revealShop((com.ghostchu.quickshop.api.shop.Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
}
} else {
LoggerUtils.logDebugInfo("TargetBlock is null!");
}
}
else {
@@ -237,7 +300,7 @@ public class CmdExecutorHandler {
}
else {
Player player = (Player) commandSender;
if(player.hasPermission(PlayerPerms.FINDITEM_RELOAD.value()) || player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())) {
if(player.hasPermission(PlayerPermsEnum.FINDITEM_RELOAD.value()) || player.hasPermission(PlayerPermsEnum.FINDITEM_ADMIN.value())) {
ConfigSetup.reloadConfig();
ConfigSetup.checkForMissingProperties();
ConfigSetup.saveConfig();
@@ -262,9 +325,11 @@ public class CmdExecutorHandler {
}
/**
* @deprecated
* Handles plugin restart
* @param commandSender Who is the command sender: console or player
*/
@Deprecated(forRemoval = true)
public void handlePluginRestart(CommandSender commandSender) {
if (!(commandSender instanceof Player)) {
Bukkit.getPluginManager().disablePlugin(FindItemAddOn.getInstance());
@@ -280,7 +345,7 @@ public class CmdExecutorHandler {
}
else {
Player player = (Player) commandSender;
if(player.hasPermission(PlayerPerms.FINDITEM_RESTART.value()) || player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())) {
if(player.hasPermission(PlayerPermsEnum.FINDITEM_RESTART.value()) || player.hasPermission(PlayerPermsEnum.FINDITEM_ADMIN.value())) {
Bukkit.getPluginManager().disablePlugin(FindItemAddOn.getInstance());
Bukkit.getPluginManager().enablePlugin(FindItemAddOn.getPlugin(FindItemAddOn.class));
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&aPlugin restarted!"));
@@ -306,7 +371,7 @@ public class CmdExecutorHandler {
* @param shop
* @param player
*/
private void hideShop(Shop shop, Player player) {
private void hideShop(org.maxgamer.quickshop.api.shop.Shop shop, Player player) {
if(shop != null) {
// check if command runner same as shop owner
if(FindItemAddOn.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
@@ -13,8 +13,10 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
// Based on an awesome tutorial from https://www.youtube.com/watch?v=xebH6M_7k18
// Gui pagination: https://www.youtube.com/watch?v=e80NO9Pgz7s
/**
* Based on an awesome tutorial from https://www.youtube.com/watch?v=xebH6M_7k18
* Gui pagination: https://www.youtube.com/watch?v=e80NO9Pgz7s
*/
public abstract class Menu implements InventoryHolder {
protected Inventory inventory;
@@ -23,7 +25,7 @@ public abstract class Menu implements InventoryHolder {
protected ItemStack GUI_FILLER_ITEM;
public Menu(PlayerMenuUtility playerMenuUtility) {
protected Menu(PlayerMenuUtility playerMenuUtility) {
this.playerMenuUtility = playerMenuUtility;
assert FindItemAddOn.getConfigProvider().SHOP_GUI_FILLER_ITEM != null;
@@ -7,8 +7,9 @@ import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Handlers.GUIHandler.PaginatedMenu;
import io.myzticbean.finditemaddon.Handlers.GUIHandler.PlayerMenuUtility;
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
import io.myzticbean.finditemaddon.Utils.Defaults.ShopLorePlaceholders;
import io.myzticbean.finditemaddon.Utils.Defaults.NearestWarpModeEnum;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPermsEnum;
import io.myzticbean.finditemaddon.Utils.Defaults.ShopLorePlaceholdersEnum;
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
import io.myzticbean.finditemaddon.Utils.LocationUtils;
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
@@ -26,19 +27,19 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.*;
/**
* Handler class for FoundShops GUI
* @author ronsane
* @author myzticbean
*/
public class FoundShopsMenu extends PaginatedMenu {
private final String NO_WARP_NEAR_SHOP_ERROR_MSG = "No Warp near this shop";
private final String NO_WG_REGION_NEAR_SHOP_ERROR_MSG = "No WG Region near this shop";
public static final String SHOP_STOCK_UNLIMITED = "Unlimited";
public static final String SHOP_STOCK_UNKNOWN = "Unknown";
private static final String NO_WARP_NEAR_SHOP_ERROR_MSG = "No Warp near this shop";
private static final String NO_WG_REGION_NEAR_SHOP_ERROR_MSG = "No WG Region near this shop";
private static final String NAMEDSPACE_KEY_LOCATION_DATA = "locationData";
public FoundShopsMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
super(playerMenuUtility, searchResult);
@@ -61,32 +62,24 @@ public class FoundShopsMenu extends PaginatedMenu {
@Override
public void handleMenu(InventoryClickEvent event) {
// Previous Page
if(event.getSlot() == 45) {
if(page == 0) {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
event.getWhoClicked().sendMessage(
ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
+ FindItemAddOn.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG));
}
}
else {
page = page - 1;
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
}
handleMenuClickForNavToPrevPage(event);
}
// First Page
else if(event.getSlot() == 46) {
handleFirstPageClick(event);
}
// Last Page
else if(event.getSlot() == 52) {
handleLastPageClick(event);
}
// Next Page
else if(event.getSlot() == 53) {
if(!((index + 1) >= super.playerMenuUtility.getPlayerShopSearchResult().size())) {
page = page + 1;
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
}
else {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
event.getWhoClicked().sendMessage(
ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG));
}
}
handleMenuClickForNavToNextPage(event);
}
else if(event.getCurrentItem().getType().equals(Material.BARRIER) && event.getSlot() == 49) {
// Issue #31: Removing condition 'event.getCurrentItem().getType().equals(Material.BARRIER)'
else if(event.getSlot() == 49) {
event.getWhoClicked().closeInventory();
}
else if(event.getCurrentItem().getType().equals(Material.AIR)) {
@@ -97,76 +90,163 @@ public class FoundShopsMenu extends PaginatedMenu {
Player player = (Player) event.getWhoClicked();
ItemStack item = event.getCurrentItem();
ItemMeta meta = item.getItemMeta();
NamespacedKey key = new NamespacedKey(FindItemAddOn.getInstance(), "locationData");
NamespacedKey key = new NamespacedKey(FindItemAddOn.getInstance(), NAMEDSPACE_KEY_LOCATION_DATA);
if(!meta.getPersistentDataContainer().isEmpty() && meta.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
String locData = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING);
List<String> locDataList = Arrays.asList(locData.split("\\s*,\\s*"));
if(FindItemAddOn.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP) {
if(playerMenuUtility.getOwner().hasPermission(PlayerPerms.FINDITEM_SHOPTP.value())) {
if(playerMenuUtility.getOwner().hasPermission(PlayerPermsEnum.FINDITEM_SHOPTP.value())) {
World world = Bukkit.getWorld(locDataList.get(0));
int locX = Integer.parseInt(locDataList.get(1)), locY = Integer.parseInt(locDataList.get(2)), locZ = Integer.parseInt(locDataList.get(3));
int locX = Integer.parseInt(locDataList.get(1));
int locY = Integer.parseInt(locDataList.get(2));
int locZ = Integer.parseInt(locDataList.get(3));
Location shopLocation = new Location(world, locX, locY, locZ);
UUID shopOwner = ShopSearchActivityStorageUtil.getShopOwnerUUID(shopLocation);
if(player.getUniqueId().equals(shopOwner) && !PlayerPermsEnum.canPlayerTpToOwnShop(player)) {
player.sendMessage(ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG));
}
Location locToTeleport = LocationUtils.findSafeLocationAroundShop(shopLocation);
if(locToTeleport != null) {
// Add Player Visit Entry
ShopSearchActivityStorageUtil.addPlayerVisitEntryAsync(shopLocation, player);
// Add Short Blindness effect... maybe?
/**
* @// TODO: 16/06/22 Make this an option in config
*/
// player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 0, false, false, false));
// TODO: 16/06/22 Make this an option in config -> player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 0, false, false, false));
// Teleport
// If EssentialsX is enabled, register last location before teleporting to make /back work
if(EssentialsXPlugin.isEnabled()) {
EssentialsXPlugin.getAPI().getUser(player).setLastLocation();
}
PaperLib.teleportAsync(player, locToTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN);
// Check for TP delay
if(StringUtils.isNumeric(FindItemAddOn.getConfigProvider().TP_DELAY_IN_SECONDS)
&& !"0".equals(FindItemAddOn.getConfigProvider().TP_DELAY_IN_SECONDS)
&& !PlayerPermsEnum.hasShopTpDelayBypassPermOrAdmin(player)) {
long delay = Long.parseLong(FindItemAddOn.getConfigProvider().TP_DELAY_IN_SECONDS);
LoggerUtils.logDebugInfo("Teleporting delay is set to: " + delay);
String tpDelayMsg = FindItemAddOn.getConfigProvider().TP_DELAY_MESSAGE;
if(!StringUtils.isEmpty(tpDelayMsg)) {
player.sendMessage(
ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + replaceDelayPlaceholder(tpDelayMsg,delay)));
}
Bukkit.getScheduler().scheduleSyncDelayedTask(
FindItemAddOn.getInstance(),
() -> PaperLib.teleportAsync(player, locToTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN),
delay*20);
} else {
PaperLib.teleportAsync(player, locToTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN);
}
}
else {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().UNSAFE_SHOP_AREA_MSG)) {
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().UNSAFE_SHOP_AREA_MSG));
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
+ FindItemAddOn.getConfigProvider().UNSAFE_SHOP_AREA_MSG));
}
}
}
else {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG)) {
playerMenuUtility.getOwner()
.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG));
.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
+ FindItemAddOn.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG));
event.getWhoClicked().closeInventory();
}
}
player.closeInventory();
}
else if(FindItemAddOn.getConfigProvider().TP_PLAYER_TO_NEAREST_WARP) {
else if(FindItemAddOn.getConfigProvider().TP_PLAYER_TO_NEAREST_WARP
// if list size = 1, it contains Warp name
if(locDataList.size() == 1) {
String warpName = locDataList.get(0);
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 1) {
Bukkit.dispatchCommand(player, "essentials:warp " + warpName);
}
else if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 2) {
PlayerWarpsPlugin.executeWarpPlayer(player, warpName);
}
&& locDataList.size() == 1) {
String warpName = locDataList.get(0);
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 1) {
Bukkit.dispatchCommand(player, "essentials:warp " + warpName);
}
else if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 2) {
PlayerWarpsPlugin.executeWarpPlayer(player, warpName);
}
}
}
else {
LoggerUtils.logError("PersistentDataContainer doesn't have the right kind of data!");
return;
}
}
}
private void handleMenuClickForNavToNextPage(InventoryClickEvent event) {
if(!((index + 1) >= super.playerMenuUtility.getPlayerShopSearchResult().size())) {
page = page + 1;
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
}
else {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
event.getWhoClicked().sendMessage(
ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG));
}
}
}
private void handleMenuClickForNavToPrevPage(InventoryClickEvent event) {
if(page == 0) {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
event.getWhoClicked().sendMessage(
ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
+ FindItemAddOn.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG));
}
}
else {
page = page - 1;
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
}
}
private void handleFirstPageClick(InventoryClickEvent event) {
if(page == 0) {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
event.getWhoClicked().sendMessage(
ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
+ FindItemAddOn.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG));
}
} else {
page = 0;
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
}
}
private void handleLastPageClick(InventoryClickEvent event) {
int listSize = super.playerMenuUtility.getPlayerShopSearchResult().size();
if(!((index + 1) >= listSize)) {
double totalPages = listSize / maxItemsPerPage;
if(totalPages % 10 == 0) {
page = (int) Math.floor(totalPages);
LoggerUtils.logDebugInfo("Floor page value: " + page);
}
else {
page = (int) Math.ceil(totalPages);
LoggerUtils.logDebugInfo("Ceiling page value: " + page);
}
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
}
else {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
event.getWhoClicked().sendMessage(
ColorTranslator.translateColorCodes(
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
+ FindItemAddOn.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG));
}
}
}
/**
* Empty method in case we need to handle static GUI icons in future
*/
@Override
public void setMenuItems() {}
public void setMenuItems() {
// Just overriding
}
/**
* Sets the slots in the search result GUI
@@ -176,68 +256,70 @@ public class FoundShopsMenu extends PaginatedMenu {
public void setMenuItems(List<FoundShopItemModel> foundShops) {
addMenuBottomBar();
if(foundShops != null && !foundShops.isEmpty()) {
int guiSlotCounter = 0;
while(guiSlotCounter < super.maxItemsPerPage) {
index = super.maxItemsPerPage * page + guiSlotCounter;
if(index >= foundShops.size()) break;
int maxItemsPerPage = super.maxItemsPerPage;
for(int guiSlotCounter = 0; guiSlotCounter < maxItemsPerPage; guiSlotCounter++) {
index = maxItemsPerPage * page + guiSlotCounter;
if(index >= foundShops.size()) {
break;
}
if(foundShops.get(index) != null) {
// Place Search Results here
FoundShopItemModel foundShop_i = foundShops.get(index);
NamespacedKey key = new NamespacedKey(FindItemAddOn.getInstance(), "locationData");
ItemStack item = new ItemStack(foundShop_i.getItem().getType());
FoundShopItemModel foundShopIter = foundShops.get(index);
NamespacedKey key = new NamespacedKey(FindItemAddOn.getInstance(), NAMEDSPACE_KEY_LOCATION_DATA);
ItemStack item = new ItemStack(foundShopIter.getItem().getType());
ItemMeta meta = item.getItemMeta();
List<String> lore;
lore = new ArrayList<>();
List<String> lore = new ArrayList<>();
com.olziedev.playerwarps.api.warp.Warp nearestPlayerWarp = null;
String nearestEWarp = null;
if(foundShop_i.getItem().hasItemMeta()) {
meta = foundShop_i.getItem().getItemMeta();
if(foundShop_i.getItem().getItemMeta().hasLore()) {
for(String s : foundShop_i.getItem().getItemMeta().getLore()) {
// set shop item's lore first
if(foundShopIter.getItem().hasItemMeta()) {
meta = foundShopIter.getItem().getItemMeta();
if(meta.hasLore()) {
for(String s : meta.getLore()) {
lore.add(ColorTranslator.translateColorCodes(s));
}
}
}
List<String> shopItemLore = FindItemAddOn.getConfigProvider().SHOP_GUI_ITEM_LORE;
for(String shopItemLore_i : shopItemLore) {
if(shopItemLore_i.contains(ShopLorePlaceholders.NEAREST_WARP.value())) {
switch(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE) {
// now set the search related lore
int nearestWarpMode = FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE;
for(String shopItemLoreIter : shopItemLore) {
if(shopItemLoreIter.contains(ShopLorePlaceholdersEnum.NEAREST_WARP.value())) {
switch(nearestWarpMode) {
case 1:
// EssentialWarp: Check nearest warp
if(EssentialsXPlugin.isEnabled()) {
nearestEWarp = new EssentialWarpsUtil().findNearestWarp(foundShop_i.getShopLocation());
nearestEWarp = new EssentialWarpsUtil().findNearestWarp(foundShopIter.getShopLocation());
if(nearestEWarp != null && !StringUtils.isEmpty(nearestEWarp)) {
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), nearestEWarp)));
lore.add(ColorTranslator.translateColorCodes(shopItemLoreIter.replace(ShopLorePlaceholdersEnum.NEAREST_WARP.value(), nearestEWarp)));
}
else {
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), NO_WARP_NEAR_SHOP_ERROR_MSG)));
lore.add(ColorTranslator.translateColorCodes(shopItemLoreIter.replace(ShopLorePlaceholdersEnum.NEAREST_WARP.value(), NO_WARP_NEAR_SHOP_ERROR_MSG)));
}
}
break;
case 2:
// PlayerWarp: Check nearest warp
if(PlayerWarpsPlugin.getIsEnabled()) {
nearestPlayerWarp = new PlayerWarpsUtil().findNearestWarp(foundShop_i.getShopLocation());
nearestPlayerWarp = new PlayerWarpsUtil().findNearestWarp(foundShopIter.getShopLocation());
if(nearestPlayerWarp != null) {
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), nearestPlayerWarp.getWarpName())));
lore.add(ColorTranslator.translateColorCodes(shopItemLoreIter.replace(ShopLorePlaceholdersEnum.NEAREST_WARP.value(), nearestPlayerWarp.getWarpName())));
}
else {
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), NO_WARP_NEAR_SHOP_ERROR_MSG)));
lore.add(ColorTranslator.translateColorCodes(shopItemLoreIter.replace(ShopLorePlaceholdersEnum.NEAREST_WARP.value(), NO_WARP_NEAR_SHOP_ERROR_MSG)));
}
}
break;
case 3:
// WG Region: Check nearest WG Region
if(WGPlugin.isEnabled()) {
String nearestWGRegion = new WGRegionUtils().findNearestWGRegion((foundShop_i.getShopLocation()));
String nearestWGRegion = new WGRegionUtils().findNearestWGRegion((foundShopIter.getShopLocation()));
if(nearestWGRegion != null && !StringUtils.isEmpty(nearestWGRegion)) {
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), nearestWGRegion)));
lore.add(ColorTranslator.translateColorCodes(shopItemLoreIter.replace(ShopLorePlaceholdersEnum.NEAREST_WARP.value(), nearestWGRegion)));
}
else {
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), NO_WG_REGION_NEAR_SHOP_ERROR_MSG)));
lore.add(ColorTranslator.translateColorCodes(shopItemLoreIter.replace(ShopLorePlaceholdersEnum.NEAREST_WARP.value(), NO_WG_REGION_NEAR_SHOP_ERROR_MSG)));
}
}
break;
@@ -246,12 +328,12 @@ public class FoundShopsMenu extends PaginatedMenu {
}
}
else {
lore.add(ColorTranslator.translateColorCodes(replaceLorePlaceholders(shopItemLore_i, foundShop_i)));
lore.add(ColorTranslator.translateColorCodes(replaceLorePlaceholders(shopItemLoreIter, foundShopIter)));
}
}
if(FindItemAddOn.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP) {
if(playerMenuUtility.getOwner().hasPermission(PlayerPerms.FINDITEM_SHOPTP.value())) {
if(playerMenuUtility.getOwner().hasPermission(PlayerPermsEnum.FINDITEM_SHOPTP.value())) {
lore.add(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().CLICK_TO_TELEPORT_MSG));
}
}
@@ -262,35 +344,32 @@ public class FoundShopsMenu extends PaginatedMenu {
String locData = StringUtils.EMPTY;
// store the coordinates
if(FindItemAddOn.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP) {
locData = Objects.requireNonNull(foundShop_i.getShopLocation().getWorld()).getName() + ","
+ foundShop_i.getShopLocation().getBlockX() + ","
+ foundShop_i.getShopLocation().getBlockY() + ","
+ foundShop_i.getShopLocation().getBlockZ();
locData = Objects.requireNonNull(foundShopIter.getShopLocation().getWorld()).getName() + ","
+ foundShopIter.getShopLocation().getBlockX() + ","
+ foundShopIter.getShopLocation().getBlockY() + ","
+ foundShopIter.getShopLocation().getBlockZ();
}
else if(FindItemAddOn.getConfigProvider().TP_PLAYER_TO_NEAREST_WARP) {
// if Nearest Warp is set to EssentialsX Warps, store the warp name
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 1) {
if(nearestWarpMode == NearestWarpModeEnum.ESSENTIAL_WARPS.value()) {
if(nearestEWarp != null) {
locData = nearestEWarp;
}
}
// if Nearest Warp is set to PlayerWarps, store the warp name
else if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 2) {
if(nearestPlayerWarp != null) {
locData = nearestPlayerWarp.getWarpName();
}
else if(nearestWarpMode == NearestWarpModeEnum.PLAYER_WARPS.value() && nearestPlayerWarp != null) {
locData = nearestPlayerWarp.getWarpName();
}
}
meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, locData);
// handling custom model data
if(Objects.requireNonNull(foundShop_i.getItem().getItemMeta()).hasCustomModelData()) {
meta.setCustomModelData(foundShop_i.getItem().getItemMeta().getCustomModelData());
if(Objects.requireNonNull(foundShopIter.getItem().getItemMeta()).hasCustomModelData()) {
meta.setCustomModelData(foundShopIter.getItem().getItemMeta().getCustomModelData());
}
item.setItemMeta(meta);
inventory.addItem(item);
}
guiSlotCounter++;
}
}
}
@@ -303,40 +382,75 @@ public class FoundShopsMenu extends PaginatedMenu {
*/
private String replaceLorePlaceholders(String text, FoundShopItemModel shop) {
if(text.contains(ShopLorePlaceholders.ITEM_PRICE.value())) {
text = text.replace(ShopLorePlaceholders.ITEM_PRICE.value(), String.valueOf(shop.getShopPrice()));
if(text.contains(ShopLorePlaceholdersEnum.ITEM_PRICE.value())) {
text = text.replace(ShopLorePlaceholdersEnum.ITEM_PRICE.value(), formatNumber(shop.getShopPrice()));
}
if(text.contains(ShopLorePlaceholders.SHOP_STOCK.value())) {
if(shop.getRemainingStockOrSpace() == -1) {
text = text.replace(ShopLorePlaceholders.SHOP_STOCK.value(), "Unlimited");
}
else {
text = text.replace(ShopLorePlaceholders.SHOP_STOCK.value(), String.valueOf(shop.getRemainingStockOrSpace()));
if(text.contains(ShopLorePlaceholdersEnum.SHOP_STOCK.value())) {
if(shop.getRemainingStockOrSpace() == -2) {
// if -2 (cache doesn't have value) -> try to fetch from MAIN thread
int stockOrSpace = processUnknownStockSpace(shop);
if(stockOrSpace == -2) {
text = text.replace(ShopLorePlaceholdersEnum.SHOP_STOCK.value(), SHOP_STOCK_UNKNOWN);
}
else {
text = text.replace(ShopLorePlaceholdersEnum.SHOP_STOCK.value(),
(stockOrSpace == -1 ? SHOP_STOCK_UNLIMITED : String.valueOf(stockOrSpace)));
}
} else if(shop.getRemainingStockOrSpace() == Integer.MAX_VALUE) {
text = text.replace(ShopLorePlaceholdersEnum.SHOP_STOCK.value(), SHOP_STOCK_UNLIMITED);
} else {
text = text.replace(ShopLorePlaceholdersEnum.SHOP_STOCK.value(), String.valueOf(shop.getRemainingStockOrSpace()));
}
}
if(text.contains(ShopLorePlaceholders.SHOP_OWNER.value())) {
if(text.contains(ShopLorePlaceholdersEnum.SHOP_OWNER.value())) {
OfflinePlayer shopOwner = Bukkit.getOfflinePlayer(shop.getShopOwner());
if(shopOwner.getName() != null) {
text = text.replace(ShopLorePlaceholders.SHOP_OWNER.value(), shopOwner.getName());
text = text.replace(ShopLorePlaceholdersEnum.SHOP_OWNER.value(), shopOwner.getName());
}
else {
// set a generic name for shops with no owner name
text = text.replace(ShopLorePlaceholders.SHOP_OWNER.value(), "Admin");
text = text.replace(ShopLorePlaceholdersEnum.SHOP_OWNER.value(), "Admin");
}
}
if(text.contains(ShopLorePlaceholders.SHOP_LOCATION.value())) {
text = text.replace(ShopLorePlaceholders.SHOP_LOCATION.value(),
if(text.contains(ShopLorePlaceholdersEnum.SHOP_LOCATION.value())) {
text = text.replace(ShopLorePlaceholdersEnum.SHOP_LOCATION.value(),
shop.getShopLocation().getBlockX() + ", "
+ shop.getShopLocation().getBlockY() + ", "
+ shop.getShopLocation().getBlockZ());
}
if(text.contains(ShopLorePlaceholders.SHOP_WORLD.value())) {
text = text.replace(ShopLorePlaceholders.SHOP_WORLD.value(), Objects.requireNonNull(shop.getShopLocation().getWorld()).getName());
if(text.contains(ShopLorePlaceholdersEnum.SHOP_WORLD.value())) {
text = text.replace(ShopLorePlaceholdersEnum.SHOP_WORLD.value(), Objects.requireNonNull(shop.getShopLocation().getWorld()).getName());
}
// Added in v2.0
if(text.contains(ShopLorePlaceholders.SHOP_VISITS.value())) {
text = text.replace(ShopLorePlaceholders.SHOP_VISITS.value(), String.valueOf(ShopSearchActivityStorageUtil.getPlayerVisitCount(shop.getShopLocation())));
if(text.contains(ShopLorePlaceholdersEnum.SHOP_VISITS.value())) {
text = text.replace(ShopLorePlaceholdersEnum.SHOP_VISITS.value(), String.valueOf(ShopSearchActivityStorageUtil.getPlayerVisitCount(shop.getShopLocation())));
}
return text;
}
private int processUnknownStockSpace(FoundShopItemModel shop) {
return FindItemAddOn.getQsApiInstance().processUnknownStockSpace(shop.getShopLocation(), shop.isToBuy());
}
private String replaceDelayPlaceholder(String tpDelayMsg, long delay) {
return tpDelayMsg.replace("{DELAY}", String.valueOf(delay));
}
public static String formatNumber(double number) {
if(FindItemAddOn.getConfigProvider().SHOP_GUI_USE_SHORTER_CURRENCY_FORMAT) {
if (number < 100_000) {
return String.format("%,.2f", number);
} else if (number < 1_000_000) {
return String.format("%.2fK", number / 1_000.0);
} else if (number < 1_000_000_000) {
return String.format("%.2fM", number / 1_000_000.0);
} else if (number < 1_000_000_000_000L) {
return String.format("%.2fB", number / 1_000_000_000.0);
} else {
return String.format("%.2fT", number / 1_000_000_000_000.0);
}
} else {
return String.format("%,.2f", number);
}
}
}
@@ -15,22 +15,26 @@ import java.util.UUID;
public abstract class PaginatedMenu extends Menu {
protected int page = 0;
protected int maxItemsPerPage = 45;
protected final int maxItemsPerPage = 45;
protected int index = 0;
protected ItemStack backButton;
protected ItemStack firstPageButton;
protected ItemStack nextButton;
protected ItemStack lastPageButton;
protected ItemStack closeInvButton;
private final String BACK_BUTTON_SKIN_ID = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjZkYWI3MjcxZjRmZjA0ZDU0NDAyMTkwNjdhMTA5YjVjMGMxZDFlMDFlYzYwMmMwMDIwNDc2ZjdlYjYxMjE4MCJ9fX0=";
private final String FIRST_PAGE_BUTTON_SKIN_ID = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTI5M2E2MDcwNTAzMTcyMDcxZjM1ZjU4YzgyMjA0ZTgxOGNkMDY1MTg2OTAxY2ExOWY3ZGFkYmRhYzE2NWU0NCJ9fX0=";
private final String NEXT_BUTTON_SKIN_ID = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGFhMTg3ZmVkZTg4ZGUwMDJjYmQ5MzA1NzVlYjdiYTQ4ZDNiMWEwNmQ5NjFiZGM1MzU4MDA3NTBhZjc2NDkyNiJ9fX0=";
private final String LAST_PAGE_BUTTON_SKIN_ID = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWRhNDRjNzY3Y2NhMjU4NjFkM2E1MmZlMTdjMjY0MjhlNjYwZWUyM2RjMGQ3OTNiZjdiZDg2ZWEyMDJmNzAzZCJ9fX0=";
public PaginatedMenu(PlayerMenuUtility playerMenuUtility) {
protected PaginatedMenu(PlayerMenuUtility playerMenuUtility) {
super(playerMenuUtility);
initMaterialsForBottomBar();
}
public PaginatedMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
protected PaginatedMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
super(playerMenuUtility);
initMaterialsForBottomBar();
super.playerMenuUtility.setPlayerShopSearchResult(searchResult);
@@ -38,21 +42,23 @@ public abstract class PaginatedMenu extends Menu {
private void initMaterialsForBottomBar() {
createGUIBackButton();
createGUIFirstPageButton();
createGUINextButton();
createGUILastPageButton();
createGUICloseInvButton();
}
public void addMenuBottomBar() {
inventory.setItem(45, backButton);
inventory.setItem(46, firstPageButton);
inventory.setItem(53, nextButton);
inventory.setItem(52, lastPageButton);
inventory.setItem(49, closeInvButton);
inventory.setItem(46, super.GUI_FILLER_ITEM);
inventory.setItem(47, super.GUI_FILLER_ITEM);
inventory.setItem(48, super.GUI_FILLER_ITEM);
inventory.setItem(50, super.GUI_FILLER_ITEM);
inventory.setItem(51, super.GUI_FILLER_ITEM);
inventory.setItem(52, super.GUI_FILLER_ITEM);
}
private void createGUIBackButton() {
@@ -63,22 +69,22 @@ public abstract class PaginatedMenu extends Menu {
else {
backButton = new ItemStack(backButtonMaterial);
}
ItemMeta backButton_meta = backButton.getItemMeta();
assert backButton_meta != null;
ItemMeta backButtonMeta = backButton.getItemMeta();
assert backButtonMeta != null;
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_TEXT)) {
backButton_meta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_TEXT));
backButtonMeta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_TEXT));
}
int backButtonCMD;
try {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_CMD)) {
backButtonCMD = Integer.parseInt(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_CMD);
backButton_meta.setCustomModelData(backButtonCMD);
backButtonMeta.setCustomModelData(backButtonCMD);
}
}
catch (NumberFormatException e) {
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Back Button in config.yml");
}
backButton.setItemMeta(backButton_meta);
backButton.setItemMeta(backButtonMeta);
}
private void createGUINextButton() {
@@ -89,22 +95,66 @@ public abstract class PaginatedMenu extends Menu {
else {
nextButton = new ItemStack(nextButtonMaterial);
}
ItemMeta nextButton_meta = nextButton.getItemMeta();
assert nextButton_meta != null;
ItemMeta nextButtonMeta = nextButton.getItemMeta();
assert nextButtonMeta != null;
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_TEXT)) {
nextButton_meta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_TEXT));
nextButtonMeta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_TEXT));
}
int nextButtonCMD;
try {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_CMD)) {
nextButtonCMD = Integer.parseInt(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_CMD);
nextButton_meta.setCustomModelData(nextButtonCMD);
nextButtonMeta.setCustomModelData(nextButtonCMD);
}
}
catch (NumberFormatException e) {
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Next Button in config.yml");
}
nextButton.setItemMeta(nextButton_meta);
nextButton.setItemMeta(nextButtonMeta);
}
private void createGUIFirstPageButton() {
Material firstPageButtonMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_MATERIAL);
if(firstPageButtonMaterial == null)
firstPageButton = createPlayerHead(FIRST_PAGE_BUTTON_SKIN_ID);
else
firstPageButton = new ItemStack(firstPageButtonMaterial);
ItemMeta firstPageButtonMeta = firstPageButton.getItemMeta();
if(firstPageButtonMeta != null && !StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_TEXT))
firstPageButtonMeta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_TEXT));
int firstPageButtonCMD;
try {
if(firstPageButtonMeta != null && !StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_CMD)) {
firstPageButtonCMD = Integer.parseInt(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_CMD);
firstPageButtonMeta.setCustomModelData(firstPageButtonCMD);
}
}
catch (NumberFormatException e) {
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Goto First Page Button in config.yml");
}
firstPageButton.setItemMeta(firstPageButtonMeta);
}
private void createGUILastPageButton() {
Material lastPageButtonMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_MATERIAL);
if(lastPageButtonMaterial == null)
lastPageButton = createPlayerHead(LAST_PAGE_BUTTON_SKIN_ID);
else
lastPageButton = new ItemStack(lastPageButtonMaterial);
ItemMeta lastPageButtonMeta = lastPageButton.getItemMeta();
if(lastPageButtonMeta != null && !StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_TEXT))
lastPageButtonMeta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_TEXT));
int lastPageButtonCMD;
try {
if(lastPageButtonMeta != null && !StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_CMD)) {
lastPageButtonCMD = Integer.parseInt(FindItemAddOn.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_CMD);
lastPageButtonMeta.setCustomModelData(lastPageButtonCMD);
}
}
catch (NumberFormatException e) {
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Goto Last Page Button in config.yml");
}
lastPageButton.setItemMeta(lastPageButtonMeta);
}
private void createGUICloseInvButton() {
@@ -113,22 +163,22 @@ public abstract class PaginatedMenu extends Menu {
closeInvButtonMaterial = Material.BARRIER;
}
closeInvButton = new ItemStack(closeInvButtonMaterial);
ItemMeta closeInv_meta = closeInvButton.getItemMeta();
assert closeInv_meta != null;
ItemMeta closeInvMeta = closeInvButton.getItemMeta();
assert closeInvMeta != null;
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_TEXT)) {
closeInv_meta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_TEXT));
closeInvMeta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_TEXT));
}
int closeInvButtonCMD;
try {
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_CMD)) {
closeInvButtonCMD = Integer.parseInt(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_CMD);
closeInv_meta.setCustomModelData(closeInvButtonCMD);
closeInvMeta.setCustomModelData(closeInvButtonCMD);
}
}
catch (NumberFormatException e) {
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Close Button in config.yml");
}
closeInvButton.setItemMeta(closeInv_meta);
closeInvButton.setItemMeta(closeInvMeta);
}
private ItemStack createPlayerHead(String value) {
@@ -1,7 +1,6 @@
package io.myzticbean.finditemaddon.Listeners;
import io.myzticbean.finditemaddon.Handlers.GUIHandler.Menu;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
@@ -11,18 +10,12 @@ public class MenuListener implements Listener {
@EventHandler
public void onMenuClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
InventoryHolder holder = e.getInventory().getHolder();
if(holder instanceof Menu) {
if(holder instanceof Menu menu) {
e.setCancelled(true);
if(e.getCurrentItem() == null) {
return;
}
Menu menu = (Menu) holder;
menu.handleMenu(e);
}
}
@@ -1,6 +1,6 @@
package io.myzticbean.finditemaddon.Listeners;
import com.olziedev.playerwarps.api.events.PlayerWarpCreateEvent;
import com.olziedev.playerwarps.api.events.warp.PlayerWarpCreateEvent;
import io.myzticbean.finditemaddon.Dependencies.PlayerWarpsPlugin;
import io.myzticbean.finditemaddon.FindItemAddOn;
import org.bukkit.Bukkit;
@@ -1,6 +1,6 @@
package io.myzticbean.finditemaddon.Listeners;
import com.olziedev.playerwarps.api.events.PlayerWarpRemoveEvent;
import com.olziedev.playerwarps.api.events.warp.PlayerWarpRemoveEvent;
import io.myzticbean.finditemaddon.Dependencies.PlayerWarpsPlugin;
import io.myzticbean.finditemaddon.FindItemAddOn;
import org.bukkit.Bukkit;
@@ -4,31 +4,35 @@
*
* IMPORTANT: You are not allowed to modify this class, except changing the package.
*
* Unallowed modifications include but are not limited to:
* Disallowed modifications include but are not limited to:
* - Remove the option for users to opt-out
* - Change the frequency for data submission
* - Obfuscate the code (every obfucator should allow you to make an exception for specific files)
* - Obfuscate the code (every obfuscator should allow you to make an exception for specific files)
* - Reformat the code (if you use a linter, add an exception)
*
* Violations will result in a ban of your plugin and account from bStats.
*/
package io.myzticbean.finditemaddon.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -36,6 +40,12 @@ import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.HttpsURLConnection;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
public class Metrics {
@@ -100,6 +110,11 @@ public class Metrics {
logResponseStatusText);
}
/** Shuts down the underlying scheduler service. */
public void shutdown() {
metricsBase.shutdown();
}
/**
* Adds a custom chart.
*
@@ -143,13 +158,12 @@ public class Metrics {
public static class MetricsBase {
/** The version of the Metrics class. */
public static final String METRICS_VERSION = "3.0.0";
private static final ScheduledExecutorService scheduler =
Executors.newScheduledThreadPool(1, task -> new Thread(task, "bStats-Metrics"));
public static final String METRICS_VERSION = "3.0.2";
private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s";
private final ScheduledExecutorService scheduler;
private final String platform;
private final String serverUuid;
@@ -213,6 +227,14 @@ public class Metrics {
boolean logErrors,
boolean logSentData,
boolean logResponseStatusText) {
ScheduledThreadPoolExecutor scheduler =
new ScheduledThreadPoolExecutor(1, task -> new Thread(task, "bStats-Metrics"));
// We want delayed tasks (non-periodic) that will execute in the future to be
// cancelled when the scheduler is shutdown.
// Otherwise, we risk preventing the server from shutting down even when
// MetricsBase#shutdown() is called
scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
this.scheduler = scheduler;
this.platform = platform;
this.serverUuid = serverUuid;
this.serviceId = serviceId;
@@ -228,7 +250,8 @@ public class Metrics {
this.logResponseStatusText = logResponseStatusText;
checkRelocation();
if (enabled) {
// WARNING: Removing the option to opt-out will get your plugin banned from bStats
// WARNING: Removing the option to opt-out will get your plugin banned from
// bStats
startSubmitting();
}
}
@@ -237,6 +260,10 @@ public class Metrics {
this.customCharts.add(chart);
}
public void shutdown() {
scheduler.shutdown();
}
private void startSubmitting() {
final Runnable submitTask =
() -> {
@@ -251,13 +278,14 @@ public class Metrics {
this.submitData();
}
};
// Many servers tend to restart at a fixed time at xx:00 which causes an uneven distribution
// of requests on the
// bStats backend. To circumvent this problem, we introduce some randomness into the initial
// and second delay.
// WARNING: You must not modify and part of this Metrics class, including the submit delay or
// frequency!
// WARNING: Modifying this code will get your plugin banned on bStats. Just don't do it!
// Many servers tend to restart at a fixed time at xx:00 which causes an uneven
// distribution of requests on the
// bStats backend. To circumvent this problem, we introduce some randomness into
// the initial and second delay.
// WARNING: You must not modify and part of this Metrics class, including the
// submit delay or frequency!
// WARNING: Modifying this code will get your plugin banned on bStats. Just
// don't do it!
long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3));
long secondDelay = (long) (1000 * 60 * (Math.random() * 30));
scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS);
@@ -332,14 +360,14 @@ public class Metrics {
// You can use the property to disable the check in your test environment
if (System.getProperty("bstats.relocatecheck") == null
|| !System.getProperty("bstats.relocatecheck").equals("false")) {
// Maven's Relocate is clever and changes strings, too. So we have to use this little
// "trick" ... :D
// Maven's Relocate is clever and changes strings, too. So we have to use this
// little "trick" ... :D
final String defaultPackage =
new String(new byte[] {'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'});
final String examplePackage =
new String(new byte[] {'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
// We want to make sure no one just copy & pastes the example and uses the wrong package
// names
// We want to make sure no one just copy & pastes the example and uses the wrong
// package names
if (MetricsBase.class.getPackage().getName().startsWith(defaultPackage)
|| MetricsBase.class.getPackage().getName().startsWith(examplePackage)) {
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
@@ -365,9 +393,9 @@ public class Metrics {
}
}
public static class DrilldownPie extends CustomChart {
public static class SimplePie extends CustomChart {
private final Callable<Map<String, Map<String, Integer>>> callable;
private final Callable<String> callable;
/**
* Class constructor.
@@ -375,41 +403,23 @@ public class Metrics {
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
public SimplePie(String chartId, Callable<String> callable) {
super(chartId);
this.callable = callable;
}
@Override
public JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Map<String, Integer>> map = callable.call();
if (map == null || map.isEmpty()) {
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
String value = callable.call();
if (value == null || value.isEmpty()) {
// Null = skip the chart
return null;
}
boolean reallyAllSkipped = true;
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
JsonObjectBuilder valueBuilder = new JsonObjectBuilder();
boolean allSkipped = true;
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
valueBuilder.appendField(valueEntry.getKey(), valueEntry.getValue());
allSkipped = false;
}
if (!allSkipped) {
reallyAllSkipped = false;
valuesBuilder.appendField(entryValues.getKey(), valueBuilder.build());
}
}
if (reallyAllSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
return new JsonObjectBuilder().appendField("value", value).build();
}
}
public static class AdvancedPie extends CustomChart {
public static class MultiLineChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
@@ -419,7 +429,7 @@ public class Metrics {
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@@ -449,7 +459,7 @@ public class Metrics {
}
}
public static class MultiLineChart extends CustomChart {
public static class AdvancedPie extends CustomChart {
private final Callable<Map<String, Integer>> callable;
@@ -459,7 +469,7 @@ public class Metrics {
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@@ -519,66 +529,6 @@ public class Metrics {
}
}
public abstract static class CustomChart {
private final String chartId;
protected CustomChart(String chartId) {
if (chartId == null) {
throw new IllegalArgumentException("chartId must not be null");
}
this.chartId = chartId;
}
public JsonObjectBuilder.JsonObject getRequestJsonObject(
BiConsumer<String, Throwable> errorLogger, boolean logErrors) {
JsonObjectBuilder builder = new JsonObjectBuilder();
builder.appendField("chartId", chartId);
try {
JsonObjectBuilder.JsonObject data = getChartData();
if (data == null) {
// If the data is null we don't send the chart.
return null;
}
builder.appendField("data", data);
} catch (Throwable t) {
if (logErrors) {
errorLogger.accept("Failed to get data for custom chart with id " + chartId, t);
}
return null;
}
return builder.build();
}
protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception;
}
public static class SimplePie extends CustomChart {
private final Callable<String> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimplePie(String chartId, Callable<String> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
String value = callable.call();
if (value == null || value.isEmpty()) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("value", value).build();
}
}
public static class AdvancedBarChart extends CustomChart {
private final Callable<Map<String, int[]>> callable;
@@ -619,6 +569,84 @@ public class Metrics {
}
}
public static class DrilldownPie extends CustomChart {
private final Callable<Map<String, Map<String, Integer>>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
super(chartId);
this.callable = callable;
}
@Override
public JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Map<String, Integer>> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean reallyAllSkipped = true;
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
JsonObjectBuilder valueBuilder = new JsonObjectBuilder();
boolean allSkipped = true;
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
valueBuilder.appendField(valueEntry.getKey(), valueEntry.getValue());
allSkipped = false;
}
if (!allSkipped) {
reallyAllSkipped = false;
valuesBuilder.appendField(entryValues.getKey(), valueBuilder.build());
}
}
if (reallyAllSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
public abstract static class CustomChart {
private final String chartId;
protected CustomChart(String chartId) {
if (chartId == null) {
throw new IllegalArgumentException("chartId must not be null");
}
this.chartId = chartId;
}
public JsonObjectBuilder.JsonObject getRequestJsonObject(
BiConsumer<String, Throwable> errorLogger, boolean logErrors) {
JsonObjectBuilder builder = new JsonObjectBuilder();
builder.appendField("chartId", chartId);
try {
JsonObjectBuilder.JsonObject data = getChartData();
if (data == null) {
// If the data is null we don't send the chart.
return null;
}
builder.appendField("data", data);
} catch (Throwable t) {
if (logErrors) {
errorLogger.accept("Failed to get data for custom chart with id " + chartId, t);
}
return null;
}
return builder.build();
}
protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception;
}
public static class SingleLineChart extends CustomChart {
private final Callable<Integer> callable;
@@ -850,4 +878,4 @@ public class Metrics {
}
}
}
}
}
@@ -0,0 +1,16 @@
package io.myzticbean.finditemaddon.Models;
import lombok.Builder;
import lombok.Getter;
import org.bukkit.Location;
import java.util.Date;
@Getter @Builder
public class CachedShop {
private long shopId;
private Location shopLocation;
private int remainingStock;
private int remainingSpace;
private Date lastFetched;
}
@@ -18,4 +18,5 @@ public class FoundShopItemModel {
private final UUID shopOwner;
private final Location shopLocation;
private final ItemStack item;
private final boolean toBuy;
}
@@ -1,26 +1,31 @@
package io.myzticbean.finditemaddon.QuickShopHandler;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.time.Duration;
import java.time.Instant;
import java.util.*;
/**
* Interface for QS API.
* Implement it depending on which API is being used (Reremake/Hikari).
* @param <QSType>
* @param <Shop>
* @author ronsane
* @author myzticbean
*/
public interface QSApi<QSType, Shop> {
String QS_TOTAL_SHOPS_ON_SERVER = "Total shops on server: ";
String QS_REMAINING_STOCK_OR_SPACE = "Remaining Stock/Space: ";
/**
* Search based on Item Type from all server shops
* @param item
@@ -58,8 +63,13 @@ public interface QSApi<QSType, Shop> {
List<ShopSearchActivityModel> syncShopsListForStorage(List<ShopSearchActivityModel> globalShopsList);
void registerSubCommand();
UUID convertNameToUuid(String playerName);
static List<FoundShopItemModel> sortShops(int sortingMethod, List<FoundShopItemModel> shopsFoundList) {
boolean isQSShopCacheImplemented();
int processUnknownStockSpace(Location shopLoc, boolean toBuy);
static List<FoundShopItemModel> sortShops(int sortingMethod, List<FoundShopItemModel> shopsFoundList, boolean toBuy) {
switch (sortingMethod) {
// Random
case 1 -> Collections.shuffle(shopsFoundList);
@@ -76,6 +86,38 @@ public interface QSApi<QSType, Shop> {
shopsFoundList.sort(Comparator.comparing(FoundShopItemModel::getShopPrice));
}
}
if(FindItemAddOn.getConfigProvider().DEBUG_MODE)
shopsFoundList.forEach(foundShopItem ->
LoggerUtils.logDebugInfo(QS_REMAINING_STOCK_OR_SPACE + foundShopItem.getRemainingStockOrSpace()));
return shopsFoundList;
}
static int processStockOrSpace(int stockOrSpace) {
if(stockOrSpace == -1)
return Integer.MAX_VALUE;
return stockOrSpace;
}
/**
* Function to check if the time difference between two dates is greater than or equal to the specified seconds
* @param date1
* @param date2
* @param seconds
* @return
*/
static boolean isTimeDifferenceGreaterThanSeconds(Date date1, Date date2, int seconds) {
Instant instant1 = date1.toInstant();
Instant instant2 = date2.toInstant();
Duration duration = Duration.between(instant1, instant2);
long secondsDifference = Math.abs(duration.getSeconds());
LoggerUtils.logDebugInfo("Difference: " + secondsDifference);
return secondsDifference >= seconds;
}
static void logTimeTookMsg(Instant timeStart) {
LoggerUtils.logInfo("Shop search took " + Duration.between(timeStart, Instant.now()).toMillis() + "ms");
}
}
@@ -1,74 +1,104 @@
package io.myzticbean.finditemaddon.QuickShopHandler;
import cc.carm.lib.easysql.api.SQLQuery;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.api.QuickShopAPI;
import com.ghostchu.quickshop.api.command.CommandContainer;
import com.ghostchu.quickshop.api.obj.QUser;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.api.shop.permission.BuiltInShopPermission;
import com.ghostchu.quickshop.database.DataTables;
import com.ghostchu.quickshop.util.Util;
import io.myzticbean.finditemaddon.Commands.QSSubCommands.FindItemCmdHikariImpl;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Models.CachedShop;
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPermsEnum;
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.HiddenShopStorageUtil;
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.nio.charset.StandardCharsets;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Implementation of QSApi for Reremake
* @author ronsane
* Implementation of QSApi for Hikari
*
* @author myzticbean
*/
public class QSHikariAPIHandler implements QSApi<QuickShop, Shop> {
private QuickShopAPI api;
private Plugin qsHikariPluginInstance;
private final String QS_HIKARI_PLUGIN_NAME = "QuickShop-Hikari";
public static final String IS_MAIN_THREAD = "Is MAIN Thread? ";
private final QuickShopAPI api;
private final String pluginVersion;
private final ConcurrentMap<Long, CachedShop> shopCache;
private final int SHOP_CACHE_TIMEOUT_SECONDS = 5*60;
private final boolean isQSHikariShopCacheImplemented;
public QSHikariAPIHandler() {
api = QuickShopAPI.getInstance();
pluginVersion = Bukkit.getPluginManager().getPlugin("QuickShop-Hikari").getDescription().getVersion();
LoggerUtils.logInfo("Initializing Shop caching");
shopCache = new ConcurrentHashMap<>();
isQSHikariShopCacheImplemented = checkIfQSHikariShopCacheImplemented();
}
public List<FoundShopItemModel> findItemBasedOnTypeFromAllShops(ItemStack item, boolean toBuy, Player searchingPlayer) {
LoggerUtils.logDebugInfo(IS_MAIN_THREAD + Bukkit.isPrimaryThread());
var begin = Instant.now();
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
List<Shop> allShops;
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
}
else {
allShops = api.getShopManager().getAllShops();
}
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
allShops.forEach((shop_i) -> {
List<Shop> allShops = fetchAllShopsFromQS();
LoggerUtils.logDebugInfo(QS_TOTAL_SHOPS_ON_SERVER + allShops.size());
for(Shop shopIterator : allShops) {
// LoggerUtils.logDebugInfo("1: ToBuy: " + toBuy + " Location: " + shopIterator.getLocation() + " | Stock: " + getRemainingStockOrSpaceFromShopCache(shopIterator, true) + " | Space: " + getRemainingStockOrSpaceFromShopCache(shopIterator, false));
// LoggerUtils.logDebugInfo("2: ToBuy: " + toBuy + " Location: " + shopIterator.getLocation() + " | Stock: " + shopIterator.getRemainingStock() + " | Space: " + shopIterator.getRemainingSpace());
// check for quickshop hikari internal per-shop based search permission
if(shop_i.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)) {
// check for blacklisted worlds
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
&& shop_i.getItem().getType().equals(item.getType())
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
if(shopIterator.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)
// check for blacklisted worlds
&& (!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shopIterator.getLocation().getWorld())
&& shopIterator.getItem().getType().equals(item.getType())
&& (toBuy ? shopIterator.isSelling() : shopIterator.isBuying()))
// check for shop if hidden
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
shopsFoundList.add(new FoundShopItemModel(
shop_i.getPrice(),
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
shop_i.getOwner(),
shop_i.getLocation(),
shop_i.getItem()
));
}
&& (!HiddenShopStorageUtil.isShopHidden(shopIterator))) {
LoggerUtils.logDebugInfo("Shop match found: " + shopIterator.getLocation());
int stockOrSpace = (toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true) : getRemainingStockOrSpaceFromShopCache(shopIterator, false));
if(checkIfShopToBeIgnoredForFullOrEmpty(stockOrSpace)) {
continue;
}
shopsFoundList.add(new FoundShopItemModel(
shopIterator.getPrice(),
QSApi.processStockOrSpace(stockOrSpace),
shopIterator.getOwner().getUniqueIdOptional().orElse(new UUID(0, 0)),
shopIterator.getLocation(),
shopIterator.getItem(),
toBuy
));
}
});
}
List<FoundShopItemModel> sortedShops = handleShopSorting(toBuy, shopsFoundList);
QSApi.logTimeTookMsg(begin);
return sortedShops;
}
@NotNull
static List<FoundShopItemModel> handleShopSorting(boolean toBuy, List<FoundShopItemModel> shopsFoundList) {
if(!shopsFoundList.isEmpty()) {
int sortingMethod = 2;
try {
@@ -78,97 +108,93 @@ public class QSHikariAPIHandler implements QSApi<QuickShop, Shop> {
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
LoggerUtils.logError("Defaulting to sorting by prices method");
}
return QSApi.sortShops(sortingMethod, shopsFoundList);
return QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
}
return shopsFoundList;
}
public List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy, Player searchingPlayer) {
LoggerUtils.logDebugInfo(IS_MAIN_THREAD + Bukkit.isPrimaryThread());
var begin = Instant.now();
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
List<Shop> allShops;
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
}
else {
allShops = api.getShopManager().getAllShops();
}
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
for(Shop shop_i : allShops) {
List<Shop> allShops = fetchAllShopsFromQS();
LoggerUtils.logDebugInfo(QS_TOTAL_SHOPS_ON_SERVER + allShops.size());
for(Shop shopIterator : allShops) {
// check for quickshop hikari internal per-shop based search permission
if(shop_i.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)) {
// check for blacklisted worlds
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())) {
if(shopIterator.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)
// check for blacklisted worlds
&& !FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shopIterator.getLocation().getWorld())
// match the item based on query
if(shop_i.getItem().hasItemMeta()) {
if(Objects.requireNonNull(shop_i.getItem().getItemMeta()).hasDisplayName()) {
if(shop_i.getItem().getItemMeta().getDisplayName().toLowerCase().contains(displayName.toLowerCase())
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
// check for shop if hidden
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
shopsFoundList.add(new FoundShopItemModel(
shop_i.getPrice(),
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
shop_i.getOwner(),
shop_i.getLocation(),
shop_i.getItem()
));
}
}
}
}
&& shopIterator.getItem().hasItemMeta()
&& Objects.requireNonNull(shopIterator.getItem().getItemMeta()).hasDisplayName()
&& (shopIterator.getItem().getItemMeta().getDisplayName().toLowerCase().contains(displayName.toLowerCase())
&& (toBuy ? shopIterator.isSelling() : shopIterator.isBuying()))
// check for shop if hidden
&& !HiddenShopStorageUtil.isShopHidden(shopIterator)) {
int stockOrSpace = (toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true) : getRemainingStockOrSpaceFromShopCache(shopIterator, false));
if(checkIfShopToBeIgnoredForFullOrEmpty(stockOrSpace)) {
continue;
}
shopsFoundList.add(new FoundShopItemModel(
shopIterator.getPrice(),
QSApi.processStockOrSpace(stockOrSpace),
shopIterator.getOwner().getUniqueIdOptional().orElse(new UUID(0, 0)),
shopIterator.getLocation(),
shopIterator.getItem(),
toBuy
));
}
}
if(!shopsFoundList.isEmpty()) {
int sortingMethod = 2;
try {
sortingMethod = FindItemAddOn.getConfigProvider().SHOP_SORTING_METHOD;
}
catch(Exception e) {
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
LoggerUtils.logError("Defaulting to sorting by prices method");
}
return QSApi.sortShops(sortingMethod, shopsFoundList);
}
return shopsFoundList;
List<FoundShopItemModel> sortedShops = handleShopSorting(toBuy, shopsFoundList);
QSApi.logTimeTookMsg(begin);
return sortedShops;
}
public List<FoundShopItemModel> fetchAllItemsFromAllShops(boolean toBuy, Player searchingPlayer) {
LoggerUtils.logDebugInfo(IS_MAIN_THREAD + Bukkit.isPrimaryThread());
var begin = Instant.now();
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
List<Shop> allShops;
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
}
else {
allShops = api.getShopManager().getAllShops();
}
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
allShops.forEach((shop_i) -> {
List<Shop> allShops = fetchAllShopsFromQS();
LoggerUtils.logDebugInfo(QS_TOTAL_SHOPS_ON_SERVER + allShops.size());
for(Shop shopIterator : allShops) {
// check for quickshop hikari internal per-shop based search permission
if(shop_i.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)) {
// check for blacklisted worlds
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
if(shopIterator.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)
// check for blacklisted worlds
&& (!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shopIterator.getLocation().getWorld())
&& (toBuy ? shopIterator.isSelling() : shopIterator.isBuying()))
// check for shop if hidden
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
shopsFoundList.add(new FoundShopItemModel(
shop_i.getPrice(),
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
shop_i.getOwner(),
shop_i.getLocation(),
shop_i.getItem()
));
}
&& (!HiddenShopStorageUtil.isShopHidden(shopIterator))) {
int stockOrSpace = (toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true) : getRemainingStockOrSpaceFromShopCache(shopIterator, false));
if(checkIfShopToBeIgnoredForFullOrEmpty(stockOrSpace)) {
continue;
}
shopsFoundList.add(new FoundShopItemModel(
shopIterator.getPrice(),
QSApi.processStockOrSpace(stockOrSpace),
shopIterator.getOwner().getUniqueIdOptional().orElse(new UUID(0, 0)),
shopIterator.getLocation(),
shopIterator.getItem(),
toBuy
));
}
});
}
List<FoundShopItemModel> sortedShops = new ArrayList<>(shopsFoundList);
if(!shopsFoundList.isEmpty()) {
int sortingMethod = 1;
return QSApi.sortShops(sortingMethod, shopsFoundList);
sortedShops = QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
}
return shopsFoundList;
QSApi.logTimeTookMsg(begin);
return sortedShops;
}
private List<Shop> fetchAllShopsFromQS() {
List<Shop> allShops;
if (FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
} else {
allShops = getAllShops();
}
return allShops;
}
public Material getShopSignMaterial() {
@@ -181,7 +207,8 @@ public class QSHikariAPIHandler implements QSApi<QuickShop, Shop> {
}
public boolean isShopOwnerCommandRunner(Player player, Shop shop) {
return shop.getOwner().toString().equalsIgnoreCase(player.getUniqueId().toString());
LoggerUtils.logDebugInfo("Shop owner: " + shop.getOwner() + " | Player: " + player.getUniqueId());
return shop.getOwner().getUniqueId().toString().equalsIgnoreCase(player.getUniqueId().toString());
}
@Override
@@ -191,10 +218,11 @@ public class QSHikariAPIHandler implements QSApi<QuickShop, Shop> {
@Override
public List<ShopSearchActivityModel> syncShopsListForStorage(List<ShopSearchActivityModel> globalShopsList) {
long start = System.currentTimeMillis();
// copy all shops from shops list in API to a temp globalShopsList
// now check shops from temp globalShopsList in current globalShopsList and pull playerVisit data
List<ShopSearchActivityModel> tempGlobalShopsList = new ArrayList<>();
for(Shop shop_i : getAllShops()) {
for (Shop shop_i : getAllShops()) {
Location shopLoc = shop_i.getLocation();
tempGlobalShopsList.add(new ShopSearchActivityModel(
shopLoc.getWorld().getName(),
@@ -203,16 +231,16 @@ public class QSHikariAPIHandler implements QSApi<QuickShop, Shop> {
shopLoc.getZ(),
shopLoc.getPitch(),
shopLoc.getYaw(),
shop_i.getOwner().toString(),
convertQUserToUUID(shop_i.getOwner()).toString(),
new ArrayList<>(),
false
));
}
for(ShopSearchActivityModel shop_temp : tempGlobalShopsList) {
for (ShopSearchActivityModel shop_temp : tempGlobalShopsList) {
ShopSearchActivityModel tempShopToRemove = null;
for(ShopSearchActivityModel shop_global : globalShopsList) {
if(shop_temp.getWorldName().equalsIgnoreCase(shop_global.getWorldName())
for (ShopSearchActivityModel shop_global : globalShopsList) {
if (shop_temp.getWorldName().equalsIgnoreCase(shop_global.getWorldName())
&& shop_temp.getX() == shop_global.getX()
&& shop_temp.getY() == shop_global.getY()
&& shop_temp.getZ() == shop_global.getZ()
@@ -224,9 +252,10 @@ public class QSHikariAPIHandler implements QSApi<QuickShop, Shop> {
break;
}
}
if(tempShopToRemove != null)
if (tempShopToRemove != null)
globalShopsList.remove(tempShopToRemove);
}
LoggerUtils.logInfo("Shops List sync complete. Time took: " + (System.currentTimeMillis() - start) + "ms.");
return tempGlobalShopsList;
}
@@ -237,24 +266,152 @@ public class QSHikariAPIHandler implements QSApi<QuickShop, Shop> {
@Override
public void registerSubCommand() {
LoggerUtils.logInfo("Unregistered find sub-command for /qs");
for(CommandContainer cmdContainer : api.getCommandManager().getRegisteredCommands()) {
if(cmdContainer.getPrefix().equalsIgnoreCase("find")) {
for (CommandContainer cmdContainer : api.getCommandManager().getRegisteredCommands()) {
if (cmdContainer.getPrefix().equalsIgnoreCase("find")) {
api.getCommandManager().unregisterCmd(cmdContainer);
break;
}
}
LoggerUtils.logInfo("Registered finditem sub-command for /qs");
/*
final TextComponent textComponent = Component.text("Search for items from all shops using an interactive GUI");
final Function<String, Component> func = x -> Component.text("Search for items from all shops using an interactive GUI");
*/
api.getCommandManager().registerCmd(
CommandContainer.builder()
.prefix("finditem")
.permission(PlayerPerms.FINDITEM_USE.value())
.permission(PlayerPermsEnum.FINDITEM_USE.value())
.hidden(false)
.description(locale -> Component.text("Search for items from all shops using an interactive GUI"))
.executor(new FindItemCmdHikariImpl())
.build());
}
private UUID convertQUserToUUID(QUser qUser) {
Optional<UUID> uuid = qUser.getUniqueIdOptional();
if (uuid.isPresent()) {
return uuid.get();
}
String username = qUser.getUsernameOptional().orElse("Unknown");
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(StandardCharsets.UTF_8));
}
public UUID convertNameToUuid(String playerName) {
return api.getPlayerFinder().name2Uuid(playerName);
}
/**
* If IGNORE_EMPTY_CHESTS is true -> do not add empty stock or space
* If to buy -> If shop has no stock -> based on ignore flag, decide to include it or not
* If to sell -> If shop has no space -> based on ignore flag, decide to include it or not
* @param stockOrSpace
* @return If shop needs to be ignored from list
*/
private boolean checkIfShopToBeIgnoredForFullOrEmpty(int stockOrSpace) {
boolean ignoreEmptyChests = FindItemAddOn.getConfigProvider().IGNORE_EMPTY_CHESTS;
if(ignoreEmptyChests) {
return stockOrSpace == 0;
}
return false;
}
/**
* Fallback to fetching info from ShopCache to avoid lag
* @param shop QuickShop Shop instance
* @param fetchRemainingStock True if fetching remaining stock, False if fetching remaining space
* @return
*/
private int getRemainingStockOrSpaceFromShopCache___test(Shop shop, boolean fetchRemainingStock) {
LoggerUtils.logDebugInfo("Shop ID: " + shop.getShopId());
CachedShop cachedShop = shopCache.get(shop.getShopId());
if (cachedShop == null || QSApi.isTimeDifferenceGreaterThanSeconds(cachedShop.getLastFetched(), new Date(), SHOP_CACHE_TIMEOUT_SECONDS)) {
cachedShop = CachedShop.builder()
.shopId(shop.getShopId())
.remainingStock(shop.getRemainingStock())
.remainingSpace(shop.getRemainingSpace())
.lastFetched(new Date())
.build();
shopCache.put(cachedShop.getShopId(), cachedShop);
LoggerUtils.logDebugInfo("Adding to ShopCache: " + shop.getShopId());
}
return (fetchRemainingStock ? cachedShop.getRemainingStock() : cachedShop.getRemainingSpace());
}
private int getRemainingStockOrSpaceFromShopCache(Shop shop, boolean fetchRemainingStock) {
// LoggerUtils.logDebugInfo("Shop ID: " + shop.getShopId());
String mainVersionStr = pluginVersion.split("\\.")[0];
int mainVersion = Integer.parseInt(mainVersionStr);
if (mainVersion >= 6) {
// New feature available
Util.ensureThread(true);
int stockOrSpace = (fetchRemainingStock ? shop.getRemainingStock() : shop.getRemainingSpace());
LoggerUtils.logDebugInfo("Stock/Space from cache: " + stockOrSpace);
return stockOrSpace;
}
else {
// Show warning
LoggerUtils.logWarning("Update recommended to QuickShop-Hikari v6+! You are still using v" + pluginVersion);
// PREPARE FOR LAG
CachedShop cachedShop = shopCache.get(shop.getShopId());
if (cachedShop == null || QSApi.isTimeDifferenceGreaterThanSeconds(cachedShop.getLastFetched(), new Date(), SHOP_CACHE_TIMEOUT_SECONDS)) {
cachedShop = CachedShop.builder()
.shopId(shop.getShopId())
.remainingStock(shop.getRemainingStock())
.remainingSpace(shop.getRemainingSpace())
.lastFetched(new Date())
.build();
shopCache.put(cachedShop.getShopId(), cachedShop);
LoggerUtils.logDebugInfo("Adding to ShopCache: " + shop.getShopId());
}
return (fetchRemainingStock ? cachedShop.getRemainingStock() : cachedShop.getRemainingSpace());
}
}
// An empty ResultSet or a value that returns -1 means that the value is not cached.
// Normally when space is -1, stock is not, and vice versa.
// In special cases, neither value may be -1.
// If Stock 0 -> Shop is admin or no stock
private void testQuickShopHikariExternalCache(Shop shop) throws RuntimeException {
boolean fetchRemainingStock = false;
long shopId = shop.getShopId();
try (SQLQuery query = DataTables.EXTERNAL_CACHE.createQuery()
.addCondition("shop", shopId)
.selectColumns("space", "stock")
.setLimit(1)
.build()
.execute(); ResultSet resultSet = query.getResultSet()) {
if(resultSet.next()){
long stock = resultSet.getLong("stock");
long space = resultSet.getLong("space");
// stock or space can be `-1`
LoggerUtils.logWarning("1: Location: " + shop.getLocation() + " | Stock: " + stock + " | Space: " + space);
}else{
// no cached data
LoggerUtils.logWarning("No cached data found!");
}
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
private boolean checkIfQSHikariShopCacheImplemented() {
String mainVersionStr = pluginVersion.split("\\.")[0];
int mainVersion = Integer.parseInt(mainVersionStr);
return mainVersion >= 6;
}
@Override
public boolean isQSShopCacheImplemented() {
return isQSHikariShopCacheImplemented;
}
@Override
public int processUnknownStockSpace(Location shopLoc, boolean toBuy) {
// This process needs to run in MAIN thread
Util.ensureThread(false);
LoggerUtils.logDebugInfo("Fetching stock/space from MAIN thread...");
Shop qsShop = api.getShopManager().getShop(shopLoc);
if(qsShop != null) {
return (toBuy ? qsShop.getRemainingStock() : qsShop.getRemainingSpace());
} else {
return -2;
}
}
}
@@ -2,9 +2,10 @@ package io.myzticbean.finditemaddon.QuickShopHandler;
import io.myzticbean.finditemaddon.Commands.QSSubCommands.FindItemCmdReremakeImpl;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Models.CachedShop;
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPermsEnum;
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.HiddenShopStorageUtil;
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
import org.bukkit.Bukkit;
@@ -13,30 +14,41 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.api.QuickShopAPI;
import org.maxgamer.quickshop.api.command.CommandContainer;
import org.maxgamer.quickshop.api.shop.Shop;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Implementation of QSApi for Reremake
* @author ronsane
* @author myzticbean
*/
@Deprecated(since = "2.0.6.0")
public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
private final QuickShopAPI api;
private final QuickShop quickShop;
private final ConcurrentMap<Location, CachedShop> shopCache;
private final int SHOP_CACHE_TIMEOUT_SECONDS = 60;
private final String QS_REREMAKE_PLUGIN_NAME = "QuickShop";
public QSReremakeAPIHandler() {
api = (QuickShopAPI) Bukkit.getPluginManager().getPlugin(QS_REREMAKE_PLUGIN_NAME);
quickShop = (QuickShop) Bukkit.getPluginManager().getPlugin(QS_REREMAKE_PLUGIN_NAME);
LoggerUtils.logInfo("Initializing Shop caching");
shopCache = new ConcurrentHashMap<>();
}
@Override
public List<FoundShopItemModel> findItemBasedOnTypeFromAllShops(ItemStack item, boolean toBuy, Player searchingPlayer) {
var begin = Instant.now();
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
List<Shop> allShops;
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
@@ -45,41 +57,36 @@ public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
else {
allShops = api.getShopManager().getAllShops();
}
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
allShops.forEach((shop_i) -> {
logTotalShopsOnServer(allShops.size());
for(Shop shop_i : allShops) {
// check for blacklisted worlds
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
&& shop_i.getItem().getType().equals(item.getType())
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
if(checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shop_i)) {
continue;
}
// check for shop if hidden
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
shopsFoundList.add(new FoundShopItemModel(
shop_i.getPrice(),
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) : getRemainingStockOrSpaceFromShopCache(shop_i, false))),
shop_i.getOwner(),
shop_i.getLocation(),
shop_i.getItem()
shop_i.getItem(),
toBuy
));
}
}
});
if(!shopsFoundList.isEmpty()) {
int sortingMethod = 2;
try {
sortingMethod = FindItemAddOn.getConfigProvider().SHOP_SORTING_METHOD;
}
catch(Exception e) {
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
LoggerUtils.logError("Defaulting to sorting by prices method");
}
return QSApi.sortShops(sortingMethod, shopsFoundList);
}
return shopsFoundList;
List<FoundShopItemModel> sortedShops = handleShopSorting(toBuy, shopsFoundList);
QSApi.logTimeTookMsg(begin);
return sortedShops;
}
@Override
public List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy, Player searchingPlayer) {
var begin = Instant.now();
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
List<Shop> allShops;
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
@@ -88,22 +95,25 @@ public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
else {
allShops = api.getShopManager().getAllShops();
}
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
logTotalShopsOnServer(allShops.size());
for(Shop shop_i : allShops) {
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())) {
if(shop_i.getItem().hasItemMeta()) {
if(Objects.requireNonNull(shop_i.getItem().getItemMeta()).hasDisplayName()) {
if(shop_i.getItem().getItemMeta().getDisplayName().toLowerCase().contains(displayName.toLowerCase())
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) != 0 : getRemainingStockOrSpaceFromShopCache(shop_i, false) != 0)
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
if(checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shop_i))
continue;
// check for shop if hidden
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
shopsFoundList.add(new FoundShopItemModel(
shop_i.getPrice(),
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) : getRemainingStockOrSpaceFromShopCache(shop_i, false))),
shop_i.getOwner(),
shop_i.getLocation(),
shop_i.getItem()
shop_i.getItem(),
toBuy
));
}
}
@@ -111,22 +121,14 @@ public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
}
}
}
if(!shopsFoundList.isEmpty()) {
int sortingMethod = 2;
try {
sortingMethod = FindItemAddOn.getConfigProvider().SHOP_SORTING_METHOD;
}
catch(Exception e) {
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
LoggerUtils.logError("Defaulting to sorting by prices method");
}
return QSApi.sortShops(sortingMethod, shopsFoundList);
}
return shopsFoundList;
List<FoundShopItemModel> sortedShops = handleShopSorting(toBuy, shopsFoundList);
QSApi.logTimeTookMsg(begin);
return sortedShops;
}
@Override
public List<FoundShopItemModel> fetchAllItemsFromAllShops(boolean toBuy, Player searchingPlayer) {
var begin = Instant.now();
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
List<Shop> allShops;
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
@@ -135,29 +137,34 @@ public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
else {
allShops = api.getShopManager().getAllShops();
}
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
allShops.forEach((shop_i) -> {
logTotalShopsOnServer(allShops.size());
for(Shop shop_i : allShops) {
// check for blacklisted worlds
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) != 0 : getRemainingStockOrSpaceFromShopCache(shop_i, false) != 0)
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
if(checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shop_i))
continue;
// check for shop if hidden
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
shopsFoundList.add(new FoundShopItemModel(
shop_i.getPrice(),
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) : getRemainingStockOrSpaceFromShopCache(shop_i, false))),
shop_i.getOwner(),
shop_i.getLocation(),
shop_i.getItem()
shop_i.getItem(),
toBuy
));
}
}
});
}
List<FoundShopItemModel> sortedShops = new ArrayList<>(shopsFoundList);
if(!shopsFoundList.isEmpty()) {
int sortingMethod = 1;
return QSApi.sortShops(sortingMethod, shopsFoundList);
sortedShops = QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
}
return shopsFoundList;
QSApi.logTimeTookMsg(begin);
return sortedShops;
}
@Override
@@ -173,6 +180,7 @@ public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
@Override
public boolean isShopOwnerCommandRunner(Player player, Shop shop) {
LoggerUtils.logDebugInfo("Shop owner: " + shop.getOwner() + " | Player: " + player.getUniqueId());
return shop.getOwner().toString().equalsIgnoreCase(player.getUniqueId().toString());
}
@@ -201,7 +209,6 @@ public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
false
));
}
for(ShopSearchActivityModel shop_temp : tempGlobalShopsList) {
ShopSearchActivityModel tempShopToRemove = null;
for(ShopSearchActivityModel shop_global : globalShopsList) {
@@ -220,7 +227,6 @@ public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
if(tempShopToRemove != null)
globalShopsList.remove(tempShopToRemove);
}
return tempGlobalShopsList;
}
@@ -240,10 +246,125 @@ public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
api.getCommandManager().registerCmd(
CommandContainer.builder()
.prefix("finditem")
.permission(PlayerPerms.FINDITEM_USE.value())
.permission(PlayerPermsEnum.FINDITEM_USE.value())
.hidden(false)
.description("Search for items from all shops using an interactive GUI")
.executor(new FindItemCmdReremakeImpl())
.build());
}
@Override
public UUID convertNameToUuid(String playerName) {
return null;
}
@NotNull
static List<FoundShopItemModel> handleShopSorting(boolean toBuy, List<FoundShopItemModel> shopsFoundList) {
if(!shopsFoundList.isEmpty()) {
int sortingMethod = 2;
try {
sortingMethod = FindItemAddOn.getConfigProvider().SHOP_SORTING_METHOD;
}
catch(Exception e) {
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
LoggerUtils.logError("Defaulting to sorting by prices method");
}
return QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
}
return shopsFoundList;
}
/**
* If IGNORE_EMPTY_CHESTS is true -> do not add empty stock or space
* If to buy -> If shop has no stock -> based on ignore flag, decide to include it or not
* If to sell -> If shop has no space -> based on ignore flag, decide to include it or not
* @param toBuy
* @param shop
* @return If shop needs to be ignored from list
*/
private boolean checkIfShopToBeIgnoredForFullOrEmpty(boolean toBuy, Shop shop) {
boolean ignoreEmptyChests = FindItemAddOn.getConfigProvider().IGNORE_EMPTY_CHESTS;
if(ignoreEmptyChests) {
if(toBuy) {
return getRemainingStockOrSpaceFromShopCache(shop, true) == 0;
} else return getRemainingStockOrSpaceFromShopCache(shop, false) == 0;
}
return false;
}
/**
*
* @param shop
* @return True if shop to be ignored
*/
/*private boolean checkIfShopToBeIgnoredIfAdminShop(Shop shop) {
boolean ignoreAdminShops = FindItemAddOn.getConfigProvider().IGNORE_ADMIN_SHOPS;
if(ignoreAdminShops) {
OfflinePlayer shopOwner = Bukkit.getOfflinePlayer(shop.getOwner());
return shopOwner.getName() == null;
}
return false;
}*/
/**
* Fallback to fetching info from ShopCache to avoid lag
* @param shop QuickShop Shop instance
* @param fetchRemainingStock True if fetching remaning stock, False if fetching remaining space
* @return
*/
private int getRemainingStockOrSpaceFromShopCache(Shop shop, boolean fetchRemainingStock) {
LoggerUtils.logDebugInfo("Shop Location: " + shop.getLocation());
CachedShop cachedShop = shopCache.get(shop.getLocation());
if (cachedShop == null || QSApi.isTimeDifferenceGreaterThanSeconds(cachedShop.getLastFetched(), new Date(), SHOP_CACHE_TIMEOUT_SECONDS)) {
Shop possibleCachedShop = getRemainingStockOrSpaceFromQSCache(shop);
if(possibleCachedShop != null) {
LoggerUtils.logDebugInfo("Shop found from QS cache: " + shop.getLocation());
cachedShop = CachedShop.builder()
.shopLocation(possibleCachedShop.getLocation())
.remainingStock(possibleCachedShop.getRemainingStock())
.remainingSpace(possibleCachedShop.getRemainingSpace())
.lastFetched(new Date())
.build();
shopCache.put(cachedShop.getShopLocation(), cachedShop);
LoggerUtils.logDebugInfo("Added to ShopCache: " + shop.getLocation());
} else {
LoggerUtils.logDebugInfo("No shop found from QS cache for location: " + shop.getLocation());
}
} else {
LoggerUtils.logDebugInfo("Shop found from cache: " + shop.getLocation());
}
return (fetchRemainingStock ?
(cachedShop != null ? cachedShop.getRemainingStock() : -1)
: (cachedShop != null ? cachedShop.getRemainingSpace() : -1));
}
/**
* Fallback to fetching info from ShopCache to avoid lag
* @param shop QuickShop Shop instance
* @return
*/
private @Nullable Shop getRemainingStockOrSpaceFromQSCache(Shop shop) {
return quickShop.getShopCache().find(shop.getLocation(), false);
}
private static void logTotalShopsOnServer(int allShopsCount) {
LoggerUtils.logDebugInfo("Total shops on server: " + allShopsCount);
}
@Override
public boolean isQSShopCacheImplemented() {
return false;
}
@Override
public int processUnknownStockSpace(Location shopLoc, boolean toBuy) {
// This method will not be called from QS-Reremake context, but keeping it here as a placeholder
return -2;
}
}
@@ -1,13 +1,20 @@
package io.myzticbean.finditemaddon.ScheduledTasks;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
import io.myzticbean.finditemaddon.Utils.WarpUtils.WarpUtils;
import org.bukkit.Bukkit;
/**
* @author myzticbean
*/
public class Task15MinInterval implements Runnable {
@Override
public void run() {
WarpUtils.updateWarps();
// HiddenShopStorageUtil.saveHiddenShopsToFile();
ShopSearchActivityStorageUtil.syncShops();
// v2.0.6.0 - Changed tasks to run in async thread
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
WarpUtils.updateWarps();
ShopSearchActivityStorageUtil.syncShops();
});
}
}
@@ -0,0 +1,19 @@
package io.myzticbean.finditemaddon.Utils.Defaults;
public enum NearestWarpModeEnum {
ESSENTIAL_WARPS(1),
PLAYER_WARPS(2),
WORLDGUARD_REGION(3);
private final int mode;
NearestWarpModeEnum(int mode) {
this.mode = mode;
}
public int value() {
return mode;
}
}
@@ -1,24 +0,0 @@
package io.myzticbean.finditemaddon.Utils.Defaults;
/**
* List of all the permissions used by the addon
* @author ronsane
*/
public enum PlayerPerms {
FINDITEM_ADMIN("finditem.admin"),
FINDITEM_USE("finditem.use"),
FINDITEM_HIDESHOP("finditem.hideshop"),
FINDITEM_RELOAD("finditem.reload"),
FINDITEM_RESTART("finditem.restart"),
FINDITEM_SHOPTP("finditem.shoptp");
private final String permName;
PlayerPerms(String perm) {
permName = perm;
}
public String value() {
return permName;
}
}
@@ -0,0 +1,46 @@
package io.myzticbean.finditemaddon.Utils.Defaults;
import org.bukkit.entity.Player;
/**
* List of all the permissions used by the addon
* @author myzticbean
*/
public enum PlayerPermsEnum {
FINDITEM_ADMIN("finditem.admin"),
FINDITEM_USE("finditem.use"),
FINDITEM_HIDESHOP("finditem.hideshop"),
FINDITEM_RELOAD("finditem.reload"),
@Deprecated
FINDITEM_RESTART("finditem.restart"),
FINDITEM_SHOPTP("finditem.shoptp"),
FINDITEM_SHOPTP_OWN("finditem.shoptp.own"),
FINDITEM_SHOPTP_BYPASS_DELAY("finditem.shoptp-delay.bypass");
private final String permName;
PlayerPermsEnum(String perm) {
permName = perm;
}
public String value() {
return permName;
}
public static boolean isAdmin(Player p) {
return p.hasPermission(FINDITEM_ADMIN.permName);
}
public static boolean hasShopTpDelayBypassPermOrAdmin(Player p) {
return (isAdmin(p) || hasShopTpDelayBypassPerm(p));
}
public static boolean hasShopTpDelayBypassPerm(Player p) {
return p.hasPermission(FINDITEM_SHOPTP_BYPASS_DELAY.permName);
}
public static boolean canPlayerTpToOwnShop(Player p) {
return p.hasPermission(FINDITEM_SHOPTP_OWN.permName);
}
}
@@ -2,9 +2,9 @@ package io.myzticbean.finditemaddon.Utils.Defaults;
/**
* List of all the placeholds used in the Shop lore in GUI
* @author ronsane
* @author myzticbean
*/
public enum ShopLorePlaceholders {
public enum ShopLorePlaceholdersEnum {
ITEM_PRICE("{ITEM_PRICE}"),
SHOP_STOCK("{SHOP_STOCK}"),
SHOP_OWNER("{SHOP_OWNER}"),
@@ -14,7 +14,7 @@ public enum ShopLorePlaceholders {
SHOP_VISITS("{SHOP_VISITS}");
private final String placeholder;
ShopLorePlaceholders(String placeholder) {
ShopLorePlaceholdersEnum(String placeholder) {
this.placeholder = placeholder;
}
public String value() {return placeholder;}
@@ -11,9 +11,12 @@ import lombok.Getter;
import me.kodysimpson.simpapi.colors.ColorTranslator;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.io.*;
import java.time.Instant;
import java.util.*;
@@ -39,21 +42,6 @@ public class ShopSearchActivityStorageUtil {
* @return
*/
private static boolean handleCooldownIfPresent(Location shopLocation, Player player) {
// The below logic is flawed
/*
// check player is inside hashmap
if(cooldowns.containsKey(player.getName())) {
// check if player still has cooldown
if(cooldowns.get(player.getName()) > (System.currentTimeMillis()/1000)) {
long timeLeft = (cooldowns.get(player.getName()) - System.currentTimeMillis()/1000);
LoggerUtils.logDebugInfo(ColorTranslator.translateColorCodes("&6" + player.getName() + " still has cooldown of " + timeLeft + " seconds!"));
return false;
}
}
cooldowns.put(player.getName(), (System.currentTimeMillis()/1000) + FindItemAddOn.getConfigProvider().SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES * 60);
LoggerUtils.logDebugInfo(ColorTranslator.translateColorCodes("&aCooldown added for " + FindItemAddOn.getConfigProvider().SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES * 60 + " seconds for " + player.getName()));
return true;
*/
// New logic
for(ShopSearchActivityModel shopSearchActivity : globalShopsList) {
@@ -96,27 +84,6 @@ public class ShopSearchActivityStorageUtil {
globalShopsList = FindItemAddOn.getQsApiInstance().syncShopsListForStorage(globalShopsList);
}
// public static void saveCooldowns() {
// try {
// for(Map.Entry<String, Long> entry : cooldowns.entrySet()) {
// cooldownsConfig.set("cooldowns." + entry.getKey(), entry.getValue());
// }
// cooldownsConfig.save(cooldownsYaml);
// }
// catch (IOException e) {
// LoggerUtils.logError("Error saving config.yml");
// }
// }
// public static void restoreCooldowns() {
// if(cooldownsConfig.isConfigurationSection("cooldowns")) {
// cooldownsConfig.getConfigurationSection("cooldowns").getKeys(false).forEach(key -> {
// long timeLeft = cooldownsConfig.getLong("cooldowns." + key);
// cooldowns.put(key, timeLeft);
// });
// }
// }
/**
* QuickShop Reremake
* @param shop
@@ -165,14 +132,6 @@ public class ShopSearchActivityStorageUtil {
globalShopsList.add(shopModel);
}
// public void deleteShop(org.maxgamer.quickshop.api.shop.Shop shop) {
//
// }
//
// public void deleteShop(com.ghostchu.quickshop.api.shop.Shop shop) {
//
// }
public static void loadShopsFromFile() {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
File file = new File(FindItemAddOn.getInstance().getDataFolder().getAbsolutePath() + "/" + SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
@@ -191,15 +150,6 @@ public class ShopSearchActivityStorageUtil {
e.printStackTrace();
}
}
// else {
// try {
// file.createNewFile();
// LoggerUtils.logInfo("Generated new " + SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
// } catch (IOException e) {
// LoggerUtils.logError("Error generating " + SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
// e.printStackTrace();
// }
// }
globalShopsList = FindItemAddOn.getQsApiInstance().syncShopsListForStorage(globalShopsList);
}
@@ -219,23 +169,6 @@ public class ShopSearchActivityStorageUtil {
}
}
/*
public static void setupCooldownsConfigFile() {
cooldownsYaml = new File(FindItemAddOn.getInstance().getDataFolder(), COOLDOWNS_YAML_FILE_NAME);
if(!cooldownsYaml.exists()) {
try {
boolean isConfigGenerated = cooldownsYaml.createNewFile();
if(isConfigGenerated) {
LoggerUtils.logInfo("Generated a new " + COOLDOWNS_YAML_FILE_NAME);
}
} catch (IOException e) {
LoggerUtils.logError("Error generating " + COOLDOWNS_YAML_FILE_NAME);
}
}
cooldownsConfig = YamlConfiguration.loadConfiguration(cooldownsYaml);
}
*/
public static void migrateHiddenShopsToShopsJson() {
File hiddenShopsJsonfile = new File(FindItemAddOn.getInstance().getDataFolder().getAbsolutePath() + "/" + HiddenShopStorageUtil.HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
if(hiddenShopsJsonfile.exists()) {
@@ -283,28 +216,12 @@ public class ShopSearchActivityStorageUtil {
PlayerShopVisitModel playerShopVisit = new PlayerShopVisitModel();
playerShopVisit.setPlayerUUID(visitingPlayer.getUniqueId());
playerShopVisit.setVisitDateTime();
// shopSearchActivity.getPlayerVisitList().add(playerShopVisit);
globalShopsList.get(i).getPlayerVisitList().add(playerShopVisit);
LoggerUtils.logDebugInfo("Added new player visit entry at " + shopLocation.toString());
break;
}
i++;
}
// for(ShopSearchActivityModel shopSearchActivity : globalShopsList) {
// if(shopSearchActivity.compareWith(
// shopLocation.getWorld().getName(),
// shopLocation.getX(),
// shopLocation.getY(),
// shopLocation.getZ()
// )) {
// PlayerShopVisitModel playerShopVisit = new PlayerShopVisitModel();
// playerShopVisit.setPlayerUUID(visitingPlayer.getUniqueId());
// playerShopVisit.setVisitDateTime();
// shopSearchActivity.getPlayerVisitList().add(playerShopVisit);
// LoggerUtils.logDebugInfo("Added new player visit entry at " + shopLocation.toString());
// break;
// }
// }
}
});
}
@@ -322,4 +239,46 @@ public class ShopSearchActivityStorageUtil {
}
return 0;
}
@Nullable
public static OfflinePlayer getShopOwner(@NotNull Location shopLocation) {
for(ShopSearchActivityModel shopSearchActivity : globalShopsList) {
if (shopSearchActivity.compareWith(
shopLocation.getWorld().getName(),
shopLocation.getX(),
shopLocation.getY(),
shopLocation.getZ()
)) {
return Bukkit.getOfflinePlayer(UUID.fromString(shopSearchActivity.getShopOwnerUUID()));
}
}
return null;
}
@Nullable
public static UUID getShopOwnerUUID(@NotNull Location shopLocation) {
Iterator<ShopSearchActivityModel> globalShopsListIterator = globalShopsList.iterator();
while(globalShopsListIterator.hasNext()) {
ShopSearchActivityModel shopSearchActivity = globalShopsListIterator.next();
if (shopSearchActivity.compareWith(
shopLocation.getWorld().getName(),
shopLocation.getX(),
shopLocation.getY(),
shopLocation.getZ()
)) {
String uuidStr = shopSearchActivity.getShopOwnerUUID();
try {
return UUID.fromString(uuidStr);
} catch (IllegalArgumentException e) {
if(!FindItemAddOn.isQSReremakeInstalled()) {
UUID uuid = FindItemAddOn.getQsApiInstance().convertNameToUuid(uuidStr);
int index = globalShopsList.indexOf(shopSearchActivity);
globalShopsList.get(index).setShopOwnerUUID(uuid.toString());
}
}
return UUID.fromString(shopSearchActivity.getShopOwnerUUID());
}
}
return null;
}
}
@@ -1,9 +1,6 @@
package io.myzticbean.finditemaddon.Utils;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.QuickShopHandler.QSApi;
import io.myzticbean.finditemaddon.QuickShopHandler.QSHikariAPIHandler;
import io.myzticbean.finditemaddon.QuickShopHandler.QSReremakeAPIHandler;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -86,13 +83,6 @@ public class LocationUtils {
@Nullable
public static Location findSafeLocationAroundShop(Location shopLocation) {
Location roundedShopLoc = getRoundedDestination(shopLocation);
QSApi qsApi;
if(FindItemAddOn.isQSReremakeInstalled()) {
qsApi = new QSReremakeAPIHandler();
}
else {
qsApi = new QSHikariAPIHandler();
}
LoggerUtils.logDebugInfo("Rounded location: " + roundedShopLoc.getX() + ", " + roundedShopLoc.getY() + ", " + roundedShopLoc.getZ());
// Creating a list of four block locations in 4 sides of the shop
List<Location> possibleSafeLocList = new ArrayList<>();
@@ -122,7 +112,7 @@ public class LocationUtils {
));
for(Location loc_i : possibleSafeLocList) {
LoggerUtils.logDebugInfo("Possible safe location: " + loc_i.getX() + ", " + loc_i.getY() + ", " + loc_i.getZ());
if(loc_i.getBlock().getType().equals(qsApi.getShopSignMaterial())) {
if(loc_i.getBlock().getType().equals(FindItemAddOn.getQsApiInstance().getShopSignMaterial())) {
LoggerUtils.logDebugInfo("Shop sign block found at " + loc_i.getX() + ", " + loc_i.getY() + ", " + loc_i.getZ());
// check if the block above is suffocating
Location blockAbove = new Location(
@@ -147,7 +137,7 @@ public class LocationUtils {
if(blockBelow.getBlock().getType().equals(Material.AIR)
|| blockBelow.getBlock().getType().equals(Material.CAVE_AIR)
|| blockBelow.getBlock().getType().equals(Material.VOID_AIR)
|| blockBelow.getBlock().getType().equals(qsApi.getShopSignMaterial())) {
|| blockBelow.getBlock().getType().equals(FindItemAddOn.getQsApiInstance().getShopSignMaterial())) {
// do nothing and let the loop run
LoggerUtils.logDebugInfo("Shop or Air found below");
}
@@ -4,20 +4,34 @@ import io.myzticbean.finditemaddon.FindItemAddOn;
import me.kodysimpson.simpapi.colors.ColorTranslator;
import org.bukkit.Bukkit;
/**
* @author myzticbean
*/
public class LoggerUtils {
public static final String QS_FIND_ITEM_ADD_ON = "[QSFindItemAddOn] ";
public static final String QS_FIND_ITEM_ADD_ON_DEBUG_LOG = "[QSFindItemAddOn-DebugLog] ";
public static void logDebugInfo(String text) {
if(FindItemAddOn.getConfigProvider().DEBUG_MODE) {
Bukkit.getLogger().warning(ColorTranslator.translateColorCodes("[QSFindItemAddOn-DebugLog] " + text));
Bukkit.getLogger().warning(ColorTranslator.translateColorCodes(QS_FIND_ITEM_ADD_ON_DEBUG_LOG + getMainOrAsyncThreadLogText() + text));
}
}
public static void logInfo(String text) {
Bukkit.getLogger().info(ColorTranslator.translateColorCodes("[QSFindItemAddOn] " + text));
Bukkit.getLogger().info(ColorTranslator.translateColorCodes(QS_FIND_ITEM_ADD_ON + getMainOrAsyncThreadLogText() + text));
}
public static void logError(String text) {
Bukkit.getLogger().severe(ColorTranslator.translateColorCodes("[QSFindItemAddOn] " + text));
Bukkit.getLogger().severe(ColorTranslator.translateColorCodes(QS_FIND_ITEM_ADD_ON + text));
}
public static void logError(Exception e) {
Bukkit.getLogger().severe(ColorTranslator.translateColorCodes(QS_FIND_ITEM_ADD_ON + e.getMessage()));
e.printStackTrace();
}
public static void logWarning(String text) {
// Bukkit.getConsoleSender().sendMessage(ColorTranslator.translateColorCodes("[QSFindItemAddOn] &6" + text));
Bukkit.getLogger().warning(ColorTranslator.translateColorCodes("[QSFindItemAddOn] " + text));
Bukkit.getLogger().warning(ColorTranslator.translateColorCodes(QS_FIND_ITEM_ADD_ON + text));
}
private static String getMainOrAsyncThreadLogText() {
return Bukkit.isPrimaryThread() ? "[MAIN] " : "[ASYNC] ";
}
}
@@ -1,7 +1,7 @@
package io.myzticbean.finditemaddon.Utils;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPermsEnum;
import me.kodysimpson.simpapi.colors.ColorTranslator;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -53,7 +53,7 @@ public class UpdateChecker {
public void notifyPlayerAboutUpdateOnJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if(player.isOp() || player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())) {
if(player.isOp() || player.hasPermission(PlayerPermsEnum.FINDITEM_ADMIN.value())) {
if(FindItemAddOn.getPluginOutdated()) {
player.sendMessage(ColorTranslator.translateColorCodes(
prefix
@@ -1,10 +1,8 @@
package io.myzticbean.finditemaddon.Utils.WarpUtils;
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
import io.myzticbean.finditemaddon.FindItemAddOn;
import io.myzticbean.finditemaddon.Models.EssentialWarpModel;
import io.myzticbean.finditemaddon.Utils.CommonUtils;
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
import org.bukkit.Location;
import org.jetbrains.annotations.Nullable;
@@ -17,7 +15,7 @@ public class EssentialWarpsUtil {
@Nullable
public String findNearestWarp(Location shopLocation) {
List<EssentialWarpModel> allWarps = EssentialsXPlugin.getAllWarps();
if(allWarps != null && allWarps.size() > 0) {
if(allWarps != null && !allWarps.isEmpty()) {
Map<Double, String> warpDistanceMap = new TreeMap<>();
allWarps.forEach(warp -> {
Double distance = CommonUtils.calculateDistance3D(
@@ -30,11 +28,11 @@ public class EssentialWarpsUtil {
);
warpDistanceMap.put(distance, warp.warpName);
});
if(FindItemAddOn.getConfigProvider().DEBUG_MODE) {
/*if(FindItemAddOn.getConfigProvider().DEBUG_MODE) {
for(Map.Entry<Double, String> entry : warpDistanceMap.entrySet()) {
LoggerUtils.logDebugInfo(entry.getValue() + " : " + entry.getKey());
}
}
}*/
return warpDistanceMap.entrySet().iterator().next().getValue();
}
else {
@@ -1,43 +0,0 @@
package io.myzticbean.finditemaddon.Utils.WarpUtils;
//import me.ronsane.finditemaddon.finditemaddon.Dependencies.PWarpPlugin;
//import me.ronsane.finditemaddon.finditemaddon.FindItemAddOn;
//import me.ronsane.finditemaddon.finditemaddon.Utils.CommonUtils;
//import me.ronsane.finditemaddon.finditemaddon.Utils.LoggerUtils;
//import me.tks.playerwarp.Warp;
//import org.bukkit.Location;
//import org.jetbrains.annotations.Nullable;
//
//import java.util.List;
//import java.util.Map;
//import java.util.TreeMap;
public class PWarpsUtil {
// @Nullable
// public Warp findNearestWarp(Location shopLocation) {
// List<Warp> allWarps = PWarpPlugin.getAllWarps();
// if(allWarps.size() > 0) {
// Map<Double, Warp> warpDistanceMap = new TreeMap<>();
// allWarps.parallelStream().forEach(warp -> {
// warpDistanceMap.put(CommonUtils.calculateDistance2D(
// shopLocation.getX(),
// shopLocation.getY(),
// warp.getWarpLocation().getX(),
// warp.getWarpLocation().getY()
// ), warp);
// });
// if(FindItemAddOn.getConfigProvider().DEBUG_MODE) {
// for(Map.Entry<Double, Warp> entry : warpDistanceMap.entrySet()) {
// LoggerUtils.logDebugInfo(entry.getValue().getName() + " : " + entry.getKey());
// }
// }
//
// return warpDistanceMap.entrySet().iterator().next().getValue();
// }
// else {
// return null;
// }
// }
}
@@ -8,6 +8,7 @@ import io.myzticbean.finditemaddon.Utils.LoggerUtils;
import org.bukkit.Location;
import org.jetbrains.annotations.Nullable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -29,17 +30,25 @@ public class PlayerWarpsUtil {
warp.getWarpLocation().getZ()
), warp);
});
if(FindItemAddOn.getConfigProvider().DEBUG_MODE) {
for(Map.Entry<Double, Warp> entry : warpDistanceMap.entrySet()) {
LoggerUtils.logDebugInfo(entry.getValue().getWarpName() + " : " + entry.getKey());
if(!FindItemAddOn.getConfigProvider().DO_NOT_TP_IF_PLAYER_WARP_LOCKED)
return warpDistanceMap.entrySet().iterator().next().getValue(); // don't care if warp is locked or not
else {
// need to return a warp that is not locked
Iterator<Map.Entry<Double, Warp>> iterator = warpDistanceMap.entrySet().iterator();
// now keep looping until we find a warp that is not locked
while(iterator.hasNext()) {
Warp warp = iterator.next().getValue();
LoggerUtils.logDebugInfo("warp: " + warp.getWarpName() + " " + warp.isWarpLocked());
if(!warp.isWarpLocked()) {
return warp;
}
}
LoggerUtils.logError("No PlayerWarp found that is in 'unlocked' state");
return null;
}
return warpDistanceMap.entrySet().iterator().next().getValue();
}
else {
return null;
}
}
}
+33 -16
View File
@@ -1,8 +1,8 @@
# QuickShop Shop Search AddOn
# Works with both Reremake and Hikari forks of QuickShop
# Works with both Hikari and Reremake forks of QuickShop
# PLEASE refer the below link to understand the meaning of all the fields and sample data:
# https://gitlab.com/ronsane/QSFindItemAddOn/-/wikis/Sample-config.yml
# https://github.com/myzticbean/QSFindItemAddOn/wiki/Sample-config.yml
plugin-prefix: "&8[&a&lShop Search&8] &r"
find-item-command:
@@ -25,6 +25,8 @@ find-item-command:
shop-already-public-message: "&cThis shop is already public!"
invalid-shop-block-message: "&cThe block you are looking at is not a shop!"
hiding-shop-owner-invalid-message: "&cThat shop is not yours!"
remove-hideshop-revealshop-subcommands: false
disable-search-all-shops: false
shop-sorting-method: 2
search-loaded-shops-only: false
shop-search-gui-title: "&l» &rShops"
@@ -32,7 +34,7 @@ nearest-warp-mode: 1
shop-gui-item-lore:
- ""
- "&fPrice: &a${ITEM_PRICE}"
- "&fStock: &7{SHOP_STOCK}"
- "&fStock/Space: &7{SHOP_STOCK}"
- "&fOwner: &7{SHOP_OWNER}"
- "&fLocation: &7{SHOP_LOC}"
- "&fWorld: &7{SHOP_WORLD}"
@@ -45,23 +47,38 @@ player-shop-teleportation:
click-to-teleport-message: "&6&lClick to teleport to the shop!"
shop-tp-no-permission-message: "&cYou don't have permission to teleport to shop!"
unsafe-shop-area-message: "&cThe area around the shop is unsafe!"
tp-delay-in-seconds: 0
tp-delay-message: "&6You will be teleported in &c{DELAY} &6seconds..."
tp-to-own-shop-no-permission-message: "&cYou cannot teleport to your own shop!"
nearest-warp-tp-mode:
tp-player-to-nearest-warp: false
shop-gui-back-button-material: ""
shop-gui-back-button-text: "&7&l« &cBack"
shop-gui-next-button-material: ""
shop-gui-next-button-text: "&aNext &7&l»"
shop-gui-filler-item: "GRAY_STAINED_GLASS_PANE"
shop-gui-close-button-material: "BARRIER"
shop-gui-close-button-text: "&fClose Search"
shop-gui-back-button-custom-model-data: ""
shop-gui-next-button-custom-model-data: ""
shop-gui-close-button-custom-model-data: ""
shop-navigation-first-page-alert-message: "&cYou are already on first page!"
shop-navigation-last-page-alert-message: "&cYou are already on last page!"
do-not-tp-if-warp-locked: true
shop-gui:
back-button-material: "RED_CONCRETE"
back-button-text: "&7&l« &cBack"
next-button-material: "GREEN_CONCRETE"
next-button-text: "&aNext &7&l»"
filler-item: "GRAY_STAINED_GLASS_PANE"
close-button-material: "BARRIER"
close-button-text: "&fClose Search"
goto-first-page-button-material: ""
goto-first-page-button-text: "&7&l« &cGo to First Page"
goto-last-page-button-material: ""
goto-last-page-button-text: "&aGo to Last Page &7&l»"
shop-navigation:
first-page-alert-message: "&cYou are already on first page!"
last-page-alert-message: "&cYou are already on last page!"
custom-model-data:
back-button-custom-model-data: ""
next-button-custom-model-data: ""
close-button-custom-model-data: ""
goto-first-page-button-custom-model-data: ""
goto-last-page-button-custom-model-data: ""
use-shorter-currency-format: true
shop-player-visit-cooldown-in-minutes: 5
ignore-empty-chests: true
blacklisted-worlds:
- "world_number_1"
- "world_number_2"
debug-mode: false
config-version: 11
config-version: 15
+8 -5
View File
@@ -2,7 +2,7 @@ name: QSFindItemAddOn
version: ${project.version}
main: io.myzticbean.finditemaddon.FindItemAddOn
api-version: 1.16
authors: [ ronsane ]
authors: [ myzticbean ]
softdepend:
- QuickShop
- QuickShop-Hikari
@@ -18,14 +18,17 @@ permissions:
description: Enables players to use the /finditem hideshop & /finditem revealshop
default: true
finditem.reload:
description: For OP. Enables use of '/finditem reload' to reload the config
default: op
finditem.restart:
description: For OP. Enables use of '/finditem restart' to restart the plugin
description: For OP. Enables use of '/finditemadmin reload' to reload the config
default: op
finditem.admin:
description: For OP. Enables use of all admin commands
default: op
finditem.shoptp:
description: If 'allow-direct-shop-tp' is enabled in config, players require this permission to be able to teleport
default: op
finditem.shoptp.own:
description: Allows teleporting to own shops
default: true
finditem.shoptp-delay.bypass:
description: Bypass the TP delay for teleporting to shop
default: op
+53 -23
View File
@@ -1,4 +1,4 @@
# QuickShop Reremake and Hikari Shop Search AddOn
# QuickShop Hikari and Reremake Shop Search AddOn
########################################
# THIS IS JUST A SAMPLE CONFIG FILE
@@ -48,6 +48,11 @@ find-item-command:
shop-already-hidden-message: "&cThis shop is already hidden!"
shop-already-public-message: "&cThis shop is already public!"
invalid-shop-block-message: "&cThe block you are looking at is not a shop!"
# Added this config option to temporarily remove hideshop/revealshop sub-commands (Issue #5)
# Set it to 'true' if you want to remove those sub-commands
remove-hideshop-revealshop-subcommands: false
# If below option is set to 'true', it will remove the 'finditem TO_BUY/TO_SELL *' command
disable-search-all-shops: false
# Shop sorting methods:
@@ -78,7 +83,7 @@ nearest-warp-mode: 1
# Shop Search GUI Item Lore
# Placeholders for shop-item-lore:
# {ITEM_PRICE} -> Item price in shop
# {SHOP_STOCK} -> Remaining stock in shop
# {SHOP_STOCK} -> Remaining stock or space in shop depending on type of shop
# {SHOP_OWNER} -> Owner of shop
# {SHOP_LOC} -> Shop coordinates
# {SHOP_WORLD} -> Name of the world the shop is in
@@ -92,7 +97,7 @@ nearest-warp-mode: 1
shop-gui-item-lore:
- ""
- "&fPrice: &a${ITEM_PRICE}"
- "&fStock: &7{SHOP_STOCK}"
- "&fStock/Space: &7{SHOP_STOCK}"
- "&fOwner: &7{SHOP_OWNER}"
- "&fLocation: &7{SHOP_LOC}"
- "&fWorld: &7{SHOP_WORLD}"
@@ -113,33 +118,58 @@ player-shop-teleportation:
click-to-teleport-message: '&6&lClick to teleport to the shop!'
shop-tp-no-permission-message: '&cYou don''t have permission to teleport to shop!'
unsafe-shop-area-message: '&cThe area around the shop is unsafe!'
# When player clicks on a shop, how long to wait before teleporting to the shop (in seconds)
tp-delay-in-seconds: 0
# Message to show a player when they have clicked on a shop in GUI (Shown only if there is a non-zero TP delay)
# Set as '' if you do not want to show any message to player
# {DELAY} will be automatically replaced with value set in 'tp-delay-in-seconds'
tp-delay-message: "&6You will be teleported in &c{DELAY} &6seconds..."
# Players require 'finditem.shoptp.own' permission to teleport to their own shop.
# If no permission, below message will be shown.
tp-to-own-shop-no-permission-message: "&cYou cannot teleport to your own shop!"
nearest-warp-tp-mode:
# The player will be teleported to the nearest warp as if they ran the warp command
# Only works with EssentialsX Warps or PlayerWarps (configurable using 'nearest-warp-mode' in this config)
tp-player-to-nearest-warp: false
# Below option is applicable to PlayerWarps only. If set to true, player will not be teleported if the warp is locked
# So it will try to find a PlayerWarp that is not locked, if unable to find, an error will be shown
do-not-tp-if-warp-locked: true
shop-gui-back-button-material: "RED_CONCRETE"
shop-gui-back-button-text: "&7&l« &cBack"
shop-gui-next-button-material: "GREEN_CONCRETE"
shop-gui-next-button-text: "&aNext &7&l»"
shop-gui-filler-item: "GRAY_STAINED_GLASS_PANE"
shop-gui-close-button-material: "BARRIER"
shop-gui-close-button-text: "&fClose Search"
# Enter Item Custom Model Data below, if available, within quotes
# or leave as "" if not available
shop-gui-back-button-custom-model-data: ""
shop-gui-next-button-custom-model-data: ""
shop-gui-close-button-custom-model-data: ""
shop-gui:
back-button-material: "RED_CONCRETE"
back-button-text: "&7&l« &cBack"
next-button-material: "GREEN_CONCRETE"
next-button-text: "&aNext &7&l»"
filler-item: "GRAY_STAINED_GLASS_PANE"
close-button-material: "BARRIER"
close-button-text: "&fClose Search"
goto-first-page-button-material: ""
goto-first-page-button-text: "&7&l« &cGo to First Page"
goto-last-page-button-material: ""
goto-last-page-button-text: "&aGo to Last Page &7&l»"
# Alert shown when player is already on first/last page and clicks back/next button
shop-navigation:
first-page-alert-message: "&cYou are already on first page!"
last-page-alert-message: "&cYou are already on last page!"
# Enter Item Custom Model Data below, if available, within quotes
# or leave as "" if not available
custom-model-data:
back-button-custom-model-data: ""
next-button-custom-model-data: ""
close-button-custom-model-data: ""
goto-first-page-button-custom-model-data: ""
goto-last-page-button-custom-model-data: ""
# Enabling this will convert currency values to a shorter format
# For example: $10,210,100 will be shown as $10.21M
use-shorter-currency-format: true
# Alert shown when player is already on first/last page and clicks back/next button
shop-navigation-first-page-alert-message: "&cYou are already on first page!"
shop-navigation-last-page-alert-message: "&cYou are already on last page!"
# Specify (in minutes) how long the plugin will wait before incrementing the player
# shop visit when teleporting to it from Search GUI
# Specify (in minutes) how long the plugin will wait before incrementing the player shop visit count
# when teleporting to it from Search GUI
shop-player-visit-cooldown-in-minutes: 5
# Ignore empty chests from search result
ignore-empty-chests: true
# When fetching shops, the below worlds will be ignored
blacklisted-worlds:
- "world_number_1"
@@ -151,4 +181,4 @@ blacklisted-worlds:
debug-mode: false
# Do not change the below value
config-version: 11
config-version: 15