mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-20 07:29:15 +00:00
Compare commits
392 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8453a8b20d | ||
|
|
e59ee03ac7 | ||
|
|
01155f40dd | ||
|
|
fa9f81e5e2 | ||
|
|
54bcef1a45 | ||
|
|
8e14899397 | ||
|
|
061718a3b6 | ||
|
|
2eea426460 | ||
|
|
b0136d6076 | ||
|
|
d0b45b951c | ||
|
|
e42f5c8c7d | ||
|
|
5d4fb85fec | ||
|
|
04b11a0830 | ||
|
|
353086b9c1 | ||
|
|
4e40a7cc96 | ||
|
|
e2715fe631 | ||
|
|
c7deb756db | ||
|
|
11f26f8f0a | ||
|
|
6d814d86b3 | ||
|
|
12f8b05469 | ||
|
|
b5322bc10b | ||
|
|
7a4fd9a98b | ||
|
|
239e13fab2 | ||
|
|
94b5a1bb3b | ||
|
|
71ed820917 | ||
|
|
20532fbaf2 | ||
|
|
4068af98d2 | ||
|
|
95e83992de | ||
|
|
96817d7279 | ||
|
|
ba7a99247a | ||
|
|
f1da6105c0 | ||
|
|
c06a4fcede | ||
|
|
afb20ea0bb | ||
|
|
774caf8d91 | ||
|
|
a0c2c8a9aa | ||
|
|
5b7f75f7a0 | ||
|
|
3f7d010dfa | ||
|
|
4d84bd681d | ||
|
|
0daff3044d | ||
|
|
ee87338cd4 | ||
|
|
2b467e63ce | ||
|
|
6000cf9c1b | ||
|
|
f2b0fb29d3 | ||
|
|
d2962ba5ed | ||
|
|
b37083a298 | ||
|
|
e35a29a13b | ||
|
|
344aaf32e0 | ||
|
|
6498cb43ea | ||
|
|
0120720cc3 | ||
|
|
d1bfa5abbc | ||
|
|
71a080a3d5 | ||
|
|
78f48703db | ||
|
|
b9e5096d33 | ||
|
|
d7603b5108 | ||
|
|
756e3390a1 | ||
|
|
8054a35f43 | ||
|
|
3b863e6dde | ||
|
|
b682dd7c42 | ||
|
|
f34f5f01aa | ||
|
|
cb9248db7a | ||
|
|
61ee228990 | ||
|
|
14e061e487 | ||
|
|
9dc2c23d04 | ||
|
|
684f8a4790 | ||
|
|
5d782bb6a3 | ||
|
|
988ec04a2e | ||
|
|
ebf87f01b8 | ||
|
|
6032eb0782 | ||
|
|
6d8c46783f | ||
|
|
407061d125 | ||
|
|
f8192d734b | ||
|
|
190f8f776d | ||
|
|
cd80bc746e | ||
|
|
d96a8e5622 | ||
|
|
53091f102e | ||
|
|
1d24881df1 | ||
|
|
ae0dc7bd14 | ||
|
|
b9a57fc48f | ||
|
|
1e2db05e45 | ||
|
|
4e2291d16f | ||
|
|
2e95a9bf58 | ||
|
|
0de6c1416c | ||
|
|
f8c2e0e605 | ||
|
|
23ad3eaf65 | ||
|
|
97887961db | ||
|
|
e48dcf9150 | ||
|
|
0f65c20095 | ||
|
|
68b0955a1f | ||
|
|
1193bc43d7 | ||
|
|
f5105200de | ||
|
|
1b7fdd3dcf | ||
|
|
2e4130012f | ||
|
|
bf7517ab20 | ||
|
|
813642ee92 | ||
|
|
f266721781 | ||
|
|
9793114ea0 | ||
|
|
b00c79f67b | ||
|
|
0528ebfa84 | ||
|
|
1e0ffdc08b | ||
|
|
cc08cc6537 | ||
|
|
455b8cd1a1 | ||
|
|
5c6bb93e6c | ||
|
|
e9c7946319 | ||
|
|
fcde8e7f25 | ||
|
|
7fcbbd6b5a | ||
|
|
a92b4c15f5 | ||
|
|
7439aabfd1 | ||
|
|
50bda8343c | ||
|
|
c189424aa8 | ||
|
|
70b97667c3 | ||
|
|
128a33a21f | ||
|
|
538edb67dd | ||
|
|
9b607a099e | ||
|
|
f084d9e782 | ||
|
|
8ee1400f85 | ||
|
|
8e33b2022b | ||
|
|
a661ea09e1 | ||
|
|
9c2120d13d | ||
|
|
7ea4ccccef | ||
|
|
0b1ed0fbeb | ||
|
|
0aac0a2377 | ||
|
|
04810b91ef | ||
|
|
f072f0e044 | ||
|
|
6e2278f4f0 | ||
|
|
7c95d9614d | ||
|
|
54e8e5102a | ||
|
|
b270d022d4 | ||
|
|
f087933d48 | ||
|
|
ed1d1515bc | ||
|
|
aa364f5e77 | ||
|
|
5ae6d17ef3 | ||
|
|
4590bdcde1 | ||
|
|
f9465e8206 | ||
|
|
cd3a9f1af4 | ||
|
|
853668ff1b | ||
|
|
e2ee55bab4 | ||
|
|
7a13715897 | ||
|
|
d92e3e4616 | ||
|
|
49023ff701 | ||
|
|
1bd405d13e | ||
|
|
69de2fa178 | ||
|
|
cdcf904ac8 | ||
|
|
80f9100bf0 | ||
|
|
751509ece4 | ||
|
|
f36d558e13 | ||
|
|
ab8ae8ee76 | ||
|
|
aca14f8a04 | ||
|
|
6ec13051bb | ||
|
|
ebc7bfa30a | ||
|
|
e59717d61d | ||
|
|
7f5a90b080 | ||
|
|
51d26a7983 | ||
|
|
d1d001fcf6 | ||
|
|
79f33ca0d1 | ||
|
|
7f37937185 | ||
|
|
0e9164a506 | ||
|
|
91361a6373 | ||
|
|
cfe5f33a63 | ||
|
|
e50566e2cb | ||
|
|
f793f4e67a | ||
|
|
b57428e3fe | ||
|
|
3137c45704 | ||
|
|
38c270558c | ||
|
|
39a36fa73c | ||
|
|
ae83355860 | ||
|
|
60d910d148 | ||
|
|
251d227ddb | ||
|
|
45e597c665 | ||
|
|
f0e60903b5 | ||
|
|
db49946e5e | ||
|
|
50ebc737e6 | ||
|
|
28d1775c86 | ||
|
|
0a1a381ebc | ||
|
|
651067fb17 | ||
|
|
1f634d668e | ||
|
|
f5bf8c70b4 | ||
|
|
f50731f83e | ||
|
|
f44d916b32 | ||
|
|
9cfb27da28 | ||
|
|
b09bd35737 | ||
|
|
b998cac5c8 | ||
|
|
9b34ffebb8 | ||
|
|
3eaaf75bfb | ||
|
|
c1bae96ad9 | ||
|
|
ddb6f53655 | ||
|
|
c37f52bbb1 | ||
|
|
dd805f1860 | ||
|
|
d9551f2827 | ||
|
|
1750a1bf5f | ||
|
|
d42f5ef5af | ||
|
|
2ca940a929 | ||
|
|
36f33b54af | ||
|
|
d0b4be6db8 | ||
|
|
4afa0bb538 | ||
|
|
201bcceaab | ||
|
|
92ad314ce1 | ||
|
|
b8962539e8 | ||
|
|
01db728b99 | ||
|
|
8525dda6f4 | ||
|
|
e8f7f57e0b | ||
|
|
8c62b47d5b | ||
|
|
2ab0b119e7 | ||
|
|
20d919c65e | ||
|
|
bd41c5b9ff | ||
|
|
60aaf0cff6 | ||
|
|
71c8f8171b | ||
|
|
2bc4e3dd3f | ||
|
|
302eaa13c9 | ||
|
|
23ff51bab8 | ||
|
|
96ee695521 | ||
|
|
a9a587495a | ||
|
|
0b69e20adc | ||
|
|
a08e531226 | ||
|
|
1e27933573 | ||
|
|
0b4815842f | ||
|
|
cc6aec99e0 | ||
|
|
b51bace9f5 | ||
|
|
c70223a800 | ||
|
|
36353b5693 | ||
|
|
d4fc903c14 | ||
|
|
980d2d89df | ||
|
|
c952a8ac08 | ||
|
|
a651c9b8da | ||
|
|
c695e8b2f9 | ||
|
|
ee72bc2ef5 | ||
|
|
ebd47e9b56 | ||
|
|
5cf5e7c543 | ||
|
|
7f2d62b5e5 | ||
|
|
8d07f7cf9f | ||
|
|
789db52b57 | ||
|
|
5fb3458a98 | ||
|
|
f6935ce60b | ||
|
|
b1eb592137 | ||
|
|
913f8ccdf7 | ||
|
|
3f951263b9 | ||
|
|
744fc87491 | ||
|
|
ca01a94502 | ||
|
|
879a58d1f4 | ||
|
|
aab40b68a7 | ||
|
|
9533e2ec46 | ||
|
|
7b2e767cac | ||
|
|
4bdd000917 | ||
|
|
b397ae52f9 | ||
|
|
40620f1daa | ||
|
|
4d8d43ee2a | ||
|
|
4f8a32c3e8 | ||
|
|
1d303dee71 | ||
|
|
e9659ab1e8 | ||
|
|
ee917dbf32 | ||
|
|
2a275fe503 | ||
|
|
a5631cd2e4 | ||
|
|
1ed1a2c41d | ||
|
|
c2bf0322a7 | ||
|
|
3f8f84735f | ||
|
|
2fb28dda32 | ||
|
|
6192515550 | ||
|
|
6fcf893bac | ||
|
|
d0dfa19f2d | ||
|
|
c3b4abea40 | ||
|
|
a030d1272b | ||
|
|
d6c4b51b98 | ||
|
|
a306d76c19 | ||
|
|
1d51ee0711 | ||
|
|
e340874270 | ||
|
|
093b01d7ff | ||
|
|
5b129cc254 | ||
|
|
7a32697906 | ||
|
|
2ea272ee4a | ||
|
|
9ebfc9748d | ||
|
|
d1a2b6a016 | ||
|
|
af78424b07 | ||
|
|
c35546e536 | ||
|
|
7db03a2f8a | ||
|
|
99f3765e6e | ||
|
|
fae001a48f | ||
|
|
1ccb35ad62 | ||
|
|
2b4e570172 | ||
|
|
965b6cc740 | ||
|
|
ffda4ba6f5 | ||
|
|
df2da4fc89 | ||
|
|
cea40033f9 | ||
|
|
42a01a44aa | ||
|
|
17c07d0e01 | ||
|
|
ea4d088b04 | ||
|
|
591198175a | ||
|
|
be93369a8b | ||
|
|
fd6553a52a | ||
|
|
961f460ffb | ||
|
|
eb925d9022 | ||
|
|
d05072eb2c | ||
|
|
f456ddf8a4 | ||
|
|
c395b68d6a | ||
|
|
fddd5d0311 | ||
|
|
f08c38ff1a | ||
|
|
a4bd9108b1 | ||
|
|
de1377dc8f | ||
|
|
00ce32c528 | ||
|
|
0ddcb12b31 | ||
|
|
adadecfa19 | ||
|
|
ac35ef8b5d | ||
|
|
65f1c72b8e | ||
|
|
178bff37f5 | ||
|
|
48b9d4fb41 | ||
|
|
81d6583430 | ||
|
|
0304c9ff44 | ||
|
|
bf591e708d | ||
|
|
14bbd111f9 | ||
|
|
2185c27be5 | ||
|
|
aef9e24d28 | ||
|
|
d1a35b721e | ||
|
|
17abd0c8cc | ||
|
|
a907cd51b9 | ||
|
|
9f6c7db8fd | ||
|
|
2ba83d8cc5 | ||
|
|
40bf0e173e | ||
|
|
a757292b4b | ||
|
|
b41d466546 | ||
|
|
135fdc94d4 | ||
|
|
d0092a2ffe | ||
|
|
acf31009d5 | ||
|
|
981c6155e7 | ||
|
|
2ecc86fc7b | ||
|
|
2682428354 | ||
|
|
df8ad26684 | ||
|
|
1f714c0153 | ||
|
|
0bfadad222 | ||
|
|
a1c719fc50 | ||
|
|
fe9812cd69 | ||
|
|
b9699b27c7 | ||
|
|
2c5ddb542e | ||
|
|
461642d64b | ||
|
|
37a8a2379d | ||
|
|
e698392e40 | ||
|
|
e1357b265f | ||
|
|
a5475b0268 | ||
|
|
60dba9efa6 | ||
|
|
e2d3391070 | ||
|
|
aed34ec28d | ||
|
|
ae6d88ab56 | ||
|
|
35be7283e9 | ||
|
|
224fcb83d9 | ||
|
|
98934536be | ||
|
|
5ac3712e56 | ||
|
|
2d2d4e6d44 | ||
|
|
4b1921b754 | ||
|
|
8ca1d44375 | ||
|
|
23c82cc6ed | ||
|
|
2bf5280827 | ||
|
|
475a1e0ef1 | ||
|
|
ef4d53eb85 | ||
|
|
97da4f7809 | ||
|
|
1622dac67f | ||
|
|
fce1ec5042 | ||
|
|
060bcc95e1 | ||
|
|
5aca80609a | ||
|
|
7c1da21026 | ||
|
|
52329a6de5 | ||
|
|
8cdef228e3 | ||
|
|
432d6d837a | ||
|
|
f42e8b2298 | ||
|
|
107f5b9215 | ||
|
|
d303fcc45b | ||
|
|
147be9ab7c | ||
|
|
7f91f9dbad | ||
|
|
63e538511b | ||
|
|
d0c8abc38c | ||
|
|
97a28b9e0c | ||
|
|
b5ae6e65a1 | ||
|
|
0c7e740d7a | ||
|
|
1b7462becc | ||
|
|
d508ecd4c0 | ||
|
|
601d6f8a53 | ||
|
|
44be4eceb8 | ||
|
|
8bebd57169 | ||
|
|
8f426cef31 | ||
|
|
abce477f0d | ||
|
|
985e797f83 | ||
|
|
8bc84cbdd2 | ||
|
|
894e4eef26 | ||
|
|
5995dabf6f | ||
|
|
ed647b7e5d | ||
|
|
e378732d44 | ||
|
|
74eb5dd85a | ||
|
|
c9ba396c33 | ||
|
|
3967ac4fa5 | ||
|
|
b1a35df7b5 | ||
|
|
0e1c9b3f7e | ||
|
|
0238ac8fc4 | ||
|
|
4d6baf0b0c | ||
|
|
157fab6309 | ||
|
|
fb8dcf53e3 | ||
|
|
a01f35c53d |
13
.github/CONTRIBUTING.md
vendored
Normal file
13
.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
If you wish to contribute to the HMCCosmetics codebase, feel free to fork the repository and [submit a pull request](https://github.com/HibiscusMC/HMCCosmetics/compare).
|
||||||
|
> **Note** Contributions to the HMCCosmetics codebase should remain consistent with current code style. Remember to keep your code clean, documented and understandable, and to avoid messy or confusing code.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
To get ready to work on the codebase, please do the following:
|
||||||
|
|
||||||
|
1. Fork & clone the repository, and make sure you're on the **remapped** branch. (*This is the default branch*)
|
||||||
|
2. Code your heart out!
|
||||||
|
3. Run `./gradlew build` to ensure your project successfully builds. (*This may take a while*)
|
||||||
|
4. Finally, [submit a pull request](https://github.com/HibiscusMC/HMCCosmetics/compare)!
|
||||||
61
.github/ISSUE_TEMPLATE/01-bug_report.yml
vendored
Normal file
61
.github/ISSUE_TEMPLATE/01-bug_report.yml
vendored
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
name: Bug Report
|
||||||
|
description: Report an issue with HMCCosmetics
|
||||||
|
labels: [bug]
|
||||||
|
assignees: ["LoJoSho"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thank you for filing an bug report! If you are here to ask a question, use our [Discord server](https://discord.gg/pcm8kWrdNt) instead!
|
||||||
|
- type: input
|
||||||
|
id: release_version
|
||||||
|
attributes:
|
||||||
|
label: Plugin Version
|
||||||
|
placeholder: vx.x.x
|
||||||
|
description: |
|
||||||
|
Insert the version of HMCCosmetics you are using (e.g. `v2.2.8`). Before continuing make sure you have the latest version of HMCCosmetics as
|
||||||
|
your issue may have already been resolved.
|
||||||
|
- type: input
|
||||||
|
id: server_version
|
||||||
|
attributes:
|
||||||
|
label: Server Version
|
||||||
|
placeholder: fork-x-x.x.x
|
||||||
|
description: |
|
||||||
|
Insert the version of your minecraft server in the format `fork-build-version` (e.g. `PAPER-521-1.19.4`, `PURPUR-1838-1.19.2`)
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Issue description
|
||||||
|
description: Describe the issue in as much detail as possible (Include any error logs in a code block below)
|
||||||
|
- type: textarea
|
||||||
|
id: reproduce
|
||||||
|
attributes:
|
||||||
|
label: Steps to reproduce
|
||||||
|
description: Explain how to reproduce this issue step-by-step, in as much detail as possible.
|
||||||
|
placeholder: |
|
||||||
|
Steps to reproduce:
|
||||||
|
1. Do thing
|
||||||
|
2. Observe behavior
|
||||||
|
3. Post any error logs below
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: priority
|
||||||
|
attributes:
|
||||||
|
label: Issue priority
|
||||||
|
description: Please be realistic. If you need to elaborate on your reasoning, please use the issue description field above.
|
||||||
|
options:
|
||||||
|
- Low (slightly annoying)
|
||||||
|
- Medium (should be fixed somewhat soon)
|
||||||
|
- High (immediate attention needed)
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: versions
|
||||||
|
attributes:
|
||||||
|
label: Other Versions
|
||||||
|
placeholder: |
|
||||||
|
- ModelEngine R3.0.1 (`/version ModelEngine`)
|
||||||
|
- Any other relevant version information such as depenedencies
|
||||||
|
description: |
|
||||||
|
List any necessary or relevant versions here.
|
||||||
28
.github/ISSUE_TEMPLATE/02-feature_request.yml
vendored
Normal file
28
.github/ISSUE_TEMPLATE/02-feature_request.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Feature Request
|
||||||
|
description: Request a new feature for HMCCosmetics
|
||||||
|
labels: [enhancement]
|
||||||
|
assignees: ["LoJoSho"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
If you are here to ask a question, use our [Discord server](https://discord.gg/pcm8kWrdNt) instead!
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Please check that the feature you are requesting does not already exist *and/or* hasn't already been requested by someone else.
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Feature Description
|
||||||
|
description: A clear and concise description of what the problem is, or what feature you want to be implemented.
|
||||||
|
placeholder: A good addition would be...
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: solution
|
||||||
|
attributes:
|
||||||
|
label: Implementation Description
|
||||||
|
description: A clear and concise description of what you want to happen, and any optional **configuration changes** that need to be made.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
62
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
62
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
@@ -1,62 +0,0 @@
|
|||||||
name: Bug Report
|
|
||||||
description: Create a bug report to help us keep track of all bugs that have to be fixed
|
|
||||||
title: "[BUG] <name for bug>"
|
|
||||||
labels: [bug]
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: checkboxes
|
|
||||||
id: i-have-checked
|
|
||||||
attributes:
|
|
||||||
label: I have checked...
|
|
||||||
options:
|
|
||||||
- label: "I am using the latest version of HMCCosmetics"
|
|
||||||
required: true
|
|
||||||
- label: "I am using the latest version of any dependencies"
|
|
||||||
required: true
|
|
||||||
- label: "I have checked if any similar bug reports exist"
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: description
|
|
||||||
attributes:
|
|
||||||
label: Description
|
|
||||||
description: A full description of the bug
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: reproduce
|
|
||||||
attributes:
|
|
||||||
label: Steps to reproduce
|
|
||||||
description: Explain how to reproduce this issue step-by-step, in as much detail as possible.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: hmcc-version
|
|
||||||
attributes:
|
|
||||||
label: Plugin Version
|
|
||||||
description: Run `version HMCCosmetics` in your console and paste the output
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: meg-version
|
|
||||||
attributes:
|
|
||||||
label: ModelEngine Version
|
|
||||||
description: "Run `version ModelEngine` in your console and paste the output. Optional if not using balloons."
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: textarea
|
|
||||||
id: server-version
|
|
||||||
attributes:
|
|
||||||
label: Server Version
|
|
||||||
description: "Run `version` in your console and paste the output."
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "dropdown"
|
|
||||||
id: "type"
|
|
||||||
attributes:
|
|
||||||
label: "How breaking is the bug?"
|
|
||||||
options:
|
|
||||||
- "Breaking Bug - Plugin unusable"
|
|
||||||
- "Non-breaking Bug - Plugin still usable, but certain features unavailable"
|
|
||||||
- "Minor Bug - Plugin completely functional, but features have non-working aspects"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: General Questions and Help
|
||||||
|
url: https://discord.gg/pcm8kWrdNt
|
||||||
|
about: This issue tracker is not for support questions. Please refer to the Hibiscus community's help and discussion discord server.
|
||||||
29
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
29
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@@ -1,29 +0,0 @@
|
|||||||
name: Feature Request
|
|
||||||
description: Create a feature request to help us keep track of all features you want to be added
|
|
||||||
title: "[FEATURE] <title>"
|
|
||||||
labels: [feature]
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: "checkboxes"
|
|
||||||
id: "i-have-checked"
|
|
||||||
attributes:
|
|
||||||
label: "I have checked that..."
|
|
||||||
options:
|
|
||||||
- label: "...such a feature does not exist already"
|
|
||||||
required: true
|
|
||||||
- label: "...such a feature request has not been submitted already"
|
|
||||||
required: true
|
|
||||||
- type: "textarea"
|
|
||||||
id: "description"
|
|
||||||
attributes:
|
|
||||||
label: "Description"
|
|
||||||
description: "A full description of the feature"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: "textarea"
|
|
||||||
id: "config-changes"
|
|
||||||
attributes:
|
|
||||||
label: "Config Changes"
|
|
||||||
description: "The configuration changes your feature should have"
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
19
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
19
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#### Select the option(s) that best describes this PR:
|
||||||
|
- [ ] Major breaking change
|
||||||
|
- [ ] Minor change
|
||||||
|
- [ ] Feature implementation
|
||||||
|
- [ ] Bug fix
|
||||||
|
- [ ] Chore (Changes that don't fix or add new features *and don't* modify source files)
|
||||||
|
- [ ] Refactoring (Changes that dont't fix or add new features *but do* modify source files)
|
||||||
|
- [ ] Documentation (Changes to README files and/or JavaDocs)
|
||||||
|
- [ ] Style (Changes that don't affect the meaning of the code)
|
||||||
|
- [ ] Performance
|
||||||
|
- [ ] Other (Please specify below)
|
||||||
|
|
||||||
|
#### Please describe the changes this PR makes and why it should be merged:
|
||||||
|
|
||||||
|
#### Check that:
|
||||||
|
- [ ] *Any* new classes, public methods and/or properties are properly documented with `JavaDocs`
|
||||||
|
- [ ] Syntax and style are consistent with existing code
|
||||||
|
- [ ] *Any* replaced method isn't deleted, but rather labeled as deprecated
|
||||||
|
> **Note** In the case where the new method has the exact same signature as the method it's replacing, mention above that the old method *was* deleted.
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,7 +23,6 @@ atlassian-ide-plugin.xml
|
|||||||
*.ctxt
|
*.ctxt
|
||||||
|
|
||||||
# Package Files #
|
# Package Files #
|
||||||
*.jar
|
|
||||||
*.war
|
*.war
|
||||||
*.nar
|
*.nar
|
||||||
*.ear
|
*.ear
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
id("xyz.jpenilla.run-paper") version "2.0.0"
|
id("xyz.jpenilla.run-paper") version "2.0.0"
|
||||||
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
|
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.2.1"
|
version = "2.5.0"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -27,6 +27,7 @@ allprojects {
|
|||||||
// ProtocolLib repo
|
// ProtocolLib repo
|
||||||
maven("https://repo.dmulloy2.net/repository/public/") //ProtocolLib Repo, constantly down
|
maven("https://repo.dmulloy2.net/repository/public/") //ProtocolLib Repo, constantly down
|
||||||
maven("https://repo.mineinabyss.com/releases/")
|
maven("https://repo.mineinabyss.com/releases/")
|
||||||
|
maven("https://repo.mineinabyss.com/snapshots/")
|
||||||
|
|
||||||
// PlaceholderAPI
|
// PlaceholderAPI
|
||||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||||
@@ -34,8 +35,8 @@ allprojects {
|
|||||||
//Hikari
|
//Hikari
|
||||||
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
|
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
|
||||||
|
|
||||||
// Citizens
|
// Citizens & Denizen
|
||||||
maven("https://repo.citizensnpcs.co")
|
maven("https://maven.citizensnpcs.co/repo")
|
||||||
|
|
||||||
// Worldguard
|
// Worldguard
|
||||||
maven("https://maven.enginehub.org/repo/")
|
maven("https://maven.enginehub.org/repo/")
|
||||||
@@ -59,45 +60,48 @@ allprojects {
|
|||||||
|
|
||||||
// PlayerAnimator
|
// PlayerAnimator
|
||||||
maven("https://mvn.lumine.io/repository/maven/")
|
maven("https://mvn.lumine.io/repository/maven/")
|
||||||
|
|
||||||
|
// md-5 Repo
|
||||||
|
maven("https://repo.md-5.net/content/groups/public/")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
compileOnly("com.mineinabyss:idofront:0.12.111")
|
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||||
compileOnly("com.mineinabyss:geary-papermc-core:0.19.113")
|
|
||||||
compileOnly("com.mineinabyss:looty:0.8.67")
|
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(path = ":common"))
|
implementation(project(path = ":common"))
|
||||||
implementation(project(path = ":v1_17_R1", configuration = "reobf"))
|
|
||||||
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
||||||
|
implementation(project(path = ":v1_19_R3", configuration = "reobf"))
|
||||||
|
implementation(project(path = ":v1_20_R1", configuration = "reobf"))
|
||||||
|
|
||||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||||
implementation("net.kyori:adventure-api:4.11.0")
|
implementation("net.kyori:adventure-api:4.11.0")
|
||||||
implementation ("net.kyori:adventure-text-minimessage:4.11.0")
|
implementation("net.kyori:adventure-text-minimessage:4.11.0")
|
||||||
implementation("net.kyori:adventure-platform-bukkit:4.1.2")
|
implementation("net.kyori:adventure-platform-bukkit:4.1.2")
|
||||||
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
||||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
||||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||||
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
@@ -117,14 +121,15 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.19.2")
|
minecraftVersion("1.20.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
dependsOn(":v1_17_R1:reobfJar")
|
|
||||||
dependsOn(":v1_18_R2:reobfJar")
|
dependsOn(":v1_18_R2:reobfJar")
|
||||||
dependsOn(":v1_19_R1:reobfJar")
|
dependsOn(":v1_19_R1:reobfJar")
|
||||||
dependsOn(":v1_19_R2:reobfJar")
|
dependsOn(":v1_19_R2:reobfJar")
|
||||||
|
dependsOn(":v1_19_R3:reobfJar")
|
||||||
|
dependsOn(":v1_20_R1:reobfJar")
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
|
||||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||||
@@ -137,6 +142,7 @@ tasks {
|
|||||||
relocate("com.jeff_media.updatechecker", "com.hisbiscusmc.hmccosmetics.updatechecker")
|
relocate("com.jeff_media.updatechecker", "com.hisbiscusmc.hmccosmetics.updatechecker")
|
||||||
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
|
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
|
||||||
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
||||||
|
relocate("com.bgsoftware", "com.hisbiscusmc.hmccosmetics.configupdater")
|
||||||
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -161,11 +167,14 @@ tasks {
|
|||||||
bukkit {
|
bukkit {
|
||||||
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
||||||
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
||||||
apiVersion = "1.17"
|
apiVersion = "1.18"
|
||||||
authors = listOf("LoJoSho")
|
authors = listOf("LoJoSho")
|
||||||
depend = listOf("ProtocolLib")
|
depend = listOf("ProtocolLib")
|
||||||
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Looty", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish")
|
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen")
|
||||||
version = "${project.version}"
|
version = "${project.version}"
|
||||||
|
loadBefore = listOf(
|
||||||
|
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
||||||
|
)
|
||||||
|
|
||||||
commands {
|
commands {
|
||||||
register("cosmetic") {
|
register("cosmetic") {
|
||||||
@@ -197,10 +206,16 @@ bukkit {
|
|||||||
register("hmccosmetics.cmd.emote") {
|
register("hmccosmetics.cmd.emote") {
|
||||||
default = BukkitPluginDescription.Permission.Default.TRUE
|
default = BukkitPluginDescription.Permission.Default.TRUE
|
||||||
}
|
}
|
||||||
|
register("hmccosmetics.cmd.playemote") {
|
||||||
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
|
}
|
||||||
|
register("hmccosmetics.cmd.playemote.other") {
|
||||||
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
|
}
|
||||||
register("hmccosmetics.cmd.emote.other") {
|
register("hmccosmetics.cmd.emote.other") {
|
||||||
default = BukkitPluginDescription.Permission.Default.OP
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
}
|
}
|
||||||
register("hmccosmetics.cmd.setlocation") {
|
register("hmccosmetics.cmd.setwardrobesetting") {
|
||||||
default = BukkitPluginDescription.Permission.Default.OP
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
}
|
}
|
||||||
register("hmccosmetics.cmd.dataclear") {
|
register("hmccosmetics.cmd.dataclear") {
|
||||||
@@ -245,4 +260,4 @@ bukkit {
|
|||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,20 +5,23 @@ plugins {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
compileOnly("com.mineinabyss:geary-papermc-core:0.19.113")
|
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||||
compileOnly("com.mineinabyss:looty:0.8.67")
|
|
||||||
compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT")
|
compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT")
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||||
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
|
||||||
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||||
|
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
|
||||||
|
exclude("org.spigotmc", "spigot")
|
||||||
|
}
|
||||||
|
|
||||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||||
implementation("net.kyori:adventure-api:4.12.0")
|
implementation("net.kyori:adventure-api:4.12.0")
|
||||||
@@ -29,7 +32,9 @@ dependencies {
|
|||||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||||
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics;
|
package com.hibiscusmc.hmccosmetics;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticSetupEvent;
|
import com.bgsoftware.common.config.CommentedConfiguration;
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
||||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
@@ -11,6 +12,8 @@ import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
|
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
|
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
|
||||||
@@ -18,14 +21,13 @@ import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
|
|||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||||
import com.jeff_media.updatechecker.UpdateCheckSource;
|
import com.jeff_media.updatechecker.UpdateCheckSource;
|
||||||
import com.jeff_media.updatechecker.UpdateChecker;
|
import com.jeff_media.updatechecker.UpdateChecker;
|
||||||
import com.ticxo.playeranimator.PlayerAnimatorImpl;
|
import com.ticxo.playeranimator.PlayerAnimatorImpl;
|
||||||
import com.ticxo.playeranimator.api.PlayerAnimator;
|
|
||||||
import com.ticxo.playeranimator.api.animation.pack.AnimationPack;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -41,9 +43,6 @@ import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public final class HMCCosmeticsPlugin extends JavaPlugin {
|
public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||||
|
|
||||||
@@ -51,7 +50,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
private static boolean disable = false;
|
private static boolean disable = false;
|
||||||
private static YamlConfigurationLoader configLoader;
|
private static YamlConfigurationLoader configLoader;
|
||||||
private static final int pluginId = 13873;
|
private static final int pluginId = 13873;
|
||||||
private static boolean hasModelEngine = false;
|
|
||||||
private static boolean onLatestVersion = true;
|
private static boolean onLatestVersion = true;
|
||||||
private static String latestVersion = "";
|
private static String latestVersion = "";
|
||||||
|
|
||||||
@@ -89,13 +87,12 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
.checkNow();
|
.checkNow();
|
||||||
onLatestVersion = checker.isUsingLatestVersion();
|
onLatestVersion = checker.isUsingLatestVersion();
|
||||||
// File setup
|
// File setup
|
||||||
if (!getDataFolder().exists()) {
|
saveDefaultConfig();
|
||||||
saveDefaultConfig();
|
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
|
||||||
saveResource("translations.yml", false);
|
if (!Path.of(getDataFolder().getPath(), "translations.yml").toFile().exists()) saveResource("translations.yml", false);
|
||||||
saveResource("messages.yml", false);
|
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
|
||||||
saveResource("cosmetics/defaultcosmetics.yml", false);
|
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
|
||||||
saveResource("menus/defaultmenu.yml", false);
|
|
||||||
}
|
|
||||||
// Emote folder setup
|
// Emote folder setup
|
||||||
File emoteFile = new File(getDataFolder().getPath() + "/emotes");
|
File emoteFile = new File(getDataFolder().getPath() + "/emotes");
|
||||||
if (!emoteFile.exists()) emoteFile.mkdir();
|
if (!emoteFile.exists()) emoteFile.mkdir();
|
||||||
@@ -103,6 +100,20 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
// Player Animator
|
// Player Animator
|
||||||
PlayerAnimatorImpl.initialize(this);
|
PlayerAnimatorImpl.initialize(this);
|
||||||
|
|
||||||
|
// Configuration Sync
|
||||||
|
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
||||||
|
final File messageFile = Path.of(getInstance().getDataFolder().getPath(), "messages.yml").toFile();
|
||||||
|
final File translationFile = Path.of(getInstance().getDataFolder().getPath(), "translations.yml").toFile();
|
||||||
|
try {
|
||||||
|
CommentedConfiguration.loadConfiguration(configFile).syncWithConfig(configFile, getInstance().getResource("config.yml"),
|
||||||
|
"database-settings", "debug-mode", "wardrobe.viewer-location", "wardrobe.npc-location", "wardrobe.wardrobe-location", "wardrobe.leave-location");
|
||||||
|
CommentedConfiguration.loadConfiguration(messageFile).syncWithConfig(messageFile, getInstance().getResource("messages.yml"));
|
||||||
|
CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
@@ -116,13 +127,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
// Database
|
// Database
|
||||||
new Database();
|
new Database();
|
||||||
|
|
||||||
// ModelEngine
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("ModelEngine") != null) {
|
|
||||||
hasModelEngine = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// WorldGuard
|
// WorldGuard
|
||||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
|
||||||
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,11 +143,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
// Plugin shutdown logic
|
||||||
disable = true;
|
disable = true;
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
Database.save(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) continue;
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
player.setInvisible(false);
|
||||||
|
}
|
||||||
|
Database.save(user);
|
||||||
}
|
}
|
||||||
// Plugin shutdown logic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HMCCosmeticsPlugin getInstance() {
|
public static HMCCosmeticsPlugin getInstance() {
|
||||||
@@ -168,7 +179,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
WardrobeSettings.load(loader.load().node("wardrobe"));
|
WardrobeSettings.load(loader.load().node("wardrobe"));
|
||||||
DatabaseSettings.load(loader.load().node("database-settings"));
|
DatabaseSettings.load(loader.load().node("database-settings"));
|
||||||
configLoader = loader;
|
configLoader = loader;
|
||||||
} catch (ConfigurateException e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,26 +245,19 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
getInstance().getServer().getPluginManager().addPermission(new Permission(cosmetic.getPermission()));
|
getInstance().getServer().getPluginManager().addPermission(new Permission(cosmetic.getPermission()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (Menu menu : Menus.values()) {
|
||||||
File emoteFolder = new File(getInstance().getDataFolder().getPath() + "/emotes/");
|
if (menu.getPermissionNode() != null) {
|
||||||
if (emoteFolder.exists()) {
|
if (getInstance().getServer().getPluginManager().getPermission(menu.getPermissionNode()) != null) continue;
|
||||||
PlayerAnimator.api.getAnimationManager().clearRegistry();
|
getInstance().getServer().getPluginManager().addPermission(new Permission(menu.getPermissionNode()));
|
||||||
File[] emotesFiles = emoteFolder.listFiles();
|
|
||||||
for (File emoteFile : emotesFiles) {
|
|
||||||
if (!emoteFile.getName().contains("bbmodel")) continue;
|
|
||||||
String animationName = emoteFile.getName().replaceAll(".bbmodel", "");
|
|
||||||
PlayerAnimator.api.getAnimationManager().importAnimations(FilenameUtils.removeExtension(emoteFile.getName()), emoteFile);
|
|
||||||
MessagesUtil.sendDebugMessages("Added '" + animationName + "' to Player Animator ");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
|
|
||||||
//Set<String> animationNames = packEntry.getValue().getAnimations().keySet().stream().map(animation -> packEntry.getKey().replace(":", ".") + "." + animation).collect(Collectors.toSet());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EmoteManager.loadEmotes();
|
||||||
|
|
||||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||||
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus Successfully Setup");
|
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus Successfully Setup");
|
||||||
|
getInstance().getLogger().info(WardrobeSettings.getWardrobes().size() + " Wardrobes Successfully Setup");
|
||||||
getInstance().getLogger().info("Data storage is set to " + DatabaseSettings.getDatabaseType());
|
getInstance().getLogger().info("Data storage is set to " + DatabaseSettings.getDatabaseType());
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent());
|
Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent());
|
||||||
@@ -276,9 +280,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasModelEngine() {
|
|
||||||
return hasModelEngine;
|
|
||||||
}
|
|
||||||
public static boolean isOnLatestVersion() {
|
public static boolean isOnLatestVersion() {
|
||||||
return onLatestVersion;
|
return onLatestVersion;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class HMCCosmeticsAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to get a cosmetic from HMCCosmetics
|
||||||
|
*
|
||||||
|
* @param cosmetic Cosmetic Id
|
||||||
|
* @return A {@link Cosmetic} if exists or null if it does not
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static Cosmetic getCosmetic(String cosmetic) {
|
||||||
|
return Cosmetics.getCosmetic(cosmetic);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to get the CosmeticUser from an online user. If a player is offline it will return null.
|
||||||
|
* A player maybe online but not have a CosmeticUser attached to them, either from delay specified in the config
|
||||||
|
* or from a /reload. Always check if it's null!
|
||||||
|
*
|
||||||
|
* @param uuid Player Unique ID
|
||||||
|
* @return A {@link CosmeticUser} if exists or null if it does not
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static CosmeticUser getUser(UUID uuid) {
|
||||||
|
return CosmeticUsers.getUser(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to get a HMCCosmetics Menu. Returns null if no menu exists under that id.
|
||||||
|
*
|
||||||
|
* @param id Menu ID
|
||||||
|
* @return A {@link Menu} if exists or null if it does not
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static Menu getMenu(String id) {
|
||||||
|
return Menus.getMenu(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equips a cosmetic to a player. You can use getUser and getCosmetic to get the CosmeticUser and Cosmetic to equip.
|
||||||
|
* @param user CosmeticUser to equip cosmetic to
|
||||||
|
* @param cosmetic Cosmetic to equip
|
||||||
|
*/
|
||||||
|
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic) {
|
||||||
|
equipCosmetic(user, cosmetic, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equips a cosmetic to a player with a color. You can use getUser and getCosmetic to get the CosmeticUser and Cosmetic to equip.
|
||||||
|
* @param user CosmeticUser to equip cosmetic to
|
||||||
|
* @param cosmetic Cosmetic to equip
|
||||||
|
* @param color Color to apply to cosmetic
|
||||||
|
*/
|
||||||
|
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic, @Nullable Color color) {
|
||||||
|
user.addPlayerCosmetic(cosmetic, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a cosmetic in cosmeticslot.
|
||||||
|
* @param user The user to remove the cosmetic from
|
||||||
|
* @param slot The slot to remove the cosmetic from
|
||||||
|
*/
|
||||||
|
public static void unequipCosmetic(CosmeticUser user, CosmeticSlot slot) {
|
||||||
|
user.removeCosmeticSlot(slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class PlayerCosmeticEquipEvent extends Event implements Cancellable {
|
|
||||||
|
|
||||||
private CosmeticUser user;
|
|
||||||
private Cosmetic cosmetic;
|
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticEquipEvent(CosmeticUser user, Cosmetic cosmetic) {
|
|
||||||
this.user = user;
|
|
||||||
this.cosmetic = cosmetic;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
isCancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cosmetic getCosmetic() {
|
|
||||||
return cosmetic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCosmetic() {
|
|
||||||
this.cosmetic = cosmetic;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class PlayerCosmeticHideEvent extends Event implements Cancellable {
|
|
||||||
|
|
||||||
private CosmeticUser user;
|
|
||||||
private CosmeticUser.HiddenReason reason;
|
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticHideEvent(CosmeticUser user, CosmeticUser.HiddenReason reason) {
|
|
||||||
this.user = user;
|
|
||||||
this.reason = reason;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
isCancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
public CosmeticUser.HiddenReason getReason() {
|
|
||||||
return reason;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class PlayerCosmeticRemoveEvent extends Event implements Cancellable {
|
|
||||||
|
|
||||||
private CosmeticUser user;
|
|
||||||
private Cosmetic cosmetic;
|
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticRemoveEvent(CosmeticUser user, Cosmetic cosmetic) {
|
|
||||||
this.user = user;
|
|
||||||
this.cosmetic = cosmetic;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
isCancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cosmetic getCosmetic() {
|
|
||||||
return cosmetic;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class PlayerCosmeticShowEvent extends Event implements Cancellable {
|
|
||||||
|
|
||||||
private CosmeticUser user;
|
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticShowEvent(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
isCancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class PlayerMenuOpenEvent extends Event implements Cancellable {
|
|
||||||
|
|
||||||
private CosmeticUser user;
|
|
||||||
private Menu menu;
|
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerMenuOpenEvent(CosmeticUser user, Menu menu) {
|
|
||||||
this.user = user;
|
|
||||||
this.menu = menu;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
isCancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Menu getMenu() {
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class PlayerWardrobeEnterEvent extends Event implements Cancellable {
|
|
||||||
|
|
||||||
private CosmeticUser user;
|
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerWardrobeEnterEvent(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
isCancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class PlayerWardrobeLeaveEvent extends Event implements Cancellable {
|
|
||||||
|
|
||||||
private CosmeticUser user;
|
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerWardrobeLeaveEvent(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return isCancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
isCancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +1,22 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the plugin is set up and/or reloaded
|
||||||
|
*/
|
||||||
public class HMCCosmeticSetupEvent extends Event {
|
public class HMCCosmeticSetupEvent extends Event {
|
||||||
|
|
||||||
public HMCCosmeticSetupEvent() {
|
|
||||||
// Empty
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player equips a cosmetic
|
||||||
|
*/
|
||||||
|
public class PlayerCosmeticEquipEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private Cosmetic cosmetic;
|
||||||
|
|
||||||
|
public PlayerCosmeticEquipEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||||
|
super(who);
|
||||||
|
this.cosmetic = cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Cosmetic} being equipped in this event
|
||||||
|
*
|
||||||
|
* @return The {@link Cosmetic} which is being equipped in this event
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public Cosmetic getCosmetic() {
|
||||||
|
return cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link Cosmetic} that the player will equip
|
||||||
|
*
|
||||||
|
* @param cosmetic The {@link Cosmetic} that the player will equip
|
||||||
|
*/
|
||||||
|
public void setCosmetic(@NotNull Cosmetic cosmetic) {
|
||||||
|
this.cosmetic = cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from equipping the cosmetic
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a cosmetic user related event
|
||||||
|
*/
|
||||||
|
public abstract class PlayerCosmeticEvent extends Event {
|
||||||
|
protected CosmeticUser user;
|
||||||
|
|
||||||
|
public PlayerCosmeticEvent(@NotNull final CosmeticUser who) {
|
||||||
|
user = who;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the user involved in this event
|
||||||
|
*
|
||||||
|
* @return User who is involved in this event
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public final CosmeticUser getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when cosmetics are hidden from a player
|
||||||
|
*/
|
||||||
|
public class PlayerCosmeticHideEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final CosmeticUser.HiddenReason reason;
|
||||||
|
|
||||||
|
public PlayerCosmeticHideEvent(@NotNull CosmeticUser who, @NotNull CosmeticUser.HiddenReason reason) {
|
||||||
|
super(who);
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link CosmeticUser.HiddenReason} as to why cosmetics are being hidden for the player
|
||||||
|
*
|
||||||
|
* @return The {@link CosmeticUser.HiddenReason} why cosmetics are being hidden for the player
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public CosmeticUser.HiddenReason getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from hiding cosmetics
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class PlayerCosmeticPostEquipEvent extends PlayerCosmeticEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private Cosmetic cosmetic;
|
||||||
|
|
||||||
|
public PlayerCosmeticPostEquipEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||||
|
super(who);
|
||||||
|
this.cosmetic = cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Cosmetic} being equipped in this event
|
||||||
|
*
|
||||||
|
* @return The {@link Cosmetic} which is being equipped in this event
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public Cosmetic getCosmetic() {
|
||||||
|
return cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link Cosmetic} that the player will equip
|
||||||
|
*
|
||||||
|
* @param cosmetic The {@link Cosmetic} that the player will equip
|
||||||
|
*/
|
||||||
|
public void setCosmetic(@NotNull Cosmetic cosmetic) {
|
||||||
|
this.cosmetic = cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player removes a cosmetic
|
||||||
|
*/
|
||||||
|
public class PlayerCosmeticRemoveEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final Cosmetic cosmetic;
|
||||||
|
|
||||||
|
public PlayerCosmeticRemoveEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||||
|
super(who);
|
||||||
|
this.cosmetic = cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Cosmetic} being removed in this event
|
||||||
|
*
|
||||||
|
* @return The {@link Cosmetic} which is being removed in this event
|
||||||
|
*/
|
||||||
|
public Cosmetic getCosmetic() {
|
||||||
|
return cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from removing the cosmetic
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when cosmetics are shown from a player
|
||||||
|
*/
|
||||||
|
public class PlayerCosmeticShowEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public PlayerCosmeticShowEvent(@NotNull CosmeticUser who) {
|
||||||
|
super(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from showing cosmetics
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player starts playing an emote
|
||||||
|
*/
|
||||||
|
public class PlayerEmoteStartEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final String animationId;
|
||||||
|
|
||||||
|
public PlayerEmoteStartEvent(@NotNull CosmeticUser who, @NotNull String animationId) {
|
||||||
|
super(who);
|
||||||
|
this.animationId = animationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation id of the emote the player started playing
|
||||||
|
* @implNote The returned string of this method may be an invalid animation id. Make sure to validate it before use
|
||||||
|
*
|
||||||
|
* @return The animation id of the emote which the player started playing
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public String getAnimationId() {
|
||||||
|
return animationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from playing the emote
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player stops playing an emote
|
||||||
|
*/
|
||||||
|
public class PlayerEmoteStopEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final UserEmoteManager.StopEmoteReason reason;
|
||||||
|
|
||||||
|
public PlayerEmoteStopEvent(@NotNull CosmeticUser who, @NotNull UserEmoteManager.StopEmoteReason reason) {
|
||||||
|
super(who);
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
|
||||||
|
*
|
||||||
|
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
|
||||||
|
* @deprecated As of release 2.2.5+, replaced by {@link #getReason()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@NotNull
|
||||||
|
public UserEmoteManager.StopEmoteReason getStopEmoteReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
|
||||||
|
*
|
||||||
|
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
|
||||||
|
* @since 2.2.5
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public UserEmoteManager.StopEmoteReason getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from stopping the emote
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a menu is closed by a player
|
||||||
|
*/
|
||||||
|
public class PlayerMenuCloseEvent extends PlayerMenuEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
public PlayerMenuCloseEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
|
||||||
|
super(who, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a menu related event
|
||||||
|
*/
|
||||||
|
public abstract class PlayerMenuEvent extends PlayerCosmeticEvent {
|
||||||
|
protected Menu menu;
|
||||||
|
|
||||||
|
public PlayerMenuEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
|
||||||
|
super(who);
|
||||||
|
this.menu = menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Menu} involved with this event
|
||||||
|
*
|
||||||
|
* @return The {@link Menu} which is involved with the event
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public final Menu getMenu() {
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a menu is opened by a player
|
||||||
|
*/
|
||||||
|
public class PlayerMenuOpenEvent extends PlayerMenuEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public PlayerMenuOpenEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
|
||||||
|
super(who, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from opening a {@link Menu}
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player enters their wardrobe
|
||||||
|
*/
|
||||||
|
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private Wardrobe wardrobe;
|
||||||
|
|
||||||
|
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull Wardrobe wardrobe) {
|
||||||
|
super(who);
|
||||||
|
this.wardrobe = wardrobe;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from entering their wardrobe
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWardrobe(Wardrobe wardrobe) {
|
||||||
|
this.wardrobe = wardrobe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Wardrobe getWardrobe() {
|
||||||
|
return wardrobe;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player leaves their wardrobe
|
||||||
|
*/
|
||||||
|
public class PlayerWardrobeLeaveEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public PlayerWardrobeLeaveEvent(@NotNull CosmeticUser who) {
|
||||||
|
super(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from leaving their wardrobe
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,15 @@ package com.hibiscusmc.hmccosmetics.command;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
|
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||||
@@ -27,13 +30,15 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class CosmeticCommand implements CommandExecutor {
|
public class CosmeticCommand implements CommandExecutor {
|
||||||
|
|
||||||
// cosmetics apply cosmetics playerName
|
// cosmetics apply cosmetics playerName
|
||||||
// 0 1 2
|
// 0 1 2
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
|
||||||
boolean silent = false;
|
boolean silent = false;
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
@@ -68,7 +73,10 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (sender.hasPermission("HMCCosmetics.cmd.silent") || sender.isOp()) {
|
if (sender.hasPermission("HMCCosmetics.cmd.silent") || sender.isOp()) {
|
||||||
for (String singleArg : args) {
|
for (String singleArg : args) {
|
||||||
if (singleArg.equalsIgnoreCase("-s")) silent = true;
|
if (singleArg.equalsIgnoreCase("-s")) {
|
||||||
|
silent = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +96,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Cosmetic cosmetic;
|
Cosmetic cosmetic;
|
||||||
Color color = Color.WHITE;
|
Color color = null;
|
||||||
|
|
||||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||||
if (sender.hasPermission("hmccosmetics.cmd.apply.other")) {
|
if (sender.hasPermission("hmccosmetics.cmd.apply.other")) {
|
||||||
@@ -144,19 +152,11 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CosmeticSlot cosmeticSlot = null;
|
|
||||||
|
|
||||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||||
if (sender.hasPermission("hmccosmetics.cmd.unapply.other")) {
|
if (sender.hasPermission("hmccosmetics.cmd.unapply.other")) {
|
||||||
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
|
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-slot");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
cosmeticSlot = CosmeticSlot.valueOf(args[1].toUpperCase());
|
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
return true;
|
return true;
|
||||||
@@ -164,26 +164,46 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
if (user.getCosmetic(cosmeticSlot) == null) {
|
Set<CosmeticSlot> cosmeticSlots;
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
|
|
||||||
return true;
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
cosmeticSlots = user.getSlotsWithCosmetics();
|
||||||
|
} else {
|
||||||
|
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-slot");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
cosmeticSlots = Set.of(CosmeticSlot.valueOf(args[1].toUpperCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TagResolver placeholders =
|
for (CosmeticSlot cosmeticSlot : cosmeticSlots) {
|
||||||
TagResolver.resolver(Placeholder.parsed("cosmetic", user.getCosmetic(cosmeticSlot).getId()),
|
if (user.getCosmetic(cosmeticSlot) == null) {
|
||||||
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
if (!silent) MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
|
||||||
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.name())));
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
|
TagResolver placeholders =
|
||||||
|
TagResolver.resolver(Placeholder.parsed("cosmetic", user.getCosmetic(cosmeticSlot).getId()),
|
||||||
|
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
||||||
|
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.name())));
|
||||||
|
|
||||||
user.removeCosmeticSlot(cosmeticSlot);
|
if (!silent) MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
|
||||||
user.updateCosmetic(cosmeticSlot);
|
|
||||||
|
user.removeCosmeticSlot(cosmeticSlot);
|
||||||
|
user.updateCosmetic(cosmeticSlot);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case ("wardrobe") -> {
|
case ("wardrobe") -> {
|
||||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("hmccosmetics.cmd.wardrobe.other")) {
|
if (sender.hasPermission("hmccosmetics.cmd.wardrobe.other")) {
|
||||||
if (args.length >= 2) player = Bukkit.getPlayer(args[1]);
|
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.wardrobe")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.wardrobe")) {
|
||||||
@@ -196,9 +216,19 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WardrobeSettings.getWardrobeNames().contains(args[1])) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "no-wardrobes");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
|
||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
user.toggleWardrobe();
|
if (user.isInWardrobe()) {
|
||||||
|
user.leaveWardrobe();
|
||||||
|
} else {
|
||||||
|
user.enterWardrobe(false, wardrobe);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// cosmetic menu exampleMenu playerName
|
// cosmetic menu exampleMenu playerName
|
||||||
@@ -277,36 +307,56 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
DyeMenu.openMenu(user, cosmetic);
|
DyeMenu.openMenu(user, cosmetic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ("setlocation") -> {
|
case ("setwardrobesetting") -> {
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.setlocation")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.setwardrobesetting")) {
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == null) return true;
|
if (player == null) return true;
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 3) {
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
|
||||||
|
if (wardrobe == null) {
|
||||||
|
wardrobe = new Wardrobe(args[1], new WardrobeLocation(null, null, null), null, -1);
|
||||||
|
WardrobeSettings.addWardrobe(wardrobe);
|
||||||
|
//MessagesUtil.sendMessage(player, "no-wardrobes");
|
||||||
|
//return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("wardrobelocation")) {
|
if (args[2].equalsIgnoreCase("npclocation")) {
|
||||||
WardrobeSettings.setWardrobeLocation(player.getLocation());
|
WardrobeSettings.setNPCLocation(wardrobe, player.getLocation());
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("viewerlocation")) {
|
if (args[2].equalsIgnoreCase("viewerlocation")) {
|
||||||
WardrobeSettings.setViewerLocation(player.getLocation());
|
WardrobeSettings.setViewerLocation(wardrobe, player.getLocation());
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("leavelocation")) {
|
if (args[2].equalsIgnoreCase("leavelocation")) {
|
||||||
WardrobeSettings.setLeaveLocation(player.getLocation());
|
WardrobeSettings.setLeaveLocation(wardrobe, player.getLocation());
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.length >= 4) {
|
||||||
|
if (args[2].equalsIgnoreCase("permission")) {
|
||||||
|
WardrobeSettings.setWardrobePermission(wardrobe, args[3]);
|
||||||
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-permission");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args[2].equalsIgnoreCase("distance")) {
|
||||||
|
WardrobeSettings.setWardrobeDistance(wardrobe, Integer.valueOf(args[3]));
|
||||||
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-distance");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case ("dump") -> {
|
case ("dump") -> {
|
||||||
if (player == null) return true;
|
if (player == null) return true;
|
||||||
@@ -318,9 +368,9 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
player.sendMessage("Passengers -> " + player.getPassengers());
|
player.sendMessage("Passengers -> " + player.getPassengers());
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorstand().getLocation());
|
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorStand().getLocation());
|
||||||
}
|
}
|
||||||
player.sendMessage("Cosmetics -> " + user.getCosmetic());
|
player.sendMessage("Cosmetics -> " + user.getCosmetics());
|
||||||
player.sendMessage("EntityId -> " + player.getEntityId());
|
player.sendMessage("EntityId -> " + player.getEntityId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -389,6 +439,10 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
if (sender.hasPermission("hmccosmetics.cmd.emote.other")) {
|
if (sender.hasPermission("hmccosmetics.cmd.emote.other")) {
|
||||||
if (args.length >= 2) player = Bukkit.getPlayer(args[1]);
|
if (args.length >= 2) player = Bukkit.getPlayer(args[1]);
|
||||||
}
|
}
|
||||||
|
if (player == null) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (!user.hasCosmeticInSlot(CosmeticSlot.EMOTE)) {
|
if (!user.hasCosmeticInSlot(CosmeticSlot.EMOTE)) {
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "emote-none");
|
if (!silent) MessagesUtil.sendMessage(sender, "emote-none");
|
||||||
@@ -399,6 +453,36 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
cosmeticEmoteType.run(user);
|
cosmeticEmoteType.run(user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ("playemote") -> {
|
||||||
|
// /cosmetic playEmote <emoteId> [playerName]
|
||||||
|
if (!sender.hasPermission("hmccosmetics.cmd.playemote")) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length < 2) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!EmoteManager.has(args[1])) {
|
||||||
|
MessagesUtil.sendDebugMessages("Did not contain " + args[1]);
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "emote-invalid");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender.hasPermission("hmccosmetics.cmd.playemote.other")) {
|
||||||
|
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
||||||
|
}
|
||||||
|
if (player == null) {
|
||||||
|
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
user.getUserEmoteManager().playEmote(args[1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.command;
|
package com.hibiscusmc.hmccosmetics.command;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
|
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.ticxo.playeranimator.api.PlayerAnimator;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -24,9 +26,9 @@ import java.util.List;
|
|||||||
public class CosmeticCommandTabComplete implements TabCompleter {
|
public class CosmeticCommandTabComplete implements TabCompleter {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String @NotNull [] args) {
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
List<String> finalCompletitons = new ArrayList<>();
|
List<String> finalCompletions = new ArrayList<>();
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.apply")) completions.add("apply");
|
if (hasPermission(sender, "hmccosmetics.cmd.apply")) completions.add("apply");
|
||||||
@@ -36,13 +38,14 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
if (hasPermission(sender, "hmccosmetics.cmd.wardrobe")) completions.add("wardrobe");
|
if (hasPermission(sender, "hmccosmetics.cmd.wardrobe")) completions.add("wardrobe");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.dataclear")) completions.add("dataclear");
|
if (hasPermission(sender, "hmccosmetics.cmd.dataclear")) completions.add("dataclear");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.dye")) completions.add("dye");
|
if (hasPermission(sender, "hmccosmetics.cmd.dye")) completions.add("dye");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.setlocation")) completions.add("setlocation");
|
if (hasPermission(sender, "hmccosmetics.cmd.setwardrobesetting")) completions.add("setwardrobesetting");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.hide")) completions.add("hide");
|
if (hasPermission(sender, "hmccosmetics.cmd.hide")) completions.add("hide");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.show")) completions.add("show");
|
if (hasPermission(sender, "hmccosmetics.cmd.show")) completions.add("show");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
|
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.emote")) completions.add("emote");
|
if (hasPermission(sender, "hmccosmetics.cmd.emote")) completions.add("emote");
|
||||||
|
if (hasPermission(sender, "hmccosmetics.cmd.playemote")) completions.add("playemote");
|
||||||
|
|
||||||
StringUtil.copyPartialMatches(args[0], completions, finalCompletitons);
|
StringUtil.copyPartialMatches(args[0], completions, finalCompletions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sender instanceof Player)) return completions;
|
if (!(sender instanceof Player)) return completions;
|
||||||
@@ -55,32 +58,43 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
completions.addAll(applyCommandComplete(user, args));
|
completions.addAll(applyCommandComplete(user, args));
|
||||||
}
|
}
|
||||||
case "unapply" -> {
|
case "unapply" -> {
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
completions.add(cosmetic.getSlot().toString().toUpperCase());
|
completions.add(cosmetic.getSlot().toString().toUpperCase());
|
||||||
}
|
}
|
||||||
|
completions.add("ALL");
|
||||||
}
|
}
|
||||||
case "menu" -> {
|
case "menu" -> {
|
||||||
for (Menu menu : Menus.getMenu()) {
|
for (Menu menu : Menus.getMenu()) {
|
||||||
if (menu.canOpen(user.getPlayer())) completions.add(menu.getId());
|
if (menu.canOpen(user.getPlayer())) completions.add(menu.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "dataclear", "wardrobe", "hide", "show", "emote" -> {
|
case "dataclear", "hide", "show", "emote" -> {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
completions.add(player.getName());
|
completions.add(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "wardrobe" -> {
|
||||||
|
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
|
||||||
|
if (wardrobe.hasPermission()) {
|
||||||
|
if (user.getPlayer().hasPermission(wardrobe.getPermission())) completions.add(wardrobe.getId());
|
||||||
|
} else {
|
||||||
|
completions.add(wardrobe.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
case "dye" -> {
|
case "dye" -> {
|
||||||
for (CosmeticSlot slot : user.getDyeableSlots()) {
|
for (CosmeticSlot slot : user.getDyeableSlots()) {
|
||||||
completions.add(slot.name());
|
completions.add(slot.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "setlocation" -> {
|
case "setwardrobesetting" -> {
|
||||||
completions.add("wardrobelocation");
|
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
|
||||||
completions.add("viewerlocation");
|
completions.add(wardrobe.getId());
|
||||||
completions.add("leavelocation");
|
}
|
||||||
}
|
}
|
||||||
|
case "playemote" -> completions.addAll(EmoteManager.getAllNames());
|
||||||
}
|
}
|
||||||
StringUtil.copyPartialMatches(args[1], completions, finalCompletitons);
|
StringUtil.copyPartialMatches(args[1], completions, finalCompletions);
|
||||||
}
|
}
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
String subcommand = args[0].toLowerCase();
|
String subcommand = args[0].toLowerCase();
|
||||||
@@ -88,13 +102,20 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
case "dye" -> {
|
case "dye" -> {
|
||||||
completions.add("#FFFFFF");
|
completions.add("#FFFFFF");
|
||||||
}
|
}
|
||||||
case "menu", "apply", "unapply" -> {
|
case "menu", "wardrobe", "apply", "unapply", "playemote" -> {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
completions.add(player.getName());
|
completions.add(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "setwardrobesetting" -> {
|
||||||
|
completions.add("npclocation");
|
||||||
|
completions.add("viewerlocation");
|
||||||
|
completions.add("leavelocation");
|
||||||
|
completions.add("permission");
|
||||||
|
completions.add("distance");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
StringUtil.copyPartialMatches(args[2], completions, finalCompletitons);
|
StringUtil.copyPartialMatches(args[2], completions, finalCompletions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 4) {
|
if (args.length == 4) {
|
||||||
@@ -104,14 +125,15 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
completions.add("#FFFFFF");
|
completions.add("#FFFFFF");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringUtil.copyPartialMatches(args[3], completions, finalCompletitons);
|
StringUtil.copyPartialMatches(args[3], completions, finalCompletions);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(finalCompletitons);
|
Collections.sort(finalCompletions);
|
||||||
return finalCompletitons;
|
return finalCompletions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> applyCommandComplete(CosmeticUser user, String[] args) {
|
@NotNull
|
||||||
|
private static List<String> applyCommandComplete(CosmeticUser user, String @NotNull [] args) {
|
||||||
List<String> completitions = new ArrayList<>();
|
List<String> completitions = new ArrayList<>();
|
||||||
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
@@ -130,7 +152,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
return completitions;
|
return completitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasPermission(CommandSender sender, String permission) {
|
private boolean hasPermission(@NotNull CommandSender sender, String permission) {
|
||||||
if (sender.isOp()) return true;
|
if (sender.isOp()) return true;
|
||||||
if (sender.hasPermission(permission)) return true;
|
if (sender.hasPermission(permission)) return true;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package com.hibiscusmc.hmccosmetics.config;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
// General Settings
|
// General Settings
|
||||||
@@ -31,7 +34,23 @@ public class Settings {
|
|||||||
private static final String TICK_PERIOD_PATH = "tick-period";
|
private static final String TICK_PERIOD_PATH = "tick-period";
|
||||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
||||||
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||||
|
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
||||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
||||||
|
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||||
|
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||||
|
private static final String HOOK_RELOAD_CHANGE_PATH = "reload-on-change";
|
||||||
|
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
||||||
|
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||||
|
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||||
|
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||||
|
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
||||||
|
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
||||||
|
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH = "chest-add-enchantments";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_BOOTS_PATH = "boots-add-enchantments";
|
||||||
|
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
|
||||||
|
|
||||||
private static String defaultMenu;
|
private static String defaultMenu;
|
||||||
private static String dyeMenuName;
|
private static String dyeMenuName;
|
||||||
@@ -46,6 +65,18 @@ public class Settings {
|
|||||||
private static boolean debugMode;
|
private static boolean debugMode;
|
||||||
private static boolean unapplyOnDeath;
|
private static boolean unapplyOnDeath;
|
||||||
private static boolean forcePermissionJoin;
|
private static boolean forcePermissionJoin;
|
||||||
|
private static boolean forceShowOnJoin;
|
||||||
|
private static boolean itemsAdderChangeReload;
|
||||||
|
private static boolean worldGuardMoveCheck;
|
||||||
|
private static boolean cosmeticEmoteBlockCheck;
|
||||||
|
private static boolean addHelmetEnchants;
|
||||||
|
private static boolean addChestplateEnchants;
|
||||||
|
private static boolean addLeggingEnchants;
|
||||||
|
private static boolean addBootsEnchants;
|
||||||
|
private static boolean emoteAirCheck;
|
||||||
|
private static boolean emoteDamageLeave;
|
||||||
|
private static boolean emoteInvincible;
|
||||||
|
private static boolean destroyLooseCosmetics;
|
||||||
private static int lookDownPitch;
|
private static int lookDownPitch;
|
||||||
private static int viewDistance;
|
private static int viewDistance;
|
||||||
private static int tickPeriod;
|
private static int tickPeriod;
|
||||||
@@ -76,7 +107,17 @@ public class Settings {
|
|||||||
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
|
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
|
||||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||||
|
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
||||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||||
|
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||||
|
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
||||||
|
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
||||||
|
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||||
|
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||||
|
addHelmetEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_HELMET_PATH).getBoolean(false);
|
||||||
|
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
|
||||||
|
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
|
||||||
|
addBootsEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_BOOTS_PATH).getBoolean(false);
|
||||||
|
|
||||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||||
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
||||||
@@ -91,6 +132,18 @@ public class Settings {
|
|||||||
dyeMenuName = dyeMenuSettings.node(DYE_MENU_NAME).getString("Dye Menu");
|
dyeMenuName = dyeMenuSettings.node(DYE_MENU_NAME).getString("Dye Menu");
|
||||||
dyeMenuInputSlot = dyeMenuSettings.node(DYE_MENU_INPUT_SLOT).getInt(19);
|
dyeMenuInputSlot = dyeMenuSettings.node(DYE_MENU_INPUT_SLOT).getInt(19);
|
||||||
dyeMenuOutputSlot = dyeMenuSettings.node(DYE_MENU_OUTPUT_SLOT).getInt(25);
|
dyeMenuOutputSlot = dyeMenuSettings.node(DYE_MENU_OUTPUT_SLOT).getInt(25);
|
||||||
|
|
||||||
|
ConfigurationNode hookSettings = source.node(HOOK_SETTING_PATH);
|
||||||
|
ConfigurationNode itemsAdderSettings = hookSettings.node(HOOK_ITEMADDER_PATH);
|
||||||
|
itemsAdderChangeReload = itemsAdderSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(false);
|
||||||
|
|
||||||
|
ConfigurationNode worldGuardSettings = hookSettings.node(HOOK_WORLDGUARD_PATH);
|
||||||
|
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH).getBoolean(true);
|
||||||
|
// I messed up in release 2.2.6 and forgot to change player_move_check to player-move-check.
|
||||||
|
if (!worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH_LEGACY).virtual()) {
|
||||||
|
MessagesUtil.sendDebugMessages("There is a deprecated way of using WG hook setting. Change player_move_check to player-move-check in your configuration to prevent issues in the future. ", Level.WARNING);
|
||||||
|
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH_LEGACY).getBoolean(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vector loadVector(final ConfigurationNode config) {
|
private static Vector loadVector(final ConfigurationNode config) {
|
||||||
@@ -190,6 +243,9 @@ public class Settings {
|
|||||||
public static boolean isDebugEnabled() {
|
public static boolean isDebugEnabled() {
|
||||||
return debugMode;
|
return debugMode;
|
||||||
}
|
}
|
||||||
|
public static boolean getItemsAdderReloadChange() {
|
||||||
|
return itemsAdderChangeReload;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getTickPeriod() {
|
public static int getTickPeriod() {
|
||||||
return tickPeriod;
|
return tickPeriod;
|
||||||
@@ -201,6 +257,10 @@ public class Settings {
|
|||||||
return forcePermissionJoin;
|
return forcePermissionJoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isForceShowOnJoin() {
|
||||||
|
return forceShowOnJoin;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean getDebugMode() {
|
public static boolean getDebugMode() {
|
||||||
return debugMode;
|
return debugMode;
|
||||||
}
|
}
|
||||||
@@ -208,6 +268,51 @@ public class Settings {
|
|||||||
public static double getEmoteDistance() {
|
public static double getEmoteDistance() {
|
||||||
return emoteDistance;
|
return emoteDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getCosmeticEmoteBlockCheck() {
|
||||||
|
return cosmeticEmoteBlockCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getEmoteAirCheck() {
|
||||||
|
return emoteAirCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEmoteDamageLeave() {
|
||||||
|
return emoteDamageLeave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEmoteInvincible() {
|
||||||
|
return emoteInvincible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWorldGuardMoveCheckEnabled() {
|
||||||
|
return worldGuardMoveCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDestroyLooseCosmetics() {
|
||||||
|
return destroyLooseCosmetics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
|
||||||
|
switch (slot) {
|
||||||
|
case HEAD -> {
|
||||||
|
return addHelmetEnchants;
|
||||||
|
}
|
||||||
|
case CHEST -> {
|
||||||
|
return addChestplateEnchants;
|
||||||
|
}
|
||||||
|
case LEGS -> {
|
||||||
|
return addLeggingEnchants;
|
||||||
|
}
|
||||||
|
case FEET -> {
|
||||||
|
return addBootsEnchants;
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setDebugMode(boolean newSetting) {
|
public static void setDebugMode(boolean newSetting) {
|
||||||
debugMode = newSetting;
|
debugMode = newSetting;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class Wardrobe {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private int distance = WardrobeSettings.getDefaultDistance();
|
||||||
|
private String permission;
|
||||||
|
private WardrobeLocation location;
|
||||||
|
|
||||||
|
public Wardrobe(String id, WardrobeLocation location, @Nullable String permission, int distance) {
|
||||||
|
this.id = id;
|
||||||
|
this.location = location;
|
||||||
|
if (permission != null) this.permission = permission;
|
||||||
|
if (distance != -1) this.distance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WardrobeLocation getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistance(int distance) {
|
||||||
|
this.distance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermission(String permission) {
|
||||||
|
this.permission = permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission() {
|
||||||
|
return permission != null;
|
||||||
|
}
|
||||||
|
public int getDistance() {
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPermission() {
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(WardrobeLocation location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canEnter(CosmeticUser user) {
|
||||||
|
Location wardrobeLocation = location.getNpcLocation();
|
||||||
|
Location location = user.getEntity().getLocation();
|
||||||
|
if (wardrobeLocation == null) return false;
|
||||||
|
if (distance == -1) return true;
|
||||||
|
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||||
|
return wardrobeLocation.distanceSquared(location) <= distance * distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class WardrobeLocation {
|
||||||
|
|
||||||
|
private Location npcLocation;
|
||||||
|
private Location viewerLocation;
|
||||||
|
private Location leaveLocation;
|
||||||
|
|
||||||
|
public WardrobeLocation(Location npcLocation, Location viewerLocation, Location leaveLocation) {
|
||||||
|
this.npcLocation = npcLocation;
|
||||||
|
this.viewerLocation = viewerLocation;
|
||||||
|
this.leaveLocation = leaveLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getNpcLocation() {
|
||||||
|
return npcLocation.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getViewerLocation() {
|
||||||
|
return viewerLocation.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLeaveLocation() {
|
||||||
|
return leaveLocation.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasAllLocations() {
|
||||||
|
if (npcLocation == null || viewerLocation == null || leaveLocation == null) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNPCLocation(Location wardrobeLocation) {
|
||||||
|
this.npcLocation = wardrobeLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setViewerLocation(Location viewerLocation) {
|
||||||
|
this.viewerLocation = viewerLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeaveLocation(Location leaveLocation) {
|
||||||
|
this.leaveLocation = leaveLocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,14 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class WardrobeSettings {
|
public class WardrobeSettings {
|
||||||
|
|
||||||
@@ -24,11 +29,22 @@ public class WardrobeSettings {
|
|||||||
private static final String APPLY_COSMETICS_ON_CLOSE = "apply-cosmetics-on-close";
|
private static final String APPLY_COSMETICS_ON_CLOSE = "apply-cosmetics-on-close";
|
||||||
private static final String OPEN_SOUND = "open-sound";
|
private static final String OPEN_SOUND = "open-sound";
|
||||||
private static final String CLOSE_SOUND = "close-sound";
|
private static final String CLOSE_SOUND = "close-sound";
|
||||||
private static final String STATIC_LOCATION_PATH = "wardrobe-location";
|
private static final String NPC_LOCATION_PATH = "npc-location";
|
||||||
private static final String VIEWER_LOCATION_PATH = "viewer-location";
|
private static final String VIEWER_LOCATION_PATH = "viewer-location";
|
||||||
private static final String LEAVE_LOCATION_PATH = "leave-location";
|
private static final String LEAVE_LOCATION_PATH = "leave-location";
|
||||||
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
||||||
|
private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics";
|
||||||
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
||||||
|
|
||||||
|
private static final String WARDROBE_MENU_OPTIONS = "menu-options";
|
||||||
|
private static final String WARDROBE_ENTER_OPEN_MENU_PATH = "enter-open-menu";
|
||||||
|
|
||||||
|
private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
|
||||||
|
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
|
||||||
|
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
|
||||||
|
private static final String WARDROBES_PATH = "wardrobes";
|
||||||
|
private static final String PERMISSION_PATH = "permission";
|
||||||
|
private static final String DISTANCE_PATH = "distance";
|
||||||
private static final String BOSSBAR_PATH = "bossbar";
|
private static final String BOSSBAR_PATH = "bossbar";
|
||||||
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
||||||
private static final String BOSSBAR_TEXT_PATH = "text";
|
private static final String BOSSBAR_TEXT_PATH = "text";
|
||||||
@@ -54,12 +70,14 @@ public class WardrobeSettings {
|
|||||||
private static int despawnDelay;
|
private static int despawnDelay;
|
||||||
private static float bossbarProgress;
|
private static float bossbarProgress;
|
||||||
private static boolean applyCosmeticsOnClose;
|
private static boolean applyCosmeticsOnClose;
|
||||||
|
private static boolean tryCosmeticsInWardrobe;
|
||||||
private static boolean equipPumpkin;
|
private static boolean equipPumpkin;
|
||||||
private static boolean returnLastLocation;
|
private static boolean returnLastLocation;
|
||||||
private static boolean enabledBossbar;
|
private static boolean enabledBossbar;
|
||||||
private static Location wardrobeLocation;
|
private static boolean enterOpenMenu;
|
||||||
private static Location viewerLocation;
|
private static boolean forceExitGamemode;
|
||||||
private static Location leaveLocation;
|
private static GameMode exitGamemode;
|
||||||
|
private static HashMap<String, Wardrobe> wardrobes;
|
||||||
private static String bossbarMessage;
|
private static String bossbarMessage;
|
||||||
private static BossBar.Overlay bossbarOverlay;
|
private static BossBar.Overlay bossbarOverlay;
|
||||||
private static BossBar.Color bossbarColor;
|
private static BossBar.Color bossbarColor;
|
||||||
@@ -84,6 +102,14 @@ public class WardrobeSettings {
|
|||||||
applyCosmeticsOnClose = source.node(APPLY_COSMETICS_ON_CLOSE).getBoolean();
|
applyCosmeticsOnClose = source.node(APPLY_COSMETICS_ON_CLOSE).getBoolean();
|
||||||
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
||||||
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
||||||
|
tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false);
|
||||||
|
|
||||||
|
ConfigurationNode menuOptionsNode = source.node(WARDROBE_MENU_OPTIONS);
|
||||||
|
enterOpenMenu = menuOptionsNode.node(WARDROBE_ENTER_OPEN_MENU_PATH).getBoolean(false);
|
||||||
|
|
||||||
|
ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
|
||||||
|
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
|
||||||
|
exitGamemode = GameMode.valueOf(gamemodeNode.node(EXIT_GAMEMODE_PATH).getString("SURVIVAL"));
|
||||||
|
|
||||||
ConfigurationNode bossBarNode = source.node(BOSSBAR_PATH);
|
ConfigurationNode bossBarNode = source.node(BOSSBAR_PATH);
|
||||||
enabledBossbar = bossBarNode.node(BOSSBAR_ENABLE_PATH).getBoolean(false);
|
enabledBossbar = bossBarNode.node(BOSSBAR_ENABLE_PATH).getBoolean(false);
|
||||||
@@ -109,15 +135,35 @@ public class WardrobeSettings {
|
|||||||
transitionStay = transitionNode.node(TRANSITION_STAY_PATH).getInt(2000);
|
transitionStay = transitionNode.node(TRANSITION_STAY_PATH).getInt(2000);
|
||||||
transitionFadeOut = transitionNode.node(TRANSITION_FADE_OUT_PATH).getInt(2000);
|
transitionFadeOut = transitionNode.node(TRANSITION_FADE_OUT_PATH).getInt(2000);
|
||||||
|
|
||||||
try {
|
wardrobes = new HashMap<>();
|
||||||
wardrobeLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(STATIC_LOCATION_PATH));
|
for (ConfigurationNode wardrobesNode : source.node(WARDROBES_PATH).childrenMap().values()) {
|
||||||
MessagesUtil.sendDebugMessages("Wardrobe Location: " + wardrobeLocation);
|
String id = wardrobesNode.key().toString();
|
||||||
viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(VIEWER_LOCATION_PATH));
|
try {
|
||||||
MessagesUtil.sendDebugMessages("Viewer Location: " + viewerLocation);
|
Location npcLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(NPC_LOCATION_PATH));
|
||||||
leaveLocation = Utils.replaceIfNull(LocationSerializer.INSTANCE.deserialize(Location.class, source.node(LEAVE_LOCATION_PATH)), viewerLocation);
|
MessagesUtil.sendDebugMessages("Wardrobe Location: " + npcLocation);
|
||||||
} catch (SerializationException e) {
|
Location viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(VIEWER_LOCATION_PATH));
|
||||||
throw new RuntimeException(e);
|
MessagesUtil.sendDebugMessages("Viewer Location: " + viewerLocation);
|
||||||
|
Location leaveLocation = Utils.replaceIfNull(LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(LEAVE_LOCATION_PATH)), viewerLocation);
|
||||||
|
MessagesUtil.sendDebugMessages("Leave Location: " + leaveLocation);
|
||||||
|
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
||||||
|
|
||||||
|
String permission = null;
|
||||||
|
int distance = -1;
|
||||||
|
if (!wardrobesNode.node(PERMISSION_PATH).virtual()) permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
||||||
|
if (!wardrobesNode.node(DISTANCE_PATH).virtual()) distance = wardrobesNode.node(DISTANCE_PATH).getInt();
|
||||||
|
|
||||||
|
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance);
|
||||||
|
addWardrobe(wardrobe);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDefaultDistance() {
|
||||||
|
return staticRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getDisableOnDamage() {
|
public static boolean getDisableOnDamage() {
|
||||||
@@ -162,27 +208,38 @@ public class WardrobeSettings {
|
|||||||
return returnLastLocation;
|
return returnLastLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getWardrobeLocation() {
|
public static Wardrobe getWardrobe(String key) {
|
||||||
return wardrobeLocation.clone();
|
return wardrobes.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getViewerLocation() {
|
public static Set<String> getWardrobeNames() {
|
||||||
return viewerLocation;
|
return wardrobes.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getLeaveLocation() {
|
public static Collection<Wardrobe> getWardrobes() {
|
||||||
return leaveLocation;
|
return wardrobes.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addWardrobe(Wardrobe wardrobe) {
|
||||||
|
wardrobes.put(wardrobe.getId(), wardrobe);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeWardrobe(String id) {
|
||||||
|
wardrobes.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static boolean inDistanceOfWardrobe(final Location wardrobeLocation, final Location playerLocation) {
|
public static boolean inDistanceOfWardrobe(final Location wardrobeLocation, final Location playerLocation) {
|
||||||
if (displayRadius == -1) return true;
|
if (displayRadius == -1) return true;
|
||||||
if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false;
|
if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false;
|
||||||
return playerLocation.distanceSquared(wardrobeLocation) <= displayRadius * displayRadius;
|
return playerLocation.distanceSquared(wardrobeLocation) <= displayRadius * displayRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean inDistanceOfStatic(final Location location) {
|
@Deprecated
|
||||||
|
public static boolean inDistanceOfStatic(Wardrobe wardrobe, final Location location) {
|
||||||
|
Location wardrobeLocation = wardrobe.getLocation().getNpcLocation();
|
||||||
if (wardrobeLocation == null) return false;
|
if (wardrobeLocation == null) return false;
|
||||||
if (staticRadius == -1) return false;
|
if (staticRadius == -1) return true;
|
||||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||||
return wardrobeLocation.distanceSquared(location) <= staticRadius * staticRadius;
|
return wardrobeLocation.distanceSquared(location) <= staticRadius * staticRadius;
|
||||||
}
|
}
|
||||||
@@ -227,57 +284,96 @@ public class WardrobeSettings {
|
|||||||
return transitionFadeOut;
|
return transitionFadeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setWardrobeLocation(Location newLocation) {
|
public static boolean isEnterOpenMenu() {
|
||||||
wardrobeLocation = newLocation;
|
return enterOpenMenu;
|
||||||
|
|
||||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
|
||||||
|
|
||||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "world", newLocation.getWorld().getName());
|
|
||||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "x", newLocation.getX());
|
|
||||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "y", newLocation.getY());
|
|
||||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "z", newLocation.getZ());
|
|
||||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "yaw", newLocation.getYaw());
|
|
||||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "pitch", newLocation.getPitch());
|
|
||||||
|
|
||||||
/* Configuration sets suck
|
|
||||||
source.node(WORLD).set(loc.getWorld().getName());
|
|
||||||
source.node(X).set(loc.getX());
|
|
||||||
source.node(Y).set(loc.getY());
|
|
||||||
source.node(Z).set(loc.getZ());
|
|
||||||
source.node(YAW).set(loc.getYaw());
|
|
||||||
source.node(PITCH).set(loc.getPitch());
|
|
||||||
*/
|
|
||||||
|
|
||||||
HMCCosmeticsPlugin.getInstance().saveConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setViewerLocation(Location newLocation) {
|
public static boolean isForceExitGamemode() {
|
||||||
viewerLocation = newLocation;
|
return forceExitGamemode;
|
||||||
|
|
||||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
|
||||||
|
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "world", newLocation.getWorld().getName());
|
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "x", newLocation.getX());
|
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "y", newLocation.getY());
|
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "z", newLocation.getZ());
|
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "yaw", newLocation.getYaw());
|
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "pitch", newLocation.getPitch());
|
|
||||||
|
|
||||||
HMCCosmeticsPlugin.getInstance().saveConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLeaveLocation(Location newLocation) {
|
public static GameMode getExitGamemode() {
|
||||||
leaveLocation = newLocation;
|
return exitGamemode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isTryCosmeticsInWardrobe() {
|
||||||
|
return tryCosmeticsInWardrobe;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets where the NPC/Mannequin will spawn in the wardrobe
|
||||||
|
* @param newLocation
|
||||||
|
*/
|
||||||
|
public static void setNPCLocation(Wardrobe wardrobe, Location newLocation) {
|
||||||
|
wardrobe.getLocation().setNPCLocation(newLocation);
|
||||||
|
|
||||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
|
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "world", newLocation.getWorld().getName());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "world", newLocation.getWorld().getName());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "x", newLocation.getX());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "x", newLocation.getX());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "y", newLocation.getY());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "y", newLocation.getY());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "z", newLocation.getZ());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "z", newLocation.getZ());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "yaw", newLocation.getYaw());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "yaw", newLocation.getYaw());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "pitch", newLocation.getPitch());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "pitch", newLocation.getPitch());
|
||||||
|
|
||||||
HMCCosmeticsPlugin.getInstance().saveConfig();
|
plugin.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets where the player will view the wardrobe
|
||||||
|
* @param newLocation
|
||||||
|
*/
|
||||||
|
public static void setViewerLocation(Wardrobe wardrobe, Location newLocation) {
|
||||||
|
wardrobe.getLocation().setViewerLocation(newLocation);
|
||||||
|
|
||||||
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
|
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.world", newLocation.getWorld().getName());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.x", newLocation.getX());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.y", newLocation.getY());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.z", newLocation.getZ());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.yaw", newLocation.getYaw());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.pitch", newLocation.getPitch());
|
||||||
|
|
||||||
|
plugin.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets where a player will leave the wardrobe from
|
||||||
|
* @param newLocation
|
||||||
|
*/
|
||||||
|
public static void setLeaveLocation(Wardrobe wardrobe, Location newLocation) {
|
||||||
|
wardrobe.getLocation().setLeaveLocation(newLocation);
|
||||||
|
|
||||||
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
|
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.world", newLocation.getWorld().getName());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.x", newLocation.getX());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.y", newLocation.getY());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.z", newLocation.getZ());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.yaw", newLocation.getYaw());
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.pitch", newLocation.getPitch());
|
||||||
|
|
||||||
|
plugin.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWardrobePermission(Wardrobe wardrobe, String permission) {
|
||||||
|
wardrobe.setPermission(permission);
|
||||||
|
|
||||||
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
|
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".permission", permission);
|
||||||
|
|
||||||
|
plugin.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWardrobeDistance(Wardrobe wardrobe, int distance) {
|
||||||
|
wardrobe.setDistance(distance);
|
||||||
|
|
||||||
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
|
|
||||||
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".distance", distance);
|
||||||
|
|
||||||
|
plugin.saveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,14 @@ package com.hibiscusmc.hmccosmetics.config.serializer;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder;
|
import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -123,12 +121,25 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
|
|||||||
if (item.getType() == Material.PLAYER_HEAD) {
|
if (item.getType() == Material.PLAYER_HEAD) {
|
||||||
SkullMeta skullMeta = (SkullMeta) itemMeta;
|
SkullMeta skullMeta = (SkullMeta) itemMeta;
|
||||||
if (!ownerNode.virtual()) {
|
if (!ownerNode.virtual()) {
|
||||||
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(ownerNode.getString()));
|
String ownerString = ownerNode.getString();
|
||||||
|
if (ownerString.contains("%")) {
|
||||||
|
// This means it has PAPI placeholders in it
|
||||||
|
skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullOwner(), PersistentDataType.STRING, ownerString);
|
||||||
|
}
|
||||||
|
OfflinePlayer player = Bukkit.getOfflinePlayer(ownerString);
|
||||||
|
skullMeta.setOwningPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!textureNode.virtual()) {
|
if (!textureNode.virtual()) {
|
||||||
|
String textureString = textureNode.getString();
|
||||||
|
if (textureString.contains("%")) {
|
||||||
|
// This means it has PAPI placeholders in it
|
||||||
|
skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullTexture(), PersistentDataType.STRING, textureString);
|
||||||
|
}
|
||||||
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
|
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
|
||||||
+ textureNode.getString() + "\"}]}}}");
|
+ textureString + "\"}]}}}");
|
||||||
|
|
||||||
|
|
||||||
itemMeta = skullMeta;
|
itemMeta = skullMeta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,9 +154,6 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NamespacedKey key = new NamespacedKey(HMCCosmeticsPlugin.getInstance(), source.key().toString());
|
|
||||||
itemMeta.getPersistentDataContainer().set(key, PersistentDataType.STRING, source.key().toString());
|
|
||||||
|
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,45 +5,51 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Cosmetic {
|
public abstract class Cosmetic {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String permission;
|
private String permission;
|
||||||
private ItemStack item;
|
private ItemStack item;
|
||||||
|
private String material;
|
||||||
private CosmeticSlot slot;
|
private CosmeticSlot slot;
|
||||||
private boolean dyable;
|
private boolean dyable;
|
||||||
|
|
||||||
protected Cosmetic(String id, ConfigurationNode config) {
|
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
if (!config.node("permission").virtual()) {
|
if (!config.node("permission").virtual()) {
|
||||||
this.permission = config.node("permission").getString();
|
this.permission = config.node("permission").getString();
|
||||||
} else {
|
} else {
|
||||||
this.permission = null;
|
this.permission = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.node("item").virtual()) this.item = generateItemStack(config.node("item"));
|
if (!config.node("item").virtual()) {
|
||||||
|
this.material = config.node("item", "material").getString();
|
||||||
|
this.item = generateItemStack(config.node("item"));
|
||||||
|
}
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
|
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
|
||||||
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
|
|
||||||
|
|
||||||
|
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
|
||||||
setDyable(config.node("dyeable").getBoolean(false));
|
setDyable(config.node("dyeable").getBoolean(false));
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
|
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
|
||||||
|
|
||||||
Cosmetics.addCosmetic(this);
|
Cosmetics.addCosmetic(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
public String getPermission() {
|
|
||||||
return this.permission;
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticSlot getSlot() {
|
public CosmeticSlot getSlot() {
|
||||||
@@ -53,17 +59,17 @@ public class Cosmetic {
|
|||||||
public void setSlot(CosmeticSlot slot) {
|
public void setSlot(CosmeticSlot slot) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPermission() {
|
||||||
|
return this.permission;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPermission(String permission) {
|
public void setPermission(String permission) {
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean requiresPermission() {
|
public boolean requiresPermission() {
|
||||||
if (permission == null) return false;
|
return permission != null;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDyable(boolean dyable) {
|
public void setDyable(boolean dyable) {
|
||||||
@@ -74,11 +80,12 @@ public class Cosmetic {
|
|||||||
return this.dyable;
|
return this.dyable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMaterial() {
|
||||||
public void update(CosmeticUser user) {
|
return material;
|
||||||
// Override
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void update(CosmeticUser user);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
|
|||||||
@@ -6,18 +6,24 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
import org.spongepowered.configurate.ConfigurateException;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class Cosmetics {
|
public class Cosmetics {
|
||||||
|
|
||||||
private static HashBiMap<String, Cosmetic> COSMETICS = HashBiMap.create();
|
private static final HashBiMap<String, Cosmetic> COSMETICS = HashBiMap.create();
|
||||||
|
|
||||||
public static void addCosmetic(Cosmetic cosmetic) {
|
public static void addCosmetic(Cosmetic cosmetic) {
|
||||||
COSMETICS.put(cosmetic.getId(), cosmetic);
|
COSMETICS.put(cosmetic.getId(), cosmetic);
|
||||||
@@ -31,14 +37,19 @@ public class Cosmetics {
|
|||||||
COSMETICS.remove(cosmetic);
|
COSMETICS.remove(cosmetic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static Cosmetic getCosmetic(String id) {
|
public static Cosmetic getCosmetic(String id) {
|
||||||
return COSMETICS.get(id);
|
return COSMETICS.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
@NotNull
|
||||||
public static Set<Cosmetic> values() {
|
public static Set<Cosmetic> values() {
|
||||||
return COSMETICS.values();
|
return COSMETICS.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
@NotNull
|
||||||
public static Set<String> keys() {
|
public static Set<String> keys() {
|
||||||
return COSMETICS.keySet();
|
return COSMETICS.keySet();
|
||||||
}
|
}
|
||||||
@@ -60,23 +71,27 @@ public class Cosmetics {
|
|||||||
File[] directoryListing = cosmeticFolder.listFiles();
|
File[] directoryListing = cosmeticFolder.listFiles();
|
||||||
if (directoryListing == null) return;
|
if (directoryListing == null) return;
|
||||||
|
|
||||||
for (File child : directoryListing) {
|
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
|
||||||
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
|
||||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
||||||
// Loads file
|
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
|
// Loads file
|
||||||
CommentedConfigurationNode root;
|
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
|
||||||
try {
|
CommentedConfigurationNode root;
|
||||||
root = loader.load();
|
try {
|
||||||
} catch (ConfigurateException e) {
|
root = loader.load();
|
||||||
throw new RuntimeException(e);
|
} catch (ConfigurateException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
setupCosmetics(root);
|
||||||
}
|
}
|
||||||
setupCosmetics(root);
|
});
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setupCosmetics(CommentedConfigurationNode config) {
|
private static void setupCosmetics(@NotNull CommentedConfigurationNode config) {
|
||||||
for (ConfigurationNode cosmeticConfig : config.childrenMap().values()) {
|
for (ConfigurationNode cosmeticConfig : config.childrenMap().values()) {
|
||||||
try {
|
try {
|
||||||
String id = cosmeticConfig.key().toString();
|
String id = cosmeticConfig.key().toString();
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
public class CosmeticArmorType extends Cosmetic {
|
public class CosmeticArmorType extends Cosmetic {
|
||||||
|
|
||||||
private EquipmentSlot equipSlot;
|
private final EquipmentSlot equipSlot;
|
||||||
|
|
||||||
public CosmeticArmorType(String id, ConfigurationNode config) {
|
public CosmeticArmorType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
@@ -20,18 +25,25 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
if (player == null) return;
|
if (entity == null) return;
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
|
||||||
|
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
||||||
|
if (!(entity instanceof HumanEntity humanEntity)) return;
|
||||||
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
||||||
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
|
if (!humanEntity.getInventory().getItemInOffHand().getType().isAir()) return;
|
||||||
}
|
}
|
||||||
PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation()));
|
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
|
||||||
|
if (Settings.getShouldAddEnchants(equipSlot)) {
|
||||||
|
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||||
|
}
|
||||||
|
|
||||||
|
NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
|
||||||
|
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
|
||||||
}
|
}
|
||||||
|
|
||||||
public EquipmentSlot getEquipSlot() {
|
public EquipmentSlot getEquipSlot() {
|
||||||
return this.equipSlot;
|
return this.equipSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,87 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.AreaEffectCloud;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CosmeticBackpackType extends Cosmetic {
|
public class CosmeticBackpackType extends Cosmetic {
|
||||||
|
|
||||||
ConfigurationNode config;
|
private final String modelName;
|
||||||
|
private ItemStack firstPersonBackpack;
|
||||||
|
|
||||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
this.config = config;
|
modelName = config.node("model").getString();
|
||||||
|
|
||||||
|
if (!config.node("firstperson-item").virtual()) {
|
||||||
|
this.firstPersonBackpack = generateItemStack(config.node("firstperson-item"));
|
||||||
|
}
|
||||||
|
//backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
Location loc = player.getLocation().clone();
|
if (entity == null) return;
|
||||||
|
|
||||||
if (user.isInWardrobe()) return;
|
Location loc = entity.getLocation().clone().add(0, 2, 0);
|
||||||
|
|
||||||
if (loc.getWorld() != user.getUserBackpackManager().getArmorstand().getWorld()) {
|
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||||
user.getUserBackpackManager().getArmorstand().teleport(loc);
|
if (!user.getUserBackpackManager().IsValidBackpackEntity()) {
|
||||||
|
MessagesUtil.sendDebugMessages("Invalid Backpack Entity[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.WARNING);
|
||||||
|
user.respawnBackpack();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
|
||||||
|
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorstand().teleport(loc);
|
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
||||||
|
user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());
|
||||||
|
|
||||||
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getFirstArmorstandId(), loc);
|
List<Player> outsideViewers = user.getUserBackpackManager().getCloudManager().refreshViewers(loc);
|
||||||
|
if (!user.isInWardrobe() && isFirstPersonCompadible()) {
|
||||||
|
List<Player> owner = List.of(user.getPlayer());
|
||||||
|
|
||||||
|
ArrayList<Integer> particleCloud = user.getUserBackpackManager().getAreaEffectEntityId();
|
||||||
|
for (int i = 0; i < particleCloud.size(); i++) {
|
||||||
|
if (i == 0) {
|
||||||
|
PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||||
|
} else {
|
||||||
|
PacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||||
|
if (!user.getHidden()) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
||||||
|
MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
|
||||||
|
}
|
||||||
|
PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorstand().setRotation(loc.getYaw(), loc.getPitch());
|
|
||||||
user.getUserBackpackManager().showBackpack();
|
user.getUserBackpackManager().showBackpack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getModelName() {
|
||||||
|
return modelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFirstPersonCompadible() {
|
||||||
|
return firstPersonBackpack != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,16 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
|
|
||||||
@@ -16,27 +19,21 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CosmeticBalloonType extends Cosmetic {
|
public class CosmeticBalloonType extends Cosmetic {
|
||||||
|
|
||||||
private String modelName;
|
private final String modelName;
|
||||||
private List<String> dyableParts;
|
private List<String> dyableParts;
|
||||||
//private HashMap<Animations, String> animationBalloons;
|
private boolean showLead;
|
||||||
|
|
||||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
String modelId = config.node("model").getString();
|
String modelId = config.node("model").getString();
|
||||||
|
|
||||||
|
showLead = config.node("show-lead").getBoolean(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!config.node("dyable-parts").virtual()) dyableParts = config.node("dyable-parts").getList(String.class);
|
if (!config.node("dyable-parts").virtual()) {
|
||||||
|
dyableParts = config.node("dyable-parts").getList(String.class);
|
||||||
/*
|
|
||||||
if (!config.node("animations").virtual()) {
|
|
||||||
for (ConfigurationNode animationNode : config.node("animations").childrenMap().values()) {
|
|
||||||
if (EnumUtils.isValidEnum(Animations.class, animationNode.key().toString().toUpperCase())) continue;
|
|
||||||
animationBalloons.put(Animations.valueOf(animationNode.key().toString().toUpperCase()), animationNode.getString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
// Seriously?
|
// Seriously?
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -46,19 +43,25 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
UserBalloonManager userBalloonManager = user.getBalloonManager();
|
UserBalloonManager userBalloonManager = user.getBalloonManager();
|
||||||
Location newLocation = player.getLocation();
|
|
||||||
if (player == null || userBalloonManager == null || newLocation == null) return;
|
if (entity == null || userBalloonManager == null) return;
|
||||||
if (user.isInWardrobe()) return;
|
if (user.isInWardrobe()) return;
|
||||||
|
|
||||||
|
if (!userBalloonManager.getModelEntity().isValid()) {
|
||||||
|
user.respawnBalloon();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location newLocation = entity.getLocation();
|
||||||
Location currentLocation = user.getBalloonManager().getLocation();
|
Location currentLocation = user.getBalloonManager().getLocation();
|
||||||
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
||||||
|
|
||||||
List<Player> viewer = PacketManager.getViewers(player.getLocation());
|
List<Player> viewer = PacketManager.getViewers(entity.getLocation());
|
||||||
viewer.add(player);
|
|
||||||
|
|
||||||
if (player.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
|
if (entity.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
|
||||||
userBalloonManager.getModelEntity().teleport(newLocation);
|
userBalloonManager.getModelEntity().teleport(newLocation);
|
||||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||||
return;
|
return;
|
||||||
@@ -69,7 +72,17 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
userBalloonManager.setLocation(newLocation);
|
userBalloonManager.setLocation(newLocation);
|
||||||
|
|
||||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||||
if (!user.getHidden()) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
|
PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
||||||
|
if (user.getHidden()) {
|
||||||
|
userBalloonManager.getPufferfish().hidePufferfish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!user.getHidden() && showLead) {
|
||||||
|
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
||||||
|
if (sendTo.isEmpty()) return;
|
||||||
|
PacketManager.sendEntitySpawnPacket(newLocation, userBalloonManager.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager.getPufferfishBalloonUniqueId(), sendTo);
|
||||||
|
PacketManager.sendInvisibilityPacket(userBalloonManager.getPufferfishBalloonId(), sendTo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModelName() {
|
public String getModelName() {
|
||||||
@@ -87,9 +100,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
return dyableParts.contains(name);
|
return dyableParts.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
public boolean isShowLead() {
|
||||||
public String getAnimation(Animations animation) {
|
return showLead;
|
||||||
return animationBalloons.get(animation);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,19 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
public class CosmeticEmoteType extends Cosmetic {
|
public class CosmeticEmoteType extends Cosmetic {
|
||||||
|
|
||||||
private String animationId;
|
private final String animationId;
|
||||||
|
private final String text;
|
||||||
|
|
||||||
public CosmeticEmoteType(String id, ConfigurationNode config) {
|
public CosmeticEmoteType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
animationId = config.node("animation").getString();
|
animationId = config.node("animation").getString();
|
||||||
|
text = config.node("text").getString();
|
||||||
MessagesUtil.sendDebugMessages("CosmeticEmoteType Animation id " + animationId);
|
MessagesUtil.sendDebugMessages("CosmeticEmoteType Animation id " + animationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,11 +24,15 @@ public class CosmeticEmoteType extends Cosmetic {
|
|||||||
// Nothing
|
// Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(CosmeticUser user) {
|
public void run(@NotNull CosmeticUser user) {
|
||||||
user.getUserEmoteManager().playEmote(this);
|
user.getUserEmoteManager().playEmote(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAnimationId() {
|
public String getAnimationId() {
|
||||||
return animationId;
|
return animationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
public class CosmeticMainhandType extends Cosmetic {
|
public class CosmeticMainhandType extends Cosmetic {
|
||||||
@@ -14,10 +15,9 @@ public class CosmeticMainhandType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
|
|
||||||
PacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), PlayerUtils.getNearbyPlayers(player));
|
PacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), PlayerUtils.getNearbyPlayers(player));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.hibiscusmc.hmccosmetics.database;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.Data;
|
import com.hibiscusmc.hmccosmetics.database.types.Data;
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.InternalData;
|
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.MySQLData;
|
import com.hibiscusmc.hmccosmetics.database.types.MySQLData;
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
|
import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
@@ -16,23 +15,20 @@ public class Database {
|
|||||||
|
|
||||||
private static Data data;
|
private static Data data;
|
||||||
|
|
||||||
private static InternalData INTERNAL_DATA = new InternalData();
|
private static final MySQLData MYSQL_DATA = new MySQLData();
|
||||||
private static MySQLData MYSQL_DATA = new MySQLData();
|
private static final SQLiteData SQLITE_DATA = new SQLiteData();
|
||||||
private static SQLiteData SQLITE_DATA = new SQLiteData();
|
|
||||||
|
|
||||||
public Database() {
|
public Database() {
|
||||||
String databaseType = DatabaseSettings.getDatabaseType();
|
String databaseType = DatabaseSettings.getDatabaseType();
|
||||||
data = INTERNAL_DATA; // default
|
data = SQLITE_DATA; // default
|
||||||
if (databaseType.equalsIgnoreCase("INTERNAL")) {
|
|
||||||
data = INTERNAL_DATA;
|
|
||||||
}
|
|
||||||
if (databaseType.equalsIgnoreCase("MySQL")) {
|
if (databaseType.equalsIgnoreCase("MySQL")) {
|
||||||
data = MYSQL_DATA;
|
data = MYSQL_DATA;
|
||||||
}
|
}
|
||||||
|
/* SQLite is the default database. Might change in the future, so keep code here in case.
|
||||||
if (databaseType.equalsIgnoreCase("sqlite")) {
|
if (databaseType.equalsIgnoreCase("sqlite")) {
|
||||||
data = SQLITE_DATA;
|
data = SQLITE_DATA;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
MessagesUtil.sendDebugMessages("Database is " + data);
|
MessagesUtil.sendDebugMessages("Database is " + data);
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|||||||
@@ -10,40 +10,34 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Data {
|
public abstract class Data {
|
||||||
|
|
||||||
public void setup() {
|
public abstract void setup();
|
||||||
// Override
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save(CosmeticUser user) {
|
public abstract void save(CosmeticUser user);
|
||||||
// Override
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
public abstract CosmeticUser get(UUID uniqueId);
|
||||||
// Override
|
|
||||||
return null;
|
public abstract void clear(UUID uniqueId);
|
||||||
}
|
|
||||||
|
|
||||||
public void clear(UUID uniqueId) {
|
|
||||||
// Override
|
|
||||||
}
|
|
||||||
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
|
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
|
||||||
public String steralizeData(CosmeticUser user) {
|
@NotNull
|
||||||
|
public final String serializeData(@NotNull CosmeticUser user) {
|
||||||
String data = "";
|
String data = "";
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
if (shouldHiddenSave(user.getHiddenReason())) {
|
if (shouldHiddenSave(user.getHiddenReason())) {
|
||||||
data = "HIDDEN=" + user.getHiddenReason();
|
data = "HIDDEN=" + user.getHiddenReason();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
||||||
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
||||||
if (color != null) input = input + "&" + color.asRGB();
|
if (color != null) input = input + "&" + color.asRGB();
|
||||||
@@ -56,9 +50,13 @@ public class Data {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<CosmeticSlot, Map<Cosmetic, Color>> desteralizedata(CosmeticUser user, String raw) {
|
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
|
||||||
|
return deserializeData(user, raw, Settings.getForcePermissionJoin());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw, boolean permissionCheck) {
|
||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||||
boolean checkPermission = Settings.getForcePermissionJoin();
|
|
||||||
|
|
||||||
String[] rawData = raw.split(",");
|
String[] rawData = raw.split(",");
|
||||||
for (String a : rawData) {
|
for (String a : rawData) {
|
||||||
@@ -69,6 +67,7 @@ public class Data {
|
|||||||
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
|
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
|
||||||
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
||||||
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
||||||
|
if (Settings.isForceShowOnJoin()) continue;
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
||||||
});
|
});
|
||||||
@@ -80,8 +79,8 @@ public class Data {
|
|||||||
String[] colorSplitData = splitData[1].split("&");
|
String[] colorSplitData = splitData[1].split("&");
|
||||||
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
||||||
if (slot == null || cosmetic == null) continue;
|
if (slot == null || cosmetic == null) continue;
|
||||||
if (cosmetic.requiresPermission() && checkPermission) {
|
if (permissionCheck && cosmetic.requiresPermission()) {
|
||||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,8 +88,8 @@ public class Data {
|
|||||||
} else {
|
} else {
|
||||||
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
||||||
if (slot == null || cosmetic == null) continue;
|
if (slot == null || cosmetic == null) continue;
|
||||||
if (cosmetic.requiresPermission() && checkPermission) {
|
if (permissionCheck && cosmetic.requiresPermission()) {
|
||||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +101,7 @@ public class Data {
|
|||||||
return cosmetics;
|
return cosmetics;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldHiddenSave(CosmeticUser.HiddenReason reason) {
|
private boolean shouldHiddenSave(CosmeticUser.@NotNull HiddenReason reason) {
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case EMOTE, NONE -> {
|
case EMOTE, NONE -> {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.database.types;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class InternalData extends Data {
|
|
||||||
|
|
||||||
NamespacedKey key = new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetics");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setup() {
|
|
||||||
// Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save(CosmeticUser user) {
|
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
|
||||||
|
|
||||||
player.getPersistentDataContainer().set(key, PersistentDataType.STRING, steralizeData(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
|
||||||
Player player = Bukkit.getPlayer(uniqueId);
|
|
||||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
|
||||||
|
|
||||||
if (!player.getPersistentDataContainer().has(key, PersistentDataType.STRING)) return user;
|
|
||||||
String rawData = player.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
|
||||||
|
|
||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> a = desteralizedata(user, rawData);
|
|
||||||
for (Map<Cosmetic, Color> cosmeticColors : a.values()) {
|
|
||||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
// This can not be async.
|
|
||||||
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(UUID uniqueId) {
|
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(uniqueId);
|
|
||||||
|
|
||||||
if (player.isOnline()) {
|
|
||||||
Player onlinePlayer = player.getPlayer();
|
|
||||||
if (onlinePlayer.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
|
|
||||||
onlinePlayer.getPersistentDataContainer().remove(key);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,18 +2,18 @@ package com.hibiscusmc.hmccosmetics.database.types;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
import java.util.Map;
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MySQLData extends Data {
|
public class MySQLData extends SQLData {
|
||||||
|
|
||||||
// Connection Information
|
// Connection Information
|
||||||
private String host;
|
private String host;
|
||||||
@@ -22,6 +22,7 @@ public class MySQLData extends Data {
|
|||||||
private String password;
|
private String password;
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -35,11 +36,12 @@ public class MySQLData extends Data {
|
|||||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
try {
|
try {
|
||||||
openConnection();
|
openConnection();
|
||||||
|
if (connection == null) throw new NullPointerException("Connection is null");
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
||||||
"(UUID varchar(36) PRIMARY KEY, " +
|
"(UUID varchar(36) PRIMARY KEY, " +
|
||||||
"COSMETICS MEDIUMTEXT " +
|
"COSMETICS MEDIUMTEXT " +
|
||||||
");").execute();
|
");").execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException | NullPointerException e) {
|
||||||
plugin.getLogger().severe("");
|
plugin.getLogger().severe("");
|
||||||
plugin.getLogger().severe("");
|
plugin.getLogger().severe("");
|
||||||
plugin.getLogger().severe("MySQL DATABASE CAN NOT BE REACHED.");
|
plugin.getLogger().severe("MySQL DATABASE CAN NOT BE REACHED.");
|
||||||
@@ -52,104 +54,58 @@ public class MySQLData extends Data {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void save(CosmeticUser user) {
|
|
||||||
Runnable run = () -> {
|
|
||||||
try {
|
|
||||||
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
|
||||||
preparedSt.setString(1, user.getUniqueId().toString());
|
|
||||||
preparedSt.setString(2, steralizeData(user));
|
|
||||||
preparedSt.executeUpdate();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (!HMCCosmeticsPlugin.isDisable()) {
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
|
||||||
} else {
|
|
||||||
run.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
public void clear(UUID uniqueId) {
|
||||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
try {
|
|
||||||
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
|
||||||
preparedStatement.setString(1, uniqueId.toString());
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
if (rs.next()) {
|
|
||||||
String rawData = rs.getString("COSMETICS");
|
|
||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = desteralizedata(user, rawData);
|
|
||||||
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
|
|
||||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
// This can not be async.
|
|
||||||
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(UUID unqiueId) {
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
try {
|
try {
|
||||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||||
preparedSt.setString(1, unqiueId.toString());
|
preparedSt.setString(1, uniqueId.toString());
|
||||||
preparedSt.executeUpdate();
|
preparedSt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openConnection() throws SQLException {
|
private void openConnection() throws SQLException {
|
||||||
if (connection != null && !connection.isClosed()) {
|
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
return;
|
// ...
|
||||||
|
// });
|
||||||
|
// connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
||||||
|
|
||||||
|
// Connection isn't null AND Connection isn't closed :: return
|
||||||
|
try {
|
||||||
|
if (isConnectionOpen()) {
|
||||||
|
return;
|
||||||
|
} else if (connection != null) close(); // Close connection if still active
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
e.printStackTrace(); // If isConnectionOpen() throws error
|
||||||
}
|
}
|
||||||
//Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
|
|
||||||
//close Connection if still active
|
// Connect to database host
|
||||||
if (connection != null) {
|
try {
|
||||||
close();
|
Class.forName("com.mysql.jdbc.Driver");
|
||||||
}
|
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, setupProperties());
|
||||||
|
} catch (SQLException e) {
|
||||||
//connect to database host
|
System.out.println(e.getMessage());
|
||||||
try {
|
} catch (ClassNotFoundException e) {
|
||||||
Class.forName("com.mysql.jdbc.Driver");
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, setupProperties());
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
//});
|
|
||||||
//connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
try {
|
try {
|
||||||
|
if (connection == null) throw new NullPointerException("Connection is null");
|
||||||
connection.close();
|
connection.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException | NullPointerException e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private Properties setupProperties() {
|
private Properties setupProperties() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put("user", user);
|
props.put("user", user);
|
||||||
@@ -158,28 +114,29 @@ public class MySQLData extends Data {
|
|||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isConnectionOpen() {
|
private boolean isConnectionOpen() throws RuntimeException {
|
||||||
try {
|
try {
|
||||||
if (connection == null || connection.isClosed()) {
|
return connection != null && !connection.isClosed();
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public PreparedStatement preparedStatement(String query) {
|
public PreparedStatement preparedStatement(String query) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
|
||||||
if (!isConnectionOpen()) {
|
if (!isConnectionOpen()) {
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (connection == null) throw new NullPointerException("Connection is null");
|
||||||
ps = connection.prepareStatement(query);
|
ps = connection.prepareStatement(query);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException | NullPointerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.database.types;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public abstract class SQLData extends Data {
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
|
||||||
|
public CosmeticUser get(UUID uniqueId) {
|
||||||
|
CosmeticUser user = new CosmeticUser(uniqueId);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
try {
|
||||||
|
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
||||||
|
preparedStatement.setString(1, uniqueId.toString());
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
if (rs.next()) {
|
||||||
|
String rawData = rs.getString("COSMETICS");
|
||||||
|
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = deserializeData(user, rawData);
|
||||||
|
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
|
||||||
|
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
||||||
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
// This can not be async.
|
||||||
|
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("resource")
|
||||||
|
public void save(CosmeticUser user) {
|
||||||
|
Runnable run = () -> {
|
||||||
|
try {
|
||||||
|
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
||||||
|
preparedSt.setString(1, user.getUniqueId().toString());
|
||||||
|
preparedSt.setString(2, serializeData(user));
|
||||||
|
preparedSt.executeUpdate();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (!HMCCosmeticsPlugin.isDisable()) {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
||||||
|
} else {
|
||||||
|
run.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract PreparedStatement preparedStatement(String query);
|
||||||
|
}
|
||||||
@@ -1,31 +1,31 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.database.types;
|
package com.hibiscusmc.hmccosmetics.database.types;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
import java.util.Map;
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class SQLiteData extends Data {
|
public class SQLiteData extends SQLData {
|
||||||
|
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
|
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
|
||||||
|
boolean exists = dataFolder.exists();
|
||||||
|
|
||||||
if (!dataFolder.exists()){
|
if (!exists) {
|
||||||
try {
|
try {
|
||||||
dataFolder.createNewFile();
|
boolean created = dataFolder.createNewFile();
|
||||||
|
if (!created) throw new IOException("File didn't exist but now does");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
MessagesUtil.sendDebugMessages("File write error. Database will not work properly", Level.SEVERE);
|
MessagesUtil.sendDebugMessages("File write error. Database will not work properly", Level.SEVERE);
|
||||||
}
|
}
|
||||||
@@ -39,66 +39,18 @@ public class SQLiteData extends Data {
|
|||||||
"(UUID varchar(36) PRIMARY KEY, " +
|
"(UUID varchar(36) PRIMARY KEY, " +
|
||||||
"COSMETICS MEDIUMTEXT " +
|
"COSMETICS MEDIUMTEXT " +
|
||||||
");").execute();
|
");").execute();
|
||||||
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(CosmeticUser user) {
|
@SuppressWarnings("resource")
|
||||||
Runnable run = () -> {
|
public void clear(UUID uniqueId) {
|
||||||
try {
|
|
||||||
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
|
||||||
preparedSt.setString(1, user.getUniqueId().toString());
|
|
||||||
preparedSt.setString(2, steralizeData(user));
|
|
||||||
preparedSt.executeUpdate();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (!HMCCosmeticsPlugin.isDisable()) {
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
|
||||||
} else {
|
|
||||||
run.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
|
||||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
try {
|
|
||||||
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
|
||||||
preparedStatement.setString(1, uniqueId.toString());
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
if (rs.next()) {
|
|
||||||
String rawData = rs.getString("COSMETICS");
|
|
||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = desteralizedata(user, rawData);
|
|
||||||
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
|
|
||||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
// This can not be async.
|
|
||||||
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(UUID unqiueId) {
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
try {
|
try {
|
||||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||||
preparedSt.setString(1, unqiueId.toString());
|
preparedSt.setString(1, uniqueId.toString());
|
||||||
preparedSt.executeUpdate();
|
preparedSt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -106,56 +58,47 @@ public class SQLiteData extends Data {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void openConnection() throws SQLException {
|
private void openConnection() throws SQLException {
|
||||||
if (connection != null && !connection.isClosed()) {
|
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
return;
|
// ...
|
||||||
}
|
// });
|
||||||
//Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
// connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
||||||
|
|
||||||
//close Connection if still active
|
if (connection != null && !connection.isClosed()) return;
|
||||||
if (connection != null) {
|
|
||||||
//close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Close Connection if still active
|
||||||
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
|
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
|
||||||
|
|
||||||
//connect to database host
|
// Connect to database host
|
||||||
try {
|
try {
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
|
|
||||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//});
|
|
||||||
//connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public PreparedStatement preparedStatement(String query) {
|
public PreparedStatement preparedStatement(String query) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
if (!isConnectionOpen()) {
|
if (!isConnectionOpen()) {
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ps = connection.prepareStatement(query);
|
ps = connection.prepareStatement(query);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isConnectionOpen() {
|
private boolean isConnectionOpen() {
|
||||||
try {
|
try {
|
||||||
if (connection == null || connection.isClosed()) {
|
return connection != null && !connection.isClosed();
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.emotes;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.ticxo.playeranimator.api.PlayerAnimator;
|
||||||
|
import com.ticxo.playeranimator.api.animation.pack.AnimationPack;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages Emotes
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class EmoteManager {
|
||||||
|
private static final @NotNull Map<String, String> emotes = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all BlockBench animations from the emotes folder and puts it into the animation manager registry and local registry
|
||||||
|
*/
|
||||||
|
public static void loadEmotes() {
|
||||||
|
// Clear the PlayerAnimator and local registries
|
||||||
|
PlayerAnimator.api.getAnimationManager().clearRegistry();
|
||||||
|
emotes.clear();
|
||||||
|
|
||||||
|
// Get the emote directory and check if it exists
|
||||||
|
File emoteDir = new File(HMCCosmeticsPlugin.getInstance().getDataFolder().getPath() + "/emotes/");
|
||||||
|
if (!emoteDir.exists()) return;
|
||||||
|
|
||||||
|
// Get all the files inside the directory and check if it isn't 0
|
||||||
|
File[] emoteFiles = emoteDir.listFiles();
|
||||||
|
if (emoteFiles == null || emoteFiles.length == 0) return;
|
||||||
|
|
||||||
|
// Remove any files that don't have the file extension ".bbmodel" and check if there are still resulting files
|
||||||
|
emoteFiles = Arrays.stream(emoteFiles).filter(file -> file.getPath().endsWith(".bbmodel")).distinct().toArray(File[]::new);
|
||||||
|
if (emoteFiles.length == 0) return;
|
||||||
|
|
||||||
|
// Loop through all files, importing all block bench animations into the registry
|
||||||
|
for (File animationFile : emoteFiles) {
|
||||||
|
String animationKey = FilenameUtils.removeExtension(animationFile.getName());
|
||||||
|
PlayerAnimator.api.getAnimationManager().importAnimations(animationKey, animationFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loops through all the entries in the registries and unpacks any animation packs to ensure if there were multiple animations
|
||||||
|
// inside a singular file, that they are added to the local registry individually for tab completion
|
||||||
|
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
|
||||||
|
packEntry.getValue().getAnimations().keySet().forEach(animationName -> {
|
||||||
|
// API key is the format "animationKey.animationFileName.animationName"
|
||||||
|
String apiKey = packEntry.getKey().replace(":", ".") + "." + animationName;
|
||||||
|
emotes.put(animationName, apiKey);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if there is an animation with the specified name
|
||||||
|
* @param animationName Name whose presence is to be tested
|
||||||
|
* @return True if this registry contains a mapping for the specified name
|
||||||
|
*/
|
||||||
|
public static boolean has(@NotNull String animationName) {
|
||||||
|
return emotes.containsKey(animationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@code API key} to which the specified name is mapped, or {@code null} if this map contains no mapping for the name.
|
||||||
|
* @param animationName Name whose {@code API key} is to be fetched
|
||||||
|
* @return The {@code API key} of the specified name or {@code null} if there was no animation name found
|
||||||
|
*/
|
||||||
|
public static @Nullable String get(@NotNull String animationName) {
|
||||||
|
return emotes.get(animationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a set of all the laoded animation names
|
||||||
|
* @return A set of all loaded animation names
|
||||||
|
*/
|
||||||
|
public static @NotNull Set<String> getAllNames() {
|
||||||
|
return emotes.keySet();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,47 +1,102 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui;
|
package com.hibiscusmc.hmccosmetics.gui;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.api.PlayerMenuOpenEvent;
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Types;
|
import com.hibiscusmc.hmccosmetics.gui.type.Types;
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
|
||||||
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
||||||
import dev.triumphteam.gui.guis.Gui;
|
import dev.triumphteam.gui.guis.Gui;
|
||||||
import dev.triumphteam.gui.guis.GuiItem;
|
import dev.triumphteam.gui.guis.GuiItem;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class Menu {
|
public class Menu {
|
||||||
|
|
||||||
private String id;
|
private final String id;
|
||||||
private String title;
|
private final String title;
|
||||||
private int rows;
|
private final int rows;
|
||||||
private ConfigurationNode config;
|
private final ConfigurationNode config;
|
||||||
private String permissionNode;
|
private final String permissionNode;
|
||||||
|
private final ArrayList<MenuItem> items;
|
||||||
|
private final int refreshRate;
|
||||||
|
|
||||||
public Menu(String id, ConfigurationNode config) {
|
public Menu(String id, @NotNull ConfigurationNode config) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
title = config.node("title").getString("chest");
|
title = config.node("title").getString("chest");
|
||||||
rows = config.node("rows").getInt(1);
|
rows = config.node("rows").getInt(1);
|
||||||
permissionNode = config.node("permission").getString("");
|
permissionNode = config.node("permission").getString("");
|
||||||
|
refreshRate = config.node("refresh-rate").getInt(-1);
|
||||||
|
|
||||||
|
items = new ArrayList<>();
|
||||||
|
setupItems();
|
||||||
|
|
||||||
Menus.addMenu(this);
|
Menus.addMenu(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupItems() {
|
||||||
|
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
||||||
|
|
||||||
|
List<String> slotString;
|
||||||
|
try {
|
||||||
|
slotString = config.node("slots").getList(String.class);
|
||||||
|
} catch (SerializationException e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (slotString == null) {
|
||||||
|
MessagesUtil.sendDebugMessages("Unable to get valid slot for " + config.key().toString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> slots = getSlots(slotString);
|
||||||
|
|
||||||
|
if (slots == null) {
|
||||||
|
MessagesUtil.sendDebugMessages("Slot is null for " + config.key().toString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item;
|
||||||
|
try {
|
||||||
|
item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config.node("item"));
|
||||||
|
} catch (SerializationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item == null) {
|
||||||
|
MessagesUtil.sendDebugMessages("something went wrong! " + item);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Type type = null;
|
||||||
|
|
||||||
|
if (!config.node("type").virtual()) {
|
||||||
|
String typeId = config.node("type").getString();
|
||||||
|
if (Types.isType(typeId)) type = Types.getType(typeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
items.add(new MenuItem(slots, item, type, config));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -58,7 +113,7 @@ public class Menu {
|
|||||||
openMenu(user, false);
|
openMenu(user, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openMenu(CosmeticUser user, boolean ignorePermission) {
|
public void openMenu(@NotNull CosmeticUser user, boolean ignorePermission) {
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
if (!ignorePermission && !permissionNode.isEmpty()) {
|
if (!ignorePermission && !permissionNode.isEmpty()) {
|
||||||
@@ -67,7 +122,7 @@ public class Menu {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Component component = Adventure.MINI_MESSAGE.deserialize(Placeholder.applyPapiPlaceholders(player, this.title));
|
final Component component = Adventure.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(player, this.title));
|
||||||
Gui gui = Gui.gui().
|
Gui gui = Gui.gui().
|
||||||
title(component).
|
title(component).
|
||||||
rows(this.rows).
|
rows(this.rows).
|
||||||
@@ -75,96 +130,64 @@ public class Menu {
|
|||||||
|
|
||||||
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||||
|
|
||||||
gui = getItems(user, gui);
|
AtomicInteger taskid = new AtomicInteger(-1);
|
||||||
|
gui.setOpenGuiAction(event -> {
|
||||||
|
Runnable run = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (gui.getInventory().getViewers().size() == 0 && taskid.get() != -1) {
|
||||||
|
Bukkit.getScheduler().cancelTask(taskid.get());
|
||||||
|
}
|
||||||
|
|
||||||
Gui finalGui = gui;
|
updateMenu(user, gui);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (refreshRate != -1) {
|
||||||
|
taskid.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(HMCCosmeticsPlugin.getInstance(), run, 0, refreshRate));
|
||||||
|
} else {
|
||||||
|
run.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gui.setCloseGuiAction(event -> {
|
||||||
|
if (taskid.get() != -1) Bukkit.getScheduler().cancelTask(taskid.get());
|
||||||
|
});
|
||||||
|
|
||||||
|
// API
|
||||||
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
});
|
});
|
||||||
|
if (event.isCancelled()) return;
|
||||||
if (event.isCancelled()) {
|
// Internal
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
finalGui.open(player);
|
gui.open(player);
|
||||||
});
|
});
|
||||||
|
|
||||||
//gui.open(player);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Gui getItems(CosmeticUser user, Gui gui) {
|
private void updateMenu(CosmeticUser user, Gui gui) {
|
||||||
Player player = user.getPlayer();
|
for (MenuItem item : items) {
|
||||||
|
Type type = item.getType();
|
||||||
|
for (int slot : item.getSlots()) {
|
||||||
|
ItemStack modifiedItem = getMenuItem(user, type, item.getItemConfig(), item.getItem().clone(), slot);
|
||||||
|
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
|
||||||
|
guiItem.setAction(event -> {
|
||||||
|
MessagesUtil.sendDebugMessages("Selected slot " + slot);
|
||||||
|
final ClickType clickType = event.getClick();
|
||||||
|
if (type != null) type.run(user, item.getItemConfig(), clickType);
|
||||||
|
updateMenu(user, gui);
|
||||||
|
});
|
||||||
|
|
||||||
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
MessagesUtil.sendDebugMessages("Added " + slot + " as " + guiItem + " in the menu");
|
||||||
|
gui.updateItem(slot, guiItem);
|
||||||
List<String> slotString = null;
|
|
||||||
try {
|
|
||||||
slotString = config.node("slots").getList(String.class);
|
|
||||||
} catch (SerializationException e) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (slotString == null) {
|
|
||||||
MessagesUtil.sendDebugMessages("Unable to get valid slot for " + config.key().toString());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Integer> slots = getSlots(slotString);
|
|
||||||
|
|
||||||
|
|
||||||
if (slots == null) {
|
|
||||||
MessagesUtil.sendDebugMessages("Slot is null for " + config.key().toString());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack item;
|
|
||||||
|
|
||||||
try {
|
|
||||||
item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config.node("item"));
|
|
||||||
//item = config.node("item").get(ItemStack.class);
|
|
||||||
} catch (SerializationException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item == null) {
|
|
||||||
MessagesUtil.sendDebugMessages("something went wrong! " + item);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Type type = null;
|
|
||||||
|
|
||||||
if (!config.node("type").virtual()) {
|
|
||||||
String typeId = config.node("type").getString();
|
|
||||||
if (Types.isType(typeId)) type = Types.getType(typeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack originalItem = item.clone();
|
|
||||||
item = updateLore(user, item, type, config);
|
|
||||||
|
|
||||||
GuiItem guiItem = ItemBuilder.from(item).asGuiItem();
|
|
||||||
|
|
||||||
Type finalType = type;
|
|
||||||
guiItem.setAction(event -> {
|
|
||||||
final ClickType clickType = event.getClick();
|
|
||||||
if (finalType != null) finalType.run(user, config, clickType);
|
|
||||||
|
|
||||||
for (int i : slots) {
|
|
||||||
gui.updateItem(i, updateLore(user, originalItem.clone(), finalType, config));
|
|
||||||
MessagesUtil.sendDebugMessages("Updated slot " + i);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Added " + slots + " as " + guiItem + " in the menu");
|
|
||||||
gui.setItem(slots, guiItem);
|
|
||||||
}
|
}
|
||||||
return gui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> getSlots(List<String> slotString) {
|
@NotNull
|
||||||
|
private List<Integer> getSlots(@NotNull List<String> slotString) {
|
||||||
List<Integer> slots = new ArrayList<>();
|
List<Integer> slots = new ArrayList<>();
|
||||||
|
|
||||||
for (String a : slotString) {
|
for (String a : slotString) {
|
||||||
@@ -181,6 +204,7 @@ public class Menu {
|
|||||||
return slots;
|
return slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private List<Integer> getSlots(int small, int max) {
|
private List<Integer> getSlots(int small, int max) {
|
||||||
List<Integer> slots = new ArrayList<>();
|
List<Integer> slots = new ArrayList<>();
|
||||||
|
|
||||||
@@ -188,11 +212,11 @@ public class Menu {
|
|||||||
return slots;
|
return slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack updateLore(CosmeticUser user, ItemStack itemStack, Type type, ConfigurationNode config) {
|
@Contract("_, _, _, _ -> param2")
|
||||||
if (itemStack.hasItemMeta()) {
|
@NotNull
|
||||||
itemStack.setItemMeta(type.setLore(user, config, itemStack.getItemMeta()));
|
private ItemStack getMenuItem(CosmeticUser user, Type type, ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||||
}
|
if (!itemStack.hasItemMeta()) return itemStack;
|
||||||
return itemStack;
|
return type.setItem(user, config, itemStack, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermissionNode() {
|
public String getPermissionNode() {
|
||||||
@@ -201,7 +225,6 @@ public class Menu {
|
|||||||
|
|
||||||
public boolean canOpen(Player player) {
|
public boolean canOpen(Player player) {
|
||||||
if (permissionNode.isEmpty()) return true;
|
if (permissionNode.isEmpty()) return true;
|
||||||
if (player.isOp() || player.hasPermission(permissionNode)) return true;
|
return player.isOp() || player.hasPermission(permissionNode);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.gui;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MenuItem {
|
||||||
|
|
||||||
|
private List<Integer> slots;
|
||||||
|
private ItemStack item;
|
||||||
|
private Type type;
|
||||||
|
private ConfigurationNode itemConfig;
|
||||||
|
|
||||||
|
public MenuItem(List<Integer> slots, ItemStack item, Type type, ConfigurationNode itemConfig) {
|
||||||
|
this.slots = slots;
|
||||||
|
this.item = item;
|
||||||
|
this.type = type;
|
||||||
|
this.itemConfig = itemConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getSlots() {
|
||||||
|
return slots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigurationNode getItemConfig() {
|
||||||
|
return itemConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,34 +4,41 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
import org.spongepowered.configurate.ConfigurateException;
|
||||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class Menus {
|
public class Menus {
|
||||||
|
|
||||||
private static HashMap<String, Menu> MENUS = new HashMap<>();
|
private static final HashMap<String, Menu> MENUS = new HashMap<>();
|
||||||
|
|
||||||
public static void addMenu(Menu menu) {
|
public static void addMenu(Menu menu) {
|
||||||
MENUS.put(menu.getId().toUpperCase(), menu);
|
MENUS.put(menu.getId().toUpperCase(), menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Menu getMenu(String id) {
|
public static Menu getMenu(@NotNull String id) {
|
||||||
return MENUS.get(id.toUpperCase());
|
return MENUS.get(id.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Contract(pure = true)
|
||||||
|
@NotNull
|
||||||
public static Collection<Menu> getMenu() {
|
public static Collection<Menu> getMenu() {
|
||||||
return MENUS.values();
|
return MENUS.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasMenu(String id) {
|
public static boolean hasMenu(@NotNull String id) {
|
||||||
return MENUS.containsKey(id.toUpperCase());
|
return MENUS.containsKey(id.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +48,7 @@ public class Menus {
|
|||||||
|
|
||||||
public static Menu getDefaultMenu() { return Menus.getMenu(Settings.getDefaultMenu()); }
|
public static Menu getDefaultMenu() { return Menus.getMenu(Settings.getDefaultMenu()); }
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static List<String> getMenuNames() {
|
public static List<String> getMenuNames() {
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
|
|
||||||
@@ -51,33 +59,39 @@ public class Menus {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Collection<Menu> values() {
|
||||||
|
return MENUS.values();
|
||||||
|
}
|
||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
MENUS.clear();
|
MENUS.clear();
|
||||||
|
|
||||||
File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus");
|
File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus");
|
||||||
if (!cosmeticFolder.exists()) cosmeticFolder.mkdir();
|
if (!cosmeticFolder.exists()) cosmeticFolder.mkdir();
|
||||||
|
|
||||||
File[] directoryListing = cosmeticFolder.listFiles();
|
// Recursive file lookup
|
||||||
if (directoryListing == null) return;
|
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
|
||||||
|
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
|
||||||
for (File child : directoryListing) {
|
if (child.toString().endsWith("yml") || child.toString().endsWith("yaml")) {
|
||||||
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
// Loads file
|
||||||
// Loads file
|
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
|
||||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
|
CommentedConfigurationNode root;
|
||||||
CommentedConfigurationNode root;
|
try {
|
||||||
try {
|
root = loader.load();
|
||||||
root = loader.load();
|
} catch (ConfigurateException e) {
|
||||||
} catch (ConfigurateException e) {
|
throw new RuntimeException(e);
|
||||||
throw new RuntimeException(e);
|
}
|
||||||
|
try {
|
||||||
|
new Menu(FilenameUtils.removeExtension(child.getFileName().toString()), root);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MessagesUtil.sendDebugMessages("Unable to create menu in " + child.getFileName().toString(), Level.WARNING);
|
||||||
|
if (Settings.isDebugEnabled()) e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
});
|
||||||
new Menu(FilenameUtils.removeExtension(child.getName()), root);
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
MessagesUtil.sendDebugMessages("Unable to create menu in " + child, Level.WARNING);
|
|
||||||
if (Settings.isDebugEnabled()) e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui.action;
|
package com.hibiscusmc.hmccosmetics.gui.action;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class Action {
|
public abstract class Action {
|
||||||
|
|
||||||
private String id;
|
private final String id;
|
||||||
|
|
||||||
public Action(String id) {
|
public Action(@NotNull String id) {
|
||||||
this.id = id.toUpperCase();
|
this.id = id.toUpperCase();
|
||||||
Actions.addAction(this);
|
Actions.addAction(this);
|
||||||
}
|
}
|
||||||
@@ -15,7 +16,5 @@ public class Action {
|
|||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(CosmeticUser user, String raw) {
|
public abstract void run(CosmeticUser user, String raw);
|
||||||
// Override
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,34 +4,36 @@ import com.hibiscusmc.hmccosmetics.gui.action.actions.*;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class Actions {
|
public class Actions {
|
||||||
|
|
||||||
private static HashMap<String, Action> actions = new HashMap<>();
|
private static final HashMap<String, Action> actions = new HashMap<>();
|
||||||
|
|
||||||
// [ID]
|
// [ID]
|
||||||
private static ActionMessage ACTION_MESSAGE = new ActionMessage();
|
private static final ActionMessage ACTION_MESSAGE = new ActionMessage();
|
||||||
private static ActionMenu ACTION_MENU = new ActionMenu();
|
private static final ActionMenu ACTION_MENU = new ActionMenu();
|
||||||
private static ActionPlayerCommand ACTION_CONSOLE_COMMAND = new ActionPlayerCommand();
|
private static final ActionPlayerCommand ACTION_CONSOLE_COMMAND = new ActionPlayerCommand();
|
||||||
private static ActionConsoleCommand ACTION_PLAYER_COMMAND = new ActionConsoleCommand();
|
private static final ActionConsoleCommand ACTION_PLAYER_COMMAND = new ActionConsoleCommand();
|
||||||
private static ActionCloseMenu ACTION_EXIT_MENU = new ActionCloseMenu();
|
private static final ActionCloseMenu ACTION_EXIT_MENU = new ActionCloseMenu();
|
||||||
private static ActionSound ACTION_SOUND = new ActionSound();
|
private static final ActionSound ACTION_SOUND = new ActionSound();
|
||||||
private static ActionEquip ACTION_EQUIP = new ActionEquip();
|
private static final ActionEquip ACTION_EQUIP = new ActionEquip();
|
||||||
private static ActionUnequip ACTION_UNEQUIP = new ActionUnequip();
|
private static final ActionUnequip ACTION_UNEQUIP = new ActionUnequip();
|
||||||
private static ActionParticle ACTION_PARTICLE = new ActionParticle();
|
private static final ActionParticle ACTION_PARTICLE = new ActionParticle();
|
||||||
private static ActionCosmeticShow ACTION_SHOW = new ActionCosmeticShow();
|
private static final ActionCosmeticShow ACTION_SHOW = new ActionCosmeticShow();
|
||||||
private static ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
|
private static final ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
|
||||||
private static ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
|
private static final ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
|
||||||
|
|
||||||
|
|
||||||
public static Action getAction(String id) {
|
public static Action getAction(@NotNull String id) {
|
||||||
return actions.get(id.toUpperCase());
|
return actions.get(id.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAction(String id) {
|
public static boolean isAction(@NotNull String id) {
|
||||||
return actions.containsKey(id.toUpperCase());
|
return actions.containsKey(id.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ public class Actions {
|
|||||||
actions.put(action.getId().toUpperCase(), action);
|
actions.put(action.getId().toUpperCase(), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runActions(CosmeticUser user, List<String> raw) {
|
public static void runActions(CosmeticUser user, @NotNull List<String> raw) {
|
||||||
for (String a : raw) {
|
for (String a : raw) {
|
||||||
String id = StringUtils.substringBetween(a, "[", "]").toUpperCase();
|
String id = StringUtils.substringBetween(a, "[", "]").toUpperCase();
|
||||||
String message = StringUtils.substringAfter(a, "] ");
|
String message = StringUtils.substringAfter(a, "] ");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionCloseMenu extends Action {
|
public class ActionCloseMenu extends Action {
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@ public class ActionCloseMenu extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
user.getPlayer().closeInventory();
|
user.getPlayer().closeInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionConsoleCommand extends Action {
|
public class ActionConsoleCommand extends Action {
|
||||||
|
|
||||||
@@ -11,8 +12,7 @@ public class ActionConsoleCommand extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(user.getPlayer(), raw);
|
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(user.getPlayer(), raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionCosmeticHide extends Action {
|
public class ActionCosmeticHide extends Action {
|
||||||
|
|
||||||
@@ -10,10 +11,8 @@ public class ActionCosmeticHide extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
if (!user.getHidden()) {
|
if (user.getHidden()) return;
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionCosmeticShow extends Action {
|
public class ActionCosmeticShow extends Action {
|
||||||
|
|
||||||
@@ -10,10 +11,11 @@ public class ActionCosmeticShow extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
if (user.getHidden()) {
|
if (!user.getHidden()) return;
|
||||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return; // Do not hide if its already off for WG
|
|
||||||
user.showCosmetics();
|
// Do not hide if it's already off for WG
|
||||||
}
|
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
||||||
|
user.showCosmetics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionCosmeticToggle extends Action {
|
public class ActionCosmeticToggle extends Action {
|
||||||
|
|
||||||
@@ -10,13 +11,13 @@ public class ActionCosmeticToggle extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ public class ActionEquip extends Action {
|
|||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(CosmeticUser user, String raw) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(raw);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(raw);
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
user.addPlayerCosmetic(cosmetic);
|
user.addPlayerCosmetic(cosmetic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ActionMenu extends Action {
|
public class ActionMenu extends Action {
|
||||||
|
|
||||||
@@ -22,12 +24,14 @@ public class ActionMenu extends Action {
|
|||||||
raw = raw.replaceAll("-o", "");
|
raw = raw.replaceAll("-o", "");
|
||||||
ignorePermission = true;
|
ignorePermission = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Menus.hasMenu(raw)) {
|
if (!Menus.hasMenu(raw)) {
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Invalid Action Menu -> " + raw);
|
MessagesUtil.sendDebugMessages("Invalid Action Menu -> " + raw, Level.WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu menu = Menus.getMenu(raw);
|
Menu menu = Menus.getMenu(raw);
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info(raw + " | " + ignorePermission);
|
MessagesUtil.sendDebugMessages(raw + " | " + ignorePermission);
|
||||||
menu.openMenu(user, ignorePermission);
|
menu.openMenu(user, ignorePermission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionMessage extends Action {
|
public class ActionMessage extends Action {
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ public class ActionMessage extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
MessagesUtil.sendMessageNoKey(user.getPlayer(), raw);
|
MessagesUtil.sendMessageNoKey(user.getPlayer(), raw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,16 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.owen1212055.particlehelper.api.particle.Particle;
|
|
||||||
import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
|
import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
|
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.vibration.VibrationParticle;
|
import com.owen1212055.particlehelper.api.particle.types.vibration.VibrationParticle;
|
||||||
|
import com.owen1212055.particlehelper.api.type.ParticleType;
|
||||||
import com.owen1212055.particlehelper.api.type.Particles;
|
import com.owen1212055.particlehelper.api.type.Particles;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionParticle extends Action {
|
public class ActionParticle extends Action {
|
||||||
|
|
||||||
@@ -22,17 +23,17 @@ public class ActionParticle extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
public void run(CosmeticUser user, @NotNull String raw) {
|
||||||
String[] rawString = raw.split(" ");
|
String[] rawString = raw.split(" ");
|
||||||
var particleType = Particles.fromKey(NamespacedKey.minecraft(rawString[0].toLowerCase()));
|
ParticleType<?, ?> particleType = Particles.fromKey(NamespacedKey.minecraft(rawString[0].toLowerCase()));
|
||||||
if (particleType == null) {
|
if (particleType == null) {
|
||||||
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " does not exist!");
|
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " does not exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean multi = false;
|
|
||||||
if (particleType.multi() != null) {
|
// particleType.multi() should never be null, but particleType can be.
|
||||||
multi = true; // Should work?
|
boolean multi = particleType.multi() != null;
|
||||||
}
|
|
||||||
|
|
||||||
var particle = multi ? particleType.multi() : particleType.single();
|
var particle = multi ? particleType.multi() : particleType.single();
|
||||||
if (particle instanceof DestinationParticle || particle instanceof BlockDataParticle
|
if (particle instanceof DestinationParticle || particle instanceof BlockDataParticle
|
||||||
@@ -40,6 +41,7 @@ public class ActionParticle extends Action {
|
|||||||
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " is not supported by this action!");
|
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " is not supported by this action!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
particle = ServerUtils.addParticleValues(particle, rawString);
|
particle = ServerUtils.addParticleValues(particle, rawString);
|
||||||
Location location = user.getPlayer().getLocation();
|
Location location = user.getPlayer().getLocation();
|
||||||
for (Player player : PacketManager.getViewers(location)) {
|
for (Player player : PacketManager.getViewers(location)) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionPlayerCommand extends Action {
|
public class ActionPlayerCommand extends Action {
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ public class ActionPlayerCommand extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
user.getPlayer().performCommand(MessagesUtil.processStringNoKeyString(user.getPlayer(), raw));
|
user.getPlayer().performCommand(MessagesUtil.processStringNoKeyString(user.getPlayer(), raw));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ public class ActionSound extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, @NotNull String raw) {
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
String[] processedString = raw.split(" ");
|
String[] processedString = raw.split(" ");
|
||||||
|
|
||||||
@@ -24,11 +25,11 @@ public class ActionSound extends Action {
|
|||||||
float pitch = 1;
|
float pitch = 1;
|
||||||
|
|
||||||
if (processedString.length > 2) {
|
if (processedString.length > 2) {
|
||||||
volume = Float.valueOf(processedString[1]);
|
volume = Float.parseFloat(processedString[1]);
|
||||||
pitch = Float.valueOf(processedString[2]);
|
pitch = Float.parseFloat(processedString[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Attempting to play " + soundName, Level.WARNING);
|
MessagesUtil.sendDebugMessages("Attempting to play " + soundName, Level.INFO);
|
||||||
|
|
||||||
player.playSound(player.getLocation(), soundName, volume, pitch);
|
player.playSound(player.getLocation(), soundName, volume, pitch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ public class ActionUnequip extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, String raw) {
|
public void run(CosmeticUser user, String raw) {
|
||||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, raw)) {
|
if (!EnumUtils.isValidEnum(CosmeticSlot.class, raw)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
CosmeticSlot slot = CosmeticSlot.valueOf(raw);
|
CosmeticSlot slot = CosmeticSlot.valueOf(raw);
|
||||||
user.removeCosmeticSlot(slot);
|
user.removeCosmeticSlot(slot);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import com.hibiscusmc.hmccolor.gui.guis.GuiItem;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -17,19 +17,22 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||||
import org.bukkit.inventory.meta.MapMeta;
|
import org.bukkit.inventory.meta.MapMeta;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class DyeMenu {
|
public class DyeMenu {
|
||||||
|
|
||||||
// Yes, I do know how tacted on this feels.
|
public static void openMenu(@NotNull CosmeticUser user, Cosmetic cosmetic) {
|
||||||
|
Player player = user.getPlayer();
|
||||||
|
if (player == null) return;
|
||||||
public static void openMenu(CosmeticUser user, Cosmetic cosmetic) {
|
if (!Hooks.isActiveHook("HMCColor")) {
|
||||||
|
addCosmetic(user, cosmetic, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ItemStack originalItem = user.getUserCosmeticItem(cosmetic);
|
ItemStack originalItem = user.getUserCosmeticItem(cosmetic);
|
||||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
if (originalItem == null || !cosmetic.isDyable()) return;
|
||||||
|
|
||||||
Player player = user.getPlayer();
|
|
||||||
Gui gui = HMCColorApi.INSTANCE.colorMenu();
|
Gui gui = HMCColorApi.INSTANCE.colorMenu();
|
||||||
gui.updateTitle(Placeholder.applyPapiPlaceholders(player, Settings.getDyeMenuName()));
|
gui.updateTitle(Hooks.processPlaceholders(player, Settings.getDyeMenuName()));
|
||||||
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
||||||
gui.setDefaultTopClickAction(event -> {
|
gui.setDefaultTopClickAction(event -> {
|
||||||
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
||||||
@@ -43,13 +46,8 @@ public class DyeMenu {
|
|||||||
meta instanceof MapMeta mapMeta ? mapMeta.getColor() : null;
|
meta instanceof MapMeta mapMeta ? mapMeta.getColor() : null;
|
||||||
if (color == null) return;
|
if (color == null) return;
|
||||||
|
|
||||||
//user.removeCosmeticSlot(cosmetic);
|
addCosmetic(user, cosmetic, color);
|
||||||
user.addPlayerCosmetic(cosmetic, color);
|
event.setCancelled(true);
|
||||||
player.setItemOnCursor(new ItemStack(Material.AIR));
|
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
player.closeInventory();
|
|
||||||
user.updateCosmetic(cosmetic.getSlot());
|
|
||||||
}, 2);
|
|
||||||
} else event.setCancelled(true);
|
} else event.setCancelled(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -57,4 +55,14 @@ public class DyeMenu {
|
|||||||
gui.setCloseGuiAction(event -> {});
|
gui.setCloseGuiAction(event -> {});
|
||||||
gui.open(player);
|
gui.open(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addCosmetic(@NotNull CosmeticUser user, Cosmetic cosmetic, Color color) {
|
||||||
|
Player player = user.getPlayer();
|
||||||
|
user.addPlayerCosmetic(cosmetic, color);
|
||||||
|
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||||
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
player.closeInventory();
|
||||||
|
user.updateCosmetic(cosmetic.getSlot());
|
||||||
|
}, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package com.hibiscusmc.hmccosmetics.gui.type;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
public class Type {
|
public abstract class Type {
|
||||||
|
|
||||||
private String id;
|
private final String id;
|
||||||
|
|
||||||
public Type(String id) {
|
public Type(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -21,12 +21,8 @@ public class Type {
|
|||||||
public void run(CosmeticUser user, ConfigurationNode config) {
|
public void run(CosmeticUser user, ConfigurationNode config) {
|
||||||
run(user, config, null);
|
run(user, config, null);
|
||||||
}
|
}
|
||||||
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
|
|
||||||
// Override
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
|
public abstract void run(CosmeticUser user, ConfigurationNode config, ClickType clickType);
|
||||||
//TODO: Finish this
|
|
||||||
return null; // Override
|
public abstract ItemStack setItem(CosmeticUser user, ConfigurationNode config, ItemStack itemStack, int slot);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,22 @@ package com.hibiscusmc.hmccosmetics.gui.type;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeCosmetic;
|
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeCosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeEmpty;
|
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeEmpty;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Types {
|
public class Types {
|
||||||
|
|
||||||
private static HashMap<String, Type> types = new HashMap<>();
|
private static final HashMap<String, Type> types = new HashMap<>();
|
||||||
|
|
||||||
private static TypeCosmetic TYPE_COSMETIC = new TypeCosmetic();
|
private static TypeCosmetic TYPE_COSMETIC = new TypeCosmetic();
|
||||||
private static TypeEmpty TYPE_EMPTY = new TypeEmpty();
|
private static TypeEmpty TYPE_EMPTY = new TypeEmpty();
|
||||||
|
|
||||||
public static Type getType(String id) {
|
public static Type getType(@NotNull String id) {
|
||||||
return types.get(id.toUpperCase());
|
return types.get(id.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isType(String id) {
|
public static boolean isType(@NotNull String id) {
|
||||||
return types.containsKey(id.toUpperCase());
|
return types.containsKey(id.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui.type.types;
|
package com.hibiscusmc.hmccosmetics.gui.type.types;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||||
@@ -10,19 +11,19 @@ import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class TypeCosmetic extends Type {
|
public class TypeCosmetic extends Type {
|
||||||
|
|
||||||
@@ -31,23 +32,32 @@ public class TypeCosmetic extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
|
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||||
if (config.node("cosmetic").virtual()) return;
|
MessagesUtil.sendDebugMessages("Running Cosmetic Click Type");
|
||||||
|
if (config.node("cosmetic").virtual()) {
|
||||||
|
MessagesUtil.sendDebugMessages("Cosmetic Config Field Virtual");
|
||||||
|
return;
|
||||||
|
}
|
||||||
String cosmeticName = config.node("cosmetic").getString();
|
String cosmeticName = config.node("cosmetic").getString();
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||||
|
Player player = user.getPlayer();
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
MessagesUtil.sendMessage(user.getPlayer(), "invalid-cosmetic");
|
MessagesUtil.sendDebugMessages("No Cosmetic Found");
|
||||||
|
MessagesUtil.sendMessage(player, "invalid-cosmetic");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.canEquipCosmetic(cosmetic)) {
|
if (!user.canEquipCosmetic(cosmetic)) {
|
||||||
MessagesUtil.sendMessage(user.getPlayer(), "no-cosmetic-permission");
|
MessagesUtil.sendDebugMessages("No Cosmetic Permission");
|
||||||
|
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> actionStrings = new ArrayList<>();
|
List<String> actionStrings = new ArrayList<>();
|
||||||
ConfigurationNode actionConfig = config.node("actions");
|
ConfigurationNode actionConfig = config.node("actions");
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("Running Actions");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
||||||
|
|
||||||
@@ -68,7 +78,7 @@ public class TypeCosmetic extends Type {
|
|||||||
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
|
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
|
||||||
MessagesUtil.sendDebugMessages("on-equip");
|
MessagesUtil.sendDebugMessages("on-equip");
|
||||||
// TODO: Redo this
|
// TODO: Redo this
|
||||||
if (cosmetic.isDyable()) {
|
if (cosmetic.isDyable() && Hooks.isActiveHook("HMCColor")) {
|
||||||
DyeMenu.openMenu(user, cosmetic);
|
DyeMenu.openMenu(user, cosmetic);
|
||||||
} else {
|
} else {
|
||||||
user.addPlayerCosmetic(cosmetic);
|
user.addPlayerCosmetic(cosmetic);
|
||||||
@@ -78,82 +88,83 @@ public class TypeCosmetic extends Type {
|
|||||||
Actions.runActions(user, actionStrings);
|
Actions.runActions(user, actionStrings);
|
||||||
|
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// Fixes issue with offhand cosmetics not appearing. Yes, I know this is dumb
|
// Fixes issue with offhand cosmetics not appearing. Yes, I know this is dumb
|
||||||
Runnable run = () -> user.updateCosmetic(cosmetic.getSlot());
|
Runnable run = () -> user.updateCosmetic(cosmetic.getSlot());
|
||||||
if (cosmetic instanceof CosmeticArmorType) {
|
if (cosmetic instanceof CosmeticArmorType) {
|
||||||
if (((CosmeticArmorType) cosmetic).getEquipSlot().equals(EquipmentSlot.OFF_HAND)) {
|
if (((CosmeticArmorType) cosmetic).getEquipSlot().equals(EquipmentSlot.OFF_HAND)) {
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, 1);
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, 1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run.run();
|
run.run();
|
||||||
|
MessagesUtil.sendDebugMessages("Finished Type Click Run");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
|
public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||||
List<String> processedLore = new ArrayList<>();
|
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||||
|
|
||||||
if (config.node("cosmetic").virtual()) return processLoreLines(user, itemMeta);;
|
if (config.node("cosmetic").virtual()) {
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
String cosmeticName = config.node("cosmetic").getString();
|
String cosmeticName = config.node("cosmetic").getString();
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
return processLoreLines(user, itemMeta);
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.canEquipCosmetic(cosmetic)) {
|
if (user.hasCosmeticInSlot(cosmetic) && !config.node("equipped-item").virtual()) {
|
||||||
return processLoreLines(user, itemMeta);
|
MessagesUtil.sendDebugMessages("GUI Equipped Item");
|
||||||
} else {
|
ConfigurationNode equippedItem = config.node("equipped-item");
|
||||||
ConfigurationNode itemConfig = config.node("item");
|
try {
|
||||||
if (itemConfig.virtual()) return itemMeta;
|
if (equippedItem.node("material").virtual()) equippedItem.node("material").set(config.node("item", "material").getString());
|
||||||
if (itemConfig.node("locked-name").virtual() && itemConfig.node("locked-lore").virtual()) {
|
} catch (SerializationException e) {
|
||||||
return processLoreLines(user, itemMeta);
|
// Nothing >:)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
List<String> lockedLore = itemMeta.getLore();
|
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, equippedItem);
|
||||||
String lockedName = itemMeta.getDisplayName();
|
} catch (SerializationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
if (!itemConfig.node("locked-lore").virtual()) {
|
|
||||||
lockedLore = Utils.replaceIfNull(itemConfig.node("locked-lore").getList(String.class),
|
|
||||||
new ArrayList<String>()).
|
|
||||||
stream().map(StringUtils::parseStringToString).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
if (!itemConfig.node("locked-name").virtual()) {
|
|
||||||
lockedName = StringUtils.parseStringToString(Utils.replaceIfNull(itemConfig.node("locked-name").getString(), ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Hooks.isActiveHook("PlaceHolderAPI")) {
|
|
||||||
lockedName = PlaceholderAPI.setPlaceholders(user.getPlayer(), lockedName);
|
|
||||||
}
|
|
||||||
itemMeta.setDisplayName(lockedName);
|
|
||||||
if (itemMeta.hasLore()) {
|
|
||||||
itemMeta.getLore().clear();
|
|
||||||
for (String loreLine : lockedLore) {
|
|
||||||
if (Hooks.isActiveHook("PlaceHolderAPI")) loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
|
||||||
processedLore.add(loreLine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||||
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemMeta.setLore(processedLore);
|
if (!user.canEquipCosmetic(cosmetic) && !config.node("locked-item").virtual()) {
|
||||||
return itemMeta;
|
MessagesUtil.sendDebugMessages("GUI Locked Item");
|
||||||
|
ConfigurationNode lockedItem = config.node("locked-item");
|
||||||
|
try {
|
||||||
|
if (lockedItem.node("material").virtual()) lockedItem.node("material").set(config.node("item", "material").getString());
|
||||||
|
} catch (SerializationException e) {
|
||||||
|
// Nothing >:)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, lockedItem);
|
||||||
|
} catch (SerializationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemMeta processLoreLines(CosmeticUser user, ItemMeta itemMeta) {
|
@Contract("_, _ -> param2")
|
||||||
|
@NotNull
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
|
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
||||||
List<String> processedLore = new ArrayList<>();
|
List<String> processedLore = new ArrayList<>();
|
||||||
|
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
if (itemMeta.hasLore()) {
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI"))
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
|
||||||
processedLore.add(loreLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
itemMeta.setLore(processedLore);
|
itemMeta.setLore(processedLore);
|
||||||
return itemMeta;
|
return itemMeta;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package com.hibiscusmc.hmccosmetics.gui.type.types;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
|
|
||||||
@@ -17,7 +17,6 @@ import java.util.List;
|
|||||||
public class TypeEmpty extends Type {
|
public class TypeEmpty extends Type {
|
||||||
|
|
||||||
// This can be used as an example for making your own types.
|
// This can be used as an example for making your own types.
|
||||||
|
|
||||||
public TypeEmpty() {
|
public TypeEmpty() {
|
||||||
super("empty");
|
super("empty");
|
||||||
// This is an empty type, meaning, when a menu item has a type of "empty" it will run the code in the method run.
|
// This is an empty type, meaning, when a menu item has a type of "empty" it will run the code in the method run.
|
||||||
@@ -25,7 +24,7 @@ public class TypeEmpty extends Type {
|
|||||||
|
|
||||||
// This is the code that's run when the item is clicked.
|
// This is the code that's run when the item is clicked.
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
|
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||||
List<String> actionStrings = new ArrayList<>(); // List where we keep the actions the server will execute.
|
List<String> actionStrings = new ArrayList<>(); // List where we keep the actions the server will execute.
|
||||||
ConfigurationNode actionConfig = config.node("actions"); // Configuration node that actions are under.
|
ConfigurationNode actionConfig = config.node("actions"); // Configuration node that actions are under.
|
||||||
|
|
||||||
@@ -33,7 +32,7 @@ public class TypeEmpty extends Type {
|
|||||||
try {
|
try {
|
||||||
// This gets the actions with the item. We can add more, such as with the Cosmetic type, an equip and unequip action set.
|
// This gets the actions with the item. We can add more, such as with the Cosmetic type, an equip and unequip action set.
|
||||||
// We add that to a List of Strings, before running those actions through the server. This is not the area where we deal
|
// We add that to a List of Strings, before running those actions through the server. This is not the area where we deal
|
||||||
// with actions, mearly what should be done for each item.
|
// with actions, merely what should be done for each item.
|
||||||
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
||||||
|
|
||||||
if (clickType != null) {
|
if (clickType != null) {
|
||||||
@@ -53,18 +52,22 @@ public class TypeEmpty extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
|
@SuppressWarnings("Duplicates")
|
||||||
|
public ItemStack setItem(CosmeticUser user, ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
|
||||||
List<String> processedLore = new ArrayList<>();
|
List<String> processedLore = new ArrayList<>();
|
||||||
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
if (itemMeta.hasLore()) {
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI"))
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
|
||||||
processedLore.add(loreLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemMeta;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
// That's it! Now, add it as a static in another one of your classes (such as your main class) and you are good to go.
|
// That's it! Now, add it as a static in another one of your classes (such as your main class) and you are good to go.
|
||||||
|
|||||||
@@ -2,45 +2,92 @@ package com.hibiscusmc.hmccosmetics.hooks;
|
|||||||
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class Hook implements Listener {
|
/**
|
||||||
|
* Represents a hook into other minecraft plugins
|
||||||
|
*/
|
||||||
|
public abstract class Hook implements Listener {
|
||||||
|
private final String id;
|
||||||
|
private boolean active = false;
|
||||||
|
private boolean itemHook = false;
|
||||||
|
|
||||||
private String id;
|
public Hook(@NotNull String id) {
|
||||||
private boolean active;
|
|
||||||
private boolean itemHook;
|
|
||||||
|
|
||||||
public Hook(String id) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
active = false;
|
|
||||||
Hooks.addHook(this);
|
Hooks.addHook(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
/**
|
||||||
// Override
|
* Loads this hook
|
||||||
}
|
*
|
||||||
|
* @implNote By default, this method does nothing. It should be overridden by child classes to implement any necessary loading logic
|
||||||
|
*/
|
||||||
|
public void load() { }
|
||||||
|
|
||||||
public ItemStack getItem(String itemid) {
|
/**
|
||||||
|
* Gets an {@link ItemStack} that is associated with the provided id from the hooked plugin
|
||||||
|
* @param itemId The id of the {@link ItemStack}
|
||||||
|
* @return The {@link ItemStack} with the id provided. If an invalid id was provided or if the hook doesn't have any related {@link ItemStack}s then this will return null
|
||||||
|
* @implNote By default, this method returns null. It should be overridden by child classes if you will to have your hook return a related {@link ItemStack}
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
return null;
|
return null;
|
||||||
// Override
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
/**
|
||||||
|
* Gets the id of this hook
|
||||||
|
*
|
||||||
|
* @return The unique id for this hook
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public final String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
/**
|
||||||
this.active = active;
|
* Gets whether this hook has been activated
|
||||||
}
|
* @return true if this hook is active, false otherwise
|
||||||
|
* @deprecated As of release 2.2.5+, replaced by {@link #isActive()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean getActive() {
|
public boolean getActive() {
|
||||||
return this.active;
|
return this.active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabledItemHook(boolean enabled) {
|
/**
|
||||||
itemHook = enabled;
|
* Gets whether this hook has been activated
|
||||||
|
* @return true if this hook is active, false otherwise
|
||||||
|
* @since 2.2.5
|
||||||
|
*/
|
||||||
|
public final boolean isActive() {
|
||||||
|
return this.active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEnabledItemHook() {
|
/**
|
||||||
|
* Sets whether this hook is active
|
||||||
|
* @param active true to activate the hook, false otherwise
|
||||||
|
*/
|
||||||
|
public final void setActive(boolean active) {
|
||||||
|
this.active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the method {@link #getItem(String)} should return a non-null value
|
||||||
|
* @return true if {@link #getItem(String)} should return a non-null value, false otherwise
|
||||||
|
*
|
||||||
|
* @apiNote Even though this method returns true does not mean that {@link #getItem(String)} won't return null, rather if this returns false then {@link #getItem(String)} should return false everytime
|
||||||
|
*/
|
||||||
|
public final boolean hasEnabledItemHook() {
|
||||||
return itemHook;
|
return itemHook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the method {@link #getItem(String)} should return a non-null value
|
||||||
|
* @param enabled true if {@link #getItem(String)} should return a non-null value, false otherwise
|
||||||
|
*/
|
||||||
|
public final void setEnabledItemHook(boolean enabled) {
|
||||||
|
itemHook = enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,32 +2,40 @@ package com.hibiscusmc.hmccosmetics.hooks;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookPremiumVanish;
|
import com.hibiscusmc.hmccosmetics.hooks.misc.*;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookSuperVanish;
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Hooks {
|
public class Hooks {
|
||||||
|
|
||||||
private static HashMap<String, Hook> hooks = new HashMap<>();
|
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
||||||
private static HookOraxen ORAXEN_HOOK = new HookOraxen();
|
private static HookOraxen ORAXEN_HOOK = new HookOraxen();
|
||||||
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
||||||
private static HookLooty LOOTY_HOOK = new HookLooty();
|
private static HookGeary GEARY_HOOK = new HookGeary();
|
||||||
private static HookMythic MYTHIC_HOOK = new HookMythic();
|
private static HookMythic MYTHIC_HOOK = new HookMythic();
|
||||||
|
private static HookDenizen DENIZEN_HOOK = new HookDenizen();
|
||||||
private static HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
private static HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
||||||
private static HookPlaceholderAPI PAPI_HOOK = new HookPlaceholderAPI();
|
private static HookPlaceholderAPI PAPI_HOOK = new HookPlaceholderAPI();
|
||||||
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
||||||
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
||||||
|
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
||||||
|
private static HookCMI CMI_HOOK = new HookCMI();
|
||||||
|
private static HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
||||||
|
private static HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine();
|
||||||
|
|
||||||
public static Hook getHook(String id) {
|
public static Hook getHook(@NotNull String id) {
|
||||||
return hooks.get(id.toLowerCase());
|
return hooks.get(id.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isItemHook(String id) {
|
public static boolean isItemHook(@NotNull String id) {
|
||||||
return hooks.containsKey(id.toLowerCase());
|
return hooks.containsKey(id.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +54,8 @@ public class Hooks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getItem(String raw) {
|
@Nullable
|
||||||
|
public static ItemStack getItem(@NotNull String raw) {
|
||||||
if (!raw.contains(":")) {
|
if (!raw.contains(":")) {
|
||||||
Material mat = Material.getMaterial(raw.toUpperCase());
|
Material mat = Material.getMaterial(raw.toUpperCase());
|
||||||
if (mat == null) return null;
|
if (mat == null) return null;
|
||||||
@@ -60,14 +69,19 @@ public class Hooks {
|
|||||||
if (!isItemHook(split[0])) return null;
|
if (!isItemHook(split[0])) return null;
|
||||||
Hook hook = getHook(split[0]);
|
Hook hook = getHook(split[0]);
|
||||||
if (!hook.hasEnabledItemHook()) return null;
|
if (!hook.hasEnabledItemHook()) return null;
|
||||||
if (!hook.getActive()) return null;
|
if (!hook.isActive()) return null;
|
||||||
ItemStack item = hook.getItem(split[1]);
|
return hook.getItem(split[1]);
|
||||||
return item;
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static String processPlaceholders(OfflinePlayer player, String raw) {
|
||||||
|
if (getHook("PlaceholderAPI").isActive()) return PlaceholderAPI.setPlaceholders(player, raw);
|
||||||
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isActiveHook(String id) {
|
public static boolean isActiveHook(String id) {
|
||||||
Hook hook = getHook(id);
|
Hook hook = getHook(id);
|
||||||
if (hook == null) return false;
|
if (hook == null) return false;
|
||||||
return hook.getActive();
|
return hook.isActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||||
|
|
||||||
|
import com.denizenscript.denizen.objects.ItemTag;
|
||||||
|
import com.denizenscript.denizencore.utilities.CoreUtilities;
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.denizenscript.denizen.Denizen Denizen} to provide custom items
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class HookDenizen extends Hook {
|
||||||
|
public HookDenizen() {
|
||||||
|
super("denizen");
|
||||||
|
setEnabledItemHook(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.denizenscript.denizen.Denizen Denizen}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
|
ItemTag item = ItemTag.valueOf(itemId, CoreUtilities.noDebugContext);
|
||||||
|
return item == null ? null : item.getItemStack();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
import com.mineinabyss.geary.addons.GearyPhase;
|
||||||
|
import com.mineinabyss.geary.modules.GearyModuleKt;
|
||||||
|
import com.mineinabyss.geary.papermc.tracking.items.ItemTrackingKt;
|
||||||
|
import com.mineinabyss.geary.prefabs.PrefabKey;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class HookGeary extends Hook {
|
||||||
|
private boolean enabled = false;
|
||||||
|
|
||||||
|
public HookGeary() {
|
||||||
|
super("geary");
|
||||||
|
setEnabledItemHook(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load() {
|
||||||
|
GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.ENABLE, () -> {
|
||||||
|
enabled = true;
|
||||||
|
HMCCosmeticsPlugin.setup();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
|
if (enabled) {
|
||||||
|
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||||
|
if (prefabKey == null) return null;
|
||||||
|
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
|
||||||
|
} else return new ItemStack(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,19 +3,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookHMCCosmetics extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin HMCCosmetics} to provide cosmetic items
|
||||||
|
*/
|
||||||
|
public class HookHMCCosmetics extends Hook {
|
||||||
public HookHMCCosmetics() {
|
public HookHMCCosmetics() {
|
||||||
super("HMCCosmetics");
|
super("HMCCosmetics");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin HMCCosmetics}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemid) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(itemid);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(itemId);
|
||||||
if (cosmetic == null) return null;
|
if (cosmetic == null) return null;
|
||||||
return cosmetic.getItem();
|
return cosmetic.getItem();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import dev.lone.itemsadder.api.CustomStack;
|
import dev.lone.itemsadder.api.CustomStack;
|
||||||
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookItemAdder extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} to provide custom items
|
||||||
// I hate IA, this overcomplicate stuff is so unneeded if it just did its stuff when its needed.
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class HookItemAdder extends Hook {
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
||||||
public HookItemAdder() {
|
public HookItemAdder() {
|
||||||
@@ -20,10 +22,13 @@ public class HookItemAdder extends Hook implements Listener {
|
|||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemid) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
CustomStack stack = CustomStack.getInstance(itemid);
|
CustomStack stack = CustomStack.getInstance(itemId);
|
||||||
if (stack == null) return null;
|
if (stack == null) return null;
|
||||||
return stack.getItemStack();
|
return stack.getItemStack();
|
||||||
} else {
|
} else {
|
||||||
@@ -33,7 +38,8 @@ public class HookItemAdder extends Hook implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
||||||
if (enabled) return; // Only run on the first event fired; ignore all rest
|
// By default, it will only run once at startup, if hook setting is enabled
|
||||||
|
if (enabled && !Settings.getItemsAdderReloadChange()) return;
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
HMCCosmeticsPlugin.setup();
|
HMCCosmeticsPlugin.setup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
|
||||||
import com.mineinabyss.geary.prefabs.PrefabKey;
|
|
||||||
import com.mineinabyss.looty.LootyFactory;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class HookLooty extends Hook implements Listener {
|
|
||||||
|
|
||||||
public HookLooty() {
|
|
||||||
super("looty");
|
|
||||||
setEnabledItemHook(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getItem(String itemid) {
|
|
||||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemid);
|
|
||||||
if (prefabKey == null) return null;
|
|
||||||
return LootyFactory.INSTANCE.createFromPrefab(prefabKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,17 +2,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import io.lumine.mythic.bukkit.MythicBukkit;
|
import io.lumine.mythic.bukkit.MythicBukkit;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookMythic extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} to provide custom items
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class HookMythic extends Hook {
|
||||||
public HookMythic() {
|
public HookMythic() {
|
||||||
super("mythicmobs");
|
super("mythicmobs");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemid) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
return MythicBukkit.inst().getItemManager().getItemStack(itemid);
|
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,25 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import io.th0rgal.oraxen.api.OraxenItems;
|
import io.th0rgal.oraxen.api.OraxenItems;
|
||||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookOraxen extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} to provide custom items
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
|
public class HookOraxen extends Hook {
|
||||||
public HookOraxen() {
|
public HookOraxen() {
|
||||||
super("oraxen");
|
super("oraxen");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemid) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
ItemBuilder builder = OraxenItems.getItemById(itemid);
|
ItemBuilder builder = OraxenItems.getItemById(itemId);
|
||||||
if (builder == null) return null;
|
if (builder == null) return null;
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||||
|
|
||||||
|
import com.Zrips.CMI.events.CMIPlayerUnVanishEvent;
|
||||||
|
import com.Zrips.CMI.events.CMIPlayerVanishEvent;
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.Zrips.CMI.CMI CMI}
|
||||||
|
*/
|
||||||
|
public class HookCMI extends Hook {
|
||||||
|
public HookCMI() {
|
||||||
|
super("CMI");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerVanish(@NotNull CMIPlayerVanishEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerShow(@NotNull CMIPlayerUnVanishEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.hibiscusmc.hmccolor.HMCColor HMCColor}
|
||||||
|
*/
|
||||||
|
public class HookHMCColor extends Hook {
|
||||||
|
public HookHMCColor() {
|
||||||
|
super("HMCColor");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import me.libraryaddict.disguise.events.DisguiseEvent;
|
||||||
|
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class HookLibsDisguises extends Hook {
|
||||||
|
public HookLibsDisguises() {
|
||||||
|
super("LibsDisguises");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerVanish(@NotNull DisguiseEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof Player player)) return;
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerShow(@NotNull UndisguiseEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof Player player)) return;
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
|
||||||
|
public class HookModelEngine extends Hook {
|
||||||
|
|
||||||
|
public HookModelEngine() {
|
||||||
|
super("ModelEngine");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,18 +7,20 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
|
|||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookPremiumVanish extends Hook implements Listener {
|
|
||||||
|
|
||||||
// NOTE: Supervanish and Premium Vanish both use the same api
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||||
|
*
|
||||||
|
* @implSpec Supervanish and Premium Vanish both use the same api
|
||||||
|
*/
|
||||||
|
public class HookPremiumVanish extends Hook {
|
||||||
public HookPremiumVanish() {
|
public HookPremiumVanish() {
|
||||||
super("PremiumVanish");
|
super("PremiumVanish");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerVanish(PlayerHideEvent event) {
|
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
@@ -26,11 +28,10 @@ public class HookPremiumVanish extends Hook implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerShow(PlayerShowEvent event) {
|
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,18 +7,20 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
|
|||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookSuperVanish extends Hook implements Listener {
|
|
||||||
|
|
||||||
// NOTE: Supervanish and Premium Vanish both use the same api
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||||
|
*
|
||||||
|
* @implSpec Supervanish and Premium Vanish both use the same api
|
||||||
|
*/
|
||||||
|
public class HookSuperVanish extends Hook {
|
||||||
public HookSuperVanish() {
|
public HookSuperVanish() {
|
||||||
super("SuperVanish");
|
super("SuperVanish");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerVanish(PlayerHideEvent event) {
|
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
@@ -26,7 +28,7 @@ public class HookSuperVanish extends Hook implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerShow(PlayerShowEvent event) {
|
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|||||||
@@ -6,18 +6,23 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPIPlugin PlaceholderAPIPlugin}
|
||||||
|
*/
|
||||||
public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||||
|
|
||||||
private static boolean papiEnabled = false;
|
private static boolean papiEnabled = false;
|
||||||
|
|
||||||
public HMCPlaceholderExpansion() {
|
public HMCPlaceholderExpansion() {
|
||||||
@@ -25,22 +30,30 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIdentifier() {
|
@NotNull
|
||||||
|
public String getIdentifier() {
|
||||||
return "HMCCosmetics";
|
return "HMCCosmetics";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getAuthor() {
|
@NotNull
|
||||||
|
public String getAuthor() {
|
||||||
return "HibiscusMC";
|
return "HibiscusMC";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getVersion() {
|
@NotNull
|
||||||
|
public String getVersion() {
|
||||||
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
|
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onRequest(OfflinePlayer player, String params) {
|
public boolean persist() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
||||||
if (!player.isOnline()) return null;
|
if (!player.isOnline()) return null;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
|
||||||
if (user == null) return null;
|
if (user == null) return null;
|
||||||
@@ -54,10 +67,11 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
}
|
}
|
||||||
if (placeholderArgs.get(1) != null) {
|
if (placeholderArgs.get(1) != null) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
|
if (cosmetic == null) return "INVALID_COSMETIC";
|
||||||
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
||||||
if (cosmetic == null || currentCosmetic == null) return "false";
|
if (currentCosmetic == null) return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false)); // I hate this way of handling translations
|
||||||
if (currentCosmetic.getId() == cosmetic.getId()) return "true";
|
if (currentCosmetic.getId() == cosmetic.getId()) return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(true));
|
||||||
return "false";
|
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
||||||
}
|
}
|
||||||
case "current":
|
case "current":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs == null) {
|
||||||
@@ -68,26 +82,29 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
if (slot == null) return null;
|
if (slot == null) return null;
|
||||||
if (user.getCosmetic(slot) == null) return null;
|
if (user.getCosmetic(slot) == null) return null;
|
||||||
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
||||||
|
|
||||||
|
String output;
|
||||||
switch (placeholderArgs.get(2).toLowerCase()) {
|
switch (placeholderArgs.get(2).toLowerCase()) {
|
||||||
case "material" -> {
|
case "material" -> {
|
||||||
return getMaterial(user.getCosmetic(slot));
|
output = getMaterialName(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "custommodeldata" -> {
|
case "custommodeldata" -> {
|
||||||
return getModelData(user.getCosmetic(slot));
|
output = getModelData(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "name" -> {
|
case "name" -> {
|
||||||
return getItemName(user.getCosmetic(slot));
|
output = getItemName(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "lore" -> {
|
case "lore" -> {
|
||||||
return getItemLore(user.getCosmetic(slot));
|
output = getItemLore(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "permission" -> {
|
case "permission" -> {
|
||||||
return user.getCosmetic(slot).getPermission();
|
output = user.getCosmetic(slot).getPermission();
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
return user.getCosmetic(slot).getId();
|
output = user.getCosmetic(slot).getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TranslationUtil.getTranslation("current-cosmetic", String.valueOf(output));
|
||||||
}
|
}
|
||||||
case "unlocked":
|
case "unlocked":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs == null) {
|
||||||
@@ -96,69 +113,124 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
if (placeholderArgs.get(1) != null) {
|
if (placeholderArgs.get(1) != null) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
if (placeholderArgs.size() >= 3) {
|
||||||
if (secondAttemptCosmetic == null) {
|
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
||||||
return "INVALID_COSMETIC";
|
if (secondAttemptCosmetic == null) {
|
||||||
|
return "INVALID_COSMETIC";
|
||||||
|
} else {
|
||||||
|
cosmetic = secondAttemptCosmetic;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cosmetic = secondAttemptCosmetic;
|
return "INVALID_COSMETIC";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TranslationUtil.getTranslation("unlockedCosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
|
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
|
||||||
}
|
}
|
||||||
case "equipped":
|
case "equipped":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (placeholderArgs.get(1) != null) {
|
if (placeholderArgs.get(1) != null) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
String args1 = placeholderArgs.get(1);
|
||||||
|
|
||||||
|
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||||
|
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null));
|
||||||
|
}
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages(args1);
|
||||||
|
|
||||||
|
Cosmetic cosmetic = Cosmetics.getCosmetic(args1);
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
if (placeholderArgs.size() == 3) {
|
||||||
if (secondAttemptCosmetic == null) {
|
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
||||||
return "INVALID_COSMETIC";
|
if (secondAttemptCosmetic == null) {
|
||||||
|
return "INVALID_COSMETIC";
|
||||||
|
} else {
|
||||||
|
cosmetic = secondAttemptCosmetic;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cosmetic = secondAttemptCosmetic;
|
return "INVALID_COSMETIC";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
|
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
|
||||||
if (cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()) {
|
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()));
|
||||||
return "true";
|
|
||||||
} else {
|
|
||||||
return "false";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case "wardrobe-enabled":
|
case "wardrobe-enabled":
|
||||||
return String.valueOf(user.isInWardrobe());
|
return TranslationUtil.getTranslation("in-wardrobe", String.valueOf(user.isInWardrobe()));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMaterial(Cosmetic cosmetic) {
|
/**
|
||||||
|
* Gets the name of the cosmetic item {@link org.bukkit.Material Material}
|
||||||
|
* @param cosmetic The cosmetic to get its {@link org.bukkit.Material Material}s name
|
||||||
|
* @return The name of the cosmetic item {@link org.bukkit.Material Material}
|
||||||
|
* @deprecated As of release 2.2.5+, use {@link #getMaterialName(Cosmetic)} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Nullable
|
||||||
|
public String getMaterial(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
return cosmetic.getItem().getType().toString();
|
return item.getType().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModelData(Cosmetic cosmetic) {
|
/**
|
||||||
|
* Gets the name of the cosmetic item {@link org.bukkit.Material Material}
|
||||||
|
* @param cosmetic The cosmetic to get its {@link org.bukkit.Material Material}s name
|
||||||
|
* @return The name of the cosmetic item {@link org.bukkit.Material Material}
|
||||||
|
* @since 2.2.5
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getMaterialName(@NotNull Cosmetic cosmetic) {
|
||||||
|
ItemStack item = cosmetic.getItem();
|
||||||
|
if (item == null) return null;
|
||||||
|
return item.getType().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cosmetic items custom model data
|
||||||
|
* @param cosmetic The cosmetic to get its custom model data
|
||||||
|
* @return The cosmetic items custom model data
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getModelData(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta == null) return null;
|
||||||
return String.valueOf(itemMeta.getCustomModelData());
|
return String.valueOf(itemMeta.getCustomModelData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItemName(Cosmetic cosmetic) {
|
/**
|
||||||
|
* Gets the cosmetic items display name
|
||||||
|
* @param cosmetic The cosmetic to get its items display name
|
||||||
|
* @return The cosmetic items display name
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getItemName(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta == null) return null;
|
||||||
return itemMeta.getDisplayName();
|
return itemMeta.getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItemLore(Cosmetic cosmetic) {
|
/**
|
||||||
|
* Gets the cosmetic items lore
|
||||||
|
* @param cosmetic The cosmetic to get its items lore
|
||||||
|
* @return The cosmetic items lore
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getItemLore(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
return String.valueOf(item.getItemMeta().getLore());
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta == null) return null;
|
||||||
|
return String.valueOf(itemMeta.getLore());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ package com.hibiscusmc.hmccosmetics.hooks.placeholders;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPI PlaceholderAPI}
|
||||||
|
*/
|
||||||
public class HookPlaceholderAPI extends Hook {
|
public class HookPlaceholderAPI extends Hook {
|
||||||
|
|
||||||
public HookPlaceholderAPI() {
|
public HookPlaceholderAPI() {
|
||||||
super("PlaceholderAPI");
|
super("PlaceholderAPI");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers HMCCosmetics Placeholder Expansion
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
new HMCPlaceholderExpansion().register();
|
new HMCPlaceholderExpansion().register();
|
||||||
|
|||||||
@@ -4,24 +4,39 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
|
import com.sk89q.worldguard.protection.flags.StringFlag;
|
||||||
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
|
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
|
||||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.sk89q.worldguard.WorldGuard WorldGuard}
|
||||||
|
*/
|
||||||
public class WGHook {
|
public class WGHook {
|
||||||
|
/**
|
||||||
|
* @implNote Please use {@link #getCosmeticEnableFlag()} instead
|
||||||
|
*/
|
||||||
|
private static StateFlag COSMETIC_ENABLE_FLAG;
|
||||||
|
|
||||||
public static StateFlag COSMETIC_ENABLE_FLAG;
|
private static StateFlag EMOTES_ENABLE_FLAG;
|
||||||
public static StateFlag COSMETIC_WARDROBE_FLAG;
|
|
||||||
|
/**
|
||||||
|
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
|
||||||
|
*/
|
||||||
|
private static StringFlag COSMETIC_WARDROBE_FLAG;
|
||||||
|
|
||||||
public WGHook() {
|
public WGHook() {
|
||||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||||
try {
|
try {
|
||||||
StateFlag cosmeticFlag = new StateFlag("cosmetic-enable", false);
|
StateFlag cosmeticFlag = new StateFlag("cosmetic-enable", false);
|
||||||
StateFlag wardrobeFlag = new StateFlag("cosmetic-wardrobe", false);
|
StateFlag emoteFlag = new StateFlag("emotes-enable", false);
|
||||||
|
StringFlag wardrobeFlag = new StringFlag("cosmetic-wardrobe");
|
||||||
registry.register(cosmeticFlag);
|
registry.register(cosmeticFlag);
|
||||||
|
registry.register(emoteFlag);
|
||||||
registry.register(wardrobeFlag);
|
registry.register(wardrobeFlag);
|
||||||
COSMETIC_ENABLE_FLAG = cosmeticFlag;
|
COSMETIC_ENABLE_FLAG = cosmeticFlag;
|
||||||
|
EMOTES_ENABLE_FLAG = emoteFlag;
|
||||||
COSMETIC_WARDROBE_FLAG = wardrobeFlag;
|
COSMETIC_WARDROBE_FLAG = wardrobeFlag;
|
||||||
} catch (FlagConflictException e) {
|
} catch (FlagConflictException e) {
|
||||||
Flag<?> existing = registry.get("cosmetic-enable");
|
Flag<?> existing = registry.get("cosmetic-enable");
|
||||||
@@ -35,11 +50,27 @@ public class WGHook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cosmetic enable {@link StateFlag}
|
||||||
|
* @return The cosmetic enable {@link StateFlag}
|
||||||
|
*/
|
||||||
public static StateFlag getCosmeticEnableFlag() {
|
public static StateFlag getCosmeticEnableFlag() {
|
||||||
return COSMETIC_ENABLE_FLAG;
|
return COSMETIC_ENABLE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StateFlag getCosmeticWardrobeFlag() {
|
/**
|
||||||
|
* Gets the emotes enable {@link StateFlag}
|
||||||
|
* @return The emotes enable {@link StateFlag}
|
||||||
|
*/
|
||||||
|
public static StateFlag getEmotesEnableFlag() {
|
||||||
|
return EMOTES_ENABLE_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cosmetic wardrobe {@link StateFlag}
|
||||||
|
* @return The cosmetic wardrobe {@link StateFlag}
|
||||||
|
*/
|
||||||
|
public static StringFlag getCosmeticWardrobeFlag() {
|
||||||
return COSMETIC_WARDROBE_FLAG;
|
return COSMETIC_WARDROBE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
@@ -9,21 +12,23 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|||||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains {@link com.sk89q.worldguard.WorldGuard WorldGuard} related event listeners
|
||||||
|
*/
|
||||||
public class WGListener implements Listener {
|
public class WGListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
Location location = event.getPlayer().getLocation();
|
Location location = event.getPlayer().getLocation();
|
||||||
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
ApplicableRegionSet set = getRegions(location);
|
||||||
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
|
||||||
RegionQuery query = region.createQuery();
|
|
||||||
ApplicableRegionSet set = query.getApplicableRegions(loc);
|
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
@@ -31,12 +36,70 @@ public class WGListener implements Listener {
|
|||||||
}
|
}
|
||||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||||
|
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||||
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD) user.showCosmetics();
|
||||||
|
return;
|
||||||
|
}
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||||
user.enterWardrobe();
|
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
|
||||||
|
Wardrobe wardrobe = WardrobeSettings.getWardrobe(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString());
|
||||||
|
user.enterWardrobe(true, wardrobe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
|
if (user == null) return;
|
||||||
|
Location location = event.getTo();
|
||||||
|
ApplicableRegionSet set = getRegions(location);
|
||||||
|
if (user.getHidden()) {
|
||||||
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||||
|
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||||
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD) user.showCosmetics();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||||
|
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
|
||||||
|
Wardrobe wardrobe = WardrobeSettings.getWardrobe(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString());
|
||||||
|
user.enterWardrobe(true, wardrobe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerEmote(PlayerEmoteStartEvent event) {
|
||||||
|
Player player = event.getUser().getPlayer();
|
||||||
|
if (player == null) return;
|
||||||
|
Location location = player.getLocation();
|
||||||
|
ApplicableRegionSet set = getRegions(location);
|
||||||
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
|
if (protectedRegion.getFlags().containsKey(WGHook.getEmotesEnableFlag())) {
|
||||||
|
if (protectedRegion.getFlags().get(WGHook.getEmotesEnableFlag()).toString().equalsIgnoreCase("DENY")) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicableRegionSet getRegions(Location location) {
|
||||||
|
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
||||||
|
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
RegionQuery query = region.createQuery();
|
||||||
|
return query.getApplicableRegions(loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
|||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -13,11 +14,12 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerConnectionListener implements Listener {
|
public class PlayerConnectionListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(@NotNull PlayerJoinEvent event) {
|
||||||
if (event.getPlayer().isOp() || event.getPlayer().hasPermission("hmccosmetics.notifyupdate")) {
|
if (event.getPlayer().isOp() || event.getPlayer().hasPermission("hmccosmetics.notifyupdate")) {
|
||||||
if (!HMCCosmeticsPlugin.getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getLatestVersion() != null)
|
if (!HMCCosmeticsPlugin.getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getLatestVersion() != null)
|
||||||
MessagesUtil.sendMessageNoKey(
|
MessagesUtil.sendMessageNoKey(
|
||||||
@@ -46,7 +48,7 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(@NotNull PlayerQuitEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) { // Remove any passengers if a user failed to initialize. Bugs can cause this to happen
|
if (user == null) { // Remove any passengers if a user failed to initialize. Bugs can cause this to happen
|
||||||
if (!event.getPlayer().getPassengers().isEmpty()) {
|
if (!event.getPlayer().getPassengers().isEmpty()) {
|
||||||
@@ -56,10 +58,11 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
user.getUserEmoteManager().stopEmote();
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
||||||
event.getPlayer().setInvisible(false);
|
event.getPlayer().setInvisible(false);
|
||||||
}
|
}
|
||||||
Database.save(user);
|
Database.save(user);
|
||||||
|
|||||||
@@ -9,32 +9,34 @@ import com.comphenix.protocol.events.PacketEvent;
|
|||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
import com.comphenix.protocol.wrappers.Pair;
|
import com.comphenix.protocol.wrappers.Pair;
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerCosmeticPostEquipEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Pose;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
|
||||||
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
@@ -53,6 +55,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
registerMenuChangeListener();
|
registerMenuChangeListener();
|
||||||
registerPlayerEquipmentListener();
|
registerPlayerEquipmentListener();
|
||||||
registerPlayerArmListener();
|
registerPlayerArmListener();
|
||||||
|
registerEntityUseListener();
|
||||||
|
|
||||||
//registerLookMovement();
|
//registerLookMovement();
|
||||||
//registerMoveListener();
|
//registerMoveListener();
|
||||||
@@ -61,12 +64,20 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerClick(@NotNull InventoryClickEvent event) {
|
public void onPlayerClick(@NotNull InventoryClickEvent event) {
|
||||||
if (event.getClick() != ClickType.SHIFT_LEFT && event.getClick() != ClickType.SHIFT_RIGHT) return;
|
// || !event.getClickedInventory().getType().equals(InventoryType.PLAYER)
|
||||||
|
if (event.getClick().isShiftClick()) return;
|
||||||
|
MessagesUtil.sendDebugMessages("inventoryclickevent");
|
||||||
//if (event.getSlotType() != InventoryType.SlotType.ARMOR) return;
|
//if (event.getSlotType() != InventoryType.SlotType.ARMOR) return;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getWhoClicked().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getWhoClicked().getUniqueId());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
ItemStack item = event.getCurrentItem();
|
ItemStack item = event.getCurrentItem();
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
|
|
||||||
|
if (Settings.isDestroyLooseCosmetics() && InventoryUtils.isCosmeticItem(event.getCurrentItem())) {
|
||||||
|
MessagesUtil.sendDebugMessages("remvoe item");
|
||||||
|
event.getWhoClicked().getInventory().removeItem(event.getCurrentItem());
|
||||||
|
}
|
||||||
|
|
||||||
EquipmentSlot slot = getArmorSlot(item.getType());
|
EquipmentSlot slot = getArmorSlot(item.getType());
|
||||||
if (slot == null) return;
|
if (slot == null) return;
|
||||||
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
||||||
@@ -84,7 +95,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (event.isSneaking()) {
|
if (event.isSneaking()) {
|
||||||
user.getUserEmoteManager().stopEmote();
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.SNEAK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.isSneaking()) return;
|
if (!event.isSneaking()) return;
|
||||||
@@ -103,24 +114,23 @@ public class PlayerGameListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.isInWardrobe()) {
|
||||||
user.getUserBackpackManager().hideBackpack();
|
user.leaveWardrobe();
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorstand().teleport(event.getTo());
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
user.updateCosmetic();
|
|
||||||
}, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||||
|
user.respawnBackpack();
|
||||||
|
}
|
||||||
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
|
user.respawnBalloon();
|
||||||
|
}
|
||||||
|
user.updateCosmetic();
|
||||||
|
}, 1);
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
||||||
final CosmeticBalloonType cosmeticBalloonType = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
user.despawnBalloon();
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
user.spawnBalloon(cosmeticBalloonType);
|
|
||||||
}, 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,14 +144,14 @@ public class PlayerGameListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Cosmetic cosmetic = user.getCosmetic(CosmeticSlot.BALLOON);
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
final Color color = user.getCosmeticColor(CosmeticSlot.BALLOON);
|
user.despawnBalloon();
|
||||||
user.removeCosmeticSlot(CosmeticSlot.BALLOON);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
user.addPlayerCosmetic(cosmetic, color);
|
user.spawnBalloon((CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON));
|
||||||
user.updateCosmetic();
|
user.updateCosmetic();
|
||||||
}, 4);
|
}, 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -154,17 +164,67 @@ public class PlayerGameListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDamaged(EntityDamageEvent event) {
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
Player player = ((Player) event.getEntity()).getPlayer();
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
if (Settings.isEmoteInvincible()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (Settings.isEmoteDamageLeave()) {
|
||||||
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.DAMAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (user.isInWardrobe()) {
|
||||||
|
user.leaveWardrobe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerLook(PlayerMoveEvent event) {
|
public void onPlayerLook(PlayerMoveEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
Player player = event.getPlayer();
|
||||||
// TODO: Move to packets
|
// TODO: Move to packets
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
// Really need to look into optimization of this
|
// Really need to look into optimization of this
|
||||||
user.updateCosmetic(CosmeticSlot.BACKPACK);
|
user.updateCosmetic(CosmeticSlot.BACKPACK);
|
||||||
user.updateCosmetic(CosmeticSlot.BALLOON);
|
user.updateCosmetic(CosmeticSlot.BALLOON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerPoseChange(EntityPoseChangeEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
Player player = ((Player) event.getEntity()).getPlayer();
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||||
|
Pose pose = event.getPose();
|
||||||
|
if (pose.equals(Pose.STANDING)) {
|
||||||
|
// #84, Riptides mess with backpacks
|
||||||
|
ItemStack currentItem = player.getInventory().getItemInMainHand();
|
||||||
|
if (currentItem != null) {
|
||||||
|
if (currentItem.hasItemMeta()) {
|
||||||
|
if (currentItem.containsEnchantment(Enchantment.RIPTIDE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user.isBackpackSpawned()) {
|
||||||
|
user.spawnBackpack((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pose.equals(Pose.SLEEPING) || pose.equals(Pose.SWIMMING) || pose.equals(Pose.FALL_FLYING) || pose.equals(Pose.SPIN_ATTACK)) {
|
||||||
|
user.despawnBackpack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerArmorDamage(PlayerItemDamageEvent event) {
|
public void onPlayerArmorDamage(PlayerItemDamageEvent event) {
|
||||||
// Possibly look into cancelling the event, then handling the damage on our own.
|
// Possibly look into cancelling the event, then handling the damage on our own.
|
||||||
@@ -252,6 +312,14 @@ public class PlayerGameListener implements Listener {
|
|||||||
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
||||||
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
||||||
}, 2);
|
}, 2);
|
||||||
|
|
||||||
|
// #84, Riptides mess with backpacks
|
||||||
|
ItemStack currentItem = event.getPlayer().getInventory().getItem(event.getNewSlot());
|
||||||
|
if (currentItem == null) return;
|
||||||
|
if (!currentItem.hasItemMeta()) return;
|
||||||
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && currentItem.containsEnchantment(Enchantment.RIPTIDE)) {
|
||||||
|
user.despawnBackpack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -259,11 +327,37 @@ public class PlayerGameListener implements Listener {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(event.getEntity());
|
CosmeticUser user = CosmeticUsers.getUser(event.getEntity());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
|
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||||
|
|
||||||
if (Settings.getUnapplyOnDeath() && !event.getEntity().hasPermission("hmccosmetics.unapplydeath.bypass")) {
|
if (Settings.getUnapplyOnDeath() && !event.getEntity().hasPermission("hmccosmetics.unapplydeath.bypass")) {
|
||||||
user.removeCosmetics();
|
user.removeCosmetics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerGamemodeSwitch(PlayerGameModeChangeEvent event) {
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
|
if (user == null) return;
|
||||||
|
|
||||||
|
if (Settings.isDestroyLooseCosmetics()) {
|
||||||
|
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
|
||||||
|
if (equippedArmor.length == 0) return;
|
||||||
|
for (ItemStack armor : equippedArmor) {
|
||||||
|
if (InventoryUtils.isCosmeticItem(armor)) armor.setAmount(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerCosemticEquip(PlayerCosmeticPostEquipEvent event) {
|
||||||
|
CosmeticUser user = event.getUser();
|
||||||
|
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
||||||
|
Location NPCLocation = user.getWardrobeManager().getNpcLocation();
|
||||||
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(Settings.getBalloonOffset()), false, List.of(event.getUser().getPlayer()));
|
||||||
|
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(Settings.getBalloonOffset()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void registerInventoryClickListener() {
|
private void registerInventoryClickListener() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||||
@Override
|
@Override
|
||||||
@@ -307,7 +401,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<>();
|
HashMap<Integer, ItemStack> items = new HashMap<>();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
||||||
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
||||||
}
|
}
|
||||||
@@ -375,6 +469,10 @@ public class PlayerGameListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!user.isInWardrobe()) return;
|
if (!user.isInWardrobe()) return;
|
||||||
Menu menu = Menus.getDefaultMenu();
|
Menu menu = Menus.getDefaultMenu();
|
||||||
if (menu == null) return;
|
if (menu == null) return;
|
||||||
@@ -384,6 +482,21 @@ public class PlayerGameListener implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerEntityUseListener() {
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
|
if (!(event.getPlayer() instanceof Player)) return;
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void registerLookMovement() {
|
private void registerLookMovement() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.LOOK) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.LOOK) {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.hibiscusmc.hmccosmetics.nms;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -19,12 +19,14 @@ public interface NMSHandler {
|
|||||||
|
|
||||||
Entity getEntity(int entityId);
|
Entity getEntity(int entityId);
|
||||||
|
|
||||||
Entity getInvisibleArmorstand(Location loc);
|
Entity getHMCArmorStand(Location loc);
|
||||||
|
|
||||||
ArmorStand getMEGEntity(Location loc);
|
ArmorStand getMEGEntity(Location loc);
|
||||||
|
|
||||||
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
||||||
|
|
||||||
|
Entity spawnDisplayEntity(Location location, String text);
|
||||||
|
|
||||||
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
||||||
|
|
||||||
void equipmentSlotUpdate(
|
void equipmentSlotUpdate(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class NMSHandlers {
|
public class NMSHandlers {
|
||||||
|
|
||||||
private static final String[] SUPPORTED_VERSION = new String[]{"v1_17_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2"};
|
private static final String[] SUPPORTED_VERSION = new String[]{"v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1"};
|
||||||
private static NMSHandler handler;
|
private static NMSHandler handler;
|
||||||
private static String version;
|
private static String version;
|
||||||
|
|
||||||
@@ -37,7 +37,6 @@ public class NMSHandlers {
|
|||||||
MessagesUtil.sendDebugMessages(packageVersion + " has been detected.", Level.INFO);
|
MessagesUtil.sendDebugMessages(packageVersion + " has been detected.", Level.INFO);
|
||||||
version = packageVersion;
|
version = packageVersion;
|
||||||
try {
|
try {
|
||||||
//Class.forName("org.bukkit.craftbukkit." + version + ".block.CraftBlock").getName();
|
|
||||||
handler = (NMSHandler) Class.forName("com.hibiscusmc.hmccosmetics.nms." + packageVersion + ".NMSHandler").getConstructor().newInstance();
|
handler = (NMSHandler) Class.forName("com.hibiscusmc.hmccosmetics.nms." + packageVersion + ".NMSHandler").getConstructor().newInstance();
|
||||||
return;
|
return;
|
||||||
} catch (ClassNotFoundException | InvocationTargetException | InstantiationException |
|
} catch (ClassNotFoundException | InvocationTargetException | InstantiationException |
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user;
|
package com.hibiscusmc.hmccosmetics.user;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableCollection;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.api.*;
|
import com.hibiscusmc.hmccosmetics.api.events.*;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
@@ -18,19 +25,21 @@ import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
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.*;
|
import org.bukkit.inventory.meta.*;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CosmeticUser {
|
public class CosmeticUser {
|
||||||
|
|
||||||
private UUID uniqueId;
|
private final UUID uniqueId;
|
||||||
private int taskId;
|
private int taskId;
|
||||||
private HashMap<CosmeticSlot, Cosmetic> playerCosmetics = new HashMap<>();
|
private HashMap<CosmeticSlot, Cosmetic> playerCosmetics = new HashMap<>();
|
||||||
private UserWardrobeManager userWardrobeManager;
|
private UserWardrobeManager userWardrobeManager;
|
||||||
@@ -52,8 +61,9 @@ public class CosmeticUser {
|
|||||||
private void tick() {
|
private void tick() {
|
||||||
// Occasionally updates the entity cosmetics
|
// Occasionally updates the entity cosmetics
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
MessagesUtil.sendDebugMessages("tick " + uniqueId, Level.INFO);
|
MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO);
|
||||||
updateCosmetic();
|
updateCosmetic();
|
||||||
|
if (getHidden() && !getUserEmoteManager().isPlayingEmote()) MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
||||||
};
|
};
|
||||||
|
|
||||||
int tickPeriod = Settings.getTickPeriod();
|
int tickPeriod = Settings.getTickPeriod();
|
||||||
@@ -77,10 +87,15 @@ public class CosmeticUser {
|
|||||||
return playerCosmetics.get(slot);
|
return playerCosmetics.get(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Collection<Cosmetic> getCosmetic() {
|
public Collection<Cosmetic> getCosmetic() {
|
||||||
return playerCosmetics.values();
|
return playerCosmetics.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImmutableCollection<Cosmetic> getCosmetics() {
|
||||||
|
return ImmutableList.copyOf(playerCosmetics.values());
|
||||||
|
}
|
||||||
|
|
||||||
public void addPlayerCosmetic(Cosmetic cosmetic) {
|
public void addPlayerCosmetic(Cosmetic cosmetic) {
|
||||||
addPlayerCosmetic(cosmetic, null);
|
addPlayerCosmetic(cosmetic, null);
|
||||||
}
|
}
|
||||||
@@ -100,16 +115,19 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
playerCosmetics.put(cosmetic.getSlot(), cosmetic);
|
playerCosmetics.put(cosmetic.getSlot(), cosmetic);
|
||||||
if (color != null) colors.put(cosmetic.getSlot(), color);
|
if (color != null) colors.put(cosmetic.getSlot(), color);
|
||||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic " + cosmetic.getId());
|
MessagesUtil.sendDebugMessages("addPlayerCosmetic[id=" + cosmetic.getId() + "]");
|
||||||
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
|
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
|
||||||
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
|
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
|
||||||
spawnBackpack(backpackType);
|
spawnBackpack(backpackType);
|
||||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic spawnBackpack " + cosmetic.getId());
|
MessagesUtil.sendDebugMessages("addPlayerCosmetic[spawnBackpack,id=" + cosmetic.getId() + "]");
|
||||||
}
|
}
|
||||||
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
|
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
|
||||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||||
spawnBalloon(balloonType);
|
spawnBalloon(balloonType);
|
||||||
}
|
}
|
||||||
|
// API
|
||||||
|
PlayerCosmeticPostEquipEvent postEquipEvent = new PlayerCosmeticPostEquipEvent(this, cosmetic);
|
||||||
|
Bukkit.getPluginManager().callEvent(postEquipEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCosmetics() {
|
public void removeCosmetics() {
|
||||||
@@ -135,7 +153,7 @@ public class CosmeticUser {
|
|||||||
despawnBalloon();
|
despawnBalloon();
|
||||||
}
|
}
|
||||||
if (slot == CosmeticSlot.EMOTE) {
|
if (slot == CosmeticSlot.EMOTE) {
|
||||||
|
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
|
||||||
}
|
}
|
||||||
colors.remove(slot);
|
colors.remove(slot);
|
||||||
playerCosmetics.remove(slot);
|
playerCosmetics.remove(slot);
|
||||||
@@ -151,6 +169,15 @@ public class CosmeticUser {
|
|||||||
return playerCosmetics.containsKey(slot);
|
return playerCosmetics.containsKey(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasCosmeticInSlot(Cosmetic cosmetic) {
|
||||||
|
if (getCosmetic(cosmetic.getSlot()) == null) return false;
|
||||||
|
return Objects.equals(cosmetic.getId(), getCosmetic(cosmetic.getSlot()).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<CosmeticSlot> getSlotsWithCosmetics() {
|
||||||
|
return Set.copyOf(playerCosmetics.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
public void updateCosmetic(CosmeticSlot slot) {
|
public void updateCosmetic(CosmeticSlot slot) {
|
||||||
if (getCosmetic(slot) == null) {
|
if (getCosmetic(slot) == null) {
|
||||||
return;
|
return;
|
||||||
@@ -164,7 +191,7 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateCosmetic() {
|
public void updateCosmetic() {
|
||||||
for (Cosmetic cosmetic : playerCosmetics.values()) {
|
for (Cosmetic cosmetic : getCosmetics()) {
|
||||||
updateCosmetic(cosmetic.getSlot());
|
updateCosmetic(cosmetic.getSlot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,6 +218,43 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
|
||||||
|
if (item.getType() == Material.PLAYER_HEAD) {
|
||||||
|
SkullMeta skullMeta = (SkullMeta) itemMeta;
|
||||||
|
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullOwner(), PersistentDataType.STRING)) {
|
||||||
|
String owner = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullOwner(), PersistentDataType.STRING);
|
||||||
|
|
||||||
|
owner = Hooks.processPlaceholders(getPlayer(), owner);
|
||||||
|
|
||||||
|
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(owner));
|
||||||
|
//skullMeta.getPersistentDataContainer().remove(InventoryUtils.getSkullOwner()); // Don't really need this?
|
||||||
|
}
|
||||||
|
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullTexture(), PersistentDataType.STRING)) {
|
||||||
|
String texture = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullTexture(), PersistentDataType.STRING);
|
||||||
|
|
||||||
|
texture = Hooks.processPlaceholders(getPlayer(), texture);
|
||||||
|
|
||||||
|
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
|
||||||
|
+ texture + "\"}]}}}");
|
||||||
|
//skullMeta.getPersistentDataContainer().remove(InventoryUtils.getSkullTexture()); // Don't really need this?
|
||||||
|
}
|
||||||
|
|
||||||
|
itemMeta = skullMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> processedLore = new ArrayList<>();
|
||||||
|
|
||||||
|
if (itemMeta.hasLore()) {
|
||||||
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
|
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
String displayName = itemMeta.getDisplayName();
|
||||||
|
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
|
||||||
|
}
|
||||||
|
itemMeta.setLore(processedLore);
|
||||||
|
|
||||||
if (colors.containsKey(cosmetic.getSlot())) {
|
if (colors.containsKey(cosmetic.getSlot())) {
|
||||||
Color color = colors.get(cosmetic.getSlot());
|
Color color = colors.get(cosmetic.getSlot());
|
||||||
if (itemMeta instanceof LeatherArmorMeta leatherMeta) {
|
if (itemMeta instanceof LeatherArmorMeta leatherMeta) {
|
||||||
@@ -201,6 +265,9 @@ public class CosmeticUser {
|
|||||||
mapMeta.setColor(color);
|
mapMeta.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
itemMeta.getPersistentDataContainer().set(InventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
|
||||||
|
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString());
|
||||||
|
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@@ -222,27 +289,28 @@ public class CosmeticUser {
|
|||||||
return userEmoteManager;
|
return userEmoteManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enterWardrobe() {
|
public void enterWardrobe(boolean ignoreDistance, Wardrobe wardrobe) {
|
||||||
enterWardrobe(false);
|
if (wardrobe.hasPermission() && !getPlayer().hasPermission(wardrobe.getPermission())) {
|
||||||
}
|
MessagesUtil.sendMessage(getPlayer(), "no-permission");
|
||||||
|
return;
|
||||||
public void enterWardrobe(boolean ignoreDistance) {
|
}
|
||||||
enterWardrobe(ignoreDistance, WardrobeSettings.getLeaveLocation(), WardrobeSettings.getViewerLocation(), WardrobeSettings.getWardrobeLocation());
|
if (!wardrobe.canEnter(this) && !ignoreDistance) {
|
||||||
}
|
|
||||||
|
|
||||||
public void enterWardrobe(boolean ignoreDistance, Location exitLocation, Location viewingLocation, Location npcLocation) {
|
|
||||||
if (!WardrobeSettings.inDistanceOfStatic(getPlayer().getLocation()) && !ignoreDistance) {
|
|
||||||
MessagesUtil.sendMessage(getPlayer(), "not-near-wardrobe");
|
MessagesUtil.sendMessage(getPlayer(), "not-near-wardrobe");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlayerWardrobeEnterEvent event = new PlayerWardrobeEnterEvent(this);
|
if (!wardrobe.getLocation().hasAllLocations()) {
|
||||||
|
MessagesUtil.sendMessage(getPlayer(), "wardrobe-not-setup");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PlayerWardrobeEnterEvent event = new PlayerWardrobeEnterEvent(this, wardrobe);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
wardrobe = event.getWardrobe();
|
||||||
|
|
||||||
if (userWardrobeManager == null) {
|
if (userWardrobeManager == null) {
|
||||||
userWardrobeManager = new UserWardrobeManager(this, exitLocation, viewingLocation, npcLocation);
|
userWardrobeManager = new UserWardrobeManager(this, wardrobe);
|
||||||
userWardrobeManager.start();
|
userWardrobeManager.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,6 +321,7 @@ public class CosmeticUser {
|
|||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MessagesUtil.sendDebugMessages("Leaving Wardrobe");
|
||||||
if (!getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
if (!getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
||||||
|
|
||||||
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
|
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
|
||||||
@@ -269,24 +338,19 @@ public class CosmeticUser {
|
|||||||
userWardrobeManager.end();
|
userWardrobeManager.end();
|
||||||
userWardrobeManager = null;
|
userWardrobeManager = null;
|
||||||
}, WardrobeSettings.getTransitionDelay());
|
}, WardrobeSettings.getTransitionDelay());
|
||||||
|
} else {
|
||||||
|
userWardrobeManager.end();
|
||||||
|
userWardrobeManager = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInWardrobe() {
|
public boolean isInWardrobe() {
|
||||||
if (userWardrobeManager == null) return false;
|
return userWardrobeManager != null;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleWardrobe() {
|
|
||||||
if (isInWardrobe()) {
|
|
||||||
leaveWardrobe();
|
|
||||||
} else {
|
|
||||||
enterWardrobe();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
this.userBackpackManager = new UserBackpackManager(this);
|
if (this.userBackpackManager != null) return;
|
||||||
|
this.userBackpackManager = new UserBackpackManager(this, cosmeticBackpackType.isFirstPersonCompadible());
|
||||||
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,24 +360,19 @@ public class CosmeticUser {
|
|||||||
userBackpackManager = null;
|
userBackpackManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBackpackSpawned() {
|
||||||
|
return this.userBackpackManager != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
||||||
Player player = Bukkit.getPlayer(getUniqueId());
|
|
||||||
|
|
||||||
if (this.userBalloonManager != null) return;
|
if (this.userBalloonManager != null) return;
|
||||||
|
|
||||||
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
|
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
|
||||||
|
updateCosmetic(cosmeticBalloonType);
|
||||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
|
|
||||||
viewer.add(player);
|
|
||||||
|
|
||||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void despawnBalloon() {
|
public void despawnBalloon() {
|
||||||
if (this.userBalloonManager == null) return;
|
if (this.userBalloonManager == null) return;
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getPlayer().getLocation());
|
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||||
|
|
||||||
PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
||||||
|
|
||||||
@@ -336,21 +395,35 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeArmor(CosmeticSlot slot) {
|
public void removeArmor(CosmeticSlot slot) {
|
||||||
PacketManager.equipmentSlotUpdate(getPlayer().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getPlayer()));
|
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the player associated with the user. Some users may not have a player attached, ie, they are npcs
|
||||||
|
* wearing cosmetics through an addon. If you need to get locations, use getEntity instead.
|
||||||
|
* @return Player
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return Bukkit.getPlayer(uniqueId);
|
return Bukkit.getPlayer(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gets the entity associated with the user.
|
||||||
|
* @return Entity
|
||||||
|
*/
|
||||||
|
public Entity getEntity() {
|
||||||
|
return Bukkit.getEntity(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
public Color getCosmeticColor(CosmeticSlot slot) {
|
public Color getCosmeticColor(CosmeticSlot slot) {
|
||||||
return colors.get(slot);
|
return colors.get(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CosmeticSlot> getDyeableSlots() {
|
public List<CosmeticSlot> getDyeableSlots() {
|
||||||
ArrayList<CosmeticSlot> dyableSlots = new ArrayList();
|
ArrayList<CosmeticSlot> dyableSlots = new ArrayList<>();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : getCosmetic()) {
|
for (Cosmetic cosmetic : getCosmetics()) {
|
||||||
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,8 +432,10 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
public boolean canEquipCosmetic(Cosmetic cosmetic) {
|
public boolean canEquipCosmetic(Cosmetic cosmetic) {
|
||||||
if (!cosmetic.requiresPermission()) return true;
|
if (!cosmetic.requiresPermission()) return true;
|
||||||
if (getPlayer().hasPermission(cosmetic.getPermission())) return true;
|
if (isInWardrobe()) {
|
||||||
return false;
|
if (WardrobeSettings.isTryCosmeticsInWardrobe() && userWardrobeManager.getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return true;
|
||||||
|
}
|
||||||
|
return getPlayer().hasPermission(cosmetic.getPermission());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hidePlayer() {
|
public void hidePlayer() {
|
||||||
@@ -382,7 +457,7 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void hideCosmetics(HiddenReason reason) {
|
public void hideCosmetics(HiddenReason reason) {
|
||||||
if (hideCosmetics == true) return;
|
if (hideCosmetics) return;
|
||||||
PlayerCosmeticHideEvent event = new PlayerCosmeticHideEvent(this, reason);
|
PlayerCosmeticHideEvent event = new PlayerCosmeticHideEvent(this, reason);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@@ -393,18 +468,17 @@ public class CosmeticUser {
|
|||||||
hiddenReason = reason;
|
hiddenReason = reason;
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
getBalloonManager().removePlayerFromModel(getPlayer());
|
getBalloonManager().removePlayerFromModel(getPlayer());
|
||||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(getPlayer());
|
getBalloonManager().sendRemoveLeashPacket();
|
||||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
|
||||||
}
|
}
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
userBackpackManager.getArmorstand().getEquipment().clear();
|
userBackpackManager.clearItems();
|
||||||
}
|
}
|
||||||
updateCosmetic();
|
updateCosmetic();
|
||||||
MessagesUtil.sendDebugMessages("HideCosmetics");
|
MessagesUtil.sendDebugMessages("HideCosmetics");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showCosmetics() {
|
public void showCosmetics() {
|
||||||
if (hideCosmetics == false) return;
|
if (!hideCosmetics) return;
|
||||||
|
|
||||||
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
@@ -423,7 +497,7 @@ public class CosmeticUser {
|
|||||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK);
|
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK);
|
||||||
ItemStack item = getUserCosmeticItem(cosmeticBackpackType);
|
ItemStack item = getUserCosmeticItem(cosmeticBackpackType);
|
||||||
userBackpackManager.getArmorstand().getEquipment().setHelmet(item);
|
userBackpackManager.setItem(item);
|
||||||
}
|
}
|
||||||
updateCosmetic();
|
updateCosmetic();
|
||||||
MessagesUtil.sendDebugMessages("ShowCosmetics");
|
MessagesUtil.sendDebugMessages("ShowCosmetics");
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user