Compare commits
402 Commits
Author | SHA1 | Date |
---|---|---|
Johan | af02eb3f14 | |
Max Lee | 7dbc1ad5d3 | |
Phoenix616 | 9f4037c312 | |
Phoenix616 | b6b7a6bf43 | |
Phoenix616 | 60b10a83b6 | |
Phoenix616 | b54824052d | |
Johanmans10 | 8a26b15ea9 | |
Phoenix616 | 09170f6d51 | |
Phoenix616 | 488cd2e9d5 | |
Phoenix616 | 46d4f583ba | |
Phoenix616 | 7a73d66939 | |
Phoenix616 | 6f5b56d20a | |
Phoenix616 | b386cacb5e | |
Phoenix616 | df17fe7483 | |
Phoenix616 | d3f8abb80e | |
Phoenix616 | 2388da62a5 | |
Phoenix616 | 53aa75d9b4 | |
Phoenix616 | a413e86ccf | |
Phoenix616 | 0fcbcbbb11 | |
Phoenix616 | a9cb8096e6 | |
Phoenix616 | 17bd2a1fcb | |
Phoenix616 | d426492561 | |
Joo200 | f3cf4cd96e | |
Phoenix616 | 9bbd6028d0 | |
Phoenix616 | 2b36b7314f | |
Phoenix616 | 0b8fe80443 | |
Phoenix616 | 3ef02d05cd | |
Phoenix616 | 3a1885e2f3 | |
Phoenix616 | 54cc1ce842 | |
Phoenix616 | dc6aa21a91 | |
Phoenix616 | 6ba8e092b8 | |
Phoenix616 | 97ffc31d2b | |
Phoenix616 | ed642ccf3c | |
Phoenix616 | 999f596125 | |
Phoenix616 | 30ff61d14f | |
Phoenix616 | 978f1270f5 | |
Phoenix616 | 7203ec17cd | |
Max Lee | 6602be68e3 | |
Krakenied | 2fb82a2529 | |
Phoenix616 | 05ebe2d054 | |
Phoenix616 | 013a21159f | |
Phoenix616 | d52c329618 | |
Phoenix616 | b425dfb69f | |
Phoenix616 | 0a16ec1d08 | |
Phoenix616 | 362dd856d3 | |
Phoenix616 | 385672ecd4 | |
Phoenix616 | 92a013dd10 | |
Phoenix616 | 7a09c53bde | |
Phoenix616 | 93f14a330d | |
Phoenix616 | 199573df59 | |
Phoenix616 | a38f309453 | |
Phoenix616 | 02ef09c586 | |
Phoenix616 | aa7bfbb7ee | |
Phoenix616 | 7d92cb820d | |
Phoenix616 | 4de1f1e8c5 | |
Phoenix616 | 7ee8d07242 | |
Phoenix616 | 37c7b97fe8 | |
Phoenix616 | 0d8d37eb85 | |
Phoenix616 | e6a2d2f1c5 | |
Phoenix616 | ada8cf3ae8 | |
Phoenix616 | fbfe789bfa | |
Phoenix616 | f547995164 | |
Phoenix616 | d6673c8afd | |
Phoenix616 | f0661656a0 | |
Phoenix616 | 967a315ff8 | |
Phoenix616 | 59e82c7078 | |
Phoenix616 | 236c4b1b37 | |
Phoenix616 | 32879ad3cd | |
Phoenix616 | c15afb4d0b | |
Phoenix616 | 852f20a50e | |
Phoenix616 | e3ab44ae32 | |
Phoenix616 | 9233064273 | |
Phoenix616 | 93e2895645 | |
Phoenix616 | e99ae1eb1e | |
Felipe Foschiera | 9842f47f37 | |
Max Lee | 34df7e368a | |
Jonathan Leitschuh | 5066a21a5f | |
Phoenix616 | da3928b723 | |
Phoenix616 | d0af977212 | |
Phoenix616 | e3cd50cf75 | |
Phoenix616 | a78b925181 | |
Phoenix616 | 5b712f9ed5 | |
Phoenix616 | c54ed6b2f5 | |
Max Lee | f57d1b04a2 | |
Max Lee | 6b372883ac | |
Krakenied | fd969cd996 | |
Phoenix616 | fd0035a99c | |
Phoenix616 | 4285358910 | |
Phoenix616 | dc731919e3 | |
Phoenix616 | a112c50d55 | |
Phoenix616 | 4c7b018f8c | |
Krakenied | 2ebc2f285b | |
Phoenix616 | e40b5567b8 | |
Phoenix616 | 419527efaa | |
Phoenix616 | 99a609b423 | |
jeffry1829 | 5ec2ab61e5 | |
Phoenix616 | d1bbcfce47 | |
Phoenix616 | fa924f0212 | |
Phoenix616 | f9a0bf90a3 | |
Phoenix616 | 02dd167024 | |
Phoenix616 | 8655870077 | |
Phoenix616 | 01b7cddaa3 | |
Phoenix616 | 6962ae2590 | |
Phoenix616 | 03317c2c78 | |
Max Lee | a84cd7a2aa | |
TreyRuffy | bb7bd3415c | |
Phoenix616 | 4f8e7938e2 | |
Phoenix616 | 986a22fb73 | |
Phoenix616 | f7aa80e566 | |
Phoenix616 | d193812392 | |
Phoenix616 | 13b727c779 | |
Phoenix616 | 129663650f | |
Phoenix616 | d3cb06acc0 | |
Phoenix616 | 965d931978 | |
Phoenix616 | 1b85bda656 | |
Phoenix616 | 42a7cc4789 | |
Phoenix616 | a549b4ef51 | |
Phoenix616 | 988420992c | |
Phoenix616 | df2e4394c4 | |
Phoenix616 | 63f68d5444 | |
Phoenix616 | 6f4be10065 | |
Phoenix616 | 8cb78165a3 | |
Max Lee | 3cc219e86b | |
Phoenix616 | 052560393c | |
Phoenix616 | 2545b95d54 | |
Phoenix616 | f825995a85 | |
Phoenix616 | 2be9207faa | |
Phoenix616 | 5b214e09f5 | |
Phoenix616 | d3ed650b74 | |
Phoenix616 | c9b8e136d1 | |
Phoenix616 | ca25dca6b0 | |
Phoenix616 | b09a1255a7 | |
Phoenix616 | b8899c8333 | |
Phoenix616 | 07a22fa534 | |
Phoenix616 | 4172d8d484 | |
Phoenix616 | 02cd9d4ec0 | |
Phoenix616 | 0c51af6b45 | |
Phoenix616 | 76e3f5b3c8 | |
Phoenix616 | 66201a9062 | |
Phoenix616 | ce7cade0a5 | |
Phoenix616 | b93361cd07 | |
Phoenix616 | a3c5ec618a | |
Daniel B | f68a3203ac | |
Rutger Kok | e6b05ff982 | |
Phoenix616 | aadfaff397 | |
Phoenix616 | 227e3e77f0 | |
Phoenix616 | 7b2fe6c1f3 | |
Phoenix616 | 68c9df2078 | |
Phoenix616 | 3ec68dcd50 | |
Phoenix616 | ebdebb81df | |
Phoenix616 | 2f0e7b81a8 | |
Phoenix616 | 320d9ad9fb | |
Phoenix616 | 65df4c40c6 | |
Phoenix616 | 22d3f262f5 | |
Phoenix616 | ba47b82ba1 | |
Phoenix616 | 9843e92525 | |
Phoenix616 | 71e8ef732f | |
Phoenix616 | 66eaab7c4d | |
Phoenix616 | 0d6f588e45 | |
Phoenix616 | f12e6ed3b6 | |
Phoenix616 | 819f028774 | |
Phoenix616 | b774258051 | |
Phoenix616 | 9dce41aa30 | |
Max Lee | 4c44e49c54 | |
Phoenix616 | 395f0513a6 | |
Phoenix616 | 4e40823d23 | |
Phoenix616 | af32b041ff | |
Phoenix616 | 51e9d5f267 | |
Phoenix616 | 8aff3da550 | |
Phoenix616 | fd81bc143e | |
Phoenix616 | 9bf6e1abc1 | |
Phoenix616 | 00fa83c56a | |
Phoenix616 | cbb605df81 | |
Phoenix616 | 4bd443c69f | |
Phoenix616 | 7a1c091c74 | |
Phoenix616 | b43454531e | |
Phoenix616 | 9a08e8897b | |
Phoenix616 | f0bf9a08ec | |
Phoenix616 | 717dcc8d9d | |
Daniel Dušek | c7b07e04d2 | |
Brice Frisco | 8d98958c2d | |
dependabot[bot] | 15b9382b09 | |
Phoenix616 | a14aaa7235 | |
Phoenix616 | 9dd56385eb | |
Phoenix616 | de14a1affb | |
Corey Shupe | 282c39c975 | |
Phoenix616 | 741a10cb95 | |
Phoenix616 | ea5318dcf1 | |
Phoenix616 | b02cc9f909 | |
Phoenix616 | 5f40273756 | |
Phoenix616 | 89ba3d0559 | |
Phoenix616 | 5bc23214e0 | |
Phoenix616 | 6a34054bc7 | |
Phoenix616 | d1f6b1616b | |
Phoenix616 | 8c1c80e138 | |
Phoenix616 | efe9ff7024 | |
Phoenix616 | 742f838f09 | |
Phoenix616 | 98985efd63 | |
Phoenix616 | 9cbf33f68f | |
Phoenix616 | 493784c2dd | |
Phoenix616 | 18c3f8f5ef | |
Phoenix616 | 908c128a10 | |
Phoenix616 | 3c51f8ed87 | |
Phoenix616 | a0630db6f8 | |
Phoenix616 | 6ee7c4759a | |
Phoenix616 | cbd427f561 | |
Phoenix616 | 4a04a623a7 | |
Phoenix616 | 4885092435 | |
Phoenix616 | 183c724583 | |
Phoenix616 | 1f8fd09dd2 | |
Phoenix616 | 0b39fd1a5e | |
Phoenix616 | 7161c0bfdf | |
Phoenix616 | d3f717deef | |
Phoenix616 | 3e061dda8d | |
Phoenix616 | e520544d3a | |
Phoenix616 | 4acd3efda1 | |
Phoenix616 | 080597c515 | |
Phoenix616 | 9f84ca8551 | |
Max Lee | f0641abf2e | |
Phoenix616 | 9dfbca3f81 | |
Phoenix616 | 24d89dbc44 | |
Phoenix616 | d868fe8af6 | |
Phoenix616 | e22a50e1cf | |
Phoenix616 | 7f32a7a722 | |
Phoenix616 | 009febb5c2 | |
Phoenix616 | 7b978ae022 | |
Phoenix616 | f044938b80 | |
Phoenix616 | a427c8c5a0 | |
Phoenix616 | 7fbf50cefe | |
Phoenix616 | 8e6bc01d97 | |
Phoenix616 | 3bf54529db | |
Phoenix616 | bb4eece790 | |
Phoenix616 | 0c1b82c9d8 | |
Phoenix616 | 432c505806 | |
Phoenix616 | 0d08880ed2 | |
Phoenix616 | 9ae6725c5d | |
Phoenix616 | 4673a3f00c | |
Phoenix616 | 8c83be59ba | |
Phoenix616 | 3bed1261aa | |
Phoenix616 | c6f6672188 | |
Phoenix616 | 744b02a447 | |
Phoenix616 | e57bf94923 | |
Phoenix616 | 781e017ae9 | |
Phoenix616 | 2426aef969 | |
Phoenix616 | e8034e20b0 | |
Phoenix616 | bb17cc35a0 | |
Phoenix616 | 059abc569c | |
Josh Roy | 809546ecab | |
Phoenix616 | 86ea093994 | |
Phoenix616 | 7bd00f23be | |
Phoenix616 | 9d6c2f8c1b | |
Phoenix616 | 3fe35cd0a5 | |
Phoenix616 | 23ceaff2ed | |
Phoenix616 | 2a37304113 | |
Phoenix616 | d4bb775086 | |
Max Lee | 584a2bd51c | |
Phoenix616 | d0919e78d7 | |
Phoenix616 | bd8f2dfc19 | |
Phoenix616 | 3d83bfdddd | |
Phoenix616 | 37b7669acb | |
Phoenix616 | 4067427650 | |
Phoenix616 | d5198bd155 | |
Phoenix616 | e15633a4a8 | |
Phoenix616 | 2075693e12 | |
Phoenix616 | 38f93c1d1d | |
Phoenix616 | 40467e3522 | |
Phoenix616 | 35dd13f917 | |
g--o | 88a23a38db | |
Phoenix616 | c028015d5e | |
Phoenix616 | d51a512ab8 | |
Phoenix616 | bc680afcaf | |
Phoenix616 | 58cf96dca8 | |
Phoenix616 | b718fcc429 | |
Phoenix616 | f90d23cfc3 | |
Phoenix616 | 285b6b9089 | |
Phoenix616 | 5eb467a1d3 | |
Phoenix616 | 930b2cc07b | |
Phoenix616 | e972a7d657 | |
Phoenix616 | 6c5e5ece81 | |
Phoenix616 | 481e2bdf9e | |
Phoenix616 | b0523b2199 | |
Max Lee | cef571223e | |
Phoenix616 | 26daa4531d | |
Phoenix616 | 17e7ab781b | |
Phoenix616 | 2907706399 | |
Phoenix616 | a8c57bc0ab | |
Phoenix616 | ca94031ddf | |
Phoenix616 | a95f7316d6 | |
Phoenix616 | b300798a62 | |
Phoenix616 | dcd1dd9057 | |
Phoenix616 | 619ac17cd5 | |
Phoenix616 | 2e0c5a3cac | |
Phoenix616 | 4769ae2cf7 | |
Phoenix616 | da1dd94705 | |
Phoenix616 | 816fe77f27 | |
Phoenix616 | 04f91aa55b | |
Phoenix616 | 0b57382cd0 | |
Phoenix616 | c538f4a3dc | |
Phoenix616 | 6773f89221 | |
Phoenix616 | 8cf9934a32 | |
Phoenix616 | f0bc277566 | |
Phoenix616 | 6e78fea880 | |
Phoenix616 | eb7abda01f | |
Phoenix616 | 28fb5cbeff | |
Phoenix616 | 53ae07b779 | |
Phoenix616 | 8a09e91e62 | |
Phoenix616 | 52492f8469 | |
Phoenix616 | 5a99180aab | |
Phoenix616 | 1952e5cb46 | |
Phoenix616 | c1509dc03a | |
Phoenix616 | 2007c4a7fb | |
Phoenix616 | be5f47cb1f | |
Phoenix616 | 03589b3fef | |
Phoenix616 | b37bf12e7f | |
Phoenix616 | 8cd89bf8ee | |
Phoenix616 | 355fa58ac4 | |
Phoenix616 | b931393a62 | |
Phoenix616 | de5b505ec5 | |
Phoenix616 | 6d99210dd7 | |
Phoenix616 | 20228dd645 | |
Phoenix616 | 91a372bd05 | |
Phoenix616 | c8d0590614 | |
Phoenix616 | 6fe6f80538 | |
Phoenix616 | bc14736a37 | |
Phoenix616 | b853afbd52 | |
Phoenix616 | b17a471c21 | |
Phoenix616 | 727f49fc28 | |
Phoenix616 | 7adf02e532 | |
Phoenix616 | fe85dafec5 | |
Phoenix616 | b5f77d67b5 | |
Phoenix616 | 470f9d8d99 | |
Phoenix616 | 2243c2fbc6 | |
Phoenix616 | 4ef24c3828 | |
Phoenix616 | 26d800132c | |
Phoenix616 | b30688b635 | |
Phoenix616 | 39a522716f | |
Phoenix616 | 96b5a675d6 | |
Phoenix616 | 0c6aaaa6f7 | |
Phoenix616 | adf5340932 | |
Phoenix616 | e1998bcd7c | |
Phoenix616 | 12d2107ce1 | |
Phoenix616 | 173991ab4a | |
Phoenix616 | 54b3b6966c | |
Phoenix616 | 516eefc5b6 | |
Phoenix616 | 2459a406fe | |
Phoenix616 | afab90d021 | |
Phoenix616 | f1ce97dbce | |
Phoenix616 | df76347697 | |
Phoenix616 | 01ebedcc84 | |
Phoenix616 | 06e4e1bf17 | |
Phoenix616 | 5f0bbfff0c | |
Phoenix616 | dd4177e7cb | |
Phoenix616 | 640364e7e7 | |
Brokkonaut | f5b3aa6b75 | |
Brokkonaut | b972e79132 | |
Phoenix616 | cf9e5bafde | |
Phoenix616 | 836ef56864 | |
Phoenix616 | e155b98c96 | |
Phoenix616 | fc62ab0823 | |
Phoenix616 | 3ae71cf13a | |
Phoenix616 | 89dcde83de | |
Phoenix616 | c38af9d5b3 | |
Phoenix616 | d4e39a3751 | |
Phoenix616 | 5680b22345 | |
Phoenix616 | 6c15890c7e | |
Phoenix616 | d24cbe515c | |
Daniel V | 8ae72e5803 | |
Phoenix616 | 7311907559 | |
Phoenix616 | 1cb481097c | |
Phoenix616 | 247b2d239e | |
Phoenix616 | 5b925171e3 | |
Phoenix616 | c39720b449 | |
Phoenix616 | 036d309965 | |
Phoenix616 | b3e62f199f | |
Phoenix616 | 34b6ab2cf2 | |
Phoenix616 | 88bffc6fde | |
Phoenix616 | ae8d1c79e9 | |
Phoenix616 | e40865ac26 | |
Phoenix616 | cceb5844ad | |
Phoenix616 | 68ce9d56f6 | |
Phoenix616 | d28e44f377 | |
Phoenix616 | 40427e427c | |
Phoenix616 | 679000de15 | |
Phoenix616 | dd44217132 | |
Phoenix616 | 51495cdefb | |
Phoenix616 | 26ddb52434 | |
Phoenix616 | d04e17450b | |
Phoenix616 | 58a14bc508 | |
Phoenix616 | 6e9824e6b0 | |
Phoenix616 | b22d8fd95d | |
Tim222 | 21815197c6 | |
Phoenix616 | c5c9e96b13 | |
Phoenix616 | 650d02e401 | |
Phoenix616 | e4fb9f9872 | |
Phoenix616 | 1788fa9702 | |
Phoenix616 | 6d4db1c8f6 | |
Phoenix616 | 0176ea1dc5 | |
Phoenix616 | 39443a2ad3 | |
Phoenix616 | 445ed9574a | |
Phoenix616 | 4fd2bcb836 | |
Phoenix616 | fe68f20997 | |
Phoenix616 | 89b949ef61 |
|
@ -0,0 +1,8 @@
|
||||||
|
files:
|
||||||
|
- source: /src/main/resources/languages/lang.en.yml
|
||||||
|
translation: /src/main/resources/languages/lang.%two_letters_code%.yml
|
||||||
|
languages_mapping:
|
||||||
|
two_letters_code:
|
||||||
|
zh-TW: zh_TW
|
||||||
|
pt-BR: pt_BR
|
||||||
|
es-MX: es_MX
|
|
@ -0,0 +1,6 @@
|
||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: Phoenix616
|
||||||
|
custom: ['https://acrobot-paypal.phoenix616.dev', 'https://tip.phoenix616.dev']
|
||||||
|
issuehunt: ChestShop-authors/ChestShop-3
|
||||||
|
ko_fi: Phoenix616
|
|
@ -1,25 +0,0 @@
|
||||||
[Please search for tickets with the same issues as yours first before reporting!]
|
|
||||||
|
|
||||||
#### Plugin Version
|
|
||||||
[The full plugin version that you are running from /version ChestShop]
|
|
||||||
|
|
||||||
#### Plugin Config
|
|
||||||
[The full config.yml file of ChestShop]
|
|
||||||
|
|
||||||
#### Server Version
|
|
||||||
[The full server version that you are running from /version]
|
|
||||||
|
|
||||||
#### Server Log
|
|
||||||
[The full latest.log file]
|
|
||||||
|
|
||||||
#### What other plugins are you running?
|
|
||||||
[List of your plugins, ideally with the version]
|
|
||||||
|
|
||||||
#### What is happening?
|
|
||||||
[Explain what happens and what steps should be done to reproduce the issue. Ideally with pictures and the full error log!]
|
|
||||||
|
|
||||||
#### What did you expect to happen?
|
|
||||||
[Explain what you expected to happen after performing the previously described steps]
|
|
||||||
|
|
||||||
Please provide any additional info below
|
|
||||||
[And delete the lines in square brackets]
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
name: Bug report
|
||||||
|
description: Report an error that happens in the plugin.
|
||||||
|
labels: []
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: >
|
||||||
|
Please check if there are already similar issues open, also please test if your issue
|
||||||
|
isn't already fixed by trying the latest development build: https://ci.minebench.de/job/ChestShop-3/
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: What is happening?
|
||||||
|
description: Explain what happens and what steps should be done to reproduce the issue. Ideally with pictures and the full error log!
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: What did you expect to happen?
|
||||||
|
description: Explain what you expected to happen after performing the previously described steps
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Plugin Version
|
||||||
|
description: The full plugin version that you are running from `/version ChestShop`
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Plugin Config
|
||||||
|
description: The full `config.yml` file of ChestShop.
|
||||||
|
value: |
|
||||||
|
<details>
|
||||||
|
<summary>Config</summary>
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
[Put the config here]
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Server Version
|
||||||
|
description: The full server version that you are running from `/version`.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Server Log
|
||||||
|
description: The full `latest.log` file, especially important if you have a stack trace
|
||||||
|
value: |
|
||||||
|
<details>
|
||||||
|
<summary>Log</summary>
|
||||||
|
|
||||||
|
```
|
||||||
|
[Your log here]
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: What other plugins are you running?
|
||||||
|
description: List of your plugins, ideally with the version
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Agreements
|
||||||
|
description: Please agree to the following.
|
||||||
|
options:
|
||||||
|
- label: I have checked if there are already similar issues open.
|
||||||
|
- label: I am running the latest development version available from https://ci.minebench.de/job/ChestShop-3/.
|
||||||
|
- label: The version [has support](https://github.com/ChestShop-authors/ChestShop-3/security/policy#supported-versions) for this type of issue.
|
||||||
|
- label: I have provided all requested information and agree to the terms of the [project's license](https://github.com/ChestShop-authors/ChestShop-3/blob/master/LICENSE)
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context or screenshots about the feature request here.
|
|
@ -0,0 +1,8 @@
|
||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: "#chestshop IRC channel on irc.spi.gt"
|
||||||
|
url: "https://kiwiirc.com/client/irc.spi.gt/#chestshop"
|
||||||
|
about: Live chat with the devs and other members of the community
|
||||||
|
- name: SpigotMC discussion thread
|
||||||
|
url: https://www.spigotmc.org/threads/chestshop.295890/
|
||||||
|
about: Ask and answer questions or discuss the plugin in general
|
|
@ -0,0 +1,43 @@
|
||||||
|
name: Enhancement
|
||||||
|
description: Request a feature or suggest an idea for this project
|
||||||
|
labels: [enhancement]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: >
|
||||||
|
Please check if there are already similar issues open, also please test if your request
|
||||||
|
isn't already implemented by trying the latest development build: https://ci.minebench.de/job/ChestShop-3/
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Is your feature request related to a problem? Please describe.
|
||||||
|
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when...
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Describe the solution you'd like
|
||||||
|
description: A clear and concise description of what you want to happen.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Describe alternatives you've considered
|
||||||
|
description: A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Agreements
|
||||||
|
description: Please agree to the following.
|
||||||
|
options:
|
||||||
|
- label: I have checked if there are already similar issues open.
|
||||||
|
required: true
|
||||||
|
- label: I have checked that the latest build doesn't already implement the feature.
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context or screenshots about the feature request here.
|
|
@ -0,0 +1,21 @@
|
||||||
|
name: Qodana
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
qodana:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: 'Qodana Scan'
|
||||||
|
uses: JetBrains/qodana-action@v2022.3.4
|
||||||
|
env:
|
||||||
|
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
|
||||||
|
with:
|
||||||
|
args: --baseline,.github/workflows/qodana/qodana.sarif.json
|
File diff suppressed because it is too large
Load Diff
|
@ -32,5 +32,9 @@ Links
|
||||||
--------------------------------
|
--------------------------------
|
||||||
* [Dev Builds](https://ci.minebench.de/job/ChestShop-3/)
|
* [Dev Builds](https://ci.minebench.de/job/ChestShop-3/)
|
||||||
* [Forum Thread](http://forums.bukkit.org/threads/4150/)
|
* [Forum Thread](http://forums.bukkit.org/threads/4150/)
|
||||||
* [BukkitDev site](http://dev.bukkit.org/server-mods/chestshop/)
|
* [BukkitDev site](http://dev.bukkit.org/projects/chestshop/)
|
||||||
* [Bug Tracker](http://dev.bukkit.org/server-mods/chestshop/tickets/?status=+)
|
* [SpigotMC site](https://www.spigotmc.org/resources/chestshop.51856/)
|
||||||
|
* [Bounties via IssueHunt](https://issuehunt.io/r/ChestShop-authors/ChestShop-3?tab=idle)
|
||||||
|
* [Localization](https://crowdin.com/project/chestshop-3)
|
||||||
|
* [Qodana code quality](https://qodana.cloud/projects/zxDG5/)
|
||||||
|
* [Old bug Tracker](http://dev.bukkit.org/server-mods/chestshop/tickets/?status=+) (please use GitHub issues!)
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
Overview over versions of ChestShop that are currently being actively developed
|
||||||
|
and which ones are supported with security updates if necessary.
|
||||||
|
|
||||||
|
| Version | Active development | Security Fixes |
|
||||||
|
| ------------- | ------------------ | ------------------ |
|
||||||
|
| latest | :heavy_check_mark: | :heavy_check_mark: |
|
||||||
|
| < latest | :x: | :x: |
|
||||||
|
| 3.9.3-1.12 | :x: | :heavy_check_mark: |
|
||||||
|
| 3.9.2-1.8.8 | :x: | :heavy_check_mark: |
|
||||||
|
|
||||||
|
Updates for the different versions can be found on the [build server](https://ci.minebench.de/job/ChestShop-3/),
|
||||||
|
only the latest version will get releases on the main project pages.
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
If you want to report an issue which might pose a security risk then
|
||||||
|
you can do this in private at the following locations:
|
||||||
|
|
||||||
|
- [Start a conversation](https://www.spigotmc.org/conversations/add?to=Phoenix616&title=ChestShop%20Vulnerability) with Phoenix616 on SpigotMC.org
|
||||||
|
- Message phoenix616 on the [SpigotMC IRC network](https://irc.spi.gt/) (irc.spi.gt)
|
||||||
|
- Message phoenix616 on the [Esper.net IRC network](https://esper.net)
|
||||||
|
|
||||||
|
For issues that do not have security implications please [open an issue](https://github.com/ChestShop-authors/ChestShop-3/issues/new/choose).
|
973
pom.xml
973
pom.xml
|
@ -1,379 +1,594 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.acrobot.chestshop</groupId>
|
<groupId>com.acrobot.chestshop</groupId>
|
||||||
<artifactId>chestshop</artifactId>
|
<artifactId>chestshop</artifactId>
|
||||||
<version>3.9.0</version>
|
<version>3.12.3-SNAPSHOT</version>
|
||||||
<description>Chest-and-sign shop plugin for Bukkit</description>
|
<description>Chest-and-sign shop plugin for Bukkit</description>
|
||||||
|
<name>ChestShop</name>
|
||||||
<scm>
|
|
||||||
<connection>scm:git:git://github.com/ChestShop-authors/ChestShop-3</connection>
|
<scm>
|
||||||
<developerConnection>scm:git:ssh://git@github.com/ChestShop-authors/ChestShop-3.git</developerConnection>
|
<connection>scm:git:git://github.com/ChestShop-authors/ChestShop-3</connection>
|
||||||
<url>https://github.com/ChestShop-authors/ChestShop-3</url>
|
<developerConnection>scm:git:ssh://git@github.com/ChestShop-authors/ChestShop-3.git</developerConnection>
|
||||||
</scm>
|
<url>https://github.com/ChestShop-authors/ChestShop-3</url>
|
||||||
|
</scm>
|
||||||
<repositories>
|
|
||||||
<repository>
|
<repositories>
|
||||||
<id>spigotmc-repo</id>
|
<repository>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public</url>
|
<id>enginehub-repo</id>
|
||||||
</repository>
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
<repository>
|
</repository>
|
||||||
<id>sk89q-repo</id>
|
<repository>
|
||||||
<url>http://maven.sk89q.com/artifactory/repo/</url>
|
<id>codemc-repo</id>
|
||||||
</repository>
|
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||||
<repository>
|
</repository>
|
||||||
<id>mcstats-releases</id>
|
<repository>
|
||||||
<url>http://repo.mcstats.org/content/repositories/releases/</url>
|
<id>lwcx-repo</id>
|
||||||
</repository>
|
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||||
<repository>
|
</repository>
|
||||||
<id>bstats-repo</id>
|
<repository>
|
||||||
<url>http://repo.bstats.org/content/repositories/releases/</url>
|
<id>vault-repo</id>
|
||||||
</repository>
|
<url>https://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||||
<repository>
|
</repository>
|
||||||
<id>vault-repo</id>
|
<repository>
|
||||||
<url>http://nexus.hc.to/content/repositories/pub_releases/</url>
|
<id>minebench-repo</id>
|
||||||
</repository>
|
<url>https://repo.minebench.de/</url>
|
||||||
<repository>
|
</repository>
|
||||||
<id>authme-repo</id>
|
<repository>
|
||||||
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
|
<id>local_repo</id>
|
||||||
</repository>
|
<url>file://${project.basedir}/repo/</url>
|
||||||
<repository>
|
</repository>
|
||||||
<id>minebench-repo</id>
|
<repository>
|
||||||
<url>https://repo.minebench.de/</url>
|
<id>jitpack.io</id>
|
||||||
</repository>
|
<url>https://jitpack.io</url>
|
||||||
<repository>
|
</repository>
|
||||||
<id>local_repo</id>
|
<repository>
|
||||||
<url>file://${project.basedir}/repo/</url>
|
<id>NyaaCat</id>
|
||||||
</repository>
|
<url>https://ci.nyaacat.com/maven/</url>
|
||||||
</repositories>
|
</repository>
|
||||||
|
<repository>
|
||||||
<dependencies>
|
<id>redprotect-repo</id>
|
||||||
<dependency>
|
<url>https://raw.githubusercontent.com/FabioZumbi12/RedProtect/mvn-repo/</url>
|
||||||
<groupId>junit</groupId>
|
</repository>
|
||||||
<artifactId>junit</artifactId>
|
<repository>
|
||||||
<version>4.12</version>
|
<id>adventure-repo</id>
|
||||||
<scope>test</scope>
|
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||||
</dependency>
|
</repository>
|
||||||
|
</repositories>
|
||||||
<dependency>
|
|
||||||
<groupId>com.j256.ormlite</groupId>
|
<dependencies>
|
||||||
<artifactId>ormlite-jdbc</artifactId>
|
<dependency>
|
||||||
<version>4.48</version>
|
<groupId>junit</groupId>
|
||||||
<scope>compile</scope>
|
<artifactId>junit</artifactId>
|
||||||
</dependency>
|
<version>4.13.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
<!-- Should be kept in sync with Mojang -->
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<dependency>
|
||||||
<artifactId>log4j-core</artifactId>
|
<groupId>com.j256.ormlite</groupId>
|
||||||
<version>2.1</version>
|
<artifactId>ormlite-jdbc</artifactId>
|
||||||
<scope>provided</scope>
|
<version>6.1</version>
|
||||||
</dependency>
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
<dependency>
|
||||||
<artifactId>spigot-api</artifactId>
|
<groupId>de.themoep.utils</groupId>
|
||||||
<version>1.12-R0.1-SNAPSHOT</version>
|
<artifactId>lang-bukkit</artifactId>
|
||||||
<scope>provided</scope>
|
<version>1.3-SNAPSHOT</version>
|
||||||
</dependency>
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.mcstats.bukkit</groupId>
|
<dependency>
|
||||||
<artifactId>metrics</artifactId>
|
<groupId>de.themoep</groupId>
|
||||||
<version>R8-SNAPSHOT</version>
|
<artifactId>minedown-adventure</artifactId>
|
||||||
<scope>compile</scope>
|
<version>1.7.2-SNAPSHOT</version>
|
||||||
<exclusions>
|
<scope>compile</scope>
|
||||||
<exclusion>
|
</dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>bukkit</artifactId>
|
<dependency>
|
||||||
</exclusion>
|
<groupId>net.kyori</groupId>
|
||||||
<exclusion>
|
<artifactId>adventure-platform-bukkit</artifactId>
|
||||||
<groupId>org.bukkit</groupId>
|
<version>4.3.2</version>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<scope>compile</scope>
|
||||||
</exclusion>
|
</dependency>
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
<dependency>
|
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||||
<groupId>org.bstats</groupId>
|
<version>4.14.0</version>
|
||||||
<artifactId>bstats-bukkit-lite</artifactId>
|
<scope>compile</scope>
|
||||||
<version>1.1</version>
|
<exclusions>
|
||||||
</dependency>
|
<exclusion>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
<dependency>
|
<artifactId>gson</artifactId>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
</exclusion>
|
||||||
<artifactId>Vault</artifactId>
|
</exclusions>
|
||||||
<version>1.6.6</version>
|
</dependency>
|
||||||
<scope>provided</scope>
|
|
||||||
<exclusions>
|
<!-- Should be kept in sync with Mojang -->
|
||||||
<exclusion>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>log4j-core</artifactId>
|
||||||
</exclusion>
|
<version>2.17.2</version>
|
||||||
<exclusion>
|
<scope>provided</scope>
|
||||||
<groupId>org.bukkit</groupId>
|
</dependency>
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
</exclusion>
|
<dependency>
|
||||||
</exclusions>
|
<groupId>org.bstats</groupId>
|
||||||
</dependency>
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
<dependency>
|
<scope>compile</scope>
|
||||||
<groupId>info.somethingodd</groupId>
|
</dependency>
|
||||||
<artifactId>odditem</artifactId>
|
|
||||||
<version>0.9.5</version>
|
<dependency>
|
||||||
<scope>compile</scope>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
<exclusions>
|
<artifactId>Vault</artifactId>
|
||||||
<exclusion>
|
<version>1.6.6</version>
|
||||||
<groupId>org.bukkit</groupId>
|
<scope>provided</scope>
|
||||||
<artifactId>bukkit</artifactId>
|
<exclusions>
|
||||||
</exclusion>
|
<exclusion>
|
||||||
<exclusion>
|
<groupId>org.bukkit</groupId>
|
||||||
<groupId>org.bukkit</groupId>
|
<artifactId>bukkit</artifactId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
</exclusion>
|
||||||
</exclusion>
|
<exclusion>
|
||||||
</exclusions>
|
<groupId>org.bukkit</groupId>
|
||||||
</dependency>
|
<artifactId>craftbukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>com.herocraftonline.heroes</groupId>
|
|
||||||
<artifactId>Heroes</artifactId>
|
|
||||||
<version>1.5.5</version>
|
<dependency>
|
||||||
<scope>provided</scope>
|
<groupId>com.herocraftonline.heroes</groupId>
|
||||||
<exclusions>
|
<artifactId>Heroes</artifactId>
|
||||||
<exclusion>
|
<version>1.5.5</version>
|
||||||
<groupId>*</groupId>
|
<scope>provided</scope>
|
||||||
<artifactId>*</artifactId>
|
<exclusions>
|
||||||
</exclusion>
|
<exclusion>
|
||||||
</exclusions>
|
<groupId>*</groupId>
|
||||||
</dependency>
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
<dependency>
|
</exclusions>
|
||||||
<groupId>fr.xephi</groupId>
|
</dependency>
|
||||||
<artifactId>authme</artifactId>
|
|
||||||
<version>5.2-SNAPSHOT</version>
|
<dependency>
|
||||||
<scope>provided</scope>
|
<groupId>fr.xephi</groupId>
|
||||||
<exclusions>
|
<artifactId>authme</artifactId>
|
||||||
<exclusion>
|
<version>5.6.0-SNAPSHOT</version>
|
||||||
<groupId>org.bukkit</groupId>
|
<scope>provided</scope>
|
||||||
<artifactId>bukkit</artifactId>
|
<exclusions>
|
||||||
</exclusion>
|
<exclusion>
|
||||||
</exclusions>
|
<groupId>org.bukkit</groupId>
|
||||||
</dependency>
|
<artifactId>bukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
<dependency>
|
</exclusions>
|
||||||
<groupId>com.griefcraft.lwc</groupId>
|
</dependency>
|
||||||
<artifactId>lwc</artifactId>
|
|
||||||
<version>4.3.1</version>
|
<dependency>
|
||||||
<scope>provided</scope>
|
<groupId>com.griefcraft.lwc</groupId>
|
||||||
<exclusions>
|
<artifactId>LWCX</artifactId>
|
||||||
<exclusion>
|
<version>2.2.5</version>
|
||||||
<groupId>org.bukkit</groupId>
|
<scope>provided</scope>
|
||||||
<artifactId>bukkit</artifactId>
|
<exclusions>
|
||||||
</exclusion>
|
<exclusion>
|
||||||
<exclusion>
|
<groupId>org.bukkit</groupId>
|
||||||
<groupId>org.bukkit</groupId>
|
<artifactId>bukkit</artifactId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
</exclusion>
|
||||||
</exclusion>
|
<exclusion>
|
||||||
</exclusions>
|
<groupId>org.bukkit</groupId>
|
||||||
</dependency>
|
<artifactId>craftbukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
<dependency>
|
</exclusions>
|
||||||
<groupId>com.daemitus.deadbolt</groupId>
|
</dependency>
|
||||||
<artifactId>deadbolt</artifactId>
|
|
||||||
<version>2.2</version>
|
<dependency>
|
||||||
<scope>provided</scope>
|
<groupId>com.daemitus.deadbolt</groupId>
|
||||||
<exclusions>
|
<artifactId>deadbolt</artifactId>
|
||||||
<exclusion>
|
<version>2.2</version>
|
||||||
<groupId>org.bukkit</groupId>
|
<scope>provided</scope>
|
||||||
<artifactId>bukkit</artifactId>
|
<exclusions>
|
||||||
</exclusion>
|
<exclusion>
|
||||||
<exclusion>
|
<groupId>org.bukkit</groupId>
|
||||||
<groupId>org.bukkit</groupId>
|
<artifactId>bukkit</artifactId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
</exclusion>
|
||||||
</exclusion>
|
<exclusion>
|
||||||
</exclusions>
|
<groupId>org.bukkit</groupId>
|
||||||
</dependency>
|
<artifactId>craftbukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
<dependency>
|
</exclusions>
|
||||||
<groupId>com.sk89q</groupId>
|
</dependency>
|
||||||
<artifactId>worldguard</artifactId>
|
|
||||||
<version>6.1.1-SNAPSHOT</version>
|
<dependency>
|
||||||
<scope>provided</scope>
|
<groupId>javax.persistence</groupId>
|
||||||
<exclusions>
|
<artifactId>persistence-api</artifactId>
|
||||||
<exclusion>
|
<version>1.0</version>
|
||||||
<groupId>org.bukkit</groupId>
|
<scope>compile</scope>
|
||||||
<artifactId>bukkit</artifactId>
|
</dependency>
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>jsr305</artifactId>
|
||||||
</exclusion>
|
<version>3.0.2</version>
|
||||||
</exclusions>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.webkonsept.bukkit.simplechestlock</groupId>
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
<artifactId>simplechestlock</artifactId>
|
<artifactId>worldedit-core</artifactId>
|
||||||
<version>1.2.1</version>
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
</exclusions>
|
||||||
<groupId>org.bukkit</groupId>
|
</dependency>
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
</exclusion>
|
<dependency>
|
||||||
</exclusions>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
</dependency>
|
<artifactId>worldguard-legacy</artifactId>
|
||||||
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
<dependency>
|
<scope>provided</scope>
|
||||||
<groupId>org.yi.acru.bukkit.lockette</groupId>
|
<exclusions>
|
||||||
<artifactId>lockette</artifactId>
|
<exclusion>
|
||||||
<version>1.8.14</version>
|
<groupId>org.bukkit</groupId>
|
||||||
<scope>provided</scope>
|
<artifactId>bukkit</artifactId>
|
||||||
<exclusions>
|
</exclusion>
|
||||||
<exclusion>
|
</exclusions>
|
||||||
<groupId>org.bukkit</groupId>
|
</dependency>
|
||||||
<artifactId>bukkit</artifactId>
|
|
||||||
</exclusion>
|
<dependency>
|
||||||
<exclusion>
|
<groupId>com.github.TechFortress</groupId>
|
||||||
<groupId>org.bukkit</groupId>
|
<artifactId>GriefPrevention</artifactId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<version>16.12.0</version>
|
||||||
</exclusion>
|
<scope>provided</scope>
|
||||||
</exclusions>
|
<exclusions>
|
||||||
</dependency>
|
<exclusion>
|
||||||
<dependency>
|
<groupId>org.bukkit</groupId>
|
||||||
<groupId>com.bekvon.bukkit</groupId>
|
<artifactId>bukkit</artifactId>
|
||||||
<artifactId>residence</artifactId>
|
</exclusion>
|
||||||
<version>4.6.1.4</version>
|
</exclusions>
|
||||||
<scope>provided</scope>
|
</dependency>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>com.github.jojodmo</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>ItemBridge</artifactId>
|
||||||
</exclusion>
|
<version>b0054538c1</version>
|
||||||
<exclusion>
|
</dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>craftbukkit</artifactId>
|
<dependency>
|
||||||
</exclusion>
|
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
|
||||||
</exclusions>
|
<artifactId>RedProtect-Spigot</artifactId>
|
||||||
</dependency>
|
<version>7.7.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>de.themoep.showitem</groupId>
|
<dependency>
|
||||||
<artifactId>api</artifactId>
|
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
|
||||||
<version>1.2.24</version>
|
<artifactId>RedProtect-Core</artifactId>
|
||||||
<scope>provided</scope>
|
<version>7.7.3</version>
|
||||||
</dependency>
|
<scope>provided</scope>
|
||||||
</dependencies>
|
</dependency>
|
||||||
|
|
||||||
<build>
|
<dependency>
|
||||||
<plugins>
|
<groupId>com.webkonsept.bukkit.simplechestlock</groupId>
|
||||||
<plugin>
|
<artifactId>simplechestlock</artifactId>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<version>1.2.1</version>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<scope>provided</scope>
|
||||||
<version>2.4</version>
|
<exclusions>
|
||||||
<configuration>
|
<exclusion>
|
||||||
<finalName>ChestShop</finalName>
|
<groupId>org.bukkit</groupId>
|
||||||
</configuration>
|
<artifactId>bukkit</artifactId>
|
||||||
</plugin>
|
</exclusion>
|
||||||
<plugin>
|
<exclusion>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<groupId>org.bukkit</groupId>
|
||||||
<version>2.3.2</version>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<configuration>
|
</exclusion>
|
||||||
<source>1.8</source>
|
</exclusions>
|
||||||
<target>1.8</target>
|
</dependency>
|
||||||
</configuration>
|
|
||||||
</plugin>
|
<dependency>
|
||||||
<plugin>
|
<groupId>org.yi.acru.bukkit.lockette</groupId>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<artifactId>lockette</artifactId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<version>1.8.14</version>
|
||||||
<version>2.3</version>
|
<scope>provided</scope>
|
||||||
<executions>
|
<exclusions>
|
||||||
<execution>
|
<exclusion>
|
||||||
<phase>package</phase>
|
<groupId>org.bukkit</groupId>
|
||||||
<goals>
|
<artifactId>bukkit</artifactId>
|
||||||
<goal>shade</goal>
|
</exclusion>
|
||||||
</goals>
|
<exclusion>
|
||||||
<configuration>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactSet>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<includes>
|
</exclusion>
|
||||||
<include>org.mcstats.bukkit</include>
|
</exclusions>
|
||||||
<include>org.bstats:*</include>
|
</dependency>
|
||||||
<include>net.gravitydevelopment.updater</include>
|
|
||||||
<include>com.j256.ormlite</include>
|
<dependency>
|
||||||
<include>org.apache.logging.log4j</include>
|
<groupId>nl.rutgerkok</groupId>
|
||||||
</includes>
|
<artifactId>blocklocker</artifactId>
|
||||||
</artifactSet>
|
<version>1.9</version>
|
||||||
<relocations>
|
<scope>provided</scope>
|
||||||
<relocation>
|
</dependency>
|
||||||
<pattern>org.mcstats</pattern>
|
|
||||||
<shadedPattern>com.Acrobot.ChestShop.Metrics.MCStats</shadedPattern>
|
<dependency>
|
||||||
</relocation>
|
<groupId>com.bekvon.bukkit</groupId>
|
||||||
<relocation>
|
<artifactId>residence</artifactId>
|
||||||
<pattern>org.bstats</pattern>
|
<version>4.6.1.4</version>
|
||||||
<shadedPattern>com.Acrobot.ChestShop.Metrics.BStats</shadedPattern>
|
<scope>provided</scope>
|
||||||
</relocation>
|
<exclusions>
|
||||||
<relocation>
|
<exclusion>
|
||||||
<pattern>net.gravitydevelopment.updater</pattern>
|
<groupId>org.bukkit</groupId>
|
||||||
<shadedPattern>com.Acrobot.ChestShop.Updater</shadedPattern>
|
<artifactId>bukkit</artifactId>
|
||||||
</relocation>
|
</exclusion>
|
||||||
<relocation>
|
<exclusion>
|
||||||
<pattern>com.j256.ormlite</pattern>
|
<groupId>org.bukkit</groupId>
|
||||||
<shadedPattern>com.Acrobot.ChestShop.ORMlite</shadedPattern>
|
<artifactId>craftbukkit</artifactId>
|
||||||
</relocation>
|
</exclusion>
|
||||||
</relocations>
|
</exclusions>
|
||||||
</configuration>
|
</dependency>
|
||||||
</execution>
|
|
||||||
</executions>
|
<dependency>
|
||||||
</plugin>
|
<groupId>de.themoep.showitem</groupId>
|
||||||
</plugins>
|
<artifactId>api</artifactId>
|
||||||
|
<version>1.6.3</version>
|
||||||
<resources>
|
<scope>provided</scope>
|
||||||
<resource>
|
</dependency>
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
<dependency>
|
||||||
</resource>
|
<groupId>net.tnemc</groupId>
|
||||||
</resources>
|
<artifactId>Reserve</artifactId>
|
||||||
</build>
|
<version>0.1.5.4</version>
|
||||||
|
<scope>provided</scope>
|
||||||
<properties>
|
</dependency>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<build.number>${buildNumber}</build.number>
|
<dependency>
|
||||||
<bukkit.plugin.version>${project.version} ${buildDescription}</bukkit.plugin.version>
|
<groupId>me.crafter.mc</groupId>
|
||||||
</properties>
|
<artifactId>lockettepro</artifactId>
|
||||||
|
<version>2.10-SNAPSHOT</version>
|
||||||
<profiles>
|
<scope>provided</scope>
|
||||||
<profile>
|
</dependency>
|
||||||
<id>static_build_number</id>
|
</dependencies>
|
||||||
<activation>
|
|
||||||
<property>
|
<build>
|
||||||
<name>!env.BUILD_NUMBER</name>
|
<finalName>${project.name}</finalName>
|
||||||
</property>
|
<plugins>
|
||||||
</activation>
|
<plugin>
|
||||||
<properties>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<buildNumber>0</buildNumber>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<buildDescription>(compiled at ${maven.build.timestamp})</buildDescription>
|
<version>3.2.0</version>
|
||||||
</properties>
|
<configuration>
|
||||||
</profile>
|
<forceCreation>true</forceCreation>
|
||||||
<profile>
|
<archive>
|
||||||
<id>dynamic_build_number</id>
|
<manifest>
|
||||||
<activation>
|
<addDefaultEntries>true</addDefaultEntries>
|
||||||
<property>
|
</manifest>
|
||||||
<name>env.BUILD_NUMBER</name>
|
<manifestEntries>
|
||||||
</property>
|
<Distribution-Type>${buildType}</Distribution-Type>
|
||||||
</activation>
|
<Built-At>${maven.build.timestamp}</Built-At>
|
||||||
<properties>
|
<Build-Jdk>${java.runtime.version}</Build-Jdk>
|
||||||
<buildNumber>${env.BUILD_NUMBER}</buildNumber>
|
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||||
<buildDescription>(build #${env.BUILD_NUMBER})</buildDescription>
|
</manifestEntries>
|
||||||
</properties>
|
</archive>
|
||||||
</profile>
|
</configuration>
|
||||||
</profiles>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
</project>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>de.themoep:*</include>
|
||||||
|
<include>de.themoep.utils:*</include>
|
||||||
|
<include>net.kyori:*</include>
|
||||||
|
<include>org.bstats:*</include>
|
||||||
|
<include>net.gravitydevelopment.updater</include>
|
||||||
|
<include>com.j256.ormlite</include>
|
||||||
|
<include>javax.persistence</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>de.themoep.utils.lang</pattern>
|
||||||
|
<shadedPattern>com.Acrobot.ChestShop.Libs.Lang</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>de.themoep.minedown.adventure</pattern>
|
||||||
|
<shadedPattern>com.Acrobot.ChestShop.Libs.MineDown</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.kyori</pattern>
|
||||||
|
<shadedPattern>com.Acrobot.ChestShop.Libs.Kyori</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.bstats</pattern>
|
||||||
|
<shadedPattern>com.Acrobot.ChestShop.Metrics.BStats</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.gravitydevelopment.updater</pattern>
|
||||||
|
<shadedPattern>com.Acrobot.ChestShop.Updater</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.j256.ormlite</pattern>
|
||||||
|
<shadedPattern>com.Acrobot.ChestShop.Libs.ORMlite</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>javax.persistence</pattern>
|
||||||
|
<shadedPattern>com.Acrobot.ChestShop.Libs.javax.persistence</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>.</directory>
|
||||||
|
<includes>
|
||||||
|
<include>LICENSE</include>
|
||||||
|
<include>README.md</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<build.number>${buildNumber}</build.number>
|
||||||
|
<user.name>${buildType}</user.name>
|
||||||
|
<bukkit.plugin.version>${project.version} ${buildDescription}</bukkit.plugin.version>
|
||||||
|
<bukkit.dependency.version>1.20.5-R0.1-SNAPSHOT</bukkit.dependency.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>default</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>!testprofile</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>paper-repo</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc.paper</groupId>
|
||||||
|
<artifactId>paper-api</artifactId>
|
||||||
|
<version>${bukkit.dependency.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>spigot</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>testprofile</name>
|
||||||
|
<value>spigot</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigotmc-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/groups/public</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>${bukkit.dependency.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<finalName>${project.name}-Spigot</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/Paper*.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>backwards</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>testprofile</name>
|
||||||
|
<value>backwards</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>paper-repo</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.destroystokyo.paper</groupId>
|
||||||
|
<artifactId>paper-api</artifactId>
|
||||||
|
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<finalName>${project.name}-1.13.2</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/PaperLatest*.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>static_build_number</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>!env.BUILD_NUMBER</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<buildType>manual</buildType>
|
||||||
|
<buildNumber>0</buildNumber>
|
||||||
|
<buildDescription>(compiled at ${maven.build.timestamp})</buildDescription>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>dynamic_build_number</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env.BUILD_NUMBER</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<buildType>jenkins</buildType>
|
||||||
|
<buildNumber>${env.BUILD_NUMBER}</buildNumber>
|
||||||
|
<buildDescription>(build ${env.BUILD_NUMBER})</buildDescription>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
fe29bd77061f1ced861554d6d6d28cf7
|
|
|
@ -1 +0,0 @@
|
||||||
d9c12329efa1b76057c6ec6eb9371823369e27f5
|
|
|
@ -1 +0,0 @@
|
||||||
45ebcc66da30cab5c5d7b2c2e29651df
|
|
|
@ -1 +0,0 @@
|
||||||
46707be3cc027277671520396501466157b6dcce
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<metadata>
|
|
||||||
<groupId>com.griefcraft.lwc</groupId>
|
|
||||||
<artifactId>lwc</artifactId>
|
|
||||||
<versioning>
|
|
||||||
<release>4.3.1</release>
|
|
||||||
<versions>
|
|
||||||
<version>4.3.1</version>
|
|
||||||
</versions>
|
|
||||||
<lastUpdated>20130308183115</lastUpdated>
|
|
||||||
</versioning>
|
|
||||||
</metadata>
|
|
|
@ -1 +0,0 @@
|
||||||
eff48fcb809bfa5cef0a0660d8449ee3
|
|
|
@ -1 +0,0 @@
|
||||||
e9c597ab4ce925154cad4e0d10aff5161d051a06
|
|
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
c7b3b9b7cd7cd27a50c079ce4349f628
|
|
|
@ -1 +0,0 @@
|
||||||
697ff692f06dc9064badb2610fd52399651b8274
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>info.somethingodd</groupId>
|
|
||||||
<artifactId>odditem</artifactId>
|
|
||||||
<version>0.9.5</version>
|
|
||||||
<description>POM was created from install:install-file</description>
|
|
||||||
</project>
|
|
|
@ -1 +0,0 @@
|
||||||
9fa8325983cb90581156734d0500aacb
|
|
|
@ -1 +0,0 @@
|
||||||
288ed3c67d66d532eac2128c120a6d74986823d6
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<metadata>
|
|
||||||
<groupId>info.somethingodd</groupId>
|
|
||||||
<artifactId>odditem</artifactId>
|
|
||||||
<versioning>
|
|
||||||
<release>0.9.5</release>
|
|
||||||
<versions>
|
|
||||||
<version>0.9.5</version>
|
|
||||||
</versions>
|
|
||||||
<lastUpdated>20130826223956</lastUpdated>
|
|
||||||
</versioning>
|
|
||||||
</metadata>
|
|
|
@ -1 +0,0 @@
|
||||||
7240080156e6cd8df6f550049950a99c
|
|
|
@ -1 +0,0 @@
|
||||||
23208c6e99b6df3664c26f771fa941a37387f428
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<metadata modelVersion="1.1.0">
|
||||||
|
<groupId>org.mcstats.bukkit</groupId>
|
||||||
|
<artifactId>metrics</artifactId>
|
||||||
|
<version>R8-SNAPSHOT</version>
|
||||||
|
<versioning>
|
||||||
|
<snapshot>
|
||||||
|
<localCopy>true</localCopy>
|
||||||
|
</snapshot>
|
||||||
|
<lastUpdated>20180711163419</lastUpdated>
|
||||||
|
<snapshotVersions>
|
||||||
|
<snapshotVersion>
|
||||||
|
<extension>jar</extension>
|
||||||
|
<value>R8-SNAPSHOT</value>
|
||||||
|
<updated>20180711163419</updated>
|
||||||
|
</snapshotVersion>
|
||||||
|
<snapshotVersion>
|
||||||
|
<extension>pom</extension>
|
||||||
|
<value>R8-SNAPSHOT</value>
|
||||||
|
<updated>20180711163419</updated>
|
||||||
|
</snapshotVersion>
|
||||||
|
</snapshotVersions>
|
||||||
|
</versioning>
|
||||||
|
</metadata>
|
|
@ -0,0 +1 @@
|
||||||
|
46632b59c9d3d47442b77c0554325496
|
|
@ -0,0 +1 @@
|
||||||
|
20541fa3752c0169c1ac8af2232281ccb1e01969
|
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
d0916f0631371e2cd1ba27b7a24e9528
|
|
@ -0,0 +1 @@
|
||||||
|
c473200c17a6157d7f59f5935df2169088a78d8e
|
|
@ -2,8 +2,8 @@
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.griefcraft.lwc</groupId>
|
<groupId>org.mcstats.bukkit</groupId>
|
||||||
<artifactId>lwc</artifactId>
|
<artifactId>metrics</artifactId>
|
||||||
<version>4.3.1</version>
|
<version>R8-SNAPSHOT</version>
|
||||||
<description>POM was created from install:install-file</description>
|
<description>POM was created from install:install-file</description>
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1 @@
|
||||||
|
209c9099f021a6a85d1d337de6c2e74a
|
|
@ -0,0 +1 @@
|
||||||
|
38207d9da32bb25d60da9676d1d34966567d62e5
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<metadata>
|
||||||
|
<groupId>org.mcstats.bukkit</groupId>
|
||||||
|
<artifactId>metrics</artifactId>
|
||||||
|
<versioning>
|
||||||
|
<versions>
|
||||||
|
<version>R8-SNAPSHOT</version>
|
||||||
|
</versions>
|
||||||
|
<lastUpdated>20180711163419</lastUpdated>
|
||||||
|
</versioning>
|
||||||
|
</metadata>
|
|
@ -0,0 +1 @@
|
||||||
|
52f4c1a0347427b995125e438ea9b81d
|
|
@ -0,0 +1 @@
|
||||||
|
ce375488dc6366cc09efdc249006b25ff0dec3cf
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.Acrobot.Breeze.Collection;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
public class SimpleCache<K, V> {
|
||||||
|
private final Map<K, V> map;
|
||||||
|
|
||||||
|
public SimpleCache(int cacheSize) {
|
||||||
|
map = Collections.synchronizedMap(new LinkedHashMap<K, V>(cacheSize * 10/9, 0.7f, true) {
|
||||||
|
@Override
|
||||||
|
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
|
||||||
|
return size() > cacheSize;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public V put(K key, V value) {
|
||||||
|
return map.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public V get(K key) {
|
||||||
|
return map.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public V get(K key, Callable<? extends V> loader) throws ExecutionException {
|
||||||
|
if (contains(key)) {
|
||||||
|
return map.get(key);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
V value = loader.call();
|
||||||
|
if (value != null) {
|
||||||
|
put(key, value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ExecutionException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(K key) {
|
||||||
|
return map.containsKey(key);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.Acrobot.Breeze.Configuration.Annotations;
|
||||||
|
|
||||||
|
import com.Acrobot.Breeze.Configuration.ValueParser;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation for a parser
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
public @interface Parser {
|
||||||
|
/**
|
||||||
|
* This option's comment
|
||||||
|
*
|
||||||
|
* @return Comment
|
||||||
|
*/
|
||||||
|
public String value();
|
||||||
|
}
|
|
@ -7,8 +7,15 @@ import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import com.Acrobot.Breeze.Configuration.Annotations.Parser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
@ -21,6 +28,18 @@ import com.Acrobot.Breeze.Configuration.Annotations.PrecededBySpace;
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
|
private static Map<String, ValueParser> parsers = new HashMap<>();
|
||||||
|
private static final ValueParser DEFAULT_PARSER = new ValueParser();
|
||||||
|
private static final ValueParser ENUM_PARSER = new ValueParser() {
|
||||||
|
@Override
|
||||||
|
public <T> Object parseToJava(Class<T> type, Object object) {
|
||||||
|
if (object instanceof String && type.isEnum()) {
|
||||||
|
return Enum.valueOf((Class<? extends Enum>) type, ((String) object).toUpperCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a YAML-formatted file into a class and modifies the file if some of class's fields are missing
|
* Loads a YAML-formatted file into a class and modifies the file if some of class's fields are missing
|
||||||
*
|
*
|
||||||
|
@ -28,8 +47,24 @@ public class Configuration {
|
||||||
* @param clazz Class to modify
|
* @param clazz Class to modify
|
||||||
*/
|
*/
|
||||||
public static void pairFileAndClass(File file, Class<?> clazz) {
|
public static void pairFileAndClass(File file, Class<?> clazz) {
|
||||||
|
pairFileAndClass(file, clazz, Bukkit.getLogger());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a YAML-formatted file into a class and modifies the file if some of class's fields are missing
|
||||||
|
*
|
||||||
|
* @param file File to load
|
||||||
|
* @param clazz Class to modify
|
||||||
|
* @param logger The logger to use to log some information about the pairing
|
||||||
|
*/
|
||||||
|
public static void pairFileAndClass(File file, Class<?> clazz, Logger logger) {
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
|
boolean debug = config.getBoolean("DEBUG", false);
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
logger.log(Level.INFO, "Loading configuration " + file.getName());
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
|
BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
|
||||||
|
|
||||||
|
@ -39,6 +74,9 @@ public class Configuration {
|
||||||
|
|
||||||
for (Field field : clazz.getDeclaredFields()) {
|
for (Field field : clazz.getDeclaredFields()) {
|
||||||
if (!Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers()) || !Modifier.isPublic(field.getModifiers())) {
|
if (!Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers()) || !Modifier.isPublic(field.getModifiers())) {
|
||||||
|
if (debug) {
|
||||||
|
logger.log(Level.WARNING, "Field " + field.getName() + " is private, transient or not static!");
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +84,9 @@ public class Configuration {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (config.isSet(path)) {
|
if (config.isSet(path)) {
|
||||||
field.set(null, ValueParser.parseToJava(config.get(path)));
|
field.set(null, getParser(field).parseToJava(field.getType(), config.get(path)));
|
||||||
|
} else if (config.isSet(path.toLowerCase(Locale.ROOT))) {
|
||||||
|
field.set(null, getParser(field).parseToJava(field.getType(), config.get(path.toLowerCase(Locale.ROOT))));
|
||||||
} else {
|
} else {
|
||||||
if (field.isAnnotationPresent(PrecededBySpace.class)) {
|
if (field.isAnnotationPresent(PrecededBySpace.class)) {
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
|
@ -55,17 +95,18 @@ public class Configuration {
|
||||||
writer.write(FieldParser.parse(field));
|
writer.write(FieldParser.parse(field));
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
if (debug) {
|
||||||
e.printStackTrace();
|
logger.log(Level.INFO, field.getName() + ": " + Configuration.getParser(field).parseToYAML(field.get(null)));
|
||||||
} catch (IOException e) {
|
}
|
||||||
e.printStackTrace();
|
} catch (IllegalArgumentException | IllegalAccessException | IOException e) {
|
||||||
|
logger.log(Level.SEVERE, "Error while loading field " + field.getName() + " in configuration " + file.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
logger.log(Level.SEVERE, "Error while loading configuration " + file.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +126,7 @@ public class Configuration {
|
||||||
|
|
||||||
return lastLine.isEmpty();
|
return lastLine.isEmpty();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("Configuration").log(Level.SEVERE, "Error while checking if file " + file.getName() + " ends with space", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +138,7 @@ public class Configuration {
|
||||||
* @return Parsed output
|
* @return Parsed output
|
||||||
*/
|
*/
|
||||||
public static String parseToConfig(Object value) {
|
public static String parseToConfig(Object value) {
|
||||||
return ValueParser.parseToYAML(value);
|
return DEFAULT_PARSER.parseToYAML(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,4 +150,44 @@ public class Configuration {
|
||||||
public static String getColoured(String string) {
|
public static String getColoured(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a parser
|
||||||
|
* @param name The name of the parser
|
||||||
|
* @param valueParser The parser itself
|
||||||
|
*/
|
||||||
|
public static void registerParser(String name, ValueParser valueParser) {
|
||||||
|
parsers.put(name.toLowerCase(Locale.ROOT), valueParser);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a registered parser
|
||||||
|
* @param name The name of the parser
|
||||||
|
* @return The parser or null if it doesn't exist
|
||||||
|
*/
|
||||||
|
public static ValueParser getParser(String name) {
|
||||||
|
return parsers.get(name.toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the parser that should be used for a field
|
||||||
|
* @param field The field
|
||||||
|
* @return The registered parser if the field has a Parser annotation or the default one
|
||||||
|
*/
|
||||||
|
public static ValueParser getParser(Field field) {
|
||||||
|
ValueParser parser = null;
|
||||||
|
if (field.isAnnotationPresent(Parser.class)) {
|
||||||
|
parser = Configuration.getParser(field.getAnnotation(Parser.class).value());
|
||||||
|
}
|
||||||
|
if (parser == null) {
|
||||||
|
parser = Configuration.getParser(field.getType().getSimpleName());
|
||||||
|
}
|
||||||
|
if (parser == null && field.getType().isEnum()) {
|
||||||
|
parser = Configuration.ENUM_PARSER;
|
||||||
|
}
|
||||||
|
if (parser == null) {
|
||||||
|
parser = Configuration.DEFAULT_PARSER;
|
||||||
|
}
|
||||||
|
return parser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.Acrobot.Breeze.Configuration;
|
||||||
import com.Acrobot.Breeze.Configuration.Annotations.ConfigurationComment;
|
import com.Acrobot.Breeze.Configuration.Annotations.ConfigurationComment;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -17,15 +19,19 @@ public class FieldParser {
|
||||||
public static String parse(Field field) {
|
public static String parse(Field field) {
|
||||||
StringBuilder builder = new StringBuilder(50);
|
StringBuilder builder = new StringBuilder(50);
|
||||||
|
|
||||||
try {
|
if (field.isAnnotationPresent(ConfigurationComment.class)) {
|
||||||
builder.append(field.getName()).append(": ").append(ValueParser.parseToYAML(field.get(null)));
|
for (String commentLine : field.getAnnotation(ConfigurationComment.class).value().split("\n")) {
|
||||||
} catch (IllegalAccessException e) {
|
builder.append("# ").append(commentLine).append('\n');
|
||||||
e.printStackTrace();
|
}
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.isAnnotationPresent(ConfigurationComment.class)) {
|
ValueParser parser = Configuration.getParser(field);
|
||||||
builder.append('\n').append('#').append(field.getAnnotation(ConfigurationComment.class).value());
|
|
||||||
|
try {
|
||||||
|
builder.append(field.getName()).append(": ").append(parser.parseToYAML(field.get(null)));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
Logger.getLogger("FieldParser").log(Level.SEVERE, "Error while parsing field", e);
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|
|
@ -2,9 +2,12 @@ package com.Acrobot.Breeze.Configuration;
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -16,9 +19,22 @@ public class ValueParser {
|
||||||
* @param object Object to parse
|
* @param object Object to parse
|
||||||
* @return YAML string
|
* @return YAML string
|
||||||
*/
|
*/
|
||||||
public static String parseToYAML(Object object) {
|
public String parseToYAML(Object object) {
|
||||||
if (object instanceof Number || object instanceof Boolean) {
|
if (object instanceof Number || object instanceof Boolean) {
|
||||||
return String.valueOf(object);
|
return String.valueOf(object);
|
||||||
|
} else if (object instanceof Collection) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Object o : (Collection) object) {
|
||||||
|
sb.append("\n- ").append(parseToYAML(o));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
} else if (object instanceof String) {
|
||||||
|
String[] lines = ((String) object).split("\\R");
|
||||||
|
if (lines.length == 1) {
|
||||||
|
return '\"' + String.valueOf(object).replace("\\", "\\\\") + '\"';
|
||||||
|
} else {
|
||||||
|
return "|-\n" + Arrays.stream(lines).map(s -> " " + s.replace("\\", "\\\\")).collect(Collectors.joining("\n"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return '\"' + String.valueOf(object) + '\"';
|
return '\"' + String.valueOf(object) + '\"';
|
||||||
}
|
}
|
||||||
|
@ -27,12 +43,13 @@ public class ValueParser {
|
||||||
/**
|
/**
|
||||||
* Parses a YAML "object" to Java-compatible object
|
* Parses a YAML "object" to Java-compatible object
|
||||||
*
|
*
|
||||||
|
* @param type The type of the returned object
|
||||||
* @param object Object to parse
|
* @param object Object to parse
|
||||||
* @return Java-compatible object
|
* @return Java-compatible object
|
||||||
*/
|
*/
|
||||||
public static Object parseToJava(Object object) {
|
public <T> Object parseToJava(Class<T> type, Object object) {
|
||||||
if (object instanceof ConfigurationSection) {
|
if (object instanceof ConfigurationSection) {
|
||||||
Map<String, List<String>> map = new HashMap<String, List<String>>();
|
Map<String, List<String>> map = new HashMap<>();
|
||||||
|
|
||||||
for (String message : ((ConfigurationSection) object).getKeys(false)) {
|
for (String message : ((ConfigurationSection) object).getKeys(false)) {
|
||||||
map.put(message, ((ConfigurationSection) object).getStringList(message));
|
map.put(message, ((ConfigurationSection) object).getStringList(message));
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package com.Acrobot.Breeze.Database;
|
package com.Acrobot.Breeze.Database;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
|
||||||
|
@ -60,7 +64,7 @@ public class Database {
|
||||||
try {
|
try {
|
||||||
table.create(fields);
|
table.create(fields);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("Database").log(Level.SEVERE, "Error while creating database from " + clazz.getName() + " (" + fields + ")", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EntityParser {
|
||||||
fields.add(convertToSQL(field));
|
fields.add(convertToSQL(field));
|
||||||
}
|
}
|
||||||
|
|
||||||
return fields.stream().collect(Collectors.joining(","));
|
return String.join(",", fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.Acrobot.Breeze.Database;
|
package com.Acrobot.Breeze.Database;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing a Row in SQL query
|
* A class representing a Row in SQL query
|
||||||
|
@ -85,21 +87,16 @@ public class Row {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
object = clazz.newInstance();
|
object = clazz.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
Logger.getLogger("Row").log(Level.SEVERE, "Error while creating new instance of class " + clazz.getName() + " for row", e);
|
||||||
return null;
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, String> value : values.entrySet()) {
|
for (Map.Entry<String, String> value : values.entrySet()) {
|
||||||
try {
|
try {
|
||||||
clazz.getDeclaredField(value.getKey()).set(object, value.getValue());
|
clazz.getDeclaredField(value.getKey()).set(object, value.getValue());
|
||||||
} catch (NoSuchFieldException ex) {
|
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||||
ex.printStackTrace();
|
Logger.getLogger("Row").log(Level.SEVERE, "Error while setting field " + value.getKey() + " to " + value.getValue() + " of class " + clazz.getName(), ex);
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class Table {
|
||||||
String statement;
|
String statement;
|
||||||
|
|
||||||
if (condition == null || condition.isEmpty()) {
|
if (condition == null || condition.isEmpty()) {
|
||||||
String format = '\'' + row.getValues().stream().collect(Collectors.joining("', ")) + '\'';
|
String format = '\'' + String.join("', ", row.getValues()) + '\'';
|
||||||
statement = String.format(INSERT_VALUES, format);
|
statement = String.format(INSERT_VALUES, format);
|
||||||
} else {
|
} else {
|
||||||
String format = row.getKeysAndValues().entrySet().stream()
|
String format = row.getKeysAndValues().entrySet().stream()
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package com.Acrobot.Breeze.Utils;
|
package com.Acrobot.Breeze.Utils;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.DoubleChest;
|
import org.bukkit.block.DoubleChest;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.Directional;
|
||||||
|
import org.bukkit.block.data.type.Sign;
|
||||||
|
import org.bukkit.block.data.type.WallSign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.material.Attachable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -21,8 +22,12 @@ public class BlockUtil {
|
||||||
* @return Is this block a sign?
|
* @return Is this block a sign?
|
||||||
*/
|
*/
|
||||||
public static boolean isSign(Block block) {
|
public static boolean isSign(Block block) {
|
||||||
return block.getType() == Material.SIGN_POST
|
if (!isLoaded(block)) {
|
||||||
|| block.getType() == Material.WALL_SIGN;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockData data = block.getBlockData();
|
||||||
|
return data instanceof Sign || data instanceof WallSign;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +37,7 @@ public class BlockUtil {
|
||||||
* @return Is this block a chest?
|
* @return Is this block a chest?
|
||||||
*/
|
*/
|
||||||
public static boolean isChest(Block block) {
|
public static boolean isChest(Block block) {
|
||||||
return block.getState() instanceof Chest;
|
return BlockUtil.isLoaded(block) && block.getBlockData() instanceof org.bukkit.block.data.type.Chest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +47,7 @@ public class BlockUtil {
|
||||||
* @return Is this holder a chest?
|
* @return Is this holder a chest?
|
||||||
*/
|
*/
|
||||||
public static boolean isChest(InventoryHolder holder) {
|
public static boolean isChest(InventoryHolder holder) {
|
||||||
return holder instanceof Chest || holder instanceof DoubleChest;
|
return holder instanceof org.bukkit.block.Chest || holder instanceof DoubleChest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,8 +56,46 @@ public class BlockUtil {
|
||||||
* @param sign Sign which is attached
|
* @param sign Sign which is attached
|
||||||
* @return Block to which the sign is attached
|
* @return Block to which the sign is attached
|
||||||
*/
|
*/
|
||||||
public static Block getAttachedBlock(Sign sign) {
|
public static Block getAttachedBlock(org.bukkit.block.Sign sign) {
|
||||||
return sign.getBlock().getRelative(((Attachable) sign.getData()).getAttachedFace());
|
BlockFace direction;
|
||||||
|
BlockData blockData = sign.getBlockData();
|
||||||
|
if (blockData instanceof WallSign) {
|
||||||
|
direction = ((Directional) blockData).getFacing().getOppositeFace();
|
||||||
|
} else if (blockData instanceof Sign) {
|
||||||
|
direction = BlockFace.DOWN;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Cannot get direction of " + blockData.getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
return sign.getBlock().getRelative(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a blockface to a major direction
|
||||||
|
*
|
||||||
|
* @param face The face to get the major direction from
|
||||||
|
* @return The major direction. For middle directions it will return the next clockwise direction
|
||||||
|
*/
|
||||||
|
public static BlockFace getMajorDirection(BlockFace face) {
|
||||||
|
switch (face) {
|
||||||
|
case NORTH_WEST:
|
||||||
|
case NORTH_NORTH_WEST:
|
||||||
|
case NORTH_NORTH_EAST:
|
||||||
|
return BlockFace.NORTH;
|
||||||
|
case NORTH_EAST:
|
||||||
|
case EAST_NORTH_EAST:
|
||||||
|
case EAST_SOUTH_EAST:
|
||||||
|
return BlockFace.EAST;
|
||||||
|
case SOUTH_EAST:
|
||||||
|
case SOUTH_SOUTH_EAST:
|
||||||
|
case SOUTH_SOUTH_WEST:
|
||||||
|
return BlockFace.SOUTH;
|
||||||
|
case SOUTH_WEST:
|
||||||
|
case WEST_NORTH_WEST:
|
||||||
|
case WEST_SOUTH_WEST:
|
||||||
|
return BlockFace.WEST;
|
||||||
|
default:
|
||||||
|
return face;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,4 +111,14 @@ public class BlockUtil {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the chunk a block is in is loaded
|
||||||
|
*
|
||||||
|
* @param block The block to check
|
||||||
|
* @return Whether or not the chunk is loaded
|
||||||
|
*/
|
||||||
|
public static boolean isLoaded(Block block) {
|
||||||
|
return block.getWorld().isChunkLoaded(block.getX() >> 4, block.getZ() >> 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package com.Acrobot.Breeze.Utils.Encoding;
|
package com.Acrobot.Breeze.Utils.Encoding;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Encodes and decodes to and from Base64 notation.</p>
|
* <p>Encodes and decodes to and from Base64 notation.</p>
|
||||||
* <p>Homepage: <a href="http://iharder.net/base64">http://iharder.net/base64</a>.</p>
|
* <p>Homepage: <a href="http://iharder.net/base64">http://iharder.net/base64</a>.</p>
|
||||||
|
@ -34,7 +38,7 @@ package com.Acrobot.Breeze.Utils.Encoding;
|
||||||
* @version 2.3.7
|
* @version 2.3.7
|
||||||
*/
|
*/
|
||||||
public class Base64 {
|
public class Base64 {
|
||||||
|
|
||||||
/* ******** P U B L I C F I E L D S ******** */
|
/* ******** P U B L I C F I E L D S ******** */
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,8 +91,8 @@ public class Base64 {
|
||||||
* <a href="http://www.faqs.org/qa/rfcc-1940.html">http://www.faqs.org/qa/rfcc-1940.html</a>.
|
* <a href="http://www.faqs.org/qa/rfcc-1940.html">http://www.faqs.org/qa/rfcc-1940.html</a>.
|
||||||
*/
|
*/
|
||||||
public final static int ORDERED = 32;
|
public final static int ORDERED = 32;
|
||||||
|
|
||||||
|
|
||||||
/* ******** P R I V A T E F I E L D S ******** */
|
/* ******** P R I V A T E F I E L D S ******** */
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +123,7 @@ public class Base64 {
|
||||||
private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
|
private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
|
||||||
private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
|
private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
|
||||||
|
|
||||||
|
|
||||||
/* ******** S T A N D A R D B A S E 6 4 A L P H A B E T ******** */
|
/* ******** S T A N D A R D B A S E 6 4 A L P H A B E T ******** */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,7 +182,7 @@ public class Base64 {
|
||||||
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9 // Decimal 244 - 255
|
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9 // Decimal 244 - 255
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* ******** U R L S A F E B A S E 6 4 A L P H A B E T ******** */
|
/* ******** U R L S A F E B A S E 6 4 A L P H A B E T ******** */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -305,7 +309,7 @@ public class Base64 {
|
||||||
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9 // Decimal 244 - 255
|
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9 // Decimal 244 - 255
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* ******** D E T E R M I N E W H I C H A L H A B E T ******** */
|
/* ******** D E T E R M I N E W H I C H A L H A B E T ******** */
|
||||||
|
|
||||||
|
|
||||||
|
@ -349,10 +353,10 @@ public class Base64 {
|
||||||
* Defeats instantiation.
|
* Defeats instantiation.
|
||||||
*/
|
*/
|
||||||
private Base64() {}
|
private Base64() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ******** E N C O D I N G M E T H O D S ******** */
|
/* ******** E N C O D I N G M E T H O D S ******** */
|
||||||
|
|
||||||
|
|
||||||
|
@ -559,59 +563,31 @@ public class Base64 {
|
||||||
throw new NullPointerException("Cannot serialize a null object.");
|
throw new NullPointerException("Cannot serialize a null object.");
|
||||||
} // end if: null
|
} // end if: null
|
||||||
|
|
||||||
// Streams
|
// ObjectOutputStream -> (GZIP) -> Base64 -> ByteArrayOutputStream
|
||||||
java.io.ByteArrayOutputStream baos = null;
|
try (java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
|
||||||
java.io.OutputStream b64os = null;
|
java.io.OutputStream b64os = new Base64.OutputStream(baos, ENCODE | options)) {
|
||||||
java.util.zip.GZIPOutputStream gzos = null;
|
|
||||||
java.io.ObjectOutputStream oos = null;
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
// ObjectOutputStream -> (GZIP) -> Base64 -> ByteArrayOutputStream
|
|
||||||
baos = new java.io.ByteArrayOutputStream();
|
|
||||||
b64os = new Base64.OutputStream(baos, ENCODE | options);
|
|
||||||
if ((options & GZIP) != 0) {
|
if ((options & GZIP) != 0) {
|
||||||
// Gzip
|
// Gzip
|
||||||
gzos = new java.util.zip.GZIPOutputStream(b64os);
|
try (java.util.zip.GZIPOutputStream gzos = new java.util.zip.GZIPOutputStream(b64os);
|
||||||
oos = new java.io.ObjectOutputStream(gzos);
|
java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(gzos)){
|
||||||
|
oos.writeObject(serializableObject);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Not gzipped
|
// Not gzipped
|
||||||
oos = new java.io.ObjectOutputStream(b64os);
|
try (java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(b64os)) {
|
||||||
|
oos.writeObject(serializableObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
oos.writeObject(serializableObject);
|
// Return value according to relevant encoding.
|
||||||
|
try {
|
||||||
|
return baos.toString(PREFERRED_ENCODING);
|
||||||
|
} // end try
|
||||||
|
catch (java.io.UnsupportedEncodingException uue) {
|
||||||
|
// Fall back to some Java default
|
||||||
|
return baos.toString();
|
||||||
|
} // end catch
|
||||||
} // end try
|
} // end try
|
||||||
catch (java.io.IOException e) {
|
|
||||||
// Catch it and then throw it immediately so that
|
|
||||||
// the finally{} block is called for cleanup.
|
|
||||||
throw e;
|
|
||||||
} // end catch
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
oos.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
gzos.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
b64os.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
baos.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
|
|
||||||
// Return value according to relevant encoding.
|
|
||||||
try {
|
|
||||||
return new String(baos.toByteArray(), PREFERRED_ENCODING);
|
|
||||||
} // end try
|
|
||||||
catch (java.io.UnsupportedEncodingException uue) {
|
|
||||||
// Fall back to some Java default
|
|
||||||
return new String(baos.toByteArray());
|
|
||||||
} // end catch
|
|
||||||
|
|
||||||
} // end encode
|
} // end encode
|
||||||
|
|
||||||
|
@ -635,7 +611,6 @@ public class Base64 {
|
||||||
} catch (java.io.IOException ex) {
|
} catch (java.io.IOException ex) {
|
||||||
assert false : ex.getMessage();
|
assert false : ex.getMessage();
|
||||||
} // end catch
|
} // end catch
|
||||||
assert encoded != null;
|
|
||||||
return encoded;
|
return encoded;
|
||||||
} // end encodeBytes
|
} // end encodeBytes
|
||||||
|
|
||||||
|
@ -700,7 +675,6 @@ public class Base64 {
|
||||||
} catch (java.io.IOException ex) {
|
} catch (java.io.IOException ex) {
|
||||||
assert false : ex.getMessage();
|
assert false : ex.getMessage();
|
||||||
} // end catch
|
} // end catch
|
||||||
assert encoded != null;
|
|
||||||
return encoded;
|
return encoded;
|
||||||
} // end encodeBytes
|
} // end encodeBytes
|
||||||
|
|
||||||
|
@ -810,40 +784,13 @@ public class Base64 {
|
||||||
|
|
||||||
// Compress?
|
// Compress?
|
||||||
if ((options & GZIP) != 0) {
|
if ((options & GZIP) != 0) {
|
||||||
java.io.ByteArrayOutputStream baos = null;
|
try (java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
|
||||||
java.util.zip.GZIPOutputStream gzos = null;
|
Base64.OutputStream b64os = new Base64.OutputStream(baos, ENCODE | options);
|
||||||
Base64.OutputStream b64os = null;
|
java.util.zip.GZIPOutputStream gzos = new java.util.zip.GZIPOutputStream(b64os)) {
|
||||||
|
|
||||||
try {
|
|
||||||
// GZip -> Base64 -> ByteArray
|
|
||||||
baos = new java.io.ByteArrayOutputStream();
|
|
||||||
b64os = new Base64.OutputStream(baos, ENCODE | options);
|
|
||||||
gzos = new java.util.zip.GZIPOutputStream(b64os);
|
|
||||||
|
|
||||||
gzos.write(source, off, len);
|
gzos.write(source, off, len);
|
||||||
gzos.close();
|
return baos.toByteArray();
|
||||||
} // end try
|
} // end try
|
||||||
catch (java.io.IOException e) {
|
|
||||||
// Catch it and then throw it immediately so that
|
|
||||||
// the finally{} block is called for cleanup.
|
|
||||||
throw e;
|
|
||||||
} // end catch
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
gzos.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
b64os.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
baos.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
|
|
||||||
return baos.toByteArray();
|
|
||||||
} // end if: compress
|
} // end if: compress
|
||||||
|
|
||||||
// Else, don't compress. Better not to use streams at all then.
|
// Else, don't compress. Better not to use streams at all then.
|
||||||
|
@ -903,11 +850,11 @@ public class Base64 {
|
||||||
} // end else: don't compress
|
} // end else: don't compress
|
||||||
|
|
||||||
} // end encodeBytesToBytes
|
} // end encodeBytesToBytes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ******** D E C O D I N G M E T H O D S ******** */
|
/* ******** D E C O D I N G M E T H O D S ******** */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1162,20 +1109,16 @@ public class Base64 {
|
||||||
// Check to see if it's gzip-compressed
|
// Check to see if it's gzip-compressed
|
||||||
// GZIP Magic Two-Byte Number: 0x8b1f (35615)
|
// GZIP Magic Two-Byte Number: 0x8b1f (35615)
|
||||||
boolean dontGunzip = (options & DONT_GUNZIP) != 0;
|
boolean dontGunzip = (options & DONT_GUNZIP) != 0;
|
||||||
if ((bytes != null) && (bytes.length >= 4) && (!dontGunzip)) {
|
if (bytes.length >= 4 && !dontGunzip) {
|
||||||
|
|
||||||
int head = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
|
int head = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
|
||||||
if (java.util.zip.GZIPInputStream.GZIP_MAGIC == head) {
|
if (java.util.zip.GZIPInputStream.GZIP_MAGIC == head) {
|
||||||
java.io.ByteArrayInputStream bais = null;
|
|
||||||
java.util.zip.GZIPInputStream gzis = null;
|
|
||||||
java.io.ByteArrayOutputStream baos = null;
|
|
||||||
byte[] buffer = new byte[2048];
|
byte[] buffer = new byte[2048];
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
||||||
try {
|
try (java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
|
||||||
baos = new java.io.ByteArrayOutputStream();
|
java.io.ByteArrayInputStream bais = new java.io.ByteArrayInputStream(bytes);
|
||||||
bais = new java.io.ByteArrayInputStream(bytes);
|
java.util.zip.GZIPInputStream gzis = new java.util.zip.GZIPInputStream(bais)) {
|
||||||
gzis = new java.util.zip.GZIPInputStream(bais);
|
|
||||||
|
|
||||||
while ((length = gzis.read(buffer)) >= 0) {
|
while ((length = gzis.read(buffer)) >= 0) {
|
||||||
baos.write(buffer, 0, length);
|
baos.write(buffer, 0, length);
|
||||||
|
@ -1184,25 +1127,10 @@ public class Base64 {
|
||||||
// No error? Get new bytes.
|
// No error? Get new bytes.
|
||||||
bytes = baos.toByteArray();
|
bytes = baos.toByteArray();
|
||||||
|
|
||||||
} // end try
|
} catch (java.io.IOException e) {
|
||||||
catch (java.io.IOException e) {
|
Logger.getLogger("Base64").log(Level.SEVERE, "Unable to decode", e);
|
||||||
e.printStackTrace();
|
|
||||||
// Just return originally-decoded bytes
|
// Just return originally-decoded bytes
|
||||||
} // end catch
|
}
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
baos.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
gzis.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
bais.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
|
|
||||||
} // end if: gzipped
|
} // end if: gzipped
|
||||||
} // end if: bytes.length >= 2
|
} // end if: bytes.length >= 2
|
||||||
|
@ -1252,55 +1180,30 @@ public class Base64 {
|
||||||
// Decode and gunzip if necessary
|
// Decode and gunzip if necessary
|
||||||
byte[] objBytes = decode(encodedObject, options);
|
byte[] objBytes = decode(encodedObject, options);
|
||||||
|
|
||||||
java.io.ByteArrayInputStream bais = null;
|
try (java.io.ByteArrayInputStream bais = new java.io.ByteArrayInputStream(objBytes)) {
|
||||||
java.io.ObjectInputStream ois = null;
|
|
||||||
Object obj = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
bais = new java.io.ByteArrayInputStream(objBytes);
|
|
||||||
|
|
||||||
// If no custom class loader is provided, use Java's builtin OIS.
|
// If no custom class loader is provided, use Java's builtin OIS.
|
||||||
if (loader == null) {
|
if (loader == null) {
|
||||||
ois = new java.io.ObjectInputStream(bais);
|
try (java.io.ObjectInputStream ois = new java.io.ObjectInputStream(bais)) {
|
||||||
|
return ois.readObject();
|
||||||
|
} // end try
|
||||||
} // end if: no loader provided
|
} // end if: no loader provided
|
||||||
|
|
||||||
// Else make a customized object input stream that uses
|
// Else make a customized object input stream that uses
|
||||||
// the provided class loader.
|
// the provided class loader.
|
||||||
else {
|
else {
|
||||||
ois = new java.io.ObjectInputStream(bais) {
|
try (java.io.ObjectInputStream ois = new java.io.ObjectInputStream(bais) {
|
||||||
@Override
|
@Override
|
||||||
public Class<?> resolveClass(java.io.ObjectStreamClass streamClass)
|
public Class<?> resolveClass(java.io.ObjectStreamClass streamClass)
|
||||||
throws java.io.IOException, ClassNotFoundException {
|
throws java.io.IOException, ClassNotFoundException {
|
||||||
Class<?> c = Class.forName(streamClass.getName(), false, loader);
|
return Class.forName(streamClass.getName(), false, loader);
|
||||||
if (c == null) {
|
|
||||||
return super.resolveClass(streamClass);
|
|
||||||
} else {
|
|
||||||
return c; // Class loader knows of this class.
|
|
||||||
} // end else: not null
|
|
||||||
} // end resolveClass
|
} // end resolveClass
|
||||||
}; // end ois
|
}) { // end ois
|
||||||
|
return ois.readObject();
|
||||||
|
} // end try
|
||||||
} // end else: no custom class loader
|
} // end else: no custom class loader
|
||||||
|
|
||||||
obj = ois.readObject();
|
|
||||||
} // end try
|
} // end try
|
||||||
catch (java.io.IOException e) {
|
|
||||||
throw e; // Catch and throw in order to execute finally{}
|
|
||||||
} // end catch
|
|
||||||
catch (java.lang.ClassNotFoundException e) {
|
|
||||||
throw e; // Catch and throw in order to execute finally{}
|
|
||||||
} // end catch
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
bais.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
ois.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
} // end decodeObject
|
} // end decodeObject
|
||||||
|
|
||||||
|
|
||||||
|
@ -1325,17 +1228,10 @@ public class Base64 {
|
||||||
throw new NullPointerException("Data to encode was null.");
|
throw new NullPointerException("Data to encode was null.");
|
||||||
} // end iff
|
} // end iff
|
||||||
|
|
||||||
Base64.OutputStream bos = null;
|
try (OutputStream bos = new OutputStream(
|
||||||
try {
|
new java.io.FileOutputStream(filename), Base64.ENCODE)) {
|
||||||
bos = new Base64.OutputStream(
|
|
||||||
new java.io.FileOutputStream(filename), Base64.ENCODE);
|
|
||||||
bos.write(dataToEncode);
|
bos.write(dataToEncode);
|
||||||
} finally {
|
}
|
||||||
try {
|
|
||||||
bos.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
|
|
||||||
} // end encodeToFile
|
} // end encodeToFile
|
||||||
|
|
||||||
|
@ -1356,21 +1252,10 @@ public class Base64 {
|
||||||
public static void decodeToFile(String dataToDecode, String filename)
|
public static void decodeToFile(String dataToDecode, String filename)
|
||||||
throws java.io.IOException {
|
throws java.io.IOException {
|
||||||
|
|
||||||
Base64.OutputStream bos = null;
|
try (OutputStream bos = new OutputStream(
|
||||||
try {
|
new java.io.FileOutputStream(filename), Base64.DECODE)) {
|
||||||
bos = new Base64.OutputStream(
|
|
||||||
new java.io.FileOutputStream(filename), Base64.DECODE);
|
|
||||||
bos.write(dataToDecode.getBytes(PREFERRED_ENCODING));
|
bos.write(dataToDecode.getBytes(PREFERRED_ENCODING));
|
||||||
} // end try
|
}
|
||||||
catch (java.io.IOException e) {
|
|
||||||
throw e; // Catch and throw to execute finally{} block
|
|
||||||
} // end catch: java.io.IOException
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
bos.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
|
|
||||||
} // end decodeToFile
|
} // end decodeToFile
|
||||||
|
|
||||||
|
@ -1393,24 +1278,22 @@ public class Base64 {
|
||||||
throws java.io.IOException {
|
throws java.io.IOException {
|
||||||
|
|
||||||
byte[] decodedData = null;
|
byte[] decodedData = null;
|
||||||
Base64.InputStream bis = null;
|
// Set up some useful variables
|
||||||
try {
|
java.io.File file = new java.io.File(filename);
|
||||||
// Set up some useful variables
|
byte[] buffer = null;
|
||||||
java.io.File file = new java.io.File(filename);
|
int length = 0;
|
||||||
byte[] buffer = null;
|
int numBytes = 0;
|
||||||
int length = 0;
|
|
||||||
int numBytes = 0;
|
|
||||||
|
|
||||||
// Check for size of file
|
// Check for size of file
|
||||||
if (file.length() > Integer.MAX_VALUE) {
|
if (file.length() > Integer.MAX_VALUE) {
|
||||||
throw new java.io.IOException("File is too big for this convenience method (" + file.length() + " bytes).");
|
throw new java.io.IOException("File is too big for this convenience method (" + file.length() + " bytes).");
|
||||||
} // end if: file too big for int index
|
} // end if: file too big for int index
|
||||||
buffer = new byte[(int) file.length()];
|
buffer = new byte[(int) file.length()];
|
||||||
|
|
||||||
// Open a stream
|
// Open a stream
|
||||||
bis = new Base64.InputStream(
|
try (Base64.InputStream bis = new Base64.InputStream(
|
||||||
new java.io.BufferedInputStream(
|
new java.io.BufferedInputStream(
|
||||||
new java.io.FileInputStream(file)), Base64.DECODE);
|
new java.io.FileInputStream(file)), Base64.DECODE)) {
|
||||||
|
|
||||||
// Read until done
|
// Read until done
|
||||||
while ((numBytes = bis.read(buffer, length, 4096)) >= 0) {
|
while ((numBytes = bis.read(buffer, length, 4096)) >= 0) {
|
||||||
|
@ -1420,17 +1303,7 @@ public class Base64 {
|
||||||
// Save in a variable to return
|
// Save in a variable to return
|
||||||
decodedData = new byte[length];
|
decodedData = new byte[length];
|
||||||
System.arraycopy(buffer, 0, decodedData, 0, length);
|
System.arraycopy(buffer, 0, decodedData, 0, length);
|
||||||
|
} // end try
|
||||||
} // end try
|
|
||||||
catch (java.io.IOException e) {
|
|
||||||
throw e; // Catch and release to execute finally{}
|
|
||||||
} // end catch: java.io.IOException
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
bis.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
|
|
||||||
return decodedData;
|
return decodedData;
|
||||||
} // end decodeFromFile
|
} // end decodeFromFile
|
||||||
|
@ -1454,18 +1327,16 @@ public class Base64 {
|
||||||
throws java.io.IOException {
|
throws java.io.IOException {
|
||||||
|
|
||||||
String encodedData = null;
|
String encodedData = null;
|
||||||
Base64.InputStream bis = null;
|
// Set up some useful variables
|
||||||
try {
|
java.io.File file = new java.io.File(filename);
|
||||||
// Set up some useful variables
|
byte[] buffer = new byte[Math.max((int) (file.length() * 1.4 + 1), 40)]; // Need max() for math on small files (v2.2.1); Need +1 for a few corner cases (v2.3.5)
|
||||||
java.io.File file = new java.io.File(filename);
|
int length = 0;
|
||||||
byte[] buffer = new byte[Math.max((int) (file.length() * 1.4 + 1), 40)]; // Need max() for math on small files (v2.2.1); Need +1 for a few corner cases (v2.3.5)
|
int numBytes = 0;
|
||||||
int length = 0;
|
|
||||||
int numBytes = 0;
|
|
||||||
|
|
||||||
// Open a stream
|
// Open a stream
|
||||||
bis = new Base64.InputStream(
|
try (Base64.InputStream bis = new Base64.InputStream(
|
||||||
new java.io.BufferedInputStream(
|
new java.io.BufferedInputStream(
|
||||||
new java.io.FileInputStream(file)), Base64.ENCODE);
|
new java.io.FileInputStream(file)), Base64.ENCODE)) {
|
||||||
|
|
||||||
// Read until done
|
// Read until done
|
||||||
while ((numBytes = bis.read(buffer, length, 4096)) >= 0) {
|
while ((numBytes = bis.read(buffer, length, 4096)) >= 0) {
|
||||||
|
@ -1476,15 +1347,6 @@ public class Base64 {
|
||||||
encodedData = new String(buffer, 0, length, Base64.PREFERRED_ENCODING);
|
encodedData = new String(buffer, 0, length, Base64.PREFERRED_ENCODING);
|
||||||
|
|
||||||
} // end try
|
} // end try
|
||||||
catch (java.io.IOException e) {
|
|
||||||
throw e; // Catch and release to execute finally{}
|
|
||||||
} // end catch: java.io.IOException
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
bis.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
|
|
||||||
return encodedData;
|
return encodedData;
|
||||||
} // end encodeFromFile
|
} // end encodeFromFile
|
||||||
|
@ -1501,21 +1363,10 @@ public class Base64 {
|
||||||
throws java.io.IOException {
|
throws java.io.IOException {
|
||||||
|
|
||||||
String encoded = Base64.encodeFromFile(infile);
|
String encoded = Base64.encodeFromFile(infile);
|
||||||
java.io.OutputStream out = null;
|
try (java.io.OutputStream out = new java.io.BufferedOutputStream(
|
||||||
try {
|
new java.io.FileOutputStream(outfile))) {
|
||||||
out = new java.io.BufferedOutputStream(
|
out.write(encoded.getBytes(StandardCharsets.US_ASCII)); // Strict, 7-bit output.
|
||||||
new java.io.FileOutputStream(outfile));
|
}
|
||||||
out.write(encoded.getBytes("US-ASCII")); // Strict, 7-bit output.
|
|
||||||
} // end try
|
|
||||||
catch (java.io.IOException e) {
|
|
||||||
throw e; // Catch and release to execute finally{}
|
|
||||||
} // end catch
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
out.close();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
} // end encodeFileToFile
|
} // end encodeFileToFile
|
||||||
|
|
||||||
|
|
||||||
|
@ -1531,24 +1382,13 @@ public class Base64 {
|
||||||
throws java.io.IOException {
|
throws java.io.IOException {
|
||||||
|
|
||||||
byte[] decoded = Base64.decodeFromFile(infile);
|
byte[] decoded = Base64.decodeFromFile(infile);
|
||||||
java.io.OutputStream out = null;
|
try (java.io.OutputStream out = new java.io.BufferedOutputStream(
|
||||||
try {
|
new java.io.FileOutputStream(outfile))) {
|
||||||
out = new java.io.BufferedOutputStream(
|
|
||||||
new java.io.FileOutputStream(outfile));
|
|
||||||
out.write(decoded);
|
out.write(decoded);
|
||||||
} // end try
|
}
|
||||||
catch (java.io.IOException e) {
|
|
||||||
throw e; // Catch and release to execute finally{}
|
|
||||||
} // end catch
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
out.close();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
} // end decodeFileToFile
|
} // end decodeFileToFile
|
||||||
|
|
||||||
|
|
||||||
/* ******** I N N E R C L A S S I N P U T S T R E A M ******** */
|
/* ******** I N N E R C L A S S I N P U T S T R E A M ******** */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1754,12 +1594,12 @@ public class Base64 {
|
||||||
} // end read
|
} // end read
|
||||||
|
|
||||||
} // end inner class InputStream
|
} // end inner class InputStream
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ******** I N N E R C L A S S O U T P U T S T R E A M ******** */
|
/* ******** I N N E R C L A S S O U T P U T S T R E A M ******** */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.Acrobot.Breeze.Utils;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.DoubleChest;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
public class ImplementationAdapter {
|
||||||
|
|
||||||
|
private static BiFunction<Inventory, Boolean, InventoryHolder> HOLDER_PROVIDER;
|
||||||
|
private static BiFunction<DoubleChest, Boolean, InventoryHolder> LEFT_HOLDER_PROVIDER;
|
||||||
|
private static BiFunction<DoubleChest, Boolean, InventoryHolder> RIGHT_HOLDER_PROVIDER;
|
||||||
|
private static BiFunction<Block, Boolean, BlockState> STATE_PROVIDER;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Inventory.class.getMethod("getHolder", boolean.class);
|
||||||
|
Class c = Class.forName("com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestHolder");
|
||||||
|
HOLDER_PROVIDER = (BiFunction<Inventory, Boolean, InventoryHolder>) c.getDeclaredField("PROVIDER").get(null);
|
||||||
|
LEFT_HOLDER_PROVIDER = (BiFunction<DoubleChest, Boolean, InventoryHolder>) c.getDeclaredField("LEFT_PROVIDER").get(null);
|
||||||
|
RIGHT_HOLDER_PROVIDER = (BiFunction<DoubleChest, Boolean, InventoryHolder>) c.getDeclaredField("RIGHT_PROVIDER").get(null);
|
||||||
|
} catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||||
|
HOLDER_PROVIDER = (inventory, useSnapshot) -> inventory.getHolder();
|
||||||
|
LEFT_HOLDER_PROVIDER = (doubleChest, useSnapshot) -> doubleChest.getLeftSide();
|
||||||
|
RIGHT_HOLDER_PROVIDER = (doubleChest, useSnapshot) -> doubleChest.getRightSide();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Block.class.getMethod("getState", boolean.class);
|
||||||
|
Class c = Class.forName("com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestState");
|
||||||
|
STATE_PROVIDER = (BiFunction<Block, Boolean, BlockState>) c.getDeclaredField("PROVIDER").get(null);
|
||||||
|
} catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||||
|
STATE_PROVIDER = (block, useSnapshot) -> block.getState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the inventory's holder.
|
||||||
|
* @param inventory The inventory
|
||||||
|
* @param useSnapshot Whether or not the holder should be a snapshot (if possible)
|
||||||
|
* @return The inventory's holder
|
||||||
|
*/
|
||||||
|
public static InventoryHolder getHolder(Inventory inventory, boolean useSnapshot) {
|
||||||
|
return HOLDER_PROVIDER.apply(inventory, useSnapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the a DoubleChest's left side
|
||||||
|
* @param doubleChest The DoubleChest
|
||||||
|
* @param useSnapshot Whether or not the holder should be a snapshot (if possible)
|
||||||
|
* @return The left side's holder
|
||||||
|
*/
|
||||||
|
public static InventoryHolder getLeftSide(DoubleChest doubleChest, boolean useSnapshot) {
|
||||||
|
return LEFT_HOLDER_PROVIDER.apply(doubleChest, useSnapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the a DoubleChest's right side
|
||||||
|
* @param doubleChest The DoubleChest
|
||||||
|
* @param useSnapshot Whether or not the holder should be a snapshot (if possible)
|
||||||
|
* @return The left right's holder
|
||||||
|
*/
|
||||||
|
public static InventoryHolder getRightSide(DoubleChest doubleChest, boolean useSnapshot) {
|
||||||
|
return RIGHT_HOLDER_PROVIDER.apply(doubleChest, useSnapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a block state
|
||||||
|
* @param block The block to get the state from
|
||||||
|
* @param useSnapshot Whether or not the state should be a snapshot (if possible)
|
||||||
|
* @return The block's state
|
||||||
|
*/
|
||||||
|
public static BlockState getState(Block block, boolean useSnapshot) {
|
||||||
|
return STATE_PROVIDER.apply(block, useSnapshot);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.Acrobot.Breeze.Utils.ImplementationFeatures;
|
||||||
|
|
||||||
|
import org.bukkit.block.DoubleChest;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
public class PaperLatestHolder {
|
||||||
|
|
||||||
|
public static final BiFunction<Inventory, Boolean, InventoryHolder> PROVIDER = Inventory::getHolder;
|
||||||
|
|
||||||
|
public static final BiFunction<DoubleChest, Boolean, InventoryHolder> LEFT_PROVIDER = DoubleChest::getLeftSide;
|
||||||
|
|
||||||
|
public static final BiFunction<DoubleChest, Boolean, InventoryHolder> RIGHT_PROVIDER = DoubleChest::getRightSide;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.Acrobot.Breeze.Utils.ImplementationFeatures;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
public class PaperLatestState {
|
||||||
|
|
||||||
|
public static final BiFunction<Block, Boolean, BlockState> PROVIDER = Block::getState;
|
||||||
|
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ import org.bukkit.inventory.ItemStack;
|
||||||
*/
|
*/
|
||||||
public class InventoryUtil {
|
public class InventoryUtil {
|
||||||
private static Boolean legacyContents = null;
|
private static Boolean legacyContents = null;
|
||||||
|
|
||||||
private static ItemStack[] getStorageContents(Inventory inventory) {
|
private static ItemStack[] getStorageContents(Inventory inventory) {
|
||||||
if (legacyContents == null) {
|
if (legacyContents == null) {
|
||||||
try {
|
try {
|
||||||
|
@ -74,7 +74,7 @@ public class InventoryUtil {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count amount of empty slots in an inventory
|
* Count amount of empty slots in an inventory
|
||||||
*
|
*
|
||||||
|
@ -88,7 +88,7 @@ public class InventoryUtil {
|
||||||
emptyAmount++;
|
emptyAmount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return emptyAmount;
|
return emptyAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public class InventoryUtil {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if items fit in the inventory
|
* Checks if items fit in the inventory
|
||||||
*
|
*
|
||||||
|
@ -124,7 +124,7 @@ public class InventoryUtil {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ public class InventoryUtil {
|
||||||
public static boolean fits(ItemStack item, Inventory inventory) {
|
public static boolean fits(ItemStack item, Inventory inventory) {
|
||||||
int left = item.getAmount();
|
int left = item.getAmount();
|
||||||
|
|
||||||
if (inventory.getMaxStackSize() == Integer.MAX_VALUE) {
|
if (inventory.getSize() == Integer.MAX_VALUE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +162,62 @@ public class InventoryUtil {
|
||||||
return left <= 0;
|
return left <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transfers an item from one inventory to another one
|
||||||
|
*
|
||||||
|
* @param item Item to transfer
|
||||||
|
* @param sourceInventory Inventory to transfer the item from
|
||||||
|
* @param targetInventory Inventory to transfer the item to
|
||||||
|
* @return Number of leftover items
|
||||||
|
*/
|
||||||
|
public static int transfer(ItemStack item, Inventory sourceInventory, Inventory targetInventory) {
|
||||||
|
return transfer(item, sourceInventory, targetInventory, item.getMaxStackSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transfers an item from one inventory to another one
|
||||||
|
*
|
||||||
|
* @param item Item to transfer
|
||||||
|
* @param sourceInventory Inventory to transfer the item from
|
||||||
|
* @param targetInventory Inventory to transfer the item to
|
||||||
|
* @param maxStackSize Maximum item's stack size
|
||||||
|
* @return Number of leftover items
|
||||||
|
*/
|
||||||
|
public static int transfer(ItemStack item, Inventory sourceInventory, Inventory targetInventory, int maxStackSize) {
|
||||||
|
if (item.getAmount() < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int amount = item.getAmount();
|
||||||
|
for (ItemStack currentItem : sourceInventory) {
|
||||||
|
if (MaterialUtil.equals(currentItem, item)) {
|
||||||
|
ItemStack clone = currentItem.clone();
|
||||||
|
if (currentItem.getAmount() >= amount) {
|
||||||
|
clone.setAmount(amount);
|
||||||
|
amount = 0;
|
||||||
|
} else {
|
||||||
|
clone.setAmount(currentItem.getAmount());
|
||||||
|
amount -= clone.getAmount();
|
||||||
|
}
|
||||||
|
int leftOver = add(clone, targetInventory, maxStackSize);
|
||||||
|
if (leftOver > 0) {
|
||||||
|
currentItem.setAmount(currentItem.getAmount() - clone.getAmount() + leftOver);
|
||||||
|
if (amount > 0) {
|
||||||
|
amount += leftOver;
|
||||||
|
} else {
|
||||||
|
return leftOver;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentItem.setAmount(currentItem.getAmount() - clone.getAmount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (amount <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an item to the inventory with given maximum stack size
|
* Adds an item to the inventory with given maximum stack size
|
||||||
*
|
*
|
||||||
|
@ -206,8 +262,7 @@ public class InventoryUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't use the armor slots or extra slots
|
// Don't use the armor slots or extra slots
|
||||||
private static int effectiveSize(Inventory inventory)
|
private static int effectiveSize(Inventory inventory) {
|
||||||
{
|
|
||||||
return getStorageContents(inventory).length;
|
return getStorageContents(inventory).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,6 +318,7 @@ public class InventoryUtil {
|
||||||
int neededToRemove = Math.min(currentItem.getAmount(), amountLeft);
|
int neededToRemove = Math.min(currentItem.getAmount(), amountLeft);
|
||||||
|
|
||||||
currentItem.setAmount(currentItem.getAmount() - neededToRemove);
|
currentItem.setAmount(currentItem.getAmount() - neededToRemove);
|
||||||
|
inventory.setItem(currentSlot, currentItem);
|
||||||
|
|
||||||
amountLeft -= neededToRemove;
|
amountLeft -= neededToRemove;
|
||||||
}
|
}
|
||||||
|
@ -295,7 +351,7 @@ public class InventoryUtil {
|
||||||
itemList.add(item.clone());
|
itemList.add(item.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
return itemList.toArray(new ItemStack[itemList.size()]);
|
return itemList.toArray(new ItemStack[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,6 +388,7 @@ public class InventoryUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the max size an item stack is allowed to stack to while respecting the STACK_TO_64 config property
|
* Get the max size an item stack is allowed to stack to while respecting the STACK_TO_64 config property
|
||||||
|
*
|
||||||
* @param item The item to get the max stacksize of
|
* @param item The item to get the max stacksize of
|
||||||
* @return The max stacksize of the item stack's type or 64 if STACK_TO_64 is enabled
|
* @return The max stacksize of the item stack's type or 64 if STACK_TO_64 is enabled
|
||||||
*/
|
*/
|
||||||
|
@ -341,28 +398,32 @@ public class InventoryUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an array of different item stacks that are properly stacked to their max stack size
|
* Get an array of different item stacks that are properly stacked to their max stack size
|
||||||
* @param item The item to stack
|
*
|
||||||
|
* @param items The items to stack
|
||||||
* @return An array of item stacks which's amount is a maximum of the allowed stack size
|
* @return An array of item stacks which's amount is a maximum of the allowed stack size
|
||||||
*/
|
*/
|
||||||
public static ItemStack[] getItemsStacked(ItemStack item) {
|
public static ItemStack[] getItemsStacked(ItemStack... items) {
|
||||||
int maxStackSize = getMaxStackSize(item);
|
List<ItemStack> stackedItems = new LinkedList<>();
|
||||||
if (maxStackSize == 0) {
|
for (ItemStack item : items) {
|
||||||
return new ItemStack[]{};
|
int maxStackSize = getMaxStackSize(item);
|
||||||
|
if (maxStackSize == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (item.getAmount() <= maxStackSize) {
|
||||||
|
stackedItems.add(item.clone());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < Math.floor((double) item.getAmount() / maxStackSize); i++) {
|
||||||
|
ItemStack itemClone = item.clone();
|
||||||
|
itemClone.setAmount(maxStackSize);
|
||||||
|
stackedItems.add(itemClone);
|
||||||
|
}
|
||||||
|
if (item.getAmount() % maxStackSize != 0) {
|
||||||
|
ItemStack rest = item.clone();
|
||||||
|
rest.setAmount(item.getAmount() % maxStackSize);
|
||||||
|
stackedItems.add(rest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (item.getAmount() <= maxStackSize) {
|
return stackedItems.toArray(new ItemStack[0]);
|
||||||
return new ItemStack[]{item};
|
|
||||||
}
|
|
||||||
List<ItemStack> items = new LinkedList<>();
|
|
||||||
for (int i = 0; i < Math.floor(item.getAmount() / maxStackSize); i++) {
|
|
||||||
ItemStack itemClone = item.clone();
|
|
||||||
itemClone.setAmount(maxStackSize);
|
|
||||||
items.add(itemClone);
|
|
||||||
}
|
|
||||||
if (item.getAmount() % maxStackSize != 0) {
|
|
||||||
ItemStack rest = item.clone();
|
|
||||||
rest.setAmount(item.getAmount() % maxStackSize);
|
|
||||||
items.add(rest);
|
|
||||||
}
|
|
||||||
return items.toArray(new ItemStack[items.size()]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,40 @@
|
||||||
package com.Acrobot.Breeze.Utils;
|
package com.Acrobot.Breeze.Utils;
|
||||||
|
|
||||||
|
import com.Acrobot.Breeze.Collection.SimpleCache;
|
||||||
import com.Acrobot.ChestShop.ChestShop;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||||
|
import com.Acrobot.ChestShop.Events.MaterialParseEvent;
|
||||||
|
import com.Acrobot.ChestShop.Utils.ItemUtil;
|
||||||
import de.themoep.ShowItem.api.ShowItem;
|
import de.themoep.ShowItem.api.ShowItem;
|
||||||
import info.somethingodd.OddItem.OddItem;
|
import de.themoep.minedown.adventure.Replacer;
|
||||||
import org.bukkit.CoalType;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.DyeColor;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.TreeSpecies;
|
import org.bukkit.configuration.file.YamlConstructor;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.configuration.file.YamlRepresenter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.material.*;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.json.simple.JSONObject;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
import org.yaml.snakeyaml.nodes.Tag;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
import static com.Acrobot.Breeze.Utils.StringUtil.getMinecraftCharWidth;
|
||||||
|
import static com.Acrobot.Breeze.Utils.StringUtil.getMinecraftStringWidth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -37,8 +45,40 @@ public class MaterialUtil {
|
||||||
|
|
||||||
public static final boolean LONG_NAME = true;
|
public static final boolean LONG_NAME = true;
|
||||||
public static final boolean SHORT_NAME = false;
|
public static final boolean SHORT_NAME = false;
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link MaterialUtil#MAXIMUM_SIGN_WIDTH}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final short MAXIMUM_SIGN_LETTERS = 15;
|
||||||
|
// 15 dashes fit on one sign line with the default resource pack:
|
||||||
|
public static final int MAXIMUM_SIGN_WIDTH = (short) getMinecraftStringWidth("---------------");
|
||||||
|
|
||||||
private static final Map<String, Material> MATERIAL_CACHE = new HashMap<String, Material>();
|
private static final Map<String, String> ABBREVIATIONS = StringUtil.map(
|
||||||
|
"Egg", "Eg",
|
||||||
|
"Spawn", "Spaw",
|
||||||
|
"Pottery", "Pot",
|
||||||
|
"Heartbreak", "Heartbr",
|
||||||
|
"Sherd", "Sher"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final Map<String, String> UNIDIRECTIONAL_ABBREVIATIONS = StringUtil.map(
|
||||||
|
"Endermite", "Endmite",
|
||||||
|
"Endmite", "Endmit",
|
||||||
|
"Wayfinder", "Wayfndr",
|
||||||
|
"Wayfndr", "Wf",
|
||||||
|
"Heartbr", "Hrtbr",
|
||||||
|
"Hrtbr", "Hrtb"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final SimpleCache<String, Material> MATERIAL_CACHE = new SimpleCache<>(Properties.CACHE_SIZE);
|
||||||
|
|
||||||
|
private static final Yaml YAML = new Yaml(new YamlBukkitConstructor(), new YamlRepresenter(), new DumperOptions());
|
||||||
|
|
||||||
|
private static class YamlBukkitConstructor extends YamlConstructor {
|
||||||
|
public YamlBukkitConstructor() {
|
||||||
|
this.yamlConstructors.put(new Tag(Tag.PREFIX + "org.bukkit.inventory.ItemStack"), yamlConstructors.get(Tag.MAP));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the itemStack is empty or null
|
* Checks if the itemStack is empty or null
|
||||||
|
@ -65,13 +105,54 @@ public class MaterialUtil {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special check for books as their pages might change when serialising (See SPIGOT-3206)
|
// Additional checks as serialisation and de-serialisation might lead to different item meta
|
||||||
return one.getType() == two.getType()
|
// This would only be done if the items share the same item meta type so it shouldn't be too inefficient
|
||||||
&& one.getDurability() == two.getDurability()
|
// Special check for books as their pages might change when serialising (See SPIGOT-3206 and ChestShop#250)
|
||||||
&& one.getData().equals(two.getData())
|
// Special check for explorer maps/every item with a localised name (See SPIGOT-4672)
|
||||||
&& one.hasItemMeta() && two.hasItemMeta()
|
// Special check for legacy spawn eggs (See ChestShop#264)
|
||||||
&& one.getItemMeta() instanceof BookMeta && two.getItemMeta() instanceof BookMeta
|
if (one.getType() != two.getType()
|
||||||
&& one.getItemMeta().serialize().equals(two.getItemMeta().serialize());
|
|| one.getDurability() != two.getDurability()
|
||||||
|
|| (one.hasItemMeta() && two.hasItemMeta() && one.getItemMeta().getClass() != two.getItemMeta().getClass())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!one.hasItemMeta() && !two.hasItemMeta()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ItemMeta oneMeta = one.getItemMeta();
|
||||||
|
ItemMeta twoMeta = two.getItemMeta();
|
||||||
|
// return true if both are null or same, false if only one is null
|
||||||
|
if (oneMeta == twoMeta || oneMeta == null || twoMeta == null) {
|
||||||
|
return oneMeta == twoMeta;
|
||||||
|
}
|
||||||
|
Map<String, Object> oneSerMeta = oneMeta.serialize();
|
||||||
|
Map<String, Object> twoSerMeta = twoMeta.serialize();
|
||||||
|
if (oneSerMeta.equals(twoSerMeta)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to use same parsing as the YAML dumper in the ItemDatabase when generating the code as the last resort
|
||||||
|
ItemStack oneDumped = YAML.loadAs(YAML.dump(one), ItemStack.class);
|
||||||
|
if (oneDumped.isSimilar(two)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemMeta oneDumpedMeta = oneDumped.getItemMeta();
|
||||||
|
if (oneDumpedMeta != null && oneDumpedMeta.serialize().equals(twoSerMeta)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack twoDumped = YAML.loadAs(YAML.dump(two), ItemStack.class);
|
||||||
|
if (oneDumped.isSimilar(twoDumped)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemMeta twoDumpedMeta = twoDumped.getItemMeta();
|
||||||
|
if (oneDumpedMeta != null && twoDumpedMeta != null && oneDumpedMeta.serialize().equals(twoDumpedMeta.serialize())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return true if both are null or same, false otherwise
|
||||||
|
return oneDumpedMeta == twoDumpedMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,43 +162,65 @@ public class MaterialUtil {
|
||||||
* @return Material found
|
* @return Material found
|
||||||
*/
|
*/
|
||||||
public static Material getMaterial(String name) {
|
public static Material getMaterial(String name) {
|
||||||
String formatted = name.replaceAll(" |_", "").toUpperCase();
|
String replacedName = name;
|
||||||
|
// revert unidirectional abbreviations
|
||||||
if (MATERIAL_CACHE.containsKey(formatted)) {
|
List<Map.Entry<String, String>> abbreviations = new ArrayList<>(UNIDIRECTIONAL_ABBREVIATIONS.entrySet());
|
||||||
return MATERIAL_CACHE.get(formatted);
|
for (int i = abbreviations.size() - 1; i >= 0; i--) {
|
||||||
|
Map.Entry<String, String> entry = abbreviations.get(i);
|
||||||
|
replacedName = replacedName.replaceAll(entry.getValue() + "(_|$)?", entry.getKey() + "$1");
|
||||||
}
|
}
|
||||||
|
|
||||||
Material material = Material.matchMaterial(name);
|
String formatted = name.replaceAll("(?<!^)(?>\\s?)([A-Z1-9])", "_$1").replace(' ', '_').toUpperCase(Locale.ROOT);
|
||||||
|
|
||||||
|
Material material = MATERIAL_CACHE.get(formatted);
|
||||||
|
if (material != null) {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
material = Material.matchMaterial(name);
|
||||||
|
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
MATERIAL_CACHE.put(formatted, material);
|
MATERIAL_CACHE.put(formatted, material);
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
short length = Short.MAX_VALUE;
|
material = new EnumParser<Material>().parse(replacedName, Material.values());
|
||||||
|
if (material != null) {
|
||||||
for (Material currentMaterial : Material.values()) {
|
MATERIAL_CACHE.put(formatted, material);
|
||||||
String matName = currentMaterial.name();
|
|
||||||
|
|
||||||
if (matName.length() < length && matName.replace("_", "").startsWith(formatted)) {
|
|
||||||
length = (short) matName.length();
|
|
||||||
material = currentMaterial;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MATERIAL_CACHE.put(formatted, material);
|
|
||||||
|
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list with item information
|
||||||
|
*
|
||||||
|
* @param items The items to get the information from
|
||||||
|
* @return The list, including the amount and names of the items
|
||||||
|
* @deprecated Use {@link ItemUtil#getItemList(ItemStack[])} instead!
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static String getItemList(ItemStack[] items) {
|
||||||
|
ItemStack[] mergedItems = InventoryUtil.mergeSimilarStacks(items);
|
||||||
|
|
||||||
|
List<String> itemText = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ItemStack item : mergedItems) {
|
||||||
|
itemText.add(item.getAmount() + " " + getName(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.join(", ", itemText);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns item's name
|
* Returns item's name
|
||||||
|
* Use {@link ItemUtil#getName(ItemStack, int)} if you want to get name aliases too!
|
||||||
*
|
*
|
||||||
* @param itemStack ItemStack to name
|
* @param itemStack ItemStack to name
|
||||||
* @return ItemStack's name
|
* @return ItemStack's name
|
||||||
*/
|
*/
|
||||||
public static String getName(ItemStack itemStack) {
|
public static String getName(ItemStack itemStack) {
|
||||||
return getName(itemStack, LONG_NAME);
|
return getName(itemStack, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,41 +229,149 @@ public class MaterialUtil {
|
||||||
* @param itemStack ItemStack to name
|
* @param itemStack ItemStack to name
|
||||||
* @param showDataValue Should we also show the data value?
|
* @param showDataValue Should we also show the data value?
|
||||||
* @return ItemStack's name
|
* @return ItemStack's name
|
||||||
|
* @deprecated Use {@link #getName(ItemStack, int)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static String getName(ItemStack itemStack, boolean showDataValue) {
|
public static String getName(ItemStack itemStack, boolean showDataValue) {
|
||||||
String dataName = DataValue.name(itemStack);
|
return getName(itemStack, 0);
|
||||||
|
|
||||||
if (dataName != null && showDataValue) {
|
|
||||||
return StringUtil.capitalizeFirstLetter(dataName + '_' + itemStack.getType(), '_');
|
|
||||||
} else {
|
|
||||||
return StringUtil.capitalizeFirstLetter(itemStack.getType().toString(), '_');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns item's name, just like on the sign
|
* Returns item's name, just like on the sign
|
||||||
|
* Use {@link ItemUtil#getSignName(ItemStack)} if you want to get name aliases too!
|
||||||
*
|
*
|
||||||
* @param itemStack ItemStack to name
|
* @param itemStack ItemStack to name
|
||||||
* @return ItemStack's name
|
* @return ItemStack's name
|
||||||
*/
|
*/
|
||||||
public static String getSignName(ItemStack itemStack) {
|
public static String getSignName(ItemStack itemStack) {
|
||||||
StringBuilder name = new StringBuilder(15);
|
return getName(itemStack, MAXIMUM_SIGN_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
String alias = Odd.getAlias(itemStack);
|
/**
|
||||||
String itemName = alias != null ? alias : itemStack.getType().name();
|
* Returns item's name, with a maximum width.
|
||||||
itemName = StringUtil.capitalizeFirstLetter(itemName, '_');
|
* Use {@link ItemUtil#getName(ItemStack, int)} if you want to get name aliases too!
|
||||||
|
*
|
||||||
name.append(itemName);
|
* @param itemStack ItemStack to name
|
||||||
|
* @param maxWidth The max width that the name should have; 0 or below if it should be unlimited
|
||||||
|
* @return ItemStack's name
|
||||||
|
*/
|
||||||
|
public static String getName(ItemStack itemStack, int maxWidth) {
|
||||||
|
String itemName = itemStack.getType().toString();
|
||||||
|
|
||||||
|
String durability = "";
|
||||||
if (itemStack.getDurability() != 0) {
|
if (itemStack.getDurability() != 0) {
|
||||||
name.append(':').append(itemStack.getDurability());
|
durability = ":" + itemStack.getDurability();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String metaData = "";
|
||||||
if (itemStack.hasItemMeta()) {
|
if (itemStack.hasItemMeta()) {
|
||||||
name.append('#').append(Metadata.getItemCode(itemStack));
|
metaData = "#" + Metadata.getItemCode(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
return name.toString();
|
String code = StringUtil.capitalizeFirstLetter(itemName, '_');
|
||||||
|
if (maxWidth > 0) {
|
||||||
|
int codeWidth = getMinecraftStringWidth(code + durability + metaData);
|
||||||
|
if (codeWidth > maxWidth) {
|
||||||
|
int exceeding = codeWidth - maxWidth;
|
||||||
|
code = getShortenedName(code, getMinecraftStringWidth(code) - exceeding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return code + durability + metaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an item name shortened to a max length that is still reversable by {@link #getMaterial(String)}
|
||||||
|
*
|
||||||
|
* @param itemName The name of the item
|
||||||
|
* @param maxWidth The max width
|
||||||
|
* @return The name shortened to the max length
|
||||||
|
*/
|
||||||
|
public static String getShortenedName(String itemName, int maxWidth) {
|
||||||
|
// Restore spaces in string that might be already be shortened
|
||||||
|
String name = itemName.replaceAll("([a-z])([A-Z1-9])", "$1 $2");
|
||||||
|
name = StringUtil.capitalizeFirstLetter(name.replace('_', ' '), ' ');
|
||||||
|
int width = getMinecraftStringWidth(name);
|
||||||
|
if (width <= maxWidth) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
String[] itemParts = name.split("[ \\-]");
|
||||||
|
String noSpaceName = String.join("", itemParts);
|
||||||
|
width = getMinecraftStringWidth(noSpaceName);
|
||||||
|
if (width <= maxWidth) {
|
||||||
|
return noSpaceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abbreviate some terms manually
|
||||||
|
for (Map.Entry<String, String> entry : ABBREVIATIONS.entrySet()) {
|
||||||
|
name = name.replaceAll(entry.getKey() + "( |$)", entry.getValue() + "$1");
|
||||||
|
itemParts = name.split("[ \\-]");
|
||||||
|
noSpaceName = String.join("", itemParts);
|
||||||
|
width = getMinecraftStringWidth(noSpaceName);
|
||||||
|
if (width <= maxWidth) {
|
||||||
|
return noSpaceName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply unidirectional abbreviations if it still doesn't work
|
||||||
|
for (Map.Entry<String, String> entry : UNIDIRECTIONAL_ABBREVIATIONS.entrySet()) {
|
||||||
|
name = name.replaceAll(entry.getKey() + "( |$)", entry.getValue() + "$1");
|
||||||
|
itemParts = name.split("[ \\-]");
|
||||||
|
noSpaceName = String.join("", itemParts);
|
||||||
|
width = getMinecraftStringWidth(noSpaceName);
|
||||||
|
if (width <= maxWidth) {
|
||||||
|
return noSpaceName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int exceeding = width - maxWidth;
|
||||||
|
int shortestIndex = 0;
|
||||||
|
int longestIndex = 0;
|
||||||
|
for (int i = 0; i < itemParts.length; i++) {
|
||||||
|
if (getMinecraftStringWidth(itemParts[longestIndex]) < getMinecraftStringWidth(itemParts[i])) {
|
||||||
|
longestIndex = i;
|
||||||
|
}
|
||||||
|
if (getMinecraftStringWidth(itemParts[shortestIndex]) > getMinecraftStringWidth(itemParts[i])) {
|
||||||
|
shortestIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int shortestWidth = getMinecraftStringWidth(itemParts[shortestIndex]);
|
||||||
|
int longestWidth = getMinecraftStringWidth(itemParts[longestIndex]);
|
||||||
|
int remove = longestWidth - shortestWidth;
|
||||||
|
while (remove > 0 && exceeding > 0) {
|
||||||
|
int endWidth = getMinecraftCharWidth(itemParts[longestIndex].charAt(itemParts[longestIndex].length() - 1));
|
||||||
|
itemParts[longestIndex] = itemParts[longestIndex].substring(0, itemParts[longestIndex].length() - 1);
|
||||||
|
remove -= endWidth;
|
||||||
|
exceeding -= endWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = itemParts.length - 1; i >= 0 && exceeding > 0; i--) {
|
||||||
|
int partWidth = getMinecraftStringWidth(itemParts[i]);
|
||||||
|
|
||||||
|
if (partWidth > shortestWidth) {
|
||||||
|
remove = partWidth - shortestWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remove > exceeding) {
|
||||||
|
remove = exceeding;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (remove > 0) {
|
||||||
|
int endWidth = getMinecraftCharWidth(itemParts[i].charAt(itemParts[i].length() - 1));
|
||||||
|
itemParts[i] = itemParts[i].substring(0, itemParts[i].length() - 1);
|
||||||
|
remove -= endWidth;
|
||||||
|
exceeding -= endWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (exceeding > 0) {
|
||||||
|
for (int i = itemParts.length - 1; i >= 0 && exceeding > 0; i--) {
|
||||||
|
int endWidth = getMinecraftCharWidth(itemParts[i].charAt(itemParts[i].length() - 1));
|
||||||
|
itemParts[i] = itemParts[i].substring(0, itemParts[i].length() - 1);
|
||||||
|
exceeding -= endWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String.join("", itemParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,48 +381,27 @@ public class MaterialUtil {
|
||||||
* @return ItemStack
|
* @return ItemStack
|
||||||
*/
|
*/
|
||||||
public static ItemStack getItem(String itemName) {
|
public static ItemStack getItem(String itemName) {
|
||||||
ItemStack itemStack = Odd.getFromString(itemName);
|
|
||||||
|
|
||||||
if (itemStack != null) {
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] split = itemName.split("[:\\-#]");
|
String[] split = itemName.split("[:\\-#]");
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
split[i] = split[i].trim();
|
split[i] = split[i].trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
Material material = getMaterial(split[0]);
|
|
||||||
short durability = getDurability(itemName);
|
short durability = getDurability(itemName);
|
||||||
|
MaterialParseEvent parseEvent = new MaterialParseEvent(split[0], durability);
|
||||||
|
Bukkit.getPluginManager().callEvent(parseEvent);
|
||||||
|
Material material = parseEvent.getMaterial();
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
if (!split[0].contains(" ")) {
|
return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = split[0].indexOf(' '); index >= 0; index = split[0].indexOf(' ', index + 1)) {
|
|
||||||
material = getMaterial(split[0].substring(index));
|
|
||||||
|
|
||||||
if (material != null) {
|
|
||||||
if (durability == 0) {
|
|
||||||
durability = DataValue.get(split[0].substring(0, index), material);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (material == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemStack = new ItemStack(material);
|
ItemStack itemStack = new ItemStack(material);
|
||||||
itemStack.setDurability(durability);
|
|
||||||
|
|
||||||
ItemMeta meta = getMetadata(itemName);
|
ItemMeta meta = getMetadata(itemName);
|
||||||
|
|
||||||
if (meta != null) {
|
if (meta != null) {
|
||||||
|
if (meta instanceof Damageable) {
|
||||||
|
((Damageable) meta).setDamage(durability);
|
||||||
|
}
|
||||||
itemStack.setItemMeta(meta);
|
itemStack.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,100 +449,52 @@ public class MaterialUtil {
|
||||||
return Metadata.getFromCode(group);
|
return Metadata.getFromCode(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DataValue {
|
private static class EnumParser<E extends Enum<E>> {
|
||||||
/**
|
private E parse(String name, E[] values) {
|
||||||
* Gets the data value from a string
|
String formatted = name.replaceAll("(?<!^)(?>\\s?)([A-Z1-9])", "_$1").toUpperCase(Locale.ROOT).replace(' ', '_');
|
||||||
*
|
try {
|
||||||
* @param type Data Value string
|
return E.valueOf(values[0].getDeclaringClass(), formatted);
|
||||||
* @param material Material
|
} catch (IllegalArgumentException exception) {
|
||||||
* @return data value
|
List<E> possibleEnums = new ArrayList<>();
|
||||||
*/
|
String[] typeParts = formatted.split("_");
|
||||||
public static byte get(String type, Material material) {
|
int length = Short.MAX_VALUE;
|
||||||
if (material == null || material.getData() == null) {
|
for (E e : values) {
|
||||||
return 0;
|
String enumName = e.name();
|
||||||
}
|
if (enumName.length() < length && enumName.startsWith(formatted)) {
|
||||||
|
length = enumName.length();
|
||||||
type = type.toUpperCase().replace(" ", "_");
|
possibleEnums.add(e);
|
||||||
|
} else if (typeParts.length > 1) {
|
||||||
MaterialData materialData = material.getNewData((byte) 0);
|
String[] nameParts = enumName.split("_");
|
||||||
|
if (typeParts.length == nameParts.length) {
|
||||||
if (materialData instanceof TexturedMaterial) {
|
boolean matched = true;
|
||||||
TexturedMaterial texturedMaterial = (TexturedMaterial) materialData;
|
for (int i = 0; i < nameParts.length; i++) {
|
||||||
|
if (!nameParts[i].startsWith(typeParts[i])) {
|
||||||
for (Material mat : texturedMaterial.getTextures()) {
|
matched = false;
|
||||||
if (mat.name().startsWith(type) && !mat.equals(material)) {
|
break;
|
||||||
return (byte) texturedMaterial.getTextures().indexOf(mat);
|
}
|
||||||
|
}
|
||||||
|
if (matched) {
|
||||||
|
possibleEnums.add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (materialData instanceof Colorable) {
|
|
||||||
DyeColor color;
|
|
||||||
|
|
||||||
try {
|
if (possibleEnums.size() == 1) {
|
||||||
color = DyeColor.valueOf(type);
|
return possibleEnums.get(0);
|
||||||
} catch (IllegalArgumentException exception) {
|
} else if (possibleEnums.size() > 1) {
|
||||||
return 0;
|
int formattedLength = formatted.length();
|
||||||
|
int closestDeviation = Short.MAX_VALUE;
|
||||||
|
E closestEnum = null;
|
||||||
|
for (E possibleEnum : possibleEnums) {
|
||||||
|
int deviation = possibleEnum.name().length() - formattedLength;
|
||||||
|
if (deviation < closestDeviation) {
|
||||||
|
closestDeviation = deviation;
|
||||||
|
closestEnum = possibleEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return closestEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (material == Material.INK_SACK) {
|
|
||||||
return color.getDyeData();
|
|
||||||
}
|
|
||||||
|
|
||||||
return color.getWoolData();
|
|
||||||
} else if (materialData instanceof Tree) {
|
|
||||||
try {
|
|
||||||
return TreeSpecies.valueOf(type).getData();
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else if (materialData instanceof SpawnEgg) {
|
|
||||||
try {
|
|
||||||
EntityType entityType = EntityType.valueOf(type);
|
|
||||||
|
|
||||||
return (byte) entityType.getTypeId();
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else if (materialData instanceof Coal) {
|
|
||||||
try {
|
|
||||||
return CoalType.valueOf(type).getData();
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a string with the DataValue
|
|
||||||
*
|
|
||||||
* @param itemStack ItemStack to describe
|
|
||||||
* @return Data value string
|
|
||||||
*/
|
|
||||||
public static String name(ItemStack itemStack) {
|
|
||||||
MaterialData data = itemStack.getData();
|
|
||||||
|
|
||||||
if (data == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data instanceof TexturedMaterial) {
|
|
||||||
return ((TexturedMaterial) data).getMaterial().name();
|
|
||||||
} else if (data instanceof Colorable) {
|
|
||||||
DyeColor color = ((Colorable) data).getColor();
|
|
||||||
|
|
||||||
return (color != null ? color.name() : null);
|
|
||||||
} else if (data instanceof Tree) {
|
|
||||||
//TreeSpecies specie = TreeSpecies.getByData((byte) (data.getData() & 3)); //This works, but not as intended
|
|
||||||
TreeSpecies specie = ((Tree) data).getSpecies();
|
|
||||||
return (specie != null && specie != TreeSpecies.GENERIC ? specie.name() : null);
|
|
||||||
} else if (data instanceof SpawnEgg) {
|
|
||||||
EntityType type = ((SpawnEgg) data).getSpawnedType();
|
|
||||||
return (type != null ? type.name() : null);
|
|
||||||
} else if (data instanceof Coal) {
|
|
||||||
CoalType coal = ((Coal) data).getType();
|
|
||||||
return (coal != null && coal != CoalType.COAL ? coal.name() : null);
|
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,10 +502,10 @@ public class MaterialUtil {
|
||||||
|
|
||||||
public static class Metadata {
|
public static class Metadata {
|
||||||
/**
|
/**
|
||||||
* Returns the ItemStack represented by this code
|
* Returns the ItemMeta represented by this code
|
||||||
*
|
*
|
||||||
* @param code Code representing the item
|
* @param code Code representing the ItemMeta
|
||||||
* @return Item represented by code
|
* @return ItemMeta represented by code
|
||||||
*/
|
*/
|
||||||
public static ItemMeta getFromCode(String code) {
|
public static ItemMeta getFromCode(String code) {
|
||||||
ItemStack item = ChestShop.getItemDatabase().getFromCode(code);
|
ItemStack item = ChestShop.getItemDatabase().getFromCode(code);
|
||||||
|
@ -386,54 +528,9 @@ public class MaterialUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Odd {
|
|
||||||
private static boolean isInitialized = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the item stack from OddItem plugin
|
|
||||||
*
|
|
||||||
* @param itemName Item name to parse
|
|
||||||
* @return itemStack that was parsed
|
|
||||||
*/
|
|
||||||
public static ItemStack getFromString(String itemName) {
|
|
||||||
if (!isInitialized) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String name = itemName.replace(':', ';');
|
|
||||||
|
|
||||||
try {
|
|
||||||
return OddItem.getItemStack(name);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAlias(ItemStack itemStack) {
|
|
||||||
if (!isInitialized) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Collection<String> aliases = OddItem.getAliases(itemStack);
|
|
||||||
if (!aliases.isEmpty()) {
|
|
||||||
return aliases.iterator().next();
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lets the class know that it's safe to use the OddItem methods now
|
|
||||||
*/
|
|
||||||
public static void initialize() {
|
|
||||||
isInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Show {
|
public static class Show {
|
||||||
private static ShowItem showItem = null;
|
private static ShowItem showItem = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets the class know that it's safe to use the ShowItem methods now
|
* Lets the class know that it's safe to use the ShowItem methods now
|
||||||
*
|
*
|
||||||
|
@ -442,7 +539,7 @@ public class MaterialUtil {
|
||||||
public static void initialize(Plugin plugin) {
|
public static void initialize(Plugin plugin) {
|
||||||
showItem = (ShowItem) plugin;
|
showItem = (ShowItem) plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message with hover info and icons
|
* Send a message with hover info and icons
|
||||||
*
|
*
|
||||||
|
@ -450,35 +547,61 @@ public class MaterialUtil {
|
||||||
* @param message The raw message
|
* @param message The raw message
|
||||||
* @param stock The items in stock
|
* @param stock The items in stock
|
||||||
*/
|
*/
|
||||||
public static boolean sendMessage(Player player, String message, ItemStack[] stock) {
|
public static boolean sendMessage(Player player, Messages.Message message, ItemStack[] stock, Map<String, String> replacementMap, String... replacements) {
|
||||||
|
return sendMessage(player, player.getName(), message, stock, replacementMap, replacements);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message with hover info and icons
|
||||||
|
*
|
||||||
|
* @param player The player to send the message to
|
||||||
|
* @param playerName The name of the player in case he is offline and bungee messages are enabled
|
||||||
|
* @param message The raw message
|
||||||
|
* @param stock The items in stock
|
||||||
|
*/
|
||||||
|
public static boolean sendMessage(Player player, String playerName, Messages.Message message, ItemStack[] stock, Map<String, String> replacementMap, String... replacements) {
|
||||||
|
return sendMessage(player, playerName, message, true, stock, replacementMap, replacements);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message with hover info and icons
|
||||||
|
*
|
||||||
|
* @param player The player to send the message to
|
||||||
|
* @param playerName The name of the player in case he is offline and bungee messages are enabled
|
||||||
|
* @param message The raw message
|
||||||
|
* @param showPrefix If the prefix should show
|
||||||
|
* @param stock The items in stock
|
||||||
|
*/
|
||||||
|
public static boolean sendMessage(Player player, String playerName, Messages.Message message, boolean showPrefix, ItemStack[] stock, Map<String, String> replacementMap, String... replacements) {
|
||||||
if (showItem == null) {
|
if (showItem == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> itemJson = new ArrayList<>();
|
TextComponent.Builder itemComponent = Component.text();
|
||||||
for (ItemStack item : InventoryUtil.mergeSimilarStacks(stock)) {
|
for (ItemStack item : InventoryUtil.mergeSimilarStacks(stock)) {
|
||||||
try {
|
try {
|
||||||
itemJson.add(showItem.getItemConverter().createComponent(item, Level.OFF).toJsonString(player));
|
itemComponent.append(GsonComponentSerializer.gson().deserialize(showItem.getItemConverter().createComponent(item, Level.FINE).toJsonString(player)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ChestShop.getPlugin().getLogger().log(Level.WARNING, "Error while trying to send message '" + message + "' to player " + player.getName() + ": " + e.getMessage());
|
ChestShop.getPlugin().getLogger().log(Level.WARNING, "Error while trying to send message '" + message + "' to player " + player.getName() + ": " + e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String joinedItemJson = itemJson.stream().collect(Collectors.joining("," + new JSONObject(ImmutableMap.of("text", " ")).toJSONString() + ", "));
|
Map<String, String> newMap = new LinkedHashMap<>(replacementMap);
|
||||||
|
newMap.put("material", "item");
|
||||||
String messageJsonString = Arrays.stream(message.split("%item"))
|
newMap.remove("item");
|
||||||
.map(s -> new JSONObject(ImmutableMap.of("text", s)).toJSONString())
|
Component component = new Replacer()
|
||||||
.collect(Collectors.joining("," + joinedItemJson + ","));
|
.placeholderSuffix("")
|
||||||
|
.replace("item",itemComponent.build())
|
||||||
while (messageJsonString.startsWith(",")) {
|
.replaceIn(message.getComponent(player, showPrefix, newMap, replacements));
|
||||||
messageJsonString = messageJsonString.substring(1);
|
if (player != null) {
|
||||||
|
ChestShop.getAudiences().player(player).sendMessage(component);
|
||||||
|
return true;
|
||||||
|
} else if (playerName != null) {
|
||||||
|
ChestShop.sendBungeeMessage(playerName, component);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
while (messageJsonString.endsWith(",")) {
|
|
||||||
messageJsonString = messageJsonString.substring(0, messageJsonString.length() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
showItem.tellRaw(player, messageJsonString);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,4 +154,14 @@ public class NumberUtil {
|
||||||
return Integer.toString(number);
|
return Integer.toString(number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a long to an integer while not overflowing but returning Integer.MAX_VALUE
|
||||||
|
*
|
||||||
|
* @param number The long to convert
|
||||||
|
* @return The integer value or Integer.MAX_VALUE on overflow
|
||||||
|
*/
|
||||||
|
public static int toInt(long number) {
|
||||||
|
return number > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package com.Acrobot.Breeze.Utils;
|
package com.Acrobot.Breeze.Utils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class PriceUtil {
|
public class PriceUtil {
|
||||||
public static final double NO_PRICE = -1;
|
public static final BigDecimal NO_PRICE = BigDecimal.valueOf(-1);
|
||||||
public static final double FREE = 0;
|
public static final BigDecimal FREE = BigDecimal.valueOf(0);
|
||||||
|
public static final BigDecimal MAX = BigDecimal.valueOf(Double.MAX_VALUE);
|
||||||
|
|
||||||
public static final String FREE_TEXT = "free";
|
public static final String FREE_TEXT = "free";
|
||||||
|
|
||||||
|
@ -13,15 +17,15 @@ public class PriceUtil {
|
||||||
public static final char SELL_INDICATOR = 's';
|
public static final char SELL_INDICATOR = 's';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the price from the text
|
* Gets the exact price from the text
|
||||||
*
|
*
|
||||||
* @param text Text to check
|
* @param text Text to check
|
||||||
* @param indicator Price indicator (for example, B for buy)
|
* @param indicator Price indicator (for example, B for buy)
|
||||||
* @return price
|
* @return exact price
|
||||||
*/
|
*/
|
||||||
public static double get(String text, char indicator) {
|
public static BigDecimal getExact(String text, char indicator) {
|
||||||
String[] split = text.replace(" ", "").toLowerCase().split(":");
|
String[] split = text.replace(" ", "").toLowerCase(Locale.ROOT).split(":");
|
||||||
String character = String.valueOf(indicator).toLowerCase();
|
String character = String.valueOf(indicator).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
for (String part : split) {
|
for (String part : split) {
|
||||||
if (!part.startsWith(character) && !part.endsWith(character)) {
|
if (!part.startsWith(character) && !part.endsWith(character)) {
|
||||||
|
@ -34,28 +38,63 @@ public class PriceUtil {
|
||||||
return FREE;
|
return FREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NumberUtil.isDouble(part)) {
|
try {
|
||||||
double price = Double.valueOf(part);
|
BigDecimal price = new BigDecimal(part);
|
||||||
|
|
||||||
if (Double.isInfinite(price) || price <= 0) {
|
if (price.compareTo(MAX) > 0 || price.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
return NO_PRICE;
|
return NO_PRICE;
|
||||||
} else {
|
} else {
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
}
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_PRICE;
|
return NO_PRICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the price from the text
|
||||||
|
*
|
||||||
|
* @param text Text to check
|
||||||
|
* @param indicator Price indicator (for example, B for buy)
|
||||||
|
* @return price
|
||||||
|
* @deprecated Use {@link #getExact(String, char)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static double get(String text, char indicator) {
|
||||||
|
return getExact(text, indicator).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the exact buy price from the text
|
||||||
|
*
|
||||||
|
* @param text Text to check
|
||||||
|
* @return Exact buy price
|
||||||
|
*/
|
||||||
|
public static BigDecimal getExactBuyPrice(String text) {
|
||||||
|
return getExact(text, BUY_INDICATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the exact sell price from the text
|
||||||
|
*
|
||||||
|
* @param text Text to check
|
||||||
|
* @return Exact sell price
|
||||||
|
*/
|
||||||
|
public static BigDecimal getExactSellPrice(String text) {
|
||||||
|
return getExact(text, SELL_INDICATOR);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the buy price from the text
|
* Gets the buy price from the text
|
||||||
*
|
*
|
||||||
* @param text Text to check
|
* @param text Text to check
|
||||||
* @return Buy price
|
* @return Buy price
|
||||||
|
* @deprecated Use {@link #getExactBuyPrice(String)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static double getBuyPrice(String text) {
|
public static double getBuyPrice(String text) {
|
||||||
return get(text, BUY_INDICATOR);
|
return getExactBuyPrice(text).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,9 +102,11 @@ public class PriceUtil {
|
||||||
*
|
*
|
||||||
* @param text Text to check
|
* @param text Text to check
|
||||||
* @return Sell price
|
* @return Sell price
|
||||||
|
* @deprecated Use {@link #getExactSellPrice(String)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static double getSellPrice(String text) {
|
public static double getSellPrice(String text) {
|
||||||
return get(text, SELL_INDICATOR);
|
return getExactSellPrice(text).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,7 +137,7 @@ public class PriceUtil {
|
||||||
* @return If the text contains indicated price
|
* @return If the text contains indicated price
|
||||||
*/
|
*/
|
||||||
public static boolean hasPrice(String text, char indicator) {
|
public static boolean hasPrice(String text, char indicator) {
|
||||||
return get(text, indicator) != NO_PRICE;
|
return getExact(text, indicator).compareTo(NO_PRICE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.Acrobot.Breeze.Utils;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bricefrisco
|
||||||
|
*/
|
||||||
|
public class QuantityUtil {
|
||||||
|
public static final Pattern QUANTITY_LINE_WITH_COUNTER_PATTERN = Pattern.compile("^Q [1-9][0-9]{0,4} : C [0-9]{1,5}$");
|
||||||
|
|
||||||
|
public static int parseQuantity(String quantityLine) throws IllegalArgumentException {
|
||||||
|
if (quantityLineContainsCounter(quantityLine)) {
|
||||||
|
return Integer.parseInt(quantityLine.split(" : ")[0].replace("Q ", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Integer.parseInt(quantityLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean quantityLineContainsCounter(String quantityLine) {
|
||||||
|
return QUANTITY_LINE_WITH_COUNTER_PATTERN.matcher(quantityLine).matches();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package com.Acrobot.Breeze.Utils;
|
package com.Acrobot.Breeze.Utils;
|
||||||
|
|
||||||
import org.apache.commons.lang.WordUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,9 +22,16 @@ public class StringUtil {
|
||||||
* @return Reformatted string
|
* @return Reformatted string
|
||||||
*/
|
*/
|
||||||
public static String capitalizeFirstLetter(String string, char separator) {
|
public static String capitalizeFirstLetter(String string, char separator) {
|
||||||
char[] separators = new char[]{separator};
|
if (string == null || string.isEmpty()) {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
return WordUtils.capitalizeFully(string, separators).replace(String.valueOf(separator), " ");
|
// Split into words
|
||||||
|
String[] words = string.toLowerCase(Locale.ROOT).split(String.valueOf(separator));
|
||||||
|
// Capitalize every word and return joined string
|
||||||
|
return Arrays.stream(words)
|
||||||
|
.map(word -> word.substring(0, 1).toUpperCase(Locale.ROOT) + word.substring(1))
|
||||||
|
.collect(Collectors.joining(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +39,7 @@ public class StringUtil {
|
||||||
*
|
*
|
||||||
* @param string String to reformat
|
* @param string String to reformat
|
||||||
* @return Reformatted string
|
* @return Reformatted string
|
||||||
* @see com.Acrobot.Breeze.Utils.StringUtil#capitalizeFirstLetter(String, char)
|
* @see StringUtil#capitalizeFirstLetter(String, char)
|
||||||
*/
|
*/
|
||||||
public static String capitalizeFirstLetter(String string) {
|
public static String capitalizeFirstLetter(String string) {
|
||||||
return capitalizeFirstLetter(string, ' ');
|
return capitalizeFirstLetter(string, ' ');
|
||||||
|
@ -45,7 +52,7 @@ public class StringUtil {
|
||||||
* @return Joined array
|
* @return Joined array
|
||||||
*/
|
*/
|
||||||
public static String joinArray(String[] array) {
|
public static String joinArray(String[] array) {
|
||||||
return joinArray(Arrays.asList(array));
|
return String.join(" ", array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +62,7 @@ public class StringUtil {
|
||||||
* @return Joined iterable
|
* @return Joined iterable
|
||||||
*/
|
*/
|
||||||
public static String joinArray(Collection<String> array) {
|
public static String joinArray(Collection<String> array) {
|
||||||
return array.stream().collect(Collectors.joining(" "));
|
return String.join(" ", array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,12 +80,95 @@ public class StringUtil {
|
||||||
* @return Stripped strings
|
* @return Stripped strings
|
||||||
*/
|
*/
|
||||||
public static String[] stripColourCodes(String[] strings) {
|
public static String[] stripColourCodes(String[] strings) {
|
||||||
List<String> output = new ArrayList<String>();
|
String[] output = new String[strings.length];
|
||||||
|
|
||||||
for (String string : strings) {
|
for (int i = 0; i < strings.length; i++) {
|
||||||
output.add(stripColourCodes(string));
|
output[i] = stripColourCodes(strings[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.toArray(new String[output.size()]);
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String characters = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'abcdefghijklmnopqrstuvwxyz{|}~¦ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø×áíóúñѪº¿®¬½¼¡«»";
|
||||||
|
private static int[] extraWidth = {4,2,5,6,6,6,6,3,5,5,5,6,2,6,2,6,6,6,6,6,6,6,6,6,6,6,2,2,5,6,5,6,7,6,6,6,6,6,6,6,6,4,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,4,6,4,6,6,3,6,6,6,6,6,5,6,6,2,6,5,3,6,6,6,6,6,6,6,4,6,6,6,6,6,6,5,2,5,7,6,6,6,6,6,6,6,6,6,6,6,6,4,6,3,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,4,6,6,3,6,6,6,6,6,6,6,7,6,6,6,2,6,6,8,9,9,6,6,6,8,8,6,8,8,8,8,8,6,6,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,6,9,9,9,5,9,9,8,7,7,8,7,8,8,8,7,8,8,7,9,9,6,7,7,7,7,7,9,6,7,8,7,6,6,9,7,6,7,1};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the width that a character is displayed with in the default resource pack.
|
||||||
|
* This relies on a hardcoded character to width mapping and might not be precise in places.
|
||||||
|
* @param c The character to get the width of
|
||||||
|
* @return The width of the character (will return 10 for characters that we don't know the width of)
|
||||||
|
*/
|
||||||
|
public static int getMinecraftCharWidth(char c) {
|
||||||
|
if (c != ChatColor.COLOR_CHAR) {
|
||||||
|
int index = characters.indexOf(c);
|
||||||
|
if (index > -1) {
|
||||||
|
return extraWidth[index];
|
||||||
|
} else {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the width that a string is displayed with in the default resource pack.
|
||||||
|
* This relies on a hardcoded character to width mapping and might not be precise in places.
|
||||||
|
* @param string The string to get the width of
|
||||||
|
* @return The width of the string
|
||||||
|
*/
|
||||||
|
public static int getMinecraftStringWidth(String string) {
|
||||||
|
int width = 0;
|
||||||
|
for (char c : string.toCharArray()) {
|
||||||
|
width += getMinecraftCharWidth(c);
|
||||||
|
}
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip whitespace from the front and back
|
||||||
|
* @param string The string to strip
|
||||||
|
* @return The string with all whitespace from front and back stripped; returns null if input is null
|
||||||
|
*/
|
||||||
|
public static String strip(String string) {
|
||||||
|
if (string == null)
|
||||||
|
return null;
|
||||||
|
// The result stripped string
|
||||||
|
StringBuilder stripped = new StringBuilder();
|
||||||
|
// The current white space which only gets added once we find a non-whitespace character
|
||||||
|
StringBuilder cachedWhitespace = new StringBuilder();
|
||||||
|
// Check each code point (not characters to support UTF16 properly)
|
||||||
|
for (int codePoint : string.codePoints().toArray()) {
|
||||||
|
// Check if it's a whitespace, so we know if we should add it
|
||||||
|
if (!Character.isWhitespace(codePoint)) {
|
||||||
|
// Check if we have cached whitespace, if so append it first and reset the cache
|
||||||
|
if (cachedWhitespace.length() > 0) {
|
||||||
|
stripped.append(cachedWhitespace);
|
||||||
|
cachedWhitespace = new StringBuilder();
|
||||||
|
}
|
||||||
|
// Append current code point
|
||||||
|
stripped.appendCodePoint(codePoint);
|
||||||
|
} else if (stripped.length() > 0) {
|
||||||
|
// If we already have some non-whitespace content in the final stripped
|
||||||
|
// then cache the current whitespace as it wasn't at the start
|
||||||
|
cachedWhitespace.appendCodePoint(codePoint);
|
||||||
|
} // Otherwise, this was the start, and we don't need the cached whitespace
|
||||||
|
}
|
||||||
|
// Return the stripped string, without any whitespace from the end left
|
||||||
|
return stripped.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a map from strings
|
||||||
|
* @param values The values to add
|
||||||
|
* @return The map
|
||||||
|
*/
|
||||||
|
public static Map<String, String> map(String... values) {
|
||||||
|
Map<String, String> map = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for (int i = 0; i + 1 < values.length; i+=2) {
|
||||||
|
map.put(values[i], values[i + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,10 @@ package com.Acrobot.ChestShop;
|
||||||
import com.Acrobot.Breeze.Configuration.Configuration;
|
import com.Acrobot.Breeze.Configuration.Configuration;
|
||||||
import com.Acrobot.ChestShop.Commands.Give;
|
import com.Acrobot.ChestShop.Commands.Give;
|
||||||
import com.Acrobot.ChestShop.Commands.ItemInfo;
|
import com.Acrobot.ChestShop.Commands.ItemInfo;
|
||||||
|
import com.Acrobot.ChestShop.Commands.ShopInfo;
|
||||||
import com.Acrobot.ChestShop.Commands.Toggle;
|
import com.Acrobot.ChestShop.Commands.Toggle;
|
||||||
import com.Acrobot.ChestShop.Commands.Version;
|
import com.Acrobot.ChestShop.Commands.Version;
|
||||||
|
import com.Acrobot.ChestShop.Commands.AccessToggle;
|
||||||
import com.Acrobot.ChestShop.Configuration.Messages;
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
import com.Acrobot.ChestShop.Configuration.Properties;
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||||
import com.Acrobot.ChestShop.Database.Migrations;
|
import com.Acrobot.ChestShop.Database.Migrations;
|
||||||
|
@ -17,11 +19,17 @@ import com.Acrobot.ChestShop.Listeners.Economy.TaxModule;
|
||||||
import com.Acrobot.ChestShop.Listeners.AuthMeChestShopListener;
|
import com.Acrobot.ChestShop.Listeners.AuthMeChestShopListener;
|
||||||
import com.Acrobot.ChestShop.Listeners.GarbageTextListener;
|
import com.Acrobot.ChestShop.Listeners.GarbageTextListener;
|
||||||
import com.Acrobot.ChestShop.Listeners.Item.ItemMoveListener;
|
import com.Acrobot.ChestShop.Listeners.Item.ItemMoveListener;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Item.ItemStringListener;
|
||||||
import com.Acrobot.ChestShop.Listeners.ItemInfoListener;
|
import com.Acrobot.ChestShop.Listeners.ItemInfoListener;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Modules.ItemAliasModule;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Modules.MetricsModule;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Modules.StockCounterModule;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.ShopInfoListener;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.SignParseListener;
|
||||||
import com.Acrobot.ChestShop.Listeners.Modules.DiscountModule;
|
import com.Acrobot.ChestShop.Listeners.Modules.DiscountModule;
|
||||||
import com.Acrobot.ChestShop.Listeners.Modules.PriceRestrictionModule;
|
import com.Acrobot.ChestShop.Listeners.Modules.PriceRestrictionModule;
|
||||||
import com.Acrobot.ChestShop.Listeners.Player.*;
|
import com.Acrobot.ChestShop.Listeners.Player.*;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.CreationFeeGetter;
|
import com.Acrobot.ChestShop.Listeners.PreShopCreation.CreationFeeGetter;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.MessageSender;
|
import com.Acrobot.ChestShop.Listeners.PostShopCreation.MessageSender;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.ShopCreationLogger;
|
import com.Acrobot.ChestShop.Listeners.PostShopCreation.ShopCreationLogger;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.SignSticker;
|
import com.Acrobot.ChestShop.Listeners.PostShopCreation.SignSticker;
|
||||||
|
@ -36,8 +44,18 @@ import com.Acrobot.ChestShop.Logging.FileFormatter;
|
||||||
import com.Acrobot.ChestShop.Metadata.ItemDatabase;
|
import com.Acrobot.ChestShop.Metadata.ItemDatabase;
|
||||||
import com.Acrobot.ChestShop.Signs.RestrictedSign;
|
import com.Acrobot.ChestShop.Signs.RestrictedSign;
|
||||||
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
|
import com.Acrobot.ChestShop.Updater.JenkinsBuildsNotifier;
|
||||||
import com.Acrobot.ChestShop.Updater.Updater;
|
import com.Acrobot.ChestShop.Updater.Updater;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
|
|
||||||
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Marker;
|
import org.apache.logging.log4j.Marker;
|
||||||
|
@ -47,8 +65,18 @@ import org.apache.logging.log4j.core.config.LoggerConfig;
|
||||||
import org.apache.logging.log4j.core.filter.AbstractFilter;
|
import org.apache.logging.log4j.core.filter.AbstractFilter;
|
||||||
import org.apache.logging.log4j.message.Message;
|
import org.apache.logging.log4j.message.Message;
|
||||||
|
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
|
import org.bstats.charts.AdvancedBarChart;
|
||||||
|
import org.bstats.charts.DrilldownPie;
|
||||||
|
import org.bstats.charts.MultiLineChart;
|
||||||
|
import org.bstats.charts.SimpleBarChart;
|
||||||
|
import org.bstats.charts.SimplePie;
|
||||||
|
import org.bstats.charts.SingleLineChart;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
@ -58,9 +86,19 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
import java.util.logging.FileHandler;
|
import java.util.logging.FileHandler;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main file of the plugin
|
* Main file of the plugin
|
||||||
|
@ -71,61 +109,106 @@ public class ChestShop extends JavaPlugin {
|
||||||
private static ChestShop plugin;
|
private static ChestShop plugin;
|
||||||
private static Server server;
|
private static Server server;
|
||||||
private static PluginDescriptionFile description;
|
private static PluginDescriptionFile description;
|
||||||
|
private static final ExecutorService executorService = Executors.newCachedThreadPool();
|
||||||
|
|
||||||
|
private static Metrics bStats;
|
||||||
|
|
||||||
|
private static BukkitAudiences audiences;
|
||||||
|
|
||||||
private static File dataFolder;
|
private static File dataFolder;
|
||||||
private static ItemDatabase itemDatabase;
|
private static ItemDatabase itemDatabase;
|
||||||
|
|
||||||
private static Logger logger;
|
private static Logger logger;
|
||||||
|
private static Logger shopLogger;
|
||||||
private FileHandler handler;
|
private FileHandler handler;
|
||||||
|
|
||||||
|
private List<PluginCommand> commands = new ArrayList<>();
|
||||||
|
|
||||||
public ChestShop() {
|
public ChestShop() {
|
||||||
dataFolder = getDataFolder();
|
dataFolder = getDataFolder();
|
||||||
logger = getLogger();
|
logger = getLogger();
|
||||||
|
shopLogger = Logger.getLogger("ChestShop Shops");
|
||||||
|
shopLogger.setParent(logger);
|
||||||
description = getDescription();
|
description = getDescription();
|
||||||
server = getServer();
|
server = getServer();
|
||||||
plugin = this;
|
plugin = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
@Override
|
||||||
Configuration.pairFileAndClass(loadFile("config.yml"), Properties.class);
|
public void onLoad() {
|
||||||
Configuration.pairFileAndClass(loadFile("local.yml"), Messages.class);
|
Dependencies.initializePlugins();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
bStats = new Metrics(this, 1109);
|
||||||
|
audiences = BukkitAudiences.create(this);
|
||||||
turnOffDatabaseLogging();
|
turnOffDatabaseLogging();
|
||||||
if (!handleMigrations()) {
|
if (!handleMigrations()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerCommand("iteminfo", new ItemInfo(), Permission.ITEMINFO);
|
||||||
|
registerCommand("shopinfo", new ShopInfo(), Permission.SHOPINFO);
|
||||||
|
registerCommand("csVersion", new Version(), Permission.ADMIN);
|
||||||
|
registerCommand("csMetrics", new com.Acrobot.ChestShop.Commands.Metrics(), Permission.ADMIN);
|
||||||
|
registerCommand("csGive", new Give(), Permission.ADMIN);
|
||||||
|
registerCommand("cstoggle", new Toggle(), Permission.NOTIFY_TOGGLE);
|
||||||
|
registerCommand("csaccess", new AccessToggle(), Permission.ACCESS_TOGGLE);
|
||||||
|
|
||||||
|
loadConfig();
|
||||||
|
|
||||||
itemDatabase = new ItemDatabase();
|
itemDatabase = new ItemDatabase();
|
||||||
|
|
||||||
NameManager.load();
|
if (!Dependencies.loadPlugins()) {
|
||||||
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
Dependencies.loadPlugins();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
registerEvents();
|
registerEvents();
|
||||||
|
|
||||||
if (Properties.LOG_TO_FILE) {
|
registerPluginMessagingChannels();
|
||||||
File log = loadFile("ChestShop.log");
|
|
||||||
|
|
||||||
FileHandler handler = loadHandler(log.getAbsolutePath());
|
|
||||||
handler.setFormatter(new FileFormatter());
|
|
||||||
|
|
||||||
this.handler = handler;
|
|
||||||
logger.addHandler(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Properties.LOG_TO_CONSOLE) {
|
|
||||||
logger.setUseParentHandlers(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
getCommand("iteminfo").setExecutor(new ItemInfo());
|
|
||||||
getCommand("csVersion").setExecutor(new Version());
|
|
||||||
getCommand("csGive").setExecutor(new Give());
|
|
||||||
getCommand("cstoggle").setExecutor(new Toggle());
|
|
||||||
|
|
||||||
startStatistics();
|
startStatistics();
|
||||||
|
startBuildNotificatier();
|
||||||
startUpdater();
|
startUpdater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerCommand(String name, CommandExecutor executor, Permission permission) {
|
||||||
|
PluginCommand command = getCommand(name);
|
||||||
|
if (command != null) {
|
||||||
|
command.setExecutor(executor);
|
||||||
|
command.setPermission(permission.toString());
|
||||||
|
commands.add(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfig() {
|
||||||
|
Configuration.pairFileAndClass(loadFile("config.yml"), Properties.class, getBukkitLogger());
|
||||||
|
|
||||||
|
Messages.load();
|
||||||
|
|
||||||
|
NameManager.load();
|
||||||
|
|
||||||
|
commands.forEach(c -> c.setPermissionMessage(Messages.ACCESS_DENIED.getTextWithPrefix(null)));
|
||||||
|
|
||||||
|
if (handler != null) {
|
||||||
|
shopLogger.removeHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Properties.LOG_TO_FILE) {
|
||||||
|
if (handler == null) {
|
||||||
|
File log = loadFile("ChestShop.log");
|
||||||
|
|
||||||
|
handler = loadHandler(log.getAbsolutePath());
|
||||||
|
handler.setFormatter(new FileFormatter());
|
||||||
|
}
|
||||||
|
shopLogger.addHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
shopLogger.setUseParentHandlers(Properties.LOG_TO_CONSOLE);
|
||||||
|
}
|
||||||
|
|
||||||
private void turnOffDatabaseLogging() {
|
private void turnOffDatabaseLogging() {
|
||||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
org.apache.logging.log4j.core.config.Configuration config = ctx.getConfiguration();
|
org.apache.logging.log4j.core.config.Configuration config = ctx.getConfiguration();
|
||||||
|
@ -176,7 +259,7 @@ public class ChestShop extends JavaPlugin {
|
||||||
try {
|
try {
|
||||||
previousVersion.save(versionFile);
|
previousVersion.save(versionFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
getLogger().log(java.util.logging.Level.SEVERE, "Unable to save new database version " + Migrations.CURRENT_DATABASE_VERSION, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +276,7 @@ public class ChestShop extends JavaPlugin {
|
||||||
try {
|
try {
|
||||||
previousVersion.save(versionFile);
|
previousVersion.save(versionFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
getLogger().log(java.util.logging.Level.SEVERE, "Unable to save new database version " + newVersion, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -214,7 +297,7 @@ public class ChestShop extends JavaPlugin {
|
||||||
|
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
getBukkitLogger().log(java.util.logging.Level.SEVERE, "Unable to load file " + file.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,14 +310,17 @@ public class ChestShop extends JavaPlugin {
|
||||||
try {
|
try {
|
||||||
handler = new FileHandler(path, true);
|
handler = new FileHandler(path, true);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
getBukkitLogger().log(java.util.logging.Level.SEVERE, "Unable to load handler " + path, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
getServer().getScheduler().cancelTasks(this);
|
executorService.shutdown();
|
||||||
|
try {
|
||||||
|
executorService.awaitTermination(15, TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException ignored) {}
|
||||||
|
|
||||||
Toggle.clearToggledPlayers();
|
Toggle.clearToggledPlayers();
|
||||||
|
|
||||||
|
@ -248,6 +334,10 @@ public class ChestShop extends JavaPlugin {
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
registerEvent(new com.Acrobot.ChestShop.Plugins.ChestShop()); //Chest protection
|
registerEvent(new com.Acrobot.ChestShop.Plugins.ChestShop()); //Chest protection
|
||||||
|
|
||||||
|
registerEvent(new Dependencies());
|
||||||
|
|
||||||
|
registerEvent(new NameManager());
|
||||||
|
|
||||||
registerPreShopCreationEvents();
|
registerPreShopCreationEvents();
|
||||||
registerPreTransactionEvents();
|
registerPreTransactionEvents();
|
||||||
registerPostShopCreationEvents();
|
registerPostShopCreationEvents();
|
||||||
|
@ -267,9 +357,12 @@ public class ChestShop extends JavaPlugin {
|
||||||
registerEvent(new PlayerLeave());
|
registerEvent(new PlayerLeave());
|
||||||
registerEvent(new PlayerTeleport());
|
registerEvent(new PlayerTeleport());
|
||||||
|
|
||||||
|
registerEvent(new SignParseListener());
|
||||||
|
registerEvent(new ItemStringListener());
|
||||||
registerEvent(new ItemInfoListener());
|
registerEvent(new ItemInfoListener());
|
||||||
|
registerEvent(new ShopInfoListener());
|
||||||
registerEvent(new GarbageTextListener());
|
registerEvent(new GarbageTextListener());
|
||||||
|
|
||||||
Plugin authMe = getServer().getPluginManager().getPlugin("AuthMe");
|
Plugin authMe = getServer().getPluginManager().getPlugin("AuthMe");
|
||||||
if (authMe != null && authMe.isEnabled()) {
|
if (authMe != null && authMe.isEnabled()) {
|
||||||
registerEvent(new AuthMeChestShopListener());
|
registerEvent(new AuthMeChestShopListener());
|
||||||
|
@ -317,6 +410,7 @@ public class ChestShop extends JavaPlugin {
|
||||||
registerEvent(new AmountAndPriceChecker());
|
registerEvent(new AmountAndPriceChecker());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerEvent(new InvalidNameIgnorer());
|
||||||
registerEvent(new CreativeModeIgnorer());
|
registerEvent(new CreativeModeIgnorer());
|
||||||
registerEvent(new ErrorMessageSender());
|
registerEvent(new ErrorMessageSender());
|
||||||
registerEvent(new PermissionChecker());
|
registerEvent(new PermissionChecker());
|
||||||
|
@ -335,8 +429,11 @@ public class ChestShop extends JavaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerModules() {
|
private void registerModules() {
|
||||||
|
registerEvent(new ItemAliasModule());
|
||||||
registerEvent(new DiscountModule());
|
registerEvent(new DiscountModule());
|
||||||
|
registerEvent(new MetricsModule());
|
||||||
registerEvent(new PriceRestrictionModule());
|
registerEvent(new PriceRestrictionModule());
|
||||||
|
registerEvent(new StockCounterModule());
|
||||||
|
|
||||||
registerEconomicalModules();
|
registerEconomicalModules();
|
||||||
}
|
}
|
||||||
|
@ -346,27 +443,130 @@ public class ChestShop extends JavaPlugin {
|
||||||
registerEvent(new TaxModule());
|
registerEvent(new TaxModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerPluginMessagingChannels() {
|
||||||
|
if (Properties.BUNGEECORD_MESSAGES) {
|
||||||
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void registerEvent(Listener listener) {
|
public void registerEvent(Listener listener) {
|
||||||
getServer().getPluginManager().registerEvents(listener, this);
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startStatistics() {
|
private void startStatistics() {
|
||||||
try {
|
try (JarFile jarFile = new JarFile(this.getFile())) {
|
||||||
new org.mcstats.Metrics(this).start();
|
String dist = jarFile.getManifest().getMainAttributes().getValue("Distribution-Type");
|
||||||
} catch (IOException ex) {
|
bStats.addCustomChart(new SimplePie("distributionType", () -> dist));
|
||||||
ChestShop.getBukkitLogger().severe("There was an error while submitting MCStats statistics.");
|
} catch (IOException ignored) {}
|
||||||
}
|
|
||||||
new org.bstats.MetricsLite(this);
|
String serverVersion = getServer().getBukkitVersion().split("-")[0];
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("versionMcSelf", serverVersion, getDescription().getVersion()));
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("versionSelfMc", getDescription().getVersion(), serverVersion));
|
||||||
|
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("serverTypeVersionSelf", getServer().getName(), getDescription().getVersion()));
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("versionSelfServerType", getDescription().getVersion(), getServer().getName()));
|
||||||
|
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("versionMcServerType", serverVersion, getServer().getName()));
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("serverTypeVersionMc", getServer().getName(), serverVersion));
|
||||||
|
|
||||||
|
String javaVersion = System.getProperty("java.version");
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("versionJavaSelf", javaVersion, getDescription().getVersion()));
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("versionSelfJava", getDescription().getVersion(), javaVersion));
|
||||||
|
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("versionJavaMc", javaVersion, serverVersion));
|
||||||
|
bStats.addCustomChart(createStaticDrilldownStat("versionMcJava", serverVersion, javaVersion));
|
||||||
|
|
||||||
|
bStats.addCustomChart(new SingleLineChart("shopAccounts", NameManager::getAccountCount));
|
||||||
|
bStats.addCustomChart(new MultiLineChart("transactionCount", () -> ImmutableMap.of(
|
||||||
|
"total", MetricsModule.getTotalTransactions(),
|
||||||
|
"buy", MetricsModule.getBuyTransactions(),
|
||||||
|
"sell", MetricsModule.getSellTransactions()
|
||||||
|
)));
|
||||||
|
bStats.addCustomChart(new MultiLineChart("itemCount", () -> ImmutableMap.of(
|
||||||
|
"total", MetricsModule.getTotalItemsCount(),
|
||||||
|
"buy", MetricsModule.getSoldItemsCount(),
|
||||||
|
"sell", MetricsModule.getBoughtItemsCount()
|
||||||
|
)));
|
||||||
|
|
||||||
|
bStats.addCustomChart(new SimplePie("includeSettingsInMetrics", () -> Properties.INCLUDE_SETTINGS_IN_METRICS ? "enabled" : "disabled"));
|
||||||
|
if (!Properties.INCLUDE_SETTINGS_IN_METRICS) return;
|
||||||
|
|
||||||
|
bStats.addCustomChart(new SimplePie("ensure-correct-playerid", () -> Properties.ENSURE_CORRECT_PLAYERID ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("allow-sign-chest-open", () -> Properties.ALLOW_SIGN_CHEST_OPEN ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("uses-server-economy-account", () -> !Properties.SERVER_ECONOMY_ACCOUNT.isEmpty() ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("uses-server-economy-account-uuid", () -> !Properties.SERVER_ECONOMY_ACCOUNT_UUID.equals(new UUID(0, 0)) ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("allow-partial-transactions", () -> Properties.ALLOW_PARTIAL_TRANSACTIONS ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("bungeecord-messages", () -> Properties.BUNGEECORD_MESSAGES ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("allow-multiple-shops-at-one-block", () -> Properties.ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("allow-partial-transactions", () -> Properties.ALLOW_PARTIAL_TRANSACTIONS ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("log-to-console", () -> Properties.LOG_TO_CONSOLE ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("log-to-file", () -> Properties.LOG_TO_FILE ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("auto-update", () -> !Properties.TURN_OFF_UPDATES ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("release-notifications", () -> !Properties.TURN_OFF_UPDATE_NOTIFIER ? "enabled" : "disabled"));
|
||||||
|
bStats.addCustomChart(new SimplePie("dev-build-notifications", () -> !Properties.TURN_OFF_DEV_UPDATE_NOTIFIER ? "enabled" : "disabled"));
|
||||||
|
|
||||||
|
bStats.addCustomChart(new AdvancedBarChart("pluginProperties", () -> {
|
||||||
|
Map<String, int[]> map = new LinkedHashMap<>();
|
||||||
|
map.put("ensure-correct-playerid", getChartArray(Properties.ENSURE_CORRECT_PLAYERID));
|
||||||
|
map.put("reverse-buttons", getChartArray(Properties.REVERSE_BUTTONS));
|
||||||
|
map.put("shift-sells-in-stacks", getChartArray(Properties.SHIFT_SELLS_IN_STACKS));
|
||||||
|
map.put("shift-sells-everything", getChartArray(Properties.SHIFT_SELLS_EVERYTHING));
|
||||||
|
map.put("allow-sign-chest-open", getChartArray(!Properties.ALLOW_SIGN_CHEST_OPEN));
|
||||||
|
map.put("sign-dying", getChartArray(!Properties.SIGN_DYING));
|
||||||
|
map.put("remove-empty-shops", getChartArray(!Properties.REMOVE_EMPTY_SHOPS));
|
||||||
|
map.put("remove-empty-chests", getChartArray(!Properties.REMOVE_EMPTY_CHESTS));
|
||||||
|
map.put("uses-server-economy-account", getChartArray(!Properties.SERVER_ECONOMY_ACCOUNT.isEmpty()));
|
||||||
|
map.put("uses-server-economy-account-uuid", getChartArray(!Properties.SERVER_ECONOMY_ACCOUNT_UUID.equals(new UUID(0, 0))));
|
||||||
|
map.put("allow-multiple-shops-at-one-block", getChartArray(Properties.ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK));
|
||||||
|
map.put("allow-partial-transactions", getChartArray(Properties.ALLOW_PARTIAL_TRANSACTIONS));
|
||||||
|
map.put("bungeecord-messages", getChartArray(Properties.BUNGEECORD_MESSAGES));
|
||||||
|
map.put("log-to-console", getChartArray(Properties.LOG_TO_CONSOLE));
|
||||||
|
map.put("log-to-file", getChartArray(Properties.LOG_TO_FILE));
|
||||||
|
map.put("auto-update", getChartArray(!Properties.TURN_OFF_UPDATES));
|
||||||
|
map.put("release-notifications", getChartArray(!Properties.TURN_OFF_UPDATE_NOTIFIER));
|
||||||
|
map.put("dev-build-notifications", getChartArray(!Properties.TURN_OFF_DEV_UPDATE_NOTIFIER));
|
||||||
|
return map;
|
||||||
|
}));
|
||||||
|
bStats.addCustomChart(new SimpleBarChart("shopContainers",
|
||||||
|
() -> Properties.SHOP_CONTAINERS.stream().map(Material::name).collect(Collectors.toMap(k -> k, k -> 1))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DrilldownPie createStaticDrilldownStat(String statId, String value1, String value2) {
|
||||||
|
final Map<String, Map<String, Integer>> map = ImmutableMap.of(value1, ImmutableMap.of(value2, 1));
|
||||||
|
return new DrilldownPie(statId, () -> map);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] getChartArray(boolean value) {
|
||||||
|
return new int[]{!value ? 1 : 0, value ? 0 : 1};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int PROJECT_BUKKITDEV_ID = 31263;
|
private static final int PROJECT_BUKKITDEV_ID = 31263;
|
||||||
|
|
||||||
private void startUpdater() {
|
private void startUpdater() {
|
||||||
if (Properties.TURN_OFF_UPDATES) {
|
if (Properties.TURN_OFF_UPDATES) {
|
||||||
|
getLogger().info("Auto-updater is disabled. If you want the plugin to automatically download new releases then set 'TURN_OFF_UPDATES' to 'false' in your config.yml!");
|
||||||
|
if (!Properties.TURN_OFF_UPDATE_NOTIFIER) {
|
||||||
|
final Updater updater = new Updater(this, getPluginName().toLowerCase(Locale.ROOT), this.getFile(), Updater.UpdateType.NO_DOWNLOAD, true);
|
||||||
|
runInAsyncThread(() -> {
|
||||||
|
if (updater.getResult() == Updater.UpdateResult.UPDATE_AVAILABLE) {
|
||||||
|
getLogger().info("There is a new version available: " + updater.getLatestName() + ". You can download it from https://modrinth.com/plugin/" + getPluginName().toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new Updater(this, PROJECT_BUKKITDEV_ID, this.getFile(), Updater.UpdateType.DEFAULT, true);
|
new Updater(this, getPluginName().toLowerCase(Locale.ROOT), this.getFile(), Updater.UpdateType.DEFAULT, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String PROJECT_JENKINS_JOB_URL = "https://ci.minebench.de/job/ChestShop-3/";
|
||||||
|
|
||||||
|
private void startBuildNotificatier() {
|
||||||
|
if (Properties.TURN_OFF_DEV_UPDATE_NOTIFIER) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new JenkinsBuildsNotifier(this, PROJECT_JENKINS_JOB_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -379,10 +579,20 @@ public class ChestShop extends JavaPlugin {
|
||||||
return dataFolder;
|
return dataFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Logger getShopLogger() {
|
||||||
|
return shopLogger;
|
||||||
|
}
|
||||||
|
|
||||||
public static Logger getBukkitLogger() {
|
public static Logger getBukkitLogger() {
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void logDebug(String message) {
|
||||||
|
if (Properties.DEBUG) {
|
||||||
|
getBukkitLogger().info("[DEBUG] " + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Server getBukkitServer() {
|
public static Server getBukkitServer() {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
@ -403,11 +613,51 @@ public class ChestShop extends JavaPlugin {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Metrics getMetrics() {
|
||||||
|
return bStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BukkitAudiences getAudiences() {
|
||||||
|
return audiences;
|
||||||
|
}
|
||||||
|
|
||||||
public static void registerListener(Listener listener) {
|
public static void registerListener(Listener listener) {
|
||||||
plugin.registerEvent(listener);
|
plugin.registerEvent(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callEvent(Event event) {
|
public static <E extends Event> E callEvent(E event) {
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendBungeeMessage(String playerName, Messages.Message message, Map<String, String> replacementMap, String... replacements) {
|
||||||
|
sendBungeeMessage(playerName, message.getComponent(null, true, replacementMap, replacements));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendBungeeMessage(String playerName, String message) {
|
||||||
|
sendBungeeMessage(playerName, "Message", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendBungeeMessage(String playerName, BaseComponent[] message) {
|
||||||
|
sendBungeeMessage(playerName, "MessageRaw", ComponentSerializer.toString(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendBungeeMessage(String playerName, Component message) {
|
||||||
|
sendBungeeMessage(playerName, "MessageRaw", GsonComponentSerializer.gson().serialize(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendBungeeMessage(String playerName, String channel, String message) {
|
||||||
|
if (Properties.BUNGEECORD_MESSAGES && !Bukkit.getOnlinePlayers().isEmpty()) {
|
||||||
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
|
out.writeUTF(channel);
|
||||||
|
out.writeUTF(playerName);
|
||||||
|
out.writeUTF(message);
|
||||||
|
|
||||||
|
Bukkit.getOnlinePlayers().iterator().next().sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runInAsyncThread(Runnable runnable) {
|
||||||
|
executorService.submit(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.Acrobot.ChestShop.Commands;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author g--o
|
||||||
|
*/
|
||||||
|
public class AccessToggle implements CommandExecutor {
|
||||||
|
private static final Set<UUID> toggledPlayers = new HashSet<>();
|
||||||
|
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (setIgnoring(player, !isIgnoring(player))) {
|
||||||
|
Messages.TOGGLE_ACCESS_OFF.sendWithPrefix(player);
|
||||||
|
} else {
|
||||||
|
Messages.TOGGLE_ACCESS_ON.sendWithPrefix(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isIgnoring(OfflinePlayer player) {
|
||||||
|
return player != null && isIgnoring(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isIgnoring(UUID playerId) {
|
||||||
|
return toggledPlayers.contains(playerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean setIgnoring(Player player, boolean ignoring) {
|
||||||
|
Preconditions.checkNotNull(player); // Make sure the player instance is not null, in case there are any errors in the code
|
||||||
|
|
||||||
|
if (ignoring) {
|
||||||
|
toggledPlayers.add(player.getUniqueId());
|
||||||
|
} else {
|
||||||
|
toggledPlayers.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ignoring;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,8 @@ import com.Acrobot.Breeze.Utils.InventoryUtil;
|
||||||
import com.Acrobot.Breeze.Utils.MaterialUtil;
|
import com.Acrobot.Breeze.Utils.MaterialUtil;
|
||||||
import com.Acrobot.Breeze.Utils.NumberUtil;
|
import com.Acrobot.Breeze.Utils.NumberUtil;
|
||||||
import com.Acrobot.ChestShop.Configuration.Messages;
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
import com.Acrobot.ChestShop.Permission;
|
import com.Acrobot.ChestShop.Events.ItemParseEvent;
|
||||||
|
import com.Acrobot.ChestShop.Utils.ItemUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -12,8 +13,9 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -22,11 +24,6 @@ public class Give implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!Permission.has(sender, Permission.ADMIN)) {
|
|
||||||
sender.sendMessage(Messages.prefix(Messages.ACCESS_DENIED));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +31,7 @@ public class Give implements CommandExecutor {
|
||||||
Player receiver = (sender instanceof Player ? (Player) sender : null);
|
Player receiver = (sender instanceof Player ? (Player) sender : null);
|
||||||
int quantity = 1;
|
int quantity = 1;
|
||||||
|
|
||||||
List<Integer> disregardedIndexes = new ArrayList<Integer>();
|
Set<Integer> disregardedIndexes = new HashSet<>();
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
for (int index = args.length - 1; index >= 0; --index) {
|
for (int index = args.length - 1; index >= 0; --index) {
|
||||||
|
@ -50,7 +47,7 @@ public class Give implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = args.length - 1; index >= 0; --index) {
|
for (int index = args.length - 1; index >= 0; --index) {
|
||||||
if (!NumberUtil.isInteger(args[index]) || Integer.parseInt(args[index]) < 0) {
|
if (disregardedIndexes.contains(index) || !NumberUtil.isInteger(args[index]) || Integer.parseInt(args[index]) < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,28 +59,26 @@ public class Give implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receiver == null) {
|
if (receiver == null) {
|
||||||
sender.sendMessage(Messages.prefix(Messages.PLAYER_NOT_FOUND));
|
Messages.PLAYER_NOT_FOUND.sendWithPrefix(sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack item = getItem(args, disregardedIndexes);
|
ItemStack item = getItem(args, disregardedIndexes);
|
||||||
|
|
||||||
if (MaterialUtil.isEmpty(item)) {
|
if (MaterialUtil.isEmpty(item)) {
|
||||||
sender.sendMessage(Messages.prefix(Messages.INCORRECT_ITEM_ID));
|
Messages.INCORRECT_ITEM_ID.sendWithPrefix(sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.setAmount(quantity);
|
item.setAmount(quantity);
|
||||||
InventoryUtil.add(item, receiver.getInventory());
|
InventoryUtil.add(item, receiver.getInventory());
|
||||||
|
|
||||||
sender.sendMessage(Messages.prefix(Messages.ITEM_GIVEN
|
Messages.ITEM_GIVEN.send(sender, "item", ItemUtil.getName(item), "player", receiver.getName());
|
||||||
.replace("%item", MaterialUtil.getName(item))
|
|
||||||
.replace("%player", receiver.getName())));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack getItem(String[] arguments, List<Integer> disregardedElements) {
|
private static ItemStack getItem(String[] arguments, Set<Integer> disregardedElements) {
|
||||||
StringBuilder builder = new StringBuilder(arguments.length * 5);
|
StringBuilder builder = new StringBuilder(arguments.length * 5);
|
||||||
|
|
||||||
for (int index = 0; index < arguments.length; ++index) {
|
for (int index = 0; index < arguments.length; ++index) {
|
||||||
|
@ -94,6 +89,8 @@ public class Give implements CommandExecutor {
|
||||||
builder.append(arguments[index]).append(' ');
|
builder.append(arguments[index]).append(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
return MaterialUtil.getItem(builder.toString());
|
ItemParseEvent parseEvent = new ItemParseEvent(builder.toString());
|
||||||
|
Bukkit.getPluginManager().callEvent(parseEvent);
|
||||||
|
return parseEvent.getItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,25 @@ import com.Acrobot.Breeze.Utils.MaterialUtil;
|
||||||
import com.Acrobot.Breeze.Utils.StringUtil;
|
import com.Acrobot.Breeze.Utils.StringUtil;
|
||||||
import com.Acrobot.ChestShop.ChestShop;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
import com.Acrobot.ChestShop.Configuration.Messages;
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||||
import com.Acrobot.ChestShop.Events.ItemInfoEvent;
|
import com.Acrobot.ChestShop.Events.ItemInfoEvent;
|
||||||
|
import com.Acrobot.ChestShop.Events.ItemParseEvent;
|
||||||
|
import com.Acrobot.ChestShop.Utils.ItemUtil;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo;
|
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo;
|
||||||
|
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_shopname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -28,18 +38,25 @@ public class ItemInfo implements CommandExecutor {
|
||||||
|
|
||||||
item = ((HumanEntity) sender).getItemInHand();
|
item = ((HumanEntity) sender).getItemInHand();
|
||||||
} else {
|
} else {
|
||||||
item = MaterialUtil.getItem(StringUtil.joinArray(args));
|
ItemParseEvent parseEvent = new ItemParseEvent(StringUtil.joinArray(args));
|
||||||
|
Bukkit.getPluginManager().callEvent(parseEvent);
|
||||||
|
item = parseEvent.getItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MaterialUtil.isEmpty(item)) {
|
if (MaterialUtil.isEmpty(item)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String durability = getDurability(item);
|
iteminfo.send(sender);
|
||||||
String metadata = getMetadata(item);
|
if (!sendItemName(sender, item, Messages.iteminfo_fullname)) return true;
|
||||||
|
|
||||||
sender.sendMessage(Messages.prefix(iteminfo));
|
try {
|
||||||
sender.sendMessage(getNameAndID(item) + durability + metadata + ChatColor.WHITE);
|
iteminfo_shopname.send(sender, "item", ItemUtil.getSignName(item));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Error while generating shop sign name. Please contact an admin or take a look at the console/log!");
|
||||||
|
ChestShop.getPlugin().getLogger().log(Level.SEVERE, "Error while generating shop sign item name", e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ItemInfoEvent event = new ItemInfoEvent(sender, item);
|
ItemInfoEvent event = new ItemInfoEvent(sender, item);
|
||||||
ChestShop.callEvent(event);
|
ChestShop.callEvent(event);
|
||||||
|
@ -47,25 +64,18 @@ public class ItemInfo implements CommandExecutor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getNameAndID(ItemStack item) {
|
public static boolean sendItemName(CommandSender sender, ItemStack item, Messages.Message message) {
|
||||||
String itemName = MaterialUtil.getName(item);
|
try {
|
||||||
|
Map<String, String> replacementMap = ImmutableMap.of("item", ItemUtil.getName(item));
|
||||||
return ChatColor.GRAY + itemName + ChatColor.WHITE + " " + item.getTypeId();
|
if (!Properties.SHOWITEM_MESSAGE || !(sender instanceof Player)
|
||||||
}
|
|| !MaterialUtil.Show.sendMessage((Player) sender, sender.getName(), message, false, new ItemStack[]{item}, replacementMap)) {
|
||||||
|
message.send(sender, replacementMap);
|
||||||
private static String getDurability(ItemStack item) {
|
}
|
||||||
if (item.getDurability() != 0) {
|
} catch (IllegalArgumentException e) {
|
||||||
return ChatColor.DARK_GREEN + ":" + Integer.toString(item.getDurability());
|
sender.sendMessage(ChatColor.RED + "Error while generating full name. Please contact an admin or take a look at the console/log!");
|
||||||
} else {
|
ChestShop.getPlugin().getLogger().log(Level.SEVERE, "Error while generating full item name", e);
|
||||||
return "";
|
return false;
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
|
|
||||||
private static String getMetadata(ItemStack item) {
|
|
||||||
if (!item.hasItemMeta()) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return ChatColor.GOLD + "#" + MaterialUtil.Metadata.getItemCode(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.Acrobot.ChestShop.Commands;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Modules.MetricsModule;
|
||||||
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Acrobot
|
||||||
|
*/
|
||||||
|
public class Metrics implements CommandExecutor {
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
Messages.METRICS.send(sender,
|
||||||
|
"accounts", String.valueOf(NameManager.getAccountCount()),
|
||||||
|
"totalTransactions", String.valueOf(MetricsModule.getTotalTransactions()),
|
||||||
|
"buyTransactions", String.valueOf(MetricsModule.getBuyTransactions()),
|
||||||
|
"sellTransactions", String.valueOf(MetricsModule.getSellTransactions()),
|
||||||
|
"totalItems", String.valueOf(MetricsModule.getTotalItemsCount()),
|
||||||
|
"boughtItems", String.valueOf(MetricsModule.getBoughtItemsCount()),
|
||||||
|
"soldItems", String.valueOf(MetricsModule.getSoldItemsCount())
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.Acrobot.ChestShop.Commands;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
|
import com.Acrobot.ChestShop.Events.ShopInfoEvent;
|
||||||
|
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
||||||
|
import com.Acrobot.ChestShop.Utils.uBlock;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Phoenix616
|
||||||
|
*/
|
||||||
|
public class ShopInfo implements CommandExecutor {
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Block target = ((Player) sender).getTargetBlockExact(5);
|
||||||
|
if (target != null) {
|
||||||
|
Sign sign = null;
|
||||||
|
if (ChestShopSign.isValid(target)) {
|
||||||
|
sign = (Sign) target.getState();
|
||||||
|
} else if (uBlock.couldBeShopContainer(target)) {
|
||||||
|
sign = uBlock.getConnectedSign(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sign != null) {
|
||||||
|
ShopInfoEvent event = new ShopInfoEvent((Player) sender, sign);
|
||||||
|
ChestShop.callEvent(event);
|
||||||
|
} else {
|
||||||
|
Messages.NO_SHOP_FOUND.sendWithPrefix(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Command must be run by a player!");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,22 +1,23 @@
|
||||||
package com.Acrobot.ChestShop.Commands;
|
package com.Acrobot.ChestShop.Commands;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.Configuration.Messages;
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
import com.Acrobot.ChestShop.Permission;
|
import com.google.common.base.Preconditions;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author KingFaris10
|
* @author KingFaris10
|
||||||
*/
|
*/
|
||||||
public class Toggle implements CommandExecutor {
|
public class Toggle implements CommandExecutor {
|
||||||
private static final List<String> toggledPlayers = new ArrayList<String>();
|
private static final Set<UUID> toggledPlayers = new HashSet<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
@ -24,21 +25,16 @@ public class Toggle implements CommandExecutor {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Permission.has(sender, Permission.NOTIFY_TOGGLE)) {
|
|
||||||
sender.sendMessage(Messages.ACCESS_DENIED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setIgnoring(player, !toggledPlayers.contains(player.getName()))) {
|
if (setIgnoring(player, !isIgnoring(player))) {
|
||||||
player.sendMessage(Messages.prefix(Messages.TOGGLE_MESSAGES_OFF));
|
Messages.TOGGLE_MESSAGES_OFF.sendWithPrefix(player);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Messages.prefix(Messages.TOGGLE_MESSAGES_ON));
|
Messages.TOGGLE_MESSAGES_ON.sendWithPrefix(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -49,24 +45,28 @@ public class Toggle implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isIgnoring(OfflinePlayer player) {
|
public static boolean isIgnoring(OfflinePlayer player) {
|
||||||
return player != null && isIgnoring(player.getName());
|
return player != null && isIgnoring(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isIgnoring(UUID playerId) {
|
||||||
|
return toggledPlayers.contains(playerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #isIgnoring(UUID)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean isIgnoring(String playerName) {
|
public static boolean isIgnoring(String playerName) {
|
||||||
return toggledPlayers.contains(playerName);
|
return isIgnoring(Bukkit.getOfflinePlayer(playerName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean setIgnoring(Player player, boolean ignoring) {
|
public static boolean setIgnoring(Player player, boolean ignoring) {
|
||||||
Validate.notNull(player); // Make sure the player instance is not null, in case there are any errors in the code
|
Preconditions.checkNotNull(player); // Make sure the player instance is not null, in case there are any errors in the code
|
||||||
|
|
||||||
if (ignoring) {
|
if (ignoring) {
|
||||||
if (!toggledPlayers.contains(player.getName())) {
|
toggledPlayers.add(player.getUniqueId());
|
||||||
toggledPlayers.add(player.getName());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (toggledPlayers.contains(player.getName())) {
|
toggledPlayers.remove(player.getUniqueId());
|
||||||
toggledPlayers.remove(player.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ignoring;
|
return ignoring;
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package com.Acrobot.ChestShop.Commands;
|
package com.Acrobot.ChestShop.Commands;
|
||||||
|
|
||||||
import com.Acrobot.Breeze.Configuration.Configuration;
|
|
||||||
import com.Acrobot.ChestShop.ChestShop;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
import com.Acrobot.ChestShop.Configuration.Messages;
|
import com.Acrobot.ChestShop.Events.ChestShopReloadEvent;
|
||||||
import com.Acrobot.ChestShop.Configuration.Properties;
|
|
||||||
import com.Acrobot.ChestShop.Permission;
|
|
||||||
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -16,15 +12,8 @@ import org.bukkit.command.CommandSender;
|
||||||
*/
|
*/
|
||||||
public class Version implements CommandExecutor {
|
public class Version implements CommandExecutor {
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (!Permission.has(sender, Permission.ADMIN)) {
|
|
||||||
sender.sendMessage(Messages.prefix(Messages.ACCESS_DENIED));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length > 0 && args[0].equals("reload")) {
|
if (args.length > 0 && args[0].equals("reload")) {
|
||||||
Configuration.pairFileAndClass(ChestShop.loadFile("config.yml"), Properties.class);
|
ChestShop.callEvent(new ChestShopReloadEvent(sender));
|
||||||
Configuration.pairFileAndClass(ChestShop.loadFile("local.yml"), Messages.class);
|
|
||||||
NameManager.load();
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "The config was reloaded.");
|
sender.sendMessage(ChatColor.DARK_GREEN + "The config was reloaded.");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,82 +1,234 @@
|
||||||
package com.Acrobot.ChestShop.Configuration;
|
package com.Acrobot.ChestShop.Configuration;
|
||||||
|
|
||||||
import com.Acrobot.Breeze.Configuration.Annotations.PrecededBySpace;
|
|
||||||
import com.Acrobot.Breeze.Configuration.Configuration;
|
import com.Acrobot.Breeze.Configuration.Configuration;
|
||||||
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
|
import de.themoep.minedown.adventure.MineDown;
|
||||||
|
import de.themoep.utils.lang.bukkit.BukkitLanguageConfig;
|
||||||
|
import de.themoep.utils.lang.bukkit.LanguageManager;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class Messages {
|
public class Messages {
|
||||||
public static String prefix = "&a[Shop] &r";
|
public static Message prefix;
|
||||||
public static String iteminfo = "&aItem Information: &r";
|
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message shopinfo;
|
||||||
public static String ACCESS_DENIED = "You don't have permission to do that!";
|
public static Message shopinfo_buy;
|
||||||
|
public static Message shopinfo_sell;
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message iteminfo;
|
||||||
public static String NOT_ENOUGH_MONEY = "You don't have enough money!";
|
public static Message iteminfo_fullname;
|
||||||
public static String NOT_ENOUGH_MONEY_SHOP = "Shop owner doesn't have enough money!";
|
public static Message iteminfo_shopname;
|
||||||
|
public static Message iteminfo_repaircost;
|
||||||
|
public static Message iteminfo_book;
|
||||||
|
public static Message iteminfo_book_generation;
|
||||||
|
public static Message iteminfo_leather_color;
|
||||||
|
public static Message iteminfo_bundle_items;
|
||||||
|
public static Message iteminfo_axolotl_variant;
|
||||||
|
public static Message iteminfo_recipes;
|
||||||
|
public static Message iteminfo_map_view;
|
||||||
|
public static Message iteminfo_map_location;
|
||||||
|
public static Message iteminfo_tropical_fish;
|
||||||
|
public static Message iteminfo_crossbow_projectiles;
|
||||||
|
public static Message iteminfo_crossbow_projectile;
|
||||||
|
public static Message iteminfo_lore;
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message METRICS;
|
||||||
public static String CLIENT_DEPOSIT_FAILED = "Money deposit to your account failed!";
|
|
||||||
public static String SHOP_DEPOSIT_FAILED = "Money deposit to shop owner failed!";
|
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message ACCESS_DENIED;
|
||||||
public static String NO_BUYING_HERE = "You can't buy here!";
|
public static Message TRADE_DENIED;
|
||||||
public static String NO_SELLING_HERE = "You can't sell here!";
|
public static Message TRADE_DENIED_ACCESS_PERMS;
|
||||||
|
public static Message TRADE_DENIED_CREATIVE_MODE;
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message NOT_ENOUGH_MONEY;
|
||||||
public static String NOT_ENOUGH_SPACE_IN_INVENTORY = "You haven't got enough space in inventory!";
|
public static Message NOT_ENOUGH_MONEY_SHOP;
|
||||||
public static String NOT_ENOUGH_SPACE_IN_CHEST = "There isn't enough space in chest!";
|
|
||||||
public static String NOT_ENOUGH_ITEMS_TO_SELL = "You don't have enough items to sell!";
|
|
||||||
public static String NOT_ENOUGH_SPACE_IN_YOUR_SHOP = "%material&7 shop at &r%world/%x/%y/%z&7 is full! (%seller tried to sell)";
|
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message CLIENT_DEPOSIT_FAILED;
|
||||||
public static String NOT_ENOUGH_STOCK = "This shop is out of stock.";
|
public static Message SHOP_DEPOSIT_FAILED;
|
||||||
public static String NOT_ENOUGH_STOCK_IN_YOUR_SHOP = "%material&7 shop at &r%world/%x/%y/%z&7 is out of stock! (%buyer tried to buy)";
|
public static Message NO_ECONOMY_ACCOUNT;
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message NO_BUYING_HERE;
|
||||||
public static String YOU_BOUGHT_FROM_SHOP = "You bought %item from %owner for %price.";
|
public static Message NO_SELLING_HERE;
|
||||||
public static String SOMEBODY_BOUGHT_FROM_YOUR_SHOP = "%buyer bought %item for %price from you.";
|
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message NOT_ENOUGH_SPACE_IN_INVENTORY;
|
||||||
public static String YOU_SOLD_TO_SHOP = "You sold %item to %buyer for %price.";
|
public static Message NOT_ENOUGH_SPACE_IN_CHEST;
|
||||||
public static String SOMEBODY_SOLD_TO_YOUR_SHOP = "%seller sold %item for %price to you.";
|
public static Message NOT_ENOUGH_ITEMS_TO_SELL;
|
||||||
|
public static Message NOT_ENOUGH_SPACE_IN_YOUR_SHOP;
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message NOT_ENOUGH_STOCK;
|
||||||
public static String YOU_CANNOT_CREATE_SHOP = "You can't create this type of shop!";
|
public static Message NOT_ENOUGH_STOCK_IN_YOUR_SHOP;
|
||||||
public static String NO_CHEST_DETECTED = "Couldn't find a chest!";
|
|
||||||
public static String INVALID_SHOP_DETECTED = "The shop cannot be used!";
|
|
||||||
public static String CANNOT_ACCESS_THE_CHEST = "You don't have permissions to access this chest!";
|
|
||||||
|
|
||||||
@PrecededBySpace
|
|
||||||
public static String CLICK_TO_AUTOFILL_ITEM = "Click the sign with the item that this shop is for!";
|
|
||||||
public static String NO_ITEM_IN_HAND = "You don't have an item in your hand to autofill!";
|
|
||||||
|
|
||||||
@PrecededBySpace
|
|
||||||
public static String PROTECTED_SHOP = "Successfully protected the shop with LWC!";
|
|
||||||
public static String SHOP_CREATED = "Shop successfully created!";
|
|
||||||
public static String SHOP_FEE_PAID = "You have been charged %amount";
|
|
||||||
public static String SHOP_REFUNDED = "You have been refunded %amount.";
|
|
||||||
public static String ITEM_GIVEN = "Given %item to %player.";
|
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message YOU_BOUGHT_FROM_SHOP;
|
||||||
public static String RESTRICTED_SIGN_CREATED = "Sign successfully created!";
|
public static Message SOMEBODY_BOUGHT_FROM_YOUR_SHOP;
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message YOU_SOLD_TO_SHOP;
|
||||||
public static String PLAYER_NOT_FOUND = "Player not found!";
|
public static Message SOMEBODY_SOLD_TO_YOUR_SHOP;
|
||||||
public static String NO_PERMISSION = "You don't have permissions to do that!";
|
|
||||||
public static String INCORRECT_ITEM_ID = "You have specified invalid item id!";
|
|
||||||
public static String NOT_ENOUGH_PROTECTIONS = "Could not create a protection!";
|
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message YOU_CANNOT_CREATE_SHOP;
|
||||||
public static String CANNOT_CREATE_SHOP_HERE = "You can't create shop here!";
|
public static Message NO_CHEST_DETECTED;
|
||||||
|
public static Message INVALID_SHOP_DETECTED;
|
||||||
|
public static Message INVALID_SHOP_PRICE;
|
||||||
|
public static Message INVALID_SHOP_QUANTITY;
|
||||||
|
public static Message CANNOT_ACCESS_THE_CHEST;
|
||||||
|
public static Message CANNOT_CHANGE_SIGN_BACKSIDE;
|
||||||
|
|
||||||
@PrecededBySpace
|
public static Message SELL_PRICE_HIGHER_THAN_BUY_PRICE;
|
||||||
public static String TOGGLE_MESSAGES_OFF = "You will no longer receive messages from your shop(s).";
|
public static Message SELL_PRICE_ABOVE_MAX;
|
||||||
public static String TOGGLE_MESSAGES_ON = "You will now receive messages from your shop(s).";
|
public static Message SELL_PRICE_BELOW_MIN;
|
||||||
|
public static Message BUY_PRICE_ABOVE_MAX;
|
||||||
|
public static Message BUY_PRICE_BELOW_MIN;
|
||||||
|
|
||||||
|
public static Message CLICK_TO_AUTOFILL_ITEM;
|
||||||
|
public static Message NO_ITEM_IN_HAND;
|
||||||
|
|
||||||
|
public static Message PROTECTED_SHOP;
|
||||||
|
public static Message PROTECTED_SHOP_SIGN;
|
||||||
|
public static Message SHOP_CREATED;
|
||||||
|
public static Message SHOP_FEE_PAID;
|
||||||
|
public static Message SHOP_REFUNDED;
|
||||||
|
public static Message ITEM_GIVEN;
|
||||||
|
|
||||||
|
public static Message RESTRICTED_SIGN_CREATED;
|
||||||
|
|
||||||
|
public static Message PLAYER_NOT_FOUND;
|
||||||
|
public static Message NO_PERMISSION;
|
||||||
|
public static Message INCORRECT_ITEM_ID;
|
||||||
|
public static Message INVALID_CLIENT_NAME;
|
||||||
|
public static Message NOT_ENOUGH_PROTECTIONS;
|
||||||
|
public static Message NO_SHOP_FOUND;
|
||||||
|
|
||||||
|
public static Message CANNOT_CREATE_SHOP_HERE;
|
||||||
|
|
||||||
|
public static Message TOGGLE_MESSAGES_OFF;
|
||||||
|
public static Message TOGGLE_MESSAGES_ON;
|
||||||
|
|
||||||
|
public static Message TOGGLE_ACCESS_ON;
|
||||||
|
public static Message TOGGLE_ACCESS_OFF;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static String prefix(String message) {
|
public static String prefix(String message) {
|
||||||
return Configuration.getColoured( prefix + message);
|
return Configuration.getColoured(prefix.getLang(null) + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static String replace(String message, String... replacements) {
|
||||||
|
for (int i = 0; i + 1 < replacements.length; i+=2) {
|
||||||
|
message = message.replace("%" + replacements[i], replacements[i+1]);
|
||||||
|
}
|
||||||
|
return Configuration.getColoured(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LanguageManager manager;
|
||||||
|
|
||||||
|
public static void load() {
|
||||||
|
for (Field field : Messages.class.getFields()) {
|
||||||
|
if (!Modifier.isStatic(field.getModifiers())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
field.set(null, new Message(field.getName()));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while setting Message " + field.getName() + "!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
manager = new LanguageManager(ChestShop.getPlugin(), Properties.DEFAULT_LANGUAGE);
|
||||||
|
|
||||||
|
if (manager.getDefaultConfig() == null) {
|
||||||
|
manager.setDefaultLocale("en");
|
||||||
|
ChestShop.getBukkitLogger().log(Level.WARNING, "There is no language file for your DEFAULT_LANGUAGE config setting of '" + Properties.DEFAULT_LANGUAGE + "' in your languages folder! Using default English as default until you have created one or changed the config option to another, existing language file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Legacy locale.yml file
|
||||||
|
File legacyFile = new File(ChestShop.getPlugin().getDataFolder(), "local.yml");
|
||||||
|
if (legacyFile.exists()) {
|
||||||
|
ChestShop.getBukkitLogger().log(Level.INFO, "Found legacy local.yml. Loading it as 'legacy' language and using that for all messages.");
|
||||||
|
ChestShop.getBukkitLogger().log(Level.INFO, "As long as the legacy file is used automatic language switching based on the client settings will not be supported!");
|
||||||
|
ChestShop.getBukkitLogger().log(Level.INFO, "Import it into the corresponding language file and remove/rename the file if you don't want it anymore!");
|
||||||
|
manager.addConfig(new BukkitLanguageConfig(ChestShop.getPlugin(), "", legacyFile, "legacy", false));
|
||||||
|
manager.setDefaultLocale("legacy");
|
||||||
|
Properties.USE_CLIENT_LOCALE = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Properties.USE_CLIENT_LOCALE) {
|
||||||
|
manager.setProvider(sender -> null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Message {
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
public Message(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendWithPrefix(CommandSender sender, Map<String, String> replacementMap, String... replacements) {
|
||||||
|
ChestShop.getAudiences().sender(sender).sendMessage(getComponent(sender, true, replacementMap, replacements));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendWithPrefix(CommandSender sender, Map<String, String> replacements) {
|
||||||
|
ChestShop.getAudiences().sender(sender).sendMessage(getComponent(sender, true, replacements));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendWithPrefix(CommandSender sender, String... replacements) {
|
||||||
|
ChestShop.getAudiences().sender(sender).sendMessage(getComponent(sender, true, Collections.emptyMap(), replacements));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(CommandSender sender, String... replacements) {
|
||||||
|
ChestShop.getAudiences().sender(sender).sendMessage(getComponent(sender, false, Collections.emptyMap(), replacements));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(CommandSender sender, Map<String, String> replacements) {
|
||||||
|
ChestShop.getAudiences().sender(sender).sendMessage(getComponent(sender, false, replacements));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public BaseComponent[] getComponents(CommandSender sender, boolean prefixSuffix, Map<String, String> replacementMap, String... replacements) {
|
||||||
|
return BungeeComponentSerializer.get().serialize(getComponent(sender, prefixSuffix, replacementMap, replacements));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getComponent(CommandSender sender, boolean prefixSuffix, Map<String, String> replacementMap, String... replacements) {
|
||||||
|
MineDown mineDown = new MineDown("%prefix" + getLang(sender));
|
||||||
|
mineDown.placeholderSuffix("");
|
||||||
|
if (prefixSuffix) {
|
||||||
|
mineDown.replace("prefix", MineDown.parse(prefix.getLang(sender)));
|
||||||
|
} else {
|
||||||
|
mineDown.replace("prefix", "");
|
||||||
|
}
|
||||||
|
mineDown.replace(replacementMap);
|
||||||
|
mineDown.replace(replacements);
|
||||||
|
return mineDown.toComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLang(CommandSender sender) {
|
||||||
|
return manager.getConfig(sender).get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTextWithPrefix(CommandSender sender, Map<String, String> replacementMap, String... replacements) {
|
||||||
|
return LegacyComponentSerializer.legacySection().serialize(getComponent(sender, true, replacementMap, replacements));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTextWithPrefix(CommandSender sender, String... replacements) {
|
||||||
|
return getTextWithPrefix(sender, Collections.emptyMap(), replacements);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTextWithPrefix(CommandSender sender, Map<String, String> replacements) {
|
||||||
|
return getTextWithPrefix(sender, replacements, new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +1,166 @@
|
||||||
package com.Acrobot.ChestShop.Configuration;
|
package com.Acrobot.ChestShop.Configuration;
|
||||||
|
|
||||||
import com.Acrobot.Breeze.Configuration.Annotations.ConfigurationComment;
|
import com.Acrobot.Breeze.Configuration.Annotations.ConfigurationComment;
|
||||||
|
import com.Acrobot.Breeze.Configuration.Annotations.Parser;
|
||||||
import com.Acrobot.Breeze.Configuration.Annotations.PrecededBySpace;
|
import com.Acrobot.Breeze.Configuration.Annotations.PrecededBySpace;
|
||||||
|
import com.Acrobot.Breeze.Configuration.Configuration;
|
||||||
|
import com.Acrobot.Breeze.Configuration.ValueParser;
|
||||||
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
|
import com.Acrobot.ChestShop.Security;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class Properties {
|
public class Properties {
|
||||||
@ConfigurationComment("Do you want to turn off the automatic updates of ChestShop?")
|
|
||||||
public static boolean TURN_OFF_UPDATES = false;
|
static {
|
||||||
|
Configuration.registerParser("StringSet", new ValueParser() {
|
||||||
|
@Override
|
||||||
|
public <T> Object parseToJava(Class<T> type, Object object) {
|
||||||
|
if (object instanceof Collection) {
|
||||||
|
return new LinkedHashSet<>((Collection<String>) object);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Configuration.registerParser("MaterialSet", new ValueParser() {
|
||||||
|
@Override
|
||||||
|
public <T> Object parseToJava(Class<T> type, Object object) {
|
||||||
|
if (object instanceof Collection) {
|
||||||
|
EnumSet<Material> set = EnumSet.noneOf(Material.class);
|
||||||
|
for (Object o : (Collection) object) {
|
||||||
|
if (o instanceof Material) {
|
||||||
|
set.add((Material) o);
|
||||||
|
} else if (o instanceof String) {
|
||||||
|
Material m = Material.getMaterial(((String) o).toUpperCase(Locale.ROOT));
|
||||||
|
if (m != null) {
|
||||||
|
set.add(m);
|
||||||
|
} else {
|
||||||
|
ChestShop.getBukkitLogger().log(Level.WARNING, o + " is not a valid Material name in the config!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Configuration.registerParser("BigDecimal", new ValueParser() {
|
||||||
|
@Override
|
||||||
|
public String parseToYAML(Object object) {
|
||||||
|
if (object instanceof BigDecimal) {
|
||||||
|
return object.toString();
|
||||||
|
}
|
||||||
|
return super.parseToYAML(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> Object parseToJava(Class<T> type, Object object) {
|
||||||
|
if (object instanceof Double) {
|
||||||
|
return BigDecimal.valueOf((Double) object);
|
||||||
|
} else if (object instanceof Long) {
|
||||||
|
return BigDecimal.valueOf((Long) object);
|
||||||
|
} else if (object instanceof Integer) {
|
||||||
|
return BigDecimal.valueOf((Integer) object);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Configuration.registerParser("UUID", new ValueParser() {
|
||||||
|
@Override
|
||||||
|
public String parseToYAML(Object object) {
|
||||||
|
if (object instanceof UUID) {
|
||||||
|
return object.toString();
|
||||||
|
}
|
||||||
|
return super.parseToYAML(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> Object parseToJava(Class<T> type, Object object) {
|
||||||
|
if (object instanceof String) {
|
||||||
|
return UUID.fromString((String) object);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigurationComment("Should the plugin log some messages that are useful for debugging?")
|
||||||
|
public static boolean DEBUG = false;
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("How large should the internal uuid and name caches be?")
|
@ConfigurationComment("Do you want to turn off the automatic updates of ChestShop?")
|
||||||
|
public static boolean TURN_OFF_UPDATES = true;
|
||||||
|
|
||||||
|
@ConfigurationComment("Do you want to turn off the automatic notifications for releases?")
|
||||||
|
public static boolean TURN_OFF_UPDATE_NOTIFIER = false;
|
||||||
|
|
||||||
|
@ConfigurationComment("Do you want to turn off the automatic notifications for new development builds?")
|
||||||
|
public static boolean TURN_OFF_DEV_UPDATE_NOTIFIER = false;
|
||||||
|
|
||||||
|
@ConfigurationComment("Do you want to include some values of this config in the metrics? (This will not submit any sensitive data and helps in the development process)")
|
||||||
|
public static boolean INCLUDE_SETTINGS_IN_METRICS = true;
|
||||||
|
|
||||||
|
@PrecededBySpace
|
||||||
|
@ConfigurationComment("How large should the internal caches be?")
|
||||||
public static int CACHE_SIZE = 1000;
|
public static int CACHE_SIZE = 1000;
|
||||||
|
|
||||||
|
@PrecededBySpace
|
||||||
|
@ConfigurationComment("The default language when the client's language can't be found.")
|
||||||
|
public static String DEFAULT_LANGUAGE = "en";
|
||||||
|
|
||||||
|
@ConfigurationComment("Should the plugin try to use a language file that matches the client's locale setting?")
|
||||||
|
public static boolean USE_CLIENT_LOCALE = true;
|
||||||
|
|
||||||
|
@ConfigurationComment("Should the plugin strip the colors from formatted price?")
|
||||||
|
public static boolean STRIP_PRICE_COLORS = false;
|
||||||
|
|
||||||
|
@PrecededBySpace
|
||||||
|
@ConfigurationComment("What containers are allowed to hold a shop? (Only blocks with inventories work!)")
|
||||||
|
@Parser("MaterialSet")
|
||||||
|
public static Set<Material> SHOP_CONTAINERS = EnumSet.of(
|
||||||
|
Material.CHEST,
|
||||||
|
Material.TRAPPED_CHEST
|
||||||
|
);
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("(In 1/1000th of a second) How often can a player use the shop sign?")
|
@ConfigurationComment("(In 1/1000th of a second) How often can a player use the shop sign?")
|
||||||
public static int SHOP_INTERACTION_INTERVAL = 250;
|
public static int SHOP_INTERACTION_INTERVAL = 250;
|
||||||
|
|
||||||
@ConfigurationComment("Do you want to allow using shops to people in creative mode?")
|
@ConfigurationComment("Do you want to block people in creative mode from using shops?")
|
||||||
public static boolean IGNORE_CREATIVE_MODE = true;
|
public static boolean IGNORE_CREATIVE_MODE = true;
|
||||||
|
|
||||||
|
@ConfigurationComment("Do you want to block people who have access to a shop due to their permissions from using it? (owners are always ignored)")
|
||||||
|
public static boolean IGNORE_ACCESS_PERMS = true;
|
||||||
|
|
||||||
@ConfigurationComment("If true, people will buy with left-click and sell with right-click.")
|
@ConfigurationComment("If true, people will buy with left-click and sell with right-click.")
|
||||||
public static boolean REVERSE_BUTTONS = false;
|
public static boolean REVERSE_BUTTONS = false;
|
||||||
|
|
||||||
@ConfigurationComment("If true, people will be able to buy/sell in 64 stacks while holding the crouch button.")
|
@ConfigurationComment("If true, people will be able to buy/sell in 64 stacks while holding the crouch button.")
|
||||||
public static boolean SHIFT_SELLS_IN_STACKS = false;
|
public static boolean SHIFT_SELLS_IN_STACKS = false;
|
||||||
|
|
||||||
|
@ConfigurationComment("If true, people will be able to sell/buy everything available of the same type.")
|
||||||
|
public static boolean SHIFT_SELLS_EVERYTHING = false;
|
||||||
|
|
||||||
@ConfigurationComment("What can you do by clicking shift with SHIFT_SELLS_IN_STACKS turned on? (ALL/BUY/SELL)")
|
@ConfigurationComment("What can you do by clicking shift with SHIFT_SELLS_IN_STACKS turned on? (ALL/BUY/SELL)")
|
||||||
public static String SHIFT_ALLOWS = "ALL";
|
public static String SHIFT_ALLOWS = "ALL";
|
||||||
|
|
||||||
@ConfigurationComment("Can shop's chest be opened by owner with right-clicking a shop's sign?")
|
@ConfigurationComment("Can shop's chest be opened by owner with right-clicking a shop's sign?")
|
||||||
public static boolean ALLOW_SIGN_CHEST_OPEN = true;
|
public static boolean ALLOW_SIGN_CHEST_OPEN = false;
|
||||||
|
|
||||||
|
@ConfigurationComment("If true and in 1.14+, the owner of a chest shop can click with a dye / ink sac to dye the sign.")
|
||||||
|
public static boolean SIGN_DYING = true;
|
||||||
|
|
||||||
@ConfigurationComment("If true, when you left-click your own shop sign you won't open chest's inventory, but instead you will start destroying the sign.")
|
@ConfigurationComment("If true, when you left-click your own shop sign you won't open chest's inventory, but instead you will start destroying the sign.")
|
||||||
public static boolean ALLOW_LEFT_CLICK_DESTROYING = true;
|
public static boolean ALLOW_LEFT_CLICK_DESTROYING = true;
|
||||||
|
@ -43,29 +172,54 @@ public class Properties {
|
||||||
@ConfigurationComment("If true, if the REMOVE_EMPTY_SHOPS option is turned on, the chest is also destroyed.")
|
@ConfigurationComment("If true, if the REMOVE_EMPTY_SHOPS option is turned on, the chest is also destroyed.")
|
||||||
public static boolean REMOVE_EMPTY_CHESTS = false;
|
public static boolean REMOVE_EMPTY_CHESTS = false;
|
||||||
|
|
||||||
|
@ConfigurationComment("A list of worlds in which to remove empty shops with the previous config. Case sensitive. An empty list means all worlds.")
|
||||||
|
@Parser("StringSet")
|
||||||
|
public static Set<String> REMOVE_EMPTY_WORLDS = new LinkedHashSet<>(Arrays.asList("world1", "world2"));
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("First line of your Admin Shop's sign should look like this:")
|
@ConfigurationComment("First line of your Admin Shop's sign should look like this:")
|
||||||
public static String ADMIN_SHOP_NAME = "Admin Shop";
|
public static String ADMIN_SHOP_NAME = "Admin Shop";
|
||||||
|
|
||||||
@ConfigurationComment("The economy account which Admin Shops should use and to which all taxes will go")
|
@ConfigurationComment("Make all admin shops be unlimited even if they have a shop container at the sign")
|
||||||
|
public static boolean FORCE_UNLIMITED_ADMIN_SHOP = false;
|
||||||
|
|
||||||
|
@ConfigurationComment("The name of the economy account which Admin Shops should use and to which all taxes will go")
|
||||||
public static String SERVER_ECONOMY_ACCOUNT = "";
|
public static String SERVER_ECONOMY_ACCOUNT = "";
|
||||||
|
|
||||||
|
@ConfigurationComment("The uuid of the economy account for the Admin Shop. Useful for fake accounts as normally only accounts of players work")
|
||||||
|
public static UUID SERVER_ECONOMY_ACCOUNT_UUID = new UUID(0, 0);
|
||||||
|
|
||||||
@ConfigurationComment("Percent of the price that should go to the server's account. (100 = 100 percent)")
|
@ConfigurationComment("Percent of the price that should go to the server's account. (100 = 100 percent)")
|
||||||
public static int TAX_AMOUNT = 0;
|
public static double TAX_AMOUNT = 0;
|
||||||
|
|
||||||
@ConfigurationComment("Percent of the price that should go to the server's account when buying from an Admin Shop.")
|
@ConfigurationComment("Percent of the price that should go to the server's account when buying from an Admin Shop.")
|
||||||
public static int SERVER_TAX_AMOUNT = 0;
|
public static double SERVER_TAX_AMOUNT = 0;
|
||||||
|
|
||||||
@ConfigurationComment("Amount of money player must pay to create a shop")
|
@ConfigurationComment("Amount of money player must pay to create a shop")
|
||||||
public static double SHOP_CREATION_PRICE = 0;
|
public static BigDecimal SHOP_CREATION_PRICE = BigDecimal.valueOf(0);
|
||||||
|
|
||||||
@ConfigurationComment("How much money do you get back when destroying a sign?")
|
@ConfigurationComment("How much money do you get back when destroying a sign?")
|
||||||
public static double SHOP_REFUND_PRICE = 0;
|
public static BigDecimal SHOP_REFUND_PRICE = BigDecimal.valueOf(0);
|
||||||
|
|
||||||
|
@ConfigurationComment("How many decimal places are allowed at a maximum for prices?")
|
||||||
|
public static int PRICE_PRECISION = 2;
|
||||||
|
|
||||||
|
@ConfigurationComment("This makes sure that the UUIDs of player shop accounts match the server's online-mode setting. Disabling this might lead to issues with offline players and is therefore unsupported!")
|
||||||
|
public static boolean ENSURE_CORRECT_PLAYERID = true;
|
||||||
|
|
||||||
|
@ConfigurationComment("This regexp validates the name of the player. If the name doesn't match, the player will neither be able to create a valid shop sign, nor buy/sell from a shop.\n" +
|
||||||
|
"Note for Bedrock support: If you have Floodgate on your server, you should set this regexp to ^\\\\.?\\\\w+$ and ENSURE_CORRECT_PLAYERID to false\n" +
|
||||||
|
"If your Floodgate prefix is not a dot, then change the first . in the regexp (the one before the question mark) to whatever your prefix is.")
|
||||||
|
public static String VALID_PLAYERNAME_REGEXP = "^\\w+$";
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("Should we block shops that sell things for more than they buy? (This prevents newbies from creating shops that would be exploited)")
|
@ConfigurationComment("Should we block shops that sell things for more than they buy? (This prevents newbies from creating shops that would be exploited)")
|
||||||
public static boolean BLOCK_SHOPS_WITH_SELL_PRICE_HIGHER_THAN_BUY_PRICE = true;
|
public static boolean BLOCK_SHOPS_WITH_SELL_PRICE_HIGHER_THAN_BUY_PRICE = true;
|
||||||
|
|
||||||
|
@PrecededBySpace
|
||||||
|
@ConfigurationComment("Maximum amount of items that can be bought/sold at a shop. Default 3456 is a double chest of 64 stacks.")
|
||||||
|
public static int MAX_SHOP_AMOUNT = 3456;
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("Do you want to allow other players to build a shop on a block where there's one already?")
|
@ConfigurationComment("Do you want to allow other players to build a shop on a block where there's one already?")
|
||||||
public static boolean ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK = false;
|
public static boolean ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK = false;
|
||||||
|
@ -76,11 +230,17 @@ public class Properties {
|
||||||
@ConfigurationComment("Can '?' be put in place of item name in order for the sign to be auto-filled?")
|
@ConfigurationComment("Can '?' be put in place of item name in order for the sign to be auto-filled?")
|
||||||
public static boolean ALLOW_AUTO_ITEM_FILL = true;
|
public static boolean ALLOW_AUTO_ITEM_FILL = true;
|
||||||
|
|
||||||
|
@PrecededBySpace
|
||||||
|
@ConfigurationComment("Enable this if you use BungeeCord and want players to receive shop notifications on other servers")
|
||||||
|
public static boolean BUNGEECORD_MESSAGES = false;
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("Do you want to show \"Out of stock\" messages?")
|
@ConfigurationComment("Do you want to show \"Out of stock\" messages?")
|
||||||
public static boolean SHOW_MESSAGE_OUT_OF_STOCK = true;
|
public static boolean SHOW_MESSAGE_OUT_OF_STOCK = true;
|
||||||
@ConfigurationComment("Do you want to show \"Full shop\" messages?")
|
@ConfigurationComment("Do you want to show \"Full shop\" messages?")
|
||||||
public static boolean SHOW_MESSAGE_FULL_SHOP = true;
|
public static boolean SHOW_MESSAGE_FULL_SHOP = true;
|
||||||
|
@ConfigurationComment("How many seconds do you want to wait before showing notifications for the same shop to the owner again?")
|
||||||
|
public static long NOTIFICATION_MESSAGE_COOLDOWN = 10;
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("Can players hide the \"Out of stock\" messages with /cstoggle?")
|
@ConfigurationComment("Can players hide the \"Out of stock\" messages with /cstoggle?")
|
||||||
|
@ -98,9 +258,12 @@ public class Properties {
|
||||||
@ConfigurationComment("If true, plugin will log transactions in its own file")
|
@ConfigurationComment("If true, plugin will log transactions in its own file")
|
||||||
public static boolean LOG_TO_FILE = false;
|
public static boolean LOG_TO_FILE = false;
|
||||||
|
|
||||||
@ConfigurationComment("Do you want ChestShop's messages to show up in console?")
|
@ConfigurationComment("Do you want ChestShop's transaction messages to show up in console?")
|
||||||
public static boolean LOG_TO_CONSOLE = true;
|
public static boolean LOG_TO_CONSOLE = true;
|
||||||
|
|
||||||
|
@ConfigurationComment("Should all shop removals be logged?")
|
||||||
|
public static boolean LOG_ALL_SHOP_REMOVALS = true;
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("Do you want to stack all items up to 64 item stacks?")
|
@ConfigurationComment("Do you want to stack all items up to 64 item stacks?")
|
||||||
public static boolean STACK_TO_64 = false;
|
public static boolean STACK_TO_64 = false;
|
||||||
|
@ -117,20 +280,32 @@ public class Properties {
|
||||||
@ConfigurationComment("Do you want to turn off the default sign protection? Warning! Other players will be able to destroy other people's shops!")
|
@ConfigurationComment("Do you want to turn off the default sign protection? Warning! Other players will be able to destroy other people's shops!")
|
||||||
public static boolean TURN_OFF_SIGN_PROTECTION = false;
|
public static boolean TURN_OFF_SIGN_PROTECTION = false;
|
||||||
|
|
||||||
@ConfigurationComment("Do you want to disable the hopper protection, which prevents the hoppers from taking items out of chests?")
|
@ConfigurationComment("Do you want to disable the hopper protection, which prevents Hopper-Minecarts from taking items out of shops?")
|
||||||
public static boolean TURN_OFF_HOPPER_PROTECTION = false;
|
public static boolean TURN_OFF_HOPPER_PROTECTION = false;
|
||||||
|
|
||||||
|
@ConfigurationComment("Only allow users to buy/sell that have access to the sign's protection? (E.g. LWC protection)")
|
||||||
|
public static boolean CHECK_ACCESS_FOR_SHOP_USE = false;
|
||||||
|
|
||||||
@ConfigurationComment("Do you want to protect shop chests with LWC?")
|
@ConfigurationComment("Do you want to protect shop chests with LWC?")
|
||||||
public static boolean PROTECT_CHEST_WITH_LWC = false;
|
public static boolean PROTECT_CHEST_WITH_LWC = false;
|
||||||
|
|
||||||
|
@ConfigurationComment("Of which type should the container protection be? Possible type: public, private, donate and on some LWC versions display")
|
||||||
|
public static Security.Type LWC_CHEST_PROTECTION_TYPE = Security.Type.PRIVATE;
|
||||||
|
|
||||||
@ConfigurationComment("Do you want to protect shop signs with LWC?")
|
@ConfigurationComment("Do you want to protect shop signs with LWC?")
|
||||||
public static boolean PROTECT_SIGN_WITH_LWC = false;
|
public static boolean PROTECT_SIGN_WITH_LWC = false;
|
||||||
|
|
||||||
|
@ConfigurationComment("Of which type should the sign protection be? Possible type: public, private, donate and on some LWC versions display")
|
||||||
|
public static Security.Type LWC_SIGN_PROTECTION_TYPE = Security.Type.PRIVATE;
|
||||||
|
|
||||||
@ConfigurationComment("Should the chest's LWC protection be removed once the shop sign is destroyed? ")
|
@ConfigurationComment("Should the chest's LWC protection be removed once the shop sign is destroyed? ")
|
||||||
public static boolean REMOVE_LWC_PROTECTION_AUTOMATICALLY = true;
|
public static boolean REMOVE_LWC_PROTECTION_AUTOMATICALLY = true;
|
||||||
|
|
||||||
|
@ConfigurationComment("Should LWC limits block shop creations?")
|
||||||
|
public static boolean LWC_LIMITS_BLOCK_CREATION = true;
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("Do you want to only let people build inside regions?")
|
@ConfigurationComment("Do you want to only let people build inside WorldGuard regions?")
|
||||||
public static boolean WORLDGUARD_INTEGRATION = false;
|
public static boolean WORLDGUARD_INTEGRATION = false;
|
||||||
|
|
||||||
@ConfigurationComment("Do you want to only let people build inside region flagged by doing /region regionName flag allow-shop allow?")
|
@ConfigurationComment("Do you want to only let people build inside region flagged by doing /region regionName flag allow-shop allow?")
|
||||||
|
@ -139,6 +314,14 @@ public class Properties {
|
||||||
@ConfigurationComment("Do you want ChestShop to respect WorldGuard's chest protection?")
|
@ConfigurationComment("Do you want ChestShop to respect WorldGuard's chest protection?")
|
||||||
public static boolean WORLDGUARD_USE_PROTECTION = false;
|
public static boolean WORLDGUARD_USE_PROTECTION = false;
|
||||||
|
|
||||||
|
@PrecededBySpace
|
||||||
|
@ConfigurationComment("Do you want to only let people build inside GriefPrevention claims?")
|
||||||
|
public static boolean GRIEFPREVENTION_INTEGRATION = false;
|
||||||
|
|
||||||
|
@PrecededBySpace
|
||||||
|
@ConfigurationComment("Do you want to only let people build inside RedProtect regions?")
|
||||||
|
public static boolean REDPROTECT_INTEGRATION = false;
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("Do you want to deny shop access to unlogged users?")
|
@ConfigurationComment("Do you want to deny shop access to unlogged users?")
|
||||||
public static boolean AUTHME_HOOK = true;
|
public static boolean AUTHME_HOOK = true;
|
||||||
|
@ -149,8 +332,12 @@ public class Properties {
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("How much Heroes exp should people get for creating a ChestShop?")
|
@ConfigurationComment("How much Heroes exp should people get for creating a ChestShop?")
|
||||||
public static double HEROES_EXP = 100;
|
public static double HEROES_EXP = 100;
|
||||||
|
|
||||||
@PrecededBySpace
|
@PrecededBySpace
|
||||||
@ConfigurationComment("Add icons and make item names hoverable in transaction messages when ShowItem is installed?")
|
@ConfigurationComment("Add icons and make item names hoverable in transaction messages when ShowItem is installed?")
|
||||||
public static boolean SHOWITEM_MESSAGE = true;
|
public static boolean SHOWITEM_MESSAGE = true;
|
||||||
|
|
||||||
|
@PrecededBySpace
|
||||||
|
@ConfigurationComment("Add stock counter to quantity line?")
|
||||||
|
public static boolean USE_STOCK_COUNTER = false;
|
||||||
}
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
package com.Acrobot.ChestShop.Containers;
|
package com.Acrobot.ChestShop.Containers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
|
import com.Acrobot.Breeze.Utils.MaterialUtil;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
@ -17,6 +19,14 @@ import org.bukkit.inventory.ItemStack;
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class AdminInventory implements Inventory {
|
public class AdminInventory implements Inventory {
|
||||||
|
|
||||||
|
private ItemStack[] content;
|
||||||
|
private int maxStackSize = 64;
|
||||||
|
|
||||||
|
public AdminInventory(ItemStack[] content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
|
@ -24,106 +34,112 @@ public class AdminInventory implements Inventory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxStackSize() {
|
public int getMaxStackSize() {
|
||||||
return Integer.MAX_VALUE;
|
return maxStackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMaxStackSize(int i) {
|
public void setMaxStackSize(int i) {
|
||||||
|
maxStackSize = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Admin inventory";
|
return "Admin inventory";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(int i) {
|
public ItemStack getItem(int i) {
|
||||||
|
if (content.length > i) {
|
||||||
|
return content[i];
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItem(int i, ItemStack itemStack) {
|
public void setItem(int i, ItemStack itemStack) {
|
||||||
|
if (i > getSize()) {
|
||||||
|
throw new IllegalArgumentException("Slot is outside inventory. Max size is " + getSize());
|
||||||
|
}
|
||||||
|
if (i >= content.length) {
|
||||||
|
content = Arrays.copyOfRange(content, 0, i);
|
||||||
|
}
|
||||||
|
content[i] = itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<Integer, ItemStack> addItem(ItemStack... itemStacks) {
|
public HashMap<Integer, ItemStack> addItem(ItemStack... itemStacks) {
|
||||||
return new HashMap<Integer, ItemStack>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... itemStacks) {
|
public HashMap<Integer, ItemStack> removeItem(ItemStack... itemStacks) {
|
||||||
return new HashMap<Integer, ItemStack>();
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Integer, ItemStack> removeItemAnySlot(ItemStack... items) throws IllegalArgumentException {
|
||||||
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack[] getContents() {
|
public ItemStack[] getContents() {
|
||||||
return new ItemStack[]{
|
return content;
|
||||||
new ItemStack(Material.CHEST, 1),
|
|
||||||
new ItemStack(Material.AIR, Integer.MAX_VALUE)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContents(ItemStack[] itemStacks) {
|
public void setContents(ItemStack[] itemStacks) {
|
||||||
|
content = itemStacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack[] getStorageContents() {
|
public ItemStack[] getStorageContents() {
|
||||||
return new ItemStack[0];
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStorageContents(ItemStack[] itemStacks) throws IllegalArgumentException {
|
public void setStorageContents(ItemStack[] itemStacks) throws IllegalArgumentException {
|
||||||
|
content = itemStacks;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(int i) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Material material) {
|
public boolean contains(Material material) {
|
||||||
return true;
|
return first(material) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(ItemStack itemStack) {
|
public boolean contains(ItemStack itemStack) {
|
||||||
return true;
|
return first(itemStack) > -1;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(int i, int i1) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Material material, int i) {
|
public boolean contains(Material material, int i) {
|
||||||
return true;
|
int amount = 0;
|
||||||
|
for (ItemStack item : content) {
|
||||||
|
if (item != null && item.getType() == material) {
|
||||||
|
amount += item.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return amount >= i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(ItemStack itemStack, int i) {
|
public boolean contains(ItemStack itemStack, int i) {
|
||||||
return true;
|
int amount = 0;
|
||||||
|
for (ItemStack item : content) {
|
||||||
|
if (MaterialUtil.equals(item, itemStack)) {
|
||||||
|
amount += itemStack.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return amount >= i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAtLeast(ItemStack itemStack, int i) {
|
public boolean containsAtLeast(ItemStack itemStack, int i) {
|
||||||
return true;
|
return contains(itemStack, i);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HashMap<Integer, ? extends ItemStack> all(int i) {
|
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
|
||||||
items.put(1, new ItemStack(i, Integer.MAX_VALUE));
|
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<Integer, ? extends ItemStack> all(Material material) {
|
public HashMap<Integer, ? extends ItemStack> all(Material material) {
|
||||||
|
HashMap<Integer, ItemStack> items = new HashMap<>();
|
||||||
if (material.getMaxDurability() != 0) {
|
if (material.getMaxDurability() != 0) {
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
|
||||||
|
|
||||||
for (short currentDurability = 0; currentDurability < material.getMaxDurability(); currentDurability++) {
|
for (short currentDurability = 0; currentDurability < material.getMaxDurability(); currentDurability++) {
|
||||||
items.put((int) currentDurability, new ItemStack(material, Integer.MAX_VALUE, currentDurability));
|
items.put((int) currentDurability, new ItemStack(material, Integer.MAX_VALUE, currentDurability));
|
||||||
|
@ -132,34 +148,42 @@ public class AdminInventory implements Inventory {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
return all(material.getId());
|
items.put(1, new ItemStack(material, Integer.MAX_VALUE));
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<Integer, ? extends ItemStack> all(ItemStack itemStack) {
|
public HashMap<Integer, ? extends ItemStack> all(ItemStack itemStack) {
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
||||||
|
|
||||||
ItemStack clone = itemStack.clone();
|
if (itemStack != null) {
|
||||||
clone.setAmount(Integer.MAX_VALUE);
|
ItemStack clone = itemStack.clone();
|
||||||
|
clone.setAmount(Integer.MAX_VALUE);
|
||||||
|
|
||||||
items.put(1, clone);
|
items.put(1, clone);
|
||||||
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int first(int i) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int first(Material material) {
|
public int first(Material material) {
|
||||||
return 0;
|
for (int i = 0; i < content.length; i++) {
|
||||||
|
if (content[i] != null && content[i].getType() == material) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int first(ItemStack itemStack) {
|
public int first(ItemStack itemStack) {
|
||||||
return 0;
|
for (int i = 0; i < content.length; i++) {
|
||||||
|
if (MaterialUtil.equals(content[i], itemStack)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -167,8 +191,8 @@ public class AdminInventory implements Inventory {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean isEmpty() {
|
||||||
public void remove(int i) {
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -187,12 +211,15 @@ public class AdminInventory implements Inventory {
|
||||||
public void clear() {
|
public void clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int close() {
|
||||||
public List<HumanEntity> getViewers() {
|
return 0;
|
||||||
return new ArrayList<HumanEntity>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public List<HumanEntity> getViewers() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return "Admin inventory";
|
return "Admin inventory";
|
||||||
}
|
}
|
||||||
|
@ -207,14 +234,18 @@ public class AdminInventory implements Inventory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public InventoryHolder getHolder(boolean useSnapshot) {
|
||||||
public ListIterator<ItemStack> iterator() {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListIterator<ItemStack> iterator() {
|
||||||
|
return Arrays.asList(content).listIterator();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListIterator<ItemStack> iterator(int i) {
|
public ListIterator<ItemStack> iterator(int i) {
|
||||||
return null;
|
return Arrays.asList(content).listIterator(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,8 +33,12 @@ public class Account {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Account(String name, UUID uuid) {
|
public Account(String name, UUID uuid) {
|
||||||
|
this(name, NameUtil.stripUsername(name), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Account(String name, String shortName, UUID uuid) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.shortName = NameUtil.stripUsername(name);
|
this.shortName = shortName;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import com.Acrobot.ChestShop.ChestShop;
|
||||||
import com.j256.ormlite.dao.Dao;
|
import com.j256.ormlite.dao.Dao;
|
||||||
import com.j256.ormlite.dao.DaoManager;
|
import com.j256.ormlite.dao.DaoManager;
|
||||||
import com.j256.ormlite.dao.LruObjectCache;
|
import com.j256.ormlite.dao.LruObjectCache;
|
||||||
import com.j256.ormlite.db.SqliteDatabaseType;
|
|
||||||
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
||||||
|
import com.j256.ormlite.jdbc.db.SqliteDatabaseType;
|
||||||
import com.j256.ormlite.support.ConnectionSource;
|
import com.j256.ormlite.support.ConnectionSource;
|
||||||
import com.j256.ormlite.table.TableUtils;
|
import com.j256.ormlite.table.TableUtils;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class Item {
|
||||||
@DatabaseField(canBeNull = false, generatedId = true)
|
@DatabaseField(canBeNull = false, generatedId = true)
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@DatabaseField(columnName = "code", canBeNull = false, unique = true)
|
@DatabaseField(columnName = "code", canBeNull = false, index = true)
|
||||||
private String base64ItemCode;
|
private String base64ItemCode;
|
||||||
|
|
||||||
public Item() {
|
public Item() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.j256.ormlite.dao.CloseableIterator;
|
||||||
import com.j256.ormlite.dao.Dao;
|
import com.j256.ormlite.dao.Dao;
|
||||||
import com.j256.ormlite.dao.GenericRawResults;
|
import com.j256.ormlite.dao.GenericRawResults;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -16,7 +17,7 @@ import java.util.logging.Level;
|
||||||
* @author Andrzej Pomirski
|
* @author Andrzej Pomirski
|
||||||
*/
|
*/
|
||||||
public class Migrations {
|
public class Migrations {
|
||||||
public static final int CURRENT_DATABASE_VERSION = 3;
|
public static final int CURRENT_DATABASE_VERSION = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migrates a database from the given version
|
* Migrates a database from the given version
|
||||||
|
@ -27,8 +28,6 @@ public class Migrations {
|
||||||
public static int migrate(int currentVersion) {
|
public static int migrate(int currentVersion) {
|
||||||
if (currentVersion != CURRENT_DATABASE_VERSION) {
|
if (currentVersion != CURRENT_DATABASE_VERSION) {
|
||||||
ChestShop.getBukkitLogger().info("Updating database...");
|
ChestShop.getBukkitLogger().info("Updating database...");
|
||||||
} else {
|
|
||||||
return CURRENT_DATABASE_VERSION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (currentVersion) {
|
switch (currentVersion) {
|
||||||
|
@ -45,6 +44,12 @@ public class Migrations {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
|
if (migrateTo4()) {
|
||||||
|
currentVersion++;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
//do nothing
|
//do nothing
|
||||||
|
@ -60,7 +65,7 @@ public class Migrations {
|
||||||
accounts.executeRaw("ALTER TABLE `accounts` ADD COLUMN lastSeenName VARCHAR");
|
accounts.executeRaw("ALTER TABLE `accounts` ADD COLUMN lastSeenName VARCHAR");
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while migrating database to v2", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,14 +109,41 @@ public class Migrations {
|
||||||
lastInfo = System.currentTimeMillis();
|
lastInfo = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results.close();
|
try {
|
||||||
|
results.close();
|
||||||
|
} catch (Exception e1) {
|
||||||
|
ChestShop.getBukkitLogger().log(Level.WARNING, "Error while closing results! " + e.getMessage());
|
||||||
|
}
|
||||||
ChestShop.getBukkitLogger().log(Level.INFO, success + " accounts successfully migrated. " + error + " accounts failed to migrate!");
|
ChestShop.getBukkitLogger().log(Level.INFO, success + " accounts successfully migrated. " + error + " accounts failed to migrate!");
|
||||||
}
|
}
|
||||||
ChestShop.getBukkitLogger().log(Level.INFO, "Migration of accounts table finished in " + (System.currentTimeMillis() - start) / 1000.0 + "s!");
|
ChestShop.getBukkitLogger().log(Level.INFO, "Migration of accounts table finished in " + (System.currentTimeMillis() - start) / 1000.0 + "s!");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while migrating database to v3", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean migrateTo4() {
|
||||||
|
try {
|
||||||
|
Dao<Item, Integer> itemsOld = DaoCreator.getDao(Item.class);
|
||||||
|
|
||||||
|
itemsOld.executeRawNoArgs("ALTER TABLE `items` RENAME TO `items-old`");
|
||||||
|
|
||||||
|
Dao<Item, Integer> items = DaoCreator.getDaoAndCreateTable(Item.class);
|
||||||
|
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
items.executeRawNoArgs("INSERT INTO `items` (id, code) SELECT id, code uuid FROM `items-old`");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while inserting items into new database while migrating to v4", e);
|
||||||
|
}
|
||||||
|
ChestShop.getBukkitLogger().log(Level.INFO, "Migration of items table finished in " + (System.currentTimeMillis() - start) / 1000.0 + "s!");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while migrating database to v4", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,35 @@ package com.Acrobot.ChestShop;
|
||||||
|
|
||||||
import com.Acrobot.Breeze.Utils.MaterialUtil;
|
import com.Acrobot.Breeze.Utils.MaterialUtil;
|
||||||
import com.Acrobot.ChestShop.Configuration.Properties;
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Economy.EconomyAdapter;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Economy.Plugins.ReserveListener;
|
||||||
import com.Acrobot.ChestShop.Listeners.Economy.Plugins.VaultListener;
|
import com.Acrobot.ChestShop.Listeners.Economy.Plugins.VaultListener;
|
||||||
import com.Acrobot.ChestShop.Plugins.*;
|
import com.Acrobot.ChestShop.Plugins.*;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.bstats.charts.DrilldownPie;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class Dependencies {
|
public class Dependencies implements Listener {
|
||||||
public static void loadPlugins() {
|
|
||||||
|
private static final Map<String, String> versions = new HashMap<>();
|
||||||
|
|
||||||
|
public static void initializePlugins() {
|
||||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||||
|
|
||||||
for (String dependency : ChestShop.getDependencies()) {
|
for (String dependency : ChestShop.getDependencies()) {
|
||||||
|
@ -25,20 +40,6 @@ public class Dependencies {
|
||||||
initializePlugin(dependency, plugin);
|
initializePlugin(dependency, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadEconomy();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadEconomy() {
|
|
||||||
String plugin = "Vault";
|
|
||||||
Listener economy = VaultListener.initializeVault();
|
|
||||||
|
|
||||||
if (economy == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChestShop.registerListener(economy);
|
|
||||||
ChestShop.getBukkitLogger().info(plugin + " loaded! Found an economy plugin!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializePlugin(String name, Plugin plugin) { //Really messy, right? But it's short and fast :)
|
private static void initializePlugin(String name, Plugin plugin) { //Really messy, right? But it's short and fast :)
|
||||||
|
@ -50,6 +51,82 @@ public class Dependencies {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (dependency) {
|
||||||
|
//Terrain protection plugins
|
||||||
|
case WorldGuard:
|
||||||
|
WorldGuardFlags.ENABLE_SHOP.getName(); // force the static code to run
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginDescriptionFile description = plugin.getDescription();
|
||||||
|
ChestShop.getBukkitLogger().info(description.getName() + " version " + description.getVersion() + " loaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean loadPlugins() {
|
||||||
|
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||||
|
|
||||||
|
for (String dependency : ChestShop.getDependencies()) {
|
||||||
|
Plugin plugin = pluginManager.getPlugin(dependency);
|
||||||
|
|
||||||
|
if (plugin != null && plugin.isEnabled()) {
|
||||||
|
try {
|
||||||
|
loadPlugin(dependency, plugin);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().log(Level.WARNING, "Unable to hook into " + plugin.getName() + " " + plugin.getDescription().getVersion(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadEconomy()) {
|
||||||
|
Map<String, Map<String, Integer>> map = versions.entrySet().stream()
|
||||||
|
.map(e -> new AbstractMap.SimpleEntry<String, Map<String, Integer>>(e.getKey(), ImmutableMap.of(e.getValue(), 1)))
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
AbstractMap.SimpleEntry::getKey,
|
||||||
|
AbstractMap.SimpleEntry::getValue
|
||||||
|
));
|
||||||
|
ChestShop.getMetrics().addCustomChart(new DrilldownPie("dependencies", () -> map));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean loadEconomy() {
|
||||||
|
String plugin = "none";
|
||||||
|
|
||||||
|
EconomyAdapter economy = null;
|
||||||
|
|
||||||
|
if(Bukkit.getPluginManager().getPlugin("Reserve") != null) {
|
||||||
|
plugin = "Reserve";
|
||||||
|
economy = ReserveListener.prepareListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Bukkit.getPluginManager().getPlugin("Vault") != null) {
|
||||||
|
plugin = "Vault";
|
||||||
|
economy = VaultListener.initializeVault();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (economy == null) {
|
||||||
|
ChestShop.getBukkitLogger().severe("No Economy adapter found! You need to install either Vault or Reserve!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChestShop.getMetrics().addCustomChart(ChestShop.createStaticDrilldownStat("economyAdapter", plugin, Bukkit.getPluginManager().getPlugin(plugin).getDescription().getVersion()));
|
||||||
|
ChestShop.getMetrics().addCustomChart(ChestShop.createStaticDrilldownStat("economyPlugin", economy.getProviderInfo().getName(), economy.getProviderInfo().getVersion()));
|
||||||
|
|
||||||
|
ChestShop.registerListener(economy);
|
||||||
|
ChestShop.getBukkitLogger().info(plugin + " loaded!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void loadPlugin(String name, Plugin plugin) { //Really messy, right? But it's short and fast :)
|
||||||
|
Dependency dependency;
|
||||||
|
|
||||||
|
try {
|
||||||
|
dependency = Dependency.valueOf(name);
|
||||||
|
} catch (IllegalArgumentException exception) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Listener listener = null;
|
Listener listener = null;
|
||||||
|
|
||||||
switch (dependency) {
|
switch (dependency) {
|
||||||
|
@ -60,12 +137,18 @@ public class Dependencies {
|
||||||
case Lockette:
|
case Lockette:
|
||||||
listener = new Lockette();
|
listener = new Lockette();
|
||||||
break;
|
break;
|
||||||
|
case LockettePro:
|
||||||
|
listener = new LockettePro();
|
||||||
|
break;
|
||||||
case Deadbolt:
|
case Deadbolt:
|
||||||
listener = new Deadbolt();
|
listener = new Deadbolt();
|
||||||
break;
|
break;
|
||||||
case SimpleChestLock:
|
case SimpleChestLock:
|
||||||
listener = SimpleChestLock.getSimpleChestLock(plugin);
|
listener = SimpleChestLock.getSimpleChestLock(plugin);
|
||||||
break;
|
break;
|
||||||
|
case BlockLocker:
|
||||||
|
listener = new BlockLocker();
|
||||||
|
break;
|
||||||
case Residence:
|
case Residence:
|
||||||
if (plugin.getDescription().getVersion().startsWith("2")) {
|
if (plugin.getDescription().getVersion().startsWith("2")) {
|
||||||
ChestShop.getBukkitLogger().severe("You are using an old version of Residence! " +
|
ChestShop.getBukkitLogger().severe("You are using an old version of Residence! " +
|
||||||
|
@ -79,7 +162,6 @@ public class Dependencies {
|
||||||
|
|
||||||
//Terrain protection plugins
|
//Terrain protection plugins
|
||||||
case WorldGuard:
|
case WorldGuard:
|
||||||
WorldGuardPlugin worldGuard = (WorldGuardPlugin) plugin;
|
|
||||||
boolean inUse = Properties.WORLDGUARD_USE_PROTECTION || Properties.WORLDGUARD_INTEGRATION;
|
boolean inUse = Properties.WORLDGUARD_USE_PROTECTION || Properties.WORLDGUARD_INTEGRATION;
|
||||||
|
|
||||||
if (!inUse) {
|
if (!inUse) {
|
||||||
|
@ -87,15 +169,29 @@ public class Dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Properties.WORLDGUARD_USE_PROTECTION) {
|
if (Properties.WORLDGUARD_USE_PROTECTION) {
|
||||||
ChestShop.registerListener(new WorldGuardProtection(worldGuard));
|
ChestShop.registerListener(new WorldGuardProtection(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Properties.WORLDGUARD_INTEGRATION) {
|
if (Properties.WORLDGUARD_INTEGRATION) {
|
||||||
listener = new WorldGuardBuilding(worldGuard);
|
listener = new WorldGuardBuilding(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GriefPrevention:
|
||||||
|
if (!Properties.GRIEFPREVENTION_INTEGRATION) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
listener = new GriefPrevenentionBuilding(plugin);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RedProtect:
|
||||||
|
if (!Properties.REDPROTECT_INTEGRATION) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
listener = new RedProtectBuilding(plugin);
|
||||||
|
break;
|
||||||
|
|
||||||
//Other plugins
|
//Other plugins
|
||||||
case Heroes:
|
case Heroes:
|
||||||
Heroes heroes = Heroes.getHeroes(plugin);
|
Heroes heroes = Heroes.getHeroes(plugin);
|
||||||
|
@ -106,8 +202,8 @@ public class Dependencies {
|
||||||
|
|
||||||
listener = heroes;
|
listener = heroes;
|
||||||
break;
|
break;
|
||||||
case OddItem:
|
case ItemBridge:
|
||||||
MaterialUtil.Odd.initialize();
|
listener = new ItemBridge();
|
||||||
break;
|
break;
|
||||||
case ShowItem:
|
case ShowItem:
|
||||||
MaterialUtil.Show.initialize(plugin);
|
MaterialUtil.Show.initialize(plugin);
|
||||||
|
@ -119,22 +215,35 @@ public class Dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginDescriptionFile description = plugin.getDescription();
|
PluginDescriptionFile description = plugin.getDescription();
|
||||||
|
versions.put(description.getName(), description.getVersion());
|
||||||
ChestShop.getBukkitLogger().info(description.getName() + " version " + description.getVersion() + " loaded.");
|
ChestShop.getBukkitLogger().info(description.getName() + " version " + description.getVersion() + " loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static enum Dependency {
|
private static enum Dependency {
|
||||||
LWC,
|
LWC,
|
||||||
Lockette,
|
Lockette,
|
||||||
|
LockettePro,
|
||||||
Deadbolt,
|
Deadbolt,
|
||||||
SimpleChestLock,
|
SimpleChestLock,
|
||||||
|
BlockLocker,
|
||||||
Residence,
|
Residence,
|
||||||
|
|
||||||
OddItem,
|
|
||||||
|
|
||||||
WorldGuard,
|
WorldGuard,
|
||||||
|
GriefPrevention,
|
||||||
|
RedProtect,
|
||||||
|
|
||||||
Heroes,
|
Heroes,
|
||||||
|
|
||||||
|
ItemBridge,
|
||||||
|
|
||||||
ShowItem
|
ShowItem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onEnable(PluginEnableEvent event) {
|
||||||
|
Plugin plugin = event.getPlugin();
|
||||||
|
if (ChestShop.getDependencies().contains(plugin.getName())) {
|
||||||
|
loadPlugin(plugin.getName(), plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,20 +33,32 @@ public class Economy {
|
||||||
return !ChestShopSign.isAdminShop(inventory) || NameManager.getServerEconomyAccount() != null;
|
return !ChestShopSign.isAdminShop(inventory) || NameManager.getServerEconomyAccount() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Directly call the {@link CurrencyAddEvent}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean add(UUID name, World world, double amount) {
|
public static boolean add(UUID name, World world, double amount) {
|
||||||
CurrencyAddEvent event = new CurrencyAddEvent(BigDecimal.valueOf(amount), name, world);
|
CurrencyAddEvent event = new CurrencyAddEvent(BigDecimal.valueOf(amount), name, world);
|
||||||
ChestShop.callEvent(event);
|
ChestShop.callEvent(event);
|
||||||
|
|
||||||
return true;
|
return event.wasHandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Directly call the {@link CurrencySubtractEvent}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean subtract(UUID name, World world, double amount) {
|
public static boolean subtract(UUID name, World world, double amount) {
|
||||||
CurrencySubtractEvent event = new CurrencySubtractEvent(BigDecimal.valueOf(amount), name, world);
|
CurrencySubtractEvent event = new CurrencySubtractEvent(BigDecimal.valueOf(amount), name, world);
|
||||||
ChestShop.callEvent(event);
|
ChestShop.callEvent(event);
|
||||||
|
|
||||||
return true;
|
return event.wasHandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Directly call the {@link CurrencyCheckEvent}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean hasEnough(UUID name, World world, double amount) {
|
public static boolean hasEnough(UUID name, World world, double amount) {
|
||||||
CurrencyCheckEvent event = new CurrencyCheckEvent(BigDecimal.valueOf(amount), name, world);
|
CurrencyCheckEvent event = new CurrencyCheckEvent(BigDecimal.valueOf(amount), name, world);
|
||||||
ChestShop.callEvent(event);
|
ChestShop.callEvent(event);
|
||||||
|
@ -54,10 +66,18 @@ public class Economy {
|
||||||
return event.hasEnough();
|
return event.hasEnough();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatBalance(double amount) {
|
public static String formatBalance(BigDecimal amount) {
|
||||||
CurrencyFormatEvent event = new CurrencyFormatEvent(BigDecimal.valueOf(amount));
|
CurrencyFormatEvent event = new CurrencyFormatEvent(amount);
|
||||||
ChestShop.callEvent(event);
|
ChestShop.callEvent(event);
|
||||||
|
|
||||||
return event.getFormattedAmount();
|
return event.getFormattedAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #formatBalance(BigDecimal)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static String formatBalance(double amount) {
|
||||||
|
return formatBalance(BigDecimal.valueOf(amount));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Database.Account;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an access request for a specific account.
|
||||||
|
*/
|
||||||
|
public class AccountAccessEvent extends PlayerEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private final Account account;
|
||||||
|
private boolean canAccess = false;
|
||||||
|
|
||||||
|
public AccountAccessEvent(Player player, Account account) {
|
||||||
|
super(player);
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The account to check the access for
|
||||||
|
*
|
||||||
|
* @return The account
|
||||||
|
*/
|
||||||
|
public Account getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the player can access the account.
|
||||||
|
*
|
||||||
|
* @return Whether or not the player can access the account
|
||||||
|
*/
|
||||||
|
public boolean canAccess() {
|
||||||
|
return canAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether or not the player can access the account.
|
||||||
|
*
|
||||||
|
* @param canAccess Whether or not the player can access the account
|
||||||
|
*/
|
||||||
|
public void setAccess(boolean canAccess) {
|
||||||
|
this.canAccess = canAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Database.Account;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a query for an account by using the name (e.g. from the shop sign)
|
||||||
|
*/
|
||||||
|
public class AccountQueryEvent extends Event {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private final String name;
|
||||||
|
private Account account = null;
|
||||||
|
private boolean searchOfflinePlayers = false;
|
||||||
|
|
||||||
|
public AccountQueryEvent(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Account getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccount(Account account) {
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether or not offline player data should be searched (too)
|
||||||
|
* @return Whether or not offline player data should be searched (too)
|
||||||
|
*/
|
||||||
|
public boolean searchOfflinePlayers() {
|
||||||
|
return searchOfflinePlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether or not offline player data should be searched (too).
|
||||||
|
* This could lead to network lookups if the player by the name never joined the server!
|
||||||
|
* @param searchOfflinePlayers Whether or not offline player data should be searched (too)
|
||||||
|
*/
|
||||||
|
public void searchOfflinePlayers(boolean searchOfflinePlayers) {
|
||||||
|
this.searchOfflinePlayers = searchOfflinePlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a plugin reload call
|
||||||
|
*
|
||||||
|
* @author Acrobot
|
||||||
|
*/
|
||||||
|
public class ChestShopReloadEvent extends Event {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private CommandSender sender;
|
||||||
|
|
||||||
|
public ChestShopReloadEvent(CommandSender sender) {
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return CommandSender who initiated the call
|
||||||
|
*/
|
||||||
|
public CommandSender getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package com.Acrobot.ChestShop.Events.Economy;
|
package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -11,10 +10,10 @@ import java.util.UUID;
|
||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class AccountCheckEvent extends Event {
|
public class AccountCheckEvent extends EconomicEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
boolean outcome;
|
private boolean outcome = false;
|
||||||
|
|
||||||
private UUID account;
|
private UUID account;
|
||||||
private World world;
|
private World world;
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -11,13 +10,13 @@ import java.util.UUID;
|
||||||
/**
|
/**
|
||||||
* Represents an addition of goods to entity
|
* Represents an addition of goods to entity
|
||||||
*
|
*
|
||||||
|
* Use {@link CurrencyTransferEvent} if you want to transfer money from one account to another one!
|
||||||
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class CurrencyAddEvent extends Event {
|
public class CurrencyAddEvent extends EconomicEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
boolean added;
|
|
||||||
|
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
private UUID target;
|
private UUID target;
|
||||||
private World world;
|
private World world;
|
||||||
|
@ -68,18 +67,22 @@ public class CurrencyAddEvent extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Was the money already added to the account?
|
* @return Was the money already added to the account?
|
||||||
|
* @deprecated Use {@link #wasHandled()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean isAdded() {
|
public boolean isAdded() {
|
||||||
return added;
|
return wasHandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if the money was added to the account
|
* Set if the money was added to the account
|
||||||
*
|
*
|
||||||
* @param added Was the money added?
|
* @param added Was the money added?
|
||||||
|
* @deprecated Use {@link #setHandled(boolean)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setAdded(boolean added) {
|
public void setAdded(boolean added) {
|
||||||
this.added = added;
|
setHandled(added);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,6 +99,13 @@ public class CurrencyAddEvent extends Event {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param target Account from which the currency is subtracted
|
||||||
|
*/
|
||||||
|
public void setTarget(UUID target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -13,7 +12,7 @@ import java.util.UUID;
|
||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class CurrencyAmountEvent extends Event {
|
public class CurrencyAmountEvent extends EconomicEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private BigDecimal amount = BigDecimal.ZERO;
|
private BigDecimal amount = BigDecimal.ZERO;
|
||||||
|
@ -77,6 +76,13 @@ public class CurrencyAmountEvent extends Event {
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param account Account that is checked
|
||||||
|
*/
|
||||||
|
public void setAccount(UUID account) {
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -13,10 +12,10 @@ import java.util.UUID;
|
||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class CurrencyCheckEvent extends Event {
|
public class CurrencyCheckEvent extends EconomicEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
boolean outcome;
|
private boolean outcome = false;
|
||||||
|
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
private UUID account;
|
private UUID account;
|
||||||
|
@ -59,6 +58,7 @@ public class CurrencyCheckEvent extends Event {
|
||||||
* @return Amount of currency, as a double
|
* @return Amount of currency, as a double
|
||||||
* @deprecated Use {@link #getAmount()} if possible
|
* @deprecated Use {@link #getAmount()} if possible
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public double getDoubleAmount() {
|
public double getDoubleAmount() {
|
||||||
return amount.doubleValue();
|
return amount.doubleValue();
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,9 @@ public class CurrencyCheckEvent extends Event {
|
||||||
* Sets the amount of currency transferred
|
* Sets the amount of currency transferred
|
||||||
*
|
*
|
||||||
* @param amount Amount to transfer
|
* @param amount Amount to transfer
|
||||||
|
* @deprecated The amount should not be changed!
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setAmount(BigDecimal amount) {
|
public void setAmount(BigDecimal amount) {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
@ -76,8 +78,9 @@ public class CurrencyCheckEvent extends Event {
|
||||||
* Sets the amount of currency transferred
|
* Sets the amount of currency transferred
|
||||||
*
|
*
|
||||||
* @param amount Amount to transfer
|
* @param amount Amount to transfer
|
||||||
* @deprecated Use {@link #setAmount(java.math.BigDecimal)} if possible
|
* @deprecated The amount should not be changed! Use {@link #setAmount(java.math.BigDecimal)} if possible
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setAmount(double amount) {
|
public void setAmount(double amount) {
|
||||||
this.amount = BigDecimal.valueOf(amount);
|
this.amount = BigDecimal.valueOf(amount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.Acrobot.ChestShop.Events.Economy;
|
package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -10,7 +9,7 @@ import java.math.BigDecimal;
|
||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class CurrencyFormatEvent extends Event {
|
public class CurrencyFormatEvent extends EconomicEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private final BigDecimal amount;
|
private final BigDecimal amount;
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -13,10 +12,10 @@ import java.util.UUID;
|
||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class CurrencyHoldEvent extends Event {
|
public class CurrencyHoldEvent extends EconomicEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
boolean canHold = true;
|
private boolean canHold = true;
|
||||||
|
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
private UUID account;
|
private UUID account;
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -11,13 +10,13 @@ import java.util.UUID;
|
||||||
/**
|
/**
|
||||||
* Represents a subtraction of goods from entity
|
* Represents a subtraction of goods from entity
|
||||||
*
|
*
|
||||||
|
* Use {@link CurrencyTransferEvent} if you want to transfer money from one account to another one!
|
||||||
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class CurrencySubtractEvent extends Event {
|
public class CurrencySubtractEvent extends EconomicEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
boolean subtracted;
|
|
||||||
|
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
private UUID target;
|
private UUID target;
|
||||||
private World world;
|
private World world;
|
||||||
|
@ -68,18 +67,22 @@ public class CurrencySubtractEvent extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Was the money already subtracted?
|
* @return Was the money already subtracted?
|
||||||
|
* @deprecated Use {@link #wasHandled()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean isSubtracted() {
|
public boolean isSubtracted() {
|
||||||
return subtracted;
|
return wasHandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if the money was subtracted from the account
|
* Set if the money was subtracted from the account
|
||||||
*
|
*
|
||||||
* @param subtracted Was the money subtracted?
|
* @param subtracted Was the money subtracted?
|
||||||
|
* @deprecated Use {@link #setHandled(boolean)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setSubtracted(boolean subtracted) {
|
public void setSubtracted(boolean subtracted) {
|
||||||
this.subtracted = subtracted;
|
setHandled(subtracted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,6 +99,13 @@ public class CurrencySubtractEvent extends Event {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param target Account from which the currency is subtracted
|
||||||
|
*/
|
||||||
|
public void setTarget(UUID target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package com.Acrobot.ChestShop.Events.Economy;
|
package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Events.TransactionEvent;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -12,49 +13,73 @@ import java.util.UUID;
|
||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class CurrencyTransferEvent extends Event {
|
public class CurrencyTransferEvent extends EconomicEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private BigDecimal amount;
|
private BigDecimal amountSent;
|
||||||
private World world;
|
private BigDecimal amountReceived;
|
||||||
private UUID sender;
|
|
||||||
private UUID receiver;
|
|
||||||
private boolean success;
|
|
||||||
|
|
||||||
public CurrencyTransferEvent(BigDecimal amount, UUID sender, UUID receiver, World world) {
|
private final Player initiator;
|
||||||
this.amount = amount;
|
|
||||||
this.world = world;
|
|
||||||
|
|
||||||
this.sender = sender;
|
private UUID partner;
|
||||||
this.receiver = receiver;
|
|
||||||
|
private Direction direction;
|
||||||
|
|
||||||
|
private final TransactionEvent transactionEvent;
|
||||||
|
|
||||||
|
public CurrencyTransferEvent(BigDecimal amount, Player initiator, UUID partner, Direction direction) {
|
||||||
|
this(amount, amount, initiator, partner, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CurrencyTransferEvent(double amount, UUID sender, UUID receiver, World world) {
|
public CurrencyTransferEvent(BigDecimal amountSent, BigDecimal amountReceived, Player initiator, UUID partner, Direction direction) {
|
||||||
this(BigDecimal.valueOf(amount), sender, receiver, world);
|
this(amountSent, amountReceived, initiator, partner, direction, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CurrencyTransferEvent(BigDecimal amount, Player initiator, UUID partner, Direction direction, TransactionEvent transactionEvent) {
|
||||||
|
this(amount, amount, initiator, partner, direction, transactionEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CurrencyTransferEvent(BigDecimal amountSent, BigDecimal amountReceived, Player initiator, UUID partner, Direction direction, TransactionEvent transactionEvent) {
|
||||||
|
this.amountSent = amountSent;
|
||||||
|
this.amountReceived = amountReceived;
|
||||||
|
this.initiator = initiator;
|
||||||
|
|
||||||
|
this.partner = partner;
|
||||||
|
this.direction = direction;
|
||||||
|
|
||||||
|
this.transactionEvent = transactionEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Amount of currency
|
* @return Amount of currency sent
|
||||||
|
* @deprecated Use {@link #getAmountSent()} and {@link #getAmountReceived()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public BigDecimal getAmount() {
|
public BigDecimal getAmount() {
|
||||||
return amount;
|
return amountSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Amount of currency, as a double
|
* @return Amount of currency, as a double
|
||||||
* @deprecated Use {@link #getAmount()} if possible
|
* @deprecated Use {@link #getAmount()} if possible
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public double getDoubleAmount() {
|
public double getDoubleAmount() {
|
||||||
return amount.doubleValue();
|
return getAmount().doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the amount of currency transferred
|
* Sets the amount of currency transferred
|
||||||
*
|
*
|
||||||
* @param amount Amount to transfer
|
* @param amount Amount to transfer
|
||||||
|
* @deprecated Use {@link #setAmountSent(BigDecimal)} and {@link #setAmountReceived(BigDecimal)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setAmount(BigDecimal amount) {
|
public void setAmount(BigDecimal amount) {
|
||||||
this.amount = amount;
|
this.amountSent = amount;
|
||||||
|
this.amountReceived = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,45 +88,127 @@ public class CurrencyTransferEvent extends Event {
|
||||||
* @param amount Amount to transfer
|
* @param amount Amount to transfer
|
||||||
* @deprecated Use {@link #setAmount(java.math.BigDecimal)} if possible
|
* @deprecated Use {@link #setAmount(java.math.BigDecimal)} if possible
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setAmount(double amount) {
|
public void setAmount(double amount) {
|
||||||
this.amount = BigDecimal.valueOf(amount);
|
setAmount(BigDecimal.valueOf(amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount sent (subtracted from the sender account)
|
||||||
|
*
|
||||||
|
* @return The amount that got sent
|
||||||
|
*/
|
||||||
|
public BigDecimal getAmountSent() {
|
||||||
|
return amountSent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the amount sent (subtracted from the sender account)
|
||||||
|
*
|
||||||
|
* @param amountSent The amount that got sent
|
||||||
|
*/
|
||||||
|
public void setAmountSent(BigDecimal amountSent) {
|
||||||
|
this.amountSent = amountSent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount received (added from the receiver account)
|
||||||
|
*
|
||||||
|
* @return The amount that gets received
|
||||||
|
*/
|
||||||
|
public BigDecimal getAmountReceived() {
|
||||||
|
return amountReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the amount received (added from the receiver account)
|
||||||
|
*
|
||||||
|
* @param amountReceived The amount that gets received
|
||||||
|
*/
|
||||||
|
public void setAmountReceived(BigDecimal amountReceived) {
|
||||||
|
this.amountReceived = amountReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If the currency has been successfully transferred
|
* @return If the currency has been successfully transferred
|
||||||
|
* @deprecated Use {@link #wasHandled()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean hasBeenTransferred() {
|
public boolean hasBeenTransferred() {
|
||||||
return success;
|
return wasHandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the transaction's outcome
|
* Sets the transaction's outcome
|
||||||
*
|
*
|
||||||
* @param success If the currency has been successfully transferred
|
* @param success If the currency has been successfully transferred
|
||||||
|
* @deprecated Use {@link #setHandled(boolean)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setTransferred(boolean success) {
|
public void setTransferred(boolean success) {
|
||||||
this.success = success;
|
setHandled(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the direction that the money is transacted
|
||||||
|
*/
|
||||||
|
public Direction getDirection() {
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link TransactionEvent} associated with this currency transfer event.
|
||||||
|
*
|
||||||
|
* @return the transaction event.
|
||||||
|
*/
|
||||||
|
public TransactionEvent getTransactionEvent() {
|
||||||
|
return transactionEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player who initiated this transaction
|
||||||
|
*
|
||||||
|
* @return The player who initiated this transaction
|
||||||
|
*/
|
||||||
|
public Player getInitiator() {
|
||||||
|
return initiator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the partner of this transaction
|
||||||
|
*/
|
||||||
|
public UUID getPartner() {
|
||||||
|
return partner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the partner of the transaction
|
||||||
|
*
|
||||||
|
* @param partner the new partner of this transaction
|
||||||
|
*/
|
||||||
|
public void setPartner(UUID partner) {
|
||||||
|
this.partner = partner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The world in which the transaction occurs
|
* @return The world in which the transaction occurs
|
||||||
*/
|
*/
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
return world;
|
return initiator.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Sender of the money
|
* @return Sender of the money
|
||||||
*/
|
*/
|
||||||
public UUID getSender() {
|
public UUID getSender() {
|
||||||
return sender;
|
return direction == Direction.PARTNER ? initiator.getUniqueId() : partner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Receiver of the money
|
* @return Receiver of the money
|
||||||
*/
|
*/
|
||||||
public UUID getReceiver() {
|
public UUID getReceiver() {
|
||||||
return receiver;
|
return direction == Direction.PARTNER ? partner : initiator.getUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
@ -111,4 +218,9 @@ public class CurrencyTransferEvent extends Event {
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Direction {
|
||||||
|
PARTNER,
|
||||||
|
INITIATOR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
public abstract class EconomicEvent extends Event {
|
||||||
|
|
||||||
|
private boolean handled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether or not this event was successfully handled by a listener
|
||||||
|
*
|
||||||
|
* @return Whether or not the amount was successfully handled
|
||||||
|
*/
|
||||||
|
public boolean wasHandled() {
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether or not this event was successfully handled by a listener
|
||||||
|
*
|
||||||
|
* @param handled Whether or not the amount was successfully handled
|
||||||
|
*/
|
||||||
|
public void setHandled(boolean handled) {
|
||||||
|
this.handled = handled;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class ItemParseEvent extends Event {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private final String itemString;
|
||||||
|
private ItemStack item = null;
|
||||||
|
|
||||||
|
public ItemParseEvent(String itemString) {
|
||||||
|
this.itemString = itemString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the item string that should be parsed
|
||||||
|
* @return The item string to parse
|
||||||
|
*/
|
||||||
|
public String getItemString() {
|
||||||
|
return itemString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the item that the string represents
|
||||||
|
* @param item The item for the string
|
||||||
|
*/
|
||||||
|
public void setItem(ItemStack item) {
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The item that was parsed
|
||||||
|
* @return The parsed item or null if none was found
|
||||||
|
*/
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the item string of this event has a parsed item
|
||||||
|
* @return True if an item was successfully parsed; false if not
|
||||||
|
*/
|
||||||
|
public boolean hasItem() {
|
||||||
|
return item != null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class ItemStringQueryEvent extends Event {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private String itemString = null;
|
||||||
|
private final ItemStack item;
|
||||||
|
private final int maxWidth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the item string representation of a certain item with a certain length
|
||||||
|
* @param item The item to query the string for
|
||||||
|
*/
|
||||||
|
public ItemStringQueryEvent(ItemStack item) {
|
||||||
|
this(item, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the item string representation of a certain item with a certain length
|
||||||
|
* @param item The item to query the string for
|
||||||
|
* @param maxWidth The max width of the item string
|
||||||
|
*/
|
||||||
|
public ItemStringQueryEvent(ItemStack item, int maxWidth) {
|
||||||
|
this.item = item;
|
||||||
|
this.maxWidth = maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The item for which the string is queried
|
||||||
|
* @return The item
|
||||||
|
*/
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the item string that represents the item
|
||||||
|
* @return The item string that represents the item
|
||||||
|
*/
|
||||||
|
public String getItemString() {
|
||||||
|
return itemString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the item string that represents the item
|
||||||
|
* @param itemString The item string that represents the item
|
||||||
|
*/
|
||||||
|
public void setItemString(String itemString) {
|
||||||
|
this.itemString = itemString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the max width that the result item string should have
|
||||||
|
* @return The max width of the result item string
|
||||||
|
*/
|
||||||
|
public int getMaxWidth() {
|
||||||
|
return maxWidth;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class MaterialParseEvent extends Event {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private final String materialString;
|
||||||
|
private final short data;
|
||||||
|
private Material material = null;
|
||||||
|
|
||||||
|
public MaterialParseEvent(String materialString, short data) {
|
||||||
|
this.materialString = materialString;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the material string that should be parsed
|
||||||
|
* @return The material string to parse
|
||||||
|
*/
|
||||||
|
public String getMaterialString() {
|
||||||
|
return materialString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data of legacy materials that might result in different flattening materials
|
||||||
|
* @return The data
|
||||||
|
*/
|
||||||
|
public short getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the material that the string represents
|
||||||
|
* @param material The material for the string
|
||||||
|
*/
|
||||||
|
public void setMaterial(Material material) {
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The material that was parsed
|
||||||
|
* @return The parsed material or null if none was found
|
||||||
|
*/
|
||||||
|
public Material getMaterial() {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the material string of this event has a parsed material
|
||||||
|
* @return True if an material was successfully parsed; false if not
|
||||||
|
*/
|
||||||
|
public boolean hasMaterial() {
|
||||||
|
return material != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,19 +1,24 @@
|
||||||
package com.Acrobot.ChestShop.Events;
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Database.Account;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a state before shop is created
|
* Represents a state before shop is created
|
||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class PreShopCreationEvent extends Event {
|
public class PreShopCreationEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Player creator;
|
private Player creator;
|
||||||
|
@Nullable private Account ownerAccount = null;
|
||||||
|
|
||||||
private CreationOutcome outcome = CreationOutcome.SHOP_CREATED_SUCCESSFULLY;
|
private CreationOutcome outcome = CreationOutcome.SHOP_CREATED_SUCCESSFULLY;
|
||||||
private Sign sign;
|
private Sign sign;
|
||||||
|
@ -30,10 +35,25 @@ public class PreShopCreationEvent extends Event {
|
||||||
*
|
*
|
||||||
* @return Is event cancelled?
|
* @return Is event cancelled?
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return outcome != CreationOutcome.SHOP_CREATED_SUCCESSFULLY;
|
return outcome != CreationOutcome.SHOP_CREATED_SUCCESSFULLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if event is cancelled. This sets a generic {@link CreationOutcome#OTHER};
|
||||||
|
*
|
||||||
|
* @param cancel Cancel the event?
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
if (cancel) {
|
||||||
|
outcome = CreationOutcome.OTHER;
|
||||||
|
} else {
|
||||||
|
outcome = CreationOutcome.SHOP_CREATED_SUCCESSFULLY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the outcome of the event
|
* Returns the outcome of the event
|
||||||
*
|
*
|
||||||
|
@ -126,6 +146,25 @@ public class PreShopCreationEvent extends Event {
|
||||||
return signLines;
|
return signLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the account of the shop owner
|
||||||
|
*
|
||||||
|
* @return the Account of the shop owner; null if not found
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Account getOwnerAccount() {
|
||||||
|
return ownerAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the account of the shop owner
|
||||||
|
*
|
||||||
|
* @param ownerAccount the Account of the shop owner
|
||||||
|
*/
|
||||||
|
public void setOwnerAccount(@Nullable Account ownerAccount) {
|
||||||
|
this.ownerAccount = ownerAccount;
|
||||||
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
@ -141,12 +180,16 @@ public class PreShopCreationEvent extends Event {
|
||||||
INVALID_ITEM,
|
INVALID_ITEM,
|
||||||
INVALID_PRICE,
|
INVALID_PRICE,
|
||||||
INVALID_QUANTITY,
|
INVALID_QUANTITY,
|
||||||
|
|
||||||
ITEM_AUTOFILL,
|
ITEM_AUTOFILL(false),
|
||||||
|
|
||||||
UNKNOWN_PLAYER,
|
UNKNOWN_PLAYER,
|
||||||
|
|
||||||
SELL_PRICE_HIGHER_THAN_BUY_PRICE,
|
SELL_PRICE_HIGHER_THAN_BUY_PRICE,
|
||||||
|
SELL_PRICE_ABOVE_MAX,
|
||||||
|
SELL_PRICE_BELOW_MIN,
|
||||||
|
BUY_PRICE_ABOVE_MAX,
|
||||||
|
BUY_PRICE_BELOW_MIN,
|
||||||
|
|
||||||
NO_CHEST,
|
NO_CHEST,
|
||||||
|
|
||||||
|
@ -159,8 +202,31 @@ public class PreShopCreationEvent extends Event {
|
||||||
/**
|
/**
|
||||||
* For plugin use
|
* For plugin use
|
||||||
*/
|
*/
|
||||||
OTHER,
|
OTHER(false),
|
||||||
|
/**
|
||||||
|
* Break the sign
|
||||||
|
*/
|
||||||
|
OTHER_BREAK,
|
||||||
|
|
||||||
SHOP_CREATED_SUCCESSFULLY
|
SHOP_CREATED_SUCCESSFULLY(false);
|
||||||
|
|
||||||
|
private final boolean breakSign;
|
||||||
|
|
||||||
|
CreationOutcome() {
|
||||||
|
this.breakSign = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreationOutcome(boolean breakSign) {
|
||||||
|
this.breakSign = breakSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether or not this outcome should result in the shop sign getting broken
|
||||||
|
*
|
||||||
|
* @return Whether or not the shop sign gets broken
|
||||||
|
*/
|
||||||
|
public boolean shouldBreakSign() {
|
||||||
|
return breakSign;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,15 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import static com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome.OTHER;
|
||||||
import static com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome.TRANSACTION_SUCCESFUL;
|
import static com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome.TRANSACTION_SUCCESFUL;
|
||||||
import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType;
|
import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType;
|
||||||
|
|
||||||
|
@ -19,7 +23,7 @@ import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType;
|
||||||
*
|
*
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class PreTransactionEvent extends Event {
|
public class PreTransactionEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private final Player client;
|
private final Player client;
|
||||||
|
@ -32,16 +36,17 @@ public class PreTransactionEvent extends Event {
|
||||||
private Inventory clientInventory;
|
private Inventory clientInventory;
|
||||||
|
|
||||||
private ItemStack[] items;
|
private ItemStack[] items;
|
||||||
private double price;
|
|
||||||
|
private BigDecimal exactPrice;
|
||||||
|
|
||||||
private TransactionOutcome transactionOutcome = TRANSACTION_SUCCESFUL;
|
private TransactionOutcome transactionOutcome = TRANSACTION_SUCCESFUL;
|
||||||
|
|
||||||
public PreTransactionEvent(Inventory ownerInventory, Inventory clientInventory, ItemStack[] items, double price, Player client, Account ownerAccount, Sign sign, TransactionType type) {
|
public PreTransactionEvent(Inventory ownerInventory, Inventory clientInventory, ItemStack[] items, BigDecimal exactPrice, Player client, Account ownerAccount, Sign sign, TransactionType type) {
|
||||||
this.ownerInventory = ownerInventory;
|
this.ownerInventory = ownerInventory;
|
||||||
this.clientInventory = (clientInventory == null ? client.getInventory() : clientInventory);
|
this.clientInventory = (clientInventory == null ? client.getInventory() : clientInventory);
|
||||||
|
|
||||||
this.items = items;
|
this.items = items;
|
||||||
this.price = price;
|
this.exactPrice = exactPrice;
|
||||||
|
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.ownerAccount = ownerAccount;
|
this.ownerAccount = ownerAccount;
|
||||||
|
@ -50,6 +55,14 @@ public class PreTransactionEvent extends Event {
|
||||||
this.transactionType = type;
|
this.transactionType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #PreTransactionEvent(Inventory, Inventory, ItemStack[], BigDecimal, Player, Account, Sign, TransactionType)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public PreTransactionEvent(Inventory ownerInventory, Inventory clientInventory, ItemStack[] items, double price, Player client, Account ownerAccount, Sign sign, TransactionType type) {
|
||||||
|
this(ownerInventory, clientInventory, items, BigDecimal.valueOf(price), client, ownerAccount, sign, type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Shop's sign
|
* @return Shop's sign
|
||||||
*/
|
*/
|
||||||
|
@ -58,19 +71,43 @@ public class PreTransactionEvent extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Total price of the items
|
* Get the exact total price
|
||||||
|
*
|
||||||
|
* @return Exact total price of the items
|
||||||
*/
|
*/
|
||||||
|
public BigDecimal getExactPrice() {
|
||||||
|
return exactPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the exact price of the items
|
||||||
|
*
|
||||||
|
* @param exactPrice Price of the items
|
||||||
|
*/
|
||||||
|
public void setExactPrice(BigDecimal exactPrice) {
|
||||||
|
this.exactPrice = exactPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the total price
|
||||||
|
*
|
||||||
|
* @return Total price of the items
|
||||||
|
* @deprecated Use {@link #getExactPrice()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public double getPrice() {
|
public double getPrice() {
|
||||||
return price;
|
return exactPrice.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the price of the items
|
* Sets the price of the items
|
||||||
*
|
*
|
||||||
* @param price Price of the items
|
* @param price Price of the items
|
||||||
|
* @deprecated Use {@link #setExactPrice(BigDecimal)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setPrice(double price) {
|
public void setPrice(double price) {
|
||||||
this.price = price;
|
this.exactPrice = BigDecimal.valueOf(price);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,26 +149,6 @@ public class PreTransactionEvent extends Event {
|
||||||
this.ownerAccount = ownerAccount;
|
this.ownerAccount = ownerAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Shop's owner
|
|
||||||
* @deprecated Use {@link #getOwnerAccount}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public OfflinePlayer getOwner() {
|
|
||||||
return Bukkit.getOfflinePlayer(ownerAccount.getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the shop's owner
|
|
||||||
*
|
|
||||||
* @param owner Shop owner
|
|
||||||
* @deprecated Use {@link #setOwnerAccount(Account)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setOwner(OfflinePlayer owner) {
|
|
||||||
this.ownerAccount = NameManager.getAccount(owner.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Owner's inventory
|
* @return Owner's inventory
|
||||||
*/
|
*/
|
||||||
|
@ -178,6 +195,15 @@ public class PreTransactionEvent extends Event {
|
||||||
return transactionOutcome != TRANSACTION_SUCCESFUL;
|
return transactionOutcome != TRANSACTION_SUCCESFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
if (cancel) {
|
||||||
|
transactionOutcome = OTHER;
|
||||||
|
} else {
|
||||||
|
transactionOutcome = TRANSACTION_SUCCESFUL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Transaction's outcome
|
* @return Transaction's outcome
|
||||||
*/
|
*/
|
||||||
|
@ -221,6 +247,7 @@ public class PreTransactionEvent extends Event {
|
||||||
NOT_ENOUGH_STOCK_IN_INVENTORY,
|
NOT_ENOUGH_STOCK_IN_INVENTORY,
|
||||||
|
|
||||||
INVALID_SHOP,
|
INVALID_SHOP,
|
||||||
|
INVALID_CLIENT_NAME,
|
||||||
|
|
||||||
SPAM_CLICKING_PROTECTION,
|
SPAM_CLICKING_PROTECTION,
|
||||||
CREATIVE_MODE_PROTECTION,
|
CREATIVE_MODE_PROTECTION,
|
||||||
|
|
|
@ -2,22 +2,24 @@ package com.Acrobot.ChestShop.Events.Protection;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class BuildPermissionEvent extends Event {
|
public class BuildPermissionEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private Location chest, sign;
|
private Location chest, sign;
|
||||||
|
|
||||||
private int disallowed = 0;
|
private boolean allowed = true;
|
||||||
private int received = 0;
|
|
||||||
|
|
||||||
public BuildPermissionEvent(Player player, Location chest, Location sign) {
|
public BuildPermissionEvent(Player player, @Nullable Location chest, Location sign) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.chest = chest;
|
this.chest = chest;
|
||||||
this.sign = sign;
|
this.sign = sign;
|
||||||
|
@ -27,7 +29,7 @@ public class BuildPermissionEvent extends Event {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getChest() {
|
public @Nullable Location getChest() {
|
||||||
return chest;
|
return chest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,24 +38,19 @@ public class BuildPermissionEvent extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void allow() {
|
public void allow() {
|
||||||
received++;
|
allowed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowed() {
|
public boolean isAllowed() {
|
||||||
return disallowed != received || received == 0;
|
return allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void allow(boolean yesOrNot) {
|
public void allow(boolean yesOrNot) {
|
||||||
if (yesOrNot) {
|
allowed = yesOrNot;
|
||||||
allow();
|
|
||||||
} else {
|
|
||||||
disallow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disallow() {
|
public void disallow() {
|
||||||
received++;
|
allowed = false;
|
||||||
disallowed++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
@ -63,4 +60,14 @@ public class BuildPermissionEvent extends Event {
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return !isAllowed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
allow(!cancel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package com.Acrobot.ChestShop.Events.Protection;
|
package com.Acrobot.ChestShop.Events.Protection;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Security;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -12,14 +15,26 @@ import org.bukkit.event.HandlerList;
|
||||||
public class ProtectBlockEvent extends Event {
|
public class ProtectBlockEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Player player;
|
private final Player player;
|
||||||
private Block block;
|
private final UUID protectionOwner;
|
||||||
|
private final Block block;
|
||||||
|
private final Security.Type type;
|
||||||
|
|
||||||
boolean isProtected = false;
|
boolean isProtected = false;
|
||||||
|
|
||||||
public ProtectBlockEvent(Block block, Player player) {
|
public ProtectBlockEvent(Block block, Player player) {
|
||||||
|
this(block, player, player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtectBlockEvent(Block block, Player player, UUID protectionOwner) {
|
||||||
|
this(block, player, protectionOwner, Security.Type.PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtectBlockEvent(Block block, Player player, UUID protectionOwner, Security.Type type) {
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
this.protectionOwner = protectionOwner;
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isProtected() {
|
public boolean isProtected() {
|
||||||
|
@ -38,6 +53,14 @@ public class ProtectBlockEvent extends Event {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getProtectionOwner() {
|
||||||
|
return protectionOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Security.Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ public class ProtectionCheckEvent extends Event {
|
||||||
|
|
||||||
private Result result = Result.DEFAULT;
|
private Result result = Result.DEFAULT;
|
||||||
private boolean ignoreBuiltInProtection = false;
|
private boolean ignoreBuiltInProtection = false;
|
||||||
|
private boolean checkManagement = true;
|
||||||
private Block block;
|
private Block block;
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
|
@ -27,10 +28,21 @@ public class ProtectionCheckEvent extends Event {
|
||||||
this.ignoreBuiltInProtection = ignoreBuiltInProtection;
|
this.ignoreBuiltInProtection = ignoreBuiltInProtection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProtectionCheckEvent(Block block, Player player, boolean ignoreBuiltInProtection, boolean checkManagement) {
|
||||||
|
this.block = block;
|
||||||
|
this.player = player;
|
||||||
|
this.ignoreBuiltInProtection = ignoreBuiltInProtection;
|
||||||
|
this.checkManagement = checkManagement;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isBuiltInProtectionIgnored() {
|
public boolean isBuiltInProtectionIgnored() {
|
||||||
return ignoreBuiltInProtection;
|
return ignoreBuiltInProtection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkCanManage() {
|
||||||
|
return checkManagement;
|
||||||
|
}
|
||||||
|
|
||||||
public Result getResult() {
|
public Result getResult() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.Acrobot.ChestShop.Events;
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Database.Account;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.block.Container;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
@ -20,13 +22,25 @@ public class ShopCreatedEvent extends Event {
|
||||||
|
|
||||||
private final Sign sign;
|
private final Sign sign;
|
||||||
private final String[] signLines;
|
private final String[] signLines;
|
||||||
@Nullable private final Chest chest;
|
@Nullable private final Account ownerAccount;
|
||||||
|
@Nullable private final Container container;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ShopCreatedEvent(Player creator, Sign sign, @Nullable Chest chest, String[] signLines) {
|
public ShopCreatedEvent(Player creator, Sign sign, @Nullable Chest chest, String[] signLines) {
|
||||||
|
this(creator, sign, (Container) chest, signLines);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public ShopCreatedEvent(Player creator, Sign sign, @Nullable Container container, String[] signLines) {
|
||||||
|
this(creator, sign, container, signLines, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopCreatedEvent(Player creator, Sign sign, @Nullable Container container, String[] signLines, @Nullable Account ownerAccount) {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
this.sign = sign;
|
this.sign = sign;
|
||||||
this.chest = chest;
|
this.container = container;
|
||||||
this.signLines = signLines.clone();
|
this.signLines = signLines.clone();
|
||||||
|
this.ownerAccount = ownerAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,12 +81,39 @@ public class ShopCreatedEvent extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the shop's chest (if applicable)
|
* Returns the shop's container (if applicable)
|
||||||
*
|
*
|
||||||
* @return Shop's chest
|
* @return Shop's container
|
||||||
*/
|
*/
|
||||||
|
@Nullable public Container getContainer() {
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #getContainer()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
@Nullable public Chest getChest() {
|
@Nullable public Chest getChest() {
|
||||||
return chest;
|
return container instanceof Chest ? (Chest) container : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the account of the shop's owner
|
||||||
|
*
|
||||||
|
* @return The account of the shop's owner; null if no Account could be found
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Account getOwnerAccount() {
|
||||||
|
return ownerAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether or not the created shop is owned by the creator
|
||||||
|
*
|
||||||
|
* @return <tt>true</tt> if the owner account is the creators one (or null); <tt>false</tt> if it's not
|
||||||
|
*/
|
||||||
|
public boolean createdByOwner() {
|
||||||
|
return ownerAccount == null || ownerAccount.getUuid().equals(creator.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.Acrobot.ChestShop.Events;
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.block.Container;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
@ -19,12 +20,17 @@ public class ShopDestroyedEvent extends Event {
|
||||||
private final Player destroyer;
|
private final Player destroyer;
|
||||||
|
|
||||||
private final Sign sign;
|
private final Sign sign;
|
||||||
private final Chest chest;
|
private final Container container;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ShopDestroyedEvent(@Nullable Player destroyer, Sign sign, @Nullable Chest chest) {
|
public ShopDestroyedEvent(@Nullable Player destroyer, Sign sign, @Nullable Chest chest) {
|
||||||
|
this(destroyer, sign, (Container) chest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopDestroyedEvent(@Nullable Player destroyer, Sign sign, @Nullable Container container) {
|
||||||
this.destroyer = destroyer;
|
this.destroyer = destroyer;
|
||||||
this.sign = sign;
|
this.sign = sign;
|
||||||
this.chest = chest;
|
this.container = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,8 +43,16 @@ public class ShopDestroyedEvent extends Event {
|
||||||
/**
|
/**
|
||||||
* @return Shop's chest
|
* @return Shop's chest
|
||||||
*/
|
*/
|
||||||
|
@Nullable public Container getContainer() {
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #getContainer()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
@Nullable public Chest getChest() {
|
@Nullable public Chest getChest() {
|
||||||
return chest;
|
return container instanceof Chest ? (Chest) container : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.Acrobot.ChestShop.Events;
|
||||||
|
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a /shopinfo call or middle click on a sign
|
||||||
|
*
|
||||||
|
* @author Phoenix616
|
||||||
|
*/
|
||||||
|
public class ShopInfoEvent extends Event implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private Player sender;
|
||||||
|
private Sign sign;
|
||||||
|
private boolean cancelled = false;
|
||||||
|
|
||||||
|
public ShopInfoEvent(Player sender, Sign sign) {
|
||||||
|
this.sender = sender;
|
||||||
|
this.sign = sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The Player who initiated the call
|
||||||
|
*/
|
||||||
|
public Player getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The shop sign
|
||||||
|
*/
|
||||||
|
public Sign getSign() {
|
||||||
|
return sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
cancelled = cancel;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue