Compare commits
251
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a151c618ff | ||
|
|
5427d34d08 | ||
|
|
66f5d50b78 | ||
|
|
98ecddeeaa | ||
|
|
f1360309ad | ||
|
|
94f9fcf0f2 | ||
|
|
72fd9750d7 | ||
|
|
59b9d7b612 | ||
|
|
4151dda51f | ||
|
|
6b41d66a19 | ||
|
|
d68f1c56b9 | ||
|
|
ce5ec35082 | ||
|
|
d7f596a9ec | ||
|
|
bdd19256e5 | ||
|
|
57c89cf129 | ||
|
|
e96b32a216 | ||
|
|
fe035dfe67 | ||
|
|
fea4f529cd | ||
|
|
a7de242323 | ||
|
|
dbe610d76a | ||
|
|
a6cc9a7951 | ||
|
|
429427d6a3 | ||
|
|
7441de763f | ||
|
|
defdbadb61 | ||
|
|
4fafff5fd4 | ||
|
|
43ffc1dc95 | ||
|
|
03ca4896df | ||
|
|
17af28cebb | ||
|
|
d7bcda0f59 | ||
|
|
c883bec465 | ||
|
|
6fd36205ad | ||
|
|
466b03f191 | ||
|
|
065a5d6b96 | ||
|
|
e3bfa3f6d3 | ||
|
|
8d51bdb940 | ||
|
|
681500c8b2 | ||
|
|
9c5dd789e4 | ||
|
|
8befcf4f5f | ||
|
|
5b1a62eb5b | ||
|
|
92fa809e7f | ||
|
|
54a0a68e67 | ||
|
|
8f4e6b694d | ||
|
|
643588be6f | ||
|
|
b9f0f43f04 | ||
|
|
ba6ea31bd4 | ||
|
|
830060980d | ||
|
|
d420ae9115 | ||
|
|
cae485468c | ||
|
|
948d95e84b | ||
|
|
2de77043d7 | ||
|
|
83bef37c03 | ||
|
|
737d9670b4 | ||
|
|
c1e2743dbe | ||
|
|
b9728e1810 | ||
|
|
f7da85be75 | ||
|
|
12c08a8737 | ||
|
|
468a5fc135 | ||
|
|
9ae1844dfe | ||
|
|
9232eb7da7 | ||
|
|
7d8db88fd9 | ||
|
|
f8a80b97b1 | ||
|
|
71e6f38940 | ||
|
|
b04b974c20 | ||
|
|
e4f9b4f721 | ||
|
|
cfe77bb711 | ||
|
|
aa263f15ae | ||
|
|
1f89babf0e | ||
|
|
63fdae31e1 | ||
|
|
53ae07b774 | ||
|
|
f19ad53a91 | ||
|
|
7a9e96a43e | ||
|
|
d2f4e14831 | ||
|
|
245e1bb986 | ||
|
|
08486e972b | ||
|
|
e2301fbc08 | ||
|
|
6ac4782d70 | ||
|
|
c3508c495e | ||
|
|
8be14a3c93 | ||
|
|
54deccc93d | ||
|
|
ce6132886d | ||
|
|
555a345228 | ||
|
|
e9d1504b14 | ||
|
|
d7af0e11f4 | ||
|
|
a3edfa8ee9 | ||
|
|
3d53cb18fe | ||
|
|
1fb1bdd1a0 | ||
|
|
d4a084f44d | ||
|
|
5b9eab72b7 | ||
|
|
95d708a2a5 | ||
|
|
f1873211bb | ||
|
|
9b43e17c9e | ||
|
|
94ebf71474 | ||
|
|
8eba532b70 | ||
|
|
a93589e85f | ||
|
|
8819b0957c | ||
|
|
401cb2466b | ||
|
|
a456e57b95 | ||
|
|
d7ccde94ab | ||
|
|
ffbd291bde | ||
|
|
b40a57f295 | ||
|
|
09679dcab1 | ||
|
|
a24e34696b | ||
|
|
8411ba79f2 | ||
|
|
53ea1e9bee | ||
|
|
1fe042c8ce | ||
|
|
60e32b4447 | ||
|
|
39c987e015 | ||
|
|
b5bcd264bb | ||
|
|
6c9c09b464 | ||
|
|
1fcbbe6de7 | ||
|
|
93c9dac03c | ||
|
|
74454931e6 | ||
|
|
20f36b82d3 | ||
|
|
9c513fe74d | ||
|
|
4232f09b58 | ||
|
|
4ffef673a8 | ||
|
|
4efe042d9a | ||
|
|
dbb01d6059 | ||
|
|
27515dcd79 | ||
|
|
ec7b0e7c1b | ||
|
|
1acacc4ab2 | ||
|
|
077a610590 | ||
|
|
2bbe230c8b | ||
|
|
6f45a50f82 | ||
|
|
c0844461d3 | ||
|
|
a215c1c4bd | ||
|
|
2aa62fe2d8 | ||
|
|
8768c9334f | ||
|
|
64a930e454 | ||
|
|
75a3062cd4 | ||
|
|
70c9faef70 | ||
|
|
56300803ae | ||
|
|
671378482e | ||
|
|
488cdbe69b | ||
|
|
35865e2de8 | ||
|
|
2cb6cca4f7 | ||
|
|
5bf488b152 | ||
|
|
45499d2a07 | ||
|
|
de5909ea1c | ||
|
|
ac5be686ea | ||
|
|
13c6180c26 | ||
|
|
7bf4cfcba0 | ||
|
|
afbc456976 | ||
|
|
04390c2b67 | ||
|
|
5a134d3425 | ||
|
|
4a7daf3d09 | ||
|
|
6e0dc2f0ab | ||
|
|
88a3253dd4 | ||
|
|
1517ab7f51 | ||
|
|
891624fae0 | ||
|
|
414086b466 | ||
|
|
1ac30c9b36 | ||
|
|
bc3aa2de98 | ||
|
|
0bb26e13f6 | ||
|
|
aa73d2f327 | ||
|
|
16720cae1d | ||
|
|
0f4295642c | ||
|
|
e580d27ccf | ||
|
|
4ac6914c49 | ||
|
|
ef10e2682f | ||
|
|
982766922a | ||
|
|
f0068250e9 | ||
|
|
9de66d52dc | ||
|
|
c00a07af3e | ||
|
|
8a85043815 | ||
|
|
6da95d89b1 | ||
|
|
80e01b8d8c | ||
|
|
ff03f2373c | ||
|
|
28b582e5f3 | ||
|
|
30651feac0 | ||
|
|
e73c28fe77 | ||
|
|
ca3e2b955c | ||
|
|
59f42b423f | ||
|
|
8ca4de53bc | ||
|
|
e60b266bf3 | ||
|
|
15df2b84c5 | ||
|
|
d574d1e3be | ||
|
|
7e0ce839f6 | ||
|
|
375669c990 | ||
|
|
d634de842e | ||
|
|
7c89ed8ee6 | ||
|
|
874d675113 | ||
|
|
477d943c7f | ||
|
|
e882a805c3 | ||
|
|
fcd2440706 | ||
|
|
cdbfee8992 | ||
|
|
7d6d88d012 | ||
|
|
00f65a1e76 | ||
|
|
e372eb5d7b | ||
|
|
8629bd8f0b | ||
|
|
1526c01227 | ||
|
|
9e1a239974 | ||
|
|
52e346ef96 | ||
|
|
bf82fe0d09 | ||
|
|
49acbcbbd1 | ||
|
|
448bf861dc | ||
|
|
05fb5bf17b | ||
|
|
1c9ccd7803 | ||
|
|
68bf709b0c | ||
|
|
a4c9227e75 | ||
|
|
49212c2271 | ||
|
|
7804712677 | ||
|
|
044dc87485 | ||
|
|
3ec1bdf577 | ||
|
|
ab054ced56 | ||
|
|
9b8845e5b9 | ||
|
|
d2712da754 | ||
|
|
a0969a05a4 | ||
|
|
e37716f77a | ||
|
|
061de9b12e | ||
|
|
b7d3b7310c | ||
|
|
2b32f57b17 | ||
|
|
dd9f58be35 | ||
|
|
f99a0ffff9 | ||
|
|
9dbb08accf | ||
|
|
c437a7489d | ||
|
|
c879f29895 | ||
|
|
c5a925286d | ||
|
|
de84d67cc6 | ||
|
|
08c5266a7c | ||
|
|
9f416d4435 | ||
|
|
7d0ef75314 | ||
|
|
9d54c57c00 | ||
|
|
10e5da927b | ||
|
|
3bc4605194 | ||
|
|
9e7daf81c3 | ||
|
|
41e3f4e695 | ||
|
|
34999e3816 | ||
|
|
bc53521578 | ||
|
|
6e0aa9aff5 | ||
|
|
9a47f30708 | ||
|
|
299750e8c4 | ||
|
|
8c1d1b66eb | ||
|
|
9da6a9df2f | ||
|
|
b7c3880c78 | ||
|
|
eba6a03d37 | ||
|
|
fdc96110b6 | ||
|
|
40b177afc4 | ||
|
|
ab4fa4834f | ||
|
|
88585fc0da | ||
|
|
3ab7e575c1 | ||
|
|
abfb073f6e | ||
|
|
a4a66e7f4f | ||
|
|
0f2cf64f80 | ||
|
|
09ac07568b | ||
|
|
59d8a6e467 | ||
|
|
22f93b7023 | ||
|
|
1c18378d53 | ||
|
|
1e5148fd7b | ||
|
|
90a2dab37d | ||
|
|
54ec3988ad |
No files matched your search
@@ -1 +0,0 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -1,3 +0,0 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: myzticbean
|
||||
|
||||
---
|
||||
|
||||
## 🐞Bug Report
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Spigot server fork and version:**
|
||||
|
||||
**QuickShop Hikari version:**
|
||||
|
||||
**QSFinditemAddOn version:**
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
<br><br>
|
||||
> [!NOTE]
|
||||
> **By submitting a bug report, you agree to the following:**
|
||||
> - Bug fixes can take time and there is no ETA for resolution.
|
||||
> - Prioritization is based on development capacity & bug criticality.
|
||||
> - Support for QuickShop-Reremake integration has been dropped.
|
||||
> - Search first. Check existing issues to avoid duplicates.
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Create a feature request
|
||||
title: ''
|
||||
labels: feature
|
||||
assignees: myzticbean
|
||||
|
||||
---
|
||||
## Feature Request
|
||||
|
||||
**Describe your feature**
|
||||
A clear and concise description of what enhancement you are looking for.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
|
||||
<br><br>
|
||||
> [!NOTE]
|
||||
> **By submitting a feature request, you agree to the following:**
|
||||
> - Submitting a feature request doesn't guarantee implementation.
|
||||
> - Features are prioritized purely based on development capacity & community needs.
|
||||
@@ -0,0 +1,30 @@
|
||||
# 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: Maven Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ "master", "release/v2.0" ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
- name: Build with Maven
|
||||
run: mvn clean install
|
||||
@@ -0,0 +1,89 @@
|
||||
# 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: Publish Release
|
||||
|
||||
on:
|
||||
# push:
|
||||
# branches: [ "master" ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Setup Environment, Build JAR and Release Project
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
- name: Upload JAR as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: QSFindItemAddOn
|
||||
path: target/QSFindItemAddOn-*.jar
|
||||
- name: Automatic Release
|
||||
uses: Fulminazzo/java-automatic-release@v2
|
||||
with:
|
||||
java-version: '21'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPOSITORY_NAME: ${{ github.event.repository.name }}
|
||||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||
- name: Get Release Info and Rename
|
||||
id: get_release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
release_info=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
|
||||
"https://api.github.com/repos/${{ github.repository }}/releases/latest")
|
||||
|
||||
release_id=$(echo "$release_info" | jq -r .id)
|
||||
upload_url=$(echo "$release_info" | jq -r .upload_url)
|
||||
version=$(echo "$release_info" | jq -r .tag_name)
|
||||
|
||||
# Extract full version from the release name (including RELEASE or SNAPSHOT)
|
||||
full_version=$(echo "$release_info" | jq -r .name | sed 's/.*[[:space:]]//')
|
||||
|
||||
# Determine if it's a RELEASE or SNAPSHOT
|
||||
if [[ $full_version == *-SNAPSHOT ]]; then
|
||||
jar_suffix="-SNAPSHOT"
|
||||
else
|
||||
jar_suffix="-RELEASE"
|
||||
fi
|
||||
|
||||
# Construct the full JAR name
|
||||
jar_name="QSFindItemAddOn-${full_version}${jar_suffix}.jar"
|
||||
|
||||
# Update the release name to include RELEASE or SNAPSHOT
|
||||
curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
"https://api.github.com/repos/${{ github.repository }}/releases/$release_id" \
|
||||
-d "{\"name\":\"$full_version\"}"
|
||||
|
||||
echo "upload_url=$upload_url" >> $GITHUB_OUTPUT
|
||||
echo "version=$full_version" >> $GITHUB_OUTPUT
|
||||
echo "jar_name=$jar_name" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Upload JAR to Release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.get_release.outputs.upload_url }}
|
||||
asset_path: ./target/${{ steps.get_release.outputs.jar_name }}
|
||||
asset_name: ${{ steps.get_release.outputs.jar_name }}
|
||||
asset_content_type: application/java-archive
|
||||
+1
-10
@@ -8,16 +8,6 @@
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# Eclipse
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
# Gradle
|
||||
bin/
|
||||
build/
|
||||
.gradle/
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
@@ -29,6 +19,7 @@ build/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
!lib/*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
[submodule "libs/Utilities-OG"]
|
||||
path = libs/Utilities-OG
|
||||
url = https://git.trueog.net/trueog/Utilities-OG
|
||||
+173
@@ -1,3 +1,144 @@
|
||||
## Release 2.0.8.0
|
||||
### Changes
|
||||
- QS-Reremake support has been dropped completely
|
||||
- GUI click is now async
|
||||
- Changed logger statements to show Main/Async thread state
|
||||
- Changed materials list in `LocationUtils` from `ArrayList` to `HashSet` to improve performance
|
||||
- Added debug mode control via command: `/finditemadmin debug-mode {enable | disable}`
|
||||
|
||||
## Release 2.0.7.7
|
||||
### Changes
|
||||
- Changed comma delimiter to triple pipe (PR #83 by @MattDeWeerd)
|
||||
- Added initial classes for Modrinth API integration and a VirtualThreadScheduler for handling asynchronous tasks.
|
||||
- Relocated all enum classes from the `utils.enums` package to `models.enums` to improve project structure and organization.
|
||||
- Bumped Spigot dependency to `1.21.8-R0.1-SNAPSHOT`
|
||||
- Bumped QS-Hikari dependency to `6.2.0.10`
|
||||
- Bumped Bentobox dependency to `3.7.3`
|
||||
|
||||
## Release 2.0.7.6
|
||||
### Bug fixes
|
||||
- Fixed `/finditem hideshop`/`/finditem revealshop` not working for newly created shop
|
||||
- Added support for custom-model-data to the GUI filler item
|
||||
- Added support for `{SHOP_WORLD}` placeholder in custom commands
|
||||
|
||||
### Changes
|
||||
- Optimized the size of the `shops.json` file
|
||||
- Updated config version to `21`
|
||||
|
||||
## Release 2.0.7.5
|
||||
### Changes
|
||||
- Updated dependencies to latest version
|
||||
- Fixed a bug teleporting to a shop without essentials (PR #77)
|
||||
|
||||
## Release 2.0.7.4
|
||||
### Bug fixes
|
||||
- Fix for /finditem shows only 'searching...' but no GUI (PR #69)
|
||||
|
||||
## Release 2.0.7.3
|
||||
### Changes
|
||||
- JDK version upgraded from 17 to 21
|
||||
- Added check to exclude shops of `buying` shops for owners who don't have enough money.
|
||||
- Bentobox integration to ignore shops in locked islands
|
||||
|
||||
### Bug fixes
|
||||
- Hideshop/revealshop should work with double chests also
|
||||
|
||||
## Release 2.0.7.2
|
||||
### Bug fixes
|
||||
- Fixed item meta not showing correctly in Search GUI
|
||||
|
||||
## Release 2.0.7.1
|
||||
### Changes
|
||||
- Added config option to suppress update notifications in chat
|
||||
```yaml
|
||||
suppress-update-notifications: false
|
||||
```
|
||||
- Added config option to configure blacklisted materials
|
||||
```yaml
|
||||
blacklisted-materials:
|
||||
- "BARRIER"
|
||||
- "STRUCTURE_BLOCK"
|
||||
- "COMMAND_BLOCK"
|
||||
```
|
||||
|
||||
## Release 2.0.7.0
|
||||
### Changes
|
||||
- Added runnable custom commands on GUI item click. New related config options added.
|
||||
- Added a new permission to bypass safety check for shop tp.
|
||||
- MAJOR code refactoring in FoundShopsMenu.java to make it human readable.. finally!
|
||||
- Added publish-release.yml github action
|
||||
|
||||
## Release 2.0.6.4
|
||||
### Changes
|
||||
- Residence support for fetching the residence the shop is in (including subzones) ([#45](https://github.com/myzticbean/QSFindItemAddOn/pull/45)) [Contribution by SengyEU]
|
||||
- Configurable "No ... near shop" messages ([#45](https://github.com/myzticbean/QSFindItemAddOn/pull/45)) [Contribution by SengyEU]
|
||||
- Spigot API updated to 1.21.
|
||||
|
||||
### Bug fixes
|
||||
- Fixed NPE when putting AIR as a filler item ([#46](https://github.com/myzticbean/QSFindItemAddOn/pull/46)) [Contribution by SengyEU]
|
||||
- Fixed bug where exception was thrown when trying to render player heads in GUI buttons (Broke in 1.21 update)
|
||||
|
||||
## Release 2.0.6.3
|
||||
### Changes
|
||||
- Added stack size placeholder to shop lore ([#37](https://github.com/myzticbean/QSFindItemAddOn/issues/37))
|
||||
- Added a 500 block limit for searching nearby PlayerWarp (@TODO: to be made configurable in a future version)
|
||||
|
||||
## Release 2.0.6.2
|
||||
### Changes
|
||||
- Added option to show only player owned warps in GUI ([#38](https://github.com/myzticbean/QSFindItemAddOn/issues/38)) [Contribution by lukemango]
|
||||
|
||||
## Release 2.0.6.1
|
||||
### Bug fixes
|
||||
- Changed scheduled task loggers to debug-mode only ([#29](https://github.com/myzticbean/QSFindItemAddOn/issues/29))
|
||||
- Fix for players not getting teleported ([#30](https://github.com/myzticbean/QSFindItemAddOn/issues/30))
|
||||
|
||||
## 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))
|
||||
@@ -21,3 +162,35 @@
|
||||
- Fix for Issue [#24](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues/24)
|
||||
- Fixed a bug related to nearest warp teleportation algorithm
|
||||
- Other minor bug fixes
|
||||
|
||||
## Snapshot 2.0
|
||||
### Changes
|
||||
- **QuickShop-Hikari Support:** It now supports both QuickShop-Reremake and QuickShop-Hikari.
|
||||
- **Hexcode color support:** All messages in the config.yml now support hexcodes so you can get a lot more creative with colors.
|
||||
- **Different commands for players and admins**
|
||||
- The /finditem command is now split into two:
|
||||
- `/finditem` - This will support the usual shop searches and hiding
|
||||
- `/finditemadmin` or `/fiadmin` - This will support plugin reloads. For example: `/fiadmin reload`.
|
||||
- **View all shops on server:** Now you can do `/finditem TO_BUY *` or `/finditem TO_SELL *` to view all shops on the server. As of this version, the sequence is always randomized. Sorting options are a work in progress.
|
||||
- **New shop visit count:** Now you can choose to display shop visits count in the shop lore in Search GUI. Just add the placeholder {SHOP_VISITS} in the "shop-gui-item-lore" in config.yml. To prevent visit spamming, a new config property "shop-player-visit-cooldown-in-minutes" has been added. Please don't use decimals here LOL.
|
||||
- **New storage format:** The "hiddenShops.json" will automatically be converted to a new file called "shops.json" which will store data of all shops along with their player visit count and whether they are hidden from searches.
|
||||
- **New Next/Back buttons:** The default next/back buttons are now fancy playerheads to make more sense. If you don't wish to use them, just specify the material in the config.yml.
|
||||
- **Customizable command aliases:** Added a new property in config.yml called "command-alias" where you can specify your own list of command aliases for /finditem command. If you don't wish to add any, just make it as:
|
||||
```yaml
|
||||
command-alias: []
|
||||
```
|
||||
- **Compatibility with QuickShop-Hikari v2.0.0.0:** Added support for Per Shop permission management for "quickshop-hikari.search". If for a shop, the shop owner Steve configures Alex to be in a group that does not have "quickshop-hikari.search" permission, then Alex won't be able to see that shop in GUI when searching.
|
||||
- **Added finditem sub-command for /qs:** Now you can try the below commands, same functionality. This feature removes the original /qs find sub-command to avoid confusion among players.
|
||||
- Added a new sample-config.yml file which will be copied over to the plugin folder. This file is just for your reference when editing the fields in the actual config.yml file.
|
||||
|
||||
### Bug fixes
|
||||
- Removed an erroneous config field "warp-player-to-nearest-warp".
|
||||
- Fixed an issue where it will load up the plugin before QuickShop is done loading causing it to disable itself. Thanks Baran for reporting :)
|
||||
- Added support for EssentialsX /back.
|
||||
- Fixed a bug that broke autocompletes for all commands in-game.
|
||||
- Made minor bug fixes when enabling plugin.
|
||||
- Made some fixes in the search system for shops that are buying items.
|
||||
- Some other minor stability fixes.
|
||||
- Fixed bug in which the new `/qs finditem` sub-command was not showing up in `/qs help`.
|
||||
- Fixed a NullPointerException bug for PlayerWarps plugin integration.
|
||||
- Updated PlayerWarps API to latest version and fixed a NPE console error
|
||||
@@ -0,0 +1,26 @@
|
||||
# Contributing to Shop Search AddOn
|
||||
|
||||
If you have experience in making bukkit/spigot plugins, you can contribute to the Shop Search AddOn codebase.
|
||||
Just make a fork and then make a pull request when you're done.
|
||||
Please try to follow the [Google Java Style](https://google.github.io/styleguide/javaguide.html), or just try to copy the style of code found in the class you're editing.
|
||||
But, please don't increase the plugin version number.
|
||||
|
||||
### How to compile?
|
||||
|
||||
**Requirements**
|
||||
1. Java 21 JDK in PATH
|
||||
2. Git
|
||||
3. Maven
|
||||
|
||||
**Compiling from source**
|
||||
```shell
|
||||
git clone https://github.com/myzticbean/QSFindItemAddOn.git
|
||||
cd QSFindItemAddOn/
|
||||
mvn clean install
|
||||
```
|
||||
|
||||
### After making a Fork
|
||||
1. Please create your own sub-branch before adding your changes.
|
||||
2. Sub-branch naming convention:
|
||||
1. If it's a new feature you are implementing, name should be `feature/<your feature name>` without the `<>`.
|
||||
2. If it's a bug you're fixing, name should be `issuefix/<issue number>` without the `<>`.
|
||||
@@ -0,0 +1,675 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari and
|
||||
Reremake Shop plugins for Spigot server platform.
|
||||
Copyright (C) 2021 myzticbean
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
QSFindItemAddOn Copyright (C) 2021 myzticbean
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
Copyright 2021 RonCreations
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,10 +1,13 @@
|
||||
# QSFindItemAddOn-OG
|
||||
# Shop Search AddOn For QuickShop
|
||||
### Version: 2.0.8.0-SNAPSHOT-1221
|
||||
|
||||
A 1.19.4 fork of QSFindItemAddOn, an unofficial add-on for the QuickShop Hikari and Reremake spigot plugin.
|
||||
Adds a `/find` command in game for searching through all the shops on the server.
|
||||
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.
|
||||
|
||||

|
||||

|
||||
[//]: # ()
|
||||

|
||||

|
||||

|
||||
|
||||
## Features
|
||||
- Search items based on buying/selling shops
|
||||
@@ -19,22 +22,23 @@ Adds a `/find` command in game for searching through all the shops on the server
|
||||
- Supports completely safe direct shop teleportation (configurable in config.yml)
|
||||
- Ignores shops that are out of stock by default
|
||||
- Support for world blacklisting (Shops in blacklisted worlds are ignored in the search result)
|
||||
- Support for material blacklisting that prevents players for searching for specific items
|
||||
|
||||
|
||||
**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.
|
||||
|
||||
**View all shops on server**
|
||||
- You can do `/find TO_BUY *` or `/find TO_SELL *` to view all shops on the server. As of this version, the sequence is always randomized. Sorting options are a work in progress.
|
||||
- You can do `/finditem TO_BUY *` or `/finditem TO_SELL *` to view all shops on the server. As of this version, the sequence is always randomized. Sorting options are a work in progress.
|
||||
|
||||
**Shop visit count**
|
||||
- You can choose to display shop visits count in the shop lore in Search GUI. Just add the placeholder `{SHOP_VISITS}` in the `shop-gui-item-lore` in config.yml. To prevent visit spamming, a new config property `shop-player-visit-cooldown-in-minutes` has been added. Please don't use decimals here. 😁
|
||||
|
||||
**Customizable command aliases**
|
||||
- You can find a property in config.yml called `command-alias` where you can specify your own list of command aliases for /find command. If you don't wish to add any, just make it as:
|
||||
- You can find a property in config.yml called `command-alias` where you can specify your own list of command aliases for /finditem command. If you don't wish to add any, just make it as:
|
||||
```yaml
|
||||
command-alias: []
|
||||
```
|
||||
@@ -42,15 +46,16 @@ 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)
|
||||
- Residence support for fetching the residence the shop is in (including subzones)
|
||||
|
||||
>Check out the sample config.yml [here](https://github.com/myzticbean/QSFindItemAddOn/wiki/Sample-config.yml).
|
||||
|
||||
## Requires
|
||||
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v5.2 or higher
|
||||
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v6.0 or higher
|
||||
|
||||
**OR**
|
||||
|
||||
@@ -69,3 +74,16 @@ See more details [here](https://github.com/myzticbean/QSFindItemAddOn/blob/maste
|
||||
|
||||
## BStats Metrics
|
||||
[](https://bstats.org/plugin/bukkit/QSFindItemAddOn/12382)
|
||||
|
||||
## Demo
|
||||
### How to use `/finditem`?
|
||||

|
||||

|
||||
### Multiple search result pages:
|
||||

|
||||
### Shows item enchantments:
|
||||

|
||||
### Shows Potion colors and effects:
|
||||

|
||||
### Shows custom item names and lore:
|
||||

|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Fetch all submodule content.
|
||||
git submodule update --force --recursive --init
|
||||
@@ -1,190 +0,0 @@
|
||||
/* ------------------------------ Plugins ------------------------------ */
|
||||
plugins {
|
||||
id("java") // Import Java plugin.
|
||||
id("java-library") // Import Java Library plugin.
|
||||
id("com.diffplug.spotless") version "8.1.0" // Import Spotless plugin.
|
||||
id("com.gradleup.shadow") version "8.3.9" // Import Shadow plugin.
|
||||
id("checkstyle") // Import Checkstyle plugin.
|
||||
eclipse // Import Eclipse plugin.
|
||||
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
|
||||
}
|
||||
|
||||
extra["kotlinAttribute"] = Attribute.of("kotlin-tag", Boolean::class.javaObjectType)
|
||||
|
||||
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
|
||||
|
||||
/* --------------------------- JDK / Kotlin ---------------------------- */
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
|
||||
toolchain { // Select Java toolchain.
|
||||
languageVersion.set(JavaLanguageVersion.of(17)) // Use JDK 17.
|
||||
vendor.set(JvmVendorSpec.GRAAL_VM) // Use GraalVM CE.
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------- Metadata ------------------------------ */
|
||||
group = "io.myzticbean.FindItemAddOnOG" // Declare bundle identifier.
|
||||
|
||||
version = "1.0.1" // Declare plugin version (will be in .jar).
|
||||
|
||||
val apiVersion = "1.19" // Declare minecraft server target version.
|
||||
val platformApi = "org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT"
|
||||
|
||||
/* ----------------------------- Resources ----------------------------- */
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
val inputsProps =
|
||||
mapOf(
|
||||
"version" to version.toString(),
|
||||
"apiVersion" to apiVersion,
|
||||
"projectName" to project.name,
|
||||
"projectGroup" to project.group.toString(),
|
||||
)
|
||||
val templateProps =
|
||||
mapOf(
|
||||
"version" to version.toString(),
|
||||
"apiVersion" to apiVersion,
|
||||
"project" to mapOf("name" to project.name, "group" to project.group.toString()),
|
||||
)
|
||||
inputs.properties(inputsProps) // Indicates to rerun if version changes.
|
||||
filteringCharset = "UTF-8"
|
||||
filesMatching("plugin.yml") { expand(templateProps) }
|
||||
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
|
||||
}
|
||||
|
||||
val copyReadme by
|
||||
tasks.registering(Copy::class) {
|
||||
val templateProps =
|
||||
mapOf(
|
||||
"version" to version.toString(),
|
||||
"apiVersion" to apiVersion,
|
||||
"project" to mapOf("name" to project.name, "group" to project.group.toString()),
|
||||
)
|
||||
from("src/main/doc") {
|
||||
include("README.md")
|
||||
expand(templateProps)
|
||||
}
|
||||
into(layout.buildDirectory.dir("generated/readme"))
|
||||
}
|
||||
|
||||
/* ---------------------- Java project deps ---------------------------- */
|
||||
dependencies {
|
||||
implementation("com.ghostchu.quickshop.compatibility:common:5.2.0.7") {
|
||||
exclude(group = "org.jetbrains", module = "annotations")
|
||||
exclude(group = "net.kyori", module = "adventure-platform-bukkit")
|
||||
exclude(group = "com.github.juliomarcopineda", module = "jdbc-stream")
|
||||
exclude(group = "one.util", module = "streamex")
|
||||
exclude(group = "tne.tne", module = "TheNewEconomy")
|
||||
exclude(group = "me.xanium", module = "GemsEconomy")
|
||||
}
|
||||
compileOnly("com.ghostchu:quickshop-bukkit:5.2.0.5:shaded") {
|
||||
exclude(group = "org.jetbrains", module = "annotations")
|
||||
exclude(group = "net.kyori", module = "adventure-platform-bukkit")
|
||||
exclude(group = "com.github.juliomarcopineda", module = "jdbc-stream")
|
||||
exclude(group = "one.util", module = "streamex")
|
||||
exclude(group = "tne.tne", module = "TheNewEconomy")
|
||||
exclude(group = "me.xanium", module = "GemsEconomy")
|
||||
}
|
||||
compileOnly(platformApi) // Declare Purpur API version to be packaged.
|
||||
compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG Java API (from source).
|
||||
compileOnly("com.ghostchu:quickshop-api:5.2.0.7") { // Import QuickShop-Hikari Core API.
|
||||
exclude(group = "org.jetbrains", module = "annotations")
|
||||
exclude(group = "net.kyori", module = "adventure-platform-bukkit")
|
||||
exclude(group = "com.github.juliomarcopineda", module = "jdbc-stream")
|
||||
exclude(group = "one.util", module = "streamex")
|
||||
exclude(group = "tne.tne", module = "TheNewEconomy")
|
||||
exclude(group = "me.xanium", module = "GemsEconomy")
|
||||
}
|
||||
compileOnly("com.github.true-og.OpenInv:openinvapi:a85e8ebc28")
|
||||
compileOnly("org.maxgamer:QuickShop:5.1.2.5-SNAPSHOT") { isTransitive = false }
|
||||
implementation("io.papermc:paperlib:1.0.7")
|
||||
compileOnly("net.essentialsx:EssentialsX:2.21.0") { isTransitive = false }
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.8") { // Import WorldGuard API.
|
||||
exclude(group = "com.google.code.findbugs", module = "annotations")
|
||||
exclude(group = "net.java.truecommons", module = "truecommons-logging")
|
||||
exclude(group = "org.slf4j", module = "jcl-over-slf4j")
|
||||
exclude(group = "org.bstats", module = "bstats-bukkit")
|
||||
exclude(group = "org.bukkit", module = "bukkit")
|
||||
exclude(group = "com.google.guava", module = "guava")
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
exclude(group = "org.yaml", module = "snakeyaml")
|
||||
exclude(group = "com.google.code.findbugs", module = "jsr305")
|
||||
exclude(group = "org.spigotmc", module = "spigot-api")
|
||||
exclude(group = "org.apache.httpcomponents", module = "httpclient")
|
||||
exclude(group = "net.java.truevfs", module = "truevfs-comp-zip")
|
||||
exclude(group = "net.java.truevfs", module = "truevfs-comp-tardriver")
|
||||
}
|
||||
implementation("com.google.code.gson:gson:2.9.0")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0") { isTransitive = false }
|
||||
compileOnly("org.projectlombok:lombok:1.18.26")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.26")
|
||||
implementation("org.apache.commons:commons-lang3:3.12.0") { isTransitive = false }
|
||||
compileOnly("net.kyori:adventure-api:4.16.0")
|
||||
compileOnly("cc.carm.lib:easysql-api:0.4.7")
|
||||
}
|
||||
|
||||
apply(from = "eclipse.gradle.kts") // Import eclipse classpath support script.
|
||||
|
||||
tasks.matching { it.name.startsWith("eclipse") }.configureEach { dependsOn(copyReadme) }
|
||||
|
||||
/* ---------------------- Reproducible jars ---------------------------- */
|
||||
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
|
||||
isPreserveFileTimestamps = false
|
||||
isReproducibleFileOrder = true
|
||||
}
|
||||
|
||||
/* ----------------------------- Shadow -------------------------------- */
|
||||
tasks.shadowJar {
|
||||
exclude("io.github.miniplaceholders.*") // Exclude the MiniPlaceholders package from being shadowed.
|
||||
archiveClassifier.set("") // Use empty string instead of null.
|
||||
minimize()
|
||||
}
|
||||
|
||||
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
|
||||
|
||||
tasks.build { dependsOn(tasks.shadowJar, copyReadme) } // Build depends on spotless and shadow.
|
||||
|
||||
/* --------------------------- Javac opts ------------------------------- */
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-parameters") // Enable reflection for java code.
|
||||
options.isFork = true // Run javac in its own process.
|
||||
options.compilerArgs.add("-Xlint:deprecation") // Trigger deprecation warning messages.
|
||||
options.encoding = "UTF-8" // Use UTF-8 file encoding.
|
||||
}
|
||||
|
||||
/* ----------------------------- Auto Formatting ------------------------ */
|
||||
spotless {
|
||||
java {
|
||||
eclipse().configFile("config/formatter/eclipse-java-formatter.xml") // Eclipse java formatting.
|
||||
leadingTabsToSpaces() // Convert leftover leading tabs to spaces.
|
||||
removeUnusedImports() // Remove imports that aren't being called.
|
||||
}
|
||||
kotlinGradle {
|
||||
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
|
||||
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.18.1" // Declare checkstyle version to use.
|
||||
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
|
||||
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
|
||||
isShowViolations = true // Show the violations in any IDE with the checkstyle plugin.
|
||||
}
|
||||
|
||||
tasks.named("compileJava") {
|
||||
dependsOn("spotlessApply") // Run spotless before compiling with the JDK.
|
||||
}
|
||||
|
||||
tasks.named("spotlessCheck") {
|
||||
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
|
||||
}
|
||||
|
||||
/* ------------------------------ Eclipse SHIM ------------------------- */
|
||||
|
||||
// This can't be put in eclipse.gradle.kts because Gradle is weird.
|
||||
subprojects {
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "eclipse")
|
||||
eclipse.project.name = "${project.name}-${rootProject.name}"
|
||||
tasks.withType<Jar>().configureEach { archiveBaseName.set("${project.name}-${rootProject.name}") }
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
<module name="Checker">
|
||||
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="FinalLocalVariable"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="Indentation">
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\borg\.junit\.jupiter\.api\.Assertions\.fail\s*\(\s*"Not yet implemented"\s*\)\s*;"/>
|
||||
<property name="message" value="Remove placeholder fail() and implement the test."/>
|
||||
<property name="ignoreCase" value="true"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="(?<!\w)fail\s*\(\s*"Not yet implemented"\s*\)\s*;"/>
|
||||
<property name="message" value="Remove placeholder fail() and implement the test."/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
|
||||
@@ -1,404 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<profiles version="23">
|
||||
<profile kind="CodeFormatterProfile" name="TrueOG Network Formatting" version="23">
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_not_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case_after_arrow" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_arrows_in_switch_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow" value="20"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
</profile>
|
||||
</profiles>
|
||||
@@ -1,151 +0,0 @@
|
||||
/* This is free and unencumbered software released into the public domain */
|
||||
|
||||
import org.gradle.plugins.ide.eclipse.model.EclipseModel
|
||||
import java.nio.file.Files
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.transform.OutputKeys
|
||||
import javax.xml.transform.TransformerFactory
|
||||
import javax.xml.transform.dom.DOMSource
|
||||
import javax.xml.transform.stream.StreamResult
|
||||
|
||||
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
|
||||
|
||||
val kotlinPluginProjects = configurations
|
||||
.getByName("compileClasspath")
|
||||
.allDependencies
|
||||
.filterIsInstance<ProjectDependency>()
|
||||
.filter { it -> it.attributes.getAttribute(kotlinAttribute) != null }
|
||||
.map { it.path }
|
||||
kotlinPluginProjects.forEach { evaluationDependsOn(it) }
|
||||
|
||||
val ideLibs: Configuration by
|
||||
configurations.creating {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
}
|
||||
|
||||
configure<EclipseModel> {
|
||||
project {
|
||||
name = "QSFindItemAddOn-OG-Plugin"
|
||||
}
|
||||
classpath {
|
||||
plusConfigurations.add(ideLibs)
|
||||
}
|
||||
}
|
||||
|
||||
val ideLibDir = layout.buildDirectory.dir("ide-libs")
|
||||
val hashRegex = Regex("-[0-9a-fA-F]{10}(?=\\.jar$)") // Black magic.
|
||||
|
||||
val copyTasks = mutableListOf<TaskProvider<Copy>>()
|
||||
|
||||
kotlinPluginProjects.forEach { path ->
|
||||
val sub = project(path)
|
||||
val shadowJarProv = sub.tasks.named("shadowJar")
|
||||
val copyTask =
|
||||
tasks.register<Copy>("ideCopy${sub.name.replaceFirstChar(Char::titlecase)}") {
|
||||
dependsOn(shadowJarProv)
|
||||
from(shadowJarProv)
|
||||
into(ideLibDir)
|
||||
rename { it.replace(hashRegex, "") } // Remove git commit hash from jarfile.
|
||||
}
|
||||
copyTasks += copyTask
|
||||
}
|
||||
|
||||
/* Ensure the jars exist before .classpath is generated */
|
||||
tasks.named("eclipseClasspath").configure { dependsOn(copyTasks) }
|
||||
|
||||
/* Supply those jars to the ideLibs configuration (after evaluation) */
|
||||
afterEvaluate { dependencies { add("ideLibs", fileTree(ideLibDir) { include("*.jar") }) } }
|
||||
|
||||
val injectIdeLibs =
|
||||
tasks.register("injectIdeLibs") {
|
||||
dependsOn("eclipse") // run after all eclipse files are generated
|
||||
doLast {
|
||||
val cpFile = file(".classpath")
|
||||
if (!cpFile.exists()) return@doLast
|
||||
|
||||
val jars = fileTree(ideLibDir.get()) { include("*.jar") }.files.sortedBy { it.name }
|
||||
if (jars.isEmpty()) return@doLast
|
||||
|
||||
// Parse DOM
|
||||
val dbf = DocumentBuilderFactory.newInstance()
|
||||
val doc = dbf.newDocumentBuilder().parse(cpFile)
|
||||
val root = doc.documentElement
|
||||
|
||||
// Helper to see if an entry already exists
|
||||
fun exists(path: String): Boolean =
|
||||
root.getElementsByTagName("classpathentry").let { list ->
|
||||
(0 until list.length).any { i ->
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue
|
||||
kind == "lib" && p == path
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any entry that points to ide-libs dir (folder or jars) to avoid dupes
|
||||
val toRemove = mutableListOf<org.w3c.dom.Node>()
|
||||
val list = root.getElementsByTagName("classpathentry")
|
||||
val dirPath = ideLibDir.get().asFile.absolutePath
|
||||
for (i in 0 until list.length) {
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue ?: ""
|
||||
if (kind == "lib" && (p == dirPath || p.startsWith("$dirPath/"))) {
|
||||
toRemove += n
|
||||
}
|
||||
}
|
||||
toRemove.forEach { root.removeChild(it) }
|
||||
|
||||
// Append our jar entries LAST
|
||||
jars.forEach { f ->
|
||||
val abs = f.absolutePath
|
||||
if (!exists(abs)) {
|
||||
val entry = doc.createElement("classpathentry")
|
||||
entry.setAttribute("kind", "lib")
|
||||
entry.setAttribute("path", abs)
|
||||
root.appendChild(entry)
|
||||
}
|
||||
}
|
||||
|
||||
// Write back pretty
|
||||
val tf =
|
||||
TransformerFactory.newInstance().newTransformer().apply {
|
||||
setOutputProperty(OutputKeys.INDENT, "yes")
|
||||
setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1")
|
||||
setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no")
|
||||
setOutputProperty(OutputKeys.ENCODING, "UTF-8")
|
||||
}
|
||||
Files.newBufferedWriter(cpFile.toPath()).use { w -> tf.transform(DOMSource(doc), StreamResult(w)) }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("eclipse").configure { finalizedBy(injectIdeLibs) }
|
||||
|
||||
val eclipseModel = extensions.getByType<EclipseModel>()
|
||||
|
||||
fun Project.addResolvableEclipseConfigs() {
|
||||
val jarAttr =
|
||||
objects.named(org.gradle.api.attributes.LibraryElements::class, org.gradle.api.attributes.LibraryElements.JAR)
|
||||
val apiAttr = objects.named(org.gradle.api.attributes.Usage::class, org.gradle.api.attributes.Usage.JAVA_API)
|
||||
|
||||
val compileOnlyRes =
|
||||
configurations.create("eclipseCompileOnly") {
|
||||
extendsFrom(configurations.getByName("compileOnly"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
val compileOnlyApiRes =
|
||||
configurations.create("eclipseCompileOnlyApi") {
|
||||
extendsFrom(configurations.getByName("compileOnlyApi"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
eclipseModel.classpath.plusConfigurations.addAll(listOf(compileOnlyRes, compileOnlyApiRes))
|
||||
}
|
||||
|
||||
addResolvableEclipseConfigs()
|
||||
Vendored
BIN
Binary file not shown.
-7
@@ -1,7 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,251 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
-94
@@ -1,94 +0,0 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
Binary file not shown.
Binary file not shown.
Submodule libs/Utilities-OG deleted from 8b5c86cc9c.
@@ -0,0 +1,464 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>io.myzticbean.finditemaddon</groupId>
|
||||
<artifactId>QSFindItemAddOn</artifactId>
|
||||
<version>2.0.8.0-SNAPSHOT-1221</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>QSFindItemAddOn</name>
|
||||
<inceptionYear>2021</inceptionYear>
|
||||
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spigot.version>1.21.8-R0.1-SNAPSHOT</spigot.version>
|
||||
<paper-api.version>1.21.10-R0.1-SNAPSHOT</paper-api.version>
|
||||
<!-- <qs-hikari.version>6.2.0.10</qs-hikari.version>-->
|
||||
<qs-hikari.version>6.2.0.11-SNAPSHOT-11</qs-hikari.version>
|
||||
<playerwarps-api-old>6.30.0</playerwarps-api-old>
|
||||
<playerwarps-api-new>7.7.1</playerwarps-api-new>
|
||||
<essentialsx.version>2.21.1</essentialsx.version>
|
||||
<jackson.version>2.13.5</jackson.version>
|
||||
</properties>
|
||||
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>https://ci.codemc.io/job/myzticbean/job/QSFindItemAddOn</url>
|
||||
</ciManagement>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/myzticbean/QSFindItemAddOn/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>QSFindItemAddOn</id>
|
||||
<url>https://repo.codemc.io/repository/QSFindItemAddOn/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson</groupId>
|
||||
<artifactId>jackson-bom</artifactId>
|
||||
<version>${jackson.version}</version> <!-- Use a stable latest version -->
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<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>D:\Github_myzticbean\MCServer_1.21\plugins</outputDirectory> -->
|
||||
<!-- Comment out if on a PC -->
|
||||
<!-- <outputDirectory>/Users/${user.name}/IdeaProjects/MCServer_1.21/plugins</outputDirectory> -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>readme</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.basedir}</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/doc</directory>
|
||||
<includes>
|
||||
<include>README.md</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-public</id>
|
||||
<url>https://repo.codemc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>essentials-releases</id>
|
||||
<url>https://repo.essentialsx.net/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>essentials-snapshots</id>
|
||||
<url>https://repo.essentialsx.net/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>olzie-repo</id>
|
||||
<url>https://repo.olziedev.com/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<url>https://repo.maven.apache.org/maven2/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bentoboxworld</id>
|
||||
<url>https://repo.codemc.io/repository/bentoboxworld/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>${paper-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.maxgamer</groupId>
|
||||
<artifactId>QuickShop</artifactId>
|
||||
<version>5.1.2.5</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ghostchu</groupId>
|
||||
<artifactId>quickshop-api</artifactId>
|
||||
<version>${qs-hikari.version}</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>${qs-hikari.version}</version>
|
||||
<scope>provided</scope>
|
||||
<classifier>shaded</classifier>
|
||||
<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>net.essentialsx</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>${essentialsx.version}</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olziedev</groupId>
|
||||
<artifactId>playerwarps-api</artifactId>
|
||||
<version>${playerwarps-api-old}</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olziedev</groupId>
|
||||
<artifactId>playerwarps-api</artifactId>
|
||||
<version>${playerwarps-api-new}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.7</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>annotations</artifactId>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>truecommons-logging</artifactId>
|
||||
<groupId>net.java.truecommons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<groupId>org.bstats</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<groupId>org.bukkit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>truevfs-comp-zip</artifactId>
|
||||
<groupId>net.java.truevfs</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>truevfs-comp-tardriver</artifactId>
|
||||
<groupId>net.java.truevfs</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>24.1.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.KodySimpson</groupId>
|
||||
<artifactId>SimpAPI</artifactId>
|
||||
<version>4.6.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.18.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>zrips.residence</groupId>
|
||||
<artifactId>Residence</artifactId>
|
||||
<version>5.1.5.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Residence5.1.5.1.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.GriefPrevention</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.18.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ryanhamshire</groupId>
|
||||
<artifactId>GPFlags</artifactId>
|
||||
<version>5.13.4</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/GPFlags-5.13.4.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>world.bentobox</groupId>
|
||||
<artifactId>bentobox</artifactId>
|
||||
<version>3.7.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,35 +0,0 @@
|
||||
rootProject.name = "QSFindItemAddOn-OG"
|
||||
|
||||
ProcessBuilder("sh", "bootstrap.sh").directory(rootDir).inheritIO().start().let {
|
||||
if (it.waitFor() != 0) throw GradleException("bootstrap.sh failed")
|
||||
}
|
||||
|
||||
file("libs")
|
||||
.listFiles()
|
||||
?.filter { it.isDirectory && !it.name.startsWith(".") }
|
||||
?.forEach { dir ->
|
||||
include(":libs:${dir.name}")
|
||||
project(":libs:${dir.name}").projectDir = dir
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
|
||||
/* ---------------------------- Repos ---------------------------------- */
|
||||
repositories {
|
||||
mavenCentral() // Import the Maven Central Maven Repository.
|
||||
gradlePluginPortal() // Import the Gradle Plugin Portal Maven Repository.
|
||||
maven { url = uri("https://repo.purpurmc.org/snapshots") } // Import the PurpurMC Maven Repository.
|
||||
maven { url = uri("https://oss.sonatype.org/content/groups/public/") }
|
||||
maven { url = uri("https://repo.codemc.io/repository/maven-public/") }
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.essentialsx.net/releases/") }
|
||||
maven { url = uri("https://repo.essentialsx.net/snapshots/") }
|
||||
maven { url = uri("https://maven.enginehub.org/repo/") }
|
||||
maven { url = uri("https://repo.glaremasters.me/repository/public/") }
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://jitpack.io") }
|
||||
maven { url = uri("https://repo.olziedev.com/") }
|
||||
}
|
||||
}
|
||||
+27
-10
@@ -2,10 +2,12 @@
|
||||
### Version: ${project.version}
|
||||
|
||||
An unofficial add-on for the QuickShop Hikari and Reremake spigot plugin.
|
||||
Adds a `/find` command in game for searching through all the shops on the server.
|
||||
Adds a `/finditem` command in game for searching through all the shops on the server.
|
||||
|
||||

|
||||

|
||||
[//]: # ()
|
||||

|
||||

|
||||

|
||||
|
||||
## Features
|
||||
- Search items based on buying/selling shops
|
||||
@@ -20,22 +22,23 @@ Adds a `/find` command in game for searching through all the shops on the server
|
||||
- Supports completely safe direct shop teleportation (configurable in config.yml)
|
||||
- Ignores shops that are out of stock by default
|
||||
- Support for world blacklisting (Shops in blacklisted worlds are ignored in the search result)
|
||||
- Support for material blacklisting that prevents players for searching for specific items
|
||||
|
||||
|
||||
**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.
|
||||
|
||||
**View all shops on server**
|
||||
- You can do `/find TO_BUY *` or `/find TO_SELL *` to view all shops on the server. As of this version, the sequence is always randomized. Sorting options are a work in progress.
|
||||
- You can do `/finditem TO_BUY *` or `/finditem TO_SELL *` to view all shops on the server. As of this version, the sequence is always randomized. Sorting options are a work in progress.
|
||||
|
||||
**Shop visit count**
|
||||
- You can choose to display shop visits count in the shop lore in Search GUI. Just add the placeholder `{SHOP_VISITS}` in the `shop-gui-item-lore` in config.yml. To prevent visit spamming, a new config property `shop-player-visit-cooldown-in-minutes` has been added. Please don't use decimals here. 😁
|
||||
|
||||
**Customizable command aliases**
|
||||
- You can find a property in config.yml called `command-alias` where you can specify your own list of command aliases for /find command. If you don't wish to add any, just make it as:
|
||||
- You can find a property in config.yml called `command-alias` where you can specify your own list of command aliases for /finditem command. If you don't wish to add any, just make it as:
|
||||
```yaml
|
||||
command-alias: []
|
||||
```
|
||||
@@ -43,15 +46,16 @@ 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)
|
||||
- Residence support for fetching the residence the shop is in (including subzones)
|
||||
|
||||
>Check out the sample config.yml [here](https://github.com/myzticbean/QSFindItemAddOn/wiki/Sample-config.yml).
|
||||
|
||||
## Requires
|
||||
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v5.2 or higher
|
||||
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v6.0 or higher
|
||||
|
||||
**OR**
|
||||
|
||||
@@ -70,3 +74,16 @@ See more details [here](https://github.com/myzticbean/QSFindItemAddOn/blob/maste
|
||||
|
||||
## BStats Metrics
|
||||
[](https://bstats.org/plugin/bukkit/QSFindItemAddOn/12382)
|
||||
|
||||
## Demo
|
||||
### How to use `/finditem`?
|
||||

|
||||

|
||||
### Multiple search result pages:
|
||||

|
||||
### Shows item enchantments:
|
||||

|
||||
### Shows Potion colors and effects:
|
||||

|
||||
### Shows custom item names and lore:
|
||||

|
||||
-190
@@ -1,190 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Commands.QSSubCommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.ghostchu.quickshop.api.command.CommandHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class FindItemCmdHikariImpl implements CommandHandler<Player> {
|
||||
|
||||
private final String hideSubCommand;
|
||||
private final String revealShopSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final List<String> buyOrSellList = new ArrayList<>();
|
||||
|
||||
public FindItemCmdHikariImpl() {
|
||||
|
||||
if (StringUtils.isBlank(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
|
||||
this.hideSubCommand = "hideshop";
|
||||
|
||||
} else {
|
||||
|
||||
this.hideSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
this.revealShopSubCommand = "revealshop";
|
||||
|
||||
} else {
|
||||
|
||||
this.revealShopSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Player commandSender, @NotNull String label, @NotNull String[] args) {
|
||||
|
||||
if (args.length == 0) {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
} else if (args.length == 1) {
|
||||
|
||||
if (commandSender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
if (args[0].equalsIgnoreCase(hideSubCommand)) {
|
||||
|
||||
cmdExecutor.handleHideShop(commandSender);
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(revealShopSubCommand)) {
|
||||
|
||||
cmdExecutor.handleRevealShop(commandSender);
|
||||
|
||||
} else {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&cYou don't have permission to use that!"));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
cmdExecutor.handleShopSearch(args[0], commandSender, args[1]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel,
|
||||
@NotNull String[] args)
|
||||
{
|
||||
|
||||
if (itemsList.isEmpty()) {
|
||||
|
||||
for (Material mat : Material.values()) {
|
||||
|
||||
itemsList.add(mat.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (buyOrSellList.isEmpty()) {
|
||||
|
||||
// to-buy
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buyOrSellList.add("TO_BUY");
|
||||
|
||||
} else {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
// to-sell
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buyOrSellList.add("TO_SELL");
|
||||
|
||||
} else {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
// hide
|
||||
if (sender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE);
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
|
||||
for (String a : buyOrSellList) {
|
||||
|
||||
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
|
||||
result.add(a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} else if (args.length == 2) {
|
||||
|
||||
for (String a : itemsList) {
|
||||
|
||||
if (a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
|
||||
result.add(a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-186
@@ -1,186 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Commands.QSSubCommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.api.command.CommandHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class FindItemCmdReremakeImpl implements CommandHandler<Player> {
|
||||
|
||||
private final String hideSubCommand;
|
||||
private final String revealShopSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final List<String> buyOrSellList = new ArrayList<>();
|
||||
|
||||
public FindItemCmdReremakeImpl() {
|
||||
|
||||
if (StringUtils.isBlank(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
|
||||
this.hideSubCommand = "hideshop";
|
||||
|
||||
} else {
|
||||
|
||||
this.hideSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
this.revealShopSubCommand = "revealshop";
|
||||
|
||||
} else {
|
||||
|
||||
this.revealShopSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Player commandSender, @NotNull String label, @NotNull String[] args) {
|
||||
|
||||
if (args.length == 0) {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
} else if (args.length == 1) {
|
||||
|
||||
if (commandSender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
if (args[0].equalsIgnoreCase(hideSubCommand)) {
|
||||
|
||||
cmdExecutor.handleHideShop(commandSender);
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(revealShopSubCommand)) {
|
||||
|
||||
cmdExecutor.handleRevealShop(commandSender);
|
||||
|
||||
} else {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&cYou don't have permission to use that!"));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
cmdExecutor.handleShopSearch(args[0], commandSender, args[1]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel,
|
||||
@NotNull String[] args)
|
||||
{
|
||||
|
||||
if (itemsList.isEmpty()) {
|
||||
|
||||
for (Material mat : Material.values()) {
|
||||
|
||||
itemsList.add(mat.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (buyOrSellList.isEmpty()) {
|
||||
|
||||
// to-buy
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buyOrSellList.add("TO_BUY");
|
||||
|
||||
} else {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
// to-sell
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buyOrSellList.add("TO_SELL");
|
||||
|
||||
} else {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
// hide
|
||||
if (sender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE);
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
|
||||
for (String a : buyOrSellList) {
|
||||
|
||||
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
|
||||
result.add(a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} else if (args.length == 2) {
|
||||
|
||||
for (String a : itemsList) {
|
||||
|
||||
if (a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
|
||||
result.add(a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /find TO_BUY
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class BuySubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final String buySubCommand;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public BuySubCmd() {
|
||||
|
||||
// to-buy
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buySubCommand = "TO_BUY";
|
||||
|
||||
} else {
|
||||
|
||||
buySubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
if (itemsList.isEmpty()) {
|
||||
|
||||
for (Material mat : Material.values()) {
|
||||
|
||||
itemsList.add(mat.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return buySubCommand;
|
||||
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
||||
return "Find shops that buy a specific item";
|
||||
|
||||
}
|
||||
|
||||
public String getSyntax() {
|
||||
|
||||
return "/find " + buySubCommand + " {item type | item name}";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
final String itemArg;
|
||||
if (args.length == 1) {
|
||||
|
||||
itemArg = args[0];
|
||||
|
||||
} else if (args.length == 2 && buySubCommand.equalsIgnoreCase(args[0])) {
|
||||
|
||||
itemArg = args[1];
|
||||
|
||||
} else {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INCORRECT_USAGE_MSG));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor.handleShopSearch(buySubCommand, commandSender, itemArg);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
final String token;
|
||||
if (args.length == 1) {
|
||||
|
||||
token = args[0];
|
||||
|
||||
} else if (args.length == 2 && buySubCommand.equalsIgnoreCase(args[0])) {
|
||||
|
||||
token = args[1];
|
||||
|
||||
} else {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
final String lower = token == null ? "" : token.toLowerCase();
|
||||
return new ArrayList<>(
|
||||
itemsList.stream().filter(a -> a.toLowerCase().startsWith(lower)).collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /find hideshop
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class HideShopSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final String hideSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public HideShopSubCmd() {
|
||||
|
||||
if (StringUtils.isBlank(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
|
||||
hideSubCommand = "hideshop";
|
||||
|
||||
} else {
|
||||
|
||||
hideSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return hideSubCommand;
|
||||
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
||||
return "Run this command while looking at the shop (NOT the shop sign) you wish to hide and it will no"
|
||||
+ " longer appear in searches";
|
||||
|
||||
}
|
||||
|
||||
public String getSyntax() {
|
||||
|
||||
return "/find " + hideSubCommand;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
cmdExecutor.handleHideShop(commandSender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditemadmin reload
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class ReloadSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public ReloadSubCmd() {
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return "reload";
|
||||
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
||||
return "Reloads config.yml";
|
||||
|
||||
}
|
||||
|
||||
public String getSyntax() {
|
||||
|
||||
return "/finditemadmin reload";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
cmdExecutor.handlePluginReload(commandSender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /find restart
|
||||
*
|
||||
* @deprecated No longer used, will be removed in future versions
|
||||
* @author myzticbean
|
||||
*/
|
||||
@Deprecated
|
||||
public class RestartSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public RestartSubCmd() {
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return "restart";
|
||||
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
||||
return "Restarts the plugin (NOT recommended in most cases, restart server if necessary)";
|
||||
|
||||
}
|
||||
|
||||
public String getSyntax() {
|
||||
|
||||
return "/finditemadmin restart";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
cmdExecutor.handlePluginRestart(commandSender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditemadmin revealshop
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class RevealShopSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final String revealShopSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public RevealShopSubCmd() {
|
||||
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
revealShopSubCommand = "revealshop";
|
||||
|
||||
} else {
|
||||
|
||||
revealShopSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return revealShopSubCommand;
|
||||
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
||||
return "Run this command while looking at a hidden shop to make it public again";
|
||||
|
||||
}
|
||||
|
||||
public String getSyntax() {
|
||||
|
||||
return "/find " + revealShopSubCommand;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
cmdExecutor.handleRevealShop(commandSender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /find TO_SELL
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class SellSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final String sellSubCommand;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public SellSubCmd() {
|
||||
|
||||
// to-sell
|
||||
if (StringUtils.isBlank(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)) {
|
||||
|
||||
sellSubCommand = "TO_SELL";
|
||||
|
||||
} else {
|
||||
|
||||
sellSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
if (itemsList.isEmpty()) {
|
||||
|
||||
for (Material mat : Material.values()) {
|
||||
|
||||
itemsList.add(mat.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return sellSubCommand;
|
||||
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
||||
return "Find shops that sell a specific item";
|
||||
|
||||
}
|
||||
|
||||
public String getSyntax() {
|
||||
|
||||
return "/find " + sellSubCommand + " {item type | item name}";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
final String itemArg;
|
||||
if (args.length == 1) {
|
||||
|
||||
itemArg = args[0];
|
||||
|
||||
} else if (args.length == 2 && sellSubCommand.equalsIgnoreCase(args[0])) {
|
||||
|
||||
itemArg = args[1];
|
||||
|
||||
} else {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INCORRECT_USAGE_MSG));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor.handleShopSearch(sellSubCommand, commandSender, itemArg);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
final String token;
|
||||
if (args.length == 1) {
|
||||
|
||||
token = args[0];
|
||||
|
||||
} else if (args.length == 2 && sellSubCommand.equalsIgnoreCase(args[0])) {
|
||||
|
||||
token = args[1];
|
||||
|
||||
} else {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
final String lower = token == null ? "" : token.toLowerCase();
|
||||
return new ArrayList<>(
|
||||
itemsList.stream().filter(a -> a.toLowerCase().startsWith(lower)).collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.ConfigUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
|
||||
public class ConfigProvider {
|
||||
|
||||
public final String PLUGIN_PREFIX = 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 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 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 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_BACK_BUTTON_CMD = ConfigSetup.get()
|
||||
.getString("shop-gui-back-button-custom-model-data");
|
||||
public final String SHOP_GUI_NEXT_BUTTON_CMD = ConfigSetup.get()
|
||||
.getString("shop-gui-next-button-custom-model-data");
|
||||
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 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 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 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");
|
||||
|
||||
private final List<World> blacklistedWorldsList = new ArrayList<>();
|
||||
|
||||
public ConfigProvider() {
|
||||
|
||||
if (BLACKLISTED_WORLDS != null) {
|
||||
|
||||
BLACKLISTED_WORLDS.forEach(world -> {
|
||||
|
||||
World worldObj = Bukkit.getWorld(world);
|
||||
if (worldObj != null) {
|
||||
|
||||
blacklistedWorldsList.add(worldObj);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Config loaded!");
|
||||
|
||||
}
|
||||
|
||||
public List<World> getBlacklistedWorlds() {
|
||||
|
||||
return blacklistedWorldsList;
|
||||
|
||||
}
|
||||
|
||||
public boolean shopGUIItemLoreHasKey(String key) {
|
||||
|
||||
if (SHOP_GUI_ITEM_LORE != null) {
|
||||
|
||||
return SHOP_GUI_ITEM_LORE.stream().anyMatch(key::contains);
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,330 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.ConfigUtil;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigSetup {
|
||||
|
||||
private static File configFile;
|
||||
private static File sampleConfigFile;
|
||||
private static FileConfiguration configFileConfiguration;
|
||||
private static final int CURRENT_CONFIG_VERSION = 13;
|
||||
|
||||
public static void setupConfig() {
|
||||
|
||||
configFile = new File(FindItemAddOnOG.getInstance().getDataFolder(), "config.yml");
|
||||
|
||||
if (!configFile.exists()) {
|
||||
|
||||
try {
|
||||
|
||||
boolean isConfigGenerated = configFile.createNewFile();
|
||||
if (isConfigGenerated) {
|
||||
|
||||
LoggerUtils.logInfo("Generated a new config.yml");
|
||||
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
LoggerUtils.logError("Error generating config.yml");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
configFileConfiguration = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
}
|
||||
|
||||
public static void saveConfig() {
|
||||
|
||||
try {
|
||||
|
||||
configFileConfiguration.save(configFile);
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
LoggerUtils.logError("Error saving config.yml");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkForMissingProperties() {
|
||||
|
||||
if (!configFileConfiguration.contains("search-loaded-shops-only", true)) {
|
||||
|
||||
configFileConfiguration.set("search-loaded-shops-only", false);
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("nearest-warp-mode", true)) {
|
||||
|
||||
configFileConfiguration.set("nearest-warp-mode", 1);
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
|
||||
int nearestWarpMode = configFileConfiguration.getInt("nearest-warp-mode");
|
||||
if (nearestWarpMode != 1 && nearestWarpMode != 2 && nearestWarpMode != 3) {
|
||||
|
||||
LoggerUtils.logError("Invalid value for 'nearest-warp-mode' in config.yml!");
|
||||
LoggerUtils.logError("Resetting by default to &e1");
|
||||
configFileConfiguration.set("nearest-warp-mode", 1);
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
LoggerUtils.logError("Invalid value for 'nearest-warp-mode' in config.yml!");
|
||||
LoggerUtils.logError("Resetting by default to &e1");
|
||||
configFileConfiguration.set("nearest-warp-mode", 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("shop-gui-item-lore", true)) {
|
||||
|
||||
List<String> shopGUIItemLore = new ArrayList<>();
|
||||
shopGUIItemLore.add("");
|
||||
shopGUIItemLore.add("&fPrice: &a${ITEM_PRICE}");
|
||||
shopGUIItemLore.add("&fStock: &7{SHOP_STOCK}");
|
||||
shopGUIItemLore.add("&fOwner: &7{SHOP_OWNER}");
|
||||
shopGUIItemLore.add("&fLocation: &7{SHOP_LOC}");
|
||||
shopGUIItemLore.add("&fWorld: &7{SHOP_WORLD}");
|
||||
shopGUIItemLore.add("&fWarp: &7{NEAREST_WARP}");
|
||||
shopGUIItemLore.add("");
|
||||
configFileConfiguration.set("shop-gui-item-lore", shopGUIItemLore);
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("blacklisted-worlds", true)) {
|
||||
|
||||
List<String> blacklistedWorlds = new ArrayList<>();
|
||||
blacklistedWorlds.add("world_number_1");
|
||||
blacklistedWorlds.add("world_number_2");
|
||||
configFileConfiguration.set("blacklisted-worlds", blacklistedWorlds);
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.hideshop-autocomplete", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.hideshop-autocomplete", "hideshop");
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.revealshop-autocomplete", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.revealshop-autocomplete", "revealshop");
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.shop-hide-success-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.shop-hide-success-message",
|
||||
"&aShop is now hidden from search list!");
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.shop-reveal-success-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.shop-reveal-success-message",
|
||||
"&aShop is no longer hidden from search list!");
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.shop-already-hidden-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.shop-already-hidden-message",
|
||||
"&cThis shop is already hidden!");
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.shop-already-public-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.shop-already-public-message",
|
||||
"&cThis shop is already public!");
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.invalid-shop-block-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.invalid-shop-block-message",
|
||||
"&cThe block you are looking at is not a shop!");
|
||||
|
||||
}
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.hiding-shop-owner-invalid-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.hiding-shop-owner-invalid-message",
|
||||
"&cThat shop is not yours!");
|
||||
|
||||
}
|
||||
|
||||
// ALWAYS AT LAST
|
||||
if (!configFileConfiguration.contains("config-version", true)) {
|
||||
|
||||
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");
|
||||
String clickToTeleportMsg = configFileConfiguration.getString("click-to-teleport-message");
|
||||
String shopTPNoPermMsg = configFileConfiguration.getString("shop-tp-no-permission-message");
|
||||
String unsafeShopAreaMsg = configFileConfiguration.getString("unsafe-shop-area-message");
|
||||
// clear existing config properties
|
||||
configFileConfiguration.set("allow-direct-shop-tp", null);
|
||||
configFileConfiguration.set("click-to-teleport-message", null);
|
||||
configFileConfiguration.set("shop-tp-no-permission-message", null);
|
||||
configFileConfiguration.set("unsafe-shop-area-message", null);
|
||||
// set the new properties
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.tp-player-directly-to-shop",
|
||||
allowDirectShopTp);
|
||||
if (clickToTeleportMsg == null || clickToTeleportMsg.isEmpty())
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message",
|
||||
"&6&lClick to teleport to the shop!");
|
||||
else
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message",
|
||||
clickToTeleportMsg);
|
||||
|
||||
if (shopTPNoPermMsg == null || shopTPNoPermMsg.isEmpty())
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message",
|
||||
"&cYou don't have permission to teleport to shop!");
|
||||
else
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message",
|
||||
shopTPNoPermMsg);
|
||||
|
||||
if (unsafeShopAreaMsg == null || unsafeShopAreaMsg.isEmpty())
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message",
|
||||
"&cThe area around the shop is unsafe!");
|
||||
else
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message",
|
||||
unsafeShopAreaMsg);
|
||||
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp",
|
||||
false);
|
||||
|
||||
}
|
||||
|
||||
// Config v11
|
||||
if (configFileConfiguration.getInt("config-version") < 11) {
|
||||
|
||||
List<String> cmdAliases = new ArrayList<>();
|
||||
cmdAliases.add("searchshop");
|
||||
cmdAliases.add("shopsearch");
|
||||
cmdAliases.add("searchitem");
|
||||
configFileConfiguration.set("find-item-command.command-alias", cmdAliases);
|
||||
|
||||
boolean warpState = configFileConfiguration
|
||||
.getBoolean("player-shop-teleportation.nearest-warp-tp-mode.warp-player-to-nearest-warp");
|
||||
if (warpState)
|
||||
configFileConfiguration
|
||||
.set("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp", true);
|
||||
// if warpState is false, don't bother updating tPState
|
||||
|
||||
// remove an erroneous field added in previous version
|
||||
configFileConfiguration
|
||||
.set("player-shop-teleportation.nearest-warp-tp-mode.warp-player-to-nearest-warp", null);
|
||||
|
||||
// Update GUI next/previous button to blank if set to default value for the new
|
||||
// player-head icons
|
||||
if (configFileConfiguration.getString("shop-gui-back-button-material")
|
||||
.equalsIgnoreCase("RED_CONCRETE"))
|
||||
{
|
||||
|
||||
configFileConfiguration.set("shop-gui-back-button-material", "");
|
||||
|
||||
}
|
||||
|
||||
if (configFileConfiguration.getString("shop-gui-next-button-material")
|
||||
.equalsIgnoreCase("GREEN_CONCRETE"))
|
||||
{
|
||||
|
||||
configFileConfiguration.set("shop-gui-next-button-material", "");
|
||||
|
||||
}
|
||||
|
||||
// Add option to configure player visit cooldown
|
||||
configFileConfiguration.set("shop-player-visit-cooldown-in-minutes", 5);
|
||||
|
||||
}
|
||||
|
||||
// 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(
|
||||
"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", "");
|
||||
|
||||
}
|
||||
|
||||
// AT LAST
|
||||
// Moving debug-mode and config-version to the last
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static FileConfiguration get() {
|
||||
|
||||
return configFileConfiguration;
|
||||
|
||||
}
|
||||
|
||||
public static void reloadConfig() {
|
||||
|
||||
configFileConfiguration = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Added in 2.0
|
||||
*/
|
||||
public static void copySampleConfig() {
|
||||
|
||||
FindItemAddOnOG.getInstance().saveResource("sample-config.yml", true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Dependencies;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import io.myzticbean.finditemaddon.Models.EssentialWarpModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Hook for EssentialsX Plugin
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class EssentialsXPlugin {
|
||||
|
||||
private static Essentials essAPI = null;
|
||||
private static List<EssentialWarpModel> allWarpsList = null;
|
||||
|
||||
public static void setup() {
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("Essentials-OG")) {
|
||||
|
||||
essAPI = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials-OG");
|
||||
if (essAPI != null) {
|
||||
|
||||
LoggerUtils.logInfo("Found Essentials-OG...");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
|
||||
return essAPI != null;
|
||||
|
||||
}
|
||||
|
||||
public static Essentials getAPI() {
|
||||
|
||||
return essAPI;
|
||||
|
||||
}
|
||||
|
||||
public static List<EssentialWarpModel> getAllWarps() {
|
||||
|
||||
return allWarpsList;
|
||||
|
||||
}
|
||||
|
||||
public static void updateAllWarps() {
|
||||
|
||||
if (essAPI.isEnabled()) {
|
||||
|
||||
Collection<String> allWarps = EssentialsXPlugin.getAPI().getWarps().getList();
|
||||
allWarpsList = new ArrayList<>();
|
||||
allWarps.forEach(warp -> {
|
||||
|
||||
try {
|
||||
|
||||
EssentialWarpModel essWarp = new EssentialWarpModel();
|
||||
essWarp.warpName = warp;
|
||||
essWarp.warpLoc = essAPI.getWarps().getWarp(warp);
|
||||
allWarpsList.add(essWarp);
|
||||
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Dependencies;
|
||||
|
||||
//import me.ronsane.finditemaddon.finditemaddon.Utils.LoggerUtils;
|
||||
//import me.tks.playerwarp.PWarp;
|
||||
//import me.tks.playerwarp.Warp;
|
||||
//import me.tks.playerwarp.WarpList;
|
||||
//import org.bukkit.Bukkit;
|
||||
|
||||
public class PWarpPlugin {
|
||||
|
||||
// private static PWarp pWarp = null;
|
||||
//
|
||||
// public static void setup() {
|
||||
// if(Bukkit.getPluginManager().isPluginEnabled("PWarp")) {
|
||||
// LoggerUtils.logInfo("Found PWarp");
|
||||
// pWarp = PWarp.getPlugin(PWarp.class);
|
||||
// }
|
||||
// }
|
||||
// public static PWarp getAPI() {
|
||||
// return pWarp;
|
||||
// }
|
||||
//
|
||||
// public static boolean isEnabled() {
|
||||
// return pWarp != null;
|
||||
// }
|
||||
//
|
||||
// public static List<Warp> getAllWarps() {
|
||||
//
|
||||
// return PWarp.wL.getWarps();
|
||||
// }
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Dependencies;
|
||||
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class WGPlugin {
|
||||
|
||||
private static boolean isPluginEnabled;
|
||||
|
||||
public static void setup() {
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) {
|
||||
|
||||
LoggerUtils.logInfo("Found WorldGuard");
|
||||
isPluginEnabled = true;
|
||||
|
||||
} else {
|
||||
|
||||
isPluginEnabled = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static WorldGuardPlugin getWgPluginInstance() {
|
||||
|
||||
return WorldGuardPlugin.inst();
|
||||
|
||||
}
|
||||
|
||||
public static WorldGuard getWgInstance() {
|
||||
|
||||
return WorldGuard.getInstance();
|
||||
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
|
||||
return isPluginEnabled;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,385 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon;
|
||||
|
||||
import io.myzticbean.finditemaddon.commands.simpapi.BuySubCmd;
|
||||
import io.myzticbean.finditemaddon.commands.simpapi.DebugSubCmd;
|
||||
import io.myzticbean.finditemaddon.commands.simpapi.HideShopSubCmd;
|
||||
import io.myzticbean.finditemaddon.commands.simpapi.ReloadSubCmd;
|
||||
import io.myzticbean.finditemaddon.commands.simpapi.RevealShopSubCmd;
|
||||
import io.myzticbean.finditemaddon.commands.simpapi.SellSubCmd;
|
||||
import io.myzticbean.finditemaddon.config.ConfigProvider;
|
||||
import io.myzticbean.finditemaddon.config.ConfigSetup;
|
||||
import io.myzticbean.finditemaddon.dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.dependencies.ResidencePlugin;
|
||||
import io.myzticbean.finditemaddon.dependencies.WGPlugin;
|
||||
import io.myzticbean.finditemaddon.dependencies.BentoBoxPlugin;
|
||||
import io.myzticbean.finditemaddon.handlers.gui.PlayerMenuUtility;
|
||||
import io.myzticbean.finditemaddon.listeners.*;
|
||||
import io.myzticbean.finditemaddon.metrics.Metrics;
|
||||
import io.myzticbean.finditemaddon.quickshop.QSApi;
|
||||
import io.myzticbean.finditemaddon.quickshop.impl.QSHikariAPIHandler;
|
||||
import io.myzticbean.finditemaddon.quickshop.impl.QSReremakeAPIHandler;
|
||||
import io.myzticbean.finditemaddon.scheduledtasks.Task15MinInterval;
|
||||
import io.myzticbean.finditemaddon.models.enums.PlayerPermsEnum;
|
||||
import io.myzticbean.finditemaddon.utils.async.VirtualThreadScheduler;
|
||||
import io.myzticbean.finditemaddon.utils.json.ShopSearchActivityStorageUtil;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import io.myzticbean.finditemaddon.utils.UpdateChecker;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import me.kodysimpson.simpapi.command.CommandManager;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
@Slf4j
|
||||
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 pluginInstance;
|
||||
|
||||
public FindItemAddOn() {
|
||||
pluginInstance = this;
|
||||
}
|
||||
|
||||
public static Plugin getInstance() {
|
||||
return pluginInstance;
|
||||
}
|
||||
|
||||
public static String serverVersion;
|
||||
|
||||
private static final int BS_PLUGIN_METRIC_ID = 12382;
|
||||
private static final int SPIGOT_PLUGIN_ID = 95104;
|
||||
private static final String MODRINTH_PROJECT_SLUG = "asp13ugE";
|
||||
private static final int REPEATING_TASK_SCHEDULE_MINS = 15*60*20;
|
||||
@Getter
|
||||
private static ConfigProvider configProvider;
|
||||
@Getter
|
||||
private static UpdateChecker updateChecker;
|
||||
@Getter
|
||||
private static boolean isPluginOutdated = false;
|
||||
@Getter
|
||||
private static boolean qSReremakeInstalled = false;
|
||||
@Getter
|
||||
private static boolean qSHikariInstalled = false;
|
||||
private static QSApi<?, ?> qsApi;
|
||||
@Getter
|
||||
private static BentoBoxPlugin bentoboxPlugin;
|
||||
|
||||
private static final HashMap<Player, PlayerMenuUtility> playerMenuUtilityMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Logger.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")) {
|
||||
Logger.logWarning("This is a SNAPSHOT build! NOT recommended for production servers.");
|
||||
Logger.logWarning("If you find any bugs, please report them here: https://github.com/myzticbean/QSFindItemAddOn/issues");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
if(ENABLE_TRIAL_PERIOD) {
|
||||
Logger.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) {
|
||||
Logger.logError("Your trial has expired! Please contact the developer.");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
} else {
|
||||
Logger.logWarning("You have " + Math.abs(duration.toDays()) + " days remaining in your trial.");
|
||||
}
|
||||
}
|
||||
|
||||
if(!Bukkit.getPluginManager().isPluginEnabled("QuickShop")
|
||||
&& !Bukkit.getPluginManager().isPluginEnabled("QuickShop-Hikari")) {
|
||||
Logger.logInfo("Delaying QuickShop hook as they are not enabled yet");
|
||||
}
|
||||
else if(Bukkit.getPluginManager().isPluginEnabled("QuickShop")) {
|
||||
qSReremakeInstalled = true;
|
||||
}
|
||||
else {
|
||||
qSHikariInstalled = true;
|
||||
}
|
||||
|
||||
// Registering Bukkit event listeners
|
||||
initBukkitEventListeners();
|
||||
|
||||
// Handle config file
|
||||
this.saveDefaultConfig();
|
||||
this.getConfig().options().copyDefaults(true);
|
||||
ConfigSetup.setupConfig();
|
||||
ConfigSetup.get().options().copyDefaults(true);
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
initConfigProvider();
|
||||
ConfigSetup.copySampleConfig();
|
||||
|
||||
initCommands();
|
||||
|
||||
// Run plugin startup logic after server is done loading
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FindItemAddOn.getInstance(), this::runPluginStartupTasks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
if(qsApi != null) {
|
||||
ShopSearchActivityStorageUtil.saveShopsToFile();
|
||||
}
|
||||
else if(!ENABLE_TRIAL_PERIOD) {
|
||||
Logger.logError("Uh oh! Looks like either this plugin has crashed or you don't have QuickShop-Hikari or QuickShop-Reremake installed.");
|
||||
}
|
||||
VirtualThreadScheduler.shutdown();
|
||||
Logger.logInfo("Bye!");
|
||||
}
|
||||
|
||||
private void runPluginStartupTasks() {
|
||||
serverVersion = Bukkit.getServer().getVersion();
|
||||
Logger.logInfo("Server version found: " + serverVersion);
|
||||
|
||||
if(!isQSReremakeInstalled() && !isQSHikariInstalled()) {
|
||||
Logger.logError("QuickShop-Hikari is required to use this addon. Please install QuickShop and try again!");
|
||||
// Logger.logError("Both QuickShop-Hikari and QuickShop-Reremake are supported by this addon.");
|
||||
Logger.logError("Download link:");
|
||||
Logger.logError("» QuickShop-Hikari: https://www.spigotmc.org/resources/100125");
|
||||
// Logger.logError("» QuickShop-Reremake (No official support): https://www.spigotmc.org/resources/62575");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
else if(isQSReremakeInstalled()) {
|
||||
Logger.logInfo("Found QuickShop-Reremake");
|
||||
qsApi = new QSReremakeAPIHandler();
|
||||
qsApi.registerSubCommand();
|
||||
} else {
|
||||
Logger.logInfo("Found QuickShop-Hikari");
|
||||
qsApi = new QSHikariAPIHandler();
|
||||
qsApi.registerSubCommand();
|
||||
}
|
||||
|
||||
// Load all hidden shops from file
|
||||
ShopSearchActivityStorageUtil.loadShopsFromFile();
|
||||
|
||||
// v2.0.0.0 - Migrating hiddenShops.json to shops.json
|
||||
ShopSearchActivityStorageUtil.migrateHiddenShopsToShopsJson();
|
||||
|
||||
// Setup optional dependencies
|
||||
PlayerWarpsPlugin.setup();
|
||||
EssentialsXPlugin.setup();
|
||||
WGPlugin.setup();
|
||||
ResidencePlugin.setup();
|
||||
bentoboxPlugin = new BentoBoxPlugin();
|
||||
|
||||
initExternalPluginEventListeners();
|
||||
|
||||
// Initiate batch tasks
|
||||
Logger.logInfo("Registering tasks");
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Task15MinInterval(), 0, REPEATING_TASK_SCHEDULE_MINS);
|
||||
|
||||
// init metrics
|
||||
Logger.logInfo("Registering anonymous bStats metrics");
|
||||
new Metrics(this, BS_PLUGIN_METRIC_ID);
|
||||
|
||||
// Check for plugin updates
|
||||
checkForPluginUpdates();
|
||||
}
|
||||
|
||||
private void checkForPluginUpdates() {
|
||||
updateChecker = new UpdateChecker();
|
||||
updateChecker.isUpdateAvailable(isUpdateAvailable -> {
|
||||
if(Boolean.TRUE.equals(isUpdateAvailable)) {
|
||||
isPluginOutdated = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCommands() {
|
||||
Logger.logInfo("Registering commands");
|
||||
initFindItemCmd();
|
||||
initFindItemAdminCmd();
|
||||
}
|
||||
|
||||
private void initBukkitEventListeners() {
|
||||
Logger.logInfo("Registering Bukkit event listeners");
|
||||
this.getServer().getPluginManager().registerEvents(new PluginEnableEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerCommandSendEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new MenuListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerJoinEventListener(), this);
|
||||
// QS-Hikari specific event listeners
|
||||
this.getServer().getPluginManager().registerEvents(new ShopCreateEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new ShopDeleteEventListener(), this);
|
||||
}
|
||||
|
||||
private void initExternalPluginEventListeners() {
|
||||
Logger.logInfo("Registering external plugin event listeners");
|
||||
if(PlayerWarpsPlugin.getIsEnabled()) {
|
||||
this.getServer().getPluginManager().registerEvents(new PWPlayerWarpRemoveEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PWPlayerWarpCreateEventListener(), this);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initConfigProvider() {
|
||||
configProvider = new ConfigProvider();
|
||||
}
|
||||
|
||||
public static PlayerMenuUtility getPlayerMenuUtility(Player p){
|
||||
PlayerMenuUtility playerMenuUtility;
|
||||
if(playerMenuUtilityMap.containsKey(p)) {
|
||||
return playerMenuUtilityMap.get(p);
|
||||
}
|
||||
else {
|
||||
playerMenuUtility = new PlayerMenuUtility(p);
|
||||
playerMenuUtilityMap.put(p, playerMenuUtility);
|
||||
return playerMenuUtility;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPluginID() {
|
||||
return SPIGOT_PLUGIN_ID;
|
||||
}
|
||||
|
||||
public static String getModrinthProjectSlug() {
|
||||
return MODRINTH_PROJECT_SLUG;
|
||||
}
|
||||
|
||||
private void initFindItemCmd() {
|
||||
List<String> aliases;
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " ")) {
|
||||
aliases = Arrays.asList("shopsearch", "searchshop", "searchitem");
|
||||
}
|
||||
else {
|
||||
aliases = 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(
|
||||
this,
|
||||
"finditem",
|
||||
"Search for items from all shops using an interactive GUI",
|
||||
"/finditem",
|
||||
(commandSender, subCommandList) -> {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&7------------------------"));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&6&lShop Search Commands"));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&7------------------------"));
|
||||
for (SubCommand subCommand : subCommandList) {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#ff9933" + subCommand.getSyntax() + " &#a3a3c2" + subCommand.getDescription()));
|
||||
}
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#b3b300Command aliases:"));
|
||||
aliases.forEach(alias -> commandSender.sendMessage(ColorTranslator.translateColorCodes("&8&l» db300/" + alias)));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
},
|
||||
aliases,
|
||||
subCommands);
|
||||
Logger.logInfo("Registered /finditem command");
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
Logger.logError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initFindItemAdminCmd() {
|
||||
List<String> alias = List.of("fiadmin");
|
||||
try {
|
||||
CommandManager.createCoreCommand(
|
||||
this,
|
||||
"finditemadmin",
|
||||
"Admin command for Shop Search addon",
|
||||
"/finditemadmin",
|
||||
(commandSender, subCommandList) -> {
|
||||
if (
|
||||
(commandSender.isOp())
|
||||
|| (!commandSender.isOp() && (commandSender.hasPermission(PlayerPermsEnum.FINDITEM_ADMIN.value())
|
||||
|| commandSender.hasPermission(PlayerPermsEnum.FINDITEM_RELOAD.value())))
|
||||
) {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&7-----------------------------"));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&6&lShop Search Admin Commands"));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&7-----------------------------"));
|
||||
|
||||
for (SubCommand subCommand : subCommandList) {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#ff1a1a" + subCommand.getSyntax() + " &#a3a3c2" + subCommand.getDescription()));
|
||||
}
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#b3b300Command alias:"));
|
||||
alias.forEach(alias_i -> commandSender.sendMessage(ColorTranslator.translateColorCodes("&8&l» db300/" + alias_i)));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
}
|
||||
},
|
||||
alias,
|
||||
ReloadSubCmd.class, DebugSubCmd.class);
|
||||
Logger.logInfo("Registered /finditemadmin command");
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
Logger.logError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setQSReremakeInstalled(boolean qSReremakeInstalled) {
|
||||
FindItemAddOn.qSReremakeInstalled = qSReremakeInstalled;
|
||||
}
|
||||
|
||||
public static void setQSHikariInstalled(boolean qSHikariInstalled) {
|
||||
FindItemAddOn.qSHikariInstalled = qSHikariInstalled;
|
||||
}
|
||||
|
||||
public static QSApi<?, ?> getQsApiInstance() {
|
||||
return qsApi;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,809 +0,0 @@
|
||||
package io.myzticbean.finditemaddon;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.BuySubCmd;
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.HideShopSubCmd;
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.ReloadSubCmd;
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.RevealShopSubCmd;
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.SellSubCmd;
|
||||
import io.myzticbean.finditemaddon.ConfigUtil.ConfigProvider;
|
||||
import io.myzticbean.finditemaddon.ConfigUtil.ConfigSetup;
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.Dependencies.WGPlugin;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.PlayerMenuUtility;
|
||||
import io.myzticbean.finditemaddon.Listeners.MenuListener;
|
||||
import io.myzticbean.finditemaddon.Listeners.PlayerCommandSendEventListener;
|
||||
import io.myzticbean.finditemaddon.Listeners.PluginEnableEventListener;
|
||||
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.LoggerUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public final class FindItemAddOnOG extends JavaPlugin {
|
||||
|
||||
private static Plugin plugin;
|
||||
|
||||
public FindItemAddOnOG() {
|
||||
|
||||
plugin = this;
|
||||
|
||||
}
|
||||
|
||||
public static Plugin getInstance() {
|
||||
|
||||
return plugin;
|
||||
|
||||
}
|
||||
|
||||
public static String serverVersion;
|
||||
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 final boolean isPluginOutdated = false;
|
||||
private static boolean qSReremakeInstalled = false;
|
||||
private static boolean qSHikariInstalled = false;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static QSApi qsApi;
|
||||
|
||||
private static final HashMap<Player, PlayerMenuUtility> playerMenuUtilityMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
LoggerUtils.logInfo("A Shop Search AddOn for QuickShop developed by myzticbean");
|
||||
|
||||
// Show warning if it's a snapshot build
|
||||
if (!this.getPluginMeta().getVersion().toLowerCase().contains("snapshot")) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logWarning("This is a SNAPSHOT build! NOT recommended for production servers.");
|
||||
LoggerUtils.logWarning(
|
||||
"If you find any bugs, please report them here: https://github.com/myzticbean/QSFindItemAddOn/issues");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("QuickShop-OG-Alt")
|
||||
&& !Bukkit.getPluginManager().isPluginEnabled("QuickShop-OG"))
|
||||
{
|
||||
|
||||
LoggerUtils.logInfo("Delaying QuickShop hook as they are not enabled yet");
|
||||
|
||||
} else if (Bukkit.getPluginManager().isPluginEnabled("QuickShop-OG-Alt")) {
|
||||
|
||||
qSReremakeInstalled = true;
|
||||
|
||||
} else {
|
||||
|
||||
qSHikariInstalled = true;
|
||||
|
||||
}
|
||||
|
||||
// Registering Bukkit event listeners
|
||||
initBukkitEventListeners();
|
||||
|
||||
// Handle config file
|
||||
this.saveDefaultConfig();
|
||||
this.getConfig().options().copyDefaults(true);
|
||||
ConfigSetup.setupConfig();
|
||||
ConfigSetup.get().options().copyDefaults(true);
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
initConfigProvider();
|
||||
ConfigSetup.copySampleConfig();
|
||||
|
||||
initCommands();
|
||||
|
||||
// Run plugin startup logic after server is done loading
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FindItemAddOnOG.getInstance(), this::runPluginStartupTasks);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Plugin shutdown logic
|
||||
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.");
|
||||
|
||||
}
|
||||
|
||||
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("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 (isQSReremakeInstalled()) {
|
||||
|
||||
LoggerUtils.logInfo("Found QuickShop-Reremake");
|
||||
qsApi = new QSReremakeAPIHandler();
|
||||
qsApi.registerSubCommand();
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logInfo("Found QuickShop-Hikari");
|
||||
qsApi = new QSHikariAPIHandler();
|
||||
qsApi.registerSubCommand();
|
||||
|
||||
}
|
||||
|
||||
// Load all hidden shops from file
|
||||
ShopSearchActivityStorageUtil.loadShopsFromFile();
|
||||
|
||||
// v2.0.0 - Migrating hiddenShops.json to shops.json
|
||||
ShopSearchActivityStorageUtil.migrateHiddenShopsToShopsJson();
|
||||
|
||||
EssentialsXPlugin.setup();
|
||||
WGPlugin.setup();
|
||||
|
||||
// Initiate batch tasks
|
||||
LoggerUtils.logInfo("Registering tasks");
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Task15MinInterval(), 0,
|
||||
REPEATING_TASK_SCHEDULE_MINS);
|
||||
|
||||
}
|
||||
|
||||
private void initCommands() {
|
||||
|
||||
LoggerUtils.logInfo("Registering commands");
|
||||
initFindItemCmd();
|
||||
initFindItemAdminCmd();
|
||||
|
||||
}
|
||||
|
||||
private void initBukkitEventListeners() {
|
||||
|
||||
LoggerUtils.logInfo("Registering Bukkit event listeners");
|
||||
this.getServer().getPluginManager().registerEvents(new PluginEnableEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerCommandSendEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new MenuListener(), this);
|
||||
|
||||
}
|
||||
|
||||
public static ConfigProvider getConfigProvider() {
|
||||
|
||||
return configProvider;
|
||||
|
||||
}
|
||||
|
||||
public static void initConfigProvider() {
|
||||
|
||||
configProvider = new ConfigProvider();
|
||||
|
||||
}
|
||||
|
||||
public static PlayerMenuUtility getPlayerMenuUtility(Player p) {
|
||||
|
||||
final PlayerMenuUtility playerMenuUtility;
|
||||
if (playerMenuUtilityMap.containsKey(p)) {
|
||||
|
||||
return playerMenuUtilityMap.get(p);
|
||||
|
||||
} else {
|
||||
|
||||
playerMenuUtility = new PlayerMenuUtility(p);
|
||||
playerMenuUtilityMap.put(p, playerMenuUtility);
|
||||
return playerMenuUtility;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean getPluginOutdated() {
|
||||
|
||||
return isPluginOutdated;
|
||||
|
||||
}
|
||||
|
||||
public static int getPluginID() {
|
||||
|
||||
return SPIGOT_PLUGIN_ID;
|
||||
|
||||
}
|
||||
|
||||
private void initFindItemCmd() {
|
||||
|
||||
final List<String> alias;
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
alias = Arrays.asList("shopsearch", "searchshop", "searchitem");
|
||||
|
||||
} else {
|
||||
|
||||
alias = FindItemAddOnOG.getConfigProvider().FIND_ITEM_COMMAND_ALIAS;
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Registering /find command");
|
||||
registerBukkitCommand("find", alias, "Search for items from all shops using an interactive GUI", "/find",
|
||||
new FindCommandExecutor(alias), new FindCommandExecutor(alias));
|
||||
LoggerUtils.logInfo("Registered /find command");
|
||||
|
||||
}
|
||||
|
||||
private void initFindItemAdminCmd() {
|
||||
|
||||
final List<String> alias = List.of("fiadmin");
|
||||
LoggerUtils.logInfo("Registering /finditemadmin command");
|
||||
registerBukkitCommand("finditemadmin", alias, "Admin command for Shop Search addon", "/finditemadmin",
|
||||
new FindItemAdminCommandExecutor(alias), new FindItemAdminCommandExecutor(alias));
|
||||
LoggerUtils.logInfo("Registered /finditemadmin command");
|
||||
|
||||
}
|
||||
|
||||
private void registerBukkitCommand(String name, List<String> aliases, String description, String usage,
|
||||
CommandExecutor executor, TabCompleter completer)
|
||||
{
|
||||
|
||||
PluginCommand cmd = this.getCommand(name);
|
||||
if (cmd == null) {
|
||||
|
||||
cmd = registerDynamicPluginCommand(name);
|
||||
|
||||
}
|
||||
|
||||
if (cmd == null) {
|
||||
|
||||
LoggerUtils.logError("Failed to register command: " + name);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
cmd.setDescription(description);
|
||||
cmd.setUsage(usage);
|
||||
|
||||
if (aliases != null) {
|
||||
|
||||
cmd.setAliases(aliases);
|
||||
|
||||
}
|
||||
|
||||
cmd.setExecutor(executor);
|
||||
cmd.setTabCompleter(completer);
|
||||
|
||||
}
|
||||
|
||||
private PluginCommand registerDynamicPluginCommand(String name) {
|
||||
|
||||
try {
|
||||
|
||||
final CommandMap commandMap = getCommandMap();
|
||||
if (commandMap == null) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
final Constructor<PluginCommand> ctor = PluginCommand.class.getDeclaredConstructor(String.class,
|
||||
Plugin.class);
|
||||
ctor.setAccessible(true);
|
||||
|
||||
final PluginCommand cmd = ctor.newInstance(name, this);
|
||||
commandMap.register(this.getPluginMeta().getName(), cmd);
|
||||
return cmd;
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
||||
LoggerUtils.logError(t.getMessage());
|
||||
t.printStackTrace();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private CommandMap getCommandMap() {
|
||||
|
||||
try {
|
||||
|
||||
final Method m = Bukkit.getServer().getClass().getMethod("getCommandMap");
|
||||
return (CommandMap) m.invoke(Bukkit.getServer());
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
||||
LoggerUtils.logError(t.getMessage());
|
||||
t.printStackTrace();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private record FindCommandExecutor(List<String> aliases) implements CommandExecutor, TabCompleter {
|
||||
|
||||
private FindCommandExecutor(List<String> aliases) {
|
||||
|
||||
this.aliases = aliases == null ? Collections.emptyList() : aliases;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if (args.length == 0 || "help".equalsIgnoreCase(args[0])) {
|
||||
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
final String sub = args[0].toLowerCase();
|
||||
final String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
final SellSubCmd sellSubCmd = new SellSubCmd();
|
||||
final BuySubCmd buySubCmd = new BuySubCmd();
|
||||
final HideShopSubCmd hideShopSubCmd = new HideShopSubCmd();
|
||||
final RevealShopSubCmd revealShopSubCmd = new RevealShopSubCmd();
|
||||
|
||||
if (matchesSubCommand(sub, "sell", sellSubCmd)) {
|
||||
|
||||
return invokeSubCommand(sellSubCmd, sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "buy", buySubCmd)) {
|
||||
|
||||
return invokeSubCommand(buySubCmd, sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "hide", hideShopSubCmd) || "hideshop".equals(sub)) {
|
||||
|
||||
return invokeSubCommand(hideShopSubCmd, sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "reveal", revealShopSubCmd) || "revealshop".equals(sub)) {
|
||||
|
||||
return invokeSubCommand(revealShopSubCmd, sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
final SellSubCmd sellSubCmd = new SellSubCmd();
|
||||
final BuySubCmd buySubCmd = new BuySubCmd();
|
||||
final HideShopSubCmd hideShopSubCmd = new HideShopSubCmd();
|
||||
final RevealShopSubCmd revealShopSubCmd = new RevealShopSubCmd();
|
||||
|
||||
if (args.length == 1) {
|
||||
|
||||
return partialMatches(args[0],
|
||||
Arrays.asList(getSubCommandName(sellSubCmd), getSubCommandName(buySubCmd),
|
||||
getSubCommandName(hideShopSubCmd), getSubCommandName(revealShopSubCmd), "sell", "buy",
|
||||
"hide", "reveal", "help", "hideshop", "revealshop"));
|
||||
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
|
||||
final String sub = args[0].toLowerCase();
|
||||
final String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if (matchesSubCommand(sub, "sell", sellSubCmd)) {
|
||||
|
||||
return invokeTabComplete(sellSubCmd, sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "buy", buySubCmd)) {
|
||||
|
||||
return invokeTabComplete(buySubCmd, sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "hide", hideShopSubCmd) || "hideshop".equals(sub)) {
|
||||
|
||||
return invokeTabComplete(hideShopSubCmd, sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "reveal", revealShopSubCmd) || "revealshop".equals(sub)) {
|
||||
|
||||
return invokeTabComplete(revealShopSubCmd, sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
private void sendHelp(CommandSender commandSender) {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&7------------------------"));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&6&lShop Search Commands"));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&7------------------------"));
|
||||
|
||||
final List<Object> subCommands = Arrays.asList(new SellSubCmd(), new BuySubCmd(), new HideShopSubCmd(),
|
||||
new RevealShopSubCmd());
|
||||
|
||||
subCommands.forEach(subCommand -> commandSender.sendMessage(UtilitiesOG.trueogColorize("<#ff9933>"
|
||||
+ getSubCommandSyntax(subCommand) + " <#a3a3c2>" + getSubCommandDescription(subCommand))));
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("<#b3b300>Command alias:"));
|
||||
aliases.forEach(
|
||||
alias_i -> commandSender.sendMessage(UtilitiesOG.trueogColorize("&8&l» <#2db300>/" + alias_i)));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private record FindItemAdminCommandExecutor(List<String> aliases) implements CommandExecutor, TabCompleter {
|
||||
|
||||
private FindItemAdminCommandExecutor(List<String> aliases) {
|
||||
|
||||
this.aliases = aliases == null ? Collections.emptyList() : aliases;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if (!((sender.isOp()) || (!sender.isOp() && (sender.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())
|
||||
|| sender.hasPermission(PlayerPerms.FINDITEM_RELOAD.value())))))
|
||||
{
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args.length == 0 || "help".equalsIgnoreCase(args[0])) {
|
||||
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
final String sub = args[0].toLowerCase();
|
||||
final String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if ("reload".equals(sub)) {
|
||||
|
||||
return invokeSubCommand(new ReloadSubCmd(), sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
if (!((sender.isOp()) || (!sender.isOp() && (sender.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())
|
||||
|| sender.hasPermission(PlayerPerms.FINDITEM_RELOAD.value())))))
|
||||
{
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
|
||||
return partialMatches(args[0], Arrays.asList("reload", "help"));
|
||||
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
|
||||
final String sub = args[0].toLowerCase();
|
||||
final String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if ("reload".equals(sub)) {
|
||||
|
||||
return invokeTabComplete(new ReloadSubCmd(), sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
private void sendHelp(CommandSender commandSender) {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&7-----------------------------"));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&6&lShop Search Admin Commands"));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&7-----------------------------"));
|
||||
|
||||
final List<Object> subCommands = Collections.singletonList(new ReloadSubCmd());
|
||||
|
||||
subCommands.forEach(subCommand -> commandSender.sendMessage(UtilitiesOG.trueogColorize("<#ff1a1a>"
|
||||
+ getSubCommandSyntax(subCommand) + " <#a3a3c2>" + getSubCommandDescription(subCommand))));
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("<#b3b300>Command alias:"));
|
||||
aliases.forEach(
|
||||
alias_i -> commandSender.sendMessage(UtilitiesOG.trueogColorize("&8&l» <#2db300>/" + alias_i)));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static boolean invokeSubCommand(Object subCommand, CommandSender sender, Command command, String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (subCommand instanceof CommandExecutor) {
|
||||
|
||||
return ((CommandExecutor) subCommand).onCommand(sender, command, label, args);
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("execute", CommandSender.class, String[].class);
|
||||
final Object res = m.invoke(subCommand, sender, args);
|
||||
if (res instanceof Boolean) {
|
||||
|
||||
return (Boolean) res;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("execute", CommandSender.class, Command.class,
|
||||
String.class, String[].class);
|
||||
final Object res = m.invoke(subCommand, sender, command, label, args);
|
||||
if (res instanceof Boolean) {
|
||||
|
||||
return (Boolean) res;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("onCommand", CommandSender.class, Command.class,
|
||||
String.class, String[].class);
|
||||
final Object res = m.invoke(subCommand, sender, command, label, args);
|
||||
if (res instanceof Boolean) {
|
||||
|
||||
return (Boolean) res;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
||||
LoggerUtils.logError(t.getMessage());
|
||||
t.printStackTrace();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static List<String> invokeTabComplete(Object subCommand, CommandSender sender, Command command,
|
||||
String label, String[] args)
|
||||
{
|
||||
|
||||
if (subCommand instanceof TabCompleter) {
|
||||
|
||||
final List<String> res = ((TabCompleter) subCommand).onTabComplete(sender, command, label, args);
|
||||
return res == null ? Collections.emptyList() : res;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("onTabComplete", CommandSender.class, Command.class,
|
||||
String.class, String[].class);
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<String> res = (List<String>) m.invoke(subCommand, sender, command, label, args);
|
||||
return res == null ? Collections.emptyList() : res;
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
private static String getSubCommandSyntax(Object subCommand) {
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("getSyntax");
|
||||
final Object res = m.invoke(subCommand);
|
||||
return res == null ? "" : String.valueOf(res);
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
private static String getSubCommandName(Object subCommand) {
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("getName");
|
||||
final Object res = m.invoke(subCommand);
|
||||
return res == null ? "" : String.valueOf(res);
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
private static boolean matchesSubCommand(String input, String fallbackCommand, Object subCommand) {
|
||||
|
||||
if (fallbackCommand.equalsIgnoreCase(input)) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
final String subCommandName = getSubCommandName(subCommand);
|
||||
return !subCommandName.isBlank() && subCommandName.equalsIgnoreCase(input);
|
||||
|
||||
}
|
||||
|
||||
private static String getSubCommandDescription(Object subCommand) {
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("getDescription");
|
||||
final Object res = m.invoke(subCommand);
|
||||
return res == null ? "" : String.valueOf(res);
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
private static List<String> partialMatches(String token, List<String> options) {
|
||||
|
||||
if (token == null || token.isEmpty()) {
|
||||
|
||||
return options;
|
||||
|
||||
}
|
||||
|
||||
final String lower = token.toLowerCase();
|
||||
return options.stream().filter(s -> s.toLowerCase().startsWith(lower)).toList();
|
||||
|
||||
}
|
||||
|
||||
public static boolean isQSReremakeInstalled() {
|
||||
|
||||
return qSReremakeInstalled;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isQSHikariInstalled() {
|
||||
|
||||
return qSHikariInstalled;
|
||||
|
||||
}
|
||||
|
||||
public static void setQSReremakeInstalled(boolean qSReremakeInstalled) {
|
||||
|
||||
FindItemAddOnOG.qSReremakeInstalled = qSReremakeInstalled;
|
||||
|
||||
}
|
||||
|
||||
public static void setQSHikariInstalled(boolean qSHikariInstalled) {
|
||||
|
||||
FindItemAddOnOG.qSHikariInstalled = qSHikariInstalled;
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static QSApi getQsApiInstance() {
|
||||
|
||||
return qsApi;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-582
@@ -1,582 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Handlers.CommandHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.quickshop.api.shop.Shop;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.ConfigUtil.ConfigSetup;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.Menus.FoundShopsMenu;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.HiddenShopStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.WarpUtils;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* Handler for different parameters of /find command
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class CmdExecutorHandler {
|
||||
|
||||
/**
|
||||
* Handles the main shop search process
|
||||
*
|
||||
* @param buySellSubCommand Whether player is buying or selling
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
* @param itemArg Specifies Item ID or Item name
|
||||
*/
|
||||
public void handleShopSearch(String buySellSubCommand, CommandSender commandSender, String itemArg) {
|
||||
|
||||
if (!(commandSender instanceof Player)) {
|
||||
|
||||
LoggerUtils.logInfo("This command can only be run from in game");
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_USE.value())) {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_SEARCH_LOADING_MSG)) {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_SEARCH_LOADING_MSG));
|
||||
|
||||
}
|
||||
|
||||
boolean isBuying;
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(
|
||||
FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
isBuying = buySellSubCommand.equalsIgnoreCase("to_buy");
|
||||
|
||||
} else {
|
||||
|
||||
isBuying = buySellSubCommand
|
||||
.equalsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
if (itemArg.equalsIgnoreCase("*")) {
|
||||
|
||||
List<FoundShopItemModel> searchResultList = FindItemAddOnOG.getQsApiInstance()
|
||||
.fetchAllItemsFromAllShops(isBuying, player);
|
||||
if (searchResultList.size() > 0) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOnOG.getPlayerMenuUtility(player),
|
||||
searchResultList);
|
||||
Bukkit.getScheduler().runTask(FindItemAddOnOG.getInstance(),
|
||||
() -> menu.open(searchResultList));
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().NO_SHOP_FOUND_MSG)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().NO_SHOP_FOUND_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
final Material mat = Material.getMaterial(itemArg.toUpperCase());
|
||||
if (mat != null) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Material found: " + mat.toString());
|
||||
final List<FoundShopItemModel> searchResultList = FindItemAddOnOG.getQsApiInstance()
|
||||
.findItemBasedOnTypeFromAllShops(new ItemStack(mat), isBuying, player);
|
||||
if (searchResultList.size() > 0) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
final FoundShopsMenu menu = new FoundShopsMenu(
|
||||
FindItemAddOnOG.getPlayerMenuUtility(player), searchResultList);
|
||||
Bukkit.getScheduler().runTask(FindItemAddOnOG.getInstance(),
|
||||
() -> menu.open(searchResultList));
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().NO_SHOP_FOUND_MSG)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().NO_SHOP_FOUND_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo("Material not found! Performing query based search..");
|
||||
List<FoundShopItemModel> searchResultList = FindItemAddOnOG.getQsApiInstance()
|
||||
.findItemBasedOnDisplayNameFromAllShops(itemArg, isBuying, player);
|
||||
if (searchResultList.size() > 0) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
final FoundShopsMenu menu = new FoundShopsMenu(
|
||||
FindItemAddOnOG.getPlayerMenuUtility(player), searchResultList);
|
||||
Bukkit.getScheduler().runTask(FindItemAddOnOG.getInstance(),
|
||||
() -> menu.open(searchResultList));
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
// Invalid Material.
|
||||
if (!StringUtils
|
||||
.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG))
|
||||
{
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(
|
||||
FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + FindItemAddOnOG
|
||||
.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the shop hiding feature
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
public void handleHideShop(CommandSender commandSender) {
|
||||
|
||||
if (!(commandSender instanceof Player)) {
|
||||
|
||||
LoggerUtils.logInfo("This command can only be run from in game");
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
Block playerLookAtBlock = player.getTargetBlock(null, 100);
|
||||
if (FindItemAddOnOG.isQSReremakeInstalled()) {
|
||||
|
||||
hideShop((Shop) FindItemAddOnOG.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
|
||||
} else {
|
||||
|
||||
hideShop((com.ghostchu.quickshop.api.shop.Shop) FindItemAddOnOG.getQsApiInstance()
|
||||
.findShopAtLocation(playerLookAtBlock), player);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the shop reveal feature
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
public void handleRevealShop(CommandSender commandSender) {
|
||||
|
||||
if (!(commandSender instanceof Player)) {
|
||||
|
||||
LoggerUtils.logInfo("This command can only be run from in game");
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
Block playerLookAtBlock = player.getTargetBlock(null, 100);
|
||||
if (FindItemAddOnOG.isQSReremakeInstalled()) {
|
||||
|
||||
revealShop((Shop) FindItemAddOnOG.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
|
||||
} else {
|
||||
|
||||
revealShop((com.ghostchu.quickshop.api.shop.Shop) FindItemAddOnOG.getQsApiInstance()
|
||||
.findShopAtLocation(playerLookAtBlock), player);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the saving hidden shops to file feature
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
/*
|
||||
* public void handleHiddenShopSavingToFile(CommandSender commandSender) { if
|
||||
* (!(commandSender instanceof Player)) {
|
||||
* LoggerUtils.logInfo("This command can only be run from in game"); } else {
|
||||
* Player player = (Player) commandSender;
|
||||
* if(player.hasPermission(PlayerPerms.FINDITEM_ADMIN.toString())) {
|
||||
* HiddenShopStorageUtil.saveHiddenShopsToFile();
|
||||
* player.sendMessage(UtilitiesOG.trueogColorize(
|
||||
* FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&aSaved hidden shops!"));
|
||||
* } else { player.sendMessage( UtilitiesOG.trueogColorize(
|
||||
* FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!")); } } }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles the loading of hidden shops from file feature
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
/*
|
||||
* public void handleHiddenShopLoadingFromFile(CommandSender commandSender) { if
|
||||
* (!(commandSender instanceof Player)) {
|
||||
* LoggerUtils.logInfo("This command can only be run from in game"); } else {
|
||||
* Player player = (Player) commandSender;
|
||||
* if(player.hasPermission(PlayerPerms.FINDITEM_ADMIN.toString())) {
|
||||
* HiddenShopStorageUtil.loadHiddenShopsFromFile();
|
||||
* player.sendMessage(UtilitiesOG.trueogColorize(
|
||||
* FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&aSaved hidden shops!"));
|
||||
* } else { player.sendMessage( UtilitiesOG.trueogColorize(
|
||||
* FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!")); } } }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles plugin reload
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
public void handlePluginReload(CommandSender commandSender) {
|
||||
|
||||
if (!(commandSender instanceof Player)) {
|
||||
|
||||
ConfigSetup.reloadConfig();
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
FindItemAddOnOG.initConfigProvider();
|
||||
List allServerShops = FindItemAddOnOG.getQsApiInstance().getAllShops();
|
||||
if (allServerShops.size() == 0) {
|
||||
|
||||
LoggerUtils.logWarning(
|
||||
"&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logInfo("&aFound &e" + allServerShops.size() + " &ashops on the server.");
|
||||
|
||||
}
|
||||
|
||||
WarpUtils.updateWarps();
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_RELOAD.value())
|
||||
|| player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value()))
|
||||
{
|
||||
|
||||
ConfigSetup.reloadConfig();
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
FindItemAddOnOG.initConfigProvider();
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&aConfig reloaded!"));
|
||||
final List allServerShops = FindItemAddOnOG.getQsApiInstance().getAllShops();
|
||||
if (allServerShops.size() == 0) {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!"));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&aFound &e" + allServerShops.size() + " &ashops on the server."));
|
||||
|
||||
}
|
||||
|
||||
WarpUtils.updateWarps();
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @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(FindItemAddOnOG.getInstance());
|
||||
Bukkit.getPluginManager().enablePlugin(FindItemAddOnOG.getPlugin(FindItemAddOnOG.class));
|
||||
LoggerUtils.logInfo("&aPlugin restarted!");
|
||||
List allServerShops = FindItemAddOnOG.getQsApiInstance().getAllShops();
|
||||
if (allServerShops.size() == 0) {
|
||||
|
||||
LoggerUtils.logWarning(
|
||||
"&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logInfo("&aFound &e" + allServerShops.size() + " &ashops on the server.");
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_RESTART.value())
|
||||
|| player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value()))
|
||||
{
|
||||
|
||||
Bukkit.getPluginManager().disablePlugin(FindItemAddOnOG.getInstance());
|
||||
Bukkit.getPluginManager().enablePlugin(FindItemAddOnOG.getPlugin(FindItemAddOnOG.class));
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&aPlugin restarted!"));
|
||||
List allServerShops = FindItemAddOnOG.getQsApiInstance().getAllShops();
|
||||
if (allServerShops.size() == 0) {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!"));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&aFound &e" + allServerShops.size() + " &ashops on the server."));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles hide shop for QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
* @param 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 (FindItemAddOnOG.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, true);
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles hide shop for QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void hideShop(com.ghostchu.quickshop.api.shop.Shop shop, Player player) {
|
||||
|
||||
if (shop != null) {
|
||||
|
||||
// check if command runner same as shop owner
|
||||
if (FindItemAddOnOG.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, true);
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles reveal shop for QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void revealShop(Shop shop, Player player) {
|
||||
|
||||
if (shop != null) {
|
||||
|
||||
// check if command runner same as shop owner
|
||||
if (FindItemAddOnOG.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
|
||||
if (HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, false);
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles reveal shop for QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void revealShop(com.ghostchu.quickshop.api.shop.Shop shop, Player player) {
|
||||
|
||||
if (shop != null) {
|
||||
|
||||
// check if command runner same as shop owner
|
||||
if (FindItemAddOnOG.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
|
||||
if (HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, false);
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Handlers.GUIHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
protected PlayerMenuUtility playerMenuUtility;
|
||||
|
||||
protected ItemStack GUI_FILLER_ITEM;
|
||||
|
||||
protected Menu(PlayerMenuUtility playerMenuUtility) {
|
||||
|
||||
this.playerMenuUtility = playerMenuUtility;
|
||||
|
||||
assert FindItemAddOnOG.getConfigProvider().SHOP_GUI_FILLER_ITEM != null;
|
||||
Material fillerMaterial = Material.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_FILLER_ITEM);
|
||||
if (fillerMaterial == null) {
|
||||
|
||||
fillerMaterial = Material.GRAY_STAINED_GLASS_PANE;
|
||||
|
||||
}
|
||||
|
||||
GUI_FILLER_ITEM = new ItemStack(fillerMaterial);
|
||||
final ItemMeta FILLER_GLASS_meta = this.GUI_FILLER_ITEM.getItemMeta();
|
||||
assert FILLER_GLASS_meta != null;
|
||||
FILLER_GLASS_meta.displayName(Component.text(" "));
|
||||
this.GUI_FILLER_ITEM.setItemMeta(FILLER_GLASS_meta);
|
||||
|
||||
}
|
||||
|
||||
public abstract TextComponent getMenuName();
|
||||
|
||||
public abstract int getSlots();
|
||||
|
||||
public abstract void handleMenu(InventoryClickEvent e);
|
||||
|
||||
public abstract void setMenuItems();
|
||||
|
||||
public abstract void setMenuItems(List<FoundShopItemModel> foundShops);
|
||||
|
||||
public void open() {
|
||||
|
||||
inventory = Bukkit.createInventory(this, getSlots(), getMenuName());
|
||||
this.setMenuItems();
|
||||
playerMenuUtility.getOwner().openInventory(inventory);
|
||||
|
||||
}
|
||||
|
||||
public void open(List<FoundShopItemModel> foundShops) {
|
||||
|
||||
inventory = Bukkit.createInventory(this, getSlots(), getMenuName());
|
||||
this.setMenuItems(foundShops);
|
||||
playerMenuUtility.getOwner().openInventory(inventory);
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
|
||||
return inventory;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-607
@@ -1,607 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Handlers.GUIHandler.Menus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.Dependencies.WGPlugin;
|
||||
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.LocationUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.ShopLorePlaceholders;
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.EssentialWarpsUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.WGRegionUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* Handler class for FoundShops GUI
|
||||
*
|
||||
* @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 FoundShopsMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
|
||||
|
||||
super(playerMenuUtility, searchResult);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextComponent getMenuName() {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_SEARCH_GUI_TITLE)) {
|
||||
|
||||
return UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_SEARCH_GUI_TITLE);
|
||||
|
||||
} else {
|
||||
|
||||
return UtilitiesOG.trueogColorize("&l» &rShops");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
|
||||
return 54;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMenu(InventoryClickEvent event) {
|
||||
|
||||
// Previous Page
|
||||
if (event.getSlot() == 45) {
|
||||
|
||||
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) {
|
||||
|
||||
handleMenuClickForNavToNextPage(event);
|
||||
|
||||
}
|
||||
// Issue #31: Removing condition
|
||||
// 'event.getCurrentItem().getType().equals(Material.BARRIER)'
|
||||
else if (event.getSlot() == 49) {
|
||||
|
||||
event.getWhoClicked().closeInventory();
|
||||
|
||||
} else {
|
||||
|
||||
final ItemStack clicked = event.getCurrentItem();
|
||||
if (clicked == null || clicked.getType() == Material.AIR) {
|
||||
|
||||
LoggerUtils.logDebugInfo(event.getWhoClicked().getName() + " just clicked on AIR!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
final ItemMeta meta = clicked.getItemMeta();
|
||||
if (meta == null) {
|
||||
|
||||
LoggerUtils.logError("Clicked item has no ItemMeta!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final NamespacedKey key = new NamespacedKey(FindItemAddOnOG.getInstance(), "locationData");
|
||||
if (!meta.getPersistentDataContainer().isEmpty()
|
||||
&& meta.getPersistentDataContainer().has(key, PersistentDataType.STRING))
|
||||
{
|
||||
|
||||
final String locData = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
||||
if (locData == null) {
|
||||
|
||||
LoggerUtils.logError("PersistentDataContainer locationData is null!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final List<String> locDataList = Arrays.asList(locData.split("\\s*,\\s*"));
|
||||
if (FindItemAddOnOG.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP) {
|
||||
|
||||
if (playerMenuUtility.getOwner().hasPermission(PlayerPerms.FINDITEM_SHOPTP.value())) {
|
||||
|
||||
final World world = Bukkit.getWorld(locDataList.get(0));
|
||||
if (world == null) {
|
||||
|
||||
LoggerUtils.logError("World not found: " + locDataList.get(0));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final int locX = Integer.parseInt(locDataList.get(1));
|
||||
final int locY = Integer.parseInt(locDataList.get(2));
|
||||
final int locZ = Integer.parseInt(locDataList.get(3));
|
||||
final Location shopLocation = new Location(world, locX, locY, locZ);
|
||||
final UUID shopOwner = ShopSearchActivityStorageUtil.getShopOwnerUUID(shopLocation);
|
||||
if (player.getUniqueId().equals(shopOwner) && !PlayerPerms.canPlayerTpToOwnShop(player)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG));
|
||||
|
||||
}
|
||||
|
||||
final Location locToTeleport = LocationUtils.findSafeLocationAroundShop(shopLocation);
|
||||
if (locToTeleport != null) {
|
||||
|
||||
ShopSearchActivityStorageUtil.addPlayerVisitEntryAsync(shopLocation, player);
|
||||
|
||||
if (EssentialsXPlugin.isEnabled()) {
|
||||
|
||||
EssentialsXPlugin.getAPI().getUser(player).setLastLocation();
|
||||
|
||||
}
|
||||
|
||||
if (StringUtils.isNumeric(FindItemAddOnOG.getConfigProvider().TP_DELAY_IN_SECONDS)
|
||||
&& !"0".equals(FindItemAddOnOG.getConfigProvider().TP_DELAY_IN_SECONDS)
|
||||
&& !PlayerPerms.hasShopTpDelayBypassPermOrAdmin(player))
|
||||
{
|
||||
|
||||
final long delay = Long
|
||||
.parseLong(FindItemAddOnOG.getConfigProvider().TP_DELAY_IN_SECONDS);
|
||||
LoggerUtils.logDebugInfo("Teleporting delay is set to: " + delay);
|
||||
final String tpDelayMsg = FindItemAddOnOG.getConfigProvider().TP_DELAY_MESSAGE;
|
||||
if (!StringUtils.isEmpty(tpDelayMsg)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ replaceDelayPlaceholder(tpDelayMsg, delay)));
|
||||
|
||||
}
|
||||
|
||||
Bukkit.getScheduler()
|
||||
.scheduleSyncDelayedTask(
|
||||
FindItemAddOnOG.getInstance(), () -> PaperLib.teleportAsync(player,
|
||||
locToTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN),
|
||||
delay * 20);
|
||||
|
||||
} else {
|
||||
|
||||
PaperLib.teleportAsync(player, locToTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().UNSAFE_SHOP_AREA_MSG)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().UNSAFE_SHOP_AREA_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG)) {
|
||||
|
||||
playerMenuUtility.getOwner().sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG));
|
||||
event.getWhoClicked().closeInventory();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
|
||||
} else if (FindItemAddOnOG.getConfigProvider().TP_PLAYER_TO_NEAREST_WARP && locDataList.size() == 1) {
|
||||
|
||||
final String warpName = locDataList.get(0);
|
||||
if (FindItemAddOnOG.getConfigProvider().NEAREST_WARP_MODE == 1) {
|
||||
|
||||
Bukkit.dispatchCommand(player, "essentials:warp " + 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(FindItemAddOnOG.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
|
||||
|
||||
event.getWhoClicked()
|
||||
.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleMenuClickForNavToPrevPage(InventoryClickEvent event) {
|
||||
|
||||
if (page == 0) {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
|
||||
|
||||
event.getWhoClicked()
|
||||
.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.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(FindItemAddOnOG.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
|
||||
|
||||
event.getWhoClicked()
|
||||
.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.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(FindItemAddOnOG.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
|
||||
|
||||
event.getWhoClicked()
|
||||
.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty method in case we need to handle static GUI icons in future
|
||||
*/
|
||||
@Override
|
||||
public void setMenuItems() {
|
||||
|
||||
// Just overriding
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the slots in the search result GUI
|
||||
*
|
||||
* @param foundShops List of found shops
|
||||
*/
|
||||
@Override
|
||||
public void setMenuItems(List<FoundShopItemModel> foundShops) {
|
||||
|
||||
addMenuBottomBar();
|
||||
if (!(foundShops != null && !foundShops.isEmpty())) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
int guiSlotCounter = 0;
|
||||
while (guiSlotCounter < super.maxItemsPerPage) {
|
||||
|
||||
index = super.maxItemsPerPage * page + guiSlotCounter;
|
||||
|
||||
if (index >= foundShops.size()) {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (foundShops.get(index) != null) {
|
||||
|
||||
final FoundShopItemModel foundShop_i = foundShops.get(index);
|
||||
final NamespacedKey key = new NamespacedKey(FindItemAddOnOG.getInstance(), "locationData");
|
||||
final ItemStack item = new ItemStack(foundShop_i.getItem().getType());
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) {
|
||||
|
||||
guiSlotCounter++;
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
final List<Component> lore = new ArrayList<>();
|
||||
if (foundShop_i.getItem().hasItemMeta()) {
|
||||
|
||||
final ItemMeta foundMeta = foundShop_i.getItem().getItemMeta();
|
||||
if (foundMeta != null) {
|
||||
|
||||
meta = foundMeta;
|
||||
final List<Component> existingLore = foundMeta.lore();
|
||||
if (existingLore != null && !existingLore.isEmpty()) {
|
||||
|
||||
lore.addAll(existingLore);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final List<String> shopItemLore = FindItemAddOnOG.getConfigProvider().SHOP_GUI_ITEM_LORE;
|
||||
String nearestEWarp = null;
|
||||
|
||||
for (String shopItemLore_i : shopItemLore) {
|
||||
|
||||
if (shopItemLore_i.contains(ShopLorePlaceholders.NEAREST_WARP.value())) {
|
||||
|
||||
switch (FindItemAddOnOG.getConfigProvider().NEAREST_WARP_MODE) {
|
||||
|
||||
case 1 -> {
|
||||
|
||||
String replacement = NO_WARP_NEAR_SHOP_ERROR_MSG;
|
||||
if (EssentialsXPlugin.isEnabled()) {
|
||||
|
||||
nearestEWarp = new EssentialWarpsUtil()
|
||||
.findNearestWarp(foundShop_i.getShopLocation());
|
||||
if (nearestEWarp != null && !StringUtils.isEmpty(nearestEWarp)) {
|
||||
|
||||
replacement = nearestEWarp;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lore.add(UtilitiesOG.trueogColorize(shopItemLore_i
|
||||
.replace(ShopLorePlaceholders.NEAREST_WARP.value(), replacement)));
|
||||
|
||||
}
|
||||
case 2 -> {
|
||||
|
||||
String replacement = NO_WG_REGION_NEAR_SHOP_ERROR_MSG;
|
||||
if (WGPlugin.isEnabled()) {
|
||||
|
||||
final String nearestWGRegion = new WGRegionUtils()
|
||||
.findNearestWGRegion((foundShop_i.getShopLocation()));
|
||||
if (nearestWGRegion != null && !StringUtils.isEmpty(nearestWGRegion)) {
|
||||
|
||||
replacement = nearestWGRegion;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lore.add(UtilitiesOG.trueogColorize(shopItemLore_i
|
||||
.replace(ShopLorePlaceholders.NEAREST_WARP.value(), replacement)));
|
||||
|
||||
}
|
||||
default -> LoggerUtils.logDebugInfo("Invalid value in 'nearest-warp-mode' in config.yml!");
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
lore.add(UtilitiesOG.trueogColorize(replaceLorePlaceholders(shopItemLore_i, foundShop_i)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (FindItemAddOnOG.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP
|
||||
&& playerMenuUtility.getOwner().hasPermission(PlayerPerms.FINDITEM_SHOPTP.value()))
|
||||
{
|
||||
|
||||
lore.add(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().CLICK_TO_TELEPORT_MSG));
|
||||
|
||||
}
|
||||
|
||||
meta.lore(lore);
|
||||
|
||||
String locData = StringUtils.EMPTY;
|
||||
if (FindItemAddOnOG.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();
|
||||
|
||||
} else if (FindItemAddOnOG.getConfigProvider().TP_PLAYER_TO_NEAREST_WARP) {
|
||||
|
||||
final boolean condition = FindItemAddOnOG.getConfigProvider().NEAREST_WARP_MODE == 1
|
||||
&& nearestEWarp != null;
|
||||
if (condition) {
|
||||
|
||||
locData = nearestEWarp;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, locData);
|
||||
|
||||
if (Objects.requireNonNull(foundShop_i.getItem().getItemMeta()).hasCustomModelData()) {
|
||||
|
||||
meta.setCustomModelData(foundShop_i.getItem().getItemMeta().getCustomModelData());
|
||||
|
||||
}
|
||||
|
||||
item.setItemMeta(meta);
|
||||
inventory.addItem(item);
|
||||
|
||||
}
|
||||
|
||||
guiSlotCounter++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all the placeholders in the Shop item lore in GUI
|
||||
*
|
||||
* @param text Line of lore
|
||||
* @param shop Shop instance
|
||||
* @return Line of lore replaced with placeholder values
|
||||
*/
|
||||
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(ShopLorePlaceholders.SHOP_STOCK.value())) {
|
||||
|
||||
if (shop.getRemainingStockOrSpace() == Integer.MAX_VALUE) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_STOCK.value(), "Unlimited");
|
||||
|
||||
} else {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_STOCK.value(),
|
||||
String.valueOf(shop.getRemainingStockOrSpace()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (text.contains(ShopLorePlaceholders.SHOP_OWNER.value())) {
|
||||
|
||||
OfflinePlayer shopOwner = Bukkit.getOfflinePlayer(shop.getShopOwner());
|
||||
if (shopOwner.getName() != null) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_OWNER.value(), shopOwner.getName());
|
||||
|
||||
} else {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_OWNER.value(), "Admin");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (text.contains(ShopLorePlaceholders.SHOP_LOCATION.value())) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.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(ShopLorePlaceholders.SHOP_VISITS.value())) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_VISITS.value(),
|
||||
String.valueOf(ShopSearchActivityStorageUtil.getPlayerVisitCount(shop.getShopLocation())));
|
||||
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
}
|
||||
|
||||
private String replaceDelayPlaceholder(String tpDelayMsg, long delay) {
|
||||
|
||||
return tpDelayMsg.replace("{DELAY}", String.valueOf(delay));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Handlers.GUIHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public abstract class PaginatedMenu extends Menu {
|
||||
|
||||
protected int page = 0;
|
||||
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=";
|
||||
|
||||
protected PaginatedMenu(PlayerMenuUtility playerMenuUtility) {
|
||||
|
||||
super(playerMenuUtility);
|
||||
initMaterialsForBottomBar();
|
||||
|
||||
}
|
||||
|
||||
protected PaginatedMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
|
||||
|
||||
super(playerMenuUtility);
|
||||
initMaterialsForBottomBar();
|
||||
super.playerMenuUtility.setPlayerShopSearchResult(searchResult);
|
||||
|
||||
}
|
||||
|
||||
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(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);
|
||||
|
||||
}
|
||||
|
||||
private void createGUIBackButton() {
|
||||
|
||||
Material backButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_MATERIAL);
|
||||
if (backButtonMaterial == null) {
|
||||
|
||||
backButton = createPlayerHead(BACK_BUTTON_SKIN_ID);
|
||||
|
||||
} else {
|
||||
|
||||
backButton = new ItemStack(backButtonMaterial);
|
||||
|
||||
}
|
||||
|
||||
ItemMeta backButtonMeta = backButton.getItemMeta();
|
||||
assert backButtonMeta != null;
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_TEXT)) {
|
||||
|
||||
backButtonMeta.displayName(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_TEXT));
|
||||
|
||||
}
|
||||
|
||||
int backButtonCMD;
|
||||
try {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_CMD)) {
|
||||
|
||||
backButtonCMD = Integer.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_CMD);
|
||||
backButtonMeta.setCustomModelData(backButtonCMD);
|
||||
|
||||
}
|
||||
|
||||
} catch (NumberFormatException eror) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Back Button in config.yml");
|
||||
|
||||
}
|
||||
|
||||
backButton.setItemMeta(backButtonMeta);
|
||||
|
||||
}
|
||||
|
||||
private void createGUINextButton() {
|
||||
|
||||
Material nextButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_MATERIAL);
|
||||
if (nextButtonMaterial == null) {
|
||||
|
||||
nextButton = createPlayerHead(NEXT_BUTTON_SKIN_ID);
|
||||
|
||||
} else {
|
||||
|
||||
nextButton = new ItemStack(nextButtonMaterial);
|
||||
|
||||
}
|
||||
|
||||
ItemMeta nextButtonMeta = nextButton.getItemMeta();
|
||||
assert nextButtonMeta != null;
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_TEXT)) {
|
||||
|
||||
nextButtonMeta.displayName(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_TEXT));
|
||||
|
||||
}
|
||||
|
||||
int nextButtonCMD;
|
||||
try {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_CMD)) {
|
||||
|
||||
nextButtonCMD = Integer.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_CMD);
|
||||
nextButtonMeta.setCustomModelData(nextButtonCMD);
|
||||
|
||||
}
|
||||
|
||||
} catch (NumberFormatException error) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Next Button in config.yml");
|
||||
|
||||
}
|
||||
|
||||
nextButton.setItemMeta(nextButtonMeta);
|
||||
|
||||
}
|
||||
|
||||
private void createGUIFirstPageButton() {
|
||||
|
||||
Material firstPageButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.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(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_TEXT))
|
||||
firstPageButtonMeta.displayName(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_TEXT));
|
||||
int firstPageButtonCMD;
|
||||
try {
|
||||
|
||||
if (firstPageButtonMeta != null
|
||||
&& !StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_CMD))
|
||||
{
|
||||
|
||||
firstPageButtonCMD = Integer
|
||||
.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_CMD);
|
||||
firstPageButtonMeta.setCustomModelData(firstPageButtonCMD);
|
||||
|
||||
}
|
||||
|
||||
} catch (NumberFormatException error) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Goto First Page Button in config.yml");
|
||||
|
||||
}
|
||||
|
||||
firstPageButton.setItemMeta(firstPageButtonMeta);
|
||||
|
||||
}
|
||||
|
||||
private void createGUILastPageButton() {
|
||||
|
||||
Material lastPageButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.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(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_TEXT))
|
||||
lastPageButtonMeta.displayName(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_TEXT));
|
||||
int lastPageButtonCMD;
|
||||
try {
|
||||
|
||||
if (lastPageButtonMeta != null
|
||||
&& !StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_CMD))
|
||||
{
|
||||
|
||||
lastPageButtonCMD = Integer
|
||||
.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_CMD);
|
||||
lastPageButtonMeta.setCustomModelData(lastPageButtonCMD);
|
||||
|
||||
}
|
||||
|
||||
} catch (NumberFormatException error) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Goto Last Page Button in config.yml");
|
||||
|
||||
}
|
||||
|
||||
lastPageButton.setItemMeta(lastPageButtonMeta);
|
||||
|
||||
}
|
||||
|
||||
private void createGUICloseInvButton() {
|
||||
|
||||
Material closeInvButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_MATERIAL);
|
||||
if (closeInvButtonMaterial == null) {
|
||||
|
||||
closeInvButtonMaterial = Material.BARRIER;
|
||||
|
||||
}
|
||||
|
||||
closeInvButton = new ItemStack(closeInvButtonMaterial);
|
||||
ItemMeta closeInvMeta = closeInvButton.getItemMeta();
|
||||
assert closeInvMeta != null;
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_TEXT)) {
|
||||
|
||||
closeInvMeta.displayName(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_TEXT));
|
||||
|
||||
}
|
||||
|
||||
int closeInvButtonCMD;
|
||||
try {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_CMD)) {
|
||||
|
||||
closeInvButtonCMD = Integer.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_CMD);
|
||||
closeInvMeta.setCustomModelData(closeInvButtonCMD);
|
||||
|
||||
}
|
||||
|
||||
} catch (NumberFormatException error) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Close Button in config.yml");
|
||||
|
||||
}
|
||||
|
||||
closeInvButton.setItemMeta(closeInvMeta);
|
||||
|
||||
}
|
||||
|
||||
private ItemStack createPlayerHead(String value) {
|
||||
|
||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||
UUID hashAsId = new UUID(value.hashCode(), value.hashCode());
|
||||
return Bukkit.getUnsafe().modifyItemStack(skull,
|
||||
"{SkullOwner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + value + "\"}]}}}");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Handlers.GUIHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerMenuUtility {
|
||||
|
||||
private Player owner;
|
||||
|
||||
private List<FoundShopItemModel> playerShopSearchResult;
|
||||
|
||||
public List<FoundShopItemModel> getPlayerShopSearchResult() {
|
||||
|
||||
return playerShopSearchResult;
|
||||
|
||||
}
|
||||
|
||||
public void setPlayerShopSearchResult(List<FoundShopItemModel> playerShopSearchResult) {
|
||||
|
||||
this.playerShopSearchResult = playerShopSearchResult;
|
||||
|
||||
}
|
||||
|
||||
public PlayerMenuUtility(Player owner) {
|
||||
|
||||
this.owner = owner;
|
||||
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
|
||||
return owner;
|
||||
|
||||
}
|
||||
|
||||
public void setOwner(Player owner) {
|
||||
|
||||
this.owner = owner;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
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) {
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
if (e.getCurrentItem() == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Menu menu = (Menu) holder;
|
||||
menu.handleMenu(e);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Listeners;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerCommandSendEventListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommandTab(PlayerCommandSendEvent event) {
|
||||
|
||||
if (!event.getPlayer().isOp()) {
|
||||
|
||||
List<String> blockedCommands = new ArrayList<>();
|
||||
blockedCommands.add("find:find");
|
||||
assert FindItemAddOnOG.getConfigProvider().FIND_ITEM_COMMAND_ALIAS != null;
|
||||
for (String cmd : FindItemAddOnOG.getConfigProvider().FIND_ITEM_COMMAND_ALIAS) {
|
||||
|
||||
blockedCommands.add("find:" + cmd);
|
||||
|
||||
}
|
||||
|
||||
blockedCommands.add("finditemadmin:finditemadmin");
|
||||
blockedCommands.add("finditemadmin:fiadmin");
|
||||
blockedCommands.add("finditemadmin");
|
||||
blockedCommands.add("fiadmin");
|
||||
event.getCommands().removeAll(blockedCommands);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Listeners;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
public class PluginEnableEventListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
|
||||
if (!FindItemAddOnOG.isQSReremakeInstalled() && !FindItemAddOnOG.isQSHikariInstalled()) {
|
||||
|
||||
// if(!event.getPlugin().getName().equalsIgnoreCase("QuickShop")
|
||||
// && !event.getPlugin().getName().equalsIgnoreCase("QuickShop-Hikari")) {
|
||||
// // do nothing
|
||||
// }
|
||||
if (event.getPlugin().getName().equalsIgnoreCase("QuickShop") && !FindItemAddOnOG.isQSHikariInstalled()) {
|
||||
|
||||
FindItemAddOnOG.setQSReremakeInstalled(true);
|
||||
|
||||
} else if (event.getPlugin().getName().equalsIgnoreCase("QuickShop-Hikari")
|
||||
&& !FindItemAddOnOG.isQSReremakeInstalled())
|
||||
{
|
||||
|
||||
FindItemAddOnOG.setQSHikariInstalled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Models;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class EssentialWarpModel {
|
||||
|
||||
public String warpName;
|
||||
public Location warpLoc;
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Models;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Model for the Shop Item lore that will be shown in the search GUI
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class FoundShopItemModel {
|
||||
|
||||
private final double shopPrice;
|
||||
private final int remainingStockOrSpace;
|
||||
private final UUID shopOwner;
|
||||
private final Location shopLocation;
|
||||
private final ItemStack item;
|
||||
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Models;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class HiddenShopModel {
|
||||
|
||||
private String worldName;
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float pitch;
|
||||
private float yaw;
|
||||
private String shopOwnerUUID;
|
||||
|
||||
// public HiddenShopModel(String worldName, double x, double y, double z, float pitch, float yaw, String shopOwnerUUID) {
|
||||
// this.worldName = worldName;
|
||||
// this.x = x;
|
||||
// this.y = y;
|
||||
// this.z = z;
|
||||
// this.pitch = pitch;
|
||||
// this.yaw = yaw;
|
||||
// this.shopOwnerUUID = shopOwnerUUID;
|
||||
// }
|
||||
//
|
||||
// public String getWorldName() {
|
||||
// return worldName;
|
||||
// }
|
||||
//
|
||||
// public void setWorldName(String worldName) {
|
||||
// this.worldName = worldName;
|
||||
// }
|
||||
//
|
||||
// public double getX() {
|
||||
// return x;
|
||||
// }
|
||||
//
|
||||
// public void setX(double x) {
|
||||
// this.x = x;
|
||||
// }
|
||||
//
|
||||
// public double getY() {
|
||||
// return y;
|
||||
// }
|
||||
//
|
||||
// public void setY(double y) {
|
||||
// this.y = y;
|
||||
// }
|
||||
//
|
||||
// public double getZ() {
|
||||
// return z;
|
||||
// }
|
||||
//
|
||||
// public void setZ(double z) {
|
||||
// this.z = z;
|
||||
// }
|
||||
//
|
||||
// public float getPitch() {
|
||||
// return pitch;
|
||||
// }
|
||||
//
|
||||
// public void setPitch(float pitch) {
|
||||
// this.pitch = pitch;
|
||||
// }
|
||||
//
|
||||
// public float getYaw() {
|
||||
// return yaw;
|
||||
// }
|
||||
//
|
||||
// public void setYaw(float yaw) {
|
||||
// this.yaw = yaw;
|
||||
// }
|
||||
//
|
||||
// public String getShopOwnerUUID() {
|
||||
// return shopOwnerUUID;
|
||||
// }
|
||||
//
|
||||
// public void setShopOwnerUUID(String shopOwnerUUID) {
|
||||
// this.shopOwnerUUID = shopOwnerUUID;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Models;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PlayerShopVisitModel {
|
||||
|
||||
private String playerUUID;
|
||||
private String visitDateTime;
|
||||
|
||||
public void setPlayerUUID(UUID uuid) {
|
||||
|
||||
this.playerUUID = uuid.toString();
|
||||
|
||||
}
|
||||
|
||||
public UUID getPlayerUUID() {
|
||||
|
||||
return UUID.fromString(this.playerUUID);
|
||||
|
||||
}
|
||||
|
||||
public void setVisitDateTime() {
|
||||
|
||||
this.visitDateTime = Instant.now().toString();
|
||||
|
||||
}
|
||||
|
||||
public Instant getVisitDateTime() {
|
||||
|
||||
return Instant.parse(visitDateTime);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Models;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class ShopSearchActivityModel {
|
||||
|
||||
private String worldName;
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float pitch;
|
||||
private float yaw;
|
||||
private String shopOwnerUUID;
|
||||
private List<PlayerShopVisitModel> playerVisitList;
|
||||
private boolean isHiddenFromSearch;
|
||||
|
||||
public boolean compareWith(String targetWorldName, double targetX, double targetY, double targetZ,
|
||||
String targetShopOwnerUUID)
|
||||
{
|
||||
|
||||
return this.getWorldName().equalsIgnoreCase(targetWorldName) && this.getX() == targetX && this.getY() == targetY
|
||||
&& this.getZ() == targetZ && this.getShopOwnerUUID().equalsIgnoreCase(targetShopOwnerUUID);
|
||||
|
||||
}
|
||||
|
||||
public boolean compareWith(String targetWorldName, double targetX, double targetY, double targetZ) {
|
||||
|
||||
return this.getWorldName().equalsIgnoreCase(targetWorldName) && this.getX() == targetX && this.getY() == targetY
|
||||
&& this.getZ() == targetZ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.QuickShopHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface for QS API. Implement it depending on which API is being used
|
||||
* (Reremake/Hikari).
|
||||
*
|
||||
* @param <QSType>
|
||||
* @param <Shop>
|
||||
* @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
|
||||
* @param toBuy
|
||||
* @param searchingPlayer
|
||||
* @return
|
||||
*/
|
||||
List<FoundShopItemModel> findItemBasedOnTypeFromAllShops(ItemStack item, boolean toBuy, Player searchingPlayer);
|
||||
|
||||
/**
|
||||
* Search based on display name of item from all server shops
|
||||
*
|
||||
* @param displayName
|
||||
* @param toBuy
|
||||
* @param searchingPlayer
|
||||
* @return
|
||||
*/
|
||||
List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy,
|
||||
Player searchingPlayer);
|
||||
|
||||
/**
|
||||
* Fetch all items from all server shops
|
||||
*
|
||||
* @param toBuy
|
||||
* @param searchingPlayer
|
||||
* @return
|
||||
*/
|
||||
List<FoundShopItemModel> fetchAllItemsFromAllShops(boolean toBuy, Player searchingPlayer);
|
||||
|
||||
Material getShopSignMaterial();
|
||||
|
||||
Shop findShopAtLocation(Block block);
|
||||
|
||||
boolean isShopOwnerCommandRunner(Player player, Shop shop);
|
||||
|
||||
List<Shop> getAllShops();
|
||||
|
||||
List<ShopSearchActivityModel> syncShopsListForStorage(List<ShopSearchActivityModel> globalShopsList);
|
||||
|
||||
void registerSubCommand();
|
||||
|
||||
static List<FoundShopItemModel> sortShops(int sortingMethod, List<FoundShopItemModel> shopsFoundList,
|
||||
boolean toBuy)
|
||||
{
|
||||
|
||||
switch (sortingMethod) {
|
||||
|
||||
// Random
|
||||
case 1 -> Collections.shuffle(shopsFoundList);
|
||||
// Based on prices (lower to higher)
|
||||
case 2 -> shopsFoundList.sort(Comparator.comparing(FoundShopItemModel::getShopPrice));
|
||||
// Based on stocks (higher to lower)
|
||||
case 3 -> {
|
||||
|
||||
shopsFoundList.sort(Comparator.comparing(FoundShopItemModel::getRemainingStockOrSpace));
|
||||
Collections.reverse(shopsFoundList);
|
||||
|
||||
}
|
||||
default -> {
|
||||
|
||||
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
|
||||
LoggerUtils.logError("Defaulting to sorting by prices method");
|
||||
shopsFoundList.sort(Comparator.comparing(FoundShopItemModel::getShopPrice));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (FindItemAddOnOG.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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,452 +0,0 @@
|
||||
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 io.myzticbean.finditemaddon.Commands.QSSubCommands.FindItemCmdHikariImpl;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
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.JsonStorageUtils.HiddenShopStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
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.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Implementation of QSApi for Hikari
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class QSHikariAPIHandler implements QSApi<QuickShop, Shop> {
|
||||
|
||||
private final QuickShopAPI api;
|
||||
|
||||
private final ConcurrentMap<Long, CachedShop> shopCache;
|
||||
|
||||
private final int SHOP_CACHE_TIMEOUT_SECONDS = 60;
|
||||
|
||||
public QSHikariAPIHandler() {
|
||||
|
||||
api = QuickShopAPI.getInstance();
|
||||
LoggerUtils.logInfo("Initializing Shop caching");
|
||||
shopCache = new ConcurrentHashMap<>();
|
||||
|
||||
}
|
||||
|
||||
public List<FoundShopItemModel> findItemBasedOnTypeFromAllShops(ItemStack item, boolean toBuy,
|
||||
Player searchingPlayer)
|
||||
{
|
||||
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if (FindItemAddOnOG.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
|
||||
} else {
|
||||
|
||||
allShops = getAllShops();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo(QS_TOTAL_SHOPS_ON_SERVER + allShops.size());
|
||||
for (Shop shopIterator : allShops) {
|
||||
|
||||
// @TODO: Testing
|
||||
testQuickShopHikariExternalCache(shopIterator);
|
||||
LoggerUtils.logWarning("2: Location: " + shopIterator.getLocation() + "Stock: "
|
||||
+ shopIterator.getRemainingStock() + " | Space: " + shopIterator.getRemainingSpace());
|
||||
|
||||
// check for quickshop hikari internal per-shop based search permission
|
||||
if (shopIterator.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)
|
||||
// check for blacklisted worlds
|
||||
&& (!FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds()
|
||||
.contains(shopIterator.getLocation().getWorld())
|
||||
&& shopIterator.getItem().getType().equals(item.getType())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true) != 0 : getRemainingStockOrSpaceFromShopCache(shopIterator, false) != 0)
|
||||
&& (toBuy ? shopIterator.isSelling() : shopIterator.isBuying()))
|
||||
// check for shop if hidden
|
||||
&& (!HiddenShopStorageUtil.isShopHidden(shopIterator)))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shopIterator)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shopIterator.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shopIterator, false))),
|
||||
shopIterator.getOwner().getUniqueIdOptional().orElse(new UUID(0, 0)),
|
||||
shopIterator.getLocation(), shopIterator.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return handleShopSorting(toBuy, shopsFoundList);
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static List<FoundShopItemModel> handleShopSorting(boolean toBuy, List<FoundShopItemModel> shopsFoundList) {
|
||||
|
||||
if (!shopsFoundList.isEmpty()) {
|
||||
|
||||
int sortingMethod = 2;
|
||||
try {
|
||||
|
||||
sortingMethod = FindItemAddOnOG.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;
|
||||
|
||||
}
|
||||
|
||||
public List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy,
|
||||
Player searchingPlayer)
|
||||
{
|
||||
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if (FindItemAddOnOG.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
|
||||
} else {
|
||||
|
||||
allShops = getAllShops();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo(QS_TOTAL_SHOPS_ON_SERVER + allShops.size());
|
||||
for (Shop shopIterator : allShops) {
|
||||
|
||||
// check for quickshop hikari internal per-shop based search permission
|
||||
if (shopIterator.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)
|
||||
// check for blacklisted worlds
|
||||
&& !FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds()
|
||||
.contains(shopIterator.getLocation().getWorld())
|
||||
// match the item based on query
|
||||
&& shopIterator.getItem().hasItemMeta()
|
||||
&& Objects.requireNonNull(shopIterator.getItem().getItemMeta()).hasDisplayName() && (shopIterator
|
||||
.getItem().getItemMeta().getDisplayName().toLowerCase().contains(displayName.toLowerCase())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true) != 0 : getRemainingStockOrSpaceFromShopCache(shopIterator, false) != 0)
|
||||
&& (toBuy ? shopIterator.isSelling() : shopIterator.isBuying()))
|
||||
// check for shop if hidden
|
||||
&& !HiddenShopStorageUtil.isShopHidden(shopIterator))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shopIterator)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shopIterator.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shopIterator, false))),
|
||||
shopIterator.getOwner().getUniqueIdOptional().orElse(new UUID(0, 0)),
|
||||
shopIterator.getLocation(), shopIterator.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return handleShopSorting(toBuy, shopsFoundList);
|
||||
|
||||
}
|
||||
|
||||
public List<FoundShopItemModel> fetchAllItemsFromAllShops(boolean toBuy, Player searchingPlayer) {
|
||||
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if (FindItemAddOnOG.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
|
||||
} else {
|
||||
|
||||
allShops = getAllShops();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo(QS_TOTAL_SHOPS_ON_SERVER + allShops.size());
|
||||
for (Shop shopIterator : allShops) {
|
||||
|
||||
// check for quickshop hikari internal per-shop based search permission
|
||||
if (shopIterator.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)
|
||||
// check for blacklisted worlds
|
||||
&& (!FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds()
|
||||
.contains(shopIterator.getLocation().getWorld())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true) != 0 : getRemainingStockOrSpaceFromShopCache(shopIterator, false) != 0)
|
||||
&& (toBuy ? shopIterator.isSelling() : shopIterator.isBuying()))
|
||||
// check for shop if hidden
|
||||
&& (!HiddenShopStorageUtil.isShopHidden(shopIterator)))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shopIterator)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shopIterator.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shopIterator, false))),
|
||||
shopIterator.getOwner().getUniqueIdOptional().orElse(new UUID(0, 0)),
|
||||
shopIterator.getLocation(), shopIterator.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!shopsFoundList.isEmpty()) {
|
||||
|
||||
int sortingMethod = 1;
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
|
||||
|
||||
}
|
||||
|
||||
return shopsFoundList;
|
||||
|
||||
}
|
||||
|
||||
public Material getShopSignMaterial() {
|
||||
|
||||
return com.ghostchu.quickshop.util.Util.getSignMaterial();
|
||||
|
||||
}
|
||||
|
||||
public Shop findShopAtLocation(Block block) {
|
||||
|
||||
Location loc = new Location(block.getWorld(), block.getX(), block.getY(), block.getZ());
|
||||
return api.getShopManager().getShop(loc);
|
||||
|
||||
}
|
||||
|
||||
public boolean isShopOwnerCommandRunner(Player player, Shop shop) {
|
||||
|
||||
return shop.getOwner().toString().equalsIgnoreCase(player.getUniqueId().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Shop> getAllShops() {
|
||||
|
||||
return api.getShopManager().getAllShops();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopSearchActivityModel> syncShopsListForStorage(List<ShopSearchActivityModel> globalShopsList) {
|
||||
|
||||
// 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()) {
|
||||
|
||||
Location shopLoc = shop_i.getLocation();
|
||||
tempGlobalShopsList.add(new ShopSearchActivityModel(shopLoc.getWorld().getName(), shopLoc.getX(),
|
||||
shopLoc.getY(), shopLoc.getZ(), shopLoc.getPitch(), shopLoc.getYaw(), shop_i.getOwner().toString(),
|
||||
new ArrayList<>(), false));
|
||||
|
||||
}
|
||||
|
||||
for (ShopSearchActivityModel shop_temp : tempGlobalShopsList) {
|
||||
|
||||
ShopSearchActivityModel tempShopToRemove = null;
|
||||
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()
|
||||
&& shop_temp.getShopOwnerUUID().equalsIgnoreCase(shop_global.getShopOwnerUUID()))
|
||||
{
|
||||
|
||||
shop_temp.setPlayerVisitList(shop_global.getPlayerVisitList());
|
||||
shop_temp.setHiddenFromSearch(shop_global.isHiddenFromSearch());
|
||||
tempShopToRemove = shop_global;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (tempShopToRemove != null)
|
||||
globalShopsList.remove(tempShopToRemove);
|
||||
|
||||
}
|
||||
|
||||
return tempGlobalShopsList;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register find sub-command for /qs Unregister /qs find
|
||||
*/
|
||||
@Override
|
||||
public void registerSubCommand() {
|
||||
|
||||
LoggerUtils.logInfo("Unregistered find sub-command for /qs");
|
||||
for (CommandContainer cmdContainer : api.getCommandManager().getRegisteredCommands()) {
|
||||
|
||||
if (cmdContainer.getPrefix().equalsIgnoreCase("find")) {
|
||||
|
||||
api.getCommandManager().unregisterCmd(cmdContainer);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Registered find 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("find")
|
||||
.permission(PlayerPerms.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));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = FindItemAddOnOG.getConfigProvider().IGNORE_EMPTY_CHESTS;
|
||||
if (ignoreEmptyChests) {
|
||||
|
||||
if (toBuy) {
|
||||
|
||||
return getRemainingStockOrSpaceFromShopCache(shop, true) == 0;
|
||||
|
||||
} else
|
||||
return getRemainingStockOrSpaceFromShopCache(shop, false) == 0;
|
||||
|
||||
}
|
||||
|
||||
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 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());
|
||||
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,473 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.QuickShopHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.Commands.QSSubCommands.FindItemCmdReremakeImpl;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
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.JsonStorageUtils.HiddenShopStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
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.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.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Implementation of QSApi for Reremake
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
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)
|
||||
{
|
||||
|
||||
long begin = System.currentTimeMillis();
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if (FindItemAddOnOG.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) {
|
||||
|
||||
// check for blacklisted worlds
|
||||
if (!FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
|
||||
&& shop_i.getItem().getType().equals(item.getType())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) != 0 : getRemainingStockOrSpaceFromShopCache(shop_i, false) != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying()))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shop_i)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// if(checkIfShopToBeIgnoredIfAdminShop(shop_i))
|
||||
// continue;
|
||||
// check for shop if hidden
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shop_i.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shop_i, false))),
|
||||
shop_i.getOwner(), shop_i.getLocation(), shop_i.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<FoundShopItemModel> sortedShops = handleShopSorting(toBuy, shopsFoundList);
|
||||
long end = System.currentTimeMillis();
|
||||
logTimeTookMsg((end - begin));
|
||||
return sortedShops;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy,
|
||||
Player searchingPlayer)
|
||||
{
|
||||
|
||||
long begin = System.currentTimeMillis();
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if (FindItemAddOnOG.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) {
|
||||
|
||||
if (!FindItemAddOnOG.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 ? getRemainingStockOrSpaceFromShopCache(shop_i, true) != 0 : getRemainingStockOrSpaceFromShopCache(shop_i, false) != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying()))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shop_i))
|
||||
continue;
|
||||
// if(checkIfShopToBeIgnoredIfAdminShop(shop_i))
|
||||
// continue;
|
||||
// check for shop if hidden
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shop_i.getPrice(),
|
||||
QSApi.processStockOrSpace(
|
||||
(toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shop_i, false))),
|
||||
shop_i.getOwner(), shop_i.getLocation(), shop_i.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<FoundShopItemModel> sortedShops = handleShopSorting(toBuy, shopsFoundList);
|
||||
long end = System.currentTimeMillis();
|
||||
logTimeTookMsg((end - begin));
|
||||
return sortedShops;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FoundShopItemModel> fetchAllItemsFromAllShops(boolean toBuy, Player searchingPlayer) {
|
||||
|
||||
long begin = System.currentTimeMillis();
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if (FindItemAddOnOG.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) {
|
||||
|
||||
// check for blacklisted worlds
|
||||
if (!FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) != 0 : getRemainingStockOrSpaceFromShopCache(shop_i, false) != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying()))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shop_i))
|
||||
continue;
|
||||
// if(checkIfShopToBeIgnoredIfAdminShop(shop_i))
|
||||
// continue;
|
||||
// check for shop if hidden
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shop_i.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shop_i, false))),
|
||||
shop_i.getOwner(), shop_i.getLocation(), shop_i.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!shopsFoundList.isEmpty()) {
|
||||
|
||||
int sortingMethod = 1;
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
|
||||
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
logTimeTookMsg((end - begin));
|
||||
return shopsFoundList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getShopSignMaterial() {
|
||||
|
||||
return org.maxgamer.quickshop.util.Util.getSignMaterial();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Shop findShopAtLocation(Block block) {
|
||||
|
||||
Location loc = new Location(block.getWorld(), block.getX(), block.getY(), block.getZ());
|
||||
return api.getShopManager().getShop(loc);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShopOwnerCommandRunner(Player player, Shop shop) {
|
||||
|
||||
return shop.getOwner().toString().equalsIgnoreCase(player.getUniqueId().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Shop> getAllShops() {
|
||||
|
||||
return api.getShopManager().getAllShops();
|
||||
|
||||
}
|
||||
|
||||
public List<ShopSearchActivityModel> syncShopsListForStorage(List<ShopSearchActivityModel> globalShopsList) {
|
||||
|
||||
// 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()) {
|
||||
|
||||
Location shopLoc = shop_i.getLocation();
|
||||
tempGlobalShopsList.add(new ShopSearchActivityModel(shopLoc.getWorld().getName(), shopLoc.getX(),
|
||||
shopLoc.getY(), shopLoc.getZ(), shopLoc.getPitch(), shopLoc.getYaw(), shop_i.getOwner().toString(),
|
||||
new ArrayList<>(), false));
|
||||
|
||||
}
|
||||
|
||||
for (ShopSearchActivityModel shop_temp : tempGlobalShopsList) {
|
||||
|
||||
ShopSearchActivityModel tempShopToRemove = null;
|
||||
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()
|
||||
&& shop_temp.getShopOwnerUUID().equalsIgnoreCase(shop_global.getShopOwnerUUID()))
|
||||
{
|
||||
|
||||
shop_temp.setPlayerVisitList(shop_global.getPlayerVisitList());
|
||||
shop_temp.setHiddenFromSearch(shop_global.isHiddenFromSearch());
|
||||
tempShopToRemove = shop_global;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (tempShopToRemove != null)
|
||||
globalShopsList.remove(tempShopToRemove);
|
||||
|
||||
}
|
||||
|
||||
return tempGlobalShopsList;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register find sub-command for /qs
|
||||
*/
|
||||
@Override
|
||||
public void registerSubCommand() {
|
||||
|
||||
LoggerUtils.logInfo("Unregistered find sub-command for /qs");
|
||||
for (CommandContainer cmdContainer : api.getCommandManager().getRegisteredCommands()) {
|
||||
|
||||
if (cmdContainer.getPrefix().equalsIgnoreCase("find")) {
|
||||
|
||||
api.getCommandManager().unregisterCmd(cmdContainer);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Registered find sub-command for /qs");
|
||||
api.getCommandManager()
|
||||
.registerCmd(CommandContainer.builder().prefix("find").permission(PlayerPerms.FINDITEM_USE.value())
|
||||
.hidden(false).description("Search for items from all shops using an interactive GUI")
|
||||
.executor(new FindItemCmdReremakeImpl()).build());
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static List<FoundShopItemModel> handleShopSorting(boolean toBuy, List<FoundShopItemModel> shopsFoundList) {
|
||||
|
||||
if (!shopsFoundList.isEmpty()) {
|
||||
|
||||
int sortingMethod = 2;
|
||||
try {
|
||||
|
||||
sortingMethod = FindItemAddOnOG.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 = FindItemAddOnOG.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) {
|
||||
|
||||
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.logError("No shop found from QS cache for location: " + shop.getLocation());
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logInfo("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) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Shop Location: " + shop.getLocation());
|
||||
|
||||
return quickShop.getShopCache().find(shop.getLocation(), false);
|
||||
|
||||
/*
|
||||
* CachedShop cachedShop = shopCache.get(shop.getLocation()); if (cachedShop ==
|
||||
* null || QSApi.isTimeDifferenceGreaterThanSeconds(cachedShop.getLastFetched(),
|
||||
* new Date(), SHOP_CACHE_TIMEOUT_SECONDS)) { cachedShop = CachedShop.builder()
|
||||
* .shopLocation(shop.getLocation()) .remainingStock(shop.getRemainingStock())
|
||||
* .remainingSpace(shop.getRemainingSpace()) .lastFetched(new Date()) .build();
|
||||
* shopCache.put(cachedShop.getShopLocation(), cachedShop);
|
||||
* LoggerUtils.logDebugInfo("Adding to ShopCache: " + shop.getLocation()); }
|
||||
* return (fetchRemainingStock ? cachedShop.getRemainingStock() :
|
||||
* cachedShop.getRemainingSpace());
|
||||
*/
|
||||
}
|
||||
|
||||
private void logTimeTookMsg(long timeTook) {
|
||||
|
||||
LoggerUtils.logInfo("Shop search took: " + timeTook + " milliseconds");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.ScheduledTasks;
|
||||
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.WarpUtils;
|
||||
|
||||
public class Task15MinInterval implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
WarpUtils.updateWarps();
|
||||
// HiddenShopStorageUtil.saveHiddenShopsToFile();
|
||||
ShopSearchActivityStorageUtil.syncShops();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class CommonUtils {
|
||||
|
||||
public static void sendPlayerActionBar(Player player, String msg) {
|
||||
|
||||
if (player == null || msg == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Component component = UtilitiesOG.trueogColorize(msg);
|
||||
player.sendActionBar(component);
|
||||
|
||||
}
|
||||
|
||||
public static String capitalizeFirstLetters(String str) {
|
||||
|
||||
final char[] array = str.toCharArray();
|
||||
|
||||
// Uppercase first letter.
|
||||
array[0] = Character.toUpperCase(array[0]);
|
||||
|
||||
// Uppercase all letters that follow a whitespace character.
|
||||
for (int i = 1; i < array.length; i++) {
|
||||
|
||||
if (Character.isWhitespace(array[i - 1])) {
|
||||
|
||||
array[i] = Character.toUpperCase(array[i]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new String(array);
|
||||
|
||||
}
|
||||
|
||||
public static Double calculateDistance2D(double x1, double y1, double x2, double y2) {
|
||||
|
||||
return Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
|
||||
|
||||
}
|
||||
|
||||
public static Double calculateDistance3D(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
|
||||
return Math.pow((Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2)), 0.5);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils.Defaults;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* List of all the permissions used by the addon
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public enum PlayerPerms {
|
||||
|
||||
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;
|
||||
|
||||
PlayerPerms(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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils.Defaults;
|
||||
|
||||
/**
|
||||
* List of all the placeholds used in the Shop lore in GUI
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public enum ShopLorePlaceholders {
|
||||
|
||||
ITEM_PRICE("{ITEM_PRICE}"), SHOP_STOCK("{SHOP_STOCK}"), SHOP_OWNER("{SHOP_OWNER}"), SHOP_LOCATION("{SHOP_LOC}"),
|
||||
SHOP_WORLD("{SHOP_WORLD}"), NEAREST_WARP("{NEAREST_WARP}"), SHOP_VISITS("{SHOP_VISITS}");
|
||||
|
||||
private final String placeholder;
|
||||
|
||||
ShopLorePlaceholders(String placeholder) {
|
||||
|
||||
this.placeholder = placeholder;
|
||||
|
||||
}
|
||||
|
||||
public String value() {
|
||||
|
||||
return placeholder;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-295
@@ -1,295 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils.JsonStorageUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.HiddenShopModel;
|
||||
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.maxgamer.quickshop.api.shop.Shop;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class HiddenShopStorageUtil {
|
||||
|
||||
protected static List<HiddenShopModel> hiddenShopsList = new ArrayList<>();
|
||||
protected static final String HIDDEN_SHOP_STORAGE_JSON_FILE_NAME = "hiddenShops.json";
|
||||
|
||||
/**
|
||||
* QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
public static void handleShopSearchVisibilityAsync(Shop shop, boolean hideShop) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
Iterator<ShopSearchActivityModel> shopSearchActivityIterator = ShopSearchActivityStorageUtil
|
||||
.getGlobalShopsList().iterator();
|
||||
int i = 0;
|
||||
while (shopSearchActivityIterator.hasNext()) {
|
||||
|
||||
ShopSearchActivityModel shopSearchActivity = shopSearchActivityIterator.next();
|
||||
Location shopLocation = shop.getLocation();
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
ShopSearchActivityStorageUtil.getGlobalShopsList().get(i).setHiddenFromSearch(hideShop);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// HiddenShopModel hiddenShop = new HiddenShopModel(
|
||||
// shop.getLocation().getWorld().getName(),
|
||||
// shop.getLocation().getX(),
|
||||
// shop.getLocation().getY(),
|
||||
// shop.getLocation().getZ(),
|
||||
// shop.getLocation().getPitch(),
|
||||
// shop.getLocation().getYaw(),
|
||||
// shop.getOwner().toString());
|
||||
// hiddenShopsList.add(hiddenShop);
|
||||
}
|
||||
|
||||
/**
|
||||
* QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
public static void handleShopSearchVisibilityAsync(com.ghostchu.quickshop.api.shop.Shop shop, boolean hideShop) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
Iterator<ShopSearchActivityModel> shopSearchActivityIterator = ShopSearchActivityStorageUtil
|
||||
.getGlobalShopsList().iterator();
|
||||
int i = 0;
|
||||
while (shopSearchActivityIterator.hasNext()) {
|
||||
|
||||
ShopSearchActivityModel shopSearchActivity = shopSearchActivityIterator.next();
|
||||
Location shopLocation = shop.getLocation();
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
ShopSearchActivityStorageUtil.getGlobalShopsList().get(i).setHiddenFromSearch(hideShop);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// HiddenShopModel hiddenShop = new HiddenShopModel(
|
||||
// shop.getLocation().getWorld().getName(),
|
||||
// shop.getLocation().getX(),
|
||||
// shop.getLocation().getY(),
|
||||
// shop.getLocation().getZ(),
|
||||
// shop.getLocation().getPitch(),
|
||||
// shop.getLocation().getYaw(),
|
||||
// shop.getOwner().toString());
|
||||
// hiddenShopsList.add(hiddenShop);
|
||||
}
|
||||
|
||||
/**
|
||||
* QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
// public static void deleteShop(Shop shop) {
|
||||
// for(HiddenShopModel hiddenShop : hiddenShopsList) {
|
||||
// if(hiddenShop.getWorldName().equalsIgnoreCase(shop.getLocation().getWorld().getName())
|
||||
// && hiddenShop.getX() == shop.getLocation().getX()
|
||||
// && hiddenShop.getY() == shop.getLocation().getY()
|
||||
// && hiddenShop.getZ() == shop.getLocation().getZ()
|
||||
// && hiddenShop.getPitch() == shop.getLocation().getPitch()
|
||||
// && hiddenShop.getYaw() == shop.getLocation().getYaw()
|
||||
// && Objects.equals(hiddenShop.getShopOwnerUUID(), shop.getOwner().toString())) {
|
||||
// hiddenShopsList.remove(hiddenShop);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
// public static void deleteShop(com.ghostchu.quickshop.api.shop.Shop shop) {
|
||||
// for(HiddenShopModel hiddenShop : hiddenShopsList) {
|
||||
// if(hiddenShop.getWorldName().equalsIgnoreCase(shop.getLocation().getWorld().getName())
|
||||
// && hiddenShop.getX() == shop.getLocation().getX()
|
||||
// && hiddenShop.getY() == shop.getLocation().getY()
|
||||
// && hiddenShop.getZ() == shop.getLocation().getZ()
|
||||
// && hiddenShop.getPitch() == shop.getLocation().getPitch()
|
||||
// && hiddenShop.getYaw() == shop.getLocation().getYaw()
|
||||
// && Objects.equals(hiddenShop.getShopOwnerUUID(), shop.getOwner().toString())) {
|
||||
// hiddenShopsList.remove(hiddenShop);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
* @return
|
||||
*/
|
||||
public static boolean isShopHidden(Shop shop) {
|
||||
|
||||
for (ShopSearchActivityModel shopSearchActivity : ShopSearchActivityStorageUtil.getGlobalShopsList()) {
|
||||
|
||||
Location shopLocation = shop.getLocation();
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
if (shopSearchActivity.isHiddenFromSearch()) {
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
// for(HiddenShopModel hiddenShop : hiddenShopsList) {
|
||||
// if(hiddenShop.getWorldName().equalsIgnoreCase(shop.getLocation().getWorld().getName())
|
||||
// && hiddenShop.getX() == shop.getLocation().getX()
|
||||
// && hiddenShop.getY() == shop.getLocation().getY()
|
||||
// && hiddenShop.getZ() == shop.getLocation().getZ()
|
||||
// && hiddenShop.getPitch() == shop.getLocation().getPitch()
|
||||
// && hiddenShop.getYaw() == shop.getLocation().getYaw()
|
||||
// && Objects.equals(hiddenShop.getShopOwnerUUID(), shop.getOwner().toString())) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
* @return
|
||||
*/
|
||||
public static boolean isShopHidden(com.ghostchu.quickshop.api.shop.Shop shop) {
|
||||
|
||||
for (ShopSearchActivityModel shopSearchActivity : ShopSearchActivityStorageUtil.getGlobalShopsList()) {
|
||||
|
||||
Location shopLocation = shop.getLocation();
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
if (shopSearchActivity.isHiddenFromSearch()) {
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
// for(HiddenShopModel hiddenShop : hiddenShopsList) {
|
||||
// if(hiddenShop.getWorldName().equalsIgnoreCase(shop.getLocation().getWorld().getName())
|
||||
// && hiddenShop.getX() == shop.getLocation().getX()
|
||||
// && hiddenShop.getY() == shop.getLocation().getY()
|
||||
// && hiddenShop.getZ() == shop.getLocation().getZ()
|
||||
// && hiddenShop.getPitch() == shop.getLocation().getPitch()
|
||||
// && hiddenShop.getYaw() == shop.getLocation().getYaw()
|
||||
// && Objects.equals(hiddenShop.getShopOwnerUUID(), shop.getOwner().toString())) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
|
||||
public static void loadHiddenShopsFromFile() {
|
||||
|
||||
Gson gson = new Gson();
|
||||
File file = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
|
||||
if (file.exists()) {
|
||||
|
||||
try {
|
||||
|
||||
Reader reader = new FileReader(file);
|
||||
// Type listType = new TypeToken<List<HiddenShopModel>>() {}.getType();
|
||||
HiddenShopModel[] h = gson.fromJson(reader, HiddenShopModel[].class);
|
||||
if (h != null) {
|
||||
|
||||
hiddenShopsList = new ArrayList<>(Arrays.asList(h));
|
||||
|
||||
} else {
|
||||
|
||||
hiddenShopsList = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Loaded hidden shops from file");
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void saveHiddenShopsToFile() {
|
||||
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
File file = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
|
||||
file.getParentFile().mkdir();
|
||||
try {
|
||||
|
||||
file.createNewFile();
|
||||
Writer writer = new FileWriter(file, false);
|
||||
gson.toJson(hiddenShopsList, writer);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
LoggerUtils.logInfo("Saved hidden shops to file");
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-412
@@ -1,412 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils.JsonStorageUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.HiddenShopModel;
|
||||
import io.myzticbean.finditemaddon.Models.PlayerShopVisitModel;
|
||||
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
public class ShopSearchActivityStorageUtil {
|
||||
|
||||
private static final String SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME = "shops.json";
|
||||
// private static final String COOLDOWNS_YAML_FILE_NAME = "cooldowns.yml";
|
||||
|
||||
@Getter
|
||||
private static final Map<String, Long> cooldowns = Collections.unmodifiableMap(new HashMap<>());
|
||||
|
||||
// private static File cooldownsYaml;
|
||||
// private static FileConfiguration cooldownsConfig;
|
||||
|
||||
@Getter
|
||||
private static List<ShopSearchActivityModel> globalShopsList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Returns true if cooldown is not present
|
||||
*
|
||||
* @param player
|
||||
* @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) {
|
||||
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
final List<PlayerShopVisitModel> playerShopVisitList = shopSearchActivity.getPlayerVisitList().stream()
|
||||
.filter(p -> p.getPlayerUUID().equals(player.getUniqueId()))
|
||||
.sorted(Comparator.comparing(PlayerShopVisitModel::getVisitDateTime))
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
final boolean isCooldownTimeElapsed;
|
||||
if (playerShopVisitList.size() > 0) {
|
||||
|
||||
isCooldownTimeElapsed = Instant.now()
|
||||
.minusSeconds(
|
||||
FindItemAddOnOG.getConfigProvider().SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES * 60)
|
||||
.isAfter(playerShopVisitList.get(playerShopVisitList.size() - 1).getVisitDateTime());
|
||||
|
||||
} else {
|
||||
|
||||
isCooldownTimeElapsed = true;
|
||||
|
||||
}
|
||||
|
||||
if (isCooldownTimeElapsed) {
|
||||
|
||||
LoggerUtils.logDebugInfo(("&6" + player.getName() + " is out of cooldown"));
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo(("&6" + player.getName() + " still has cooldown"));
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo(("&6Shop not found, returning false for cooldown check"));
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static void syncShops() {
|
||||
|
||||
globalShopsList = FindItemAddOnOG.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
|
||||
*/
|
||||
public void addShop(org.maxgamer.quickshop.api.shop.Shop shop) {
|
||||
|
||||
for (ShopSearchActivityModel shop_i : globalShopsList) {
|
||||
|
||||
if (shop_i.getX() == shop.getLocation().getX() && shop_i.getY() == shop.getLocation().getY()
|
||||
&& shop_i.getZ() == shop.getLocation().getZ()
|
||||
&& shop_i.getWorldName().equalsIgnoreCase(shop.getLocation().getWorld().getName()))
|
||||
{
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final ShopSearchActivityModel shopModel = new ShopSearchActivityModel(shop.getLocation().getWorld().getName(),
|
||||
shop.getLocation().getX(), shop.getLocation().getY(), shop.getLocation().getZ(),
|
||||
shop.getLocation().getPitch(), shop.getLocation().getYaw(), shop.getOwner().toString(),
|
||||
new ArrayList<>(), false);
|
||||
globalShopsList.add(shopModel);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
public void addShop(com.ghostchu.quickshop.api.shop.Shop shop) {
|
||||
|
||||
final ShopSearchActivityModel shopModel = new ShopSearchActivityModel(shop.getLocation().getWorld().getName(),
|
||||
shop.getLocation().getX(), shop.getLocation().getY(), shop.getLocation().getZ(),
|
||||
shop.getLocation().getPitch(), shop.getLocation().getYaw(), shop.getOwner().toString(),
|
||||
new ArrayList<>(), false);
|
||||
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() {
|
||||
|
||||
final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
final File file = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
if (file.exists()) {
|
||||
|
||||
try {
|
||||
|
||||
final Reader reader = new FileReader(file);
|
||||
final ShopSearchActivityModel[] h = gson.fromJson(reader, ShopSearchActivityModel[].class);
|
||||
if (h != null) {
|
||||
|
||||
globalShopsList = new ArrayList<>(Arrays.asList(h));
|
||||
|
||||
} else {
|
||||
|
||||
globalShopsList = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Loaded shops from file");
|
||||
|
||||
} catch (FileNotFoundException error) {
|
||||
|
||||
error.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 = FindItemAddOnOG.getQsApiInstance().syncShopsListForStorage(globalShopsList);
|
||||
|
||||
}
|
||||
|
||||
public static void saveShopsToFile() {
|
||||
|
||||
final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
final File file = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
file.getParentFile().mkdir();
|
||||
try {
|
||||
|
||||
file.createNewFile();
|
||||
final Writer writer = new FileWriter(file, false);
|
||||
gson.toJson(globalShopsList, writer);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
LoggerUtils.logInfo("Saved shops to file");
|
||||
|
||||
} catch (IOException error) {
|
||||
|
||||
error.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 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() {
|
||||
|
||||
final File hiddenShopsJsonfile = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ HiddenShopStorageUtil.HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
|
||||
if (hiddenShopsJsonfile.exists()) {
|
||||
|
||||
HiddenShopStorageUtil.loadHiddenShopsFromFile();
|
||||
if (HiddenShopStorageUtil.hiddenShopsList.size() > 0) {
|
||||
|
||||
for (int globalShopsList_i = 0; globalShopsList_i < globalShopsList.size(); globalShopsList_i++) {
|
||||
|
||||
final ShopSearchActivityModel shopSearchActivity = globalShopsList.get(globalShopsList_i);
|
||||
HiddenShopModel tempHiddenShop = null;
|
||||
for (HiddenShopModel hiddenShop_i : HiddenShopStorageUtil.hiddenShopsList) {
|
||||
|
||||
if (shopSearchActivity.compareWith(hiddenShop_i.getWorldName(), hiddenShop_i.getX(),
|
||||
hiddenShop_i.getY(), hiddenShop_i.getZ(), hiddenShop_i.getShopOwnerUUID()))
|
||||
{
|
||||
|
||||
tempHiddenShop = hiddenShop_i;
|
||||
shopSearchActivity.setHiddenFromSearch(true);
|
||||
globalShopsList.set(globalShopsList_i, shopSearchActivity);
|
||||
LoggerUtils.logDebugInfo("Converted shop: " + shopSearchActivity);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HiddenShopStorageUtil.hiddenShopsList.remove(tempHiddenShop);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo("Here we will delete the hiddenShops.json");
|
||||
hiddenShopsJsonfile.delete();
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo("hiddenshops.json: No conversion required");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void addPlayerVisitEntryAsync(Location shopLocation, Player visitingPlayer) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
if (handleCooldownIfPresent(shopLocation, visitingPlayer)) {
|
||||
|
||||
final Iterator<ShopSearchActivityModel> shopSearchActivityIterator = globalShopsList.iterator();
|
||||
int i = 0;
|
||||
while (shopSearchActivityIterator.hasNext()) {
|
||||
|
||||
final ShopSearchActivityModel shopSearchActivity = shopSearchActivityIterator.next();
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
final 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;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static int getPlayerVisitCount(Location shopLocation) {
|
||||
|
||||
return globalShopsList.stream()
|
||||
.filter(shopSearchActivity -> shopSearchActivity.compareWith(shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(), shopLocation.getY(), shopLocation.getZ()))
|
||||
.findFirst().map(shopSearchActivity -> shopSearchActivity.getPlayerVisitList().size()).orElse(0);
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static OfflinePlayer getShopOwner(@NotNull Location shopLocation) {
|
||||
|
||||
return globalShopsList.stream()
|
||||
.filter(shopSearchActivity -> shopSearchActivity.compareWith(shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(), shopLocation.getY(), shopLocation.getZ()))
|
||||
.findFirst().map(shopSearchActivity -> Bukkit
|
||||
.getOfflinePlayer(UUID.fromString(shopSearchActivity.getShopOwnerUUID())))
|
||||
.orElse(null);
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static UUID getShopOwnerUUID(@NotNull Location shopLocation) {
|
||||
|
||||
return globalShopsList.stream()
|
||||
.filter(shopSearchActivity -> shopSearchActivity.compareWith(shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(), shopLocation.getY(), shopLocation.getZ()))
|
||||
.findFirst().map(shopSearchActivity -> UUID.fromString(shopSearchActivity.getShopOwnerUUID()))
|
||||
.orElse(null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,261 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
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;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class LocationUtils {
|
||||
|
||||
private static final List<Material> damagingBlocks = new ArrayList<>();
|
||||
private static final List<Material> nonSuffocatingBlocks = new ArrayList<>();
|
||||
private static final int BELOW_SAFE_BLOCK_CHECK_LIMIT = 20;
|
||||
|
||||
static {
|
||||
|
||||
// Initializing Damaging blocks
|
||||
damagingBlocks.add(Material.LAVA);
|
||||
damagingBlocks.add(Material.CACTUS);
|
||||
damagingBlocks.add(Material.CAMPFIRE);
|
||||
damagingBlocks.add(Material.SOUL_CAMPFIRE);
|
||||
damagingBlocks.add(Material.MAGMA_BLOCK);
|
||||
damagingBlocks.add(Material.FIRE);
|
||||
damagingBlocks.add(Material.SOUL_FIRE);
|
||||
damagingBlocks.add(Material.SWEET_BERRY_BUSH);
|
||||
damagingBlocks.add(Material.WITHER_ROSE);
|
||||
damagingBlocks.add(Material.END_PORTAL);
|
||||
|
||||
// Initializing Non Suffocating blocks
|
||||
nonSuffocatingBlocks.add(Material.AIR);
|
||||
// Glass
|
||||
nonSuffocatingBlocks.add(Material.GLASS);
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("_glass")).toList()));
|
||||
// Glass Panes
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("glass_pane")).toList()));
|
||||
// Leaves
|
||||
nonSuffocatingBlocks.add(Material.ACACIA_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.BIRCH_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.DARK_OAK_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.JUNGLE_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.OAK_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.SPRUCE_LEAVES);
|
||||
if (Bukkit.getServer().getVersion().contains("1.17")) {
|
||||
|
||||
nonSuffocatingBlocks.add(Material.AZALEA_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.FLOWERING_AZALEA_LEAVES);
|
||||
|
||||
}
|
||||
|
||||
// Slabs
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("_slab")).toList()));
|
||||
// Walled Signs
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("_sign")).toList()));
|
||||
// Stairs
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("_stairs")).toList()));
|
||||
// MISC
|
||||
nonSuffocatingBlocks.add(Material.HONEY_BLOCK);
|
||||
nonSuffocatingBlocks.add(Material.BELL);
|
||||
nonSuffocatingBlocks.add(Material.CHEST);
|
||||
nonSuffocatingBlocks.add(Material.TRAPPED_CHEST);
|
||||
nonSuffocatingBlocks.add(Material.HOPPER);
|
||||
nonSuffocatingBlocks.add(Material.COMPOSTER);
|
||||
nonSuffocatingBlocks.add(Material.GRINDSTONE);
|
||||
nonSuffocatingBlocks.add(Material.STONECUTTER);
|
||||
nonSuffocatingBlocks.add(Material.IRON_BARS);
|
||||
nonSuffocatingBlocks.add(Material.END_PORTAL_FRAME);
|
||||
nonSuffocatingBlocks.add(Material.PISTON_HEAD);
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Location findSafeLocationAroundShop(Location shopLocation) {
|
||||
|
||||
Location roundedShopLoc = getRoundedDestination(shopLocation);
|
||||
QSApi qsApi;
|
||||
if (FindItemAddOnOG.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<>();
|
||||
possibleSafeLocList.add(new Location(roundedShopLoc.getWorld(), roundedShopLoc.getX() + 1,
|
||||
roundedShopLoc.getY(), roundedShopLoc.getZ()));
|
||||
possibleSafeLocList.add(new Location(roundedShopLoc.getWorld(), roundedShopLoc.getX() - 1,
|
||||
roundedShopLoc.getY(), roundedShopLoc.getZ()));
|
||||
possibleSafeLocList.add(new Location(roundedShopLoc.getWorld(), roundedShopLoc.getX(), roundedShopLoc.getY(),
|
||||
roundedShopLoc.getZ() + 1));
|
||||
possibleSafeLocList.add(new Location(roundedShopLoc.getWorld(), roundedShopLoc.getX(), roundedShopLoc.getY(),
|
||||
roundedShopLoc.getZ() - 1));
|
||||
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())) {
|
||||
|
||||
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(loc_i.getWorld(), loc_i.getBlockX(), loc_i.getBlockY() + 1,
|
||||
loc_i.getBlockZ());
|
||||
LoggerUtils.logDebugInfo("Block above shop sign: " + blockAbove.getX() + ", " + blockAbove.getY() + ", "
|
||||
+ blockAbove.getZ());
|
||||
if (!isBlockSuffocating(blockAbove)) {
|
||||
|
||||
Location blockBelow = null;
|
||||
boolean safeLocFound = false;
|
||||
for (int i = 1; i <= BELOW_SAFE_BLOCK_CHECK_LIMIT; i++) {
|
||||
|
||||
blockBelow = new Location(loc_i.getWorld(), loc_i.getBlockX(), loc_i.getBlockY() - i,
|
||||
loc_i.getBlockZ());
|
||||
LoggerUtils.logDebugInfo("Block below shop sign: " + blockBelow.getBlock().getType() + " "
|
||||
+ blockBelow.getX() + ", " + blockBelow.getY() + ", " + blockBelow.getZ());
|
||||
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()))
|
||||
{
|
||||
|
||||
// do nothing and let the loop run
|
||||
LoggerUtils.logDebugInfo("Shop or Air found below");
|
||||
|
||||
} else if (!isBlockDamaging(blockBelow)) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Safe block found!");
|
||||
safeLocFound = true;
|
||||
break;
|
||||
|
||||
} else {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (safeLocFound) {
|
||||
|
||||
loc_i = lookAt(getRoundedDestination(new Location(blockBelow.getWorld(), blockBelow.getX(),
|
||||
blockBelow.getY() + 1, blockBelow.getZ())), roundedShopLoc);
|
||||
return loc_i;
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo(
|
||||
"Block above shop sign found not air. Block type: " + blockAbove.getBlock().getType());
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo("Block not shop sign. Block type: " + loc_i.getBlock().getType());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo("No safe block found near shop");
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
// Found the below function from this thread:
|
||||
// https://bukkit.org/threads/lookat-and-move-functions.26768/
|
||||
private static Location lookAt(Location loc, Location lookat) {
|
||||
|
||||
// Clone the loc to prevent applied changes to the input loc
|
||||
loc = loc.clone();
|
||||
|
||||
// Values of change in distance (make it relative)
|
||||
double dx = lookat.getX() - loc.getX();
|
||||
double dy = lookat.getY() - loc.getY();
|
||||
double dz = lookat.getZ() - loc.getZ();
|
||||
|
||||
// Set yaw
|
||||
if (dx != 0) {
|
||||
|
||||
// Set yaw start value based on dx
|
||||
if (dx < 0) {
|
||||
|
||||
loc.setYaw((float) (1.5 * Math.PI));
|
||||
|
||||
} else {
|
||||
|
||||
loc.setYaw((float) (0.5 * Math.PI));
|
||||
|
||||
}
|
||||
|
||||
loc.setYaw((float) loc.getYaw() - (float) Math.atan(dz / dx));
|
||||
|
||||
} else if (dz < 0) {
|
||||
|
||||
loc.setYaw((float) Math.PI);
|
||||
|
||||
}
|
||||
|
||||
// Get the distance from dx/dz
|
||||
double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));
|
||||
|
||||
// Set pitch
|
||||
loc.setPitch((float) -Math.atan(dy / dxz));
|
||||
|
||||
// Set values, convert to degrees (invert the yaw since Bukkit uses a different
|
||||
// yaw dimension format)
|
||||
loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI);
|
||||
loc.setPitch(loc.getPitch() * 180f / (float) Math.PI);
|
||||
|
||||
return loc;
|
||||
|
||||
}
|
||||
|
||||
private static boolean isBlockDamaging(Location loc) {
|
||||
|
||||
return damagingBlocks.contains(loc.getBlock().getType());
|
||||
|
||||
}
|
||||
|
||||
private static boolean isBlockSuffocating(Location loc) {
|
||||
|
||||
return !nonSuffocatingBlocks.contains(loc.getBlock().getType());
|
||||
|
||||
}
|
||||
|
||||
private static Location getRoundedDestination(final Location loc) {
|
||||
|
||||
World world = loc.getWorld();
|
||||
int x = loc.getBlockX();
|
||||
int y = (int) Math.round(loc.getY());
|
||||
int z = loc.getBlockZ();
|
||||
return new Location(world, (double) x + 0.5D, (double) y, (double) z + 0.5D, loc.getYaw(), loc.getPitch());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class LoggerUtils {
|
||||
|
||||
public static void logDebugInfo(String text) {
|
||||
|
||||
if (FindItemAddOnOG.getConfigProvider().DEBUG_MODE) {
|
||||
|
||||
UtilitiesOG.logToConsole("[QSFindItemAddOn-OG] Debug:", text);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void logInfo(String text) {
|
||||
|
||||
UtilitiesOG.logToConsole("[QSFindItemAddOn-OG] Info:", text);
|
||||
|
||||
}
|
||||
|
||||
public static void logError(String text) {
|
||||
|
||||
UtilitiesOG.logToConsole("[QSFindItemAddOn-OG] Error:", text);
|
||||
|
||||
}
|
||||
|
||||
public static void logWarning(String text) {
|
||||
|
||||
UtilitiesOG.logToConsole("[QSFindItemAddOn-OG] Warning:", text);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils.WarpUtils;
|
||||
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.Models.EssentialWarpModel;
|
||||
import io.myzticbean.finditemaddon.Utils.CommonUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class EssentialWarpsUtil {
|
||||
|
||||
@Nullable
|
||||
public String findNearestWarp(Location shopLocation) {
|
||||
|
||||
List<EssentialWarpModel> allWarps = EssentialsXPlugin.getAllWarps();
|
||||
if (allWarps != null && !allWarps.isEmpty()) {
|
||||
|
||||
Map<Double, String> warpDistanceMap = new TreeMap<>();
|
||||
allWarps.forEach(warp -> {
|
||||
|
||||
Double distance = CommonUtils.calculateDistance3D(shopLocation.getX(), shopLocation.getY(),
|
||||
shopLocation.getZ(), warp.warpLoc.getX(), warp.warpLoc.getY(), warp.warpLoc.getZ());
|
||||
warpDistanceMap.put(distance, warp.warpName);
|
||||
|
||||
});
|
||||
/*
|
||||
* 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 {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils.WarpUtils;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import io.myzticbean.finditemaddon.Dependencies.WGPlugin;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class WGRegionUtils {
|
||||
|
||||
@Nullable
|
||||
public String findNearestWGRegion(Location shopLocation) {
|
||||
|
||||
ApplicableRegionSet set = WGPlugin.getWgInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.getApplicableRegions(BukkitAdapter.adapt(shopLocation));
|
||||
|
||||
Set<ProtectedRegion> regions = set.getRegions();
|
||||
if (!regions.isEmpty()) {
|
||||
|
||||
Iterator<ProtectedRegion> regionIterator = regions.iterator();
|
||||
Map<Integer, ProtectedRegion> regionPriorityMap = new TreeMap<>(Collections.reverseOrder());
|
||||
while (regionIterator.hasNext()) {
|
||||
|
||||
ProtectedRegion region_i = regionIterator.next();
|
||||
regionPriorityMap.put(region_i.getPriority(), region_i);
|
||||
|
||||
}
|
||||
|
||||
return regionPriorityMap.entrySet().iterator().next().getValue().getId();
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils.WarpUtils;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
|
||||
public class WarpUtils {
|
||||
|
||||
public static void updateWarps() {
|
||||
|
||||
final boolean condition = FindItemAddOnOG.getConfigProvider().shopGUIItemLoreHasKey("{NEAREST_WARP}")
|
||||
&& FindItemAddOnOG.getConfigProvider().NEAREST_WARP_MODE == 1 && EssentialsXPlugin.isEnabled();
|
||||
if (condition) {
|
||||
|
||||
EssentialsXPlugin.updateAllWarps();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.commands.quickshop.subcommands;
|
||||
|
||||
import com.ghostchu.quickshop.api.command.CommandHandler;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.handlers.command.CmdExecutorHandler;
|
||||
import io.myzticbean.finditemaddon.models.enums.PlayerPermsEnum;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class FindItemCmdHikariImpl implements CommandHandler<Player> {
|
||||
|
||||
private final String hideSubCommand;
|
||||
private final String revealShopSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final List<String> buyOrSellList = new ArrayList<>();
|
||||
|
||||
public FindItemCmdHikariImpl() {
|
||||
if (FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_REMOVE_HIDE_REVEAL_SUBCMDS) {
|
||||
// I don't know what to do here ¯\_(ツ)_/¯
|
||||
}
|
||||
if (StringUtils.isBlank(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
this.hideSubCommand = "hideshop";
|
||||
} else {
|
||||
this.hideSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(
|
||||
FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " ")) {
|
||||
this.revealShopSubCommand = "revealshop";
|
||||
} else {
|
||||
this.revealShopSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
}
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles player commands within a Bukkit plugin, including permission checks
|
||||
* and subcommand execution.
|
||||
*/
|
||||
@Override
|
||||
public void onCommand(Player commandSender, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 0) {
|
||||
commandSender.sendMessage(ColorTranslator
|
||||
.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
} else if (args.length == 1) {
|
||||
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)) {
|
||||
cmdExecutor.handleRevealShop(commandSender);
|
||||
} else {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
}
|
||||
} else {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cYou don't have permission to use that!"));
|
||||
}
|
||||
} else {
|
||||
cmdExecutor.handleShopSearch(args[0], commandSender, args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel,
|
||||
@NotNull String[] args) {
|
||||
if (itemsList.isEmpty()) {
|
||||
for (Material mat : Material.values()) {
|
||||
itemsList.add(mat.name());
|
||||
}
|
||||
}
|
||||
if (buyOrSellList.isEmpty()) {
|
||||
// to-buy
|
||||
if (StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE,
|
||||
" ")) {
|
||||
buyOrSellList.add("TO_BUY");
|
||||
} else {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
}
|
||||
// to-sell
|
||||
if (StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE,
|
||||
" ")) {
|
||||
buyOrSellList.add("TO_SELL");
|
||||
} else {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
|
||||
}
|
||||
// hide
|
||||
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);
|
||||
}
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
for (String a : buyOrSellList) {
|
||||
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
result.add(a);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else if (args.length == 2) {
|
||||
for (String a : itemsList) {
|
||||
if (a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
result.add(a);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.commands.quickshop.subcommands;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.handlers.command.CmdExecutorHandler;
|
||||
import io.myzticbean.finditemaddon.models.enums.PlayerPermsEnum;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.api.command.CommandHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class FindItemCmdReremakeImpl implements CommandHandler<Player> {
|
||||
|
||||
private final String hideSubCommand;
|
||||
private final String revealShopSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final List<String> buyOrSellList = new ArrayList<>();
|
||||
|
||||
public FindItemCmdReremakeImpl() {
|
||||
if(StringUtils.isBlank(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
this.hideSubCommand = "hideshop";
|
||||
}
|
||||
else {
|
||||
this.hideSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
}
|
||||
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(
|
||||
FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " ")) {
|
||||
this.revealShopSubCommand = "revealshop";
|
||||
}
|
||||
else {
|
||||
this.revealShopSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
}
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Player commandSender, @NotNull String label, @NotNull String[] args) {
|
||||
if(args.length == 0) {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
}
|
||||
else if(args.length == 1) {
|
||||
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)) {
|
||||
cmdExecutor.handleRevealShop(commandSender);
|
||||
} else {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
}
|
||||
} else {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cYou don't have permission to use that!"));
|
||||
}
|
||||
} else {
|
||||
cmdExecutor.handleShopSearch(args[0], commandSender, args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
if(itemsList.isEmpty()) {
|
||||
for(Material mat : Material.values()) {
|
||||
itemsList.add(mat.name());
|
||||
}
|
||||
}
|
||||
if(buyOrSellList.isEmpty()) {
|
||||
// to-buy
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " ")) {
|
||||
buyOrSellList.add("TO_BUY");
|
||||
}
|
||||
else {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
}
|
||||
// to-sell
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " ")) {
|
||||
buyOrSellList.add("TO_SELL");
|
||||
}
|
||||
else {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
|
||||
}
|
||||
// hide
|
||||
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);
|
||||
}
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
if(args.length == 1) {
|
||||
for(String a : buyOrSellList) {
|
||||
if(a.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
result.add(a);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else if(args.length == 2) {
|
||||
for(String a : itemsList) {
|
||||
if(a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
result.add(a);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.commands.simpapi;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.handlers.command.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditem TO_BUY
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class BuySubCmd extends SubCommand {
|
||||
|
||||
private final String buySubCommand;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public BuySubCmd() {
|
||||
// to-buy
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " ")) {
|
||||
buySubCommand = "TO_BUY";
|
||||
}
|
||||
else {
|
||||
buySubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE;
|
||||
}
|
||||
if(itemsList.isEmpty()) {
|
||||
itemsList.addAll(Arrays.stream(Material.values())
|
||||
.filter(mat -> !FindItemAddOn.getConfigProvider().getBlacklistedMaterials().contains(mat))
|
||||
.map(Material::name)
|
||||
.toList());
|
||||
}
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return buySubCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Find shops that buy a specific item";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditem " + buySubCommand + " {item type | item name}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
if(args.length != 2)
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INCORRECT_USAGE_MSG));
|
||||
else
|
||||
cmdExecutor.handleShopSearch(buySubCommand, commandSender, args[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] args) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for(String a : itemsList) {
|
||||
if(a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
result.add(a);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.commands.simpapi;
|
||||
|
||||
import io.myzticbean.finditemaddon.handlers.command.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditemadmin debug-mode
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class DebugSubCmd extends SubCommand {
|
||||
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public DebugSubCmd() {
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "debug-mode";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Enables / disables debug mode";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditemadmin debug-mode {enable | disable}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
cmdExecutor.handleDebugMode(commandSender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] strings) {
|
||||
return List.of("enable", "disable");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.commands.simpapi;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.handlers.command.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditem hideshop
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class HideShopSubCmd extends SubCommand {
|
||||
|
||||
private final String hideSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public HideShopSubCmd() {
|
||||
if(StringUtils.isBlank(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
hideSubCommand = "hideshop";
|
||||
}
|
||||
else {
|
||||
hideSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
}
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return hideSubCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Run this command while looking at the shop (NOT the shop sign) you wish to hide and it will no" +
|
||||
" longer appear in searches";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditem " + hideSubCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
cmdExecutor.handleHideShop(commandSender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] strings) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.commands.simpapi;
|
||||
|
||||
import io.myzticbean.finditemaddon.handlers.command.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditemadmin reload
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class ReloadSubCmd extends SubCommand {
|
||||
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public ReloadSubCmd() {
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Reloads config.yml";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditemadmin reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] strings) {
|
||||
cmdExecutor.handlePluginReload(commandSender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] strings) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.commands.simpapi;
|
||||
|
||||
import io.myzticbean.finditemaddon.handlers.command.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditem restart
|
||||
* @deprecated No longer used, will be removed in future versions
|
||||
* @author myzticbean
|
||||
*/
|
||||
@Deprecated
|
||||
public class RestartSubCmd extends SubCommand {
|
||||
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public RestartSubCmd() {
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "restart";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Restarts the plugin (NOT recommended in most cases, restart server if necessary)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditemadmin restart";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
cmdExecutor.handlePluginRestart(commandSender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] strings) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.commands.simpapi;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.handlers.command.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditemadmin revealshop
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class RevealShopSubCmd extends SubCommand {
|
||||
|
||||
private final String revealShopSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public RevealShopSubCmd() {
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(
|
||||
FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " ")) {
|
||||
revealShopSubCommand = "revealshop";
|
||||
}
|
||||
else {
|
||||
revealShopSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
}
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return revealShopSubCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Run this command while looking at a hidden shop to make it public again";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditem " + revealShopSubCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
cmdExecutor.handleRevealShop(commandSender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] strings) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.commands.simpapi;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.handlers.command.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditem TO_SELL
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class SellSubCmd extends SubCommand {
|
||||
|
||||
private final String sellSubCommand;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public SellSubCmd() {
|
||||
// to-sell
|
||||
if(StringUtils.isBlank(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)) {
|
||||
sellSubCommand = "TO_SELL";
|
||||
}
|
||||
else {
|
||||
sellSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE;
|
||||
}
|
||||
if(itemsList.isEmpty()) {
|
||||
itemsList.addAll(Arrays.stream(Material.values())
|
||||
.filter(mat -> !FindItemAddOn.getConfigProvider().getBlacklistedMaterials().contains(mat))
|
||||
.map(Material::name)
|
||||
.toList());
|
||||
}
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return sellSubCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Find shops that sell a specific item";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditem " + sellSubCommand + " {item type | item name}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
if(args.length != 2)
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INCORRECT_USAGE_MSG));
|
||||
else
|
||||
cmdExecutor.handleShopSearch(sellSubCommand, commandSender, args[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] args) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for(String a : itemsList) {
|
||||
if(a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
result.add(a);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.config;
|
||||
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
@SuppressWarnings("java:S116")
|
||||
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 CUSTOM_COMMANDS = "custom-commands.";
|
||||
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.";
|
||||
private static final String BENTOBOX = "bentobox.";
|
||||
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 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 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 boolean ONLY_SHOW_PLAYER_OWNDED_WARPS = ConfigSetup.get().getBoolean(PLAYER_SHOP_TELEPORTATION + NEAREST_WARP_TP_MODE + "only-show-player-owned-warps");
|
||||
public final boolean USE_RESIDENCE_SUBZONES = ConfigSetup.get().getBoolean(PLAYER_SHOP_TELEPORTATION + NEAREST_WARP_TP_MODE + "use-residence-subzones");
|
||||
public final String NO_WARP_NEAR_SHOP_ERROR_MSG = ConfigSetup.get().getString(PLAYER_SHOP_TELEPORTATION + NEAREST_WARP_TP_MODE + "no-warp-near-shop-error-message");
|
||||
public final String NO_WG_REGION_NEAR_SHOP_ERROR_MSG = ConfigSetup.get().getString(PLAYER_SHOP_TELEPORTATION + NEAREST_WARP_TP_MODE + "no-wg-region-near-shop-error-message");
|
||||
public final String NO_RESIDENCE_NEAR_SHOP_ERROR_MSG = ConfigSetup.get().getString(PLAYER_SHOP_TELEPORTATION + NEAREST_WARP_TP_MODE + "no-residence-near-shop-error-message");
|
||||
public final boolean CUSTOM_CMDS_RUN_ENABLED = ConfigSetup.get().getBoolean(PLAYER_SHOP_TELEPORTATION + CUSTOM_COMMANDS + "run-custom-commands");
|
||||
public final List<String> CUSTOM_CMDS_LIST = (List<String>) ConfigSetup.get().getList(PLAYER_SHOP_TELEPORTATION + CUSTOM_COMMANDS + "commands-list");
|
||||
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_GUI_FILLER_ITEM_CMD = ConfigSetup.get().getString(SHOP_GUI + SHOP_GUI_CMD + "filler-item-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");
|
||||
private final List<String> BLACKLISTED_WORLDS = (List<String>) ConfigSetup.get().getList("blacklisted-worlds");
|
||||
private final List<String> BLACKLISTED_MATERIALS = (List<String>) ConfigSetup.get().getList("blacklisted-materials");
|
||||
public final boolean SUPPRESS_UPDATE_NOTIFICATIONS = ConfigSetup.get().getBoolean("suppress-update-notifications");
|
||||
public final int CONFIG_VERSION = ConfigSetup.get().getInt("config-version");
|
||||
public final boolean BENTOBOX_IGNORE_LOCKED_ISLAND_SHOPS = ConfigSetup.get().getBoolean(BENTOBOX + "ignore-locked-island-shops");
|
||||
|
||||
private boolean debugMode = ConfigSetup.get().getBoolean("debug-mode");
|
||||
private final List<World> blacklistedWorldsList = new ArrayList<>();
|
||||
private final List<Material> blacklistedMaterialsList = new ArrayList<>();
|
||||
|
||||
public ConfigProvider() {
|
||||
loadBlacklistedWorlds();
|
||||
loadBlacklistedMaterials();
|
||||
Logger.logInfo("Config loaded!");
|
||||
}
|
||||
|
||||
public boolean isDebugModeEnabled() {
|
||||
return debugMode;
|
||||
}
|
||||
|
||||
public void setDebugMode(boolean debugMode) {
|
||||
this.debugMode = debugMode;
|
||||
// Also update the config file
|
||||
ConfigSetup.get().set("debug-mode", debugMode);
|
||||
ConfigSetup.get().set("config-version", ConfigSetup.getCURRENT_CONFIG_VERSION());
|
||||
ConfigSetup.saveConfig();
|
||||
}
|
||||
|
||||
public List<World> getBlacklistedWorlds() {
|
||||
return blacklistedWorldsList;
|
||||
}
|
||||
|
||||
public List<Material> getBlacklistedMaterials() {
|
||||
return blacklistedMaterialsList;
|
||||
}
|
||||
|
||||
public boolean shopGUIItemLoreHasKey(String key) {
|
||||
if (SHOP_GUI_ITEM_LORE != null) {
|
||||
return SHOP_GUI_ITEM_LORE.stream().anyMatch(key::contains);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBlacklistedWorlds() {
|
||||
if(BLACKLISTED_WORLDS != null) {
|
||||
BLACKLISTED_WORLDS.forEach(world -> {
|
||||
World worldObj = Bukkit.getWorld(world);
|
||||
if(worldObj != null) {
|
||||
blacklistedWorldsList.add(worldObj);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBlacklistedMaterials() {
|
||||
if(BLACKLISTED_MATERIALS != null) {
|
||||
BLACKLISTED_MATERIALS.forEach(material -> {
|
||||
var materialObj = Material.getMaterial(material);
|
||||
if(materialObj != null) {
|
||||
blacklistedMaterialsList.add(materialObj);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.config;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
@UtilityClass
|
||||
public class ConfigSetup {
|
||||
|
||||
private static File configFile;
|
||||
private static File sampleConfigFile;
|
||||
private static FileConfiguration configFileConfiguration;
|
||||
@Getter
|
||||
private static final int CURRENT_CONFIG_VERSION = 21;
|
||||
|
||||
public static void setupConfig() {
|
||||
configFile = new File(FindItemAddOn.getInstance().getDataFolder(), "config.yml");
|
||||
|
||||
if(!configFile.exists()) {
|
||||
try {
|
||||
boolean isConfigGenerated = configFile.createNewFile();
|
||||
if(isConfigGenerated) {
|
||||
Logger.logInfo("Generated a new config.yml");
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
Logger.logError("Error generating config.yml");
|
||||
}
|
||||
}
|
||||
|
||||
configFileConfiguration = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
public static void saveConfig() {
|
||||
try {
|
||||
configFileConfiguration.save(configFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
Logger.logError("Error saving config.yml");
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkForMissingProperties() {
|
||||
if(!configFileConfiguration.contains("search-loaded-shops-only", true)) {
|
||||
configFileConfiguration.set("search-loaded-shops-only", false);
|
||||
}
|
||||
if(!configFileConfiguration.contains("nearest-warp-mode", true)) {
|
||||
configFileConfiguration.set("nearest-warp-mode", 1);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
int nearestWarpMode = configFileConfiguration.getInt("nearest-warp-mode");
|
||||
if(nearestWarpMode != 1 && nearestWarpMode != 2 && nearestWarpMode != 3 && nearestWarpMode != 4) {
|
||||
Logger.logError("Invalid value for 'nearest-warp-mode' in config.yml!");
|
||||
Logger.logError("Resetting by default to &e1");
|
||||
configFileConfiguration.set("nearest-warp-mode", 1);
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
Logger.logError("Invalid value for 'nearest-warp-mode' in config.yml!");
|
||||
Logger.logError("Resetting by default to &e1");
|
||||
configFileConfiguration.set("nearest-warp-mode", 1);
|
||||
}
|
||||
}
|
||||
if(!configFileConfiguration.contains("shop-gui-item-lore", true)) {
|
||||
List<String> shopGUIItemLore = new ArrayList<>();
|
||||
shopGUIItemLore.add("");
|
||||
shopGUIItemLore.add("&fPrice: &a${ITEM_PRICE}");
|
||||
shopGUIItemLore.add("&fStock: &7{SHOP_STOCK}");
|
||||
shopGUIItemLore.add("&fOwner: &7{SHOP_OWNER}");
|
||||
shopGUIItemLore.add("&fLocation: &7{SHOP_LOC}");
|
||||
shopGUIItemLore.add("&fWorld: &7{SHOP_WORLD}");
|
||||
shopGUIItemLore.add("&fWarp: &7{NEAREST_WARP}");
|
||||
shopGUIItemLore.add("");
|
||||
configFileConfiguration.set("shop-gui-item-lore", shopGUIItemLore);
|
||||
}
|
||||
if(!configFileConfiguration.contains("blacklisted-worlds", true)) {
|
||||
List<String> blacklistedWorlds = new ArrayList<>();
|
||||
blacklistedWorlds.add("world_number_1");
|
||||
blacklistedWorlds.add("world_number_2");
|
||||
configFileConfiguration.set("blacklisted-worlds", blacklistedWorlds);
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.hideshop-autocomplete", true)) {
|
||||
configFileConfiguration.set("find-item-command.hideshop-autocomplete", "hideshop");
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.revealshop-autocomplete", true)) {
|
||||
configFileConfiguration.set("find-item-command.revealshop-autocomplete", "revealshop");
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.shop-hide-success-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.shop-hide-success-message", "&aShop is now hidden from search list!");
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.shop-reveal-success-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.shop-reveal-success-message", "&aShop is no longer hidden from search list!");
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.shop-already-hidden-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.shop-already-hidden-message", "&cThis shop is already hidden!");
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.shop-already-public-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.shop-already-public-message", "&cThis shop is already public!");
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.invalid-shop-block-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.invalid-shop-block-message", "&cThe block you are looking at is not a shop!");
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.hiding-shop-owner-invalid-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.hiding-shop-owner-invalid-message", "&cThat shop is not yours!");
|
||||
}
|
||||
|
||||
// ALWAYS AT LAST
|
||||
if(!configFileConfiguration.contains("config-version", true)) {
|
||||
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");
|
||||
String clickToTeleportMsg = configFileConfiguration.getString("click-to-teleport-message");
|
||||
String shopTPNoPermMsg = configFileConfiguration.getString("shop-tp-no-permission-message");
|
||||
String unsafeShopAreaMsg = configFileConfiguration.getString("unsafe-shop-area-message");
|
||||
// clear existing config properties
|
||||
configFileConfiguration.set("allow-direct-shop-tp", null);
|
||||
configFileConfiguration.set("click-to-teleport-message", null);
|
||||
configFileConfiguration.set("shop-tp-no-permission-message", null);
|
||||
configFileConfiguration.set("unsafe-shop-area-message", null);
|
||||
// set the new properties
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.tp-player-directly-to-shop", allowDirectShopTp);
|
||||
if(clickToTeleportMsg == null || clickToTeleportMsg.isEmpty())
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message", "&6&lClick to teleport to the shop!");
|
||||
else
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message", clickToTeleportMsg);
|
||||
|
||||
if(shopTPNoPermMsg == null || shopTPNoPermMsg.isEmpty())
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message", "&cYou don't have permission to teleport to shop!");
|
||||
else
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message", shopTPNoPermMsg);
|
||||
|
||||
if(unsafeShopAreaMsg == null || unsafeShopAreaMsg.isEmpty())
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message", "&cThe area around the shop is unsafe!");
|
||||
else
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message", unsafeShopAreaMsg);
|
||||
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp", false);
|
||||
}
|
||||
// Config v11
|
||||
if(configFileConfiguration.getInt("config-version") < 11) {
|
||||
List<String> cmdAliases = new ArrayList<>();
|
||||
cmdAliases.add("searchshop");
|
||||
cmdAliases.add("shopsearch");
|
||||
cmdAliases.add("searchitem");
|
||||
configFileConfiguration.set("find-item-command.command-alias", cmdAliases);
|
||||
|
||||
boolean warpState = configFileConfiguration.getBoolean("player-shop-teleportation.nearest-warp-tp-mode.warp-player-to-nearest-warp");
|
||||
if(warpState)
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp", true);
|
||||
// if warpState is false, don't bother updating tPState
|
||||
|
||||
// remove an erroneous field added in previous version
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.warp-player-to-nearest-warp", null);
|
||||
|
||||
// Update GUI next/previous button to blank if set to default value for the new player-head icons
|
||||
if(configFileConfiguration.getString("shop-gui-back-button-material").equalsIgnoreCase("RED_CONCRETE")) {
|
||||
configFileConfiguration.set("shop-gui-back-button-material", "");
|
||||
}
|
||||
if(configFileConfiguration.getString("shop-gui-next-button-material").equalsIgnoreCase("GREEN_CONCRETE")) {
|
||||
configFileConfiguration.set("shop-gui-next-button-material", "");
|
||||
}
|
||||
|
||||
// Add option to configure player visit cooldown
|
||||
configFileConfiguration.set("shop-player-visit-cooldown-in-minutes", 5);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
// Config 16
|
||||
if(configFileConfiguration.getInt("config-version") < 16) {
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.only-show-player-owned-warps", true);
|
||||
}
|
||||
// Config 17
|
||||
if(configFileConfiguration.getInt("config-version") < 17) {
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.use-residence-subzones", false);
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.no-warp-near-shop-error-message", "&cNo warp near this shop");
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.no-wg-region-near-shop-error-message", "&cNo WG Region near this shop");
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.no-residence-near-shop-error-message", "&cNo residence Region near this shop");
|
||||
}
|
||||
// Config 18
|
||||
if(configFileConfiguration.getInt("config-version") < 18) {
|
||||
configFileConfiguration.set("player-shop-teleportation.custom-commands.run-custom-commands", false);
|
||||
List<String> commands = Arrays.asList("tp {PLAYER_NAME} {SHOP_LOC_X} {SHOP_LOC_Y} {SHOP_LOC_Z}", "bal add 10000 {PLAYER_NAME}");
|
||||
configFileConfiguration.set("player-shop-teleportation.custom-commands.commands-list", commands);
|
||||
}
|
||||
|
||||
// Config 19
|
||||
if(configFileConfiguration.getInt("config-version") < 19) {
|
||||
configFileConfiguration.set("blacklisted-materials", populateSampleBlacklistedMaterials());
|
||||
configFileConfiguration.set("suppress-update-notifications", false);
|
||||
}
|
||||
|
||||
// Config 20
|
||||
if(configFileConfiguration.getInt("config-version") < 20) {
|
||||
configFileConfiguration.set("bentobox.ignore-locked-island-shops", true);
|
||||
}
|
||||
|
||||
// Config 21
|
||||
if(configFileConfiguration.getInt("config-version") < 21) {
|
||||
configFileConfiguration.set("shop-gui.custom-model-data.filler-item-custom-model-data", "");
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
private static @NotNull List<String> populateSampleBlacklistedMaterials() {
|
||||
List<String> blacklistedMaterials = new ArrayList<>();
|
||||
blacklistedMaterials.add("BARRIER");
|
||||
blacklistedMaterials.add("STRUCTURE_BLOCK");
|
||||
blacklistedMaterials.add("COMMAND_BLOCK");
|
||||
blacklistedMaterials.add("CHAIN_COMMAND_BLOCK");
|
||||
blacklistedMaterials.add("REPEATING_COMMAND_BLOCK");
|
||||
blacklistedMaterials.add("COMMAND_BLOCK_MINECART");
|
||||
blacklistedMaterials.add("JIGSAW");
|
||||
blacklistedMaterials.add("DEBUG_STICK");
|
||||
blacklistedMaterials.add("LIGHT");
|
||||
blacklistedMaterials.add("STRUCTURE_VOID");
|
||||
return blacklistedMaterials;
|
||||
}
|
||||
|
||||
public static FileConfiguration get() {
|
||||
return configFileConfiguration;
|
||||
}
|
||||
|
||||
public static void reloadConfig() {
|
||||
configFileConfiguration = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Added in 2.0
|
||||
*/
|
||||
public static void copySampleConfig() {
|
||||
FindItemAddOn.getInstance().saveResource("sample-config.yml", true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package io.myzticbean.finditemaddon.dependencies;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
public class BentoBoxPlugin {
|
||||
|
||||
private boolean isBentoBoxEnabled = false;
|
||||
|
||||
public BentoBoxPlugin() {
|
||||
checkBentoBoxPlugin();
|
||||
}
|
||||
|
||||
private void checkBentoBoxPlugin() {
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("BentoBox");
|
||||
isBentoBoxEnabled = plugin != null && plugin.isEnabled();
|
||||
}
|
||||
|
||||
public boolean isIslandLocked(Location loc, Player searchingPlayer) {
|
||||
if (!isBentoBoxEnabled) {
|
||||
return false;
|
||||
}
|
||||
User bentoboxUser = User.getInstance(searchingPlayer);
|
||||
return BentoBox.getInstance()
|
||||
.getIslands()
|
||||
.getIslandAt(loc)
|
||||
.filter(island -> !island.isAllowed(bentoboxUser, Flags.LOCK))
|
||||
.isPresent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.dependencies;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import io.myzticbean.finditemaddon.models.EssentialWarpModel;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Hook for EssentialsX Plugin
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
@UtilityClass
|
||||
public class EssentialsXPlugin {
|
||||
|
||||
private static Essentials essAPI = null;
|
||||
private static List<EssentialWarpModel> allWarpsList = null;
|
||||
|
||||
public static void setup() {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
|
||||
essAPI = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
|
||||
if (essAPI != null) {
|
||||
Logger.logInfo("Found Essentials");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return essAPI != null;
|
||||
}
|
||||
|
||||
public static Essentials getAPI() {
|
||||
return essAPI;
|
||||
}
|
||||
|
||||
public static List<EssentialWarpModel> getAllWarps() {
|
||||
return allWarpsList;
|
||||
}
|
||||
|
||||
public static void updateAllWarps() {
|
||||
if (!essAPI.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
Collection<String> allWarps = EssentialsXPlugin.getAPI().getWarps().getList();
|
||||
allWarpsList = new ArrayList<>();
|
||||
|
||||
for (String warp : allWarps) {
|
||||
addWarpToList(warp);
|
||||
}
|
||||
|
||||
logUpdateCompletion(start);
|
||||
}
|
||||
|
||||
private static void addWarpToList(String warp) {
|
||||
try {
|
||||
EssentialWarpModel essWarp = new EssentialWarpModel();
|
||||
essWarp.warpName = warp;
|
||||
essWarp.warpLoc = essAPI.getWarps().getWarp(warp);
|
||||
allWarpsList.add(essWarp);
|
||||
} catch (Exception ignored) {
|
||||
Logger.logError("Error adding warp to list: " + warp);
|
||||
}
|
||||
}
|
||||
|
||||
private static void logUpdateCompletion(long startTime) {
|
||||
long duration = System.currentTimeMillis() - startTime;
|
||||
Logger.logDebugInfo(String.format("Update complete for Essentials warps list! Found %d warps. Time took: %dms.",
|
||||
getAllWarps().size(), duration));
|
||||
}
|
||||
|
||||
public static void setLastLocation(Player player) {
|
||||
if (essAPI.isEnabled()) {
|
||||
getAPI().getUser(player).setLastLocation();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package io.myzticbean.finditemaddon.dependencies;
|
||||
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import me.ryanhamshire.GPFlags.GPFlags;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class GPFlagsPlugin {
|
||||
|
||||
private static GPFlags gpFlags;
|
||||
|
||||
public static void setup() {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("GPFlags")) {
|
||||
gpFlags = (GPFlags) Bukkit.getServer().getPluginManager().getPlugin("GPFlags");
|
||||
if(gpFlags != null) {
|
||||
Logger.logInfo("Found GPFlags");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return gpFlags.isEnabled();
|
||||
}
|
||||
|
||||
public static GPFlags getAPI() {
|
||||
return gpFlags;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.dependencies;
|
||||
|
||||
//import me.ronsane.finditemaddon.finditemaddon.Utils.LoggerUtils;
|
||||
//import me.tks.playerwarp.PWarp;
|
||||
//import me.tks.playerwarp.Warp;
|
||||
//import me.tks.playerwarp.WarpList;
|
||||
//import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class PWarpPlugin {
|
||||
|
||||
// private static PWarp pWarp = null;
|
||||
//
|
||||
// public static void setup() {
|
||||
// if(Bukkit.getPluginManager().isPluginEnabled("PWarp")) {
|
||||
// LoggerUtils.logInfo("Found PWarp");
|
||||
// pWarp = PWarp.getPlugin(PWarp.class);
|
||||
// }
|
||||
// }
|
||||
// public static PWarp getAPI() {
|
||||
// return pWarp;
|
||||
// }
|
||||
//
|
||||
// public static boolean isEnabled() {
|
||||
// return pWarp != null;
|
||||
// }
|
||||
//
|
||||
// public static List<Warp> getAllWarps() {
|
||||
//
|
||||
// return PWarp.wL.getWarps();
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.dependencies;
|
||||
|
||||
import com.olziedev.playerwarps.api.PlayerWarpsAPI;
|
||||
import com.olziedev.playerwarps.api.warp.Warp;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.models.enums.NearestWarpModeEnum;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
@UtilityClass
|
||||
public class PlayerWarpsPlugin {
|
||||
|
||||
private static boolean isEnabled = false;
|
||||
private static List<Warp> allWarpsList = null;
|
||||
private static PlayerWarpsAPI playerWarpsAPI = null;
|
||||
private static final String ALL_WARPS_LIST_CLASSPATH = PlayerWarpsPlugin.class.getCanonicalName() + ".allWarpsList";
|
||||
|
||||
public static void setup() {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("PlayerWarps")) {
|
||||
Logger.logInfo("Found PlayerWarps");
|
||||
PlayerWarpsAPI.getInstance(api -> {
|
||||
playerWarpsAPI = api;
|
||||
isEnabled = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getIsEnabled() { return isEnabled; }
|
||||
|
||||
/**
|
||||
* Issue #24 Fix: Changing all api get references to callback, making this method deprecated
|
||||
* @return PlayerWarpsAPI api
|
||||
*/
|
||||
@Deprecated
|
||||
public static PlayerWarpsAPI getAPI() {
|
||||
return playerWarpsAPI;
|
||||
}
|
||||
|
||||
public static List<Warp> getAllWarps() {
|
||||
if(!isEnabled) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
PlayerWarpsAPI.getInstance(api -> allWarpsList = api.getPlayerWarps(false));
|
||||
return allWarpsList;
|
||||
}
|
||||
|
||||
public static void updateAllWarpsFromAPI() {
|
||||
if(isEnabled) {
|
||||
long start = System.currentTimeMillis();
|
||||
// Issue #24 Fix: Changing api instance to callback
|
||||
PlayerWarpsAPI.getInstance(api -> {
|
||||
allWarpsList = api.getPlayerWarps(false);
|
||||
Logger.logDebugInfo("Update complete for PlayerWarps list! Found " + getAllWarps().size() + " warps. Time took: " + (System.currentTimeMillis() - start) + "ms.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateWarpsOnEventCall(Warp warp, boolean isRemoved) {
|
||||
Logger.logDebugInfo("Got a PlayerWarps event call... checking nearest-warp-mode");
|
||||
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == NearestWarpModeEnum.PLAYER_WARPS.value()) {
|
||||
Logger.logDebugInfo("'nearest-warp-mode' found set to 2");
|
||||
if (getIsEnabled()) {
|
||||
Logger.logDebugInfo("PlayerWarps plugin is enabled");
|
||||
tryUpdateWarps(warp, isRemoved, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Logger.logDebugInfo("No update required to '" + ALL_WARPS_LIST_CLASSPATH + "' as PlayerWarps integration is disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void tryUpdateWarps(Warp warp, boolean isRemoved, int updateTrialSequence) {
|
||||
// Issue #21 Fix: Adding a NPE check
|
||||
if(allWarpsList != null) {
|
||||
if(isRemoved) {
|
||||
if(allWarpsList.contains(warp)) {
|
||||
allWarpsList.remove(warp);
|
||||
Logger.logDebugInfo("Warp removed from allWarpsList: " + warp.getWarpName());
|
||||
} else {
|
||||
Logger.logError("Error occurred while updating '" + ALL_WARPS_LIST_CLASSPATH + "'. Warp name: '" + warp.getWarpName() + "' does not exist!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
allWarpsList.add(warp);
|
||||
Logger.logDebugInfo("New warp added to allWarpsList: " + warp.getWarpName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Issue #21 Fix: forcing update of allWarpsList
|
||||
if(updateTrialSequence == 1) {
|
||||
updateAllWarpsFromAPI();
|
||||
tryUpdateWarps(warp, isRemoved, 2);
|
||||
} else {
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
errorMsg.append("Error occurred while updating '").append(ALL_WARPS_LIST_CLASSPATH).append("' as it is null! ")
|
||||
.append("Please install PlayerWarps by Olzie-12 if you would like to use 'nearest-warp-mode' as 2. ")
|
||||
.append("If PlayerWarps plugin is installed and issue persists, please contact the developer!");
|
||||
Logger.logError(errorMsg.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWarpLocked(Player player, String warpName) {
|
||||
Warp warp = playerWarpsAPI.getPlayerWarp(warpName, player);
|
||||
if(warp == null)
|
||||
return false;
|
||||
return warp.isWarpLocked();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package io.myzticbean.finditemaddon.dependencies;
|
||||
|
||||
import com.bekvon.bukkit.residence.api.ResidenceApi;
|
||||
import com.bekvon.bukkit.residence.api.ResidenceInterface;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* @author SengyEU
|
||||
*/
|
||||
public class ResidencePlugin {
|
||||
|
||||
private static boolean isPluginEnabled;
|
||||
|
||||
public static void setup() {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("Residence")) {
|
||||
Logger.logInfo("Found Residence");
|
||||
isPluginEnabled = true;
|
||||
}
|
||||
else {
|
||||
isPluginEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static ResidenceInterface getResidenceManager () {
|
||||
return ResidenceApi.getResidenceManager();
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return isPluginEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.dependencies;
|
||||
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class WGPlugin {
|
||||
|
||||
private static boolean isPluginEnabled;
|
||||
|
||||
public static void setup() {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) {
|
||||
Logger.logInfo("Found WorldGuard");
|
||||
isPluginEnabled = true;
|
||||
}
|
||||
else {
|
||||
isPluginEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static WorldGuardPlugin getWgPluginInstance() {
|
||||
return WorldGuardPlugin.inst();
|
||||
}
|
||||
|
||||
public static WorldGuard getWgInstance () { return WorldGuard.getInstance(); }
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return isPluginEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.handlers.command;
|
||||
|
||||
import io.myzticbean.finditemaddon.config.ConfigSetup;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.handlers.gui.menus.FoundShopsMenu;
|
||||
import io.myzticbean.finditemaddon.models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.models.enums.PlayerPermsEnum;
|
||||
import io.myzticbean.finditemaddon.quickshop.impl.QSHikariAPIHandler;
|
||||
import io.myzticbean.finditemaddon.quickshop.impl.QSReremakeAPIHandler;
|
||||
import io.myzticbean.finditemaddon.utils.PlayerUtil;
|
||||
import io.myzticbean.finditemaddon.utils.async.VirtualThreadScheduler;
|
||||
import io.myzticbean.finditemaddon.utils.json.HiddenShopStorageUtil;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import io.myzticbean.finditemaddon.utils.warp.WarpUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.quickshop.api.shop.Shop;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handler for different parameters of /finditem command
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class CmdExecutorHandler {
|
||||
|
||||
private static final String THIS_COMMAND_CAN_ONLY_BE_RUN_FROM_IN_GAME = "This command can only be run from in game";
|
||||
public static final String NO_PERMISSION = "&cNo permission!";
|
||||
|
||||
/**
|
||||
* Handles the main shop search process
|
||||
* @param buySellSubCommand Whether player is buying or selling
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
* @param itemArg Specifies Item ID or Item name
|
||||
*/
|
||||
public void handleShopSearch(String buySellSubCommand, CommandSender commandSender, String itemArg) {
|
||||
VirtualThreadScheduler.runTaskAsync(() -> {
|
||||
if (!(commandSender instanceof Player player)) {
|
||||
Logger.logInfo(THIS_COMMAND_CAN_ONLY_BE_RUN_FROM_IN_GAME);
|
||||
return;
|
||||
}
|
||||
if (!player.hasPermission(PlayerPermsEnum.FINDITEM_USE.value())) {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + NO_PERMISSION);
|
||||
return;
|
||||
}
|
||||
|
||||
// Show searching... message
|
||||
if (!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_SEARCH_LOADING_MSG)) {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + 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, " ")) {
|
||||
isBuying = buySellSubCommand.equalsIgnoreCase("to_buy");
|
||||
} else {
|
||||
isBuying = buySellSubCommand.equalsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
}
|
||||
|
||||
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)
|
||||
// UPDATE: No need to run in async thread as it is already running in async thread (Assume everyone has QS-Hikari v6.* installed)
|
||||
FindItemAddOn
|
||||
.getQsApiInstance()
|
||||
.fetchAllItemsFromAllShops(isBuying, player)
|
||||
.thenAccept(searchResultList -> this.openShopMenu(player, searchResultList, FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG));
|
||||
} else {
|
||||
Material mat = Material.getMaterial(itemArg.toUpperCase());
|
||||
if(this.checkMaterialBlacklist(mat)) {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + "&cThis material is not allowed.");
|
||||
return;
|
||||
}
|
||||
if (mat != null && mat.isItem()) {
|
||||
Logger.logDebugInfo("Material found: " + mat);
|
||||
// If QS Hikari installed and Shop Cache feature available (>6), then run in async thread (Fix for Issue #12)
|
||||
// UPDATE: No need to run in async thread as it is already running in async thread (Assume everyone has QS-Hikari v6.* installed)
|
||||
FindItemAddOn
|
||||
.getQsApiInstance()
|
||||
.findItemBasedOnTypeFromAllShops(new ItemStack(mat), isBuying, player)
|
||||
.thenAccept(searchResultList -> this.openShopMenu(player, searchResultList, FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG));
|
||||
} else {
|
||||
Logger.logDebugInfo("Material not found! Performing query based search..");
|
||||
// If QS Hikari installed and Shop Cache feature available (>6), then run in async thread (Fix for Issue #12)
|
||||
// UPDATE: No need to run in async thread as it is already running in async thread (Assume everyone has QS-Hikari v6.* installed)
|
||||
FindItemAddOn
|
||||
.getQsApiInstance()
|
||||
.findItemBasedOnDisplayNameFromAllShops(itemArg, isBuying, player)
|
||||
.thenAccept(searchResultList -> this.openShopMenu(player, searchResultList, FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openShopMenu(Player player, List<FoundShopItemModel> searchResultList, String errorMsg) {
|
||||
if (!searchResultList.isEmpty()) {
|
||||
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
|
||||
menu.open(searchResultList);
|
||||
} else {
|
||||
if (!StringUtils.isEmpty(errorMsg)) {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkMaterialBlacklist(Material mat) {
|
||||
return FindItemAddOn.getConfigProvider().getBlacklistedMaterials().contains(mat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the shop hiding feature
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
public void handleHideShop(CommandSender commandSender) {
|
||||
if(commandSender instanceof Player player) {
|
||||
if(player.hasPermission(PlayerPermsEnum.FINDITEM_HIDESHOP.value())) {
|
||||
Block playerLookAtBlock = player.getTargetBlock(null, 3);
|
||||
Logger.logDebugInfo("TargetBlock found: " + playerLookAtBlock.getType());
|
||||
if(FindItemAddOn.isQSReremakeInstalled()) {
|
||||
hideReremakeShop((Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
}
|
||||
else {
|
||||
hideHikariShop((com.ghostchu.quickshop.api.shop.Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
}
|
||||
}
|
||||
else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + NO_PERMISSION);
|
||||
}
|
||||
} else {
|
||||
Logger.logInfo(THIS_COMMAND_CAN_ONLY_BE_RUN_FROM_IN_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the shop reveal feature
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
public void handleRevealShop(CommandSender commandSender) {
|
||||
if (commandSender instanceof Player player) {
|
||||
if(player.hasPermission(PlayerPermsEnum.FINDITEM_HIDESHOP.value())) {
|
||||
Block playerLookAtBlock = player.getTargetBlock(null, 5);
|
||||
if(playerLookAtBlock != null) {
|
||||
Logger.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 {
|
||||
Logger.logDebugInfo("TargetBlock is null!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + NO_PERMISSION);
|
||||
}
|
||||
} else {
|
||||
Logger.logInfo(THIS_COMMAND_CAN_ONLY_BE_RUN_FROM_IN_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles plugin reload
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
public void handlePluginReload(CommandSender commandSender) {
|
||||
VirtualThreadScheduler.runTaskAsync(() -> {
|
||||
if (commandSender instanceof Player player) {
|
||||
if(player.hasPermission(PlayerPermsEnum.FINDITEM_RELOAD.value()) || player.hasPermission(PlayerPermsEnum.FINDITEM_ADMIN.value())) {
|
||||
ConfigSetup.reloadConfig();
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
FindItemAddOn.initConfigProvider();
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + "&aConfig reloaded!");
|
||||
var allServerShops = FindItemAddOn.getQsApiInstance().getAllShops();
|
||||
if(allServerShops.isEmpty()) {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + "&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + "&aFound &e" + allServerShops.size() + " &ashops on the server.");
|
||||
}
|
||||
WarpUtils.updateWarps();
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + NO_PERMISSION);
|
||||
}
|
||||
} else { // commandSender is console
|
||||
ConfigSetup.reloadConfig();
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
FindItemAddOn.initConfigProvider();
|
||||
var allServerShops = FindItemAddOn.getQsApiInstance().getAllShops();
|
||||
if(allServerShops.isEmpty()) {
|
||||
Logger.logWarning("&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
} else {
|
||||
Logger.logInfo("&aFound &e" + allServerShops.size() + " &ashops on the server.");
|
||||
}
|
||||
WarpUtils.updateWarps();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @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());
|
||||
Bukkit.getPluginManager().enablePlugin(FindItemAddOn.getPlugin(FindItemAddOn.class));
|
||||
Logger.logInfo("&aPlugin restarted!");
|
||||
List allServerShops = FindItemAddOn.getQsApiInstance().getAllShops();
|
||||
if(allServerShops.size() == 0) {
|
||||
Logger.logWarning("&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
} else {
|
||||
Logger.logInfo("&aFound &e" + allServerShops.size() + " &ashops on the server.");
|
||||
}
|
||||
} else {
|
||||
Player player = (Player) commandSender;
|
||||
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));
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + "&aPlugin restarted!");
|
||||
List allServerShops = FindItemAddOn.getQsApiInstance().getAllShops();
|
||||
if(allServerShops.size() == 0) {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + "&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + "&aFound &e" + allServerShops.size() + " &ashops on the server.");
|
||||
}
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + NO_PERMISSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles hide shop for QuickShop Reremake
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void hideReremakeShop(org.maxgamer.quickshop.api.shop.Shop shop, Player player) {
|
||||
if(shop != null) {
|
||||
QSReremakeAPIHandler qsReremakeAPIHandler = (QSReremakeAPIHandler) FindItemAddOn.getQsApiInstance();
|
||||
// check if command runner same as shop owner
|
||||
if(qsReremakeAPIHandler.isShopOwnerCommandRunner(player, shop)) {
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, true);
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG);
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG);
|
||||
}
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG);
|
||||
}
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles hide shop for QuickShop Hikari
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void hideHikariShop(com.ghostchu.quickshop.api.shop.Shop shop, Player player) {
|
||||
if(shop != null) {
|
||||
QSHikariAPIHandler qsHikariAPIHandler = (QSHikariAPIHandler) FindItemAddOn.getQsApiInstance();
|
||||
// check if command runner same as shop owner
|
||||
if(qsHikariAPIHandler.isShopOwnerCommandRunner(player, shop)) {
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, true);
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG);
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG);
|
||||
}
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG);
|
||||
}
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles reveal shop for QuickShop Reremake
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void revealShop(org.maxgamer.quickshop.api.shop.Shop shop, Player player) {
|
||||
if(shop != null) {
|
||||
QSReremakeAPIHandler qsReremakeAPIHandler = (QSReremakeAPIHandler) FindItemAddOn.getQsApiInstance();
|
||||
// check if command runner same as shop owner
|
||||
if(qsReremakeAPIHandler.isShopOwnerCommandRunner(player, shop)) {
|
||||
if(HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, false);
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG);
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG);
|
||||
}
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG);
|
||||
}
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles reveal shop for QuickShop Hikari
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void revealShop(com.ghostchu.quickshop.api.shop.Shop shop, Player player) {
|
||||
if(shop != null) {
|
||||
QSHikariAPIHandler qsHikariAPIHandler = (QSHikariAPIHandler) FindItemAddOn.getQsApiInstance();
|
||||
// check if command runner same as shop owner
|
||||
if(qsHikariAPIHandler.isShopOwnerCommandRunner(player, shop)) {
|
||||
if(HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, false);
|
||||
PlayerUtil.sendMessage(player,
|
||||
getPluginPrefix()
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG);
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player,
|
||||
getPluginPrefix()
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG);
|
||||
}
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player,
|
||||
getPluginPrefix()
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG);
|
||||
}
|
||||
} else {
|
||||
PlayerUtil.sendMessage(player,
|
||||
getPluginPrefix()
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles enabling/disabling debug mode
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
* @param args Command arguments
|
||||
*/
|
||||
public void handleDebugMode(CommandSender commandSender, String[] args) {
|
||||
VirtualThreadScheduler.runTaskAsync(() -> {
|
||||
if(args.length == 1) {
|
||||
if (commandSender instanceof Player player) {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix()
|
||||
+ "&7Debug is currently " + (FindItemAddOn.getConfigProvider().isDebugModeEnabled() ? "enabled." : "disabled.")
|
||||
+ "\nYou can change it by typing &e/finditemadmin debug-mode {enable | disable}\n");
|
||||
} else {
|
||||
Logger.logInfo("\n\nDebug is currently " + (FindItemAddOn.getConfigProvider().isDebugModeEnabled() ? "enabled." : "disabled.")
|
||||
+ "\nYou can change it by typing /finditemadmin debug-mode {enable | disable}\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
String mode = args[1];
|
||||
boolean enable = mode.equalsIgnoreCase("enable");
|
||||
String message;
|
||||
// !player.hasPermission(PlayerPermsEnum.FINDITEM_ADMIN.value())
|
||||
if (commandSender instanceof Player player && !PlayerUtil.hasPermission(player, PlayerPermsEnum.FINDITEM_ADMIN.value())) {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + NO_PERMISSION);
|
||||
return;
|
||||
}
|
||||
// Update debug mode using ConfigProvider's setter
|
||||
FindItemAddOn.getConfigProvider().setDebugMode(enable);
|
||||
message = "Debug mode " + (enable ? "enabled" : "disabled") + " successfully.";
|
||||
if (commandSender instanceof Player player) {
|
||||
PlayerUtil.sendMessage(player, getPluginPrefix() + message);
|
||||
} else {
|
||||
Logger.logInfo(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getPluginPrefix() {
|
||||
return FindItemAddOn.getConfigProvider().PLUGIN_PREFIX;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.handlers.gui;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.components.CustomModelDataComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Based on an awesome tutorial from https://www.youtube.com/watch?v=xebH6M_7k18
|
||||
* Gui pagination: https://www.youtube.com/watch?v=e80NO9Pgz7s
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
@SuppressWarnings({"java:S100", "java:S3776"})
|
||||
public abstract class Menu implements InventoryHolder {
|
||||
|
||||
protected Inventory inventory;
|
||||
|
||||
protected PlayerMenuUtility playerMenuUtility;
|
||||
|
||||
protected ItemStack GUI_FILLER_ITEM;
|
||||
|
||||
protected Menu(PlayerMenuUtility playerMenuUtility) {
|
||||
this.playerMenuUtility = playerMenuUtility;
|
||||
|
||||
assert FindItemAddOn.getConfigProvider().SHOP_GUI_FILLER_ITEM != null;
|
||||
Material fillerMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_FILLER_ITEM);
|
||||
if (fillerMaterial == null) {
|
||||
fillerMaterial = Material.GRAY_STAINED_GLASS_PANE;
|
||||
}
|
||||
if (!fillerMaterial.isAir()) {
|
||||
GUI_FILLER_ITEM = new ItemStack(fillerMaterial);
|
||||
ItemMeta fillerItemItemMeta = this.GUI_FILLER_ITEM.getItemMeta();
|
||||
assert fillerItemItemMeta != null;
|
||||
fillerItemItemMeta.setDisplayName(" ");
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_FILLER_ITEM_CMD)) {
|
||||
try {
|
||||
fillerItemItemMeta.setCustomModelData(Integer.parseInt(FindItemAddOn.getConfigProvider().SHOP_GUI_FILLER_ITEM_CMD));
|
||||
if(checkServerVersionIs_1_21_5_OrAbove()) {
|
||||
var customModelDataComponent = fillerItemItemMeta.getCustomModelDataComponent();
|
||||
customModelDataComponent.setFloats(List.of(Float.parseFloat(FindItemAddOn.getConfigProvider().SHOP_GUI_FILLER_ITEM_CMD)));
|
||||
fillerItemItemMeta.setCustomModelDataComponent(customModelDataComponent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.logError("Error setting custom model data", e);
|
||||
}
|
||||
}
|
||||
this.GUI_FILLER_ITEM.setItemMeta(fillerItemItemMeta);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkServerVersionIs_1_21_5_OrAbove() {
|
||||
String serverVersionString = Bukkit.getVersion();
|
||||
// Example: "1.21-109-5a5035b (MC: 1.21)" or "git-Paper-123 (MC: 1.20.4)"
|
||||
Logger.logDebugInfo("Full Server Version for check: " + serverVersionString);
|
||||
Pattern pattern = Pattern.compile("\\(MC: ([\\d\\.]+)\\)");
|
||||
Matcher matcher = pattern.matcher(serverVersionString);
|
||||
if (matcher.find()) {
|
||||
String mcVersionStr = matcher.group(1); // This will be "1.21" or "1.20.4" etc.
|
||||
Logger.logDebugInfo("Extracted MC Version: " + mcVersionStr);
|
||||
String[] versionParts = mcVersionStr.split("\\.");
|
||||
// We need at least major and minor version numbers (e.g., "1.21")
|
||||
if (versionParts.length >= 2) {
|
||||
try {
|
||||
int major = Integer.parseInt(versionParts[0]);
|
||||
int minor = Integer.parseInt(versionParts[1]);
|
||||
int patch = 0; // Default patch to 0 if not specified (e.g., for "1.21")
|
||||
if (versionParts.length >= 3) {
|
||||
// Attempt to parse patch version, removing any non-numeric characters
|
||||
String patchStr = versionParts[2].replaceAll("[^0-9]", "");
|
||||
if (!patchStr.isEmpty()) {
|
||||
patch = Integer.parseInt(patchStr);
|
||||
}
|
||||
}
|
||||
// Target version: 1.21.5
|
||||
final int TARGET_MAJOR = 1;
|
||||
final int TARGET_MINOR = 21;
|
||||
final int TARGET_PATCH = 5;
|
||||
// Compare versions
|
||||
if (major > TARGET_MAJOR) {
|
||||
return true; // e.g., 2.x.x is > 1.21.5
|
||||
}
|
||||
if (major == TARGET_MAJOR) {
|
||||
if (minor > TARGET_MINOR) {
|
||||
return true; // e.g., 1.22.x is > 1.21.5
|
||||
}
|
||||
if (minor == TARGET_MINOR) {
|
||||
return patch >= TARGET_PATCH; // e.g., 1.21.5, 1.21.6 are >= 1.21.5
|
||||
}
|
||||
}
|
||||
// All other cases are older versions (e.g., 1.20.x, 1.21.0-1.21.4)
|
||||
return false;
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.logDebugInfo("Failed to parse MC version parts from: '" + mcVersionStr + "': " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Logger.logDebugInfo("Could not parse MC version string '" + mcVersionStr + "' into at least major.minor parts.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Logger.logDebugInfo("Could not find MC version pattern '(MC: ...)' in server version string: '" + serverVersionString + "'. Assuming older version or unable to determine.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String getMenuName();
|
||||
|
||||
public abstract int getSlots();
|
||||
|
||||
public abstract void handleMenu(InventoryClickEvent e);
|
||||
|
||||
public abstract void setMenuItems(List<FoundShopItemModel> foundShops);
|
||||
|
||||
/*public void open() {
|
||||
inventory = Bukkit.createInventory(this, getSlots(), getMenuName());
|
||||
this.setMenuItems();
|
||||
playerMenuUtility.getOwner().openInventory(inventory);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Opens the menu for the player
|
||||
* Runs on the MAIN thread
|
||||
*
|
||||
* @param foundShops
|
||||
*/
|
||||
public void open(List<FoundShopItemModel> foundShops) {
|
||||
if (playerMenuUtility.getOwner() == null) return;
|
||||
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> {
|
||||
inventory = Bukkit.createInventory(this, getSlots(), getMenuName());
|
||||
this.setMenuItems(foundShops);
|
||||
playerMenuUtility.getOwner().openInventory(inventory);
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.handlers.gui;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.profile.PlayerProfile;
|
||||
import org.bukkit.profile.PlayerTextures;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public abstract class PaginatedMenu extends Menu {
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
protected int page = 0;
|
||||
protected int index = 0;
|
||||
|
||||
protected ItemStack backButton;
|
||||
protected ItemStack firstPageButton;
|
||||
protected ItemStack nextButton;
|
||||
protected ItemStack lastPageButton;
|
||||
protected ItemStack closeInvButton;
|
||||
|
||||
protected static final int MAX_ITEMS_PER_PAGE = 45;
|
||||
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=";
|
||||
|
||||
protected PaginatedMenu(PlayerMenuUtility playerMenuUtility) {
|
||||
super(playerMenuUtility);
|
||||
initMaterialsForBottomBar();
|
||||
}
|
||||
|
||||
protected PaginatedMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
|
||||
super(playerMenuUtility);
|
||||
initMaterialsForBottomBar();
|
||||
super.playerMenuUtility.setPlayerShopSearchResult(searchResult);
|
||||
}
|
||||
|
||||
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(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);
|
||||
}
|
||||
|
||||
private void createGUIBackButton() {
|
||||
Material backButtonMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_MATERIAL);
|
||||
if(backButtonMaterial == null) {
|
||||
backButton = createPlayerHead(BACK_BUTTON_SKIN_ID);
|
||||
}
|
||||
else {
|
||||
backButton = new ItemStack(backButtonMaterial);
|
||||
}
|
||||
ItemMeta backButtonMeta = backButton.getItemMeta();
|
||||
assert backButtonMeta != null;
|
||||
if(!StringUtils.isEmpty(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);
|
||||
backButtonMeta.setCustomModelData(backButtonCMD);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
Logger.logDebugInfo("Invalid Custom Model Data for Back Button in config.yml");
|
||||
}
|
||||
backButton.setItemMeta(backButtonMeta);
|
||||
}
|
||||
|
||||
private void createGUINextButton() {
|
||||
Material nextButtonMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_MATERIAL);
|
||||
if(nextButtonMaterial == null) {
|
||||
nextButton = createPlayerHead(NEXT_BUTTON_SKIN_ID);
|
||||
}
|
||||
else {
|
||||
nextButton = new ItemStack(nextButtonMaterial);
|
||||
}
|
||||
ItemMeta nextButtonMeta = nextButton.getItemMeta();
|
||||
assert nextButtonMeta != null;
|
||||
if(!StringUtils.isEmpty(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);
|
||||
nextButtonMeta.setCustomModelData(nextButtonCMD);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
Logger.logDebugInfo("Invalid Custom Model Data for Next Button in config.yml");
|
||||
}
|
||||
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) {
|
||||
Logger.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) {
|
||||
Logger.logDebugInfo("Invalid Custom Model Data for Goto Last Page Button in config.yml");
|
||||
}
|
||||
lastPageButton.setItemMeta(lastPageButtonMeta);
|
||||
}
|
||||
|
||||
private void createGUICloseInvButton() {
|
||||
Material closeInvButtonMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_MATERIAL);
|
||||
if(closeInvButtonMaterial == null) {
|
||||
closeInvButtonMaterial = Material.BARRIER;
|
||||
}
|
||||
closeInvButton = new ItemStack(closeInvButtonMaterial);
|
||||
ItemMeta closeInvMeta = closeInvButton.getItemMeta();
|
||||
assert closeInvMeta != null;
|
||||
if(!StringUtils.isEmpty(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);
|
||||
closeInvMeta.setCustomModelData(closeInvButtonCMD);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
Logger.logDebugInfo("Invalid Custom Model Data for Close Button in config.yml");
|
||||
}
|
||||
closeInvButton.setItemMeta(closeInvMeta);
|
||||
}
|
||||
|
||||
private ItemStack createPlayerHead(String textureValue) {
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||
SkullMeta meta = (SkullMeta) head.getItemMeta();
|
||||
if (meta != null) {
|
||||
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID(), null);
|
||||
PlayerTextures textures = profile.getTextures();
|
||||
try {
|
||||
String decodedValue = new String(Base64.getDecoder().decode(textureValue));
|
||||
Logger.logDebugInfo("Decoded Value: " + decodedValue);
|
||||
String textureUrl = extractTextureUrl(decodedValue);
|
||||
URL url = new URL(textureUrl);
|
||||
textures.setSkin(url);
|
||||
} catch (Exception e) {
|
||||
Logger.logError(e);
|
||||
}
|
||||
profile.setTextures(textures);
|
||||
meta.setOwnerProfile(profile);
|
||||
head.setItemMeta(meta);
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
||||
private String extractTextureUrl(String decodedValue) {
|
||||
JsonObject jsonObject = gson.fromJson(decodedValue, JsonObject.class);
|
||||
return jsonObject
|
||||
.getAsJsonObject("textures")
|
||||
.getAsJsonObject("SKIN")
|
||||
.get("url")
|
||||
.getAsString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.handlers.gui;
|
||||
|
||||
import io.myzticbean.finditemaddon.models.FoundShopItemModel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class PlayerMenuUtility {
|
||||
private UUID owner;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private List<FoundShopItemModel> playerShopSearchResult;
|
||||
|
||||
public PlayerMenuUtility(Player owner) {
|
||||
this.owner = owner.getUniqueId();
|
||||
}
|
||||
|
||||
public PlayerMenuUtility(UUID owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Player getOwner() {
|
||||
return Bukkit.getPlayer(owner);
|
||||
}
|
||||
|
||||
public void setOwner(Player owner) {
|
||||
this.owner = owner.getUniqueId();
|
||||
}
|
||||
|
||||
public void setOwner(UUID owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,669 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.handlers.gui.menus;
|
||||
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
import com.olziedev.playerwarps.api.warp.Warp;
|
||||
import io.myzticbean.finditemaddon.config.ConfigProvider;
|
||||
import io.myzticbean.finditemaddon.dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.dependencies.ResidencePlugin;
|
||||
import io.myzticbean.finditemaddon.dependencies.WGPlugin;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.handlers.gui.PaginatedMenu;
|
||||
import io.myzticbean.finditemaddon.handlers.gui.PlayerMenuUtility;
|
||||
import io.myzticbean.finditemaddon.models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.models.enums.CustomCmdPlaceholdersEnum;
|
||||
import io.myzticbean.finditemaddon.models.enums.PlayerPermsEnum;
|
||||
import io.myzticbean.finditemaddon.models.enums.ShopLorePlaceholdersEnum;
|
||||
import io.myzticbean.finditemaddon.utils.PlayerUtil;
|
||||
import io.myzticbean.finditemaddon.utils.async.VirtualThreadScheduler;
|
||||
import io.myzticbean.finditemaddon.utils.json.ShopSearchActivityStorageUtil;
|
||||
import io.myzticbean.finditemaddon.utils.LocationUtils;
|
||||
import io.myzticbean.finditemaddon.utils.log.Logger;
|
||||
import io.myzticbean.finditemaddon.utils.warp.EssentialWarpsUtil;
|
||||
import io.myzticbean.finditemaddon.utils.warp.PlayerWarpsUtil;
|
||||
import io.myzticbean.finditemaddon.utils.warp.ResidenceUtils;
|
||||
import io.myzticbean.finditemaddon.utils.warp.WGRegionUtils;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Handler class for FoundShops GUI
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class FoundShopsMenu extends PaginatedMenu {
|
||||
|
||||
public static final String SHOP_STOCK_UNLIMITED = "Unlimited";
|
||||
public static final String SHOP_STOCK_UNKNOWN = "Unknown";
|
||||
private static final String NAMEDSPACE_KEY_LOCATION_DATA = "locationData";
|
||||
private final ConfigProvider configProvider;
|
||||
|
||||
public FoundShopsMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
|
||||
super(playerMenuUtility, searchResult);
|
||||
configProvider = FindItemAddOn.getConfigProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMenuName() {
|
||||
if (!StringUtils.isEmpty(configProvider.SHOP_SEARCH_GUI_TITLE)) {
|
||||
return ColorTranslator.translateColorCodes(configProvider.SHOP_SEARCH_GUI_TITLE);
|
||||
} else {
|
||||
return ColorTranslator.translateColorCodes("&l» &rShops");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return 54;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMenu(@NotNull InventoryClickEvent event) {
|
||||
int slot = event.getSlot();
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
// Handle navigation buttons (prev, next, first, last page)
|
||||
if (handleNavigationClick(event, slot)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Close inventory if the close button (slot 49) is clicked
|
||||
if (slot == 49) {
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore clicks on empty slots
|
||||
if (event.getCurrentItem().getType().equals(Material.AIR)) {
|
||||
Logger.logDebugInfo(player.getName() + " just clicked on AIR!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle clicks on shop items
|
||||
handleShopItemClick(event, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles clicks on navigation buttons
|
||||
*
|
||||
* @param event The InventoryClickEvent
|
||||
* @param slot The clicked slot number
|
||||
* @return true if a navigation button was clicked, false otherwise
|
||||
*/
|
||||
private boolean handleNavigationClick(InventoryClickEvent event, int slot) {
|
||||
return switch (slot) {
|
||||
case 45 -> {
|
||||
handleMenuClickForNavToPrevPage(event);
|
||||
yield true;
|
||||
}
|
||||
case 46 -> {
|
||||
handleFirstPageClick(event);
|
||||
yield true;
|
||||
}
|
||||
case 52 -> {
|
||||
handleLastPageClick(event);
|
||||
yield true;
|
||||
}
|
||||
case 53 -> {
|
||||
handleMenuClickForNavToNextPage(event);
|
||||
yield true;
|
||||
}
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles clicks on shop items in the inventory
|
||||
*
|
||||
* @param event The InventoryClickEvent
|
||||
* @param player The player who clicked
|
||||
*/
|
||||
private void handleShopItemClick(@NotNull InventoryClickEvent event, Player player) {
|
||||
ItemStack item = event.getCurrentItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
NamespacedKey key = new NamespacedKey(FindItemAddOn.getInstance(), NAMEDSPACE_KEY_LOCATION_DATA);
|
||||
|
||||
// Check if the item has the required location data
|
||||
if (!meta.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
|
||||
Logger.logError("PersistentDataContainer doesn't have the right kind of data!");
|
||||
return;
|
||||
}
|
||||
|
||||
String locData = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
||||
List<String> locDataList = Arrays.asList(locData.split("\\s*\\|\\|\\|\\s*"));
|
||||
|
||||
// Handle direct teleportation to shop
|
||||
if (configProvider.TP_PLAYER_DIRECTLY_TO_SHOP && locDataList.size() > 1) {
|
||||
handleDirectShopTeleport(player, locDataList);
|
||||
}
|
||||
// Handle teleportation to nearest warp
|
||||
else if (configProvider.TP_PLAYER_TO_NEAREST_WARP && locDataList.size() == 1
|
||||
&& !locDataList.get(0).isEmpty()) {
|
||||
handleWarpTeleport(player, locDataList.get(0));
|
||||
}
|
||||
|
||||
// Execute custom commands if enabled
|
||||
handleCustomCommands(player, locDataList);
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles direct teleportation to a shop
|
||||
*
|
||||
* @param player The player to teleport
|
||||
* @param locDataList List containing location data
|
||||
*/
|
||||
private void handleDirectShopTeleport(@NotNull Player player, List<String> locDataList) {
|
||||
VirtualThreadScheduler.runTaskAsync(() -> {
|
||||
// Check if player has permission to teleport
|
||||
if (!PlayerUtil.hasPermission(player, PlayerPermsEnum.FINDITEM_SHOPTP.value())) {
|
||||
sendNoPermissionMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Location shopLocation = parseShopLocation(locDataList);
|
||||
if (shopLocation == null)
|
||||
return;
|
||||
|
||||
// Check if player is teleporting to their own shop
|
||||
UUID shopOwner = ShopSearchActivityStorageUtil.getShopOwnerUUID(shopLocation);
|
||||
if (player.getUniqueId().equals(shopOwner) && !PlayerPermsEnum.canPlayerTpToOwnShop(player)) {
|
||||
PlayerUtil.sendMessage(player, configProvider.PLUGIN_PREFIX + configProvider.SHOP_TP_NO_PERMISSION_MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find a safe location around the shop
|
||||
Location locToTeleport = LocationUtils.findSafeLocationAroundShop(shopLocation, player);
|
||||
if (locToTeleport == null) {
|
||||
sendUnsafeAreaMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Record the visit and set last location for Essentials
|
||||
ShopSearchActivityStorageUtil.addPlayerVisitEntryAsync(shopLocation, player);
|
||||
if (EssentialsXPlugin.isEnabled())
|
||||
EssentialsXPlugin.setLastLocation(player);
|
||||
|
||||
// Apply teleport delay if necessary, otherwise teleport immediately
|
||||
if (shouldApplyTeleportDelay(player)) {
|
||||
applyTeleportDelay(player, locToTeleport);
|
||||
} else {
|
||||
PlayerUtil.teleport(player, locToTeleport);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles teleportation to the nearest warp
|
||||
*
|
||||
* @param player The player to teleport
|
||||
* @param warpName The name of the warp
|
||||
*/
|
||||
private void handleWarpTeleport(Player player, String warpName) {
|
||||
switch (configProvider.NEAREST_WARP_MODE) {
|
||||
case 1:
|
||||
EssentialWarpsUtil.warpPlayer(player, warpName);
|
||||
break;
|
||||
case 2:
|
||||
PlayerWarpsUtil.executeWarpPlayer(player, warpName);
|
||||
break;
|
||||
case 4:
|
||||
ResidenceUtils.residenceTp(player, warpName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes custom commands if enabled
|
||||
*
|
||||
* @param player The player who triggered the commands
|
||||
* @param locDataList List containing location data
|
||||
*/
|
||||
private void handleCustomCommands(Player player, List<String> locDataList) {
|
||||
if (configProvider.CUSTOM_CMDS_RUN_ENABLED && !configProvider.CUSTOM_CMDS_LIST.isEmpty()
|
||||
&& locDataList.size() > 1) {
|
||||
Location shopLocation = parseShopLocation(locDataList);
|
||||
if (shopLocation == null)
|
||||
return;
|
||||
|
||||
for (String cmd : configProvider.CUSTOM_CMDS_LIST) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), replaceCustomCmdPlaceholders(cmd, player, shopLocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses location data into a Bukkit Location
|
||||
*
|
||||
* @param locDataList List containing location data
|
||||
* @return A Bukkit Location, or null if parsing fails
|
||||
*/
|
||||
private @Nullable Location parseShopLocation(@NotNull List<String> locDataList) {
|
||||
if (locDataList.size() <= 1)
|
||||
return null;
|
||||
World world = Bukkit.getWorld(locDataList.get(0));
|
||||
int locX = Integer.parseInt(locDataList.get(1));
|
||||
int locY = Integer.parseInt(locDataList.get(2));
|
||||
int locZ = Integer.parseInt(locDataList.get(3));
|
||||
return new Location(world, locX, locY, locZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a no permission message to the player
|
||||
*
|
||||
* @param player The player to send the message to
|
||||
*/
|
||||
private void sendNoPermissionMessage(Player player) {
|
||||
if (!StringUtils.isEmpty(configProvider.SHOP_TP_NO_PERMISSION_MSG)) {
|
||||
PlayerUtil.sendMessage(player, configProvider.PLUGIN_PREFIX + configProvider.SHOP_TP_NO_PERMISSION_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an unsafe area message to the player
|
||||
*
|
||||
* @param player The player to send the message to
|
||||
*/
|
||||
private void sendUnsafeAreaMessage(Player player) {
|
||||
if (!StringUtils.isEmpty(configProvider.UNSAFE_SHOP_AREA_MSG)) {
|
||||
PlayerUtil.sendMessage(player, configProvider.PLUGIN_PREFIX + configProvider.UNSAFE_SHOP_AREA_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a teleport delay should be applied
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if a delay should be applied, false otherwise
|
||||
*/
|
||||
private boolean shouldApplyTeleportDelay(Player player) {
|
||||
return StringUtils.isNumeric(configProvider.TP_DELAY_IN_SECONDS)
|
||||
&& !"0".equals(configProvider.TP_DELAY_IN_SECONDS)
|
||||
&& !PlayerPermsEnum.hasShopTpDelayBypassPermOrAdmin(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a teleport delay and sends a message to the player
|
||||
*
|
||||
* @param player The player to apply the delay to
|
||||
* @param locToTeleport The location to teleport to after the delay
|
||||
*/
|
||||
private void applyTeleportDelay(Player player, Location locToTeleport) {
|
||||
long delay = Long.parseLong(configProvider.TP_DELAY_IN_SECONDS);
|
||||
Logger.logDebugInfo("Teleporting delay is set to: " + delay);
|
||||
String tpDelayMsg = configProvider.TP_DELAY_MESSAGE;
|
||||
if (!StringUtils.isEmpty(tpDelayMsg)) {
|
||||
PlayerUtil.sendMessage(player, configProvider.PLUGIN_PREFIX + replaceDelayPlaceholder(tpDelayMsg, delay));
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(
|
||||
FindItemAddOn.getInstance(),
|
||||
() -> PlayerUtil.teleport(player, locToTeleport),
|
||||
delay * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles navigation to the next page
|
||||
*
|
||||
* @param event The InventoryClickEvent
|
||||
*/
|
||||
private void handleMenuClickForNavToNextPage(InventoryClickEvent event) {
|
||||
if (!((index + 1) >= super.playerMenuUtility.getPlayerShopSearchResult().size())) {
|
||||
page = page + 1;
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
} else {
|
||||
if (!StringUtils.isEmpty(configProvider.SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
|
||||
PlayerUtil.sendMessage(event.getWhoClicked(), configProvider.PLUGIN_PREFIX + configProvider.SHOP_NAV_LAST_PAGE_ALERT_MSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles navigation to the previous page
|
||||
*
|
||||
* @param event The InventoryClickEvent
|
||||
*/
|
||||
private void handleMenuClickForNavToPrevPage(InventoryClickEvent event) {
|
||||
if (page == 0) {
|
||||
if (!StringUtils.isEmpty(configProvider.SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
|
||||
PlayerUtil.sendMessage(event.getWhoClicked(), configProvider.PLUGIN_PREFIX + configProvider.SHOP_NAV_FIRST_PAGE_ALERT_MSG);
|
||||
}
|
||||
} else {
|
||||
page = page - 1;
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles navigation to the first page
|
||||
*
|
||||
* @param event The InventoryClickEvent
|
||||
*/
|
||||
private void handleFirstPageClick(InventoryClickEvent event) {
|
||||
if (page == 0) {
|
||||
if (!StringUtils.isEmpty(configProvider.SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
|
||||
PlayerUtil.sendMessage(event.getWhoClicked(), configProvider.PLUGIN_PREFIX + configProvider.SHOP_NAV_FIRST_PAGE_ALERT_MSG);
|
||||
}
|
||||
} else {
|
||||
page = 0;
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles navigation to the last page
|
||||
*
|
||||
* @param event The InventoryClickEvent
|
||||
*/
|
||||
private void handleLastPageClick(InventoryClickEvent event) {
|
||||
int listSize = super.playerMenuUtility.getPlayerShopSearchResult().size();
|
||||
if (!((index + 1) >= listSize)) {
|
||||
double totalPages = listSize / MAX_ITEMS_PER_PAGE;
|
||||
if (totalPages % 10 == 0) {
|
||||
page = (int) Math.floor(totalPages);
|
||||
Logger.logDebugInfo("Floor page value: " + page);
|
||||
} else {
|
||||
page = (int) Math.ceil(totalPages);
|
||||
Logger.logDebugInfo("Ceiling page value: " + page);
|
||||
}
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
} else {
|
||||
if (!StringUtils.isEmpty(configProvider.SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
|
||||
PlayerUtil.sendMessage(event.getWhoClicked(), configProvider.PLUGIN_PREFIX + configProvider.SHOP_NAV_LAST_PAGE_ALERT_MSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the slots in the search result GUI
|
||||
*
|
||||
* @param foundShops List of found shops
|
||||
*/
|
||||
@Override
|
||||
public void setMenuItems(List<FoundShopItemModel> foundShops) {
|
||||
// Add the bottom navigation bar to the menu
|
||||
addMenuBottomBar();
|
||||
|
||||
// If no shops were found, return early
|
||||
if (foundShops == null || foundShops.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int maxItemsPerPage = MAX_ITEMS_PER_PAGE;
|
||||
// Iterate through the slots for this page
|
||||
for (int guiSlotCounter = 0; guiSlotCounter < maxItemsPerPage; guiSlotCounter++) {
|
||||
// Calculate the index in the foundShops list for the current slot
|
||||
index = maxItemsPerPage * page + guiSlotCounter;
|
||||
if (index >= foundShops.size()) {
|
||||
break;
|
||||
}
|
||||
|
||||
FoundShopItemModel foundShop = foundShops.get(index);
|
||||
if (foundShop == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create an ItemStack for the shop and add it to the inventory
|
||||
ItemStack item = createShopItem(foundShop);
|
||||
inventory.addItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ItemStack representing a shop
|
||||
*
|
||||
* @param foundShop The shop to create an item for
|
||||
* @return An ItemStack representing the shop
|
||||
*/
|
||||
private @NotNull ItemStack createShopItem(@NotNull FoundShopItemModel foundShop) {
|
||||
// Create a new ItemStack based on the shop's item
|
||||
ItemStack item = new ItemStack(foundShop.getItem().getType(), foundShop.getItem().getAmount());
|
||||
ItemMeta meta = foundShop.getItem().getItemMeta();
|
||||
if (meta == null) {
|
||||
meta = Bukkit.getItemFactory().getItemMeta(item.getType());
|
||||
}
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
// Add lore to the item
|
||||
addItemLore(lore, foundShop);
|
||||
|
||||
meta.setLore(lore);
|
||||
// Set location data in the item's metadata
|
||||
setLocationData(meta, foundShop);
|
||||
|
||||
// Preserve custom model data if it exists
|
||||
if (foundShop.getItem().getItemMeta().hasCustomModelData()) {
|
||||
meta.setCustomModelData(foundShop.getItem().getItemMeta().getCustomModelData());
|
||||
}
|
||||
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds lore to an item representing a shop
|
||||
*
|
||||
* @param lore The list to add lore to
|
||||
* @param foundShop The shop to create lore for
|
||||
*/
|
||||
private void addItemLore(List<String> lore, FoundShopItemModel foundShop) {
|
||||
// Add existing item lore
|
||||
ItemMeta shopItemMeta = foundShop.getItem().getItemMeta();
|
||||
if (shopItemMeta != null && shopItemMeta.hasLore()) {
|
||||
for (String line : shopItemMeta.getLore()) {
|
||||
lore.add(ColorTranslator.translateColorCodes(line));
|
||||
}
|
||||
}
|
||||
|
||||
// Add shop info lore
|
||||
for (String loreLine : configProvider.SHOP_GUI_ITEM_LORE) {
|
||||
if (loreLine.contains(ShopLorePlaceholdersEnum.NEAREST_WARP.value())) {
|
||||
String nearestWarpInfo = getNearestWarpInfo(foundShop);
|
||||
lore.add(ColorTranslator.translateColorCodes(
|
||||
loreLine.replace(ShopLorePlaceholdersEnum.NEAREST_WARP.value(), nearestWarpInfo)));
|
||||
} else {
|
||||
lore.add(ColorTranslator.translateColorCodes(replaceLorePlaceholders(loreLine, foundShop)));
|
||||
}
|
||||
}
|
||||
|
||||
// Add teleport info if applicable
|
||||
if (configProvider.TP_PLAYER_DIRECTLY_TO_SHOP
|
||||
&& playerMenuUtility.getOwner().hasPermission(PlayerPermsEnum.FINDITEM_SHOPTP.value())) {
|
||||
lore.add(ColorTranslator.translateColorCodes(configProvider.CLICK_TO_TELEPORT_MSG));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the nearest warp or region to a shop based on the configuration
|
||||
*
|
||||
* @param foundShop The shop to find the nearest warp/region for
|
||||
* @return A string representing the nearest warp/region, or an error message if
|
||||
* none found
|
||||
*/
|
||||
private String getNearestWarpInfo(FoundShopItemModel foundShop) {
|
||||
int nearestWarpMode = configProvider.NEAREST_WARP_MODE;
|
||||
switch (nearestWarpMode) {
|
||||
case 1:
|
||||
// EssentialsX warps
|
||||
if (EssentialsXPlugin.isEnabled()) {
|
||||
String nearestEWarp = EssentialWarpsUtil.findNearestWarp(foundShop.getShopLocation());
|
||||
return (nearestEWarp != null && !StringUtils.isEmpty(nearestEWarp)) ? nearestEWarp
|
||||
: configProvider.NO_WARP_NEAR_SHOP_ERROR_MSG;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// PlayerWarps
|
||||
if (PlayerWarpsPlugin.getIsEnabled()) {
|
||||
Warp nearestPlayerWarp = PlayerWarpsUtil.findNearestWarp(foundShop.getShopLocation(),
|
||||
foundShop.getShopOwner());
|
||||
return (nearestPlayerWarp != null) ? nearestPlayerWarp.getWarpName()
|
||||
: configProvider.NO_WARP_NEAR_SHOP_ERROR_MSG;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// WorldGuard regions
|
||||
if (WGPlugin.isEnabled()) {
|
||||
String nearestWGRegion = new WGRegionUtils().findNearestWGRegion(foundShop.getShopLocation());
|
||||
return (nearestWGRegion != null && !StringUtils.isEmpty(nearestWGRegion)) ? nearestWGRegion
|
||||
: configProvider.NO_WG_REGION_NEAR_SHOP_ERROR_MSG;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// Residence plugin
|
||||
if (ResidencePlugin.isEnabled()) {
|
||||
ClaimedResidence nearestResidence = ResidenceUtils
|
||||
.findNearestResidence(foundShop.getShopLocation());
|
||||
return (nearestResidence != null) ? ResidenceUtils.getResidenceName(nearestResidence)
|
||||
: configProvider.NO_RESIDENCE_NEAR_SHOP_ERROR_MSG;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Logger.logDebugInfo("Invalid value in 'nearest-warp-mode' in config.yml!");
|
||||
}
|
||||
return configProvider.NO_WARP_NEAR_SHOP_ERROR_MSG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets location data in the item's metadata
|
||||
*
|
||||
* @param meta The ItemMeta to set the data on
|
||||
* @param foundShop The shop to get location data from
|
||||
*/
|
||||
private void setLocationData(ItemMeta meta, FoundShopItemModel foundShop) {
|
||||
NamespacedKey key = new NamespacedKey(FindItemAddOn.getInstance(), NAMEDSPACE_KEY_LOCATION_DATA);
|
||||
String locData = "";
|
||||
|
||||
if (configProvider.TP_PLAYER_DIRECTLY_TO_SHOP) {
|
||||
// Store exact coordinates for direct teleportation
|
||||
Location shopLoc = foundShop.getShopLocation();
|
||||
locData = String.format("%s|||%d|||%d|||%d", shopLoc.getWorld().getName(), shopLoc.getBlockX(),
|
||||
shopLoc.getBlockY(), shopLoc.getBlockZ());
|
||||
} else if (configProvider.TP_PLAYER_TO_NEAREST_WARP) {
|
||||
// Store nearest warp info for warp teleportation
|
||||
locData = getNearestWarpInfo(foundShop);
|
||||
}
|
||||
|
||||
meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, locData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all the placeholders in the Shop item lore in GUI
|
||||
*
|
||||
* @param text Line of lore
|
||||
* @param shop Shop instance
|
||||
* @return Line of lore replaced with placeholder values
|
||||
*/
|
||||
private @NotNull String replaceLorePlaceholders(String text, @NotNull FoundShopItemModel shop) {
|
||||
text = text.replace(ShopLorePlaceholdersEnum.ITEM_PRICE.value(), formatNumber(shop.getShopPrice()));
|
||||
|
||||
if (text.contains(ShopLorePlaceholdersEnum.SHOP_STOCK.value())) {
|
||||
int stock = shop.getRemainingStockOrSpace();
|
||||
String stockText;
|
||||
if (stock == -2) {
|
||||
// if -2 (cache doesn't have value) -> try to fetch from MAIN thread
|
||||
int stockOrSpace = processUnknownStockSpace(shop);
|
||||
stockText = (stockOrSpace == -2) ? SHOP_STOCK_UNKNOWN
|
||||
: (stockOrSpace == -1 ? SHOP_STOCK_UNLIMITED : String.valueOf(stockOrSpace));
|
||||
} else {
|
||||
stockText = (stock == Integer.MAX_VALUE) ? SHOP_STOCK_UNLIMITED : String.valueOf(stock);
|
||||
}
|
||||
text = text.replace(ShopLorePlaceholdersEnum.SHOP_STOCK.value(), stockText);
|
||||
}
|
||||
|
||||
text = text.replace(ShopLorePlaceholdersEnum.SHOP_PER_ITEM_QTY.value(),
|
||||
String.valueOf(shop.getItem().getAmount()));
|
||||
|
||||
if (text.contains(ShopLorePlaceholdersEnum.SHOP_OWNER.value())) {
|
||||
OfflinePlayer shopOwner = Bukkit.getOfflinePlayer(shop.getShopOwner());
|
||||
// set a generic name for shops with no owner name ('Admin')
|
||||
String ownerName = shopOwner.getName() != null ? shopOwner.getName() : "Admin";
|
||||
text = text.replace(ShopLorePlaceholdersEnum.SHOP_OWNER.value(), ownerName);
|
||||
}
|
||||
|
||||
if (text.contains(ShopLorePlaceholdersEnum.SHOP_LOCATION.value())) {
|
||||
Location loc = shop.getShopLocation();
|
||||
String locText = loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ();
|
||||
text = text.replace(ShopLorePlaceholdersEnum.SHOP_LOCATION.value(), locText);
|
||||
}
|
||||
|
||||
text = text.replace(ShopLorePlaceholdersEnum.SHOP_WORLD.value(),
|
||||
Objects.requireNonNull(shop.getShopLocation().getWorld()).getName());
|
||||
|
||||
// Added in v2.0
|
||||
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));
|
||||
}
|
||||
|
||||
private String formatNumber(double number) {
|
||||
if (configProvider.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);
|
||||
}
|
||||
}
|
||||
|
||||
private String replaceCustomCmdPlaceholders(String cmd, Player player, Location shopLoc) {
|
||||
return cmd
|
||||
.replace(CustomCmdPlaceholdersEnum.PLAYER_NAME.value(), player.getName())
|
||||
.replace(CustomCmdPlaceholdersEnum.SHOP_LOC_X.value(), Double.toString(shopLoc.getX()))
|
||||
.replace(CustomCmdPlaceholdersEnum.SHOP_LOC_Y.value(), Double.toString(shopLoc.getY()))
|
||||
.replace(CustomCmdPlaceholdersEnum.SHOP_LOC_Z.value(), Double.toString(shopLoc.getZ()))
|
||||
.replace(CustomCmdPlaceholdersEnum.SHOP_WORLD.value(), shopLoc.getWorld().getName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.listeners;
|
||||
|
||||
import io.myzticbean.finditemaddon.handlers.gui.Menu;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class MenuListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMenuClick(InventoryClickEvent e) {
|
||||
InventoryHolder holder = e.getInventory().getHolder();
|
||||
if(holder instanceof Menu menu) {
|
||||
e.setCancelled(true);
|
||||
if(e.getCurrentItem() == null) {
|
||||
return;
|
||||
}
|
||||
menu.handleMenu(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.listeners;
|
||||
|
||||
import com.olziedev.playerwarps.api.events.warp.PlayerWarpCreateEvent;
|
||||
import io.myzticbean.finditemaddon.dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class PWPlayerWarpCreateEventListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerWarpCreate(PlayerWarpCreateEvent event) {
|
||||
// Issue #24 Fix: Converted updateWarpsOnEventCall() call to async
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(),
|
||||
() -> PlayerWarpsPlugin.updateWarpsOnEventCall(event.getPlayerWarp(), false));
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.listeners;
|
||||
|
||||
import com.olziedev.playerwarps.api.events.warp.PlayerWarpRemoveEvent;
|
||||
import io.myzticbean.finditemaddon.dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class PWPlayerWarpRemoveEventListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerWarpRemove(PlayerWarpRemoveEvent event) {
|
||||
// Issue #24 Fix: Converted updateWarpsOnEventCall() call to async
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(),
|
||||
() -> PlayerWarpsPlugin.updateWarpsOnEventCall(event.getPlayerWarp(), true));
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.listeners;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class PlayerCommandSendEventListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerCommandTab(PlayerCommandSendEvent event) {
|
||||
if(!event.getPlayer().isOp()) {
|
||||
List<String> blockedCommands = new ArrayList<>();
|
||||
blockedCommands.add("finditem:finditem");
|
||||
assert FindItemAddOn.getConfigProvider().FIND_ITEM_COMMAND_ALIAS != null;
|
||||
for(String cmd : FindItemAddOn.getConfigProvider().FIND_ITEM_COMMAND_ALIAS) {
|
||||
blockedCommands.add("finditem:" + cmd);
|
||||
}
|
||||
blockedCommands.add("finditemadmin:finditemadmin");
|
||||
blockedCommands.add("finditemadmin:fiadmin");
|
||||
blockedCommands.add("finditemadmin");
|
||||
blockedCommands.add("fiadmin");
|
||||
event.getCommands().removeAll(blockedCommands);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.listeners;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.utils.UpdateChecker;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class PlayerJoinEventListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
new UpdateChecker().notifyPlayerAboutUpdateOnJoin(event);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* QSFindItemAddOn: An Minecraft add-on plugin for the QuickShop Hikari
|
||||
* and Reremake Shop plugins for Spigot server platform.
|
||||
* Copyright (C) 2021 myzticbean
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.myzticbean.finditemaddon.listeners;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
/**
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class PluginEnableEventListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if(!FindItemAddOn.isQSReremakeInstalled() && !FindItemAddOn.isQSHikariInstalled()) {
|
||||
// if(!event.getPlugin().getName().equalsIgnoreCase("QuickShop")
|
||||
// && !event.getPlugin().getName().equalsIgnoreCase("QuickShop-Hikari")) {
|
||||
// // do nothing
|
||||
// }
|
||||
if(event.getPlugin().getName().equalsIgnoreCase("QuickShop") && !FindItemAddOn.isQSHikariInstalled()) {
|
||||
FindItemAddOn.setQSReremakeInstalled(true);
|
||||
} else if (event.getPlugin().getName().equalsIgnoreCase("QuickShop-Hikari") && !FindItemAddOn.isQSReremakeInstalled()) {
|
||||
FindItemAddOn.setQSHikariInstalled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 136 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user