Feat: Maven -> Gradle 8.14.2

This commit is contained in:
NotAlexNoyle committed 2025-06-20 16:19:28 -04:00
1 parent a3aad0b7ed
commit 3a81df4788
426 files changed
+7618 -10963

No files matched your search

-13
View File
@@ -1,13 +0,0 @@
# These are supported funding model platforms
#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
#patreon: # Replace with a single Patreon username
#open_collective: # Replace with a single Open Collective username
ko_fi: ghostchu
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
#liberapay: # Replace with a single Liberapay username
#issuehunt: # Replace with a single IssueHunt username
#otechie: # Replace with a single Otechie username
#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: [ "https://imgur.com/a/fgES06K" ]
-72
View File
@@ -1,72 +0,0 @@
name: 'Bug Report'
description: 'Report a bug with QuickShop to us.'
title: '[BUG] '
labels:
- 'Bug'
body:
- type: 'markdown'
attributes:
value: |-
## Please Read!
This Form is reserved for **Bug reports only!**
- For performance issues with QuickShop, open a [Performance Report](https://github.com/Ghost-chu/QuickShop-Hikari/issues/new?template=performance.yml&labels=performance).
- For contributions towards the wiki, open a [Wiki Contribution](https://github.com/Ghost-chu/QuickShop-Hikari/issues/new?template=wiki_contribution.yml.yml&labels=wiki).
- Feature requests or other suggestions should be made in the [Discussions](https://github.com/Ghost-chu/QuickShop-Hikari/discussions).
Please fill out all required fields in their entirety and as detailed as possible. Failing to do so could get your issue closed without any warning.
- type: 'textarea'
attributes:
label: 'Description'
description: |-
Describe the bug as detailed as possible.
You cann upload screenshots of the bug in the "screenshots" section further down.
placeholder: 'When I used Quickshop did ... happen.'
validations:
required: true
- type: 'textarea'
attributes:
label: 'Steps to reproduce'
description: 'List your steps on how to reproduce this bug reliably here.'
placeholder: |-
1. Do something
2. ...
3. Bug!
validations:
required: true
- type: 'textarea'
attributes:
label: 'Expected Behaviour'
description: 'What did you expect QuickShop to do?'
placeholder: 'QuickShop should ...'
validations:
required: true
- type: 'textarea'
attributes:
label: 'Screenshots'
description: |-
Provide screenshots to show the bug, if possible.
Gifs or Videos are also welcome if they can help explaining the issue.
placeholder: 'When I used Quickshop did ... happen.'
validations:
required: true
- type: 'input'
attributes:
label: '`/quickshop paste` URL'
description: |-
Please execute `/quickshop paste` in-game or `quickshop paste` in your server console.
The plugin will generate a URL that you can then post in the field below.
If you can't create a paste, should you upload other files such as the `latest.log` file to https://paste.helpch.at and share the URL.
If QuickShop is unable to generate a Paste will it create a file under `plugins/QuickShop/`
placeholder: 'https://paste.helpch.at/...'
validations:
required: true
- type: 'textarea'
attributes:
label: 'Additional Context'
description: 'Feel free to include any info that may not fit any of the previous sections.'
placeholder: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ...'
-16
View File
@@ -1,16 +0,0 @@
blank_issues_enabled: true
contact_links:
- name: 'Development Builds'
about: |-
Bleeding-edge builds with the latest features and bug fixes.
DEV-BUILDS MAY CAUSE DAMAGE TO YOUR SERVER! MAKE BACKUPS FIRST!
url: 'https://ci.codemc.io/job/Ghost-chu/job/QuickShop-Hikari/'
- name: 'Feature Requests'
about: 'Use our discussions page to request changes towards QuickShop.'
url: 'https://github.com/Ghost-chu/QuickShop-Hikari/discussions/categories/ideas'
- name: 'Wiki'
about: 'Find info about QuickShop in our dedicated wiki.'
url: 'https://github.com/Ghost-chu/QuickShop-Hikari/wiki'
- name: 'Discord'
about: 'Join our Discord to ask questions and get fast support.'
url: 'https://discord.gg/Bu3dVtmsD3'
-90
View File
@@ -1,90 +0,0 @@
name: 'Performance Report'
description: 'Report performance issues with QuickShop.'
title: '[PERFORMANCE] '
labels:
- 'Performance Issue'
body:
- type: 'markdown'
attributes:
value: |-
## Please Read!
This Form is reserved for **Performance reports only!**
- For Bugs or issues with QuickShop, open a [Bug Report](https://github.com/Ghost-chu/QuickShop-Hikari/issues/new?template=bug_report.yml&labels=bug).
- For contributions towards the wiki, open a [Wiki Contribution](https://github.com/Ghost-chu/QuickShop-Hikari/issues/new?template=wiki_contribution.yml.yml&labels=wiki).
- Feature requests or other suggestions should be made in the [Discussions](https://github.com/Ghost-chu/QuickShop-Hikari/discussions).
Please fill out all required fields in their entirety and as details as possible. Failing to do so could get your issue closed without any warning.
#### Additional Notes
Please only provide Sampler results from [Spark](https://www.spigotmc.org/resources/57242/)! Spigot Timings - no matter if v1 or v2 - will be ignored.
Your issue will be closed without any reply if only a Spigot Timings Report was provided.
- type: 'textarea'
attributes:
label: 'Description'
description: |-
Describe the issue as detailed as possible.
You cann upload screenshots of the issue in the "screenshots" section further down.
placeholder: 'When I used Quickshop did ... happen.'
validations:
required: true
- type: 'textarea'
attributes:
label: 'Steps to reproduce'
description: 'List your steps on how to reproduce this issue reliably here.'
placeholder: |-
1. Do something
2. ...
3. Bad performance!
validations:
required: true
- type: 'textarea'
attributes:
label: 'Expected Behaviour'
description: 'What did you expect QuickShop to do?'
placeholder: 'QuickShop should ...'
validations:
required: true
- type: 'textarea'
attributes:
label: 'Screenshots'
description: |-
Provide screenshots to show the performance problems, if possible.
Gifs or Videos are also welcome if they can help explaining the issue.
placeholder: 'When I used Quickshop did ... happen.'
validations:
required: true
- type: 'input'
attributes:
label: '`/quickshop paste` URL'
description: |-
Please execute `/quickshop paste` in-game or `qs paste` in your server console.
The plugin will generate a URL that you can then post in the field below.
If you can't create a paste, should you upload other files such as the `latest.log` file to https://paste.helpch.at and share the URL.
If QuickShop is unable to generate a Paste will it create a file under `plugins/QuickShop/`
placeholder: 'https://paste.helpch.at/...'
validations:
required: true
- type: 'input'
attributes:
label: 'Spark Sample URL'
description: |-
**How to use [Spark](https://www.spigotmc.org/resources/57242/)**
1. Download the plugin from the Spigot page (linked above) if you haven't already.
2. Add it to the server like any other plugin (Stop Server, add jar, start server).
3. Join the server and execute `/spark sampler --start`
4. Wait at least 10 minutes and/or perform the actions that cause performance issues with QuickShop.
5. Execute `/spark sampler --stop` to get the URL
6. Paste the URL in the field below.
validations:
required: true
- type: 'textarea'
attributes:
label: 'Additional Context'
description: 'Feel free to include any info that may not fit any of the previous sections.'
placeholder: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ...'
@@ -1,36 +0,0 @@
name: 'Wiki Contribution'
description: 'Inform about a Contribution that you want to make towards the wiki.'
title: '[WIKI] '
labels:
- 'Wiki'
body:
- type: 'markdown'
attributes:
value: |-
## Please Read!
This Form is reserved for **Wiki Contributions only!**
- For Bugs or issues with QuickShop, open a [Bug Report](https://github.com/Ghost-chu/QuickShop-Hikari/issues/new?template=bug_report.yml&labels=bug).
- For performance issues with QuickShop, open a [Performance Report](https://github.com/Ghost-chu/QuickShop-Hikari/issues/new?template=performance.yml&labels=performance).
- Feature requests or other suggestions should be made in the [Discussions](https://github.com/Ghost-chu/QuickShop-Hikari/discussions).
Please fill out all required fields in their entirety and as detailed as possible. Failing to do so could get your issue closed without any warning.
- type: 'input'
attributes:
label: 'Repository URL'
description: 'Provide a URL to your GitHub Repository containing your Wiki changes.'
placeholder: 'https://github.com/example/repo'
validations:
required: true
- type: 'textarea'
attributes:
label: 'Changes'
description: 'Provide a list of all changes you made.'
placeholder: |-
- Changed this.
- Changed that.
- Also changed this!
validations:
required: true
-49
View File
@@ -1,49 +0,0 @@
version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
ignore:
- dependency-name: com.github.ben-manes.caffeine:caffeine
versions:
- "> 2.8.8"
- dependency-name: com.github.TownyAdvanced:Towny
versions:
- "> 0.96.2.0"
- dependency-name: io.sentry:sentry
versions:
- "> 3.1.1"
- dependency-name: net.kyori:adventure-text-serializer-gson
versions:
- "> 4.2.0, < 5"
- dependency-name: net.minidev:json-smart
versions:
- "> 1.3.2"
- dependency-name: net.tnemc:Reserve
versions:
- "> 0.1.3.0"
- dependency-name: org.junit.jupiter:junit-jupiter
versions:
- "> RELEASE"
- dependency-name: org.slf4j:slf4j-nop
versions:
- "> 1.7.6"
- dependency-name: com.massivecraft:Factions
versions:
- 1.6.9.5-2.6.8-STABLE
- dependency-name: com.github.angeschossen:LandsAPI
versions:
- 5.2.1
- 5.2.2
- 5.3.2
- 5.3.3
- 5.5.5
- dependency-name: com.github.seeseemelk:MockBukkit-v1.16
versions:
- 0.25.0
- 0.27.0
- 0.28.0
- 0.32.1
- 0.32.2
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

-4
View File
@@ -1,4 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="71" height="80" fill="none" viewBox="0 0 71 80">
<path fill="#5865F2"
d="M60.1045 13.8978C55.5792 11.8214 50.7265 10.2916 45.6527 9.41542C45.5603 9.39851 45.468 9.44077 45.4204 9.52529C44.7963 10.6353 44.105 12.0834 43.6209 13.2216C38.1637 12.4046 32.7345 12.4046 27.3892 13.2216C26.905 12.0581 26.1886 10.6353 25.5617 9.52529C25.5141 9.44359 25.4218 9.40133 25.3294 9.41542C20.2584 10.2888 15.4057 11.8186 10.8776 13.8978C10.8384 13.9147 10.8048 13.9429 10.7825 13.9795C1.57795 27.7309 -0.943561 41.1443 0.293408 54.3914C0.299005 54.4562 0.335386 54.5182 0.385761 54.5576C6.45866 59.0174 12.3413 61.7249 18.1147 63.5195C18.2071 63.5477 18.305 63.5139 18.3638 63.4378C19.7295 61.5728 20.9469 59.6063 21.9907 57.5383C22.0523 57.4172 21.9935 57.2735 21.8676 57.2256C19.9366 56.4931 18.0979 55.6 16.3292 54.5858C16.1893 54.5041 16.1781 54.304 16.3068 54.2082C16.679 53.9293 17.0513 53.6391 17.4067 53.3461C17.471 53.2926 17.5606 53.2813 17.6362 53.3151C29.2558 58.6202 41.8354 58.6202 53.3179 53.3151C53.3935 53.2785 53.4831 53.2898 53.5502 53.3433C53.9057 53.6363 54.2779 53.9293 54.6529 54.2082C54.7816 54.304 54.7732 54.5041 54.6333 54.5858C52.8646 55.6197 51.0259 56.4931 49.0921 57.2228C48.9662 57.2707 48.9102 57.4172 48.9718 57.5383C50.038 59.6034 51.2554 61.5699 52.5959 63.435C52.6519 63.5139 52.7526 63.5477 52.845 63.5195C58.6464 61.7249 64.529 59.0174 70.6019 54.5576C70.6551 54.5182 70.6887 54.459 70.6943 54.3942C72.1747 39.0791 68.2147 25.7757 60.1968 13.9823C60.1772 13.9429 60.1437 13.9147 60.1045 13.8978ZM23.7259 46.3253C20.2276 46.3253 17.3451 43.1136 17.3451 39.1693C17.3451 35.225 20.1717 32.0133 23.7259 32.0133C27.308 32.0133 30.1626 35.2532 30.1066 39.1693C30.1066 43.1136 27.28 46.3253 23.7259 46.3253ZM47.3178 46.3253C43.8196 46.3253 40.9371 43.1136 40.9371 39.1693C40.9371 35.225 43.7636 32.0133 47.3178 32.0133C50.9 32.0133 53.7545 35.2532 53.6986 39.1693C53.6986 43.1136 50.9 46.3253 47.3178 46.3253Z"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

-121
View File
@@ -1,121 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" id="svg2" width="226" height="312"
version="1.1" xml:space="preserve"><metadata id="metadata8"/>
<defs id="defs6"><clipPath id="clipPath18" clipPathUnits="userSpaceOnUse"><path id="path20" d="M 0,2494.84 0,0 l 1804.34,0 0,2494.84 -1804.34,0 z"/></clipPath></defs>
<g id="g10" transform="matrix(1.25,0,0,-1.25,0,312)"><g id="g3393"><path style="fill:#d33833;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path22" d="m 177.718,129.264 c 0,-49.4288 -39.175,-89.4992 -87.5,-89.4992 -48.3242,0 -87.49925,40.0704 -87.49925,89.4992 0,49.43 39.17505,89.501 87.49925,89.501 48.325,0 87.5,-40.071 87.5,-89.501"/><path
style="fill:#ef3d3a;fill-opacity:1;fill-rule:nonzero;stroke:none" id="path24"
d="m 6.28438,107.098 c 0,0 -6.33438,93.333 79.66602,96 l -5.9996,10 -46.6664,-15.667 -13.3336,-15.333 -11.66642,-22.334 -6.66719,-26 2,-17.333"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:none" id="path26"
d="M 30.2883,190.319 C 14.9363,174.611 5.43633,152.923 5.43633,128.93 l 0,0 c 0,-23.988 9.49997,-45.6788 24.85197,-61.3839 l 0,0 C 45.6477,51.841 66.8152,42.15 90.2168,42.15 l 0,0 c 23.4022,0 44.5712,9.691 59.9292,25.3961 l 0,0 c 15.351,15.7051 24.853,37.3959 24.853,61.3839 l 0,0 c 0,23.993 -9.502,45.681 -24.853,61.389 l 0,0 c -15.358,15.702 -36.527,25.393 -59.9292,25.395 l 0,0 C 66.8152,215.712 45.6477,206.021 30.2883,190.319 l 0,0 z M 26.4023,63.7469 C 10.0867,80.4328 0,103.493 0,128.93 l 0,0 c 0,25.441 10.0867,48.499 26.4023,65.186 l 0,0 c 16.3118,16.69 38.8915,27.035 63.8145,27.032 l 0,0 c 24.9232,0.003 47.5052,-10.342 63.8142,-27.032 l 0,0 c 16.317,-16.687 26.405,-39.747 26.403,-65.186 l 0,0 c 0.002,-25.437 -10.086,-48.4972 -26.403,-65.1831 l 0,0 C 137.722,47.0578 115.14,36.7141 90.2168,36.7141 l 0,0 c -24.923,0 -47.5027,10.3437 -63.8145,27.0328 l 0,0"/><path
style="fill:#f0d6b7;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path28"
d="m 127.051,128.768 -13.334,-2 -18.0002,-2 -11.6672,-0.333 -11.3328,0.333 -8.6672,2.667 -7.6668,8.333 -6,17 -1.3332,3.667 -8,2.666 -4.6668,7.667 -3.3332,11 3.6672,9.667 8.666,3 7,-3.334 3.334,-7.333 4,0.667 1.3328,1.666 -1.3328,7.667 -0.334,9.667 2,13.333 -0.0781,7.616 6.0781,9.717 10.6668,7.667 18.6672,8 20.6662,-3 18,-13 8.334,-13.333 5.333,-9.667 1.333,-24 -4,-20.667 -7.333,-18.333 -7,-9.667"/><path
style="fill:#335061;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path30"
d="m 115.717,71.102 -47.6674,-2 0,-8 4,-28 -2,-2.334 -33.3328,11.334 -2.334,4 -3.3332,37.666 -7.6656,22.667 -1.6672,5.333 26.666,18.333 8.334,3.334 7.3328,-9 6.3332,-5.667 7.334,-2.333 3.3328,-1 4,-17.333 3,-3.6668 7.6672,2.6668 -5.334,-10.334 29.0002,-13.666 -3.666,-2"/><path
style="fill:#6d6b6d;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path32"
d="m 36.7168,187.435 8.666,3 7,-3.334 3.334,-7.333 4,0.667 1,4 -2,7.666 2,18.334 -1.6672,10 6,7 13,10.333 -3.6668,5 -18.3332,-9 -7.6668,-6 -4.3332,-9.333 -6.6668,-9 -2,-10.667 1.334,-11.333"/><path
style="fill:#dcd9d8;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path34"
d="m 50.3828,218.768 c 0,0 5,12.333 25,18.333 20,6 1,4.334 1,4.334 l -21.666,-8.334 -8.334,-8.333 -3.666,-6.667 7.666,0.667"/><path
style="fill:#dcd9d8;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path36"
d="m 40.3828,189.768 c 0,0 -7,23.334 19.6668,26.667 l -1,4 -18.3328,-4.334 -5.334,-17.333 1.334,-11.333 3.666,2.333"/><path
style="fill:#f7e4cd;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path38"
d="m 51.0496,158.768 4.3645,4.229 c 0,0 1.9699,-0.229 2.3027,-2.562 0.3328,-2.334 1.3328,-23.334 15.666,-34.668 1.3074,-1.034 -10.666,1.668 -10.666,1.668 l -10.6672,16.666"/><path
style="fill:#f7e4cd;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path40"
d="m 112.385,165.101 c 0,0 0.777,10.104 3.498,9.327 2.721,-0.777 2.721,-3.498 2.721,-3.498 0,0 -6.608,-4.275 -6.219,-5.829"/><path
style="fill:#f7e4cd;fill-opacity:1;fill-rule:nonzero;stroke:none" id="path42"
d="m 140.05,202.101 c 0,0 -5.494,-1.16 -6,-6 -0.506,-4.841 6,-1 7,-0.667"/><path
style="fill:#f7e4cd;fill-opacity:1;fill-rule:nonzero;stroke:none" id="path44"
d="m 99.7168,201.767 c 0,0 -7.334,-1 -7.334,-5.666 0,-4.667 8.3342,-4.334 10.6672,-2.334"/><path
style="fill:#f7e4cd;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path46"
d="m 54.3828,180.101 c 0,0 -12.6672,7.667 -14,0.333 -1.3332,-7.333 -4.334,-12.667 2,-20.333 l -4.3332,1.333 -4,10.333 -1.3328,10 7.666,8.001 8.6668,-0.667 5,-4 0.3332,-5"/><path
style="fill:#f7e4cd;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path48"
d="m 60.3828,201.101 c 0,0 5.6668,29.333 34.334,35 23.6012,4.665 35.9992,-1 40.6662,-6.333 0,0 -21,24.999 -41.0002,17.333 -20,-7.667 -34.666,-21.667 -34.3332,-30.666 0.5676,-15.328 0.3332,-15.334 0.3332,-15.334"/><path
style="fill:#f7e4cd;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path50"
d="m 137.717,226.435 c 0,0 -9.666,0.333 -10,-8.334 0,0 -0.001,-1.333 0.666,-2.666 0,0 7.668,8.667 12.334,4"/><path
style="fill:#f7e4cd;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path52"
d="m 95.3887,214.532 c 0,0 -1.6641,13.303 -13.0059,5.569 -7.3332,-5 -6.666,-12 -5.3332,-13.333 1.3332,-1.334 0.9707,-4.019 1.9856,-2.176 1.0144,1.843 0.6804,7.843 4.3476,9.509 3.6668,1.667 9.6777,3.529 12.0059,0.431"/><path
style="fill:#49728b;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path54"
d="m 64.0496,124.435 -31.3328,-14 c 0,0 13,-51.667 6.3328,-67.667 l -4.6668,1.666 -0.3332,19.6672 -8.6656,37.3328 -3.6672,10.334 32.666,21.999 9.6668,-9.332"/><path
style="fill:#49728b;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path56"
d="m 67.2715,95.8578 4.4453,-5.4238 0,-20 -5.334,0 c 0,0 -0.666,14 -0.666,15.6672 0,1.6668 0.666,7.6668 0.666,7.6668"/><path
style="fill:#49728b;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path58"
d="m 67.3828,67.434 -15,-0.666 4.334,-3 10.666,-1.6668"/><path
style="fill:#335061;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path60"
d="m 118.717,70.768 12.333,0.3332 3,-30.6672 -12.667,-1.666 -2.666,32"/><path
style="fill:#335061;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path62"
d="m 122.05,70.768 18.667,1 c 0,0 7.666,19.3332 7.666,20.3332 0,1 6.667,27.9998 6.667,27.9998 l -15,15.666 -3,2.667 -8,-8 0,-31 -7,-28.666"/><path
style="fill:#49728b;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path64"
d="m 130.383,73.1012 -11.666,-2.3332 1.666,-9.334 c 4.333,-2 11.667,3.334 11.667,3.334"/><path
style="fill:#49728b;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path66"
d="m 130.717,131.434 23.333,-17.333 0.667,8 -17.667,16.333 -6.333,-7"/><path
style="fill:#fff;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path68"
d="M 78.9508,5.09805 72.0496,33.102 68.6172,53.7648 68.0496,69.102 l 31.2348,1.6628 19.4326,0.0032 -1.767,-35.0032 3,-26.99996 -0.333,-5 -25.3326,-2 -15.3336,3.33321"/><path
style="fill:#dcd9d8;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path70"
d="m 114.383,71.1012 c 0,0 -1.666,-34.6672 3.334,-59.3332 0,0 -10,-6.33402 -24.6674,-8.00003 l 28.0004,1 3.333,2 -4,54.66603 -1,11.668"/><path
style="fill:#fff;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path72"
d="m 134.618,43.098 13,3.6668 24.666,1.3332 3.667,11.3329 -6.667,19.6671 -7.666,1 -10.667,-3.3332 -10.234,-4.9968 -5.433,0.9968 -4.234,-1.6636"/><path
style="fill:#dcd9d8;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path74"
d="m 134.383,49.768 c 0,0 8.666,3.9992 10,3.666 l -3.666,18.334 4.333,1.666 c 0,0 3,-17.3328 3,-19.3328 0,0 18.666,-1 20.333,-1 0,0 4,7.6668 3,15.6668 l 3.667,-10.6668 0.333,-6 -5.333,-8 -6,-1.3332 -10,0.3332 -3.333,4.3328 -11.667,-1.666 -3.667,-1.334"/><path
style="fill:#fff;fill-opacity:1;fill-rule:nonzero;stroke:none" id="path76"
d="m 121.284,73.4309 -7.333,18.6671 -7.667,11 c 0,0 1.666,4.667 4,4.667 2.334,0 7.667,0 7.667,0 l 7.333,-2.667 -0.666,-12.3332 -3.334,-19.3339"/><path
style="fill:#dcd9d8;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path78"
d="m 122.717,79.768 c 0,0 -9.334,17.9992 -9.334,20.666 0,0 1.666,4 4,3 2.334,-1 7.334,-3.666 7.334,-3.666 l 0,6.333 -11.334,2.334 -7.666,-1 13,-30.667 2.666,-0.334"/><path
style="fill:#fff;fill-opacity:1;fill-rule:nonzero;stroke:none" id="path80"
d="m 81.9512,123.764 -9.2344,1.004 -8.6672,2.667 0,-3 4.2348,-4.67 13.3332,-6"/><path
style="fill:#dcd9d8;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path82"
d="m 67.0508,122.765 c 0,0 10.334,-4.334 13.6672,-3.334 l 0.3316,-3.996 -9.3316,1.996 -5.6672,4 1,1.334"/><path
style="fill:#d33833;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path84"
d="m 134.582,106.63 c -5.656,0.166 -10.766,0.838 -15.24,2.1 0.304,1.834 -0.265,3.634 0.192,4.955 1.247,0.898 3.337,0.884 5.222,1.095 -1.63,0.801 -3.92,1.118 -5.801,0.655 -0.044,1.273 -0.615,2.062 -0.961,3.058 3.18,1.135 10.687,8.576 14.91,6.112 2.012,-1.172 2.867,-7.866 3.023,-11.121 0.13,-2.7 -0.245,-5.424 -1.345,-6.854"/><path
style="fill:none;stroke:#d33833;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path86"
d="m 134.582,106.63 c -5.656,0.166 -10.766,0.838 -15.24,2.1 0.304,1.834 -0.265,3.634 0.192,4.955 1.247,0.898 3.337,0.884 5.222,1.095 -1.63,0.801 -3.92,1.118 -5.801,0.655 -0.044,1.273 -0.615,2.062 -0.961,3.058 3.18,1.135 10.687,8.576 14.91,6.112 2.012,-1.172 2.867,-7.866 3.023,-11.121 0.13,-2.7 -0.245,-5.424 -1.345,-6.854 z"/><path
style="fill:#d33833;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path88"
d="m 107.535,115.876 c -0.015,-0.428 -0.033,-0.859 -0.05,-1.291 -1.766,-1.16 -4.617,-1.146 -6.555,-2.121 2.857,-0.125 5.106,-0.813 7.052,-1.783 -0.043,-1.078 -0.084,-2.155 -0.126,-3.233 -3.237,-2.216 -6.194,-5.516 -10.0052,-7.5941 -1.802,-0.9828 -8.1262,-3.5117 -10.0434,-3.0648 -1.0847,0.2519 -1.1824,1.598 -1.616,2.8668 -0.9238,2.7171 -3.0508,7.0421 -3.2363,11.1321 -0.2363,5.166 -0.7578,13.824 4.8094,12.76 4.4914,-0.857 9.7152,-2.926 13.1925,-4.826 2.125,-1.162 3.354,-2.598 6.578,-2.846"/><path
style="fill:none;stroke:#d33833;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path90"
d="m 107.535,115.876 c -0.015,-0.428 -0.033,-0.859 -0.05,-1.291 -1.766,-1.16 -4.617,-1.146 -6.555,-2.121 2.857,-0.125 5.106,-0.813 7.052,-1.783 -0.043,-1.078 -0.084,-2.155 -0.126,-3.233 -3.237,-2.216 -6.194,-5.516 -10.0052,-7.5941 -1.802,-0.9828 -8.1262,-3.5117 -10.0434,-3.0648 -1.0847,0.2519 -1.1824,1.598 -1.616,2.8668 -0.9238,2.7171 -3.0508,7.0421 -3.2363,11.1321 -0.2363,5.166 -0.7578,13.824 4.8094,12.76 4.4914,-0.857 9.7152,-2.926 13.1925,-4.826 2.125,-1.162 3.354,-2.598 6.578,-2.846 z"/><path
style="fill:#d33833;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path92"
d="m 110.75,109.712 c -0.494,2.814 -1.065,3.617 -0.844,6.072 7.505,5.004 8.914,-8.595 0.844,-6.072"/><path
style="fill:none;stroke:#d33833;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path94"
d="m 110.75,109.712 c -0.494,2.814 -1.065,3.617 -0.844,6.072 7.505,5.004 8.914,-8.595 0.844,-6.072 z"/><path
style="fill:#ef3d3a;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path96"
d="m 121.617,107.431 c 0,0 -2.334,3.334 -0.667,4.334 1.667,1 3.334,-0.001 4.334,1.666 1,1.667 0,2.667 0.333,4.667 0.333,2 2.001,2.334 3.667,2.667 1.666,0.333 6.334,1 7,-0.667 l -2,6 -4,1.333 -12.667,-7.333 -0.667,-3.667 0,-7.333"/><path
style="fill:#ef3d3a;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path98"
d="m 86.6172,96.4309 c -0.4004,5.2021 -0.8242,10.3971 -1.2957,15.5941 -0.7055,7.76 1.864,6.406 8.5906,6.406 1.0274,0 6.3259,-1.225 6.7049,-2 1.818,-3.713 -3.04,-2.888 2.094,-5.688 4.334,-2.363 11.99,1.435 10.239,6.688 -0.98,1.168 -5.106,0.364 -6.585,1.131 -2.604,1.35 -5.208,2.7 -7.8123,4.05 -3.3132,1.719 -10.9707,4.225 -14.5031,1.823 -8.9504,-6.087 0.5649,-21.296 3.7578,-27.6459"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path100"
d="m 95.3887,214.532 c -9.0852,2.116 -13.5996,-3.802 -16.3535,-9.94 -2.459,0.596 -1.4805,3.94 -0.8594,5.644 1.6262,4.472 8.1797,10.425 13.5344,9.618 2.3043,-0.347 5.4226,-2.454 3.6785,-5.322"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path102"
d="m 139.655,204.186 c 0.143,-0.006 0.288,-0.011 0.431,-0.017 2.053,-4.265 3.83,-8.783 6.42,-12.548 -1.735,-4.041 -13.138,-7.617 -12.962,-0.361 2.466,1.078 6.723,0.22 8.909,1.597 -1.264,3.469 -3.088,6.422 -2.798,11.329"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path104"
d="m 100.04,204.075 c 1.948,-3.571 2.582,-7.323 5.351,-10.022 1.247,-1.215 3.672,-2.696 2.47,-6.075 -0.281,-0.797 -2.334,-2.574 -3.519,-2.923 -4.329,-1.278 -14.4162,-0.264 -11.0002,5.133 3.5801,-0.167 8.3922,-2.325 11.0682,0.274 -2.055,3.285 -5.7186,9.784 -4.37,13.613"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path106"
d="m 138.03,167.781 c -6.518,-4.187 -13.786,-8.74 -24.466,-7.684 -2.282,1.984 -3.152,6.399 -0.935,9.315 1.154,-1.984 0.429,-5.633 3.645,-6.182 6.06,-1.037 13.113,3.707 17.472,5.365 2.703,4.557 -0.233,6.233 -2.668,9.166 -4.985,6.009 -11.672,13.457 -11.429,22.453 2.015,1.461 2.189,-2.23 2.478,-2.902 2.603,-6.092 9.154,-13.883 13.935,-19.097 1.174,-1.284 3.107,-2.516 3.322,-3.365 0.62,-2.469 -1.613,-5.427 -1.354,-7.069"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path108"
d="m 52.1016,172.189 c -2.043,1.166 -2.5293,6.302 -4.9278,6.448 -3.4277,0.208 -2.8027,-6.663 -2.789,-10.681 -2.3594,2.142 -2.7743,8.737 -1.041,12.124 -1.9754,0.97 -2.8575,-1.07 -3.9532,-1.789 1.4082,10.23 14.9649,4.745 12.711,-6.102"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path110"
d="m 142.18,163.521 c -3.034,-5.775 -7.326,-12.135 -16.229,-12.32 -0.181,1.865 -0.32,4.703 0.01,5.826 6.806,0.654 11.008,4.118 16.219,6.494"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path112"
d="m 99.5266,159.777 c 5.6784,-2.986 16.1144,-3.307 23.8324,-3.081 0.414,-1.691 0.404,-3.78 0.42,-5.842 -9.921,-0.495 -21.651,1.96 -24.2524,8.923"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path114"
d="m 98.4473,154.209 c 3.9267,-9.859 17.4227,-8.724 28.8037,-8.452 -0.501,-1.28 -1.587,-2.792 -2.937,-3.339 -3.647,-1.484 -13.706,-2.61 -18.769,0.079 -3.211,1.707 -5.274,5.564 -7.0333,7.825 -0.8496,1.092 -5.0801,3.881 -0.0644,3.887"/><path
style="fill:#81b0c4;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path116"
d="m 137.556,99.8262 c -4.608,-7.8922 -9.017,-15.9981 -14.484,-22.9594 2.292,6.7391 3.273,18.0184 3.619,26.6172 4.795,2.244 8.901,-0.505 10.865,-3.6578"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path118"
d="m 162.352,71.4609 c -5.159,-1.0328 -8.784,-6.0468 -13.817,-5.725 2.766,3.8993 7.613,5.543 13.817,5.725"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path120"
d="m 164.628,63.3871 c -4.205,-0.4441 -9.144,-1.125 -13.409,-0.7742 2.019,3.084 9.798,2.0199 13.409,0.7742"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path122"
d="m 166.085,56.4262 c -4.726,-0.1024 -10.6,-0.0082 -15.092,0.3687 2.657,2.8539 12.027,1.059 15.092,-0.3687"/><path
style="fill:#dcd9d8;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path124"
d="m 128.664,37.377 c 0.678,-5.9352 3.031,-11.9489 2.736,-18.4489 -2.613,-0.8812 -4.114,-1.6519 -7.615,-1.6472 -0.247,5.5242 -0.986,13.9691 -0.765,19.2351 1.722,-0.114 4.261,1.2301 5.644,0.861"/><path
style="fill:#f0d6b7;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path126"
d="m 121.045,124.849 c -2.373,-1.549 -4.394,-3.483 -6.673,-5.137 -5.054,-0.25 -7.812,0.35 -11.525,3.252 0.061,0.233 0.434,0.129 0.448,0.415 5.41,-2.411 12.287,0.982 17.75,1.47"/><path
style="fill:#81b0c4;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path128"
d="m 92.6445,87.9711 c 1.4864,6.441 7.3106,9.7769 12.5995,13.3239 5.459,-6.9282 8.779,-15.838 12.435,-24.436 -8.638,2.6039 -17.464,6.8289 -25.0345,11.1121"/><path
style="fill:#231f20;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path130"
d="m 123.02,36.516 c -0.221,-5.266 0.518,-13.7109 0.765,-19.2351 3.501,-0.0047 5.002,0.766 7.615,1.6472 0.295,6.5 -2.058,12.5137 -2.736,18.4489 -1.383,0.3691 -3.922,-0.975 -5.644,-0.861 z M 68.5059,66.4648 C 70.8145,45.2418 74.1582,27.4012 80.291,8.60781 93.9023,4.475 110.311,4.11484 122.342,7.84414 120.133,18.4512 121.098,31.3648 119.807,42.684 c -0.973,8.5078 -0.477,17.068 -1.811,25.748 -14.578,3.0328 -35.1835,0.709 -49.4901,-1.9672 z m 52.9371,1.834 c -0.123,-9.1148 0.408,-18.1058 1.104,-27.232 3.5,0.5254 5.875,0.8762 9.127,1.5891 -1.056,8.7859 -0.926,18.6722 -3.077,26.4441 -2.486,-0.0238 -4.675,0.0289 -7.154,-0.8012 z m 17.755,1.4692 c -1.661,0.3808 -3.595,0.0148 -5.182,-0.016 0.746,-7.4301 2.556,-15.629 3.193,-23.4282 2.497,-0.0777 3.831,1.1 5.885,1.4961 0.11,6.8461 -0.598,16.2781 -3.896,21.9481 z m 26.884,-24.5629 c 5.205,1.264 8.478,7.639 7.022,14.1859 -0.977,4.4 -2.717,12.6852 -4.579,15.5 -1.376,2.082 -5.107,4.8078 -8.086,2.9 -4.846,-3.1031 -13.383,-4.0039 -16.917,-7.7601 1.772,-5.9 2.322,-14.0039 3.053,-21.4797 6.054,-0.3774 13.503,1.666 18.538,-0.5024 -3.515,-1.1386 -8.076,-1.1476 -11.113,-2.807 2.482,-1.1988 8.293,-0.9566 12.082,-0.0367 z M 117.679,76.859 c -3.656,8.598 -6.976,17.5078 -12.435,24.436 C 99.9551,97.748 94.1309,94.4121 92.6445,87.9711 100.215,83.6879 109.041,79.4629 117.679,76.859 z m 9.012,26.625 c -0.346,-8.5988 -1.327,-19.8781 -3.619,-26.6172 5.467,6.9613 9.876,15.0672 14.484,22.9594 -1.964,3.1528 -6.07,5.9018 -10.865,3.6578 z m -10.216,3.63 c -2.071,0.223 -3.829,-2.381 -6.522,-1.255 -0.617,-0.682 -1.178,-1.421 -1.807,-2.087 5.948,-7.1681 8.651,-17.338 13.245,-25.7618 2.465,8.0918 2.181,16.957 2.724,25.7888 -3.387,-0.215 -5.266,3.063 -7.64,3.315 z m -6.569,8.67 c -0.221,-2.455 0.35,-3.258 0.844,-6.072 8.07,-2.523 6.661,11.076 -0.844,6.072 z m -8.949,2.938 c -3.4773,1.9 -8.7011,3.969 -13.1925,4.826 -5.5672,1.065 -5.0457,-7.594 -4.8094,-12.76 0.1855,-4.09 2.3125,-8.415 3.2363,-11.1321 0.4336,-1.2688 0.5313,-2.6149 1.616,-2.8668 1.9172,-0.4469 8.2414,2.082 10.0434,3.0648 3.8112,2.0781 6.7682,5.3781 10.0052,7.5941 0.042,1.078 0.083,2.155 0.126,3.233 -1.946,0.97 -4.195,1.658 -7.052,1.783 1.938,0.975 4.789,0.961 6.555,2.121 0.017,0.432 0.035,0.863 0.05,1.291 -3.224,0.248 -4.453,1.684 -6.578,2.846 z m -33.2136,6.033 c -2.886,-2.93 8.0945,-6.924 11.5906,-7.139 -0.0195,1.854 1.0566,3.602 0.8398,4.932 -4.1523,0.729 -9.6093,0.248 -12.4304,2.207 z m 35.5516,-1.376 c -0.014,-0.286 -0.387,-0.182 -0.448,-0.415 3.713,-2.902 6.471,-3.502 11.525,-3.252 2.279,1.654 4.3,3.588 6.673,5.137 -5.463,-0.488 -12.34,-3.881 -17.75,-1.47 z m 32.632,-9.895 c -0.156,3.255 -1.011,9.949 -3.023,11.121 -4.223,2.465 -11.73,-4.977 -14.91,-6.112 0.346,-0.996 0.917,-1.785 0.961,-3.058 1.881,0.463 4.171,0.146 5.801,-0.655 -1.885,-0.211 -3.975,-0.197 -5.222,-1.095 -0.457,-1.321 0.112,-3.121 -0.192,-4.955 4.474,-1.262 9.584,-1.934 15.24,-2.1 1.1,1.43 1.475,4.154 1.345,6.854 z m -73.0422,8.437 c -0.9063,0.646 -7.0371,8.623 -7.877,8.292 C 43.9141,125.838 33.541,118.273 24.2715,111.118 33.1094,92.1539 36.677,68.9199 37.3074,46.5262 47.4316,41.791 56.3242,34.9648 70.0625,34.252 68.4727,45.5 67.0215,55.5352 66.1191,66.125 c -3.4519,1.4551 -8.4043,-0.066 -11.6347,0.4512 -0.0274,3.8929 4.9336,1.7047 5.3468,4.3226 0.3114,1.9801 -2.7296,2.1301 -1.7394,5.2481 2.5254,-0.918 3.8516,-2.9457 6.5449,-3.7071 2.461,5.384 -0.0344,14.9102 0.3203,19.4102 0.0672,0.8449 0.4219,4.6809 2.3145,4.0078 1.675,-0.5957 -0.0957,-10.2019 0.0879,-14.4609 0.1672,-3.9239 -0.4739,-7.7207 1.1152,-10.184 13.2754,1.807 26.7656,2.975 41.1294,3.3691 -3.16,1.3559 -6.914,2.6391 -11.0298,4.959 -2.2312,1.2578 -9.2644,3.875 -9.9082,5.9942 -1.0273,3.3769 2.6953,5.1757 3.332,8.0707 -6.7011,-3.6547 -8.0085,3.5031 -9.5937,8.5741 -1.4363,4.593 -2.2539,8.024 -2.6063,10.673 -5.7726,2.752 -11.9445,5.539 -16.9132,9.068 z m 67.1792,7.327 c 9.243,4.482 10.909,-16.751 7.286,-23.591 0.56,-2.04 2.486,-2.821 3.272,-4.655 -5.158,-9.2399 -10.887,-17.8649 -16.15,-26.9961 3.915,2.4371 9.507,0.4359 14.114,2.2601 1.684,0.666 2.903,4.5211 4.178,7.6051 3.507,8.4848 7.189,19.1819 8.827,27.2789 0.37,1.845 1.378,5.865 1.152,7.507 -0.403,2.94 -4.392,5.12 -6.421,6.938 -3.738,3.358 -6.092,6.313 -9.991,9.453 -1.581,-2.334 -4.974,-3.902 -6.267,-5.8 z m -88.3179,81.968 c -4.4043,-4.846 -3.4824,-13.926 -2.9492,-20.386 7.9609,5.008 18.5273,-0.396 18.4277,-8.914 3.8008,0.101 1.4199,4.747 0.7324,7.74 -2.2468,9.776 3.7852,20.397 0.2735,29.337 -6.8184,-0.517 -12.42,-3.302 -16.4844,-7.777 z m 31.5137,28.126 c -9.9707,-2.826 -22.7493,-10.071 -26.8465,-19.028 3.1726,0.461 5.375,2.061 8.5047,2.259 1.1828,0.077 2.7324,-0.496 4.0918,-0.158 2.709,0.672 4.9953,6.746 7.039,9.006 1.9922,2.207 4.3867,3.15 6.0254,5.162 1.0528,0.508 2.6094,0.473 2.6692,2.054 -0.4563,0.488 -0.9368,0.86 -1.4836,0.705 z m 51.9032,-2.658 c -10.349,5.839 -27.8661,10.231 -38.8747,4.743 -8.8828,-4.429 -20.8899,-11.757 -24.9836,-21.043 3.8242,-8.961 -1.1328,-17.172 -1.4492,-26.27 -0.168,-4.841 2.2793,-9.067 2.4668,-14.337 -1.3086Line truncated
style="fill:#f7e4cd;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path132"
d="m 90.491,157.255 c 0.4387,0.584 2.8508,1.471 6.2258,-0.154 0,0 -4,-0.667 -3.6672,-7.336 l -1.6668,0.334 c 0,0 -1.7226,6.047 -0.8918,7.156"/><path
style="fill:#1d1919;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path134"
d="m 119.717,99.934 c 0,-1.0121 -0.821,-1.8328 -1.834,-1.8328 -1.012,0 -1.833,0.8207 -1.833,1.8328 0,1.012 0.821,1.834 1.833,1.834 1.013,0 1.834,-0.822 1.834,-1.834"/><path
style="fill:#1d1919;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path136"
d="m 121.55,91.434 c 0,-1.0121 -0.821,-1.8328 -1.834,-1.8328 -1.012,0 -1.833,0.8207 -1.833,1.8328 0,1.0121 0.821,1.834 1.833,1.834 1.013,0 1.834,-0.8219 1.834,-1.834"/></g></g></svg>

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

-4
View File
@@ -1,4 +0,0 @@
label-alias:
bug: 'Bug'
feature_request: 'Enhancement'
question: 'Question'
-5
View File
@@ -1,5 +0,0 @@
# Number of labels to fetch (optional). Defaults to 20
numLabels: 40
# These labels will not be used even if the issue contains them
excludeLabels:
- pinned
-26
View File
@@ -1,26 +0,0 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- '*'
- 'hikari'
- 'release'
jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2023.2
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
-33
View File
@@ -1,33 +0,0 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Maven CI
on:
push:
branches: [ hikari, cleanup ]
pull_request:
branches: [ hikari, cleanup ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Build with Maven
run: mvn package --batch-mode --update-snapshots -T 1.5C -f pom.xml -P github
- uses: actions/upload-artifact@v3
with:
name: quickshop-snapshots
path: |
**/target/*.jar
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
-99
View File
@@ -1,99 +0,0 @@
# 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: mc-publish
on:
workflow_dispatch:
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package -T 1.5C --file pom.xml
- uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: ijC5dDkD
modrinth-featured: true
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-discussion: Announcements
github-token: ${{ secrets.GITHUB_TOKEN }}
github-draft: false
files: |
quickshop-bukkit/target/QuickShop-Hikari-*.jar
**/target/+(Compat*|Addon*).jar
loaders: |
spigot
paper
purpur
game-versions: |
>=1.18.2 <=1.20.4
game-version-filter: releases
java: |
17
dependencies: |
essentialsx(optional)
nbtapi(optional)
discordsrv(optional)
bluemap(optional)
dynmap(optional)
worldedit(optional)
worldguard(optional)
plan(optional)
bentobox(optional)
clearlag(optional)
elitemobs(optional)
griefprevention(optional)
lands(optional)
openinv(optional)
placeholderapi(optional)
residence(optional)
towny(optional)
superiorskyblock(optional)
luckperms(optional)
vault(optional)
plan(optional)
advancedregionmarket(optional)
ecoenchants(optional)
reforges(optional)
packetlistenerapi(conflicting)
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
- name: Build Translations
uses: Ghost-chu/CrowdinCopyDeploy-action@master
with:
args: uploads3
env:
CROWDIN_ACCESS_TOKEN: ${{ secrets.CROWDIN_ACCESS_TOKEN }}
CROWDIN_PROJECT_BRANCH_ID: '126'
CROWDIN_PROJECT_ID: '524354'
#DEPLOY_PATH: './deploy-prod'
AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: auto
- name: Purge CloudFlare cache
uses: jakejarvis/cloudflare-purge-action@master
env:
# Zone is required by both authentication methods
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
-36
View File
@@ -1,36 +0,0 @@
name: ota-distribution
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# - uses: actions/checkout@v3
# - name: Set up JDK 17
# uses: actions/setup-java@v3
# with:
# java-version: '17'
# distribution: 'temurin'
- name: Build Translations
uses: Ghost-chu/CrowdinCopyDeploy-action@master
with:
args: uploads3
env:
CROWDIN_ACCESS_TOKEN: ${{ secrets.CROWDIN_ACCESS_TOKEN }}
CROWDIN_PROJECT_BRANCH_ID: '126'
CROWDIN_PROJECT_ID: '524354'
#DEPLOY_PATH: './deploy-prod'
AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: auto
- name: Purge CloudFlare cache
uses: jakejarvis/cloudflare-purge-action@master
env:
# Zone is required by both authentication methods
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
+9 -1
View File
@@ -8,6 +8,11 @@
# IntelliJ
out/
# Eclipse
.classpath
.project
.settings/
# Compiled class file
*.class
@@ -95,7 +100,8 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
target/
bin/
build/
pom.xml.tag
pom.xml.releaseBackup
@@ -113,3 +119,5 @@ buildNumber.properties
run/
/build-artifacts/
/.vscode/settings.json
/.gradle/
/build/
+3
View File
@@ -0,0 +1,3 @@
[submodule "libs/Utilities-OG"]
path = libs/Utilities-OG
url = https://github.com/true-og/Utilities-OG
-10
View File
@@ -1,10 +0,0 @@
pull_request_rules:
- name: Automatic merge on Crowdin
conditions:
- and:
- author=Ghost-chu
- title=New Crowdin updates
actions:
merge:
method: squash
commit_message_template: "Automatically merge Crowdin translations"
-19
View File
@@ -1,19 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
+3 -47
View File
@@ -1,11 +1,5 @@
<!-- Links -->
[codacy]: https://www.codacy.com/gh/Ghost-chu/QuickShop-Hikari/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Ghost-chu/QuickShop-Hikari&amp;utm_campaign=Badge_Grade
[codeFactor]: https://www.codefactor.io/repository/github/ghost-chu/quickshop-hikari
[codeScore]: https://app.codiga.io/public/project/32011/QuickShop-Hikari/dashboard
[license]: https://github.com/Ghost-chu/QuickShop-Hikari/blob/hikari/LICENSE
[contributors]: https://github.com/Ghost-chu/QuickShop-Hikari/graphs/contributors
@@ -22,8 +16,6 @@
[quickshop-original]: https://github.com/KaiKikuchi/QuickShop
[codemc]: https://ci.codemc.io/job/Ghost-chu/job/QuickShop-Hikari/
[clearlagg]: https://www.spigotmc.org/resources/68271/
[worldguard]: https://dev.bukkit.org/projects/worldguard
@@ -36,28 +28,16 @@
[optional_modules]: https://ci.codemc.io/job/Ghost-chu/job/QuickShop-Hikari/
[googlejava]: https://google.github.io/styleguide/javaguide.html
[adoptium]: https://adoptium.net/
[bStats-site]: https://bstats.org
[bStats-plugin]: https://bstats.org/plugin/bukkit/QuickShop-Hikari/14281
<!-- Images/Badges -->
[codacyBadge]: https://app.codacy.com/project/badge/Grade/a04ef7174d9f4e65b60ae28b09222809
[codeFactorBadge]: https://www.codefactor.io/repository/github/ghost-chu/quickshop-hikari/badge
[codeScoreBadge]: https://api.codiga.io/project/32011/score/svg
[licenseBadge]: https://img.shields.io/github/license/Ghost-chu/QuickShop-Hikari.svg
[contributorsBadge]: https://img.shields.io/github/contributors/Ghost-chu/QuickShop-Hikari
[passedTests]: https://img.shields.io/jenkins/tests?compact_message&jobUrl=https://ci.codemc.io/job/Ghost-chu/job/QuickShop-Hikari
[fossaStatusBadge]: https://app.fossa.com/api/projects/git%2Bgithub.com%2FGhost-chu%2FQuickShop-Hikari.svg?type=shield
[fossaStatusImageLarge]: https://app.fossa.com/api/projects/git%2Bgithub.com%2FGhost-chu%2FQuickShop-Hikari.svg?type=large
@@ -70,16 +50,9 @@
[Ver]: https://img.shields.io/spiget/version/100125?label=version
<!-- Unused? -->
<!-- [//]: # (![Downloads]&#40;https://img.shields.io/spiget/downloads/62575?label=downloads&#41;) -->
<!-- [//]: # (![Rating]&#40;https://img.shields.io/spiget/rating/62575?label=rating&#41;) -->
<!-- Start of README -->
# QuickShop-OG
# QuickShop-Hikari
[![codacyBadge]][codacy]
[![codeScoreBadge]][codeScore]
[![licenseBadge]][license]
[![contributorsBadge]][contributors]
![passedTests]
@@ -91,23 +64,17 @@
## Introduction
QuickShop Hikari is a Shop plugin that allows players to create Chest Shops to easily sell and buy items, without the
QuickShop-OG is a GPLv3 based fork of QuickShop Hikari maintained by [TrueOG Network](https://trueog.net) for Purpur 1.19.4. QuickShop Hikari is a Shop plugin that allows players to create Chest Shops to easily sell and buy items, without the
need for any commands.
In fact, all commands in QuickShop are not even needed for normal gameplay.
This version of QuickShop ([Ghost-chu/QuickShop-Hikari][quickshop-hikari]) is a fork
QuickShop-OG is based on an older version of ([Ghost-chu/QuickShop-Hikari][quickshop-hikari]), which is a fork
from [PotatoCraft-Studio's version][quickshop-potato] which itself is a fork from the [Reremake][quickshop-ghostchu] of
the [original QuickShop][quickshop-original].
QuickShop Hikari is maintained by Ghost-Chu and has the goal to modernize the core content of QuickShop and adapt it to
the latest versions of Minecraft.
## Community & Support
[Discussions](https://github.com/Ghost-chu/QuickShop-Hikari/discussions)
[Bug Tracker](https://github.com/Ghost-chu/QuickShop-Hikari/issues)
[Discord](https://discord.gg/Bu3dVtmsD3)
## Features
- Easy to use
@@ -136,10 +103,6 @@ the latest versions of Minecraft.
- Shop benefits between shop owner and other players!
- And much much more!
## Downloads
Obtain the latest version from [ci.codemc.io][codemc]
## Compatibility Modules
You can download optional modules [here][optional_modules] for compatibility with other plugins.
@@ -164,16 +127,9 @@ You can download optional modules [here][optional_modules] for compatibility wit
- Flag-based shop control.
## Contribute
If you're a developer, you can contribute to the QuickShop source code! Just make a fork, install the Lombok plugin (if
not done automatically), make your changes and create a pull request when you're done!
Please try to follow [Google's Java Code Style][googlejava] and do not increase the Plugin version. Thank you!
### Distributing forks
You're allowed to create your fork to share. No permission is needed.
Though it would be nice if you could pull-request your changes into this repository when they are good ones.
### Compile and Debugging
+1
View File
@@ -0,0 +1 @@
/build/
-78
View File
@@ -1,78 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
<artifactId>bluemap</artifactId>
<packaging>jar</packaging>
<name>Addon-BlueMap</name>
<description>Displaying the quickshops on your BlueMap instance</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.BlueMap-Minecraft</groupId>
<artifactId>BlueMapAPI</artifactId>
<version>2.6.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -8,6 +8,7 @@ import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.BlueMapWorld;
import de.bluecolored.bluemap.api.markers.MarkerSet;
import de.bluecolored.bluemap.api.markers.POIMarker;
import java.util.Optional;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.Bukkit;
@@ -18,8 +19,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
public final class Main extends JavaPlugin implements Listener {
static Main instance;
private QuickShop plugin;
@@ -43,7 +42,9 @@ public final class Main extends JavaPlugin implements Listener {
BlueMapAPI.onEnable(blueMapAPI -> {
getLogger().info("Found BlueMap loaded! Hooking!");
createMarkerSet();
Bukkit.getScheduler().runTaskTimerAsynchronously(this, this::updateAllMarkers, 1, getConfig().getInt("refresh-per-seconds") * 20L);
Bukkit.getScheduler()
.runTaskTimerAsynchronously(
this, this::updateAllMarkers, 1, getConfig().getInt("refresh-per-seconds") * 20L);
});
BlueMapAPI.onDisable(api -> Bukkit.getScheduler().cancelTasks(this));
@@ -69,7 +70,8 @@ public final class Main extends JavaPlugin implements Listener {
}
private void updateAllMarkers() {
blueMapAPI.getWorlds().forEach(bWorld -> bWorld.getMaps().forEach(bMap -> bMap.getMarkerSets().remove("quickshop-hikari-shops")));
blueMapAPI.getWorlds().forEach(bWorld -> bWorld.getMaps()
.forEach(bMap -> bMap.getMarkerSets().remove("quickshop-hikari-shops")));
plugin.getShopManager().getAllShops().forEach(this::updateShopMarker);
}
@@ -79,12 +81,14 @@ public final class Main extends JavaPlugin implements Listener {
return;
}
for (BlueMapMap map : bWorld.get().getMaps()) {
MarkerSet markerSet = map.getMarkerSets().computeIfAbsent("quickshop-hikari-shops", (key) -> createMarkerSet());
MarkerSet markerSet =
map.getMarkerSets().computeIfAbsent("quickshop-hikari-shops", (key) -> createMarkerSet());
String markerName = fillPlaceholders(getConfig().getString("marker-label"), shop);
String desc = fillPlaceholders(getConfig().getString("marker-detail"), shop);
POIMarker marker = POIMarker.builder()
.label(markerName)
.position(shop.getLocation().getX(),
.position(
shop.getLocation().getX(),
shop.getLocation().getY(),
shop.getLocation().getZ())
.maxDistance(getConfig().getDouble("max-distance"))
-83
View File
@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
<artifactId>discount</artifactId>
<packaging>jar</packaging>
<name>Addon-Discount</name>
<description>Add discount code to your QuickShop-Hikari server</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
<repository>
<id>Scarsz-Nexus</id>
<url>https://nexus.scarsz.me/content/groups/public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.kyori</groupId>-->
<!-- <artifactId>adventure-text-serializer-plain</artifactId>-->
<!-- <version>4.12.0</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
</dependencies>
</project>
@@ -7,14 +7,13 @@ import com.ghostchu.quickshop.api.localization.text.TextManager;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.common.util.CalculateUtil;
import com.ghostchu.quickshop.common.util.JsonUtil;
import java.util.*;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
public class DiscountCode {
private final String code;
private final UUID owner;
@@ -27,7 +26,16 @@ public class DiscountCode {
private long expiredTime;
public DiscountCode(@NotNull UUID owner, @NotNull String code, @NotNull CodeType codeType, @NotNull DiscountRate rate, int maxUsage, @NotNull Map<UUID, Integer> usages, @NotNull Set<Long> shopScope, double threshold, long expiredTime) {
public DiscountCode(
@NotNull UUID owner,
@NotNull String code,
@NotNull CodeType codeType,
@NotNull DiscountRate rate,
int maxUsage,
@NotNull Map<UUID, Integer> usages,
@NotNull Set<Long> shopScope,
double threshold,
long expiredTime) {
this.owner = owner;
this.code = code;
this.codeType = codeType;
@@ -39,7 +47,14 @@ public class DiscountCode {
this.expiredTime = expiredTime;
}
public DiscountCode(@NotNull UUID owner, @NotNull String code, @NotNull CodeType codeType, @NotNull DiscountRate rate, int maxUsage, double threshold, long expiredTime) {
public DiscountCode(
@NotNull UUID owner,
@NotNull String code,
@NotNull CodeType codeType,
@NotNull DiscountRate rate,
int maxUsage,
double threshold,
long expiredTime) {
this.owner = owner;
this.code = code;
this.codeType = codeType;
@@ -87,7 +102,8 @@ public class DiscountCode {
} else {
rate = JsonUtil.getGson().fromJson(data.getRate(), FixedDiscountRate.class);
}
return new DiscountCode(data.getOwner(),
return new DiscountCode(
data.getOwner(),
data.getCode(),
data.getCodeType(),
rate,
@@ -135,7 +151,8 @@ public class DiscountCode {
public boolean addShopToScope(@NotNull Shop shop) {
if (codeType != CodeType.SPECIFIC_SHOPS) {
throw new IllegalStateException("Cannot add shop to code scope, because this code is not a specific shop code.");
throw new IllegalStateException(
"Cannot add shop to code scope, because this code is not a specific shop code.");
}
return this.shopScope.add(shop.getShopId());
}
@@ -218,23 +235,24 @@ public class DiscountCode {
if (usage + 1 > maxUsage) {
return ApplicableType.REACHED_THE_LIMIT;
}
ApplicableType type = switch (codeType) {
case SPECIFIC_SHOPS -> {
if (shopScope.contains(shop.getShopId())) {
yield ApplicableType.APPLICABLE;
} else {
yield ApplicableType.NOT_APPLICABLE;
}
}
case PLAYER_ALL_SHOPS -> {
if (owner.equals(shop.getOwner().getUniqueId())) {
yield ApplicableType.APPLICABLE;
} else {
yield ApplicableType.NOT_APPLICABLE;
}
}
case SERVER_ALL_SHOPS -> ApplicableType.APPLICABLE;
};
ApplicableType type =
switch (codeType) {
case SPECIFIC_SHOPS -> {
if (shopScope.contains(shop.getShopId())) {
yield ApplicableType.APPLICABLE;
} else {
yield ApplicableType.NOT_APPLICABLE;
}
}
case PLAYER_ALL_SHOPS -> {
if (owner.equals(shop.getOwner().getUniqueId())) {
yield ApplicableType.APPLICABLE;
} else {
yield ApplicableType.NOT_APPLICABLE;
}
}
case SERVER_ALL_SHOPS -> ApplicableType.APPLICABLE;
};
if (type != ApplicableType.APPLICABLE) {
return type;
}
@@ -256,8 +274,7 @@ public class DiscountCode {
threshold,
maxUsage,
usages,
shopScope
);
shopScope);
return JsonUtil.getGson().toJson(data);
}
@@ -274,22 +291,28 @@ public class DiscountCode {
if (!(o instanceof DiscountCode that)) {
return false;
}
return maxUsage == that.maxUsage && Double.compare(that.threshold, threshold) == 0 && expiredTime == that.expiredTime && code.equals(that.code) && owner.equals(that.owner) && shopScope.equals(that.shopScope) && codeType == that.codeType && rate.equals(that.rate);
return maxUsage == that.maxUsage
&& Double.compare(that.threshold, threshold) == 0
&& expiredTime == that.expiredTime
&& code.equals(that.code)
&& owner.equals(that.owner)
&& shopScope.equals(that.shopScope)
&& codeType == that.codeType
&& rate.equals(that.rate);
}
@Override
public String toString() {
return "DiscountCode{" +
"code='" + code + '\'' +
", owner=" + owner +
", usages=" + usages +
", shopScope=" + shopScope +
", codeType=" + codeType +
", rate=" + rate +
", maxUsage=" + maxUsage +
", threshold=" + threshold +
", expiredTime=" + expiredTime +
'}';
return "DiscountCode{" + "code='"
+ code + '\'' + ", owner="
+ owner + ", usages="
+ usages + ", shopScope="
+ shopScope + ", codeType="
+ codeType + ", rate="
+ rate + ", maxUsage="
+ maxUsage + ", threshold="
+ threshold + ", expiredTime="
+ expiredTime + '}';
}
public interface DiscountRate {
@@ -319,7 +342,9 @@ public class DiscountCode {
@Override
public @NotNull Component format(@NotNull CommandSender sender, @NotNull TextManager textManager) {
return textManager.of(sender, "addon.discount.fixed-off", String.format("%.2f", rate)).forLocale();
return textManager
.of(sender, "addon.discount.fixed-off", String.format("%.2f", rate))
.forLocale();
}
}
@@ -343,7 +368,9 @@ public class DiscountCode {
@Override
public @NotNull Component format(@NotNull CommandSender sender, @NotNull TextManager textManager) {
return textManager.of(sender, "addon.discount.percentage-off", CalculateUtil.multiply(percent, 100)).forLocale();
return textManager
.of(sender, "addon.discount.percentage-off", CalculateUtil.multiply(percent, 100))
.forLocale();
}
}
}
@@ -2,13 +2,12 @@ package com.ghostchu.quickshop.addon.discount;
import com.ghostchu.quickshop.addon.discount.type.CodeType;
import com.ghostchu.quickshop.addon.discount.type.RateType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@@ -24,5 +23,4 @@ public class DiscountCodeData {
private int maxUsage;
private Map<UUID, Integer> usages;
private Set<Long> shopScope;
}
@@ -3,16 +3,15 @@ package com.ghostchu.quickshop.addon.discount;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.discount.type.CodeCreationResponse;
import com.ghostchu.quickshop.addon.discount.type.CodeType;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
import java.util.regex.Pattern;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class DiscountCodeManager {
public static final String NAME_REG_EXP = "[a-zA-Z0-9_]*";
@@ -49,7 +48,8 @@ public class DiscountCodeManager {
public void saveDatabase() {
try {
this.config.set("codes", this.codes.stream().map(DiscountCode::saveToString).toList());
this.config.set(
"codes", this.codes.stream().map(DiscountCode::saveToString).toList());
this.config.save(this.file);
} catch (IOException e) {
main.getLogger().log(Level.WARNING, "Couldn't save the player discount codes status into database.", e);
@@ -76,7 +76,15 @@ public class DiscountCodeManager {
}
@NotNull
public CodeCreationResponse createDiscountCode(@NotNull CommandSender sender, @NotNull UUID owner, @NotNull String code, @NotNull CodeType codeType, @NotNull String rate, int maxUsage, double threshold, long expiredTime) {
public CodeCreationResponse createDiscountCode(
@NotNull CommandSender sender,
@NotNull UUID owner,
@NotNull String code,
@NotNull CodeType codeType,
@NotNull String rate,
int maxUsage,
double threshold,
long expiredTime) {
if (!namePattern.matcher(code).matches()) {
return CodeCreationResponse.REGEX_FAILURE;
}
@@ -96,15 +104,18 @@ public class DiscountCodeManager {
if (discountRate == null) {
return CodeCreationResponse.INVALID_RATE;
}
if (!QuickShop.getPermissionManager().hasPermission(sender, "quickshopaddon.discount.create." + codeType.name().toLowerCase())) {
if (!QuickShop.getPermissionManager()
.hasPermission(
sender,
"quickshopaddon.discount.create." + codeType.name().toLowerCase())) {
return CodeCreationResponse.PERMISSION_DENIED;
}
DiscountCode discountCode = new DiscountCode(owner, code, codeType, discountRate, maxUsage, threshold, expiredTime);
DiscountCode discountCode =
new DiscountCode(owner, code, codeType, discountRate, maxUsage, threshold, expiredTime);
if (!this.codes.add(discountCode)) {
return CodeCreationResponse.CODE_EXISTS;
}
main.getCodeManager().saveDatabase();
return CodeCreationResponse.SUCCESS;
}
}
@@ -1,11 +1,10 @@
package com.ghostchu.quickshop.addon.discount;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class DiscountStatusManager {
private final Map<UUID, String> PLAYER_STATUS = new HashMap<>();
@@ -5,15 +5,14 @@ import com.ghostchu.quickshop.addon.discount.command.DiscountCommand;
import com.ghostchu.quickshop.addon.discount.listener.MainListener;
import com.ghostchu.quickshop.api.command.CommandContainer;
import com.ghostchu.quickshop.api.shop.permission.BuiltInShopPermissionGroup;
import java.io.IOException;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.util.logging.Level;
public final class Main extends JavaPlugin implements Listener {
static Main instance;
private final DiscountStatusManager discountStatusManager = new DiscountStatusManager();
@@ -43,20 +42,27 @@ public final class Main extends JavaPlugin implements Listener {
return;
}
getLogger().info("Registering the per shop permissions...");
plugin.getShopPermissionManager().registerPermission(BuiltInShopPermissionGroup.ADMINISTRATOR.getNamespacedNode(), this, "discount_code_create");
plugin.getShopPermissionManager().registerPermission(BuiltInShopPermissionGroup.ADMINISTRATOR.getNamespacedNode(), this, "discount_code_use");
plugin.getShopPermissionManager().registerPermission(BuiltInShopPermissionGroup.EVERYONE.getNamespacedNode(), this, "discount_code_use");
plugin.getShopPermissionManager().registerPermission(BuiltInShopPermissionGroup.STAFF.getNamespacedNode(), this, "discount_code_use");
plugin.getShopPermissionManager()
.registerPermission(
BuiltInShopPermissionGroup.ADMINISTRATOR.getNamespacedNode(), this, "discount_code_create");
plugin.getShopPermissionManager()
.registerPermission(
BuiltInShopPermissionGroup.ADMINISTRATOR.getNamespacedNode(), this, "discount_code_use");
plugin.getShopPermissionManager()
.registerPermission(BuiltInShopPermissionGroup.EVERYONE.getNamespacedNode(), this, "discount_code_use");
plugin.getShopPermissionManager()
.registerPermission(BuiltInShopPermissionGroup.STAFF.getNamespacedNode(), this, "discount_code_use");
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> codeManager.cleanExpiredCodes(), 1L, 20 * 60 * 30);
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> codeManager.saveDatabase(), 1L, 20 * 60 * 15);
getLogger().info("Registering the listeners...");
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new MainListener(this), this);
plugin.getCommandManager().registerCmd(
CommandContainer
.builder()
plugin.getCommandManager()
.registerCmd(CommandContainer.builder()
.prefix("discount")
.description((locale) -> plugin.text().of("addon.discount.commands.discount.description").forLocale(locale))
.description((locale) -> plugin.text()
.of("addon.discount.commands.discount.description")
.forLocale(locale))
.permission("quickshopaddon.discount.use")
.executor(new DiscountCommand(this, plugin))
.build());
@@ -12,6 +12,8 @@ import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.common.util.CommonUtil;
import com.ghostchu.quickshop.util.ChatSheetPrinter;
import com.ghostchu.quickshop.util.logger.Log;
import java.text.SimpleDateFormat;
import java.util.*;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
@@ -20,9 +22,6 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.text.SimpleDateFormat;
import java.util.*;
public class DiscountCommand implements CommandHandler<CommandSender> {
private final Main main;
private final QuickShop quickshop;
@@ -35,7 +34,13 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
@Override
public void onCommand(CommandSender sender, @NotNull String commandLabel, @NotNull CommandParser parser) {
if (parser.getArgs().isEmpty()) {
quickshop.text().of(sender, "command-incorrect", "/quickshop discount <install/uninstall/create/remove/list/config/query>").send();
quickshop
.text()
.of(
sender,
"command-incorrect",
"/quickshop discount <install/uninstall/create/remove/list/config/query>")
.send();
return;
}
String[] passThroughArgs = new String[parser.getArgs().size() - 1];
@@ -48,8 +53,13 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
case "info" -> info(sender, passThroughArgs);
case "config" -> config(sender, passThroughArgs);
case "list" -> list(sender, passThroughArgs);
default ->
quickshop.text().of(sender, "command-incorrect", "/quickshop discount <install/uninstall/create/remove/config/query>").send();
default -> quickshop
.text()
.of(
sender,
"command-incorrect",
"/quickshop discount <install/uninstall/create/remove/config/query>")
.send();
}
}
@@ -59,7 +69,10 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
return;
}
if (passThroughArgs.length < 1) {
quickshop.text().of(sender, "command-incorrect", "/quickshop discount install <code>").send();
quickshop
.text()
.of(sender, "command-incorrect", "/quickshop discount install <code>")
.send();
return;
}
String codeStr = passThroughArgs[0];
@@ -69,7 +82,10 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
return;
}
main.getStatusManager().set(p.getUniqueId(), code);
quickshop.text().of(sender, "addon.discount.discount-code-installed", code.getCode()).send();
quickshop
.text()
.of(sender, "addon.discount.discount-code-installed", code.getCode())
.send();
}
private void uninstall(CommandSender sender, String[] passThroughArgs) {
@@ -87,12 +103,24 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
return;
}
if (passThroughArgs.length < 1) {
quickshop.text().of(sender, "command-incorrect", "/quickshop discount create <code> <code-type> <rate> [max-usage] [threshold] [expired-time]").send();
quickshop
.text()
.of(
sender,
"command-incorrect",
"/quickshop discount create <code> <code-type> <rate> [max-usage] [threshold] [expired-time]")
.send();
return;
}
// code, code-type, rate, max-usage, threshold, expired-time
if (passThroughArgs.length < 3) {
quickshop.text().of(sender, "command-incorrect", "/quickshop discount create <code> <code-type> <rate> [max-usage] [threshold] [expired-time]").send();
quickshop
.text()
.of(
sender,
"command-incorrect",
"/quickshop discount create <code> <code-type> <rate> [max-usage] [threshold] [expired-time]")
.send();
return;
}
String code = passThroughArgs[0];
@@ -105,7 +133,10 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
}
}
if (codeType == null) {
quickshop.text().of(sender, "addon.discount.invalid-code-type", codeTypeStr).send();
quickshop
.text()
.of(sender, "addon.discount.invalid-code-type", codeTypeStr)
.send();
return;
}
int maxUsages = -1;
@@ -130,34 +161,66 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
if (passThroughArgs.length >= 6 && !"-1".equalsIgnoreCase(passThroughArgs[5])) {
Date date = CommonUtil.parseTime(passThroughArgs[5]);
if (date == null) {
quickshop.text().of(sender, "not-a-valid-time", passThroughArgs[5]).send();
quickshop
.text()
.of(sender, "not-a-valid-time", passThroughArgs[5])
.send();
return;
}
expiredOn = date.getTime();
}
CodeCreationResponse response = main.getCodeManager().createDiscountCode(p, p.getUniqueId(), code, codeType, passThroughArgs[2], maxUsages, threshold, expiredOn);
CodeCreationResponse response = main.getCodeManager()
.createDiscountCode(
p, p.getUniqueId(), code, codeType, passThroughArgs[2], maxUsages, threshold, expiredOn);
switch (response) {
case PERMISSION_DENIED -> quickshop.text().of(sender, "no-permission").send();
case INVALID_RATE -> quickshop.text().of(sender, "addon.discount.invalid-discount-rate").send();
case REGEX_FAILURE ->
quickshop.text().of(sender, "addon.discount.invalid-discount-code-regex", DiscountCodeManager.NAME_REG_EXP).send();
case INVALID_USAGE -> quickshop.text().of(sender, "addon.discount.invalid-usage-restriction").send();
case INVALID_THRESHOLD ->
quickshop.text().of(sender, "addon.discount.invalid-threshold-restriction").send();
case INVALID_EXPIRE_TIME -> quickshop.text().of(sender, "addon.discount.invalid-expire-time").send();
case CODE_EXISTS -> quickshop.text().of(sender, "addon.discount.discount-code-already-exists").send();
case SUCCESS -> quickshop.text().of(sender, "addon.discount.discount-code-created-successfully",
code,
CommonUtil.prettifyText(codeType.name()),
"/quickshop discount install " + code,
"/quickshop discount config " + code + " addshop").send();
case PERMISSION_DENIED -> quickshop
.text()
.of(sender, "no-permission")
.send();
case INVALID_RATE -> quickshop
.text()
.of(sender, "addon.discount.invalid-discount-rate")
.send();
case REGEX_FAILURE -> quickshop
.text()
.of(sender, "addon.discount.invalid-discount-code-regex", DiscountCodeManager.NAME_REG_EXP)
.send();
case INVALID_USAGE -> quickshop
.text()
.of(sender, "addon.discount.invalid-usage-restriction")
.send();
case INVALID_THRESHOLD -> quickshop
.text()
.of(sender, "addon.discount.invalid-threshold-restriction")
.send();
case INVALID_EXPIRE_TIME -> quickshop
.text()
.of(sender, "addon.discount.invalid-expire-time")
.send();
case CODE_EXISTS -> quickshop
.text()
.of(sender, "addon.discount.discount-code-already-exists")
.send();
case SUCCESS -> quickshop
.text()
.of(
sender,
"addon.discount.discount-code-created-successfully",
code,
CommonUtil.prettifyText(codeType.name()),
"/quickshop discount install " + code,
"/quickshop discount config " + code + " addshop")
.send();
}
Log.debug("Discount code created: " + main.getCodeManager().getCode(code));
}
private void remove(CommandSender sender, String[] passThroughArgs) {
if (passThroughArgs.length < 1) {
quickshop.text().of(sender, "command-incorrect", "/quickshop discount remove <code>").send();
quickshop
.text()
.of(sender, "command-incorrect", "/quickshop discount remove <code>")
.send();
return;
}
String codeStr = passThroughArgs[0];
@@ -167,7 +230,8 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
return;
}
if (sender instanceof Player p) {
if (!code.getOwner().equals(p.getUniqueId()) && !quickshop.perm().hasPermission(sender, "quickshopaddon.discount.remove.bypass")) {
if (!code.getOwner().equals(p.getUniqueId())
&& !quickshop.perm().hasPermission(sender, "quickshopaddon.discount.remove.bypass")) {
quickshop.text().of(sender, "no-permission").send();
return;
}
@@ -178,7 +242,10 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
}
}
main.getCodeManager().removeCode(code);
quickshop.text().of(sender, "addon.discount.discount-code-removed", code.getCode()).send();
quickshop
.text()
.of(sender, "addon.discount.discount-code-removed", code.getCode())
.send();
}
private void info(CommandSender sender, String[] passThroughArgs) {
@@ -188,7 +255,10 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
}
DiscountCode code = main.getStatusManager().get(p.getUniqueId(), main.getCodeManager());
if (code == null) {
quickshop.text().of(sender, "addon.discount.discount-code-query-nothing").send();
quickshop
.text()
.of(sender, "addon.discount.discount-code-query-nothing")
.send();
return;
}
String name = "Unknown";
@@ -196,7 +266,10 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
if (lookupName != null) {
name = lookupName;
}
Component appliedTo = quickshop.text().of(sender, "addon.discount.code-type." + code.getCodeType().name()).forLocale();
Component appliedTo = quickshop
.text()
.of(sender, "addon.discount.code-type." + code.getCodeType().name())
.forLocale();
String remainsUsage;
int remains = code.getRemainsUsage(((Player) sender).getUniqueId());
if (remains == -1) {
@@ -207,7 +280,19 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
String expiredOn = sdf.format(new Date(code.getExpiredTime()));
quickshop.text().of(sender, "addon.discount.discount-code-details", code.getCode(), name, appliedTo, remainsUsage, expiredOn, code.getThreshold(), code.getRate().format(sender, quickshop.text())).send();
quickshop
.text()
.of(
sender,
"addon.discount.discount-code-details",
code.getCode(),
name,
appliedTo,
remainsUsage,
expiredOn,
code.getThreshold(),
code.getRate().format(sender, quickshop.text()))
.send();
}
private void config(CommandSender sender, String[] passThroughArgs) {
@@ -216,12 +301,21 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
return;
}
if (passThroughArgs.length < 2) {
quickshop.text().of(sender, "command-incorrect", "/quickshop discount config <code> <addshop/removeshop/scope> [args]").send();
quickshop
.text()
.of(
sender,
"command-incorrect",
"/quickshop discount config <code> <addshop/removeshop/scope> [args]")
.send();
return;
}
DiscountCode code = main.getCodeManager().getCode(passThroughArgs[0]);
if (code == null) {
quickshop.text().of(sender, "addon.discount.invalid-discount-code", passThroughArgs[0]).send();
quickshop
.text()
.of(sender, "addon.discount.invalid-discount-code", passThroughArgs[0])
.send();
return;
}
switch (passThroughArgs[1]) {
@@ -236,10 +330,16 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
return;
}
if (code.getShopScope().add(shop.getShopId())) {
quickshop.text().of(sender, "addon.discount.discount-code-config-shop-added", shop.getShopId()).send();
quickshop
.text()
.of(sender, "addon.discount.discount-code-config-shop-added", shop.getShopId())
.send();
main.getCodeManager().saveDatabase();
} else {
quickshop.text().of(sender, "addon.discount.discount-code-config-shop-add-failure", shop.getShopId()).send();
quickshop
.text()
.of(sender, "addon.discount.discount-code-config-shop-add-failure", shop.getShopId())
.send();
}
}
case "removeshop" -> {
@@ -253,27 +353,42 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
return;
}
if (code.getShopScope().remove(shop.getShopId())) {
quickshop.text().of(sender, "addon.discount.discount-code-config-shop-removed", shop.getShopId()).send();
quickshop
.text()
.of(sender, "addon.discount.discount-code-config-shop-removed", shop.getShopId())
.send();
main.getCodeManager().saveDatabase();
} else {
quickshop.text().of(sender, "addon.discount.discount-code-config-shop-remove-failure", shop.getShopId()).send();
quickshop
.text()
.of(sender, "addon.discount.discount-code-config-shop-remove-failure", shop.getShopId())
.send();
}
}
case "scope" -> {
if (passThroughArgs.length < 3) {
// StringJoiner joiner = new StringJoiner("<", "/", ">");
// Arrays.stream(CodeType.values()).forEach(t -> joiner.add(t.name()));
quickshop.text().of(sender, "command-incorrect", "/quickshop discount config <code> scope <scope>").send();
// StringJoiner joiner = new StringJoiner("<", "/", ">");
// Arrays.stream(CodeType.values()).forEach(t -> joiner.add(t.name()));
quickshop
.text()
.of(sender, "command-incorrect", "/quickshop discount config <code> scope <scope>")
.send();
return;
}
if (!code.getOwner().equals(((Player) sender).getUniqueId()) && !quickshop.perm().hasPermission(sender, "quickshopaddon.discount.bypass")) {
if (!code.getOwner().equals(((Player) sender).getUniqueId())
&& !quickshop.perm().hasPermission(sender, "quickshopaddon.discount.bypass")) {
quickshop.text().of(sender, "no-permission").send();
return;
}
String newScope = passThroughArgs[2].toUpperCase(Locale.ROOT).replace("-", "_");
try {
CodeType type = CodeType.valueOf(newScope);
if (!quickshop.perm().hasPermission(sender, "quickshopaddon.discount.create." + type.name().toLowerCase())) {
if (!quickshop
.perm()
.hasPermission(
sender,
"quickshopaddon.discount.create."
+ type.name().toLowerCase())) {
quickshop.text().of(sender, "no-permission").send();
return;
}
@@ -281,7 +396,10 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
quickshop.text().of(sender, "discount-code-config-applied").send();
main.getCodeManager().saveDatabase();
} catch (IllegalArgumentException e) {
quickshop.text().of(sender, "addon.discount.invalid-code-type", newScope).send();
quickshop
.text()
.of(sender, "addon.discount.invalid-code-type", newScope)
.send();
}
}
}
@@ -298,31 +416,37 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
}
ChatSheetPrinter printer = new ChatSheetPrinter(sender);
printer.printHeader();
printer.printLine(quickshop.text().of(sender, "addon.discount.discount-code-list").forLocale());
main.getCodeManager().getCodes().stream().filter(code -> code.getOwner().equals(((Player) sender).getUniqueId())).forEach(code -> printer.printLine(Component.text(code.getCode()).color(NamedTextColor.AQUA)));
printer.printLine(
quickshop.text().of(sender, "addon.discount.discount-code-list").forLocale());
main.getCodeManager().getCodes().stream()
.filter(code -> code.getOwner().equals(((Player) sender).getUniqueId()))
.forEach(
code -> printer.printLine(Component.text(code.getCode()).color(NamedTextColor.AQUA)));
printer.printFooter();
}
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
public @Nullable List<String> onTabComplete(
@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
if (cmdArg.length == 1) {
return Arrays.asList("install", "uninstall", "create", "remove", "info", "config", "list");
}
if (cmdArg.length == 2) {
return switch (cmdArg[0]) {
case "install", "uninstall", "remove", "create", "config" -> List.of(PlainTextComponentSerializer
.plainText()
.serialize(quickshop
.text()
.of(sender,
"addon.discount.tab-complete.discount.general.code"
).forLocale()));
case "install", "uninstall", "remove", "create", "config" -> List.of(
PlainTextComponentSerializer.plainText()
.serialize(quickshop
.text()
.of(sender, "addon.discount.tab-complete.discount.general.code")
.forLocale()));
default -> Collections.emptyList();
};
}
if (cmdArg.length == 3) {
return switch (cmdArg[0]) {
case "create" -> Arrays.stream(CodeType.values()).map(Enum::name).toList();
case "create" -> Arrays.stream(CodeType.values())
.map(Enum::name)
.toList();
case "config" -> List.of("scope", "addshop", "removeshop");
default -> Collections.emptyList();
};
@@ -355,7 +479,8 @@ public class DiscountCommand implements CommandHandler<CommandSender> {
}
private List<String> tabCompleteHint(@NotNull CommandSender sender, @NotNull String key) {
String str = PlainTextComponentSerializer.plainText().serialize(quickshop.text().of(sender, key).forLocale());
String str = PlainTextComponentSerializer.plainText()
.serialize(quickshop.text().of(sender, key).forLocale());
List<String> list = new ArrayList<>();
String[] explode = str.split("\n");
for (int i = 0; i < explode.length; i++) {
@@ -9,14 +9,13 @@ import com.ghostchu.quickshop.api.obj.QUser;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.util.Util;
import com.ghostchu.quickshop.util.logger.Log;
import java.util.UUID;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
public class MainListener implements Listener {
private final Main main;
private final QuickShop quickshop;
@@ -41,17 +40,39 @@ public class MainListener implements Listener {
String code = codeInstalled.getCode();
Util.mainThreadRun(() -> {
switch (codeInstalled.applicableShop(purchaser, shop)) {
case APPLICABLE ->
quickshop.text().of(purchaser, "addon.discount.discount-code-applicable", code).send();
case APPLICABLE_WITH_THRESHOLD ->
quickshop.text().of(purchaser, "addon.discount.discount-code-applicable", code, quickshop.getEconomy().format(codeInstalled.getThreshold(), shop.getLocation().getWorld(), shop.getCurrency())).send();
case NOT_APPLICABLE ->
quickshop.text().of(purchaser, "addon.discount.discount-code-not-applicable", code).send();
case REACHED_THE_LIMIT ->
quickshop.text().of(purchaser, "addon.discount.discount-code-reach-the-limit", code).send();
case NO_PERMISSION ->
quickshop.text().of(purchaser, "addon.discount.discount-code-no-permission", code).send();
case EXPIRED -> quickshop.text().of(purchaser, "addon.discount.discount-code-expired", code).send();
case APPLICABLE -> quickshop
.text()
.of(purchaser, "addon.discount.discount-code-applicable", code)
.send();
case APPLICABLE_WITH_THRESHOLD -> quickshop
.text()
.of(
purchaser,
"addon.discount.discount-code-applicable",
code,
quickshop
.getEconomy()
.format(
codeInstalled.getThreshold(),
shop.getLocation().getWorld(),
shop.getCurrency()))
.send();
case NOT_APPLICABLE -> quickshop
.text()
.of(purchaser, "addon.discount.discount-code-not-applicable", code)
.send();
case REACHED_THE_LIMIT -> quickshop
.text()
.of(purchaser, "addon.discount.discount-code-reach-the-limit", code)
.send();
case NO_PERMISSION -> quickshop
.text()
.of(purchaser, "addon.discount.discount-code-no-permission", code)
.send();
case EXPIRED -> quickshop
.text()
.of(purchaser, "addon.discount.discount-code-expired", code)
.send();
}
});
}
@@ -78,25 +99,66 @@ public class MainListener implements Listener {
double beforeDiscount = event.getTotal();
event.setTotal(codeInstalled.apply(purchaser, event.getTotal()));
double discounted = beforeDiscount - event.getTotal();
quickshop.text().of(purchaser, "addon.discount.discount-code-applied-in-purchase", code, quickshop.getEconomy().format(discounted, shop.getLocation().getWorld(), shop.getCurrency())).send();
quickshop
.text()
.of(
purchaser,
"addon.discount.discount-code-applied-in-purchase",
code,
quickshop
.getEconomy()
.format(discounted, shop.getLocation().getWorld(), shop.getCurrency()))
.send();
}
case APPLICABLE_WITH_THRESHOLD -> {
if (event.getTotal() < codeInstalled.getThreshold()) {
quickshop.text().of(purchaser, "addon.discount.discount-code-under-threshold", quickshop.getEconomy().format(codeInstalled.getThreshold(), shop.getLocation().getWorld(), shop.getCurrency())).send();
quickshop
.text()
.of(
purchaser,
"addon.discount.discount-code-under-threshold",
quickshop
.getEconomy()
.format(
codeInstalled.getThreshold(),
shop.getLocation().getWorld(),
shop.getCurrency()))
.send();
} else {
double beforeDiscount = event.getTotal();
event.setTotal(codeInstalled.apply(purchaser, event.getTotal()));
double discounted = beforeDiscount - event.getTotal();
quickshop.text().of(purchaser, "addon.discount.discount-code-applied-in-purchase", code, quickshop.getEconomy().format(discounted, shop.getLocation().getWorld(), shop.getCurrency())).send();
quickshop
.text()
.of(
purchaser,
"addon.discount.discount-code-applied-in-purchase",
code,
quickshop
.getEconomy()
.format(
discounted,
shop.getLocation().getWorld(),
shop.getCurrency()))
.send();
}
}
case NOT_APPLICABLE ->
quickshop.text().of(purchaser, "addon.discount.discount-code-not-applicable", code).send();
case REACHED_THE_LIMIT ->
quickshop.text().of(purchaser, "addon.discount.discount-code-reach-the-limit", code).send();
case NO_PERMISSION ->
quickshop.text().of(purchaser, "addon.discount.discount-code-no-permission", code).send();
case EXPIRED -> quickshop.text().of(purchaser, "addon.discount.discount-code-expired", code).send();
case NOT_APPLICABLE -> quickshop
.text()
.of(purchaser, "addon.discount.discount-code-not-applicable", code)
.send();
case REACHED_THE_LIMIT -> quickshop
.text()
.of(purchaser, "addon.discount.discount-code-reach-the-limit", code)
.send();
case NO_PERMISSION -> quickshop
.text()
.of(purchaser, "addon.discount.discount-code-no-permission", code)
.send();
case EXPIRED -> quickshop
.text()
.of(purchaser, "addon.discount.discount-code-expired", code)
.send();
}
}
@@ -104,5 +166,4 @@ public class MainListener implements Listener {
public void onQuit(PlayerQuitEvent event) {
main.getStatusManager().unset(event.getPlayer().getUniqueId());
}
}
-83
View File
@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
<artifactId>displaycontrol</artifactId>
<packaging>jar</packaging>
<name>Addon-DisplayControl</name>
<description>Allow clients toggle the virtual display items status</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
<repository>
<id>Scarsz-Nexus</id>
<url>https://nexus.scarsz.me/content/groups/public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.kyori</groupId>-->
<!-- <artifactId>adventure-text-serializer-plain</artifactId>-->
<!-- <version>4.12.0</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
</dependencies>
</project>
@@ -1,151 +0,0 @@
package com.ghostchu.quickshop.addon.displaycontrol;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.displaycontrol.bean.ClientType;
import com.ghostchu.quickshop.addon.displaycontrol.bean.DisplayOption;
import com.ghostchu.quickshop.addon.displaycontrol.command.SubCommand_DisplayControl;
import com.ghostchu.quickshop.addon.displaycontrol.database.DisplayControlDatabaseHelper;
import com.ghostchu.quickshop.api.command.CommandContainer;
import com.ghostchu.quickshop.api.event.DisplayApplicableCheckEvent;
import com.ghostchu.quickshop.util.PackageUtil;
import com.ghostchu.quickshop.util.Util;
import com.ghostchu.quickshop.util.logger.Log;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;
import java.sql.SQLException;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
public final class Main extends JavaPlugin implements Listener, PluginMessageListener {
private static final String BUNGEE_CHANNEL = "quickshopcompat:bcgeyser";
private static final String RESPONSE_PREFIX = "CLIENTTYPE";
static Main instance;
private final Map<UUID, ClientType> playerClientMapping = new ConcurrentHashMap<>();
private final Map<UUID, DisplayOption> playerDisplayStatus = new ConcurrentHashMap<>();
private QuickShop plugin;
private DisplayControlDatabaseHelper databaseHelper;
@Override
public void onLoad() {
instance = this;
}
@Override
public void onDisable() {
HandlerList.unregisterAll((Plugin) this);
}
@Override
public void onEnable() {
saveDefaultConfig();
plugin = QuickShop.getInstance();
try {
databaseHelper = new DisplayControlDatabaseHelper(instance, plugin.getSqlManager(), plugin.getDbPrefix());
} catch (SQLException e) {
getLogger().log(Level.WARNING, "Failed to init database helper", e);
Bukkit.getPluginManager().disablePlugin(this);
return;
}
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> this.playerClientMapping.entrySet().removeIf(e -> Bukkit.getPlayer(e.getKey()) == null), 60 * 20 * 60, 60 * 20 * 60);
plugin.getCommandManager().registerCmd(CommandContainer.builder()
.prefix("displaycontrol")
.permission("quickshopaddon.displaycontrol.use")
.description((locale) -> plugin.text().of("addon.displaycontrol.command.displaycontrol").forLocale(locale))
.executor(new SubCommand_DisplayControl(plugin, this))
.build());
getLogger().info("BungeeCord: " + Util.checkIfBungee());
if (Util.checkIfBungee()) {
getLogger().info("Detected BungeeCord, register the BungeeCord client information forward module, you will need install Compat-BungeeCord-Geyser module to make this feature work.");
Bukkit.getMessenger().registerIncomingPluginChannel
(this, BUNGEE_CHANNEL, this); // we register the incoming channel
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void playerLogin(AsyncPlayerPreLoginEvent event) {
UUID uuid = event.getUniqueId();
try {
DisplayOption displayOption = databaseHelper.getDisplayOption(uuid);
this.playerDisplayStatus.put(uuid, displayOption);
} catch (SQLException e) {
getLogger().log(Level.WARNING, "Failed to getting the player display status from database", e);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void playerQuit(PlayerQuitEvent event) {
cleanup(event.getPlayer().getUniqueId());
}
private void cleanup(UUID uuid) {
this.playerDisplayStatus.remove(uuid);
this.playerClientMapping.remove(uuid);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void displaySending(DisplayApplicableCheckEvent event) {
UUID uuid = event.getPlayer();
DisplayOption option = this.playerDisplayStatus.getOrDefault(uuid, DisplayOption.AUTO);
boolean bedrockClient = this.playerClientMapping.getOrDefault(uuid, ClientType.UNDISCOVERED).isBedrockType();
if (!option.isDisplayAvailable(bedrockClient)) {
event.setApplicable(false);
}
}
public DisplayControlDatabaseHelper getDatabaseHelper() {
return databaseHelper;
}
@Override
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte @NotNull [] message) {
if (!channel.equalsIgnoreCase(BUNGEE_CHANNEL)) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String prefix = in.readUTF();
//noinspection SwitchStatementWithTooFewBranches
switch (prefix) {
case RESPONSE_PREFIX -> handleBungeeBedrockPlayerCallback(in);
default -> getLogger().log(Level.WARNING, "Unrecognized type: " + prefix);
}
}
private void handleBungeeBedrockPlayerCallback(ByteArrayDataInput in) {
if (!PackageUtil.parsePackageProperly("acceptBungeeCordBedrockPlayerDiscoveryCallback").asBoolean(true)) {
return;
}
UUID uuid = UUID.fromString(in.readUTF());
int responseType = in.readShort();
ClientType clientType = ClientType.UNDISCOVERED;
if (responseType == 0) {
clientType = ClientType.JAVA_EDITION_PLAYER;
}
if (responseType == 1) {
clientType = ClientType.BEDROCK_EDITION_PLAYER_GEYSER;
}
if (responseType == 2) {
clientType = ClientType.BEDROCK_EDITION_PLAYER_FLOODGATE;
}
Log.debug("Player " + uuid + " client type check callback: " + clientType.name() + ", isBedrockClient: " + clientType.isBedrockType());
if (this.playerClientMapping.getOrDefault(uuid, ClientType.UNDISCOVERED).isWaitingDiscover()) {
Log.debug("[BUNGEE-CALLBACK] Discovered player " + uuid + " client type is: " + clientType.name());
this.playerClientMapping.put(uuid, clientType);
}
}
}
@@ -1,16 +0,0 @@
package com.ghostchu.quickshop.addon.displaycontrol.bean;
public enum ClientType {
UNDISCOVERED,
BEDROCK_EDITION_PLAYER_GEYSER,
BEDROCK_EDITION_PLAYER_FLOODGATE,
JAVA_EDITION_PLAYER;
public boolean isBedrockType() {
return this == BEDROCK_EDITION_PLAYER_FLOODGATE || this == BEDROCK_EDITION_PLAYER_GEYSER;
}
public boolean isWaitingDiscover() {
return this == UNDISCOVERED;
}
}
@@ -1,32 +0,0 @@
package com.ghostchu.quickshop.addon.displaycontrol.bean;
public enum DisplayOption {
AUTO(0),
ENABLED(1),
DISABLED(2);
private final int id;
DisplayOption(int id) {
this.id = id;
}
public boolean isDisplayAvailable(boolean bedrock) {
if (this == AUTO) {
return !bedrock;
}
return this == ENABLED;
}
public static DisplayOption fromId(int id) {
for (DisplayOption value : values()) {
if (value.id == id) {
return value;
}
}
return AUTO;
}
public int getId() {
return id;
}
}
@@ -1,63 +0,0 @@
package com.ghostchu.quickshop.addon.displaycontrol.command;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.displaycontrol.Main;
import com.ghostchu.quickshop.addon.displaycontrol.bean.DisplayOption;
import com.ghostchu.quickshop.api.command.CommandHandler;
import com.ghostchu.quickshop.api.command.CommandParser;
import com.ghostchu.quickshop.util.Util;
import com.ghostchu.quickshop.util.logger.Log;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
public class SubCommand_DisplayControl implements CommandHandler<Player> {
private final QuickShop qs;
private final Main plugin;
public SubCommand_DisplayControl(QuickShop qs, Main plugin) {
this.qs = qs;
this.plugin = plugin;
}
@Override
public void onCommand(Player sender, @NotNull String commandLabel, @NotNull CommandParser parser) {
if (parser.getArgs().isEmpty()) {
qs.text().of(sender, "command-incorrect", "/quickshop displaycontrol <auto/enable/disable>").send();
return;
}
DisplayOption option = DisplayOption.AUTO;
String userInput = parser.getArgs().get(0).trim();
if ("enable".equalsIgnoreCase(userInput)) {
option = DisplayOption.ENABLED;
}
if ("disable".equalsIgnoreCase(userInput)) {
option = DisplayOption.DISABLED;
}
DisplayOption optionFinCopy = option;
Util.asyncThreadRun(() -> {
try {
Integer i = plugin.getDatabaseHelper().setDisplayDisableForPlayer(sender.getUniqueId(), optionFinCopy);
Log.debug("Execute DisplayToggle with id " + i + " affected");
qs.text().of(sender, "addon.displaycontrol.toggle", optionFinCopy.name()).send();
} catch (SQLException e) {
qs.text().of(sender, "addon.displaycontrol.toggle-exception").send();
plugin.getLogger().log(Level.WARNING, "Cannot save the player display status", e);
}
});
}
@Override
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull CommandParser parser) {
if (parser.getArgs().size() == 1) {
return List.of("enable", "disable");
}
return Collections.emptyList();
}
}
@@ -1,69 +0,0 @@
package com.ghostchu.quickshop.addon.displaycontrol.database;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery;
import com.ghostchu.quickshop.addon.displaycontrol.Main;
import com.ghostchu.quickshop.addon.displaycontrol.bean.DisplayOption;
import com.ghostchu.quickshop.util.Util;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
import java.util.logging.Level;
public class DisplayControlDatabaseHelper {
private final Main plugin;
public DisplayControlDatabaseHelper(@NotNull Main plugin, @NotNull SQLManager sqlManager, @NotNull String dbPrefix) throws SQLException {
this.plugin = plugin;
try {
DisplayControlTables.initializeTables(sqlManager, dbPrefix);
} catch (SQLException e) {
plugin.getLogger().log(Level.WARNING, "Cannot initialize tables", e);
throw e;
}
}
public @NotNull Integer setDisplayDisableForPlayer(@NotNull UUID uuid, DisplayOption status) throws SQLException {
Util.ensureThread(true);
try (SQLQuery query = DisplayControlTables.DISPLAY_CONTROL_PLAYERS.createQuery()
.setLimit(1)
.addCondition("player", uuid.toString())
.build().execute();
ResultSet set = query.getResultSet()) {
if (set.next()) {
return DisplayControlTables.DISPLAY_CONTROL_PLAYERS.createUpdate()
.setLimit(1)
.addCondition("player", uuid.toString())
.setColumnValues("displayOption", status.getId())
.build().execute();
} else {
return DisplayControlTables.DISPLAY_CONTROL_PLAYERS.createInsert()
.setColumnNames("player", "displayOption")
.setParams(uuid.toString(), status.getId())
.returnGeneratedKey()
.execute();
}
}
}
@Nullable
public DisplayOption getDisplayOption(@NotNull UUID player) throws SQLException {
Util.ensureThread(true);
try (SQLQuery query = DisplayControlTables.DISPLAY_CONTROL_PLAYERS
.createQuery()
.selectColumns("displayOption")
.addCondition("player", player.toString()).setLimit(1).build().execute();
ResultSet set = query.getResultSet()) {
if (set.next()) {
int optionId = set.getInt("displayOption");
return DisplayOption.fromId(optionId);
}
return DisplayOption.AUTO;
}
}
}
@@ -1,155 +0,0 @@
package com.ghostchu.quickshop.addon.displaycontrol.database;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction;
import cc.carm.lib.easysql.api.builder.*;
import cc.carm.lib.easysql.api.enums.IndexType;
import cc.carm.lib.easysql.api.function.SQLHandler;
import com.ghostchu.quickshop.util.Util;
import com.ghostchu.quickshop.util.logger.Log;
import org.jetbrains.annotations.NotNull;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
public enum DisplayControlTables {
DISPLAY_CONTROL_PLAYERS("display_control_psettings", (table) -> {
table.addAutoIncrementColumn("id", true); // SHOP DATA ID
table.addColumn("player", "VARCHAR(36) NOT NULL"); // SHOP DATA OWNER (ALL-ZERO if this is server)
table.addColumn("displayOption", "INT NOT NULL DEFAULT 0"); // DISPLAY SETTINGS, JSON ENCODE
table.setIndex(IndexType.INDEX, "idx_qs_addon_display_control_psettings", "player");
});
private final @NotNull String name;
private final @NotNull SQLHandler<TableCreateBuilder> tableHandler;
private String prefix;
private SQLManager manager;
DisplayControlTables(@NotNull String name,
@NotNull SQLHandler<TableCreateBuilder> tableHandler) {
this.name = name;
this.tableHandler = tableHandler;
}
public static void initializeTables(@NotNull SQLManager sqlManager,
@NotNull String tablePrefix) throws SQLException {
for (DisplayControlTables value : values()) {
value.create(sqlManager, tablePrefix);
}
}
private void create(@NotNull SQLManager sqlManager, @NotNull String tablePrefix) throws SQLException {
if (this.manager == null) {
this.manager = sqlManager;
}
this.prefix = tablePrefix;
TableCreateBuilder tableBuilder = sqlManager.createTable(this.getName());
tableHandler.accept(tableBuilder);
tableBuilder.build().execute();
Log.debug("Table creating:" + this.getName());
}
public @NotNull String getName() {
return this.prefix + this.name;
}
public @NotNull DeleteBuilder createDelete() {
return this.createDelete(this.manager);
}
public @NotNull DeleteBuilder createDelete(@NotNull SQLManager sqlManager) {
return sqlManager.createDelete(this.getName());
}
public @NotNull InsertBuilder<PreparedSQLUpdateAction<Integer>> createInsert() {
return this.createInsert(this.manager);
}
public @NotNull InsertBuilder<PreparedSQLUpdateAction<Integer>> createInsert(@NotNull SQLManager sqlManager) {
return sqlManager.createInsert(this.getName());
}
public @NotNull InsertBuilder<PreparedSQLUpdateBatchAction<Integer>> createInsertBatch() {
return this.createInsertBatch(this.manager);
}
public @NotNull InsertBuilder<PreparedSQLUpdateBatchAction<Integer>> createInsertBatch(@NotNull SQLManager sqlManager) {
return sqlManager.createInsertBatch(this.getName());
}
public @NotNull TableQueryBuilder createQuery() {
return this.createQuery(this.manager);
}
public @NotNull TableQueryBuilder createQuery(@NotNull SQLManager sqlManager) {
return sqlManager.createQuery().inTable(this.getName());
}
public @NotNull ReplaceBuilder<PreparedSQLUpdateAction<Integer>> createReplace() {
return this.createReplace(this.manager);
}
public @NotNull ReplaceBuilder<PreparedSQLUpdateAction<Integer>> createReplace(@NotNull SQLManager sqlManager) {
return sqlManager.createReplace(this.getName());
}
public @NotNull ReplaceBuilder<PreparedSQLUpdateBatchAction<Integer>> createReplaceBatch() {
return this.createReplaceBatch(this.manager);
}
public @NotNull ReplaceBuilder<PreparedSQLUpdateBatchAction<Integer>> createReplaceBatch(@NotNull SQLManager sqlManager) {
return sqlManager.createReplaceBatch(this.getName());
}
public @NotNull UpdateBuilder createUpdate() {
return this.createUpdate(this.manager);
}
public @NotNull UpdateBuilder createUpdate(@NotNull SQLManager sqlManager) {
return sqlManager.createUpdate(this.getName());
}
public boolean isExists() {
return isExists(this.manager);
}
public boolean isExists(@NotNull SQLManager manager) {
boolean match = false;
try {
try (Connection connection = manager.getConnection(); ResultSet rs = connection.getMetaData().getTables(null, null, "%", null)) {
while (rs.next()) {
if (getName().equalsIgnoreCase(rs.getString("TABLE_NAME"))) {
match = true;
break;
}
}
}
} catch (SQLException e) {
if (Util.isDevMode()) {
e.printStackTrace();
}
Log.debug("Error while checking table existence: " + getName());
}
return match;
}
public boolean purgeTable() {
return purgeTable(this.manager);
}
public boolean purgeTable(@NotNull SQLManager sqlManager) {
try {
sqlManager.createDelete(this.getName())
.addCondition("1=1")
.build().execute();
return true;
} catch (SQLException e) {
Log.debug("Failed to purge table " + this.getName() + e);
return false;
}
}
}
@@ -1 +0,0 @@
config-version: 1
@@ -1,11 +0,0 @@
name: qsaddon-${project.artifactId}
version: '${project.version}'
main: com.ghostchu.quickshop.addon.${project.artifactId}.Main
api-version: 1.18
depend:
- QuickShop-Hikari
authors: [ Ghost_chu ]
permissions:
quickshopaddon.displaycontrol.use:
description: Allows players to use displaycontrol commands
default: true
-78
View File
@@ -1,78 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
<artifactId>dynmap</artifactId>
<packaging>jar</packaging>
<name>Addon-Dynmap</name>
<description>Displaying the quickshops on your Dynmap instance</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>MikeRepo</id>
<url>https://repo.mikeprimm.com/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>3.4-beta-3</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -1,182 +0,0 @@
package com.ghostchu.quickshop.addon.dynmap;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.api.event.*;
import com.ghostchu.quickshop.api.localization.text.TextManager;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.api.shop.ShopType;
import com.ghostchu.quickshop.util.PackageUtil;
import com.ghostchu.quickshop.util.Util;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.dynmap.DynmapAPI;
import org.dynmap.markers.*;
import org.jetbrains.annotations.NotNull;
public final class Main extends JavaPlugin implements Listener {
static Main instance;
private QuickShop plugin;
private DynmapAPI dynmapAPI;
private MarkerAPI markerAPI;
@Override
public void onLoad() {
instance = this;
}
@Override
public void onDisable() {
HandlerList.unregisterAll((Plugin) this);
}
@Override
public void onEnable() {
saveDefaultConfig();
plugin = QuickShop.getInstance();
this.dynmapAPI = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap");
this.markerAPI = this.dynmapAPI.getMarkerAPI();
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getScheduler().runTaskLater(this, this::updateAllMarkers, 80);
}
@EventHandler(ignoreCancelled = true)
public void onEvent(WorldLoadEvent event) {
Util.mainThreadRun(this::updateAllMarkers);
}
@EventHandler(ignoreCancelled = true)
public void onEvent(WorldUnloadEvent event) {
Util.mainThreadRun(this::updateAllMarkers);
}
@EventHandler(ignoreCancelled = true)
public void onEvent(QSConfigurationReloadEvent event) {
Util.mainThreadRun(this::updateAllMarkers);
}
@EventHandler(ignoreCancelled = true)
public void onEvent(ShopCreateSuccessEvent event) {
updateShopMarker(event.getShop());
}
@EventHandler(ignoreCancelled = true)
public void onEvent(ShopDeleteEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}
@EventHandler(ignoreCancelled = true)
public void onEvent(ShopPriceChangeEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}
@EventHandler(ignoreCancelled = true)
public void onEvent(ShopItemChangeEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}
@EventHandler(ignoreCancelled = true)
public void onEvent(ShopOwnershipTransferEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}
@EventHandler(ignoreCancelled = true)
public void onEvent(ShopSuccessPurchaseEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}
@EventHandler(ignoreCancelled = true)
public void onEvent(ShopTypeChangeEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}
@EventHandler(ignoreCancelled = true)
public void onEvent(ShopNamingEvent event) {
Util.mainThreadRun(() -> updateShopMarker(event.getShop()));
}
@NotNull
public String plain(@NotNull Component component) {
return PlainTextComponentSerializer.plainText().serialize(component);
}
@NotNull
public TextManager text() {
return plugin.getTextManager();
}
public MarkerSet getMarkerSet() {
String id = PackageUtil.parsePackageProperly("marker-id").asString("quickshop-hikari-shops");
MarkerSet markerSet = markerAPI.getMarkerSet(id);
if (markerSet == null) {
markerSet = markerAPI.createMarkerSet(id, plain(text().of("addon.dynmap.markerset-title").forLocale()), null, false);
}
markerSet.setHideByDefault(getConfig().getBoolean("display-by-default", true));
return markerSet;
}
public MarkerIcon getShopMarkerIcon() {
return markerAPI.getMarkerIcon(PackageUtil.parsePackageProperly("marker-icon").asString("chest"));
}
public void updateAllMarkers() {
MarkerSet markerSet = getMarkerSet();
markerSet.getMarkers().forEach(GenericMarker::deleteMarker);
for (Shop shop : plugin.getShopManager().getAllShops()) {
updateShopMarker(shop);
}
}
public void updateShopMarker(Shop shop) {
MarkerSet markerSet = getMarkerSet();
String shopName = shop.getShopName();
String posStr = String.format("%s %s, %s, %s", shop.getLocation().getWorld().getName(), shop.getLocation().getBlockX(), shop.getLocation().getBlockY(), shop.getLocation().getBlockZ());
if (shopName == null) {
shopName = posStr;
}
Marker marker = markerSet.findMarker("quickshop-hikari-shop-" + shop.getShopId());
String markerName = plain(text().of("addon.dynmap.marker-name",
shopName,
plain(shop.ownerName()),
plain(Util.getItemStackName(shop.getItem())),
plugin.getShopManager().format(shop.getPrice(), shop),
shop.getShopStackingAmount(),
shop.getShopType() == ShopType.SELLING ? plain(text().of("shop-type.selling").forLocale()) : plain(text().of("shop-type.buying").forLocale()),
shop.isUnlimited(),
posStr
).forLocale());
if (marker == null) {
marker = markerSet.createMarker("quickshop-hikari-shop-" + shop.getShopId()
, markerName
, shop.getLocation().getWorld().getName(),
shop.getLocation().getX(),
shop.getLocation().getY(),
shop.getLocation().getZ(),
getShopMarkerIcon(), false);
} else {
marker.setLocation(shop.getLocation().getWorld().getName(),
shop.getLocation().getX(),
shop.getLocation().getY(),
shop.getLocation().getZ());
}
String desc = plain(text().of("addon.dynmap.marker-description",
shopName,
plain(shop.ownerName()),
plain(Util.getItemStackName(shop.getItem())),
plugin.getShopManager().format(shop.getPrice(), shop),
shop.getShopStackingAmount(),
shop.getShopType() == ShopType.SELLING ? plain(text().of("shop-type.selling").forLocale()) : plain(text().of("shop-type.buying").forLocale()),
shop.isUnlimited(),
posStr
).forLocale());
marker.setDescription(desc.replace("\n", "<br/>"));
}
}
@@ -1,2 +0,0 @@
config-version: 1
display-by-default: true
@@ -1,7 +0,0 @@
name: qsaddon-${project.artifactId}
version: '${project.version}'
main: com.ghostchu.quickshop.addon.${project.artifactId}.Main
api-version: 1.18
depend:
- dynmap
authors: [ Ghost_chu ]
-83
View File
@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
<artifactId>limited</artifactId>
<packaging>jar</packaging>
<name>Addon-Limited</name>
<description>Limit the player max amount of item can purchase in your specific shop</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
<repository>
<id>Scarsz-Nexus</id>
<url>https://nexus.scarsz.me/content/groups/public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.kyori</groupId>-->
<!-- <artifactId>adventure-text-serializer-plain</artifactId>-->
<!-- <version>4.12.0</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
</dependencies>
</project>
@@ -1,145 +0,0 @@
package com.ghostchu.quickshop.addon.limited;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.limited.command.SubCommand_Limit;
import com.ghostchu.quickshop.api.command.CommandContainer;
import com.ghostchu.quickshop.api.event.CalendarEvent;
import com.ghostchu.quickshop.api.event.ShopClickEvent;
import com.ghostchu.quickshop.api.event.ShopPurchaseEvent;
import com.ghostchu.quickshop.api.event.ShopSuccessPurchaseEvent;
import com.ghostchu.quickshop.api.localization.text.Text;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.util.Util;
import com.ghostchu.quickshop.util.logger.Log;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.UUID;
public final class Main extends JavaPlugin implements Listener {
public static Main instance;
private QuickShop plugin;
private CommandContainer container;
@Override
public void onDisable() {
// Plugin shutdown logic
plugin.getCommandManager().unregisterCmd(container);
}
@Override
public void onEnable() {
// Plugin startup logic
instance = this;
saveDefaultConfig();
Bukkit.getPluginManager().registerEvents(this, this);
this.plugin = QuickShop.getInstance();
this.container = CommandContainer.builder()
.prefix("limit")
.permission("quickshopaddon.limit.use")
.description((locale) -> plugin.text().of("addon.limited.commands.limit").forLocale(locale))
.executor(new SubCommand_Limit(plugin))
.build();
plugin.getCommandManager().registerCmd(container);
}
@EventHandler(ignoreCancelled = true)
public void shopPurchase(ShopPurchaseEvent event) {
Shop shop = event.getShop();
ConfigurationSection storage = shop.getExtra(this);
if (storage.getInt("limit") < 1) {
return;
}
int limit = storage.getInt("limit");
UUID uuid = event.getPurchaser().getUniqueIdIfRealPlayer().orElse(null);
if (uuid != null) {
int playerUsedLimit = storage.getInt("data." + uuid, 0);
if (playerUsedLimit + event.getAmount() > limit) {
Text text = plugin.text().of(event.getPurchaser(), "addon.limited.trade-limit-reached-cancel-reason");
text.send();
event.setCancelled(true, PlainTextComponentSerializer.plainText().serialize(text.forLocale()));
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void shopClick(ShopClickEvent event) {
Shop shop = event.getShop();
ConfigurationSection storage = shop.getExtra(this);
if (storage.getInt("limit") < 1) {
Log.debug("Shop limit is not enabled on this shop.");
return;
}
int limit = storage.getInt("limit");
int playerUsedLimit = storage.getInt("data." + event.getClicker().getUniqueId(), 0);
plugin.text().of(event.getClicker(), "addon.limited.remains-limits", limit - playerUsedLimit).send();
Log.debug("Shop limit is enabled on this shop. Limit: " + limit + " Used: " + playerUsedLimit);
}
@EventHandler(priority = EventPriority.MONITOR)
public void shopPurchaseSuccess(ShopSuccessPurchaseEvent event) {
Shop shop = event.getShop();
ConfigurationSection storage = shop.getExtra(this);
if (storage.getInt("limit") < 1) {
return;
}
UUID uuid = event.getPurchaser().getUniqueIdIfRealPlayer().orElse(null);
if (uuid != null) {
int limit = storage.getInt("limit");
int playerUsedLimit = storage.getInt("data." + uuid, 0);
playerUsedLimit += event.getAmount();
storage.set("data." + uuid, playerUsedLimit);
shop.setExtra(this, storage);
Player player = Bukkit.getPlayer(uuid);
if (player != null) {
player.sendTitle(
LegacyComponentSerializer.legacySection()
.serialize(plugin.text().of(player, "addon.limited.titles.title")
.forLocale()),
LegacyComponentSerializer.legacySection()
.serialize(plugin.text().of(player, "addon.limited.titles.subtitle"
, (limit - playerUsedLimit)).forLocale()));
}
}
}
@EventHandler(ignoreCancelled = true)
public void scheduleEvent(CalendarEvent event) {
if (event.getCalendarTriggerType() == CalendarEvent.CalendarTriggerType.SECOND
|| event.getCalendarTriggerType() == CalendarEvent.CalendarTriggerType.NOTHING_CHANGED) {
return;
}
Util.asyncThreadRun(() -> plugin.getShopManager().getAllShops().forEach(shop -> {
ConfigurationSection manager = shop.getExtra(this);
int limit = manager.getInt("limit");
if (limit < 1) {
return;
}
if (StringUtils.isEmpty(manager.getString("period"))) {
return;
}
try {
if (event.getCalendarTriggerType().ordinal() >= CalendarEvent.CalendarTriggerType.valueOf(manager.getString("period")).ordinal()) {
manager.set("data", null);
shop.setExtra(this, manager);
Log.debug("Limit data has been reset. Shop -> " + shop);
}
} catch (IllegalArgumentException ignored) {
Log.debug("Limit data failed to reset. Shop -> " + shop + " type " + manager.getString("period") + " not exists.");
manager.set("period", null);
shop.setExtra(this, manager);
}
}));
}
}
@@ -1,99 +0,0 @@
package com.ghostchu.quickshop.addon.limited.command;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.limited.Main;
import com.ghostchu.quickshop.api.command.CommandHandler;
import com.ghostchu.quickshop.api.command.CommandParser;
import com.ghostchu.quickshop.api.event.CalendarEvent;
import com.ghostchu.quickshop.api.shop.Shop;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
public class SubCommand_Limit implements CommandHandler<Player> {
private final QuickShop quickshop;
public SubCommand_Limit(QuickShop quickshop) {
this.quickshop = quickshop;
}
@Override
public void onCommand(Player sender, @NotNull String commandLabel, @NotNull CommandParser parser) {
if (parser.getArgs().isEmpty()) {
quickshop.text().of(sender, "command.wrong-args").send();
return;
}
Shop shop = getLookingShop(sender);
if (shop == null) {
quickshop.text().of(sender, "not-looking-at-shop").send();
return;
}
ConfigurationSection manager = shop.getExtra(Main.instance);
switch (parser.getArgs().get(0)) {
case "set" -> {
try {
int limitAmount = Integer.parseInt(parser.getArgs().get(1));
if (limitAmount > 0) {
manager.set("limit", limitAmount);
quickshop.text().of(sender, "addon.limited.success-setup").send();
} else {
manager.set("limit", null);
manager.set("data", null);
quickshop.text().of(sender, "addon.limited.success-remove").send();
}
shop.setExtra(Main.instance, manager);
} catch (NumberFormatException e) {
quickshop.text().of(sender, "not-a-integer", parser.getArgs().get(1)).send();
}
}
case "unset" -> {
manager.set("limit", null);
manager.set("data", null);
quickshop.text().of(sender, "addon.limited.success-remove").send();
shop.setExtra(Main.instance, manager);
}
case "reset" -> {
manager.set("data", null);
shop.setExtra(Main.instance, manager);
quickshop.text().of(sender, "addon.limited.success-reset").send();
}
case "period" -> {
try {
CalendarEvent.CalendarTriggerType type = CalendarEvent.CalendarTriggerType.valueOf(parser.getArgs().get(1).toUpperCase(Locale.ROOT));
manager.set("period", type.name());
quickshop.text().of(sender, "addon.limited.success-setup").send();
shop.setExtra(Main.instance, manager);
} catch (IllegalArgumentException ignored) {
quickshop.text().of(sender, "command.wrong-args", parser.getArgs().get(1)).send();
}
}
}
}
@Override
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
if (cmdArg.length < 2) {
return List.of("set", "unset", "reset", "period");
}
if (cmdArg.length < 3) {
switch (cmdArg[0]) {
case "set" -> {
return List.of("<max>");
}
case "period" -> {
return Arrays.stream(CalendarEvent.CalendarTriggerType.values())
.filter(e -> !e.equals(CalendarEvent.CalendarTriggerType.SECOND))
.filter(e -> !e.equals(CalendarEvent.CalendarTriggerType.NOTHING_CHANGED))
.map(Enum::name).toList();
}
}
}
return Collections.emptyList();
}
}
@@ -1 +0,0 @@
config-version: 1
@@ -1,11 +0,0 @@
name: qssuite-limited
version: '${project.version}'
main: com.ghostchu.quickshop.addon.${project.artifactId}.Main
api-version: 1.18
depend:
- QuickShop-Hikari
authors: [ Ghost_chu ]
permissions:
quickshopaddon.limit.use:
description: Allow player to use /quickshop limit
default: op
-83
View File
@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
<artifactId>list</artifactId>
<packaging>jar</packaging>
<name>Addon-List</name>
<description>Listing the all your quickshop</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
<repository>
<id>Scarsz-Nexus</id>
<url>https://nexus.scarsz.me/content/groups/public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.kyori</groupId>-->
<!-- <artifactId>adventure-text-serializer-plain</artifactId>-->
<!-- <version>4.12.0</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
</dependencies>
</project>
@@ -29,11 +29,11 @@ public final class Main extends JavaPlugin implements Listener {
plugin = QuickShop.getInstance();
getLogger().info("Registering the per shop permissions...");
Bukkit.getPluginManager().registerEvents(this, this);
plugin.getCommandManager().registerCmd(
CommandContainer
.builder()
plugin.getCommandManager()
.registerCmd(CommandContainer.builder()
.prefix("list")
.description((locale) -> plugin.text().of("addon.list.commands.list").forLocale(locale))
.description((locale) ->
plugin.text().of("addon.list.commands.list").forLocale(locale))
.selectivePermission("quickshopaddon.list.self")
.selectivePermission("quickshopaddon.list.other")
.executor(new SubCommand_List(plugin))
@@ -1,11 +1,16 @@
package com.ghostchu.quickshop.addon.list.command;
import static com.ghostchu.quickshop.util.Util.getPlayerList;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.api.command.CommandHandler;
import com.ghostchu.quickshop.api.command.CommandParser;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.util.ChatSheetPrinter;
import com.ghostchu.quickshop.util.Util;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
@@ -16,12 +21,6 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import static com.ghostchu.quickshop.util.Util.getPlayerList;
public class SubCommand_List implements CommandHandler<Player> {
private final QuickShop quickshop;
@@ -39,7 +38,8 @@ public class SubCommand_List implements CommandHandler<Player> {
}
@Override
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull CommandParser parser) {
public @Nullable List<String> onTabComplete(
@NotNull Player sender, @NotNull String commandLabel, @NotNull CommandParser parser) {
if (parser.getArgs().size() == 1) {
if (sender.hasPermission("quickshopaddon.list.other")) {
return getPlayerList();
@@ -73,24 +73,53 @@ public class SubCommand_List implements CommandHandler<Player> {
List<Shop> shops = quickshop.getShopManager().getAllShops(lookupUser);
ChatSheetPrinter printer = new ChatSheetPrinter(sender);
printer.printHeader();
printer.printLine(quickshop.text().of(sender, "addon.list.table-prefix", name, shops.size()).forLocale());
printer.printLine(quickshop
.text()
.of(sender, "addon.list.table-prefix", name, shops.size())
.forLocale());
int counter = 1;
for (Shop shop : shops) {
String shopName = shop.getShopName();
Location location = shop.getLocation();
String combineLocation = location.getWorld().getName() + " " + location.getBlockX() + ", " + location.getBlockY() + ", " + location.getBlockZ();
String combineLocation = location.getWorld().getName() + " " + location.getBlockX() + ", "
+ location.getBlockY() + ", " + location.getBlockZ();
if (StringUtils.isEmpty(shopName)) {
shopName = combineLocation;
}
Component shopNameComponent = LegacyComponentSerializer.legacySection().deserialize(shopName).append(Component.textOfChildren(Component.text(" (").append(Util.getItemStackName(shop.getItem())).append(Component.text(")"))).color(NamedTextColor.GRAY));
Component shopNameComponent = LegacyComponentSerializer.legacySection()
.deserialize(shopName)
.append(Component.textOfChildren(Component.text(" (")
.append(Util.getItemStackName(shop.getItem()))
.append(Component.text(")")))
.color(NamedTextColor.GRAY));
Component shopTypeComponent;
if (shop.isBuying()) {
shopTypeComponent = quickshop.text().of(sender, "menu.this-shop-is-buying").forLocale();
shopTypeComponent =
quickshop.text().of(sender, "menu.this-shop-is-buying").forLocale();
} else {
shopTypeComponent = quickshop.text().of(sender, "menu.this-shop-is-selling").forLocale();
shopTypeComponent =
quickshop.text().of(sender, "menu.this-shop-is-selling").forLocale();
}
Component component = quickshop.text().of(sender, "addon.list.entry", counter, shopNameComponent, location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), quickshop.getEconomy().format(shop.getPrice(), shop.getLocation().getWorld(), shop.getCurrency()), shop.getShopStackingAmount(), Util.getItemStackName(shop.getItem()), shopTypeComponent).forLocale();
component = component.clickEvent(ClickEvent.runCommand("/quickshop silentpreview " + shop.getRuntimeRandomUniqueId()));
Component component = quickshop
.text()
.of(
sender,
"addon.list.entry",
counter,
shopNameComponent,
location.getWorld().getName(),
location.getBlockX(),
location.getBlockY(),
location.getBlockZ(),
quickshop
.getEconomy()
.format(shop.getPrice(), shop.getLocation().getWorld(), shop.getCurrency()),
shop.getShopStackingAmount(),
Util.getItemStackName(shop.getItem()),
shopTypeComponent)
.forLocale();
component = component.clickEvent(
ClickEvent.runCommand("/quickshop silentpreview " + shop.getRuntimeRandomUniqueId()));
printer.printLine(component);
counter++;
}
-113
View File
@@ -1,113 +0,0 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# Common working directory
run/
-89
View File
@@ -1,89 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
<artifactId>plan</artifactId>
<packaging>jar</packaging>
<name>Addon-Plan</name>
<description>Showcase the metrics about QuickShop-Hikari on your Plan page</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>jitpack</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.plan-player-analytics</groupId>
<artifactId>Plan</artifactId>
<version>5.6.2614</version> <!-- Add the version number here -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.juliomarcopineda</groupId>
<artifactId>jdbc-stream</artifactId>
<version>0.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>easysql-api</artifactId>
<version>0.4.7</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.kyori</groupId>-->
<!-- <artifactId>adventure-text-serializer-plain</artifactId>-->
<!-- <version>4.12.0</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
</dependencies>
</project>
@@ -1,181 +0,0 @@
package com.ghostchu.quickshop.addon.plan;
import com.djrapitops.plan.extension.CallEvents;
import com.djrapitops.plan.extension.DataExtension;
import com.djrapitops.plan.extension.annotation.*;
import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.table.Table;
import com.ghostchu.quickshop.addon.plan.util.DataUtil;
import com.ghostchu.quickshop.addon.plan.util.DateUtil;
import com.ghostchu.quickshop.addon.plan.util.MetricQuery;
import com.ghostchu.quickshop.api.database.ShopMetricRecord;
import com.ghostchu.quickshop.api.database.bean.DataRecord;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.common.util.CommonUtil;
import com.ghostchu.quickshop.database.SimpleDatabaseHelperV2;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import java.text.DecimalFormat;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
@PluginInfo(name = "QuickShop-Hikari", iconName = "credit-card", iconFamily = Family.REGULAR, color = Color.LIGHT_BLUE)
@TabInfo(tab = "Summary", iconName = "info-circle", iconFamily = Family.SOLID, elementOrder = {})
@TabInfo(tab = "Purchases", iconName = "inbox", elementOrder = {})
@TabInfo(tab = "Shops", iconName = "list", iconFamily = Family.SOLID, elementOrder = {})
@TabOrder({"Summary", "Purchases", "Shops"})
public class HikariDataExtension implements DataExtension {
private final Main main;
private final MetricQuery metricQuery;
private final DataUtil dataUtil;
private final DecimalFormat df = new DecimalFormat("#.00");
public HikariDataExtension(Main main) {
this.main = main;
this.dataUtil = new DataUtil(main);
this.metricQuery = new MetricQuery(main.getQuickShop(), (SimpleDatabaseHelperV2) main.getQuickShop().getDatabaseHelper());
}
@Override
public CallEvents[] callExtensionMethodsOn() {
return new CallEvents[]{
CallEvents.PLAYER_LEAVE,
CallEvents.SERVER_PERIODICAL};
}
// ======================= GLOBAL PROVIDERS =======================
@StringProvider(text = "Total shops", description = "How many shops exists on this server", iconName = "hashtable", iconColor = Color.GREEN, priority = 100)
@Tab("Summary")
public String shopCreated() {
return String.valueOf(main.getQuickShop().getShopManager().getAllShops().size());
}
@Tab("Summary")
@StringProvider(text = "Total purchases", description = "Number of purchases on this server", iconName = "hashtable", iconColor = Color.GREEN, priority = 100)
public String totalTransactions() {
return String.valueOf(metricQuery.queryServerPurchaseCount());
}
@TableProvider(tableColor = Color.BLUE)
@Tab("Purchases")
public Table purchasesTab() {
Table.Factory tableBuilder = Table.builder()
.columnOne("Player", Icon.called("user").build())
.columnTwo("Action", Icon.called("code-branch").build())
.columnThree("Shop", Icon.called("shopping-cart").build())
.columnFour("Item(amount)", Icon.called("box").build())
.columnFive("Balance", Icon.called("money-bill-wave").build());
List<ShopMetricRecord> records = this.metricQuery.queryServerPurchaseRecords(DateUtil.daysAgo(365), 1000, true).stream().filter(record -> switch (record.getType()) {
//noinspection deprecation
case PURCHASE, PURCHASE_BUYING_SHOP, PURCHASE_SELLING_SHOP -> true;
default -> false;
}).toList();
try {
LinkedHashMap<ShopMetricRecord, DataRecord> recordsMapped = this.metricQuery.mapToDataRecord(records);
recordsMapped.forEach((metric, data) -> {
String player = metric.getPlayer();
String action = CommonUtil.prettifyText(metric.getType().name());
String shop = dataUtil.getShopName(metric, data);
String item = dataUtil.getItemName(data) + " (" + metric.getAmount() + ")";
String balance = dataUtil.formatEconomy(metric);
tableBuilder.addRow(player, action, shop, item, balance);
});
} catch (ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
}
return tableBuilder.build();
}
@TableProvider(tableColor = Color.CYAN)
@Tab("Shops")
public Table shopsTab() {
Table.Factory tableBuilder = Table.builder()
.columnOne("Owner", Icon.called("user").build())
.columnTwo("Item", Icon.called("shopping-cart").build())
.columnThree("Price", Icon.called("money-bill-wave").build())
.columnFour("Type", Icon.called("code-branch").build())
.columnFive("Location", Icon.called("location-arrow").build());
for (Shop shop : main.getQuickShop().getShopManager().getAllShops()) {
String owner = PlainTextComponentSerializer.plainText().serialize(shop.ownerName());
String item = dataUtil.getItemName(shop.getItem()) + " x" + shop.getShopStackingAmount();
String price = df.format(shop.getPrice());
if (main.getQuickShop().getEconomy() != null) {
price = main.getQuickShop().getEconomy().format(shop.getPrice(), shop.getLocation().getWorld(), shop.getCurrency());
}
String type = switch (shop.getShopType()) {
case BUYING -> "Buying";
case SELLING -> "Selling";
};
String location = dataUtil.loc2String(shop.getLocation());
tableBuilder.addRow(owner, item, price, type, location);
}
return tableBuilder.build();
}
// ======================= PLAYER PROVIDERS =======================
@StringProvider(text = "Owned shops", description = "How many shops created and exists by this player", iconName = "hashtable", iconColor = Color.GREEN, priority = 100, showInPlayerTable = true)
public String shopCreatedPlayer(UUID playerUUID) {
return String.valueOf(main.getQuickShop().getShopManager().getAllShops(playerUUID).size());
}
@TableProvider(tableColor = Color.BLUE)
@Tab("Purchases")
public Table purchasesTabPlayer(UUID playerUUID) {
Table.Factory tableBuilder = Table.builder()
.columnOne("Action", Icon.called("code-branch").build())
.columnTwo("Location", Icon.called("location-arrow").build())
.columnThree("Item(amount)", Icon.called("box").build())
.columnFour("Balance", Icon.called("money-bill-wave").build());
List<ShopMetricRecord> records = this.metricQuery.queryServerPurchaseRecords(DateUtil.daysAgo(365), 50, true).stream().filter(record -> switch (record.getType()) {
//noinspection deprecation
case PURCHASE, PURCHASE_BUYING_SHOP, PURCHASE_SELLING_SHOP -> true;
default -> false;
}).toList();
try {
LinkedHashMap<ShopMetricRecord, DataRecord> recordsMapped = this.metricQuery.mapToDataRecord(records);
recordsMapped.forEach((metric, data) -> {
String action = CommonUtil.prettifyText(metric.getType().name());
String shop = dataUtil.getShopName(metric, data);
String item = dataUtil.getItemName(data) + " (" + metric.getAmount() + ")";
String balance = dataUtil.formatEconomy(metric);
tableBuilder.addRow(action, shop, item, balance);
});
} catch (ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
}
return tableBuilder.build();
}
@TableProvider(tableColor = Color.CYAN)
@Tab("Shops")
public Table shopsTabPlayer(UUID playerUUID) {
Table.Factory tableBuilder = Table.builder()
.columnOne("Item", Icon.called("shopping-cart").build())
.columnTwo("Price", Icon.called("money-bill-wave").build())
.columnThree("Type", Icon.called("code-branch").build())
.columnFour("Location", Icon.called("location-arrow").build());
for (Shop shop : main.getQuickShop().getShopManager().getAllShops(playerUUID)) {
String item = dataUtil.getItemName(shop.getItem()) + " x" + shop.getShopStackingAmount();
String price = df.format(shop.getPrice());
if (main.getQuickShop().getEconomy() != null) {
price = main.getQuickShop().getEconomy().format(shop.getPrice(), shop.getLocation().getWorld(), shop.getCurrency());
}
String type = switch (shop.getShopType()) {
case BUYING -> "Buying";
case SELLING -> "Selling";
};
String location = dataUtil.loc2String(shop.getLocation());
tableBuilder.addRow(item, price, type, location);
}
return tableBuilder.build();
}
}
@@ -1,20 +0,0 @@
package com.ghostchu.quickshop.addon.plan;
import com.ghostchu.quickshop.QuickShop;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public final class Main extends JavaPlugin implements Listener {
private QuickShop quickshop;
@Override
public void onEnable() {
saveDefaultConfig();
quickshop = QuickShop.getInstance();
new PlanHook(this).hookIntoPlan();
}
public QuickShop getQuickShop() {
return quickshop;
}
}
@@ -1,46 +0,0 @@
package com.ghostchu.quickshop.addon.plan;
import com.djrapitops.plan.capability.CapabilityService;
import com.djrapitops.plan.extension.ExtensionService;
import org.bukkit.Bukkit;
public class PlanHook {
private final Main main;
private final CapabilityService capabilities = CapabilityService.getInstance();
public PlanHook(Main main) {
this.main = main;
}
public void hookIntoPlan() {
registerDataExtension();
listenForPlanReloads();
}
private void registerDataExtension() {
try {
if (capabilities.hasCapability("DATA_EXTENSION_TABLES")
&& capabilities.hasCapability("DATA_EXTENSION_VALUES")) {
ExtensionService.getInstance().register(new HikariDataExtension(main));
} else {
main.getLogger().severe("Your Plan build doesn't support DATA_EXTENSION_TABLES or DATA_EXTENSION_VALUES capability!");
Bukkit.getPluginManager().disablePlugin(main);
}
} catch (IllegalStateException planIsNotEnabled) {
// Plan is not enabled, handle exception
} catch (IllegalArgumentException dataExtensionImplementationIsInvalid) {
// The DataExtension implementation has an implementation error, handle exception
}
}
private void listenForPlanReloads() {
CapabilityService.getInstance().registerEnableListener(
isPlanEnabled -> {
// Register DataExtension again
if (isPlanEnabled) {
registerDataExtension();
}
}
);
}
}
@@ -1,102 +0,0 @@
package com.ghostchu.quickshop.addon.plan.util;
import com.ghostchu.quickshop.addon.plan.Main;
import com.ghostchu.quickshop.api.database.ShopMetricRecord;
import com.ghostchu.quickshop.api.database.bean.DataRecord;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.common.util.CommonUtil;
import com.ghostchu.quickshop.util.Util;
import com.google.common.html.HtmlEscapers;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.text.DecimalFormat;
import java.util.UUID;
public class DataUtil {
public final Main main;
public DataUtil(@NotNull Main main) {
this.main = main;
}
@NotNull
public String formatEconomy(@NotNull ShopMetricRecord record) {
Shop shop = main.getQuickShop().getShopManager().getShop(record.getShopId());
if (shop == null || main.getQuickShop().getEconomy() == null) {
DecimalFormat df = new DecimalFormat("#.00");
return df.format(record.getTotal());
}
return main.getQuickShop().getEconomy().format(record.getTotal(), shop.getLocation().getWorld(), shop.getCurrency());
}
@NotNull
public String getItemName(@NotNull DataRecord dataRecord) {
ItemStack stack;
try {
stack = Util.deserialize(dataRecord.getItem());
} catch (InvalidConfigurationException e) {
return "[Failed to deserialize]";
}
if (stack == null) {
return "[Failed to deserialize]";
}
String name = CommonUtil.prettifyText(stack.getType().name());
if (stack.getItemMeta() != null && stack.getItemMeta().hasDisplayName()) {
name = stack.getItemMeta().getDisplayName();
}
return HtmlEscapers.htmlEscaper().escape(name);
}
@NotNull
public String getItemName(@NotNull ItemStack stack) {
String name = CommonUtil.prettifyText(stack.getType().name());
if (stack.getItemMeta() != null && stack.getItemMeta().hasDisplayName()) {
name = stack.getItemMeta().getDisplayName();
}
return HtmlEscapers.htmlEscaper().escape(name);
}
@NotNull
public String getShopName(@NotNull ShopMetricRecord record, @NotNull DataRecord dataRecord) {
StringBuilder nameBuilder = new StringBuilder();
Shop shop = main.getQuickShop().getShopManager().getShop(record.getShopId());
if (shop == null) {
nameBuilder.append("[Deleted] ");
}
String shopName = dataRecord.getName();
if (shopName != null) {
nameBuilder.append(ChatColor.stripColor(shopName));
} else {
if (shop != null) {
Location location = shop.getLocation();
String template = "%s %s,%s,%s";
nameBuilder.append(String.format(template, location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()));
} else {
nameBuilder.append("N/A");
}
}
return HtmlEscapers.htmlEscaper().escape(nameBuilder.toString());
}
@NotNull
public String loc2String(@NotNull Location location) {
String template = "%s %s,%s,%s";
return String.format(template, location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
@NotNull
public String getPlayerName(@NotNull UUID uuid) {
if (CommonUtil.getNilUniqueId().equals(uuid)) {
return "[Server]";
}
String name = main.getQuickShop().getPlayerFinder().uuid2Name(uuid);
if (name == null || name.isEmpty()) {
return uuid.toString();
}
return HtmlEscapers.htmlEscaper().escape(name);
}
}
@@ -1,15 +0,0 @@
package com.ghostchu.quickshop.addon.plan.util;
import org.jetbrains.annotations.NotNull;
import java.util.Calendar;
import java.util.Date;
public class DateUtil {
@NotNull
public static Date daysAgo(int ago) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, -ago);
return cal.getTime();
}
}
@@ -1,120 +0,0 @@
package com.ghostchu.quickshop.addon.plan.util;
import cc.carm.lib.easysql.api.SQLQuery;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.api.database.ShopMetricRecord;
import com.ghostchu.quickshop.api.database.ShopOperationEnum;
import com.ghostchu.quickshop.api.database.bean.DataRecord;
import com.ghostchu.quickshop.database.SimpleDatabaseHelperV2;
import com.ghostchu.quickshop.obj.QUserImpl;
import com.ghostchu.quickshop.util.logger.Log;
import org.jetbrains.annotations.NotNull;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ExecutionException;
public class MetricQuery {
private final SimpleDatabaseHelperV2 databaseHelper;
private final QuickShop plugin;
public MetricQuery(QuickShop plugin, SimpleDatabaseHelperV2 databaseHelper) {
this.databaseHelper = databaseHelper;
this.plugin = plugin;
}
public long queryServerPurchaseCount() {
String sql = "SELECT COUNT(*) AS result FROM " + databaseHelper.getPrefix() + "log_purchase";
try (SQLQuery query = databaseHelper.getManager().createQuery().withPreparedSQL(sql).setParams(Collections.emptyList()).execute()) {
ResultSet set = query.getResultSet();
if (set.next()) {
return set.getInt("result");
} else {
return -1;
}
} catch (SQLException e) {
return -1;
}
}
@NotNull
public List<ShopTransactionRecord> queryTransactions(@NotNull Date startTime, long limit, boolean descending) {
List<ShopTransactionRecord> list = new ArrayList<>();
try (SQLQuery query = databaseHelper.getManager().createQuery()
.inTable(databaseHelper.getPrefix() + "log_transaction")
.addTimeCondition("time", startTime, null)
.selectColumns()
.setLimit(1000)
.orderBy("id", !descending).build().execute()) {
ResultSet set = query.getResultSet();
while (set.next()) {
//"time", "shop", "data", "buyer", "type", "amount", "money", "tax"
ShopTransactionRecord record = new ShopTransactionRecord(
set.getDate("time"),
UUID.fromString(set.getString("from")),
UUID.fromString(set.getString("to")),
set.getString("currency"),
set.getDouble("amount"),
UUID.fromString(set.getString("tax_currency")),
set.getDouble("tax_amount"),
set.getString("error")
);
list.add(record);
}
} catch (SQLException e) {
e.printStackTrace();
return list;
}
return list;
}
// Use LinkedHashMap forced because we need keep the order.
public @NotNull LinkedHashMap<ShopMetricRecord, DataRecord> mapToDataRecord(@NotNull List<ShopMetricRecord> metricRecords) throws ExecutionException, InterruptedException {
// map ShopMetricRecord#getShopId to DataRecord with blocking future
LinkedHashMap<ShopMetricRecord, DataRecord> dataRecords = new LinkedHashMap<>();
for (ShopMetricRecord metricRecord : metricRecords) {
long shopId = metricRecord.getShopId();
Long dataId = databaseHelper.locateShopDataId(shopId).get();
if (dataId == null) {
Log.debug("dataId is null for shopId " + shopId);
continue;
}
DataRecord dataRecord = databaseHelper.getDataRecord(dataId).get();
dataRecords.put(metricRecord, dataRecord);
}
return dataRecords;
}
@NotNull
public List<ShopMetricRecord> queryServerPurchaseRecords(@NotNull Date startTime, long limit, boolean descending) {
List<ShopMetricRecord> list = new ArrayList<>();
try (SQLQuery query = databaseHelper.getManager().createQuery()
.inTable(databaseHelper.getPrefix() + "log_purchase")
.addTimeCondition("time", startTime, null)
.selectColumns()
.setLimit(1000)
.orderBy("id", !descending).build().execute()) {
ResultSet set = query.getResultSet();
while (set.next()) {
//"time", "shop", "data", "buyer", "type", "amount", "money", "tax"
ShopMetricRecord record = ShopMetricRecord.builder()
.time(set.getDate("time").getTime())
.shopId(set.getLong("shop"))
.type(ShopOperationEnum.valueOf(set.getString("type")))
.total(set.getDouble("money"))
.tax(set.getDouble("tax"))
.amount(set.getInt("amount"))
.player(QUserImpl.createSync(plugin.getPlayerFinder(), set.getString("buyer")))
.build();
list.add(record);
}
} catch (SQLException e) {
e.printStackTrace();
return list;
}
return list;
}
}
@@ -1,22 +0,0 @@
package com.ghostchu.quickshop.addon.plan.util;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.util.Date;
import java.util.UUID;
@Data
@AllArgsConstructor
@Builder
public class ShopTransactionRecord {
private Date time;
private UUID from;
private UUID to;
private String currency;
private double amount;
private UUID taxAccount;
private double taxAmount;
private String error;
}
-2
View File
@@ -1,2 +0,0 @@
config-version: 1
-10
View File
@@ -1,10 +0,0 @@
name: qsaddon-${project.artifactId}
version: '${project.version}'
main: com.ghostchu.quickshop.addon.${project.artifactId}.Main
api-version: 1.18
depend:
- QuickShop-Hikari
- Plan
authors: [ Ghost_chu ]
#libraries:
# - net.dv8tion:JDA:4.4.0_352.fix-2
-176
View File
@@ -1,176 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
<artifactId>reremake-migrator</artifactId>
<packaging>jar</packaging>
<name>Addon-Reremake-Migrator</name>
<description>Migrator QuickShop-Reremake data to QuickShop-Hikari</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>quickshop-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
<repository>
<id>minebench-repo</id>
<url>https://repo.minebench.de/</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${name}-${version}</finalName>
<!-- <outputDirectory>${rootDir}/build-artifacts</outputDirectory>-->
<createDependencyReducedPom>true</createDependencyReducedPom>
<minimizeJar>false</minimizeJar>
<createSourcesJar>false</createSourcesJar>
<createTestSourcesJar>false</createTestSourcesJar>
<shadeSourcesContent>true</shadeSourcesContent>
<shadedArtifactAttached>true</shadedArtifactAttached>
<!-- <artifactSet>-->
<!-- <includes>-->
<!-- <include>com.ghostchu:quickshop*:*</include>-->
<!-- <include>de.themoep:minedown:*</include>-->
<!-- </includes>-->
<!-- </artifactSet>-->
<artifactSet>
<includes>
<include>de.themoep:minedown-adventure:*</include>
<include>com.ghostchu.thirdparty:JsonConfiguration:*</include>
<include>net.minidev:json-smart:*</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>de.themoep.minedown.</pattern>
<shadedPattern>
com.ghostchu.quickshop.addon.reremakemigrator.shade.de.themoep.minedown.
</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.</pattern>
<shadedPattern>
com.ghostchu.quickshop.addon.reremakemigrator.shade.com.dumptruckman.
</shadedPattern>
</relocation>
<relocation>
<pattern>net.minidev.</pattern>
<shadedPattern>com.ghostchu.quickshop.addon.reremakemigrator.shade.net.minidev.
</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.kotlin_module</exclude>
<exclude>META-INF/*.txt</exclude>
<exclude>META-INF/proguard/*</exclude>
<exclude>META-INF/services/*</exclude>
<exclude>META-INF/versions/9/*</exclude>
<exclude>*License*</exclude>
<exclude>*LICENSE*</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId>
<version>5.1.2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.themoep</groupId>
<artifactId>minedown-adventure</artifactId>
<version>1.7.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.ghostchu.thirdparty</groupId>
<artifactId>JsonConfiguration</artifactId>
<version>1.2-20230922.165143-1</version>
</dependency>
<!-- Required json dependency because no other json lib can handle numbers appropriately. -->
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.kyori</groupId>-->
<!-- <artifactId>adventure-text-serializer-plain</artifactId>-->
<!-- <version>4.12.0</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
</dependencies>
</project>
@@ -1,73 +0,0 @@
package com.ghostchu.quickshop.addon.reremakemigrator;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.reremakemigrator.command.SubCommand_ReremakeMigrate;
import com.ghostchu.quickshop.api.command.CommandContainer;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
static Main instance;
private QuickShop hikari;
private org.maxgamer.quickshop.QuickShop reremake;
private String deniedMessage;
@Override
public void onLoad() {
instance = this;
}
@Override
public void onEnable() {
saveDefaultConfig();
hikari = QuickShop.getInstance();
reremake = org.maxgamer.quickshop.QuickShop.getInstance();
getLogger().info("Found QuickShop-Hikari: " + hikari.getJavaPlugin().getDescription().getVersion());
getLogger().info("Found QuickShop-Reremake: " + reremake.getDescription().getVersion());
Bukkit.getPluginManager().registerEvents(this, this);
hikari.getCommandManager().registerCmd(
CommandContainer
.builder()
.prefix("migratefromreremake")
.description((locale) -> hikari.text().of("addon.reremake-migrator.commands.migratefromreremake").forLocale(locale))
.permission("quickshopaddon.reremakemigrator.migrator-admin")
.executor(new SubCommand_ReremakeMigrate(this, hikari, reremake))
.build());
}
@Override
public void onDisable() {
HandlerList.unregisterAll((Plugin) this);
}
public QuickShop getHikari() {
return hikari;
}
public org.maxgamer.quickshop.QuickShop getReremake() {
return reremake;
}
public void setDeniedMessage(String deniedMessage) {
this.deniedMessage = deniedMessage;
}
public void setDeniedMessage(Component deniedMessage) {
this.deniedMessage = LegacyComponentSerializer.legacySection().serialize(deniedMessage);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerJoin(AsyncPlayerPreLoginEvent event) {
if (this.deniedMessage != null) {
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, this.deniedMessage);
}
}
}
@@ -1,75 +0,0 @@
package com.ghostchu.quickshop.addon.reremakemigrator.command;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.reremakemigrator.Main;
import com.ghostchu.quickshop.addon.reremakemigrator.migratecomponent.*;
import com.ghostchu.quickshop.api.command.CommandHandler;
import com.ghostchu.quickshop.api.command.CommandParser;
import com.ghostchu.quickshop.util.ProgressMonitor;
import com.ghostchu.quickshop.util.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
public class SubCommand_ReremakeMigrate implements CommandHandler<ConsoleCommandSender> {
private final Main plugin;
private final QuickShop hikari;
private final org.maxgamer.quickshop.QuickShop reremake;
private final AtomicBoolean running = new AtomicBoolean(false);
public SubCommand_ReremakeMigrate(Main main, QuickShop hikari, org.maxgamer.quickshop.QuickShop reremake) {
this.plugin = main;
this.hikari = hikari;
this.reremake = reremake;
}
@Override
public void onCommand(ConsoleCommandSender sender, @NotNull String commandLabel, @NotNull CommandParser parser) {
if (running.get()) {
return;
}
if (parser.getArgs().isEmpty() || parser.getArgs().size() < 2) {
hikari.text().of(sender, "command-incorrect", "/quickshop reremakemigrate <shouldOverrideExistShops> <shouldMigrateTransactionLogs>").send();
return;
}
if (!Bukkit.getOnlinePlayers().isEmpty()) {
hikari.text().of(sender, "addon.reremake-migrator.server-not-empty").send();
return;
}
boolean shouldOverrideExistShops = Boolean.parseBoolean(parser.getArgs().get(0));
boolean shouldMigrateTransactionLogs = Boolean.parseBoolean(parser.getArgs().get(1));
List<MigrateComponent> migrateComponentList = new ArrayList<>();
migrateComponentList.add(new ConfigMigrate(plugin, hikari, reremake, sender));
migrateComponentList.add(new TranslationMigrateComponent(plugin, hikari, reremake, sender));
migrateComponentList.add(new ShopMigrate(plugin, hikari, reremake, sender, shouldOverrideExistShops));
if (shouldMigrateTransactionLogs) {
migrateComponentList.add(new ShopLogsMigrate(plugin, hikari, reremake, sender));
}
Util.asyncThreadRun(() -> {
running.set(true);
plugin.setDeniedMessage(hikari.text().of(sender, "addon.reremake-migrator.join_blocking_converting").forLocale());
for (MigrateComponent migrateComponent : new ProgressMonitor<>(migrateComponentList, triple -> hikari.text().of(sender, "addon.reremake-migrator.executing", triple.getRight().getClass().getSimpleName(), triple.getLeft(), triple.getMiddle()).send())) {
String migrateComponentName = migrateComponent.getClass().getSimpleName();
try {
if (!migrateComponent.migrate()) {
// Something failed during the migration?
hikari.text().of(sender, "addon.reremake-migrator.failed", migrateComponentName).send();
running.set(false);
return;
}
} catch (Exception e) {
hikari.logger().warn("Failed to execute migrate component {}", migrateComponentName, e);
running.set(false);
return;
}
}
hikari.text().of(sender, "addon.reremake-migrator.completed").send();
plugin.setDeniedMessage(hikari.text().of(sender, "addon.reremake-migrator.join_blocking_finished").forLocale());
running.set(false);
});
}
}
@@ -1,49 +0,0 @@
package com.ghostchu.quickshop.addon.reremakemigrator.migratecomponent;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.QuickShopBukkit;
import com.ghostchu.quickshop.addon.reremakemigrator.Main;
import com.ghostchu.quickshop.api.localization.text.Text;
import org.bukkit.command.CommandSender;
public abstract class AbstractMigrateComponent implements MigrateComponent {
private final Main plugin;
private final QuickShop hikari;
private final org.maxgamer.quickshop.QuickShop reremake;
private final CommandSender sender;
public AbstractMigrateComponent(Main main, QuickShop hikari, org.maxgamer.quickshop.QuickShop reremake, CommandSender sender) {
this.plugin = main;
this.hikari = hikari;
this.reremake = reremake;
this.sender = sender;
}
@Override
public QuickShop getHikari() {
return this.hikari;
}
@Override
public QuickShopBukkit getHikariJavaPlugin() {
return this.hikari.getJavaPlugin();
}
@Override
public org.maxgamer.quickshop.QuickShop getReremake() {
return this.reremake;
}
@Override
public Main getPlugin() {
return plugin;
}
public CommandSender getSender() {
return sender;
}
public Text text(String modulePath, Object... objects) {
return getHikari().text().of(sender, "addon.reremake-migrator." + modulePath, objects);
}
}
@@ -1,130 +0,0 @@
package com.ghostchu.quickshop.addon.reremakemigrator.migratecomponent;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.reremakemigrator.Main;
import com.ghostchu.quickshop.util.ProgressMonitor;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
import java.util.UUID;
public class ConfigMigrate extends AbstractMigrateComponent {
// tax-free-for-unlimited-shop
//
private final String[] DIRECT_COPY_KEYS = new String[]{
"game-language", "enabled-languages", "mojangapi-mirror", "dev-mode", "tax", "tax-account", "unlimited-shop-owner-change",
"unlimited-shop-owner-change-account", "show-tax", "respect-item-flag", "currency", "logging", "trying-fix-banlance-insuffient",
"include-offlineplayer-list", "economy-type", "use-decimal-format", "decimal-format", "send-display-item-protection-alert",
"send-shop-protection-alert", "chat-type", "limits", "shop-block", "shop.cost", "shop.refund",
"shop.sending-stock-message-to-staffs", "shop.disable-creative-mode-trading", "shop.disable-super-tool",
"shop.allow-owner-break-shop-sign", "shop.price-change-requires-fee", "shop.fee-for-price-change", "shop.lock",
"shop.disable-quick-create", "shop.auto-sign", "shop.sign-glowing", "shop.sign-dye-color", "shop.pay-unlimited-shop-owners",
"shop.display-items", "shop.display-items-check-ticks", "shop.display-type", "shop.display-auto-despawn",
"shop.display-despawn-range", "shop.display-check-time", "shop.display-allow-stacks", "shop.finding", "shop.alternate-currency-symbol",
"shop.alternate-currency-symbol-list", "shop.disable-vault-format", "shop.currency-symbol-on-right", "shop.ignore-unlimited-shop-messages",
"shop.auto-fetch-shop-messages", "shop.ignore-cancel-chat-event", "shop.allow-shop-without-space-for-sign",
"shop.maximum-digits-in-price", "shop.show-owner-uuid-in-controlpanel-if-op", "shop.sign-material",
"shop.use-enchantment-for-enchanted-book", "shop.use-effect-for-potion-item", "shop.blacklist-world",
"shop.blacklist-lores", "shop.protection-checking", "shop.protection-checking-blacklist", "shop.protection-checking-listener-blacklist",
"shop.max-shops-checks-in-once", "shop.display-item-use-name", "shop.update-sign-when-inventory-moving", "shop.allow-economy-loan",
"shop.word-for-trade-all-items", "shop.ongoing-fee", "shop.force-load-downgrade-items", "shop.remove-protection-trigger",
"shop.allow-stacks", "shop.force-use-item-original-name", "blacklist", "plugin.Multiverse-Core", "plugin.WorldEdit",
"effect", "matcher", "protect.explode", "protect.hopper", "protect.entity", "custom-item-stacksize", "purge", "debug"
};
public ConfigMigrate(Main main, QuickShop hikari, org.maxgamer.quickshop.QuickShop reremake, CommandSender sender) {
super(main, hikari, reremake, sender);
}
@Override
public boolean migrate() {
copyValues();
migrateCommandAlias();
migratePriceRestrictions();
setFixedConfigValues();
getHikariJavaPlugin().reloadConfig();
return true;
}
private void migrateCommandAlias() {
List<String> commandAlias = getReremake().getConfig().getStringList("custom-commands");
if (!commandAlias.contains("qs")) {
commandAlias.add("qs");
}
getHikari().getConfig().set("custom-commands", commandAlias);
getHikariJavaPlugin().saveConfig();
}
private void setFixedConfigValues() {
getHikari().getConfig().set("legacy-updater.shop-sign", true);
}
private void migratePriceRestrictions() {
// Generating price-restriction.yml, copy from SimplePriceLimiter.java
text("modules.config.migrate-price-restriction").send();
File configFile = new File(getHikariJavaPlugin().getDataFolder(), "price-restriction.yml");
if (!configFile.exists()) {
try {
Files.copy(getHikariJavaPlugin().getResource("price-restriction.yml"), configFile.toPath());
} catch (IOException e) {
getHikari().logger().warn("Failed to copy price-restriction.yml.yml to plugin folder!", e);
}
}
FileConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
// migrate the minimum-price and maximum-price
configuration.set("undefined.min", getReremake().getConfig().get("shop.minimum-price", "0.01"));
configuration.set("undefined.max", getReremake().getConfig().get("shop.maximum-price", 999999999999999999999999999999.99d));
configuration.set("enable", true);
// migrate the whole-number setting from Reremake configuration
configuration.set("whole-number-only", getReremake().getConfig().get("shop.whole-number-prices-only"));
List<String> str = getReremake().getConfig().getStringList("shop.price-restriction");
for (String record : new ProgressMonitor<>(str, (triple) -> text("modules.migrate-price-restriction-entry", triple.getLeft(), triple.getMiddle()).send())) {
try {
String[] records = record.split(";");
if (records.length != 3) {
continue;
}
Material material = Material.matchMaterial(records[0]);
double min = Double.parseDouble(records[1]);
double max = Double.parseDouble(records[2]);
String name = UUID.randomUUID().toString().replace("-", "");
if (material == null) {
continue;
}
configuration.set("rules." + name + ".items", List.of(material));
configuration.set("rules." + name + ".currency", List.of("*"));
configuration.set("rules." + name + ".min", min);
configuration.set("rules." + name + ".max", max);
} catch (Exception e) {
getHikari().logger().warn("Failed to migrate rule {}", record, e);
}
}
try {
configuration.save(configFile);
} catch (IOException e) {
getHikari().logger().warn("Failed to save the price-restriction.yml", e);
}
}
private void copyValues() {
text("modules.config.copy-values", DIRECT_COPY_KEYS.length).send();
for (String directCopyKey : new ProgressMonitor<>(DIRECT_COPY_KEYS, triple ->
text("modules.config.copying-value", triple.getRight(), triple.getLeft(), triple.getMiddle()).send())) {
copyValue(directCopyKey);
}
getHikariJavaPlugin().saveConfig();
}
private void copyValue(String keyName) {
if (getReremake().getConfig().contains(keyName)) {
getHikari().getConfig().set(keyName, getReremake().getConfig().get(keyName));
}
}
}
@@ -1,17 +0,0 @@
package com.ghostchu.quickshop.addon.reremakemigrator.migratecomponent;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.QuickShopBukkit;
import com.ghostchu.quickshop.addon.reremakemigrator.Main;
public interface MigrateComponent {
QuickShop getHikari();
QuickShopBukkit getHikariJavaPlugin();
org.maxgamer.quickshop.QuickShop getReremake();
boolean migrate();
Main getPlugin();
}
@@ -1,148 +0,0 @@
package com.ghostchu.quickshop.addon.reremakemigrator.migratecomponent;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.generator.BiomeProvider;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.logging.Logger;
public class MockPlugin implements Plugin {
private final String pluginName;
public MockPlugin(String pluginName) {
this.pluginName = pluginName;
}
@NotNull
@Override
public File getDataFolder() {
return null;
}
@NotNull
@Override
public PluginDescriptionFile getDescription() {
return new PluginDescriptionFile(pluginName, "0.0.0", "N/A");
}
@NotNull
@Override
public FileConfiguration getConfig() {
return null;
}
@Nullable
@Override
public InputStream getResource(@NotNull String s) {
return null;
}
@Override
public void saveConfig() {
}
@Override
public void saveDefaultConfig() {
}
@Override
public void saveResource(@NotNull String s, boolean b) {
}
@Override
public void reloadConfig() {
}
@NotNull
@Override
public PluginLoader getPluginLoader() {
return null;
}
@NotNull
@Override
public Server getServer() {
return null;
}
@Override
public boolean isEnabled() {
return false;
}
@Override
public void onDisable() {
}
@Override
public void onLoad() {
}
@Override
public void onEnable() {
}
@Override
public boolean isNaggable() {
return false;
}
@Override
public void setNaggable(boolean b) {
}
@Nullable
@Override
public ChunkGenerator getDefaultWorldGenerator(@NotNull String s, @Nullable String s1) {
return null;
}
@Nullable
@Override
public BiomeProvider getDefaultBiomeProvider(@NotNull String s, @Nullable String s1) {
return null;
}
@NotNull
@Override
public Logger getLogger() {
return null;
}
@NotNull
@Override
public String getName() {
return pluginName;
}
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
return false;
}
@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
return null;
}
}
@@ -1,268 +0,0 @@
package com.ghostchu.quickshop.addon.reremakemigrator.migratecomponent;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.reremakemigrator.Main;
import com.ghostchu.quickshop.api.database.ShopMetricRecord;
import com.ghostchu.quickshop.api.database.ShopOperationEnum;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.api.shop.ShopType;
import com.ghostchu.quickshop.common.util.CommonUtil;
import com.ghostchu.quickshop.common.util.JsonUtil;
import com.ghostchu.quickshop.common.util.QuickExecutor;
import com.ghostchu.quickshop.obj.QUserImpl;
import com.google.gson.JsonObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.MalformedInputException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.util.Base64;
import java.util.Date;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
public class ShopLogsMigrate extends AbstractMigrateComponent {
private final String template = "[2023-11-11 19:35:43.502] ";
DateTimeFormatter DATETIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS").withZone(ZoneId.systemDefault());
public ShopLogsMigrate(Main main, QuickShop hikari, org.maxgamer.quickshop.QuickShop reremake, CommandSender sender) {
super(main, hikari, reremake, sender);
}
@Override
public boolean migrate() {
text("modules.shop-logs.start-migrate").send();
File logsFile = new File(getReremake().getDataFolder(), "appended-qs.log");
File filteredFile = new File(getReremake().getDataFolder(), "filtered-qs.log");
File formattedFile = new File(getReremake().getDataFolder(), "formatted-qs.log");
try (PrintWriter printWriter = new PrintWriter(logsFile, StandardCharsets.UTF_8)) {
logsFile.createNewFile();
filteredFile.createNewFile();
appendFiles(getReremake().getDataFolder(), printWriter);
printWriter.flush();
migrateAppendedLogs(logsFile, filteredFile);
readAndFormatEntire(filteredFile, formattedFile);
importToDatabase(formattedFile);
} catch (Exception ex) {
getHikari().logger().warn("Failed to migrate logs", ex);
return true;
} finally {
logsFile.delete();
filteredFile.delete();
formattedFile.delete();
}
return true;
}
private void importToDatabase(File filteredFile) throws IOException {
long sumLines = countLines(filteredFile);
BufferedReader bufferedReader = new BufferedReader(new FileReader(filteredFile));
try (bufferedReader) {
String cursor;
long count = 0;
while ((cursor = bufferedReader.readLine()) != null) {
try {
count++;
text("modules.shop-logs.import-entry", "<ENTRY TOO LONG>", count, sumLines);
DatedLogEntry entry = JsonUtil.standard().fromJson(new String(Base64.getDecoder().decode(cursor), StandardCharsets.UTF_8), DatedLogEntry.class);
Date date = entry.getDate();
JsonObject jObj = JsonUtil.readObject(entry.getContent());
if (jObj.has("shop") && jObj.has("type") && jObj.has("trader")
&& jObj.has("itemStack") && jObj.has("amount")
&& jObj.has("balance")
&& jObj.has("tax")) {
try {
importThePurchaseRecord(date, jObj);
} catch (Exception e) {
getHikari().logger().warn("Error on importing to database", e);
}
continue;
}
// if (jObj.has("creator") && jObj.has("shop") && jObj.has("location")) {
// importTheCreationRecord(date, jObj);
// continue;
// }
getHikari().logger().warn("Invalid record {}, skipping", entry);
} catch (Exception e2) {
getHikari().logger().warn("Parse the log failed, cursor [{}]", cursor, e2);
}
}
}
}
private long countLines(File filteredFile) throws FileNotFoundException {
BufferedReader bufferedReader = new BufferedReader(new FileReader(filteredFile));
return bufferedReader.lines().count();
}
// private void importTheCreationRecord(Date date, JsonObject jObj) {
// UUID creator = UUID.fromString(jObj.getAsJsonObject("creator").getAsString());
// JsonObject shopObj = jObj.get("shop").getAsJsonObject();
// JsonObject loc = jObj.get("location").getAsJsonObject();
// String worldName = loc.get("world").getAsString();
// int x = loc.get("x").getAsInt();
// int y = loc.get("y").getAsInt();
// int z = loc.get("z").getAsInt();
// World world = Bukkit.getWorld("worldName");
// if (world == null) {
// getHikari().logger().warn("Failed to migrate record, world is null.");
// return;
// }
// Shop shop = getHikari().getShopManager().getShop(new Location(world, x, y, z));
// if (shop == null) {
// getHikari().logger().warn("Failed to migrate record, shop already no-longer exists.");
// return;
// }
//
// }
private void importThePurchaseRecord(Date date, JsonObject jObj) throws InvalidConfigurationException {
int amount = jObj.get("amount").getAsInt();
double balance = jObj.get("balance").getAsDouble();
double tax = jObj.get("tax").getAsDouble();
UUID trader = UUID.fromString(jObj.get("trader").getAsString());
ShopType type = ShopType.valueOf(jObj.get("type").getAsString());
JsonObject shop = jObj.get("shop").getAsJsonObject();
JsonObject pos = shop.get("position").getAsJsonObject();
World world = Bukkit.getWorld(pos.get("world").getAsString());
if (world == null) {
throw new IllegalArgumentException("World " + jObj.get("world").getAsString() + " not exists.");
}
int x = pos.get("x").getAsInt();
int y = pos.get("y").getAsInt();
int z = pos.get("z").getAsInt();
Location location = new Location(world, x, y, z);
Shop shopInstance = getHikari().getShopManager().getShop(location);
if (shopInstance == null) {
throw new IllegalArgumentException("Shop at " + location + " not exists anymore");
}
ShopMetricRecord shopMetricRecord = new ShopMetricRecord(
date.getTime(),
shopInstance.getShopId(),
type == ShopType.SELLING ? ShopOperationEnum.PURCHASE_SELLING_SHOP : ShopOperationEnum.PURCHASE_BUYING_SHOP,
balance,
tax,
amount,
QUserImpl.createSync(getHikari().getPlayerFinder(), trader, QuickExecutor.getSecondaryProfileIoExecutor())
);
getHikari().getDatabaseHelper().insertMetricRecord(shopMetricRecord);
}
private void readAndFormatEntire(File filteredFile, File formattedFile) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new FileReader(filteredFile));
formattedFile.createNewFile();
PrintWriter writer = new PrintWriter(formattedFile, StandardCharsets.UTF_8);
StringBuilder buffer = new StringBuilder();
try (bufferedReader; writer) {
String cursor;
while ((cursor = bufferedReader.readLine()) != null) {
if (_isNewLineStart(cursor)) {
// Clean buffer
if (!buffer.isEmpty()) {
DatedLogEntry formatted = _formatLine(buffer.toString());
if (formatted != null) {
writer.println(Base64.getEncoder().encodeToString(JsonUtil.standard().toJson(formatted)
.getBytes(StandardCharsets.UTF_8)));
} else {
getHikari().logger().warn("Entry {} is invalid.", cursor);
}
buffer = new StringBuilder();
}
buffer.append(cursor);
} else {
buffer.append(cursor);
}
}
writer.flush();
}
}
@Data
@AllArgsConstructor
static class DatedLogEntry {
private Date date;
private String content;
}
@Nullable
private DatedLogEntry _formatLine(String line) throws DateTimeParseException {
String json = StringUtils.substringAfter(line, "] ");
if (!CommonUtil.isJson(json)) return null;
String dateStr = line.substring(1, template.length() - 1).trim();
TemporalAccessor accessor = DATETIME_FORMATTER.parse(dateStr);
return new DatedLogEntry(new Date(accessor.getLong(ChronoField.MILLI_OF_SECOND)), json);
}
private boolean _isNewLineStart(String line) {
if (!line.startsWith("[")) return false;
if (line.length() < template.length()) return false;
return line.endsWith("] ");
}
private void migrateAppendedLogs(File logsFile, File filteredFile) throws IOException {
text("modules.shop-logs.filter-history-files").send();
BufferedReader bufferedReader = new BufferedReader(new FileReader(logsFile));
PrintWriter writer = new PrintWriter(filteredFile, StandardCharsets.UTF_8);
long counter = 0;
try (bufferedReader; writer) {
String line;
while ((line = bufferedReader.readLine()) != null) {
if (line.contains("beforeTrading") && line.contains("player") && line.contains("holding")) {
continue;
}
if (StringUtils.isBlank(line)) {
continue;
}
writer.println(line);
counter++;
}
} finally {
writer.flush();
logsFile.delete();
text("modules.shop-logs.filtered-history-files", counter);
}
}
private void appendFiles(File dataFolder, PrintWriter logsFile) throws IOException {
text("modules.shop-logs.extract-history-files").send();
File logsSubFolder = new File(dataFolder, "logs");
if (logsSubFolder.exists()) {
File[] files = logsSubFolder.listFiles(f -> f.getName().endsWith(".log.gz"));
if (files != null) {
for (File file : files) {
try (GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(file))) {
String content = new String(gzipInputStream.readAllBytes(), StandardCharsets.UTF_8);
logsFile.println(content);
logsFile.flush();
}
}
}
}
File mainLogFile = new File(dataFolder, "qs.log");
getHikari().logger().info("Selected main log file: " + mainLogFile.getAbsolutePath());
if (mainLogFile.exists()) {
try {
logsFile.println(Files.readString(mainLogFile.toPath()));
} catch (MalformedInputException e) {
logsFile.println(Files.readString(mainLogFile.toPath(), Charset.defaultCharset()));
}
} else {
throw new IllegalStateException("Main qs.log log file not exists");
}
}
}
@@ -1,173 +0,0 @@
package com.ghostchu.quickshop.addon.reremakemigrator.migratecomponent;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.reremakemigrator.Main;
import com.ghostchu.quickshop.api.shop.ShopType;
import com.ghostchu.quickshop.api.shop.permission.BuiltInShopPermissionGroup;
import com.ghostchu.quickshop.common.util.CommonUtil;
import com.ghostchu.quickshop.common.util.QuickExecutor;
import com.ghostchu.quickshop.economy.SimpleBenefit;
import com.ghostchu.quickshop.obj.QUserImpl;
import com.ghostchu.quickshop.shop.ContainerShop;
import com.ghostchu.quickshop.shop.inventory.BukkitInventoryWrapper;
import com.ghostchu.quickshop.util.ProgressMonitor;
import com.ghostchu.quickshop.util.performance.BatchBukkitExecutor;
import com.google.common.io.Files;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.BlockState;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.InventoryHolder;
import org.maxgamer.quickshop.api.shop.Shop;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
public class ShopMigrate extends AbstractMigrateComponent {
private final boolean override;
public ShopMigrate(Main main, QuickShop hikari, org.maxgamer.quickshop.QuickShop reremake, CommandSender sender, boolean overrideExists) {
super(main, hikari, reremake, sender);
this.override = overrideExists;
}
@Override
public boolean migrate() {
final AtomicBoolean success = new AtomicBoolean(true);
final AtomicInteger c = new AtomicInteger(0);
List<Shop> allShops = getReremake().getShopManager().getAllShops();
List<ContainerShop> preparedShops = new ArrayList<>();
text("modules.shop.start-migrate", allShops.size()).send();
BatchBukkitExecutor<Shop> batchBukkitExecutor = new BatchBukkitExecutor<>();
batchBukkitExecutor.addTasks(allShops);
batchBukkitExecutor.startHandle(getHikari().getJavaPlugin(), reremakeShop -> {
text("modules.shop.migrate-entry", reremakeShop.toString(), c.incrementAndGet(), allShops.size()).send();
try {
Location shopLoc = reremakeShop.getLocation();
com.ghostchu.quickshop.api.shop.Shop hikariShop = getHikari().getShopManager().getShop(shopLoc, true);
if (hikariShop != null) {
if (!override) {
text("modules.shop.conflict", "SKIPPING").send();
return;
} else {
text("modules.shop.conflict", "OVERWRITING").send();
getHikari().getShopManager().deleteShop(hikariShop);
}
}
BlockState block = shopLoc.getBlock().getState();
if (!(block instanceof InventoryHolder container)) {
getHikari().logger().warn("Shop Invalid: Shop block not a valid Container, failed to create InventoryHolder.");
return;
}
ContainerShop hikariRawShop = new ContainerShop(
getHikari(),
-1,
shopLoc,
Math.min(reremakeShop.getPrice(), 999999999999999999999999999999.99), // DECIMAL (32,2) MAX
reremakeShop.getItem().clone(),
QUserImpl.createSync(getHikari().getPlayerFinder(), reremakeShop.getOwner()),
reremakeShop.isUnlimited(),
ShopType.fromID(reremakeShop.getShopType().toID()),
getReremakeShopExtra(reremakeShop),
reremakeShop.getCurrency(),
reremakeShop.isDisableDisplay(),
reremakeShop.getTaxAccountActual() == null ? null : QUserImpl.createSync(getHikari().getPlayerFinder(), reremakeShop.getTaxAccountActual()),
getHikari().getJavaPlugin().getName(),
getHikari().getInventoryWrapperManager().mklink(new BukkitInventoryWrapper(container.getInventory())),
null,
Collections.emptyMap(),
new SimpleBenefit()
);
migrateReremakeBanAddonData(reremakeShop, hikariRawShop);
hikariRawShop.setDirty();
preparedShops.add(hikariRawShop);
} catch (Exception e) {
getHikari().logger().warn("Failed to migrate shop " + reremakeShop, e);
}
}).thenAcceptAsync(a -> {
unloadAndMoveAwayReremake();
registerHikariShops(preparedShops);
saveHikariShops();
}, QuickExecutor.getCommonExecutor()).exceptionally((error) -> {
getHikari().logger().warn("Error while migrating shops", error);
success.set(false);
return null;
}).join();
return success.get();
}
private void migrateReremakeBanAddonData(Shop reremakeShop, ContainerShop hikariRawShop) {
try {
ConfigurationSection reremakeBanExtra = reremakeShop.getExtra(new MockPlugin("QuickShopBan"));
for (String bannedPlayer : reremakeBanExtra.getStringList("bannedplayers")) {
if (!CommonUtil.isUUID(bannedPlayer)) continue;
getHikari().logger().info("Migrating shop ban record {} at {} to new Hikari container shop.", bannedPlayer, reremakeShop);
UUID uuid = UUID.fromString(bannedPlayer);
hikariRawShop.setPlayerGroup(uuid, BuiltInShopPermissionGroup.BLOCKED);
}
} catch (Throwable th) {
getHikari().logger().warn("Failed to migrate the shop ban record", th);
}
}
private YamlConfiguration getReremakeShopExtra(Shop reremakeShop) {
YamlConfiguration configuration = new YamlConfiguration();
try {
configuration.loadFromString(reremakeShop.saveExtraToYaml());
} catch (InvalidConfigurationException ignored) {
}
return configuration;
}
private void saveHikariShops() {
CompletableFuture<?>[] shopsToSaveFuture = getHikari().getShopManager().getAllShops().stream().filter(com.ghostchu.quickshop.api.shop.Shop::isDirty)
.map(com.ghostchu.quickshop.api.shop.Shop::update)
.toArray(CompletableFuture[]::new);
text("modules.shop.saving-shops", shopsToSaveFuture.length).send();
for (CompletableFuture<?> completableFuture : new ProgressMonitor<>(shopsToSaveFuture, triple -> text("modules.shop.save-entry", triple.getLeft(), triple.getMiddle()).send())) {
try {
completableFuture.join();
} catch (Exception e) {
getHikari().logger().warn("Error while saving shops, skipping", e);
}
}
// CompletableFuture.allOf(shopsToSaveFuture)
// .thenAcceptAsync((v) -> {
// if (shopsToSaveFuture.length != 0) {
// Log.debug("Saved " + shopsToSaveFuture.length + " shops in background.");
// }
// }, QuickExecutor.getShopSaveExecutor())
// .exceptionally(e -> {
// getHikari().logger().warn("Error while saving shops", e);
// return null;
// }).join();
}
private void registerHikariShops(List<ContainerShop> preparedShops) {
for (com.ghostchu.quickshop.api.shop.Shop shop : new ProgressMonitor<>(preparedShops, triple -> text("modules.shop.register-entry", triple.getRight(), triple.getLeft(), triple.getMiddle()).send())) {
getHikari().getShopManager().registerShop(shop, true).join();
shop.setDirty();
}
}
private void unloadAndMoveAwayReremake() {
text("modules.shop.unloading-reremake").send();
Bukkit.getPluginManager().disablePlugin(getReremake());
File reremakeDataDirectory = new File(getHikari().getDataFolder(), "QuickShop");
try {
Files.move(reremakeDataDirectory, new File(getHikari().getDataFolder(), "QuickShop.migrated"));
} catch (IOException e) {
getHikari().logger().warn("Failed to move QuickShop-Reremake data directory, it may cause issues. You should manually move it to another location.");
}
}
}
@@ -1,104 +0,0 @@
package com.ghostchu.quickshop.addon.reremakemigrator.migratecomponent;
import com.dumptruckman.bukkit.configuration.json.JsonConfiguration;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.addon.reremakemigrator.Main;
import com.ghostchu.quickshop.util.ProgressMonitor;
import de.themoep.minedown.adventure.MineDown;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class TranslationMigrateComponent extends AbstractMigrateComponent {
public TranslationMigrateComponent(Main main, QuickShop hikari, org.maxgamer.quickshop.QuickShop reremake, CommandSender sender) {
super(main, hikari, reremake, sender);
}
@Override
public boolean migrate() {
text("modules.translation.start-migrate").send();
File reremakeOverrideFolder = new File(getReremake().getDataFolder(), "overrides");
if (!reremakeOverrideFolder.exists()) {
return true;
}
File[] fileTree = reremakeOverrideFolder.listFiles();
if (fileTree == null) {
getHikari().logger().warn("Skipping translation migrate (no file tree)");
return true;
}
for (File langFolder : new ProgressMonitor<>(fileTree, (triple) -> text("modules.translation.migrate-entry", triple.getRight().getName(), triple.getLeft(), triple.getMiddle()))) {
File langJsonFile = new File(langFolder, "messages.json");
if (!langJsonFile.exists()) {
continue;
}
try {
migrateFile(langFolder, langJsonFile);
} catch (Exception exception) {
getHikari().logger().warn("Failed migrate lang file " + langJsonFile.getName() + ".", exception);
}
}
return true;
}
private void migrateFile(File langFolder, File langJsonFile) throws IOException {
File hikariOverrideFolder = new File(getHikari().getDataFolder(), "overrides");
File targetLangFolder = new File(hikariOverrideFolder, langFolder.getName());
if (!targetLangFolder.exists()) {
if (!targetLangFolder.mkdirs()) {
throw new IOException("Failed to create lang " + langFolder.getName() + " directory.");
}
}
JsonConfiguration jsonConfiguration = JsonConfiguration.loadConfiguration(langJsonFile);
YamlConfiguration yamlConfiguration = new YamlConfiguration();
File targetLangFile = new File(targetLangFolder, langJsonFile.getName().replace(".json", ".yml"));
if (targetLangFile.exists()) {
yamlConfiguration = YamlConfiguration.loadConfiguration(targetLangFile);
}
getHikari().logger().info("Migrating the Reremake language file: " + langJsonFile.getAbsolutePath() + "...");
Set<String> keys = jsonConfiguration.getKeys(true);
text("modules.translation.copy-values", targetLangFolder.getName(), keys.size()).send();
for (String key : new ProgressMonitor<>(keys, (triple) -> text("modules.translation.copying-value", triple.getRight(), triple.getLeft(), triple.getMiddle()).send())) {
if ("_comment".equals(key)) {
continue;
}
if (jsonConfiguration.isConfigurationSection(key)) {
continue;
}
if (jsonConfiguration.isString(key)) {
String originalValue = jsonConfiguration.getString(key);
Component component = MineDown.parse(originalValue).compact();
String convertedValue = MiniMessage.miniMessage().serialize(component);
yamlConfiguration.set(key, convertedValue);
} else {
if (jsonConfiguration.isList(key)) {
List<String> list = jsonConfiguration.getStringList(key);
List<String> convert = new ArrayList<>();
list.forEach(s -> {
Component component = MineDown.parse(s).compact();
String convertedValue = MiniMessage.miniMessage().serialize(component);
convert.add(convertedValue);
});
yamlConfiguration.set(key, convert);
} else {
yamlConfiguration.set(key, jsonConfiguration.get(key));
}
}
}
if (!targetLangFile.exists()) {
if (!targetLangFile.createNewFile()) {
getHikari().logger().warn("Couldn't save converted data to file: file creation failed");
return;
}
}
yamlConfiguration.save(targetLangFile);
}
}
@@ -1 +0,0 @@
config-version: 1
@@ -1,12 +0,0 @@
name: qsaddon-reremakemigrator
version: '${project.version}'
main: com.ghostchu.quickshop.addon.reremakemigrator.Main
api-version: 1.18
depend:
- QuickShop-Hikari
- QuickShop
authors: [ Ghost_chu ]
permissions:
quickshopaddon.reremakemigrator.migrator-admin:
default: op
description: Migrate from QuickShop-Reremake
-83
View File
@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.addon</groupId>
<artifactId>shopitemonly</artifactId>
<packaging>jar</packaging>
<name>Addon-ShopItemOnly</name>
<description>Restrict only store items can be placed in store containers</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
<repository>
<id>Scarsz-Nexus</id>
<url>https://nexus.scarsz.me/content/groups/public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.kyori</groupId>-->
<!-- <artifactId>adventure-text-serializer-plain</artifactId>-->
<!-- <version>4.12.0</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
</dependencies>
</project>
@@ -2,6 +2,8 @@ package com.ghostchu.quickshop.addon.shopitemonly;
import com.ghostchu.quickshop.QuickShop;
import com.ghostchu.quickshop.api.shop.Shop;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -16,9 +18,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.List;
public final class Main extends JavaPlugin implements Listener {
static Main instance;
private QuickShop plugin;
@@ -40,7 +39,6 @@ public final class Main extends JavaPlugin implements Listener {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void invClose(InventoryCloseEvent event) {
Inventory inventory = event.getInventory();
@@ -75,19 +73,21 @@ public final class Main extends JavaPlugin implements Listener {
inventory.remove(item);
invLocation.getWorld().dropItemNaturally(invLocation.add(0, 1, 0), item);
}
plugin.text().of(event.getPlayer(), "addon.shopitemonly.message", pendingForRemoval.size()).send();
plugin.text()
.of(event.getPlayer(), "addon.shopitemonly.message", pendingForRemoval.size())
.send();
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void invMove(InventoryMoveItemEvent event) {
if (event.getDestination() == null) { //Stupid CMIGUI plugin
if (event.getDestination() == null) { // Stupid CMIGUI plugin
return;
}
if (event.getDestination().getLocation() == null) {
return;
}
Shop shop = plugin.getShopManager().getShopIncludeAttached(event.getDestination().getLocation());
Shop shop = plugin.getShopManager()
.getShopIncludeAttached(event.getDestination().getLocation());
if (shop == null) {
return;
}
Executable
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/bash
# Fetch all submodule content.
git submodule update --force --recursive --init
+301
View File
@@ -0,0 +1,301 @@
val quickshopVersion = "5.9"
val purpurApiVersion = "1.19.4-R0.1-SNAPSHOT"
val javaLanguageVersion = 17
val jetbrainsAnnotationsVersion = "24.1.0"
val adventureApiVersion = "4.22.0"
val adventureExtraVersion = "4.2.0"
val adventurePlatformVersion = "4.3.2"
val viaversionApi = "4.3.0"
plugins {
id("java-library")
id("io.freefair.lombok") version "8.14" apply false
id("com.gradleup.shadow") version "8.3.6" apply false
id("com.diffplug.spotless") version "7.0.4"
}
subprojects {
apply(plugin = "java-library")
apply(plugin = "io.freefair.lombok")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "com.gradleup.shadow")
apply(plugin = "eclipse")
group = "com.ghostchu"
version = quickshopVersion
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(javaLanguageVersion))
vendor.set(org.gradle.jvm.toolchain.JvmVendorSpec.GRAAL_VM)
}
}
repositories {
mavenCentral()
maven("https://repo.viaversion.com")
maven("https://repo.purpurmc.org/snapshots")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.codemc.io/repository/maven-public/")
maven("https://repo.codemc.io/repository/nms/")
maven("https://repo.md-5.net/content/repositories/releases/")
maven("https://repo.md-5.net/content/repositories/snapshots/")
maven("https://repo.dmulloy2.net/repository/public/")
maven("https://repo.essentialsx.net/releases/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://maven.enginehub.org/repo/")
maven("https://m2.dv8tion.net/releases")
maven("https://nexus.scarsz.me/content/groups/public/")
maven("https://www.jitpack.io")
}
dependencies { compileOnly("org.jetbrains:annotations:$jetbrainsAnnotationsVersion") }
if (path != ":libs:Utilities-OG") {
spotless {
java {
removeUnusedImports()
palantirJavaFormat()
}
kotlinGradle {
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) }
target("build.gradle.kts", "settings.gradle.kts")
}
}
}
tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
tasks.withType<JavaCompile>().configureEach {
dependsOn("spotlessApply")
options.compilerArgs.addAll(listOf("-parameters", "-Xlint:deprecation"))
options.encoding = "UTF-8"
options.isFork = true
}
}
project(":quickshop-common") {
dependencies {
api("net.kyori:adventure-api:$adventureApiVersion")
api("net.kyori:adventure-nbt:$adventureApiVersion")
api("com.ghostchu:simplereloadlib:1.1.2")
implementation("org.apache.commons:commons-lang3:3.14.0")
implementation("org.slf4j:slf4j-jdk14:2.0.9")
implementation("com.google.code.gson:gson:2.10.1")
api("cc.carm.lib:easysql-hikaricp:0.4.7")
api("org.apache.commons:commons-text:1.11.0")
api("org.apache.commons:commons-compress:1.25.0")
compileOnly("org.purpurmc.purpur:purpur-api:$purpurApiVersion")
compileOnlyApi(project(":libs:Utilities-OG"))
}
}
project(":quickshop-api") {
dependencies {
api(project(":quickshop-common"))
implementation("com.vdurmont:semver4j:3.1.0")
compileOnly("cc.carm.lib:easysql-api:0.4.7")
compileOnly("org.purpurmc.purpur:purpur-api:$purpurApiVersion")
}
}
val platformApi = "org.purpurmc.purpur:purpur-api:$purpurApiVersion"
project(":platform:quickshop-platform-interface") {
dependencies {
api(project(":quickshop-common"))
compileOnly(platformApi)
compileOnly("de.tr7zw:item-nbt-api-plugin:2.12.1")
}
}
project(":platform:quickshop-platform-spigot-abstract") {
dependencies {
api(project(":platform:quickshop-platform-interface"))
compileOnly(platformApi)
implementation("commons-lang:commons-lang:2.6")
compileOnly("de.tr7zw:item-nbt-api-plugin:2.12.1")
}
}
project(":platform:quickshop-platform-paper") {
dependencies {
implementation(project(":platform:quickshop-platform-interface"))
compileOnly("io.papermc.paper:paper-api:$purpurApiVersion")
}
}
listOf(
"v1_19_R1" to "1.19.1-R0.1-SNAPSHOT",
"v1_19_R2" to "1.19.3-R0.1-SNAPSHOT",
"v1_19_R3" to "1.19.4-R0.1-SNAPSHOT"
).forEach { (suffix, spigotVer) ->
project(":platform:quickshop-platform-spigot-$suffix") {
dependencies {
api(project(":platform:quickshop-platform-spigot-abstract"))
compileOnly("org.spigotmc:spigot:$spigotVer:remapped-mojang")
compileOnly("de.tr7zw:item-nbt-api-plugin:2.12.1")
}
}
}
project(":quickshop-bukkit") {
tasks.processResources {
val versionString = project.version.toString()
val props = mapOf(
"version" to versionString,
"project" to mapOf("version" to versionString)
)
inputs.properties(props)
filesMatching("plugin.yml") { expand(props) }
}
dependencies {
implementation(project(":quickshop-api"))
implementation(project(":platform:quickshop-platform-spigot-abstract"))
implementation("com.ghostchu.crowdin:crowdinota:1.0.3")
compileOnly(project(":libs:Utilities-OG"))
listOf(
":platform:quickshop-platform-spigot-v1_19_R1",
":platform:quickshop-platform-spigot-v1_19_R2",
":platform:quickshop-platform-spigot-v1_19_R3",
":platform:quickshop-platform-paper"
).forEach { implementation(project(it)) }
compileOnly(platformApi)
compileOnly("net.kyori:adventure-platform-bukkit:$adventurePlatformVersion")
compileOnly("net.kyori:adventure-platform-viaversion:$adventurePlatformVersion")
compileOnly("net.kyori:adventure-text-serializer-ansi:$adventureExtraVersion")
compileOnly("net.kyori:adventure-text-serializer-bungeecord:$adventureExtraVersion")
compileOnly("com.viaversion:viaversion-api:$viaversionApi")
compileOnly("com.h2database:h2:2.2.224")
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1")
compileOnly("me.clip:placeholderapi:2.11.5")
compileOnly("net.tnemc:EconomyCore:0.1.2.6-Pre1")
compileOnly("net.tnemc:Reserve:0.1.5.3-SNAPSHOT-4")
compileOnly("org.bstats:bstats-bukkit:3.0.2")
compileOnly("com.konghq:unirest-java:3.14.5")
compileOnly("com.github.juliomarcopineda:jdbc-stream:0.1.1")
compileOnly("net.sourceforge.csvjdbc:csvjdbc:1.0.41")
compileOnly("org.dom4j:dom4j:2.1.4")
compileOnly("net.essentialsx:EssentialsX:2.20.1")
compileOnly("com.rollbar:rollbar-java:1.10.0")
compileOnly(files("lib/GemsEconomy-4.9.2.jar"))
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
archiveClassifier.set("")
minimize()
relocate("io.papermc.lib", "com.ghostchu.quickshop.shade.io.papermc.lib")
relocate("de.tr7zw.changeme.nbtapi", "com.ghostchu.quickshop.shade.de.tr7zw.changeme.nbtapi")
relocate("org.bstats", "com.ghostchu.quickshop.shade.org.bstats")
relocate("de.themoep.minedown", "com.ghostchu.quickshop.shade.de.themoep.minedown")
manifest { attributes["Main-Class"] = "com.ghostchu.quickshop.bootstrap.Bootstrap" }
exclude(
"META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA",
"META-INF/*.kotlin_module", "META-INF/*.txt",
"META-INF/proguard/*", "META-INF/services/*",
"META-INF/versions/9/*", "*License*", "*LICENSE*"
)
}
tasks.named<Jar>("jar") { archiveClassifier.set("original") }
tasks.register<Copy>("copyReleaseJar") {
dependsOn("shadowJar")
from(tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar").flatMap { it.archiveFile })
into(layout.projectDirectory.dir("../target"))
}
tasks.build {
dependsOn(tasks.spotlessApply)
dependsOn("shadowJar", "copyReleaseJar")
}
}
val commonAddOnDeps = listOf(
platformApi,
"org.apache.commons:commons-lang3:3.14.0"
)
project(":addon:bluemap") {
dependencies {
compileOnly(project(":quickshop-bukkit"))
compileOnly(project(":quickshop-api"))
compileOnly("com.github.BlueMap-Minecraft:BlueMapAPI:2.6.2")
commonAddOnDeps.forEach { compileOnly(it) }
}
}
listOf("discount", "list", "shopitemonly").forEach { name ->
project(":addon:$name") {
dependencies {
compileOnly(project(":quickshop-bukkit"))
compileOnly(project(":quickshop-api"))
commonAddOnDeps.forEach { compileOnly(it) }
}
}
}
project(":compatibility:common") {
dependencies {
compileOnly(platformApi)
api(project(":quickshop-common"))
compileOnly(project(":quickshop-api"))
compileOnly(project(":quickshop-bukkit"))
}
}
project(":compatibility:clearlag") {
dependencies {
implementation(project(":compatibility:common"))
compileOnly(project(":quickshop-bukkit"))
compileOnly(platformApi)
compileOnly(files("lib/Clearlag-3.2.2.jar"))
}
}
project(":compatibility:nocheatplus") {
dependencies {
implementation(project(":compatibility:common"))
compileOnly(project(":quickshop-bukkit"))
compileOnly(platformApi)
compileOnly(project(":quickshop-api"))
compileOnly("fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT")
}
}
project(":compatibility:openinv") {
dependencies {
implementation(project(":compatibility:common"))
compileOnly(project(":quickshop-bukkit"))
compileOnly(platformApi)
compileOnly(project(":quickshop-api"))
compileOnly("com.github.true-og.OpenInv:openinvapi:a85e8ebc28")
}
}
project(":compatibility:worldedit") {
dependencies {
implementation(project(":compatibility:common"))
compileOnly(project(":quickshop-bukkit"))
compileOnly(project(":quickshop-api"))
compileOnly(platformApi)
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.17")
}
}
project(":compatibility:worldguard") {
dependencies {
implementation(project(":compatibility:common"))
compileOnly(project(":quickshop-bukkit"))
compileOnly(project(":quickshop-api"))
compileOnly(platformApi)
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.8")
compileOnly("com.github.juliomarcopineda:jdbc-stream:0.1.1")
compileOnly("one.util:streamex:0.8.2")
}
}
+1
View File
@@ -0,0 +1 @@
/build/
-70
View File
@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>clearlag</artifactId>
<packaging>jar</packaging>
<name>Compat-Clearlag</name>
<description>Compatibility module for ClearLagg</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>common</artifactId>
<version>${parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.minebuilders</groupId>
<artifactId>clearlag</artifactId>
<version>3.2.2</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Clearlag-3.2.2.jar</systemPath>
</dependency>
</dependencies>
</project>
@@ -2,14 +2,13 @@ package com.ghostchu.quickshop.compatibility.clearlag;
import com.ghostchu.quickshop.compatibility.CompatibilityModule;
import com.ghostchu.quickshop.shop.display.AbstractDisplayItem;
import java.util.Iterator;
import me.minebuilders.clearlag.events.EntityRemoveEvent;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.Iterator;
public final class Main extends CompatibilityModule implements Listener {
@Override
-57
View File
@@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<name>quickshop-compatibility-common</name>
<description>Compatibility module for Commons</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -7,6 +7,9 @@ import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.common.util.CommonUtil;
import com.ghostchu.quickshop.obj.QUserImpl;
import com.ghostchu.quickshop.util.logging.container.ShopRemoveLog;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
@@ -18,10 +21,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public abstract class CompatibilityModule extends JavaPlugin implements Listener {
private QuickShopAPI api;
-82
View File
@@ -1,82 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>nocheatplus</artifactId>
<packaging>jar</packaging>
<name>Compat-NoCheatPlus</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
<repository>
<id>codemc-releases</id>
<url>https://repo.codemc.io/repository/maven-releases/</url>
</repository>
<repository>
<id>md_5-snapshots</id>
<url>https://repo.md-5.net/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus</artifactId>
<version>3.16.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>common</artifactId>
<version>${parent.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -9,9 +9,7 @@ import org.bukkit.event.Listener;
public final class Main extends CompatibilityModule implements Listener {
@Override
public void init() {
}
public void init() {}
@EventHandler(ignoreCancelled = true)
public void onFakeEventBegin(ShopProtectionCheckEvent event) {
-75
View File
@@ -1,75 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>openinv</artifactId>
<packaging>jar</packaging>
<name>Compat-OpenInv</name>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://www.jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.github.true-og.OpenInv</groupId>
<artifactId>openinvapi</artifactId>
<version>a85e8ebc28</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>common</artifactId>
<version>${parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -5,6 +5,7 @@ import com.ghostchu.quickshop.api.inventory.InventoryWrapperIterator;
import com.ghostchu.quickshop.api.inventory.InventoryWrapperManager;
import com.ghostchu.quickshop.api.inventory.InventoryWrapperType;
import com.lishid.openinv.IOpenInv;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
@@ -14,8 +15,6 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public class EnderChestWrapper implements InventoryWrapper {
private final UUID uuid;
private final Player player;
@@ -26,7 +25,6 @@ public class EnderChestWrapper implements InventoryWrapper {
this.uuid = uuid;
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
this.player = iOpenInv.loadPlayer(offlinePlayer);
}
public UUID getUuid() {
@@ -30,7 +30,14 @@ public final class Main extends CompatibilityModule implements Listener {
@Override
public void onEnable() {
super.onEnable();
getApi().getCommandManager().registerCmd(CommandContainer.builder().prefix("echest").permission("quickshop.echest").description((locale) -> LegacyComponentSerializer.legacySection().deserialize(getConfig().getString("messages.description"))).executor(new OpenInvCommand(this)).build());
getApi().getCommandManager()
.registerCmd(CommandContainer.builder()
.prefix("echest")
.permission("quickshop.echest")
.description((locale) -> LegacyComponentSerializer.legacySection()
.deserialize(getConfig().getString("messages.description")))
.executor(new OpenInvCommand(this))
.build());
}
@Override
@@ -5,14 +5,13 @@ import com.ghostchu.quickshop.api.command.CommandHandler;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.common.util.CommonUtil;
import com.ghostchu.quickshop.shop.inventory.BukkitInventoryWrapper;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class OpenInvCommand implements CommandHandler<Player> {
private final Main plugin;
@@ -34,16 +33,27 @@ public class OpenInvCommand implements CommandHandler<Player> {
plugin.getApi().getTextManager().of(sender, "not-looking-at-shop").send();
return;
}
if (!sender.getUniqueId().equals(shop.getOwner().getUniqueId()) && !QuickShop.getPermissionManager().hasPermission(sender, "quickshop.admin")) {
if (!sender.getUniqueId().equals(shop.getOwner().getUniqueId())
&& !QuickShop.getPermissionManager().hasPermission(sender, "quickshop.admin")) {
plugin.getApi().getTextManager().of(sender, "no-permission").send();
return;
}
if (shop.getInventory() instanceof EnderChestWrapper) {
shop.setInventory(new BukkitInventoryWrapper((((InventoryHolder) shop.getLocation().getBlock().getState()).getInventory())), plugin.getApi().getInventoryWrapperRegistry().get("QuickShop-Hikari"));
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("messages.to-chest")));
shop.setInventory(
new BukkitInventoryWrapper(
(((InventoryHolder) shop.getLocation().getBlock().getState()).getInventory())),
plugin.getApi().getInventoryWrapperRegistry().get("QuickShop-Hikari"));
sender.sendMessage(ChatColor.translateAlternateColorCodes(
'&', plugin.getConfig().getString("messages.to-chest")));
} else {
shop.setInventory(new EnderChestWrapper(shop.getOwner().getUniqueIdIfRealPlayer().orElse(CommonUtil.getNilUniqueId()), plugin.getOpenInv(), plugin), plugin.getManager());
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("messages.to-echest")));
shop.setInventory(
new EnderChestWrapper(
shop.getOwner().getUniqueIdIfRealPlayer().orElse(CommonUtil.getNilUniqueId()),
plugin.getOpenInv(),
plugin),
plugin.getManager());
sender.sendMessage(ChatColor.translateAlternateColorCodes(
'&', plugin.getConfig().getString("messages.to-echest")));
}
}
@@ -56,7 +66,8 @@ public class OpenInvCommand implements CommandHandler<Player> {
* @return Candidate list
*/
@Override
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
public @Nullable List<String> onTabComplete(
@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
return CommandHandler.super.onTabComplete(sender, commandLabel, cmdArg);
}
}
@@ -3,9 +3,8 @@ package com.ghostchu.quickshop.compatibility.openinv;
import com.ghostchu.quickshop.api.inventory.InventoryWrapper;
import com.ghostchu.quickshop.api.inventory.InventoryWrapperManager;
import com.lishid.openinv.IOpenInv;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
import org.jetbrains.annotations.NotNull;
public class OpenInvInventoryManager implements InventoryWrapperManager {
private final IOpenInv openInv;
@@ -42,6 +41,7 @@ public class OpenInvInventoryManager implements InventoryWrapperManager {
if (wrapper instanceof EnderChestWrapper wrap) {
return wrap.getUuid().toString();
}
throw new IllegalArgumentException("Cannot create symbol link for target Inventory: " + wrapper.getClass().getName());
throw new IllegalArgumentException("Cannot create symbol link for target Inventory: "
+ wrapper.getClass().getName());
}
}
-81
View File
@@ -1,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>worldedit</artifactId>
<packaging>jar</packaging>
<name>Compat-WorldEdit</name>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>enginehub-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.17</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bstats</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>common</artifactId>
<version>${parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -17,7 +17,8 @@ public final class Main extends CompatibilityModule implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
WorldEditPlugin worldEditPlugin = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
WorldEditPlugin worldEditPlugin =
(WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
adapter = new WorldEditAdapter(worldEditPlugin);
Bukkit.getPluginManager().registerEvents(adapter, this);
super.onEnable();
@@ -27,5 +28,4 @@ public final class Main extends CompatibilityModule implements Listener {
public void init() {
// There no init stuffs need to do
}
}
@@ -33,6 +33,4 @@ public class WorldEditAdapter implements Listener {
public void unregister() {
weBukkit.getWorldEdit().getEventBus().unregister(this);
}
}
@@ -36,7 +36,8 @@ public class WorldEditBlockListener extends AbstractDelegateExtent {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(final BlockVector3 position, final T block) throws WorldEditException {
public <T extends BlockStateHolder<T>> boolean setBlock(final BlockVector3 position, final T block)
throws WorldEditException {
if (!(this.world instanceof BukkitWorld)) {
return super.setBlock(position, block);
}
@@ -48,11 +49,19 @@ public class WorldEditBlockListener extends AbstractDelegateExtent {
if (extent.setBlock(position, block)) {
// Block Changed
if (oldBlock.getBlockType().getMaterial().hasContainer() && !newBlock.getBlockType().getMaterial().hasContainer()) {
Shop shop = api.getShopManager().getShop(location, true); // Because WorldEdit can only remove half of shop, so we can keep another half as shop if it is doublechest shop.
if (oldBlock.getBlockType().getMaterial().hasContainer()
&& !newBlock.getBlockType().getMaterial().hasContainer()) {
Shop shop = api.getShopManager()
.getShop(
location,
true); // Because WorldEdit can only remove half of shop, so we can keep another half as
// shop if it is doublechest shop.
if (shop != null) {
Util.mainThreadRun(() -> {
api.logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "WorldEdit", false), "WorldEdit", shop.saveToInfoStorage()));
api.logEvent(new ShopRemoveLog(
QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "WorldEdit", false),
"WorldEdit",
shop.saveToInfoStorage()));
api.getShopManager().deleteShop(shop);
});
}
-87
View File
@@ -1,87 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>5.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>worldguard</artifactId>
<packaging>jar</packaging>
<name>Compat-WorldGuard</name>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>enginehub-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ghostchu.quickshop.compatibility</groupId>
<artifactId>common</artifactId>
<version>${parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-bukkit</artifactId>
<version>${parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.juliomarcopineda</groupId>
<artifactId>jdbc-stream</artifactId>
<version>0.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>one.util</groupId>
<artifactId>streamex</artifactId>
<version>0.8.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -22,6 +22,8 @@ import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import java.util.*;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
@@ -29,9 +31,6 @@ import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.*;
import java.util.logging.Level;
public final class Main extends CompatibilityModule implements Listener {
private StateFlag createFlag;
private StateFlag tradeFlag;
@@ -43,8 +42,10 @@ public final class Main extends CompatibilityModule implements Listener {
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
try {
// create a flag with the name "my-custom-flag", defaulting to true
StateFlag createFlag = new StateFlag("quickshophikari-create", getConfig().getBoolean("create.default-allow", false));
StateFlag tradeFlag = new StateFlag("quickshophikari-trade", getConfig().getBoolean("trade.default-allow", true));
StateFlag createFlag =
new StateFlag("quickshophikari-create", getConfig().getBoolean("create.default-allow", false));
StateFlag tradeFlag =
new StateFlag("quickshophikari-trade", getConfig().getBoolean("trade.default-allow", true));
registry.register(createFlag);
registry.register(tradeFlag);
this.createFlag = createFlag;
@@ -73,7 +74,6 @@ public final class Main extends CompatibilityModule implements Listener {
super.onLoad();
}
@Override
public void init() {
// There no init stuffs need to do
@@ -87,10 +87,12 @@ public final class Main extends CompatibilityModule implements Listener {
if (manager == null) {
return;
}
ApplicableRegionSet set = manager.getApplicableRegions(BlockVector3.at(shopLoc.getX(), shopLoc.getY(), shopLoc.getZ()));
ApplicableRegionSet set =
manager.getApplicableRegions(BlockVector3.at(shopLoc.getX(), shopLoc.getY(), shopLoc.getZ()));
for (ProtectedRegion region : set.getRegions()) {
if (region.getOwners().contains(event.getAuthorizer())) {
if (event.getNamespace().equals(QuickShop.getInstance().getJavaPlugin()) && event.getPermission().equals(BuiltInShopPermission.DELETE.getRawNode())) {
if (event.getNamespace().equals(QuickShop.getInstance().getJavaPlugin())
&& event.getPermission().equals(BuiltInShopPermission.DELETE.getRawNode())) {
event.setResult(true);
}
}
@@ -104,10 +106,13 @@ public final class Main extends CompatibilityModule implements Listener {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(event.getLocation()), localPlayer, this.createFlag)) {
event.setCancelled(true, getApi().getTextManager().of(event.getCreator(), "addon.worldguard.creation-flag-test-failed").forLocale());
event.setCancelled(
true,
getApi().getTextManager()
.of(event.getCreator(), "addon.worldguard.creation-flag-test-failed")
.forLocale());
}
});
}
@EventHandler(ignoreCancelled = true)
@@ -117,15 +122,27 @@ public final class Main extends CompatibilityModule implements Listener {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(event.getShop().getLocation()), localPlayer, this.createFlag)) {
event.setCancelled(true, getApi().getTextManager().of(event.getCreator(), "addon.worldguard.creation-flag-test-failed").forLocale());
event.setCancelled(
true,
getApi().getTextManager()
.of(event.getCreator(), "addon.worldguard.creation-flag-test-failed")
.forLocale());
return;
}
Set<ProtectedRegion> regions = container.createQuery().getApplicableRegions(BukkitAdapter.adapt(event.getShop().getLocation())).getRegions();
Set<ProtectedRegion> regions = container
.createQuery()
.getApplicableRegions(BukkitAdapter.adapt(event.getShop().getLocation()))
.getRegions();
List<Shop> shops = new ArrayList<>();
regions.forEach(r -> shops.addAll(getRegionShops(r, event.getShop().getLocation().getWorld()).values()));
regions.forEach(r -> shops.addAll(
getRegionShops(r, event.getShop().getLocation().getWorld()).values()));
if (limitPerRegion > 0) {
if (shops.size() + 1 > limitPerRegion) {
event.setCancelled(true, getApi().getTextManager().of(event.getCreator(), "addon.worldguard.reached-per-region-amount-limit").forLocale());
event.setCancelled(
true,
getApi().getTextManager()
.of(event.getCreator(), "addon.worldguard.reached-per-region-amount-limit")
.forLocale());
}
}
});
@@ -160,7 +177,11 @@ public final class Main extends CompatibilityModule implements Listener {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(event.getShop().getLocation()), localPlayer, this.tradeFlag)) {
event.setCancelled(true, getApi().getTextManager().of(event.getPurchaser(), "addon.worldguard.trade-flag-test-failed").forLocale());
event.setCancelled(
true,
getApi().getTextManager()
.of(event.getPurchaser(), "addon.worldguard.trade-flag-test-failed")
.forLocale());
}
});
}
Loaded 100 of 426 files, more files were not shown because too many files have changed in this diff. Show more