mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
Compare commits
755 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e2b2edadd | ||
|
|
7e384fcd79 | ||
|
|
e88b84610e | ||
|
|
223ffa46eb | ||
|
|
f408108682 | ||
|
|
b9f9448367 | ||
|
|
c40aca9946 | ||
|
|
98d2692def | ||
|
|
ebbc80c465 | ||
|
|
775699d9ca | ||
|
|
b0ba5fc011 | ||
|
|
af01ff600b | ||
|
|
2e4619da02 | ||
|
|
b4bd08c249 | ||
|
|
19981b33d3 | ||
|
|
c7c4c0e583 | ||
|
|
935c157421 | ||
|
|
20a3a508c2 | ||
|
|
92b75c43ab | ||
|
|
a6ad2c19aa | ||
|
|
fe8b4c97ff | ||
|
|
8c119c78db | ||
|
|
ce33a72fc2 | ||
|
|
2a8f30636d | ||
|
|
4103c2c232 | ||
|
|
fb5c9d205c | ||
|
|
126d576303 | ||
|
|
c74b76837b | ||
|
|
d2c37f8273 | ||
|
|
dbadbda82f | ||
|
|
d66aa3b79c | ||
|
|
1c5cd7b467 | ||
|
|
10f8dda150 | ||
|
|
e76aa0783e | ||
|
|
0676125f07 | ||
|
|
7aef681149 | ||
|
|
d5ac55f266 | ||
|
|
c2b787c97c | ||
|
|
732c3de0d8 | ||
|
|
3843a28804 | ||
|
|
a63494ba9f | ||
|
|
c7e6a77eb8 | ||
|
|
075d2b3182 | ||
|
|
515de7d2c8 | ||
|
|
429287c9f3 | ||
|
|
fed13b8ee6 | ||
|
|
8011dda200 | ||
|
|
7abfb0edf1 | ||
|
|
1f8c772712 | ||
|
|
7d727bb68f | ||
|
|
007f27f109 | ||
|
|
e0e0d0c997 | ||
|
|
75a1458ae1 | ||
|
|
548b15d99d | ||
|
|
50f04373b7 | ||
|
|
27a6c1bd54 | ||
|
|
bb08fb108c | ||
|
|
3907bc5839 | ||
|
|
1ef7f4759f | ||
|
|
937f66e8c5 | ||
|
|
158f3afdec | ||
|
|
38bdc01e9f | ||
|
|
797992362a | ||
|
|
9716a079be | ||
|
|
dfe51ba5b8 | ||
|
|
f5e81446a6 | ||
|
|
c99a57a6bf | ||
|
|
79630263f2 | ||
|
|
478c4280c1 | ||
|
|
4fd439acc4 | ||
|
|
58c955a00f | ||
|
|
2f9325b2fb | ||
|
|
823270648b | ||
|
|
d5e988261b | ||
|
|
13303096ec | ||
|
|
3ee79e8443 | ||
|
|
7785556967 | ||
|
|
1296ca6e92 | ||
|
|
f56d5c9093 | ||
|
|
bae04fba3f | ||
|
|
cbe5404399 | ||
|
|
dc4098782a | ||
|
|
2eb0b26fb3 | ||
|
|
22159fa9f4 | ||
|
|
539c09801c | ||
|
|
bed5cd7bbb | ||
|
|
4a1a631557 | ||
|
|
ad282a9efe | ||
|
|
86ef4d0efa | ||
|
|
da09a542f1 | ||
|
|
62f32cc03d | ||
|
|
ff1addfd65 | ||
|
|
73f013bf1f | ||
|
|
204fee4456 | ||
|
|
e7ea62a4d2 | ||
|
|
42802e41b4 | ||
|
|
7e7d81d0f8 | ||
|
|
b07c3c9878 | ||
|
|
a19d564460 | ||
|
|
b3408143f0 | ||
|
|
3c1539285d | ||
|
|
a642d88af2 | ||
|
|
36d4009f5e | ||
|
|
bebee807bc | ||
|
|
26c579b69f | ||
|
|
ef665e7e83 | ||
|
|
7a6475c467 | ||
|
|
63963cccc3 | ||
|
|
7cf6a3c75c | ||
|
|
22a5bb4cf1 | ||
|
|
148d163d9c | ||
|
|
ef36e66c51 | ||
|
|
e5fda588c3 | ||
|
|
3baf2694be | ||
|
|
a1dafdee5b | ||
|
|
e3a42d8b4a | ||
|
|
b366f5930b | ||
|
|
45eb1fa668 | ||
|
|
c466405a81 | ||
|
|
172ffc0333 | ||
|
|
41ac857a11 | ||
|
|
737d63642c | ||
|
|
7b9b7678a3 | ||
|
|
fe88d0c608 | ||
|
|
e14935af7b | ||
|
|
3e83d370f8 | ||
|
|
874a7f5624 | ||
|
|
3af992a291 | ||
|
|
9ef7791998 | ||
|
|
1cbe17ddd4 | ||
|
|
2841742af9 | ||
|
|
6e2f333404 | ||
|
|
af8949b713 | ||
|
|
d6f7d0fcb3 | ||
|
|
a8f035bbe2 | ||
|
|
301fd6a349 | ||
|
|
90b71e7dc9 | ||
|
|
e6827cdf72 | ||
|
|
1212ab2025 | ||
|
|
e31f000de6 | ||
|
|
70028598d5 | ||
|
|
07b772d228 | ||
|
|
065e48c125 | ||
|
|
49eb1d61ef | ||
|
|
9e1a30025f | ||
|
|
76429ed041 | ||
|
|
f5a01c0104 | ||
|
|
545f258f90 | ||
|
|
720437212b | ||
|
|
d932732d9b | ||
|
|
1118be1153 | ||
|
|
1dc549d645 | ||
|
|
4136d19396 | ||
|
|
52de7425e4 | ||
|
|
f470e55142 | ||
|
|
470de3b749 | ||
|
|
ea72499826 | ||
|
|
6b19bf442a | ||
|
|
436de38102 | ||
|
|
4bb00071d4 | ||
|
|
650cf75168 | ||
|
|
0d07e8a267 | ||
|
|
b7ec587d7d | ||
|
|
e807c7e2f7 | ||
|
|
15e1f0aaa9 | ||
|
|
f1e975f940 | ||
|
|
89fba800a4 | ||
|
|
863275a2ce | ||
|
|
b516cfced4 | ||
|
|
28034318ac | ||
|
|
c2e4764ace | ||
|
|
948bfb17f5 | ||
|
|
6c98b7696a | ||
|
|
2c4638fa47 | ||
|
|
ced2fe7b03 | ||
|
|
3a56f074fa | ||
|
|
dca5abe4ec | ||
|
|
1dd54ea1cb | ||
|
|
b81af97573 | ||
|
|
74d64b16d2 | ||
|
|
2174ec6124 | ||
|
|
1de84bce6f | ||
|
|
3aa5939225 | ||
|
|
44650250c5 | ||
|
|
49fff9b650 | ||
|
|
190f66a990 | ||
|
|
8a34f100d3 | ||
|
|
79687a22fc | ||
|
|
f5fac4e048 | ||
|
|
eac0812dbb | ||
|
|
93f5bfbb2a | ||
|
|
94cba225a6 | ||
|
|
ab614d8b07 | ||
|
|
e7fd39a077 | ||
|
|
530cdb282b | ||
|
|
97534f6916 | ||
|
|
22fb52acc6 | ||
|
|
cf0da580e0 | ||
|
|
64a590b581 | ||
|
|
afb3218bc1 | ||
|
|
170911a6a1 | ||
|
|
ea5b878f74 | ||
|
|
88af1cd68e | ||
|
|
34237e0a45 | ||
|
|
a037487497 | ||
|
|
e7b1fda73e | ||
|
|
c591641754 | ||
|
|
2a0aa1593a | ||
|
|
330723a45c | ||
|
|
f6a1438299 | ||
|
|
1f0f8e5f70 | ||
|
|
216c05ed9b | ||
|
|
89fbacafac | ||
|
|
8c45bfc76b | ||
|
|
4ad3c02d88 | ||
|
|
477729242b | ||
|
|
e96d06892a | ||
|
|
5b1b91f119 | ||
|
|
446e629474 | ||
|
|
57c2cd0719 | ||
|
|
8f2a01b348 | ||
|
|
6fe5817fd7 | ||
|
|
663b3d1647 | ||
|
|
bf0a372edd | ||
|
|
5d0237e28c | ||
|
|
349311cb58 | ||
|
|
a1098641b5 | ||
|
|
8c0ca5083d | ||
|
|
c42ecadd90 | ||
|
|
735386718e | ||
|
|
95459cc2d2 | ||
|
|
fe52edd833 | ||
|
|
d659128ae4 | ||
|
|
397eebf38f | ||
|
|
e18690496f | ||
|
|
c522581d46 | ||
|
|
c31d2e1aee | ||
|
|
9879c82d40 | ||
|
|
1873f5b9b5 | ||
|
|
68d94be743 | ||
|
|
14e38e7974 | ||
|
|
5cc19ab2db | ||
|
|
93b1c20c40 | ||
|
|
49435436cb | ||
|
|
0477e801a6 | ||
|
|
5779d278a9 | ||
|
|
0a8821d3e8 | ||
|
|
e96e9e00bb | ||
|
|
217fb5d332 | ||
|
|
6636cc9548 | ||
|
|
c3fcf760d7 | ||
|
|
7116767e22 | ||
|
|
0877165f9f | ||
|
|
b43466a793 | ||
|
|
401e6170e6 | ||
|
|
782eb4c464 | ||
|
|
1ef2c6b631 | ||
|
|
c7667b2dc2 | ||
|
|
e4c4933d46 | ||
|
|
1f94192772 | ||
|
|
8ebcea5465 | ||
|
|
4c7ccc06ca | ||
|
|
667f58ff4b | ||
|
|
69d318c4b0 | ||
|
|
0414f3be90 | ||
|
|
402203b4c2 | ||
|
|
6dcaf06ebe | ||
|
|
1b6adca00e | ||
|
|
0dce5822e3 | ||
|
|
0f1b75f09e | ||
|
|
19192c46a5 | ||
|
|
62a9e7d1ac | ||
|
|
06077201f9 | ||
|
|
b2795a705e | ||
|
|
1e6734bf6f | ||
|
|
ad382e5d9e | ||
|
|
6458a1e316 | ||
|
|
279d6edc34 | ||
|
|
439dc85aa3 | ||
|
|
60e23411dc | ||
|
|
33fb680c22 | ||
|
|
536b7ebdec | ||
|
|
5da95f2f5b | ||
|
|
30f4a84241 | ||
|
|
f34e126c85 | ||
|
|
d7d0f27e49 | ||
|
|
f42937a6d0 | ||
|
|
c8b7430998 | ||
|
|
42de76d84d | ||
|
|
5102fd77b7 | ||
|
|
9c66d4ee81 | ||
|
|
7ade2d9227 | ||
|
|
7b43b42740 | ||
|
|
25f050f387 | ||
|
|
05c13e8990 | ||
|
|
34b02574b2 | ||
|
|
f81d350a2e | ||
|
|
be86314daf | ||
|
|
345f903113 | ||
|
|
3cf265f231 | ||
|
|
d26e7df2ca | ||
|
|
e5dc3f6774 | ||
|
|
fdc9893a60 | ||
|
|
e8694076b8 | ||
|
|
1acf536080 | ||
|
|
9d3ad0b54b | ||
|
|
0b2ade1598 | ||
|
|
83651b7250 | ||
|
|
6818c09a69 | ||
|
|
dc72b677de | ||
|
|
5ff1a63eaa | ||
|
|
8300a86225 | ||
|
|
9e8084194a | ||
|
|
c0ea4d5a5b | ||
|
|
5a963391f8 | ||
|
|
6c4586a6b9 | ||
|
|
4cc0a6f968 | ||
|
|
ab8656ad1a | ||
|
|
ca5e0f96c2 | ||
|
|
5cddd24097 | ||
|
|
656e539ae3 | ||
|
|
862b7c9ee6 | ||
|
|
c632174de8 | ||
|
|
1e96303765 | ||
|
|
1a6d587ee0 | ||
|
|
adcb6de5e4 | ||
|
|
c36e263a95 | ||
|
|
de1e5bf100 | ||
|
|
ea25dcf208 | ||
|
|
e3c73d0bfe | ||
|
|
91b24bfa82 | ||
|
|
28bf5ba2b6 | ||
|
|
0249d6abdb | ||
|
|
cb32f635d0 | ||
|
|
3bfdde4281 | ||
|
|
8daa2709f3 | ||
|
|
35260d4abb | ||
|
|
2d44435d53 | ||
|
|
3d785bd157 | ||
|
|
c33cfbd302 | ||
|
|
f5ed39e02c | ||
|
|
0c3af0e0cd | ||
|
|
f5a1a67e1e | ||
|
|
ddc0a504fd | ||
|
|
de108753d5 | ||
|
|
b31e8b7a4b | ||
|
|
383fdfa7f6 | ||
|
|
54e867ab0b | ||
|
|
068ed3eb70 | ||
|
|
a203c60df1 | ||
|
|
e13c3fccb4 | ||
|
|
add72e66c9 | ||
|
|
0e587feff0 | ||
|
|
27be86c419 | ||
|
|
3d940d8468 | ||
|
|
7515cdd137 | ||
|
|
8e92f3e689 | ||
|
|
7c4b833d80 | ||
|
|
b291dc4c9f | ||
|
|
60b91df843 | ||
|
|
56f380025d | ||
|
|
b3e0acbcbd | ||
|
|
e2d334db9d | ||
|
|
dffcf6213b | ||
|
|
485f5837f4 | ||
|
|
442cddb81e | ||
|
|
1f38d1aa46 | ||
|
|
ce7dc03350 | ||
|
|
9a75fcb55b | ||
|
|
5522eed2d1 | ||
|
|
1737330b87 | ||
|
|
eff25664f3 | ||
|
|
27d3a1df42 | ||
|
|
63bda02869 | ||
|
|
8c251a8c69 | ||
|
|
4b481ef3ea | ||
|
|
2d62c96d3d | ||
|
|
f8cb436c5b | ||
|
|
0de31fcd04 | ||
|
|
99edb501a5 | ||
|
|
66aaed009f | ||
|
|
4c0b86b127 | ||
|
|
155133a2a0 | ||
|
|
93062d47a8 | ||
|
|
1f0c67a805 | ||
|
|
74feb112f6 | ||
|
|
967349f5af | ||
|
|
d7fe2475ed | ||
|
|
f87bf93641 | ||
|
|
4b467b4644 | ||
|
|
15234a904f | ||
|
|
9ff6d3f60c | ||
|
|
aeba867e9e | ||
|
|
d21e148f39 | ||
|
|
51188fdeba | ||
|
|
dcf072f3de | ||
|
|
ebf09d8e0f | ||
|
|
ca5cb25331 | ||
|
|
65877bff5b | ||
|
|
4a75c7b333 | ||
|
|
be4f1d6675 | ||
|
|
55d4f9ae09 | ||
|
|
88691956ba | ||
|
|
a6133a2b45 | ||
|
|
0aa821e51a | ||
|
|
fb37ea8af9 | ||
|
|
0f36803026 | ||
|
|
2910540c26 | ||
|
|
93fb885195 | ||
|
|
2438d5385f | ||
|
|
73ce071427 | ||
|
|
e3485b7733 | ||
|
|
7ff4fbb3d7 | ||
|
|
de5b9be6ac | ||
|
|
0c6e8eb160 | ||
|
|
9b85fd2d8c | ||
|
|
a136b95451 | ||
|
|
cf5eb64029 | ||
|
|
c4591b030b | ||
|
|
9dc6eb1dfc | ||
|
|
d7c1bf39e2 | ||
|
|
ae1527fca3 | ||
|
|
d14698b282 | ||
|
|
800d3be25f | ||
|
|
27599030cf | ||
|
|
3ee959abd6 | ||
|
|
617df48cc2 | ||
|
|
9e290c2dfd | ||
|
|
f98614c4ee | ||
|
|
d28bb23f8c | ||
|
|
502cb533f8 | ||
|
|
b7fdc2087a | ||
|
|
10a42a3c96 | ||
|
|
51fc52e24b | ||
|
|
be632d8e8c | ||
|
|
a732a2b0a0 | ||
|
|
b14a0b5d16 | ||
|
|
50393c62b0 | ||
|
|
dbc4a07895 | ||
|
|
ab329e4fbf | ||
|
|
90ad700d0a | ||
|
|
56529d6111 | ||
|
|
b6a06007e8 | ||
|
|
edccc9ce4e | ||
|
|
e0b2f0f6b1 | ||
|
|
57f4d3703c | ||
|
|
8ef6692198 | ||
|
|
c48830f3ac | ||
|
|
734c04c1f4 | ||
|
|
b08b4019a9 | ||
|
|
cfb7876b6e | ||
|
|
6047d0e3c3 | ||
|
|
880c333df9 | ||
|
|
c4d7b657dd | ||
|
|
5be3ce8d21 | ||
|
|
33bba631fc | ||
|
|
775b9c299d | ||
|
|
6e02331c13 | ||
|
|
b7457cec9c | ||
|
|
e7288a1910 | ||
|
|
26b90bd8bb | ||
|
|
24a10b6838 | ||
|
|
af7bc0dc3f | ||
|
|
162d4a6ed6 | ||
|
|
41140f60c5 | ||
|
|
a6145a607c | ||
|
|
89c6951a93 | ||
|
|
28c466e342 | ||
|
|
90caa23cd7 | ||
|
|
910f223151 | ||
|
|
ac1b50a957 | ||
|
|
9cb9bad3c8 | ||
|
|
f68e2633a2 | ||
|
|
c8ad5c0881 | ||
|
|
c93a718799 | ||
|
|
b5f781e00f | ||
|
|
f6cd73f436 | ||
|
|
8b0fcc5da9 | ||
|
|
b5787f22bf | ||
|
|
c1c431d914 | ||
|
|
b41dc66508 | ||
|
|
cfbf74257b | ||
|
|
9b2083b90a | ||
|
|
33437cd387 | ||
|
|
9f4e4616d4 | ||
|
|
01c62bc94e | ||
|
|
3be4bdeb6f | ||
|
|
145aec9b7f | ||
|
|
4a2266bbfa | ||
|
|
7fa3cd6cb7 | ||
|
|
9c5fe9c426 | ||
|
|
0a9d750d3e | ||
|
|
da996fb146 | ||
|
|
c051b267cf | ||
|
|
d1fc84b5bc | ||
|
|
b47b9d8235 | ||
|
|
edccc844c9 | ||
|
|
5788b2cce0 | ||
|
|
627ebafb79 | ||
|
|
ef3bf3fc19 | ||
|
|
97c02883b8 | ||
|
|
ad516e80d1 | ||
|
|
317ee261db | ||
|
|
5f8fb642a4 | ||
|
|
7f4a1bc3f2 | ||
|
|
e2a727864e | ||
|
|
c0014476fd | ||
|
|
8ec6a87b94 | ||
|
|
97cf079b63 | ||
|
|
82f13c349f | ||
|
|
f91c174b20 | ||
|
|
3ae6a11626 | ||
|
|
f2fab91916 | ||
|
|
55890fa4ac | ||
|
|
fa2aa2c6dc | ||
|
|
0b5f986cfc | ||
|
|
26361b833f | ||
|
|
28a37848c8 | ||
|
|
7131a45d9c | ||
|
|
6d9325ed18 | ||
|
|
0640b33d50 | ||
|
|
8b944b8e29 | ||
|
|
4481fa1c12 | ||
|
|
de133fa288 | ||
|
|
20da7797c9 | ||
|
|
2aed727832 | ||
|
|
b6731ba21a | ||
|
|
d333527664 | ||
|
|
a82bb8183b | ||
|
|
1eaeb8ecea | ||
|
|
7a9d2f0041 | ||
|
|
6d11deb9aa | ||
|
|
f5f33f5fe7 | ||
|
|
62a1d04040 | ||
|
|
17db498e18 | ||
|
|
0c11e1b1e5 | ||
|
|
d20eb11f45 | ||
|
|
51e19d3c36 | ||
|
|
8e8d86b94c | ||
|
|
c0caea2447 | ||
|
|
33356ea81d | ||
|
|
a486b13e7e | ||
|
|
938a561d25 | ||
|
|
1c61b72624 | ||
|
|
46d82b01f0 | ||
|
|
c98f132871 | ||
|
|
554bdf91bd | ||
|
|
fced771953 | ||
|
|
6ec47c3f08 | ||
|
|
2df2646622 | ||
|
|
e8d1dd1798 | ||
|
|
59479fc474 | ||
|
|
14b27abe92 | ||
|
|
8c2c6db81b | ||
|
|
5696039799 | ||
|
|
3068ce5a03 | ||
|
|
548d0c3e9a | ||
|
|
a37d6d984b | ||
|
|
d41b385b2a | ||
|
|
2ab59dd2b2 | ||
|
|
450083baf0 | ||
|
|
0d3129bc3f | ||
|
|
fe68c43c1f | ||
|
|
4aa1f412fe | ||
|
|
e53e0110f9 | ||
|
|
f645907ed5 | ||
|
|
af465180c0 | ||
|
|
210e6f61d6 | ||
|
|
14288479f4 | ||
|
|
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 | ||
|
|
006319a757 | ||
|
|
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 | ||
|
|
a8ff8e6a7a | ||
|
|
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 | ||
|
|
8b20207442 | ||
|
|
8bbe12ed84 | ||
|
|
d23f3e19d2 |
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
|
||||
4
.github/ISSUE_TEMPLATE/config.yml
vendored
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1 +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: [enhancement]
|
||||
|
||||
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
|
||||
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,11 +1,14 @@
|
||||
#### Select the option(s) that best describes this PR:
|
||||
- [ ] Major breaking change
|
||||
- [ ] Minor change
|
||||
- [ ] Bug fix
|
||||
- [ ] Feature implementation
|
||||
- [ ] Documentation
|
||||
- [ ] Cleaning
|
||||
- [ ] Refactoring
|
||||
- [ ] 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:
|
||||
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -115,3 +115,4 @@ run/
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
/qodana.yaml
|
||||
|
||||
186
build.gradle.kts
186
build.gradle.kts
@@ -2,13 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
id("xyz.jpenilla.run-paper") version "2.0.0"
|
||||
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
|
||||
id("com.gradleup.shadow") version "8.3.2"
|
||||
id("xyz.jpenilla.run-paper") version "2.3.1"
|
||||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||
}
|
||||
|
||||
group = "com.hibiscusmc"
|
||||
version = "2.2.8"
|
||||
version = "2.8.3${getGitCommitHash()}"
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
@@ -16,26 +16,24 @@ allprojects {
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
|
||||
// Paper Repo
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots")
|
||||
|
||||
// Jitpack
|
||||
maven("https://jitpack.io")
|
||||
|
||||
// ProtocolLib repo
|
||||
maven("https://repo.dmulloy2.net/repository/public/") //ProtocolLib Repo, constantly down
|
||||
// Geary
|
||||
maven("https://repo.mineinabyss.com/releases/")
|
||||
maven("https://repo.mineinabyss.com/snapshots/")
|
||||
|
||||
// PlaceholderAPI
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
|
||||
//Hikari
|
||||
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
|
||||
|
||||
// Citizens
|
||||
maven("https://repo.citizensnpcs.co")
|
||||
// Citizens & Denizen
|
||||
maven("https://maven.citizensnpcs.co/repo")
|
||||
|
||||
// Worldguard
|
||||
maven("https://maven.enginehub.org/repo/")
|
||||
@@ -51,9 +49,6 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateChecker
|
||||
maven("https://hub.jeff-media.com/nexus/repository/jeff-media-public/")
|
||||
|
||||
// ParticleHelper
|
||||
maven("https://repo.bytecode.space/repository/maven-public/")
|
||||
|
||||
@@ -62,52 +57,78 @@ allprojects {
|
||||
|
||||
// md-5 Repo
|
||||
maven("https://repo.md-5.net/content/groups/public/")
|
||||
|
||||
// MMOItems
|
||||
maven("https://nexus.phoenixdevt.fr/repository/maven-public/")
|
||||
|
||||
// Eco-Suite/Auxilor Repo
|
||||
maven("https://repo.auxilor.io/repository/maven-public/")
|
||||
|
||||
// Triumph GUI
|
||||
maven("https://repo.triumphteam.dev/snapshots")
|
||||
|
||||
// Hibiscus Commons
|
||||
maven("https://repo.hibiscusmc.com/releases")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
||||
compileOnly("com.mojang:authlib:1.5.25")
|
||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||
compileOnly("com.mineinabyss:idofront:0.12.111")
|
||||
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("it.unimi.dsi:fastutil:8.5.11")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
||||
//compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:24.1.0")
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.6")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.12") {
|
||||
exclude(group = "org.bukkit")
|
||||
exclude(group = "com.google.guava")
|
||||
exclude(group = "com.google.code.gson")
|
||||
exclude(group = "it.unimi.dsi")
|
||||
exclude(group = "com.sk89q.jnbt")
|
||||
exclude(group = "org.enginehub.lin-bus.format")
|
||||
}
|
||||
compileOnly("io.github.toxicity188:BetterHud-standard-api:1.12") //Standard api
|
||||
compileOnly("io.github.toxicity188:BetterHud-bukkit-api:1.12") //Platform api
|
||||
compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library
|
||||
//compileOnly("it.unimi.dsi:fastutil:8.5.14")
|
||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||
compileOnly("me.lojosho:HibiscusCommons:0.8.1-d9fbae1d")
|
||||
|
||||
// Handled by Spigot Library Loader ~ Deprecated as of Dec 16, 2025
|
||||
/*
|
||||
compileOnly("net.kyori:adventure-api:4.24.0")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.24.0")
|
||||
compileOnly("net.kyori:adventure-platform-bukkit:4.4.1")
|
||||
*/
|
||||
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.36")
|
||||
testCompileOnly("org.projectlombok:lombok:1.18.36")
|
||||
testAnnotationProcessor("org.projectlombok:lombok:1.18.36")
|
||||
|
||||
implementation("dev.triumphteam:triumph-gui:3.2.0-SNAPSHOT") {
|
||||
exclude("net.kyori") // Already have adventure API
|
||||
}
|
||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||
}
|
||||
|
||||
tasks {
|
||||
javadoc {
|
||||
// javadoc spec has these added.
|
||||
(options as StandardJavadocDocletOptions)
|
||||
.tags("apiNote:a:API:", "implSpec:a:Implementation Requirements", "implNote:a:Implementation Note:")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(path = ":common"))
|
||||
implementation(project(path = ":v1_17_R1", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R3", configuration = "reobf"))
|
||||
|
||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||
implementation("net.kyori:adventure-api:4.11.0")
|
||||
implementation("net.kyori:adventure-text-minimessage:4.11.0")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.1.2")
|
||||
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
options.release.set(21)
|
||||
}
|
||||
|
||||
javadoc {
|
||||
@@ -120,27 +141,23 @@ tasks {
|
||||
}
|
||||
|
||||
runServer {
|
||||
minecraftVersion("1.19.4")
|
||||
minecraftVersion("1.21.8")
|
||||
|
||||
downloadPlugins {
|
||||
hangar("PlaceholderAPI", "2.11.6")
|
||||
hangar("Multiverse-Core", "5.3.4")
|
||||
url("https://download.luckperms.net/1604/bukkit/loader/LuckPerms-Bukkit-5.5.15.jar")
|
||||
github("Test-Account666", "PlugManX", "2.4.1", "PlugManX-2.4.1.jar")
|
||||
//github("gecolay", "GSit", "2.4.3", "GSit-2.4.3.jar")
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependsOn(":v1_17_R1:reobfJar")
|
||||
dependsOn(":v1_18_R2:reobfJar")
|
||||
dependsOn(":v1_19_R1:reobfJar")
|
||||
dependsOn(":v1_19_R2:reobfJar")
|
||||
dependsOn(":v1_19_R3:reobfJar")
|
||||
mergeServiceFiles()
|
||||
|
||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||
relocate("me.mattstudios.mf", "com.hisbiscusmc.hmccosmetics.mf")
|
||||
relocate("net.kyori.adventure", "com.hisbiscusmc.hmccosmetics.adventure")
|
||||
relocate("org.spongepowered.configurate", "com.hisbiscusmc.hmccosmetics.configurate")
|
||||
relocate("org.bstats", "com.hisbiscusmc.hmccosmetics.bstats")
|
||||
relocate("com.zaxxer.hikaricp", "com.hisbiscusmc.hmccosmetics.hikaricp")
|
||||
relocate("com.j256.ormlite", "com.hisbiscusmc.hmccosmetics.ormlite")
|
||||
relocate("com.jeff_media.updatechecker", "com.hisbiscusmc.hmccosmetics.updatechecker")
|
||||
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
|
||||
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
||||
relocate("dev.triumphteam.gui", "com.hibiscusmc.hmccosmetics.shaded.gui")
|
||||
relocate("com.owen1212055.particlehelper", "com.hibiscusmc.hmccosmetics.shaded.particlehelper")
|
||||
relocate("com.ticxo.playeranimator", "com.hibiscusmc.hmccosmetics.shaded.playeranimator")
|
||||
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
||||
|
||||
dependencies {
|
||||
@@ -165,15 +182,19 @@ tasks {
|
||||
bukkit {
|
||||
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
||||
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
||||
apiVersion = "1.17"
|
||||
apiVersion = "1.20"
|
||||
authors = listOf("LoJoSho")
|
||||
depend = listOf("ProtocolLib")
|
||||
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Looty", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish")
|
||||
depend = listOf("HibiscusCommons")
|
||||
softDepend = listOf("Nexo", "BetterHud", "ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems", "Eco")
|
||||
version = "${project.version}"
|
||||
loadBefore = listOf(
|
||||
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
||||
)
|
||||
|
||||
commands {
|
||||
register("cosmetic") {
|
||||
description = "Base Cosmetic Command"
|
||||
aliases = listOf("hmccosmetics", "cosmetics")
|
||||
}
|
||||
}
|
||||
permissions {
|
||||
@@ -210,7 +231,7 @@ bukkit {
|
||||
register("hmccosmetics.cmd.emote.other") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.setlocation") {
|
||||
register("hmccosmetics.cmd.setwardrobesetting") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.dataclear") {
|
||||
@@ -249,10 +270,41 @@ bukkit {
|
||||
register("hmccosmetics.unapplydeath.bypass") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.disableall") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.hiddenreasons") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.clearhiddenreasons") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
||||
))
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
fun getGitCommitHash(): String {
|
||||
var includeHash = true
|
||||
val includeHashVariable = System.getenv("HMCC_INCLUDE_HASH")
|
||||
|
||||
if (!includeHashVariable.isNullOrEmpty()) includeHash = includeHashVariable.toBoolean()
|
||||
|
||||
if (includeHash) {
|
||||
return try {
|
||||
val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD")
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
|
||||
process.inputStream.bufferedReader().use { "-" + it.readLine().trim() }
|
||||
} catch (e: Exception) {
|
||||
"-unknown" // Fallback if Git is not available or an error occurs
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -3,38 +3,11 @@ plugins {
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.mojang:authlib:1.5.25")
|
||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||
compileOnly("com.mineinabyss:geary-papermc-core:0.19.113")
|
||||
compileOnly("com.mineinabyss:looty:0.8.67")
|
||||
compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
||||
|
||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||
implementation("net.kyori:adventure-api:4.12.0")
|
||||
implementation("net.kyori:adventure-text-minimessage:4.12.0")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.2.0")
|
||||
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
||||
))
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "HMCCosmetics"
|
||||
@@ -1,110 +1,103 @@
|
||||
package com.hibiscusmc.hmccosmetics;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticSetupEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenuProvider;
|
||||
import com.hibiscusmc.hmccosmetics.gui.special.impl.HMCColorDyeMenu;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.items.HookHMCCosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookBetterHud;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
|
||||
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
||||
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.listener.*;
|
||||
import com.hibiscusmc.hmccosmetics.packets.CosmeticPacketInterface;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerSearchManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||
import com.jeff_media.updatechecker.UpdateCheckSource;
|
||||
import com.jeff_media.updatechecker.UpdateChecker;
|
||||
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 lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||
import me.lojosho.hibiscuscommons.HibiscusPlugin;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.LocationSerializer;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.shaded.configupdater.common.config.CommentedConfiguration;
|
||||
import me.lojosho.shaded.configurate.ConfigurateException;
|
||||
import me.lojosho.shaded.configurate.ConfigurationOptions;
|
||||
import me.lojosho.shaded.configurate.yaml.NodeStyle;
|
||||
import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurationOptions;
|
||||
import org.spongepowered.configurate.yaml.NodeStyle;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
|
||||
public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
||||
|
||||
private static HMCCosmeticsPlugin instance;
|
||||
private static boolean disable = false;
|
||||
private static YamlConfigurationLoader configLoader;
|
||||
private static final int pluginId = 13873;
|
||||
private static boolean hasModelEngine = false;
|
||||
private static boolean onLatestVersion = true;
|
||||
private static String latestVersion = "";
|
||||
|
||||
@Getter
|
||||
private PlayerSearchManager playerSearchManager;
|
||||
|
||||
public HMCCosmeticsPlugin() {
|
||||
super(13873, 1879);
|
||||
new HookHMCCosmetics();
|
||||
new HookBetterHud();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
public void onStart() {
|
||||
// Plugin startup logic
|
||||
instance = this;
|
||||
// bstats https://bstats.org/plugin/bukkit/HMCCosmetics/13873
|
||||
Metrics metrics = new Metrics(this, pluginId);
|
||||
|
||||
// NMS version check
|
||||
if (!NMSHandlers.getHandler().getSupported()) {
|
||||
getLogger().severe("This version is not supported! Consider switching versions?");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
// Search Service
|
||||
this.playerSearchManager = new PlayerSearchManager(this);
|
||||
|
||||
// Update Checker
|
||||
UpdateChecker checker = new UpdateChecker(this, UpdateCheckSource.POLYMART, "1879")
|
||||
.onSuccess((commandSenders, latestVersion) -> {
|
||||
this.latestVersion = (String) latestVersion;
|
||||
if (!this.latestVersion.equalsIgnoreCase(getDescription().getVersion())) {
|
||||
getLogger().info("+++++++++++++++++++++++++++++++++++");
|
||||
getLogger().info("There is a new update for HMCCosmetics!");
|
||||
getLogger().info("Please download it as soon as possible for possible fixes and new features.");
|
||||
getLogger().info("Current Version " + getDescription().getVersion() + " | Latest Version " + latestVersion);
|
||||
getLogger().info("Spigot: https://www.spigotmc.org/resources/100107/");
|
||||
getLogger().info("Polymart: https://polymart.org/resource/1879");
|
||||
getLogger().info("+++++++++++++++++++++++++++++++++++");
|
||||
}
|
||||
})
|
||||
.setNotifyRequesters(false)
|
||||
.setNotifyOpsOnJoin(false)
|
||||
.checkEveryXHours(24)
|
||||
.checkNow();
|
||||
onLatestVersion = checker.isUsingLatestVersion();
|
||||
// File setup
|
||||
if (!getDataFolder().exists()) {
|
||||
saveDefaultConfig();
|
||||
saveResource("translations.yml", false);
|
||||
saveResource("messages.yml", false);
|
||||
saveResource("cosmetics/defaultcosmetics.yml", false);
|
||||
saveResource("menus/defaultmenu.yml", false);
|
||||
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
|
||||
if (!Path.of(getDataFolder().getPath(), "translations.yml").toFile().exists()) saveResource("translations.yml", false);
|
||||
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
|
||||
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) {
|
||||
saveResource("menus/defaultmenu_hats.yml", false);
|
||||
saveResource("menus/defaultmenu_balloons.yml", false);
|
||||
saveResource("menus/defaultmenu_hands.yml", false);
|
||||
saveResource("menus/defaultmenu_backpacks.yml", false);
|
||||
}
|
||||
// Emote folder setup
|
||||
File emoteFile = new File(getDataFolder().getPath() + "/emotes");
|
||||
if (!emoteFile.exists()) emoteFile.mkdir();
|
||||
|
||||
// Player Animator
|
||||
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", "wardrobe.wardrobes", "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();
|
||||
}
|
||||
|
||||
// Move this over to Hibiscus Commons later
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) new HMCPlaceholderExpansion().register();
|
||||
|
||||
// Setup
|
||||
setup();
|
||||
setPacketInterface(new CosmeticPacketInterface());
|
||||
|
||||
// Commands
|
||||
getServer().getPluginCommand("cosmetic").setExecutor(new CosmeticCommand());
|
||||
@@ -113,18 +106,28 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
// Listener
|
||||
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerGameListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new ServerListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerMovementListener(), this);
|
||||
getServer().getPluginManager().registerEvents(playerSearchManager, this);
|
||||
|
||||
if (HibiscusCommonsPlugin.isOnPaper()) {
|
||||
getServer().getPluginManager().registerEvents(new PaperPlayerGameListener(), this);
|
||||
}
|
||||
// Database
|
||||
new Database();
|
||||
|
||||
// ModelEngine
|
||||
if (Bukkit.getPluginManager().getPlugin("ModelEngine") != null) {
|
||||
hasModelEngine = true;
|
||||
// WorldGuard
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheck()) {
|
||||
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
||||
}
|
||||
|
||||
// WorldGuard
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
|
||||
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
||||
// HMCColor
|
||||
if (Hooks.isActiveHook("HMCColor")) {
|
||||
try {
|
||||
DyeMenuProvider.setDyeMenuProvider(new HMCColorDyeMenu());
|
||||
} catch (IllegalStateException e) {
|
||||
getLogger().warning("Unable to set HMCColor as the dye menu. There is likely another plugin registering another dye menu.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,14 +140,13 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
public void onEnd() {
|
||||
// Plugin shutdown logic
|
||||
disable = true;
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) continue;
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
player.setInvisible(false);
|
||||
if (user.isInWardrobe()) {
|
||||
user.leaveWardrobe(true);
|
||||
}
|
||||
Database.save(user);
|
||||
}
|
||||
@@ -174,7 +176,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
WardrobeSettings.load(loader.load().node("wardrobe"));
|
||||
DatabaseSettings.load(loader.load().node("database-settings"));
|
||||
configLoader = loader;
|
||||
} catch (ConfigurateException e) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -209,9 +211,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// Misc Hooks setup (like items)
|
||||
Hooks.setup();
|
||||
|
||||
// Cosmetics setup
|
||||
Cosmetics.setup();
|
||||
|
||||
@@ -240,57 +239,19 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
getInstance().getServer().getPluginManager().addPermission(new Permission(cosmetic.getPermission()));
|
||||
}
|
||||
}
|
||||
|
||||
File emoteFolder = new File(getInstance().getDataFolder().getPath() + "/emotes/");
|
||||
if (emoteFolder.exists()) {
|
||||
PlayerAnimator.api.getAnimationManager().clearRegistry();
|
||||
File[] emotesFiles = emoteFolder.listFiles();
|
||||
for (File emoteFile : emotesFiles) {
|
||||
if (!emoteFile.getName().contains("bbmodel")) continue;
|
||||
String animationName = FilenameUtils.removeExtension(emoteFile.getName());
|
||||
PlayerAnimator.api.getAnimationManager().importAnimations(animationName, emoteFile);
|
||||
MessagesUtil.sendDebugMessages("Added '" + animationName + "' to Player Animator ");
|
||||
for (Menu menu : Menus.values()) {
|
||||
if (menu.getPermissionNode() != null) {
|
||||
if (getInstance().getServer().getPluginManager().getPermission(menu.getPermissionNode()) != null) continue;
|
||||
getInstance().getServer().getPluginManager().addPermission(new Permission(menu.getPermissionNode()));
|
||||
}
|
||||
|
||||
/*
|
||||
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());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics 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());
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent());
|
||||
}
|
||||
|
||||
public static boolean isDisable() {
|
||||
return disable;
|
||||
}
|
||||
|
||||
public static YamlConfigurationLoader getConfigLoader() {
|
||||
return configLoader;
|
||||
}
|
||||
|
||||
public static void saveConfig(ConfigurationNode node) {
|
||||
try {
|
||||
HMCCosmeticsPlugin.getConfigLoader().save(node);
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Set new location " + node.path());
|
||||
} catch (ConfigurateException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasModelEngine() {
|
||||
return hasModelEngine;
|
||||
}
|
||||
public static boolean isOnLatestVersion() {
|
||||
return onLatestVersion;
|
||||
}
|
||||
public static String getLatestVersion() {
|
||||
return latestVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
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 {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticProvider;
|
||||
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.CosmeticUserProvider;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import me.lojosho.hibiscuscommons.nms.MinecraftVersion;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The main API class for HMCCosmetics. This class provides methods to interact with the plugin.
|
||||
*/
|
||||
public final class HMCCosmeticsAPI {
|
||||
private HMCCosmeticsAPI() {
|
||||
throw new UnsupportedOperationException("This class cannot be instantiated.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a {@link Cosmetic} associated with the specified id.
|
||||
* <p>
|
||||
* This method attempts to fetch a {@link Cosmetic} using the given id. If no {@link Cosmetic} exists
|
||||
* with the specified id, it will return {@code null}.
|
||||
* </p>
|
||||
* @param id the id of the {@link Cosmetic} to retrieve
|
||||
* @return the {@link Cosmetic} if it exists, or {@code null} if no cosmetic is associated with the given id
|
||||
*/
|
||||
public static @Nullable Cosmetic getCosmetic(@NotNull String id) {
|
||||
return Cosmetics.getCosmetic(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@link CosmeticUser} associated with the specified player's {@link UUID}.
|
||||
* <p>
|
||||
* This method attempts to fetch a {@link CosmeticUser} for an online player. If the player is offline,
|
||||
* or if no {@link CosmeticUser} is currently associated with them, it will return {@code null}.
|
||||
* </p>
|
||||
* Note that a player may be online but not have a {@link CosmeticUser} attached due to:
|
||||
* <ul>
|
||||
* <li>A delay specified in the configuration</li>
|
||||
* <li>A recent server reload (e.g., via the {@code /reload} command)</li>
|
||||
* </ul>
|
||||
* Always perform a {@code null} check before using the returned object to ensure safe operation.
|
||||
*
|
||||
* @param uuid the {@link UUID} of the player whose {@link CosmeticUser} is being retrieved
|
||||
* @return the {@link CosmeticUser} if it exists, or {@code null} if the player is offline or unassociated
|
||||
*/
|
||||
public static @Nullable CosmeticUser getUser(@NotNull UUID uuid) {
|
||||
return CosmeticUsers.getUser(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a {@link Menu} associated with the specified id, or {@code null} if no menu exists with the given id.
|
||||
*
|
||||
* @param id the id of the menu to retrieve
|
||||
* @return the {@link Menu} if it exists, or {@code null} if no menu is associated with the given id
|
||||
*/
|
||||
public static @Nullable Menu getMenu(@NotNull String id) {
|
||||
return Menus.getMenu(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Equips a {@link Cosmetic} to a player. To retrieve the necessary {@code CosmeticUser} and {@code Cosmetic}, use the {@link #getUser}
|
||||
* and {@link #getCosmetic} methods respectively.
|
||||
*
|
||||
* @param user the {@link CosmeticUser} to equip the cosmetic to
|
||||
* @param cosmetic the {@link Cosmetic} to equip
|
||||
*/
|
||||
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic) {
|
||||
equipCosmetic(user, cosmetic, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Equips a {@link Cosmetic} to a player with an optional color customization. To retrieve the necessary
|
||||
* {@code CosmeticUser} and {@code Cosmetic}, use the {@link #getUser} and {@link #getCosmetic} methods
|
||||
* respectively.
|
||||
*
|
||||
* @param user the {@link CosmeticUser} to equip the cosmetic to
|
||||
* @param cosmetic the {@link Cosmetic} to equip
|
||||
* @param color the color to apply to the cosmetic, or {@code null} if the cosmetic does not support color
|
||||
* customization
|
||||
*/
|
||||
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic, @Nullable Color color) {
|
||||
user.addCosmetic(cosmetic, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a cosmetic from a specified slot for the given user.
|
||||
*
|
||||
* @param user the {@link CosmeticUser} from whom the cosmetic will be removed
|
||||
* @param slot the {@link CosmeticSlot} from which the cosmetic will be removed
|
||||
*/
|
||||
public static void unequipCosmetic(@NotNull CosmeticUser user, @NotNull CosmeticSlot slot) {
|
||||
user.removeCosmeticSlot(slot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of all cosmetics currently registered with HMCC.
|
||||
*
|
||||
* @return an {@code immutable} list containing all registered {@link Cosmetic} object
|
||||
*/
|
||||
public static @NotNull List<Cosmetic> getAllCosmetics() {
|
||||
return List.copyOf(Cosmetics.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of all cosmetic users currently registered with HMCC.
|
||||
*
|
||||
* @return an immutable list containing all registered {@link CosmeticUser} objects
|
||||
*/
|
||||
public static @NotNull List<CosmeticUser> getAllCosmeticUsers() {
|
||||
return List.copyOf(CosmeticUsers.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a map of all cosmetic slots currently registered with HMCC.
|
||||
*
|
||||
* @return an immutable {@link Map} containing all registered cosmetic slots
|
||||
*/
|
||||
public static @NotNull Map<String, CosmeticSlot> getAllCosmeticSlots() {
|
||||
return Map.copyOf(CosmeticSlot.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new cosmetic slot with the specified id. If a slot with the same id already exists,
|
||||
* the existing slot will be returned.
|
||||
*
|
||||
* <p>
|
||||
* The provided id will automatically be converted to uppercase when registering the slot.
|
||||
* </p>
|
||||
*
|
||||
* @param id the id for the cosmetic slot
|
||||
* @return the {@link CosmeticSlot} associated with the given id
|
||||
* @apiNote this should be done in your {@link JavaPlugin#onLoad()} or it may error.
|
||||
*/
|
||||
public static @NotNull CosmeticSlot registerCosmeticSlot(@NotNull String id) {
|
||||
return CosmeticSlot.register(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new cosmetic user provider to use for constructing {@link CosmeticUser} instances.
|
||||
*
|
||||
* @param provider the provider to register
|
||||
* @throws IllegalArgumentException if another plugin has already registered a provider
|
||||
* @apiNote this should be done in your {@link JavaPlugin#onLoad()} or it may error.
|
||||
*/
|
||||
public static void registerCosmeticUserProvider(@NotNull CosmeticUserProvider provider) {
|
||||
CosmeticUsers.registerProvider(provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current {@link CosmeticUserProvider} that is in use.
|
||||
*
|
||||
* @return the current {@link CosmeticUserProvider}
|
||||
*/
|
||||
public static @NotNull CosmeticUserProvider getCosmeticUserProvider() {
|
||||
return CosmeticUsers.getProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new cosmetic user provider to use for constructing {@link Cosmetic} instances.
|
||||
*
|
||||
* @param provider the provider to register
|
||||
* @throws IllegalArgumentException if another plugin has already registered a provider
|
||||
* @apiNote this should be done in your {@link JavaPlugin#onLoad()} or it may error.
|
||||
*/
|
||||
public static void registerCosmeticProvider(@NotNull CosmeticProvider provider) {
|
||||
Cosmetics.registerProvider(provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current {@link CosmeticProvider} that is in use.
|
||||
*
|
||||
* @return the current {@link CosmeticProvider}
|
||||
*/
|
||||
public static @NotNull CosmeticProvider getCosmeticProvider() {
|
||||
return Cosmetics.getProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the NMS version of the server as recognized by HMCCosmetics.
|
||||
*
|
||||
* <p>This value will be {@code null} until the HMCC setup has been completed. Ensure setup is finished
|
||||
* before attempting to access this version.</p>
|
||||
*
|
||||
* @return the NMS version of the server in string format, or {@code null} if setup is not complete.
|
||||
*/
|
||||
public static @Nullable String getNMSVersion() {
|
||||
MinecraftVersion version = NMSHandlers.getVersion();
|
||||
if (version == null) return null;
|
||||
return version.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the version of HMCCosmetics currently in use.
|
||||
*
|
||||
* @return the HMCCosmetics version in string format
|
||||
*/
|
||||
public static @NotNull String getHMCCVersion() {
|
||||
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
|
||||
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;
|
||||
|
||||
public PlayerWardrobeEnterEvent(@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 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when an attempt is made to register a cosmetic type that is not part of the default HMCC cosmetics.
|
||||
* <p>
|
||||
* For example, if a user specifies "test" in the config slot, and it is not a default cosmetic, this event will be
|
||||
* triggered.
|
||||
* </p>
|
||||
*/
|
||||
public class CosmeticTypeRegisterEvent extends Event {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final String id;
|
||||
private final ConfigurationNode config;
|
||||
|
||||
public CosmeticTypeRegisterEvent(@NotNull String id, @NotNull ConfigurationNode config) {
|
||||
this.id = id;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the cosmetic attempting to be registered.
|
||||
*
|
||||
* @return the id of the cosmetic. This is the key in the cosmetic configuration.
|
||||
*/
|
||||
public @NotNull String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@link ConfigurationNode} for the cosmetic that was attempted to be registered.
|
||||
* <p>
|
||||
* This node is nested below the id in the configuration.
|
||||
* </p>
|
||||
*
|
||||
* @return the configuration node for the cosmetic in the cosmetic configuration
|
||||
*/
|
||||
public @NotNull ConfigurationNode getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
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 {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
@@ -7,22 +7,24 @@ import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player equips a cosmetic
|
||||
* Called when a player equips a {@link Cosmetic}.
|
||||
*/
|
||||
public class PlayerCosmeticEquipEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel = false;
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private Cosmetic cosmetic;
|
||||
|
||||
private boolean cancel = false;
|
||||
|
||||
public PlayerCosmeticEquipEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||
super(who);
|
||||
this.cosmetic = cosmetic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Cosmetic} being equipped in this event
|
||||
* Gets the {@link Cosmetic} being equipped in this event.
|
||||
*
|
||||
* @return The {@link Cosmetic} which is being equipped in this event
|
||||
* @return the cosmetic which is being equipped in this event
|
||||
*/
|
||||
@NotNull
|
||||
public Cosmetic getCosmetic() {
|
||||
@@ -30,9 +32,9 @@ public class PlayerCosmeticEquipEvent extends PlayerCosmeticEvent implements Can
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link Cosmetic} that the player will equip
|
||||
* Sets the {@link Cosmetic} that the player will equip.
|
||||
*
|
||||
* @param cosmetic The {@link Cosmetic} that the player will equip
|
||||
* @param cosmetic the cosmetic that the player will equip
|
||||
*/
|
||||
public void setCosmetic(@NotNull Cosmetic cosmetic) {
|
||||
this.cosmetic = cosmetic;
|
||||
@@ -43,28 +45,17 @@ public class PlayerCosmeticEquipEvent extends PlayerCosmeticEvent implements Can
|
||||
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;
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an event related to a {@link CosmeticUser}.
|
||||
*/
|
||||
public abstract class PlayerCosmeticEvent extends PlayerEvent {
|
||||
protected final CosmeticUser user;
|
||||
|
||||
public PlayerCosmeticEvent(@NotNull CosmeticUser who) {
|
||||
super(who.getUniqueId());
|
||||
user = who;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link CosmeticUser} involved in this event.
|
||||
*
|
||||
* @return the user who is involved in this event
|
||||
*/
|
||||
public final @NotNull CosmeticUser getUser() {
|
||||
return user;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -6,25 +6,26 @@ import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when cosmetics are hidden from a player
|
||||
* 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 static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final CosmeticUser.HiddenReason reason;
|
||||
|
||||
private boolean cancel = false;
|
||||
|
||||
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
|
||||
* 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
|
||||
* @return the reason why cosmetics are being hidden for the player
|
||||
*/
|
||||
@NotNull
|
||||
public CosmeticUser.HiddenReason getReason() {
|
||||
public @NotNull CosmeticUser.HiddenReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@@ -33,28 +34,17 @@ public class PlayerCosmeticHideEvent extends PlayerCosmeticEvent implements Canc
|
||||
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;
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Called when a player has equipped a {@link Cosmetic}.
|
||||
*/
|
||||
public class PlayerCosmeticPostEquipEvent extends PlayerCosmeticEvent {
|
||||
private static final HandlerList HANDLER_LIST = 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 cosmetic which is being equipped in this event
|
||||
*/
|
||||
public @NotNull Cosmetic getCosmetic() {
|
||||
return cosmetic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link Cosmetic} that the player will equip.
|
||||
*
|
||||
* @param cosmetic the cosmetic that the player will equip
|
||||
*/
|
||||
public void setCosmetic(@NotNull Cosmetic cosmetic) {
|
||||
this.cosmetic = cosmetic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
@@ -7,22 +7,24 @@ import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player removes a cosmetic
|
||||
* Called when a player removes a {@link Cosmetic}.
|
||||
*/
|
||||
public class PlayerCosmeticRemoveEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel = false;
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Cosmetic cosmetic;
|
||||
|
||||
private boolean cancel = false;
|
||||
|
||||
public PlayerCosmeticRemoveEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||
super(who);
|
||||
this.cosmetic = cosmetic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Cosmetic} being removed in this event
|
||||
* Gets the {@link Cosmetic} being removed in this event.
|
||||
*
|
||||
* @return The {@link Cosmetic} which is being removed in this event
|
||||
* @return the cosmetic which is being removed in this event
|
||||
*/
|
||||
public Cosmetic getCosmetic() {
|
||||
return cosmetic;
|
||||
@@ -33,27 +35,17 @@ public class PlayerCosmeticRemoveEvent extends PlayerCosmeticEvent implements Ca
|
||||
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 @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -6,10 +6,11 @@ import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when cosmetics are shown from a player
|
||||
* Called when cosmetics are shown from a player.
|
||||
*/
|
||||
public class PlayerCosmeticShowEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancel = false;
|
||||
|
||||
public PlayerCosmeticShowEvent(@NotNull CosmeticUser who) {
|
||||
@@ -21,28 +22,17 @@ public class PlayerCosmeticShowEvent extends PlayerCosmeticEvent implements Canc
|
||||
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;
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents an event related to a {@link org.bukkit.entity.Player}.
|
||||
*/
|
||||
public abstract class PlayerEvent extends Event {
|
||||
protected final UUID player;
|
||||
|
||||
public PlayerEvent(@NotNull UUID uuid) {
|
||||
this.player = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link UUID} of the player involved in this event.
|
||||
*
|
||||
* @return the UUID of the player who is involved in this event
|
||||
*/
|
||||
public final @NotNull UUID getUniqueId() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player's cosmetic data is loaded.
|
||||
*/
|
||||
public class PlayerLoadEvent extends PlayerCosmeticEvent {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
public PlayerLoadEvent(@NotNull CosmeticUser who) {
|
||||
super(who);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a {@link Menu} is closed by a player.
|
||||
*/
|
||||
public class PlayerMenuCloseEvent extends PlayerMenuEvent {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private final InventoryCloseEvent.Reason reason;
|
||||
|
||||
public PlayerMenuCloseEvent(@NotNull CosmeticUser who, @NotNull Menu menu, @NotNull InventoryCloseEvent.Reason reason) {
|
||||
super(who, menu);
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link InventoryCloseEvent.Reason} why the menu was closed.
|
||||
* @return The reason why the menu was closed.
|
||||
*/
|
||||
public InventoryCloseEvent.Reason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
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
|
||||
* Represents an event related to a player's interaction with a {@link Menu}.
|
||||
*/
|
||||
public abstract class PlayerMenuEvent extends PlayerCosmeticEvent {
|
||||
protected Menu menu;
|
||||
protected final Menu menu;
|
||||
|
||||
public PlayerMenuEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
|
||||
super(who);
|
||||
@@ -16,12 +16,11 @@ public abstract class PlayerMenuEvent extends PlayerCosmeticEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Menu} involved with this event
|
||||
* Gets the {@link Menu} involved with this event.
|
||||
*
|
||||
* @return The {@link Menu} which is involved with the event
|
||||
* @return the menu involved in this event
|
||||
*/
|
||||
@NotNull
|
||||
public final Menu getMenu() {
|
||||
public @NotNull final Menu getMenu() {
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
@@ -7,10 +7,11 @@ import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a menu is opened by a player
|
||||
* Called when a {@link Menu} is opened by a player.
|
||||
*/
|
||||
public class PlayerMenuOpenEvent extends PlayerMenuEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancel = false;
|
||||
|
||||
public PlayerMenuOpenEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
|
||||
@@ -22,28 +23,17 @@ public class PlayerMenuOpenEvent extends PlayerMenuEvent implements Cancellable
|
||||
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;
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Called before a player's data is loaded into the plugin.
|
||||
*
|
||||
* <p>
|
||||
* If this event is cancelled, the player's data will not be loaded,
|
||||
* and the player will not be able to interact with the plugin.
|
||||
* </p>
|
||||
*/
|
||||
public class PlayerPreLoadEvent extends PlayerEvent implements Cancellable {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PlayerPreLoadEvent(@NotNull UUID id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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 before a player's data is un-loaded from the plugin.
|
||||
*
|
||||
* <p>
|
||||
* If this event is cancelled, the player's data will not be un-loaded,
|
||||
* and will be kept in memory.
|
||||
* </p>
|
||||
*/
|
||||
public class PlayerPreUnloadEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PlayerPreUnloadEvent(@NotNull CosmeticUser who) {
|
||||
super(who);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a players data is unloaded from the plugin. This is called when a player leaves the server.
|
||||
*/
|
||||
public class PlayerUnloadEvent extends PlayerCosmeticEvent {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
public PlayerUnloadEvent(@NotNull CosmeticUser who) {
|
||||
super(who);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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 {@link Wardrobe}.
|
||||
*/
|
||||
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancel = false;
|
||||
|
||||
private Wardrobe wardrobe;
|
||||
|
||||
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull Wardrobe wardrobe) {
|
||||
super(who);
|
||||
this.wardrobe = wardrobe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link Wardrobe} the player is entering.
|
||||
* @return The wardrobe being entered
|
||||
*/
|
||||
public Wardrobe getWardrobe() {
|
||||
return wardrobe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link Wardrobe} the player is entering.
|
||||
* @param wardrobe the wardrobe being entered
|
||||
*/
|
||||
public void setWardrobe(Wardrobe wardrobe) {
|
||||
this.wardrobe = wardrobe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -6,10 +6,11 @@ import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player leaves their wardrobe
|
||||
* Called when a player leaves their {@link com.hibiscusmc.hmccosmetics.config.Wardrobe}.
|
||||
*/
|
||||
public class PlayerWardrobeLeaveEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancel = false;
|
||||
|
||||
public PlayerWardrobeLeaveEvent(@NotNull CosmeticUser who) {
|
||||
@@ -21,28 +22,17 @@ public class PlayerWardrobeLeaveEvent extends PlayerCosmeticEvent implements Can
|
||||
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;
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,27 @@
|
||||
package com.hibiscusmc.hmccosmetics.command;
|
||||
|
||||
import com.hibiscusmc.hmccolor.HMCColorConfig;
|
||||
import com.hibiscusmc.hmccolor.HMCColorContextKt;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
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.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenuProvider;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.ticxo.playeranimator.api.PlayerAnimator;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -38,10 +41,14 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
|
||||
boolean silent = false;
|
||||
boolean console = false;
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
console = true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
if (!(sender instanceof Player)) {
|
||||
// Console
|
||||
if (console) {
|
||||
return true;
|
||||
}
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.default")) {
|
||||
@@ -102,7 +109,18 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (sender.hasPermission("hmccosmetics.cmd.apply.color")) {
|
||||
if (args.length >= 4) color = ServerUtils.hex2Rgb(args[3]);
|
||||
if (args.length >= 4) {
|
||||
// TODO: Add sub-color support somehow... (and make this neater)
|
||||
String textColor = args[3];
|
||||
if (!textColor.contains("#") && Hooks.isActiveHook("HMCColor")) {
|
||||
HMCColorConfig.Colors colors = HMCColorContextKt.getHmcColor().getConfig().getColors().get(textColor);
|
||||
if (colors != null) {
|
||||
color = colors.getBaseColor().getColor();
|
||||
}
|
||||
} else {
|
||||
color = HMCCServerUtils.hex2Rgb(textColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
@@ -124,7 +142,12 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
|
||||
if (!user.canEquipCosmetic(cosmetic)) {
|
||||
if (user == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!user.canEquipCosmetic(cosmetic) && !console) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
||||
return true;
|
||||
}
|
||||
@@ -132,11 +155,11 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
TagResolver placeholders =
|
||||
TagResolver.resolver(Placeholder.parsed("cosmetic", cosmetic.getId()),
|
||||
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
|
||||
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmetic.getSlot().name())));
|
||||
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmetic.getSlot().toString())));
|
||||
|
||||
if (!silent) MessagesUtil.sendMessage(player, "equip-cosmetic", placeholders);
|
||||
|
||||
user.addPlayerCosmetic(cosmetic, color);
|
||||
user.addCosmetic(cosmetic, color);
|
||||
user.updateCosmetic(cosmetic.getSlot());
|
||||
return true;
|
||||
}
|
||||
@@ -167,11 +190,12 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
cosmeticSlots = user.getSlotsWithCosmetics();
|
||||
} else {
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
|
||||
String rawSlot = args[1].toUpperCase();
|
||||
if (!CosmeticSlot.contains(rawSlot)) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-slot");
|
||||
return true;
|
||||
}
|
||||
cosmeticSlots = Set.of(CosmeticSlot.valueOf(args[1].toUpperCase()));
|
||||
cosmeticSlots = Set.of(CosmeticSlot.valueOf(rawSlot));
|
||||
}
|
||||
|
||||
for (CosmeticSlot cosmeticSlot : cosmeticSlots) {
|
||||
@@ -183,7 +207,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
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())));
|
||||
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.toString())));
|
||||
|
||||
if (!silent) MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
|
||||
|
||||
@@ -194,8 +218,14 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
}
|
||||
case ("wardrobe") -> {
|
||||
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 (args.length >= 2) player = Bukkit.getPlayer(args[1]);
|
||||
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.wardrobe")) {
|
||||
@@ -208,19 +238,33 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
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);
|
||||
|
||||
user.toggleWardrobe();
|
||||
if (user.isInWardrobe()) {
|
||||
user.leaveWardrobe(false);
|
||||
} else {
|
||||
user.enterWardrobe(wardrobe, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// cosmetic menu exampleMenu playerName
|
||||
case ("menu") -> {
|
||||
if (args.length == 1) return true;
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.menu")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
Menu menu = Menus.getMenu(args[1]);
|
||||
Menu menu;
|
||||
if (args.length == 1) {
|
||||
menu = Menus.getDefaultMenu();
|
||||
} else {
|
||||
menu = Menus.getMenu(args[1]);
|
||||
}
|
||||
|
||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||
if (sender.hasPermission("hmccosmetics.cmd.menu.other")) {
|
||||
@@ -244,7 +288,6 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
case ("dataclear") -> {
|
||||
if (args.length == 1) return true;
|
||||
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
|
||||
if (selectedPlayer == null) return true;
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
@@ -267,58 +310,92 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1])) {
|
||||
final String rawSlot = args[1];
|
||||
if (!CosmeticSlot.contains(rawSlot)) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-slot");
|
||||
return true;
|
||||
}
|
||||
final CosmeticSlot slot = CosmeticSlot.valueOf(rawSlot); // This is checked above. While IDEs may say the slot might be null, it will not be.
|
||||
final Cosmetic cosmetic = user.getCosmetic(slot);
|
||||
if (cosmetic == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-slot");
|
||||
return true;
|
||||
}
|
||||
CosmeticSlot slot = CosmeticSlot.valueOf(args[1]);
|
||||
Cosmetic cosmetic = user.getCosmetic(slot);
|
||||
|
||||
if (args.length >= 3) {
|
||||
if (args[2].isEmpty()) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||
return true;
|
||||
}
|
||||
Color color = ServerUtils.hex2Rgb(args[2]);
|
||||
Color color = HMCCServerUtils.hex2Rgb(args[2]);
|
||||
if (color == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||
return true;
|
||||
}
|
||||
user.addPlayerCosmetic(cosmetic, color); // #FFFFFF
|
||||
user.addCosmetic(cosmetic, color); // #FFFFFF
|
||||
} else {
|
||||
DyeMenu.openMenu(user, cosmetic);
|
||||
if (DyeMenuProvider.hasMenuProvider()) {
|
||||
DyeMenuProvider.openMenu(player, user, cosmetic);
|
||||
} else {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||
}
|
||||
}
|
||||
case ("setlocation") -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.setlocation")) {
|
||||
}
|
||||
case ("setwardrobesetting") -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.setwardrobesetting")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player == null) return true;
|
||||
|
||||
if (args.length < 2) {
|
||||
if (args.length < 3) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||
return true;
|
||||
}
|
||||
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
|
||||
if (wardrobe == null) {
|
||||
wardrobe = new Wardrobe(args[1], new WardrobeLocation(null, null, null), null, -1, null);
|
||||
WardrobeSettings.addWardrobe(wardrobe);
|
||||
//MessagesUtil.sendMessage(player, "no-wardrobes");
|
||||
//return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("wardrobelocation")) {
|
||||
WardrobeSettings.setWardrobeLocation(player.getLocation());
|
||||
if (args[2].equalsIgnoreCase("npclocation")) {
|
||||
WardrobeSettings.setNPCLocation(wardrobe, player.getLocation());
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("viewerlocation")) {
|
||||
WardrobeSettings.setViewerLocation(player.getLocation());
|
||||
if (args[2].equalsIgnoreCase("viewerlocation")) {
|
||||
WardrobeSettings.setViewerLocation(wardrobe, player.getEyeLocation());
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("leavelocation")) {
|
||||
WardrobeSettings.setLeaveLocation(player.getLocation());
|
||||
if (args[2].equalsIgnoreCase("leavelocation")) {
|
||||
WardrobeSettings.setLeaveLocation(wardrobe, player.getLocation());
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
|
||||
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.parseInt(args[3]));
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-distance");
|
||||
return true;
|
||||
}
|
||||
if (args[2].equalsIgnoreCase("defaultmenu")) {
|
||||
WardrobeSettings.setWardrobeDefaultMenu(wardrobe, args[3]);
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-menu");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
case ("dump") -> {
|
||||
if (player == null) return true;
|
||||
@@ -330,8 +407,9 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
}
|
||||
player.sendMessage("Passengers -> " + player.getPassengers());
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorStand().getLocation());
|
||||
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getEntityManager().getLocation());
|
||||
}
|
||||
player.sendMessage("Cosmetic Passengers -> " + user.getUserBackpackManager().getAreaEffectEntityId());
|
||||
player.sendMessage("Cosmetics -> " + user.getCosmetics());
|
||||
player.sendMessage("EntityId -> " + player.getEntityId());
|
||||
return true;
|
||||
@@ -376,7 +454,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "show-cosmetic");
|
||||
user.showCosmetics();
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.COMMAND);
|
||||
return true;
|
||||
}
|
||||
case ("debug") -> {
|
||||
@@ -385,7 +463,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Settings.getDebugMode()) {
|
||||
if (Settings.isDebugMode()) {
|
||||
Settings.setDebugMode(false);
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "debug-disabled");
|
||||
} else {
|
||||
@@ -393,58 +471,60 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "debug-enabled");
|
||||
}
|
||||
}
|
||||
case ("emote") -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.emote")) {
|
||||
case "disableall" -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.disableall")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
if (sender.hasPermission("hmccosmetics.cmd.emote.other")) {
|
||||
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);
|
||||
if (!user.hasCosmeticInSlot(CosmeticSlot.EMOTE)) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "emote-none");
|
||||
return true;
|
||||
}
|
||||
|
||||
CosmeticEmoteType cosmeticEmoteType = (CosmeticEmoteType) user.getCosmetic(CosmeticSlot.EMOTE);
|
||||
cosmeticEmoteType.run(user);
|
||||
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 (args.length == 1) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
if (!PlayerAnimator.api.getAnimationManager().getRegistry().keySet().contains(args[1])) {
|
||||
MessagesUtil.sendDebugMessages("Did not contain " + args[1]);
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "emote-invalid");
|
||||
if (args[1].equalsIgnoreCase("true")) {
|
||||
Settings.setAllPlayersHidden(true);
|
||||
for (CosmeticUser user : CosmeticUsers.values()) user.hideCosmetics(CosmeticUser.HiddenReason.DISABLED);
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "disabled-all");
|
||||
} else if (args[1].equalsIgnoreCase("false")) {
|
||||
Settings.setAllPlayersHidden(false);
|
||||
for (CosmeticUser user : CosmeticUsers.values()) user.showCosmetics(CosmeticUser.HiddenReason.DISABLED);
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "enabled-all");
|
||||
} else {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-args");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (sender.hasPermission("hmccosmetics.cmd.playemote.other")) {
|
||||
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
||||
case "hiddenreasons" -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.hiddenreasons")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
user.getUserEmoteManager().playEmote(args[1]);
|
||||
sender.sendMessage(user.getHiddenReasons().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
case "clearhiddenreasons" -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.clearhiddenreasons")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
user.clearHiddenReasons();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.hibiscusmc.hmccosmetics.command;
|
||||
|
||||
import com.hibiscusmc.hmccolor.HMCColorContextKt;
|
||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
@@ -7,7 +10,7 @@ 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 com.ticxo.playeranimator.api.PlayerAnimator;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -36,18 +39,20 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.wardrobe")) completions.add("wardrobe");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.dataclear")) completions.add("dataclear");
|
||||
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.show")) completions.add("show");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.emote")) completions.add("emote");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.playemote")) completions.add("playemote");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.disableall")) completions.add("disableall");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.hiddenreasons")) completions.add("hiddenreasons");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.clearhiddenreasons")) completions.add("clearhiddenreasons");
|
||||
|
||||
StringUtil.copyPartialMatches(args[0], completions, finalCompletions);
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) return completions;
|
||||
CosmeticUser user = CosmeticUsers.getUser(((Player) sender).getUniqueId());
|
||||
if (user == null) return completions; // User hasn't loaded in yet, can't do proper checks
|
||||
|
||||
if (args.length == 2) {
|
||||
String subcommand = args[0].toLowerCase();
|
||||
@@ -66,23 +71,33 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
if (menu.canOpen(user.getPlayer())) completions.add(menu.getId());
|
||||
}
|
||||
}
|
||||
case "dataclear", "wardrobe", "hide", "show", "emote" -> {
|
||||
case "dataclear", "hide", "show", "hiddenreasons", "clearhiddenreasons" -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
completions.add(player.getName());
|
||||
}
|
||||
}
|
||||
case "disableall" -> {
|
||||
completions.add("true");
|
||||
completions.add("false");
|
||||
}
|
||||
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" -> {
|
||||
for (CosmeticSlot slot : user.getDyeableSlots()) {
|
||||
completions.add(slot.name());
|
||||
completions.add(slot.toString());
|
||||
}
|
||||
}
|
||||
case "setlocation" -> {
|
||||
completions.add("wardrobelocation");
|
||||
completions.add("viewerlocation");
|
||||
completions.add("leavelocation");
|
||||
case "setwardrobesetting" -> {
|
||||
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
|
||||
completions.add(wardrobe.getId());
|
||||
}
|
||||
case "playemote" -> {
|
||||
completions.addAll(PlayerAnimator.api.getAnimationManager().getRegistry().keySet());
|
||||
}
|
||||
}
|
||||
StringUtil.copyPartialMatches(args[1], completions, finalCompletions);
|
||||
@@ -93,11 +108,19 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
case "dye" -> {
|
||||
completions.add("#FFFFFF");
|
||||
}
|
||||
case "menu", "apply", "unapply", "playemote" -> {
|
||||
case "menu", "wardrobe", "apply", "unapply" -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
completions.add(player.getName());
|
||||
}
|
||||
}
|
||||
case "setwardrobesetting" -> {
|
||||
completions.add("npclocation");
|
||||
completions.add("viewerlocation");
|
||||
completions.add("leavelocation");
|
||||
completions.add("permission");
|
||||
completions.add("distance");
|
||||
completions.add("defaultmenu");
|
||||
}
|
||||
}
|
||||
StringUtil.copyPartialMatches(args[2], completions, finalCompletions);
|
||||
}
|
||||
@@ -106,8 +129,14 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
String subcommand = args[0].toLowerCase();
|
||||
switch (subcommand) {
|
||||
case "apply" -> {
|
||||
if (Hooks.isActiveHook("HMCColor")) completions.addAll(HMCColorContextKt.getHmcColor().getConfig().getColors().keySet());
|
||||
completions.add("#FFFFFF");
|
||||
}
|
||||
case "setwardrobesetting" -> {
|
||||
if (args[2].equalsIgnoreCase("defaultmenu")) {
|
||||
completions.addAll(Menus.getMenuNames());
|
||||
}
|
||||
}
|
||||
}
|
||||
StringUtil.copyPartialMatches(args[3], completions, finalCompletions);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
|
||||
public class DatabaseSettings {
|
||||
|
||||
//private static final String DATABASE_SETTINGS_PATH = "cosmetic-settings";
|
||||
private static final String DATABASE_TYPE_PATH = "type";
|
||||
private static final String MYSQL_DATABASE_SETTINGS = "mysql";
|
||||
|
||||
@@ -17,18 +17,24 @@ public class DatabaseSettings {
|
||||
private static final String ENABLE_DELAY = "enabled";
|
||||
private static final String DELAY_LENGTH = "delay";
|
||||
|
||||
@Getter
|
||||
private static String databaseType;
|
||||
@Getter
|
||||
private static String database;
|
||||
@Getter
|
||||
private static String password;
|
||||
@Getter
|
||||
private static String host;
|
||||
@Getter
|
||||
private static String username;
|
||||
@Getter
|
||||
private static int port;
|
||||
@Getter
|
||||
private static boolean enabledDelay;
|
||||
@Getter
|
||||
private static int delayLength;
|
||||
|
||||
public static void load(ConfigurationNode source) {
|
||||
//ConfigurationNode databaseSettings = source.node(DATABASE_SETTINGS_PATH);
|
||||
|
||||
databaseType = source.node(DATABASE_TYPE_PATH).getString();
|
||||
|
||||
ConfigurationNode mySql = source.node(MYSQL_DATABASE_SETTINGS);
|
||||
@@ -44,36 +50,4 @@ public class DatabaseSettings {
|
||||
enabledDelay = delay.node(ENABLE_DELAY).getBoolean(false);
|
||||
delayLength = delay.node(DELAY_LENGTH).getInt(2);
|
||||
}
|
||||
|
||||
public static String getDatabaseType() {
|
||||
return databaseType;
|
||||
}
|
||||
|
||||
public static String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public static String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public static String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public static String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public static int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public static boolean isEnabledDelay() {
|
||||
return enabledDelay;
|
||||
}
|
||||
|
||||
public static int getDelayLength() {
|
||||
return delayLength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Settings {
|
||||
@@ -15,17 +19,8 @@ public class Settings {
|
||||
private static final String DEFAULT_MENU = "default-menu";
|
||||
private static final String CONFIG_VERSION = "config-version";
|
||||
private static final String COSMETIC_SETTINGS_PATH = "cosmetic-settings";
|
||||
private static final String REQUIRE_EMPTY_HELMET_PATH = "require-empty-helmet";
|
||||
private static final String REQUIRE_EMPTY_OFF_HAND_PATH = "require-empty-off-hand";
|
||||
private static final String REQUIRE_EMPTY_CHEST_PLATE_PATH = "require-empty-chest-plate";
|
||||
private static final String REQUIRE_EMPTY_PANTS_PATH = "require-empty-pants";
|
||||
private static final String REQUIRE_EMPTY_BOOTS_PATH = "require-empty-boots";
|
||||
private static final String BALLOON_OFFSET = "balloon-offset";
|
||||
private static final String FIRST_PERSON_BACKPACK_MODE = "first-person-backpack-mode";
|
||||
|
||||
private static final transient String LOOK_DOWN_PITCH_PATH = "look-down-backpack-remove";
|
||||
private static final String VIEW_DISTANCE_PATH = "view-distance";
|
||||
private static final String PARTICLE_COUNT = "particle-count";
|
||||
private static final String DYE_MENU_PATH = "dye-menu";
|
||||
private static final String DYE_MENU_NAME = "title";
|
||||
private static final String DYE_MENU_INPUT_SLOT = "input-slot";
|
||||
@@ -34,50 +29,130 @@ public class Settings {
|
||||
private static final String TICK_PERIOD_PATH = "tick-period";
|
||||
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 EMOTE_DISTANCE_PATH = "emote-distance";
|
||||
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
||||
private static final String ITEM_PROCESSING_PATH = "item-processing";
|
||||
private static final String ITEM_PROCESS_DISPLAY_NAME_PATH = "display-name";
|
||||
private static final String ITEM_PROCESS_LORE_PATH = "lore";
|
||||
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
|
||||
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
|
||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||
private static final String HOOK_NEXO_PATH = "nexo";
|
||||
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_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_DISABLED_WORLDS_PATH = "disabled-worlds";
|
||||
private static final String COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH = "backpack-force-riding-packet";
|
||||
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
|
||||
private static final String COSMETIC_BALLOON_HEAD_FORWARD_PATH = "balloon-head-forward";
|
||||
private static final String COSMETIC_OFFHAND_PREVENT_SWAPPING = "offhand-prevent-swapping";
|
||||
private static final String MENU_SETTINGS_PATH = "menu-settings";
|
||||
private static final String MENU_CLICK_COOLDOWN_PATH = "click-cooldown";
|
||||
private static final String MENU_CLICK_COOLDOWN_TIME_PATH = "time";
|
||||
private static final String COSMETIC_TYPE_SETTINGS_PATH = "cosmetic-type";
|
||||
private static final String EQUIP_CLICK_TYPE = "equip-click";
|
||||
private static final String UNEQUIP_CLICK_TYPE = "unequip-click";
|
||||
private static final String DYE_CLICK_TYPE = "dye-click";
|
||||
private static final String SHADING_PATH = "shading";
|
||||
private static final String FIRST_ROW_SHIFT_PATH = "first-row-shift";
|
||||
private static final String SEQUENT_ROW_SHIFT_PATH = "sequent-row-shift";
|
||||
private static final String INDIVIDUAL_COLUMN_SHIFT_PATH = "individual-column-shift";
|
||||
private static final String BACKGROUND_PATH = "background";
|
||||
private static final String CLEAR_BACKGROUND_PATH = "clear-background";
|
||||
private static final String EQUIPPED_COSMETIC_COLOR_PATH = "equipped-cosmetic-color";
|
||||
private static final String EQUIPABLE_COSMETIC_COLOR_PATH = "equipable-cosmetic-color";
|
||||
private static final String LOCKED_COSMETIC_COLOR_PATH = "locked-cosmetic-color";
|
||||
private static final String ENABLED_PATH = "enabled";
|
||||
private static final String SLOT_OPTIONS_PATH = "slot-options";
|
||||
private static final String BACKPACK_PREVENT_DARKNESS_PATH = "backpack-prevent-darkness";
|
||||
private static final String BETTER_HUD_PATH = "betterhud";
|
||||
private static final String BETTER_HUD_HIDE_IN_WARDROBE_PATH = "wardrobe-hide";
|
||||
|
||||
@Getter
|
||||
private static String defaultMenu;
|
||||
@Getter
|
||||
private static String dyeMenuName;
|
||||
@Getter
|
||||
private static int dyeMenuInputSlot;
|
||||
@Getter
|
||||
private static int dyeMenuOutputSlot;
|
||||
@Getter
|
||||
private static int configVersion;
|
||||
private static boolean requireEmptyHelmet;
|
||||
private static boolean requireEmptyOffHand;
|
||||
private static boolean requireEmptyChestPlate;
|
||||
private static boolean requireEmptyPants;
|
||||
private static boolean requireEmptyBoots;
|
||||
@Getter
|
||||
private static boolean debugMode;
|
||||
@Getter
|
||||
private static boolean unapplyOnDeath;
|
||||
@Getter
|
||||
private static boolean forcePermissionJoin;
|
||||
@Getter
|
||||
private static boolean forceShowOnJoin;
|
||||
@Getter
|
||||
private static boolean itemProcessingDisplayName;
|
||||
@Getter
|
||||
private static boolean itemProcessingLore;
|
||||
@Getter
|
||||
private static boolean itemsAdderChangeReload;
|
||||
@Getter
|
||||
private static boolean nexoChangeReload;
|
||||
@Getter
|
||||
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 emoteDamageLeave;
|
||||
private static boolean emoteInvincible;
|
||||
private static final HashMap<EquipmentSlot, SlotOptionConfig> slotOptions = new HashMap<>();
|
||||
@Getter
|
||||
private static boolean destroyLooseCosmetics;
|
||||
private static int lookDownPitch;
|
||||
@Getter
|
||||
private static boolean preventOffhandSwapping;
|
||||
@Getter
|
||||
private static boolean backpackForceRidingEnabled;
|
||||
@Getter
|
||||
private static boolean disabledGamemodesEnabled;
|
||||
@Getter
|
||||
private static boolean balloonHeadForward;
|
||||
@Getter
|
||||
private static boolean backpackPreventDarkness;
|
||||
@Getter
|
||||
private static List<String> disabledGamemodes;
|
||||
@Getter
|
||||
private static List<String> disabledWorlds;
|
||||
@Getter
|
||||
private static int viewDistance;
|
||||
@Getter
|
||||
private static int tickPeriod;
|
||||
private static double emoteDistance;
|
||||
@Getter
|
||||
private static Long defaultMenuCooldown;
|
||||
@Getter
|
||||
private static boolean menuClickCooldown;
|
||||
@Getter
|
||||
private static Vector balloonOffset;
|
||||
@Getter
|
||||
private static String cosmeticEquipClickType;
|
||||
@Getter
|
||||
private static String cosmeticUnEquipClickType;
|
||||
@Getter
|
||||
private static String cosmeticDyeClickType;
|
||||
@Getter
|
||||
private static boolean defaultShading;
|
||||
@Getter
|
||||
private static String firstRowShift;
|
||||
@Getter
|
||||
private static String sequentRowShift;
|
||||
@Getter
|
||||
private static String individualColumnShift;
|
||||
@Getter
|
||||
private static String background;
|
||||
@Getter
|
||||
private static String clearBackground;
|
||||
@Getter
|
||||
private static String equippedCosmeticColor;
|
||||
@Getter
|
||||
private static String equipableCosmeticColor;
|
||||
@Getter
|
||||
private static String lockedCosmeticColor;
|
||||
@Getter @Setter
|
||||
private static boolean allPlayersHidden;
|
||||
@Getter
|
||||
private static boolean wardrobeHideHud;
|
||||
|
||||
|
||||
public static void load(ConfigurationNode source) {
|
||||
|
||||
@@ -96,29 +171,66 @@ public class Settings {
|
||||
|
||||
ConfigurationNode cosmeticSettings = source.node(COSMETIC_SETTINGS_PATH);
|
||||
|
||||
requireEmptyHelmet = cosmeticSettings.node(REQUIRE_EMPTY_HELMET_PATH).getBoolean();
|
||||
requireEmptyOffHand = cosmeticSettings.node(REQUIRE_EMPTY_OFF_HAND_PATH).getBoolean();
|
||||
requireEmptyChestPlate = cosmeticSettings.node(REQUIRE_EMPTY_CHEST_PLATE_PATH).getBoolean();
|
||||
requireEmptyPants = cosmeticSettings.node(REQUIRE_EMPTY_PANTS_PATH).getBoolean();
|
||||
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
|
||||
ConfigurationNode disabledGamemodeSettings = cosmeticSettings.node(DISABLED_GAMEMODE_PATH);
|
||||
disabledGamemodesEnabled = disabledGamemodeSettings.node(ENABLED_PATH).getBoolean(true);
|
||||
try {
|
||||
disabledGamemodes = disabledGamemodeSettings.node(DISABLED_GAMEMODE_GAMEMODES_PATH).getList(String.class);
|
||||
disabledWorlds = cosmeticSettings.node(COSMETIC_DISABLED_WORLDS_PATH).getList(String.class);
|
||||
} catch (Exception e) {
|
||||
disabledGamemodes = new ArrayList<>();
|
||||
disabledWorlds = new ArrayList<>();
|
||||
}
|
||||
|
||||
ConfigurationNode itemProcessingSettings = cosmeticSettings.node(ITEM_PROCESSING_PATH);
|
||||
itemProcessingDisplayName = itemProcessingSettings.node(ITEM_PROCESS_DISPLAY_NAME_PATH).getBoolean(true);
|
||||
itemProcessingLore = itemProcessingSettings.node(ITEM_PROCESS_LORE_PATH).getBoolean(true);
|
||||
|
||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_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);
|
||||
backpackForceRidingEnabled = cosmeticSettings.node(COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH).getBoolean(false);
|
||||
preventOffhandSwapping = cosmeticSettings.node(COSMETIC_OFFHAND_PREVENT_SWAPPING).getBoolean(false);
|
||||
|
||||
cosmeticSettings.node(SLOT_OPTIONS_PATH).childrenMap().forEach((key, value) -> {
|
||||
EquipmentSlot slot = convertConfigToEquipment(key.toString().toLowerCase());
|
||||
if (slot == null) {
|
||||
MessagesUtil.sendDebugMessages("Invalid slot option: " + key, Level.WARNING);
|
||||
return;
|
||||
}
|
||||
boolean addEnchantments = value.node("add-enchantments").getBoolean(false);
|
||||
boolean requireEmpty = value.node("require-empty").getBoolean(false);
|
||||
slotOptions.put(slot, new SlotOptionConfig(slot, addEnchantments, requireEmpty));
|
||||
});
|
||||
|
||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
||||
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt();
|
||||
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt(-3);
|
||||
balloonHeadForward = cosmeticSettings.node(COSMETIC_BALLOON_HEAD_FORWARD_PATH).getBoolean(false);
|
||||
backpackPreventDarkness = cosmeticSettings.node(BACKPACK_PREVENT_DARKNESS_PATH).getBoolean(true);
|
||||
|
||||
ConfigurationNode menuSettings = source.node(MENU_SETTINGS_PATH);
|
||||
|
||||
ConfigurationNode clickCooldownSettings = menuSettings.node(MENU_CLICK_COOLDOWN_PATH);
|
||||
menuClickCooldown = clickCooldownSettings.node(ENABLED_PATH).getBoolean(true);
|
||||
defaultMenuCooldown = clickCooldownSettings.node(MENU_CLICK_COOLDOWN_TIME_PATH).getLong(1000L);
|
||||
|
||||
ConfigurationNode shadingSettings = menuSettings.node(SHADING_PATH);
|
||||
defaultShading = shadingSettings.node(ENABLED_PATH).getBoolean();
|
||||
firstRowShift = shadingSettings.node(FIRST_ROW_SHIFT_PATH).getString();
|
||||
sequentRowShift = shadingSettings.node(SEQUENT_ROW_SHIFT_PATH).getString();
|
||||
individualColumnShift = shadingSettings.node(INDIVIDUAL_COLUMN_SHIFT_PATH).getString();
|
||||
background = shadingSettings.node(BACKGROUND_PATH).getString();
|
||||
clearBackground = shadingSettings.node(CLEAR_BACKGROUND_PATH).getString();
|
||||
equippedCosmeticColor = shadingSettings.node(EQUIPPED_COSMETIC_COLOR_PATH).getString();
|
||||
equipableCosmeticColor = shadingSettings.node(EQUIPABLE_COSMETIC_COLOR_PATH).getString();
|
||||
lockedCosmeticColor = shadingSettings.node(LOCKED_COSMETIC_COLOR_PATH).getString();
|
||||
|
||||
ConfigurationNode cosmeticTypeSettings = menuSettings.node(COSMETIC_TYPE_SETTINGS_PATH);
|
||||
cosmeticEquipClickType = cosmeticTypeSettings.node(EQUIP_CLICK_TYPE).getString("ANY");
|
||||
cosmeticUnEquipClickType = cosmeticTypeSettings.node(UNEQUIP_CLICK_TYPE).getString("ANY");
|
||||
cosmeticDyeClickType = cosmeticTypeSettings.node(DYE_CLICK_TYPE).getString("ANY");
|
||||
|
||||
final var balloonSection = cosmeticSettings.node(BALLOON_OFFSET);
|
||||
|
||||
balloonOffset = loadVector(balloonSection);
|
||||
|
||||
ConfigurationNode dyeMenuSettings = source.node(DYE_MENU_PATH);
|
||||
@@ -128,9 +240,16 @@ public class Settings {
|
||||
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 nexoSettings = hookSettings.node(HOOK_NEXO_PATH);
|
||||
nexoChangeReload = nexoSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(true);
|
||||
|
||||
ConfigurationNode betterHudSettings = hookSettings.node(BETTER_HUD_PATH);
|
||||
wardrobeHideHud = betterHudSettings.node(BETTER_HUD_HIDE_IN_WARDROBE_PATH).getBoolean(true);
|
||||
|
||||
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.
|
||||
@@ -140,163 +259,13 @@ public class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector loadVector(final ConfigurationNode config) {
|
||||
public static Vector loadVector(final ConfigurationNode config) {
|
||||
return new Vector(config.node("x").getDouble(), config.node("y").getDouble(), config.node("z").getDouble());
|
||||
}
|
||||
|
||||
public static boolean isRequireEmptyHelmet() {
|
||||
return requireEmptyHelmet;
|
||||
}
|
||||
|
||||
public static boolean isRequireEmptyOffHand() {
|
||||
return requireEmptyOffHand;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isRequireEmptyChestPlate() {
|
||||
return requireEmptyChestPlate;
|
||||
}
|
||||
|
||||
public static boolean isRequireEmptyPants() {
|
||||
return requireEmptyPants;
|
||||
}
|
||||
|
||||
public static boolean isRequireEmptyBoots() {
|
||||
return requireEmptyBoots;
|
||||
}
|
||||
|
||||
public static boolean getRequireEmpty(CosmeticSlot slot) {
|
||||
switch (slot) {
|
||||
case HELMET -> {
|
||||
return requireEmptyHelmet;
|
||||
}
|
||||
case CHESTPLATE -> {
|
||||
return requireEmptyChestPlate;
|
||||
}
|
||||
case LEGGINGS -> {
|
||||
return requireEmptyPants;
|
||||
}
|
||||
case BOOTS -> {
|
||||
return requireEmptyBoots;
|
||||
}
|
||||
case OFFHAND -> {
|
||||
return requireEmptyOffHand;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean getRequireEmpty(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case HEAD -> {
|
||||
return requireEmptyHelmet;
|
||||
}
|
||||
case CHEST -> {
|
||||
return requireEmptyChestPlate;
|
||||
}
|
||||
case LEGS -> {
|
||||
return requireEmptyPants;
|
||||
}
|
||||
case FEET -> {
|
||||
return requireEmptyBoots;
|
||||
}
|
||||
case OFF_HAND -> {
|
||||
return requireEmptyOffHand;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Vector getBalloonOffset() {
|
||||
if (balloonOffset == null) HMCCosmeticsPlugin.getInstance().getLogger().info("Shits null");
|
||||
return balloonOffset;
|
||||
}
|
||||
|
||||
public static int getLookDownPitch() {
|
||||
return lookDownPitch;
|
||||
}
|
||||
|
||||
public static int getViewDistance() {
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
public static String getDefaultMenu() {
|
||||
return defaultMenu;
|
||||
}
|
||||
|
||||
public static int getConfigVersion() {
|
||||
return configVersion;
|
||||
}
|
||||
|
||||
public static String getDyeMenuName() {
|
||||
return dyeMenuName;
|
||||
}
|
||||
public static int getDyeMenuInputSlot() { return dyeMenuInputSlot; }
|
||||
public static int getDyeMenuOutputSlot() { return dyeMenuOutputSlot; }
|
||||
|
||||
public static boolean isDebugEnabled() {
|
||||
return debugMode;
|
||||
}
|
||||
public static boolean getItemsAdderReloadChange() {
|
||||
return itemsAdderChangeReload;
|
||||
}
|
||||
|
||||
public static int getTickPeriod() {
|
||||
return tickPeriod;
|
||||
}
|
||||
public static boolean getUnapplyOnDeath() {
|
||||
return unapplyOnDeath;
|
||||
}
|
||||
public static boolean getForcePermissionJoin() {
|
||||
return forcePermissionJoin;
|
||||
}
|
||||
|
||||
public static boolean getDebugMode() {
|
||||
return debugMode;
|
||||
}
|
||||
|
||||
public static double getEmoteDistance() {
|
||||
return emoteDistance;
|
||||
}
|
||||
|
||||
public static boolean getCosmeticEmoteBlockCheck() {
|
||||
return cosmeticEmoteBlockCheck;
|
||||
}
|
||||
|
||||
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 SlotOptionConfig getSlotOption(EquipmentSlot slot) {
|
||||
if (!slotOptions.containsKey(slot)) slotOptions.put(slot, new SlotOptionConfig(slot, false, false));
|
||||
return slotOptions.get(slot);
|
||||
}
|
||||
|
||||
public static void setDebugMode(boolean newSetting) {
|
||||
@@ -308,4 +277,16 @@ public class Settings {
|
||||
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
private static EquipmentSlot convertConfigToEquipment(String slot) {
|
||||
return switch (slot) {
|
||||
case "helmet" -> EquipmentSlot.HEAD;
|
||||
case "chestplate" -> EquipmentSlot.CHEST;
|
||||
case "leggings" -> EquipmentSlot.LEGS;
|
||||
case "boots" -> EquipmentSlot.FEET;
|
||||
case "offhand" -> EquipmentSlot.OFF_HAND;
|
||||
case "mainhand" -> EquipmentSlot.HAND;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
public class SlotOptionConfig {
|
||||
|
||||
@Getter
|
||||
private final EquipmentSlot slot;
|
||||
@Getter
|
||||
private final boolean addEnchantments;
|
||||
@Getter
|
||||
private final boolean requireEmpty;
|
||||
|
||||
public SlotOptionConfig(EquipmentSlot slot, boolean addEnchantments, boolean requireEmpty) {
|
||||
this.slot = slot;
|
||||
this.addEnchantments = addEnchantments;
|
||||
this.requireEmpty = requireEmpty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class Wardrobe {
|
||||
|
||||
@Getter
|
||||
private final String id;
|
||||
@Getter @Setter
|
||||
private int distance;
|
||||
@Getter @Setter @Nullable
|
||||
private String permission;
|
||||
@Getter @Setter
|
||||
private WardrobeLocation location;
|
||||
@Getter @Setter @Nullable
|
||||
private String defaultMenu;
|
||||
|
||||
/**
|
||||
* This creates a Wardrobe object with all the information that a user will need when entering.
|
||||
* @param id The id of the wardrobe
|
||||
* @param location The 3 locations of the Wardrobe, if any of these 3 locations are null, the wardrobe will not work
|
||||
* @param permission The permission required to enter the wardrobe, if null, no permission is required
|
||||
* @param distance The distance from the wardrobe that the player can be to enter, if -1, the player can enter from any distance
|
||||
* @param defaultMenu The default menu that the player will open when entering the wardrobe.
|
||||
*/
|
||||
public Wardrobe(@NotNull String id, @NotNull WardrobeLocation location, @Nullable String permission, int distance, @Nullable String defaultMenu) {
|
||||
this.id = id;
|
||||
this.location = location;
|
||||
this.distance = distance;
|
||||
if (permission != null) this.permission = permission;
|
||||
if (defaultMenu != null) this.defaultMenu = defaultMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if the wardrobe has a permission. If it's null, no permission is required and will return false. If it's not null, it will return true.
|
||||
* @return if the wardrobe has a permission
|
||||
*/
|
||||
public boolean hasPermission() {
|
||||
return permission != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates if a player can enter a wardrobe. Will return true if the player can enter, else false.
|
||||
* @param user The user that is trying to enter the wardrobe
|
||||
* @return if the player can enter the wardrobe
|
||||
*/
|
||||
public boolean canEnter(@NotNull CosmeticUser user) {
|
||||
Location wardrobeLocation = location.getNpcLocation();
|
||||
Location location = user.getEntity().getLocation();
|
||||
if (wardrobeLocation == null) return false;
|
||||
if (distance <= 0) return true;
|
||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||
return wardrobeLocation.distanceSquared(location) <= distance * distance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class WardrobeLocation {
|
||||
|
||||
@Getter @Setter
|
||||
private Location npcLocation;
|
||||
@Getter @Setter
|
||||
private Location viewerLocation;
|
||||
@Getter @Setter
|
||||
private Location leaveLocation;
|
||||
|
||||
/**
|
||||
* This creates a WardrobeLocation object with the 3 locations that are required for a wardrobe to work
|
||||
* @param npcLocation The location of the NPC
|
||||
* @param viewerLocation The location of the viewer
|
||||
* @param leaveLocation The location that the player will be teleported to when they leave the wardrobe if return-last-location in the config is false
|
||||
*/
|
||||
public WardrobeLocation(@Nullable Location npcLocation, @Nullable Location viewerLocation, @Nullable Location leaveLocation) {
|
||||
this.npcLocation = npcLocation;
|
||||
this.viewerLocation = viewerLocation;
|
||||
this.leaveLocation = leaveLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if any of the locations are null
|
||||
* @return true if all locations are not null, else false
|
||||
*/
|
||||
public boolean hasAllLocations() {
|
||||
return npcLocation != null && viewerLocation != null && leaveLocation != null;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,50 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.LocationSerializer;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
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 {
|
||||
|
||||
private static final String WARDROBE_PATH = "wardrobe";
|
||||
private static final String DISABLE_ON_DAMAGE_PATH = "disable-on-damage";
|
||||
private static final String DISPLAY_RADIUS_PATH = "display-radius";
|
||||
private static final String PORTABLE_PATH = "portable";
|
||||
private static final String ALWAYS_DISPLAY_PATH = "always-display";
|
||||
private static final String STATIC_RADIUS_PATH = "static-radius";
|
||||
private static final String ROTATION_SPEED_PATH = "rotation-speed";
|
||||
private static final String SPAWN_DELAY_PATH = "spawn-delay";
|
||||
private static final String DESPAWN_DELAY_PATH = "despawn-delay";
|
||||
private static final String APPLY_COSMETICS_ON_CLOSE = "apply-cosmetics-on-close";
|
||||
private static final String OPEN_SOUND = "open-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 LEAVE_LOCATION_PATH = "leave-location";
|
||||
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 DAMAGE_KICK_PATH = "damage-kicked";
|
||||
private static final String PREVENT_DAMAGE_PATH = "prevent-damage";
|
||||
|
||||
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 WARDROBE_DEFAULT_MENU = "default-menu";
|
||||
private static final String BOSSBAR_PATH = "bossbar";
|
||||
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
||||
private static final String BOSSBAR_TEXT_PATH = "text";
|
||||
@@ -48,41 +60,65 @@ public class WardrobeSettings {
|
||||
private static final String TRANSITION_FADE_OUT_PATH = "title-fade-out";
|
||||
|
||||
private static ConfigurationNode configRoot;
|
||||
@Getter
|
||||
private static boolean disableOnDamage;
|
||||
private static int displayRadius;
|
||||
@Getter
|
||||
private static boolean portable;
|
||||
@Getter
|
||||
private static boolean alwaysDisplay;
|
||||
private static int staticRadius;
|
||||
@Getter
|
||||
private static int rotationSpeed;
|
||||
@Getter
|
||||
private static int spawnDelay;
|
||||
@Getter
|
||||
private static int despawnDelay;
|
||||
@Getter
|
||||
private static float bossbarProgress;
|
||||
@Getter
|
||||
private static boolean applyCosmeticsOnClose;
|
||||
@Getter
|
||||
private static boolean tryCosmeticsInWardrobe;
|
||||
@Getter
|
||||
private static boolean equipPumpkin;
|
||||
@Getter
|
||||
private static boolean returnLastLocation;
|
||||
@Getter
|
||||
private static boolean enabledBossbar;
|
||||
@Getter
|
||||
private static boolean enterOpenMenu;
|
||||
@Getter
|
||||
private static boolean forceExitGamemode;
|
||||
@Getter
|
||||
private static boolean damagedKicked;
|
||||
@Getter
|
||||
private static boolean preventDamage;
|
||||
@Getter
|
||||
private static GameMode exitGamemode;
|
||||
private static Location wardrobeLocation;
|
||||
private static Location viewerLocation;
|
||||
private static Location leaveLocation;
|
||||
private static HashMap<String, Wardrobe> wardrobes;
|
||||
@Getter
|
||||
private static String bossbarMessage;
|
||||
@Getter
|
||||
private static BossBar.Overlay bossbarOverlay;
|
||||
@Getter
|
||||
private static BossBar.Color bossbarColor;
|
||||
@Getter
|
||||
private static boolean enabledTransition;
|
||||
@Getter
|
||||
private static String transitionText;
|
||||
@Getter
|
||||
private static int transitionDelay;
|
||||
@Getter
|
||||
private static int transitionFadeIn;
|
||||
@Getter
|
||||
private static int transitionStay;
|
||||
@Getter
|
||||
private static int transitionFadeOut;
|
||||
|
||||
public static void load(ConfigurationNode source) {
|
||||
configRoot = source;
|
||||
|
||||
disableOnDamage = source.node(DISABLE_ON_DAMAGE_PATH).getBoolean();
|
||||
displayRadius = source.node(DISPLAY_RADIUS_PATH).getInt();
|
||||
portable = source.node(PORTABLE_PATH).getBoolean();
|
||||
staticRadius = source.node(STATIC_RADIUS_PATH).getInt();
|
||||
alwaysDisplay = source.node(ALWAYS_DISPLAY_PATH).getBoolean();
|
||||
rotationSpeed = source.node(ROTATION_SPEED_PATH).getInt();
|
||||
spawnDelay = source.node(SPAWN_DELAY_PATH).getInt();
|
||||
@@ -90,6 +126,12 @@ public class WardrobeSettings {
|
||||
applyCosmeticsOnClose = source.node(APPLY_COSMETICS_ON_CLOSE).getBoolean();
|
||||
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
||||
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
||||
tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false);
|
||||
damagedKicked = source.node(DAMAGE_KICK_PATH).getBoolean(false);
|
||||
preventDamage = source.node(PREVENT_DAMAGE_PATH).getBoolean(true);
|
||||
|
||||
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);
|
||||
@@ -119,183 +161,135 @@ public class WardrobeSettings {
|
||||
transitionStay = transitionNode.node(TRANSITION_STAY_PATH).getInt(2000);
|
||||
transitionFadeOut = transitionNode.node(TRANSITION_FADE_OUT_PATH).getInt(2000);
|
||||
|
||||
wardrobes = new HashMap<>();
|
||||
for (ConfigurationNode wardrobesNode : source.node(WARDROBES_PATH).childrenMap().values()) {
|
||||
String id = wardrobesNode.key().toString();
|
||||
try {
|
||||
wardrobeLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(STATIC_LOCATION_PATH));
|
||||
MessagesUtil.sendDebugMessages("Wardrobe Location: " + wardrobeLocation);
|
||||
viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(VIEWER_LOCATION_PATH));
|
||||
Location npcLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(NPC_LOCATION_PATH));
|
||||
MessagesUtil.sendDebugMessages("Wardrobe Location: " + npcLocation);
|
||||
Location viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(VIEWER_LOCATION_PATH));
|
||||
MessagesUtil.sendDebugMessages("Viewer Location: " + viewerLocation);
|
||||
leaveLocation = Utils.replaceIfNull(LocationSerializer.INSTANCE.deserialize(Location.class, source.node(LEAVE_LOCATION_PATH)), viewerLocation);
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
Location leaveLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(LEAVE_LOCATION_PATH));
|
||||
if (leaveLocation == null) leaveLocation = viewerLocation;
|
||||
MessagesUtil.sendDebugMessages("Leave Location: " + leaveLocation);
|
||||
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
||||
|
||||
String permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
||||
String defaultMenu = wardrobesNode.node(WARDROBE_DEFAULT_MENU).getString();
|
||||
int distance = wardrobesNode.node(DISTANCE_PATH).getInt(-1);
|
||||
|
||||
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance, defaultMenu);
|
||||
addWardrobe(wardrobe);
|
||||
} catch (Exception e) {
|
||||
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getDisableOnDamage() {
|
||||
return disableOnDamage;
|
||||
public static Wardrobe getWardrobe(String key) {
|
||||
return wardrobes.get(key);
|
||||
}
|
||||
|
||||
public static int getDisplayRadius() {
|
||||
return displayRadius;
|
||||
public static Set<String> getWardrobeNames() {
|
||||
return wardrobes.keySet();
|
||||
}
|
||||
|
||||
public static boolean isPortable() {
|
||||
return portable;
|
||||
public static Collection<Wardrobe> getWardrobes() {
|
||||
return wardrobes.values();
|
||||
}
|
||||
|
||||
public static boolean isAlwaysDisplay() {
|
||||
return alwaysDisplay;
|
||||
public static void addWardrobe(Wardrobe wardrobe) {
|
||||
wardrobes.put(wardrobe.getId(), wardrobe);
|
||||
}
|
||||
|
||||
public static int getStaticRadius() {
|
||||
return staticRadius;
|
||||
public static void removeWardrobe(String id) {
|
||||
wardrobes.remove(id);
|
||||
}
|
||||
|
||||
public static int getRotationSpeed() {
|
||||
return rotationSpeed;
|
||||
}
|
||||
|
||||
public static int getSpawnDelay() {
|
||||
return spawnDelay;
|
||||
}
|
||||
|
||||
public static int getDespawnDelay() {
|
||||
return despawnDelay;
|
||||
}
|
||||
|
||||
public static boolean isApplyCosmeticsOnClose() {
|
||||
return applyCosmeticsOnClose;
|
||||
}
|
||||
public static boolean isEquipPumpkin() {
|
||||
return equipPumpkin;
|
||||
}
|
||||
public static boolean isReturnLastLocation() {
|
||||
return returnLastLocation;
|
||||
}
|
||||
|
||||
public static Location getWardrobeLocation() {
|
||||
return wardrobeLocation.clone();
|
||||
}
|
||||
|
||||
public static Location getViewerLocation() {
|
||||
return viewerLocation;
|
||||
}
|
||||
|
||||
public static Location getLeaveLocation() {
|
||||
return leaveLocation;
|
||||
}
|
||||
|
||||
public static boolean inDistanceOfWardrobe(final Location wardrobeLocation, final Location playerLocation) {
|
||||
if (displayRadius == -1) return true;
|
||||
if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false;
|
||||
return playerLocation.distanceSquared(wardrobeLocation) <= displayRadius * displayRadius;
|
||||
}
|
||||
|
||||
public static boolean inDistanceOfStatic(final Location location) {
|
||||
if (wardrobeLocation == null) return false;
|
||||
if (staticRadius == -1) return true;
|
||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||
return wardrobeLocation.distanceSquared(location) <= staticRadius * staticRadius;
|
||||
}
|
||||
|
||||
public static boolean getEnabledBossbar() {
|
||||
return enabledBossbar;
|
||||
}
|
||||
|
||||
public static float getBossbarProgress() {
|
||||
return bossbarProgress;
|
||||
}
|
||||
|
||||
public static String getBossbarText() {
|
||||
return bossbarMessage;
|
||||
}
|
||||
|
||||
public static BossBar.Overlay getBossbarOverlay() {
|
||||
return bossbarOverlay;
|
||||
}
|
||||
|
||||
public static BossBar.Color getBossbarColor() {
|
||||
return bossbarColor;
|
||||
}
|
||||
public static boolean isEnabledTransition() {
|
||||
return enabledTransition;
|
||||
}
|
||||
|
||||
public static String getTransitionText() {
|
||||
return transitionText;
|
||||
}
|
||||
|
||||
public static int getTransitionDelay() {
|
||||
return transitionDelay;
|
||||
}
|
||||
public static int getTransitionFadeIn() {
|
||||
return transitionFadeIn;
|
||||
}
|
||||
public static int getTransitionStay() {
|
||||
return transitionStay;
|
||||
}
|
||||
public static int getTransitionFadeOut() {
|
||||
return transitionFadeOut;
|
||||
}
|
||||
|
||||
public static boolean isForceExitGamemode() {
|
||||
return forceExitGamemode;
|
||||
}
|
||||
|
||||
public static GameMode getExitGamemode() {
|
||||
return exitGamemode;
|
||||
}
|
||||
|
||||
public static void setWardrobeLocation(Location newLocation) {
|
||||
wardrobeLocation = newLocation;
|
||||
|
||||
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());
|
||||
/**
|
||||
* Sets where the NPC/Mannequin will spawn in the wardrobe
|
||||
* @param newLocation
|
||||
*/
|
||||
|
||||
HMCCosmeticsPlugin.getInstance().saveConfig();
|
||||
}
|
||||
|
||||
public static void setViewerLocation(Location newLocation) {
|
||||
viewerLocation = newLocation;
|
||||
public static void setNPCLocation(Wardrobe wardrobe, Location newLocation) {
|
||||
wardrobe.getLocation().setNpcLocation(newLocation);
|
||||
|
||||
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());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "world", newLocation.getWorld().getName());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "x", newLocation.getX());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "y", newLocation.getY());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "z", newLocation.getZ());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "yaw", newLocation.getYaw());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "pitch", newLocation.getPitch());
|
||||
|
||||
HMCCosmeticsPlugin.getInstance().saveConfig();
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
public static void setLeaveLocation(Location newLocation) {
|
||||
leaveLocation = newLocation;
|
||||
/**
|
||||
* 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.leave-location." + "world", newLocation.getWorld().getName());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "x", newLocation.getX());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "y", newLocation.getY());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "z", newLocation.getZ());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "yaw", newLocation.getYaw());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "pitch", newLocation.getPitch());
|
||||
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());
|
||||
|
||||
HMCCosmeticsPlugin.getInstance().saveConfig();
|
||||
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();
|
||||
}
|
||||
|
||||
public static void setWardrobeDefaultMenu(Wardrobe wardrobe, String defaultMenu) {
|
||||
wardrobe.setDefaultMenu(defaultMenu);
|
||||
|
||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".default-menu", defaultMenu);
|
||||
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.config.serializer;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.serialize.TypeSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemSerializer implements TypeSerializer<ItemStack> {
|
||||
|
||||
public static final ItemSerializer INSTANCE = new ItemSerializer();
|
||||
private static final String MATERIAL = "material";
|
||||
private static final String AMOUNT = "amount";
|
||||
private static final String NAME = "name";
|
||||
private static final String UNBREAKABLE = "unbreakable";
|
||||
private static final String GLOWING = "glowing";
|
||||
private static final String LORE = "lore";
|
||||
private static final String MODEL_DATA = "model-data";
|
||||
private static final String NBT_TAGS = "nbt-tag";
|
||||
private static final String ENCHANTS = "enchants";
|
||||
private static final String ITEM_FLAGS = "item-flags";
|
||||
private static final String TEXTURE = "texture";
|
||||
private static final String OWNER = "owner";
|
||||
private static final String COLOR = "color";
|
||||
private static final String RED = "red";
|
||||
private static final String GREEN = "green";
|
||||
private static final String BLUE = "blue";
|
||||
|
||||
private ItemSerializer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack deserialize(final Type type, final ConfigurationNode source)
|
||||
throws SerializationException {
|
||||
final ConfigurationNode materialNode = source.node(MATERIAL);
|
||||
final ConfigurationNode amountNode = source.node(AMOUNT);
|
||||
final ConfigurationNode nameNode = source.node(NAME);
|
||||
final ConfigurationNode unbreakableNode = source.node(UNBREAKABLE);
|
||||
final ConfigurationNode glowingNode = source.node(GLOWING);
|
||||
final ConfigurationNode loreNode = source.node(LORE);
|
||||
final ConfigurationNode modelDataNode = source.node(MODEL_DATA);
|
||||
final ConfigurationNode nbtNode = source.node(NBT_TAGS);
|
||||
final ConfigurationNode enchantsNode = source.node(ENCHANTS);
|
||||
final ConfigurationNode itemFlagsNode = source.node(ITEM_FLAGS);
|
||||
final ConfigurationNode textureNode = source.node(TEXTURE);
|
||||
final ConfigurationNode ownerNode = source.node(OWNER);
|
||||
final ConfigurationNode colorNode = source.node(COLOR);
|
||||
final ConfigurationNode redNode = colorNode.node(RED);
|
||||
final ConfigurationNode greenNode = colorNode.node(GREEN);
|
||||
final ConfigurationNode blueNode = colorNode.node(BLUE);
|
||||
|
||||
if (materialNode.virtual()) return null;
|
||||
|
||||
String material = materialNode.getString();
|
||||
|
||||
ItemStack item = Hooks.getItem(material);
|
||||
if (item == null) {
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().severe("Invalid Material -> " + material);
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
item.setAmount(amountNode.getInt(1));
|
||||
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (itemMeta == null) return item;
|
||||
if (!nameNode.virtual())
|
||||
itemMeta.setDisplayName(StringUtils.parseStringToString(Utils.replaceIfNull(nameNode.getString(), "")));
|
||||
if (!unbreakableNode.virtual()) itemMeta.setUnbreakable(unbreakableNode.getBoolean());
|
||||
if (!glowingNode.virtual()) {
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
itemMeta.addEnchant(Enchantment.LUCK, 1, true);
|
||||
}
|
||||
if (!loreNode.virtual()) itemMeta.setLore(Utils.replaceIfNull(loreNode.getList(String.class),
|
||||
new ArrayList<String>()).
|
||||
stream().map(StringUtils::parseStringToString).collect(Collectors.toList()));
|
||||
if (!modelDataNode.virtual()) itemMeta.setCustomModelData(modelDataNode.getInt());
|
||||
|
||||
if (!nbtNode.virtual()) {
|
||||
for (ConfigurationNode nbtNodes : nbtNode.childrenMap().values()) {
|
||||
itemMeta.getPersistentDataContainer().set(NamespacedKey.minecraft(nbtNodes.key().toString()), PersistentDataType.STRING, nbtNodes.getString());
|
||||
}
|
||||
}
|
||||
|
||||
if (!enchantsNode.virtual()) {
|
||||
for (ConfigurationNode enchantNode : enchantsNode.childrenMap().values()) {
|
||||
if (Enchantment.getByKey(NamespacedKey.minecraft(enchantNode.key().toString())) == null) continue;
|
||||
itemMeta.addEnchant(Enchantment.getByKey(NamespacedKey.minecraft(enchantNode.key().toString())), enchantNode.getInt(1), true);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!itemFlagsNode.virtual()) {
|
||||
for (String itemFlag : itemFlagsNode.getList(String.class)) {
|
||||
if (!EnumUtils.isValidEnum(ItemFlag.class, itemFlag)) continue;
|
||||
MessagesUtil.sendDebugMessages("Added " + itemFlag + " to the item!");
|
||||
itemMeta.addItemFlags(ItemFlag.valueOf(itemFlag));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (item.getType() == Material.PLAYER_HEAD) {
|
||||
SkullMeta skullMeta = (SkullMeta) itemMeta;
|
||||
if (!ownerNode.virtual()) {
|
||||
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(ownerNode.getString()));
|
||||
}
|
||||
|
||||
if (!textureNode.virtual()) {
|
||||
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
|
||||
+ textureNode.getString() + "\"}]}}}");
|
||||
itemMeta = skullMeta;
|
||||
}
|
||||
}
|
||||
|
||||
if (!colorNode.virtual()) {
|
||||
if (ColorBuilder.canBeColored(item.getType())) {
|
||||
if (!redNode.virtual()) {
|
||||
itemMeta = ColorBuilder.color(itemMeta, Color.fromRGB(redNode.getInt(0), greenNode.getInt(0), blueNode.getInt(0)));
|
||||
} else {
|
||||
itemMeta = ColorBuilder.color(itemMeta, ServerUtils.hex2Rgb(colorNode.getString("#FFFFFF")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
@Override
|
||||
public void serialize(final Type type, @Nullable final ItemStack obj, final ConfigurationNode node) throws SerializationException {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.config.serializer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.serialize.TypeSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class LocationSerializer implements TypeSerializer<Location> {
|
||||
|
||||
public static final LocationSerializer INSTANCE = new LocationSerializer();
|
||||
|
||||
private static final String WORLD = "world";
|
||||
private static final String X = "x";
|
||||
private static final String Y = "y";
|
||||
private static final String Z = "z";
|
||||
private static final String PITCH = "pitch";
|
||||
private static final String YAW = "yaw";
|
||||
|
||||
|
||||
private LocationSerializer() {}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Location deserialize(final Type type, final ConfigurationNode source) throws SerializationException {
|
||||
final World world = Bukkit.getWorld(source.node(WORLD).getString());
|
||||
if (world == null) return null;
|
||||
return new Location(
|
||||
world,
|
||||
source.node(X).getDouble(),
|
||||
source.node(Y).getDouble(),
|
||||
source.node(Z).getDouble(),
|
||||
source.node(YAW).getFloat(),
|
||||
source.node(PITCH).getFloat()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(final Type type, @Nullable final Location loc, final ConfigurationNode source) throws SerializationException {
|
||||
// Empty
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,69 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.behavior.CosmeticUpdateBehavior;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class Cosmetic {
|
||||
protected static ItemStack UNDEFINED_DISPLAY_ITEM_STACK;
|
||||
|
||||
static {
|
||||
UNDEFINED_DISPLAY_ITEM_STACK = new ItemStack(Material.BARRIER);
|
||||
|
||||
ItemMeta meta = UNDEFINED_DISPLAY_ITEM_STACK.getItemMeta();
|
||||
if (meta != null) {
|
||||
// Legacy methods for Spigot >:(
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&cUndefined Item Display"));
|
||||
meta.setLore(List.of(
|
||||
ChatColor.translateAlternateColorCodes('&', "&cPlease check your configurations & console to"),
|
||||
ChatColor.translateAlternateColorCodes('&', "&censure there are no errors.")));
|
||||
}
|
||||
UNDEFINED_DISPLAY_ITEM_STACK.setItemMeta(meta);
|
||||
}
|
||||
|
||||
/** Identifier of the cosmetic. */
|
||||
private String id;
|
||||
private String permission;
|
||||
private ItemStack item;
|
||||
private CosmeticSlot slot;
|
||||
private boolean dyable;
|
||||
|
||||
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
|
||||
/** Permission to use the cosmetic. */
|
||||
private String permission;
|
||||
|
||||
/** The display {@link ItemStack} of the cosmetic. */
|
||||
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
|
||||
private ItemStack item;
|
||||
|
||||
/** The material string of the cosmetic. */
|
||||
private String material;
|
||||
|
||||
/** The {@link CosmeticSlot} this cosmetic occupies. */
|
||||
private CosmeticSlot slot;
|
||||
|
||||
/** Whether the cosmetic is dyeable or not. */
|
||||
private boolean dyeable;
|
||||
|
||||
/** The config for the cosmetic */
|
||||
private ConfigurationNode config;
|
||||
|
||||
protected Cosmetic(@NotNull String id, @NotNull ConfigurationNode config) {
|
||||
this.id = id;
|
||||
this.config = config;
|
||||
|
||||
if (!config.node("permission").virtual()) {
|
||||
this.permission = config.node("permission").getString();
|
||||
@@ -29,61 +71,68 @@ public abstract class Cosmetic {
|
||||
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();
|
||||
try {
|
||||
this.item = generateItemStack(config.node("item"));
|
||||
} catch(Exception ex) {
|
||||
MessagesUtil.sendDebugMessages("Forcing %s to use undefined display".formatted(getId()));
|
||||
this.item = UNDEFINED_DISPLAY_ITEM_STACK;
|
||||
}
|
||||
}
|
||||
|
||||
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
|
||||
this.slot = CosmeticSlot.valueOf(config.node("slot").getString());
|
||||
|
||||
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
|
||||
setDyable(config.node("dyeable").getBoolean(false));
|
||||
|
||||
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
|
||||
Cosmetics.addCosmetic(this);
|
||||
this.dyeable = config.node("dyeable").getBoolean(false);
|
||||
MessagesUtil.sendDebugMessages("Dyeable " + dyeable);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
protected Cosmetic(String id, String permission, ItemStack item, String material, CosmeticSlot slot, boolean dyeable) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public CosmeticSlot getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
|
||||
public void setSlot(CosmeticSlot slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return this.permission;
|
||||
}
|
||||
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
this.item = item;
|
||||
this.material = material;
|
||||
this.slot = slot;
|
||||
this.dyeable = dyeable;
|
||||
}
|
||||
|
||||
public boolean requiresPermission() {
|
||||
return permission != null;
|
||||
}
|
||||
|
||||
public void setDyable(boolean dyable) {
|
||||
this.dyable = dyable;
|
||||
/**
|
||||
* Dispatched when an update is requested upon the cosmetic. Instead, you should use {@link CosmeticUser#updateCosmetic(CosmeticSlot)})}
|
||||
* @param user the user to preform the update against
|
||||
*/
|
||||
@Deprecated(since = "2.8.2")
|
||||
public void update(CosmeticUser user) {
|
||||
if(this instanceof CosmeticUpdateBehavior behavior) {
|
||||
behavior.dispatchUpdate(user);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDyable() {
|
||||
return this.dyable;
|
||||
/**
|
||||
* Action preformed on the update. Instead, you should use {@link CosmeticUser#updateCosmetic(CosmeticSlot)})}
|
||||
* @param user the user to preform the update against
|
||||
*/
|
||||
@Deprecated(since = "2.8.2")
|
||||
protected void doUpdate(final CosmeticUser user) {
|
||||
// #update should be the preferred way of interacting with this api now.
|
||||
this.update(user);
|
||||
}
|
||||
|
||||
public abstract void update(CosmeticUser user);
|
||||
|
||||
@Nullable
|
||||
public ItemStack getItem() {
|
||||
if (item == null) return null;
|
||||
return item.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an {@link ItemStack} from a {@link ConfigurationNode}.
|
||||
* @param config the configuration node
|
||||
* @return the {@link ItemStack}
|
||||
*/
|
||||
protected ItemStack generateItemStack(ConfigurationNode config) {
|
||||
try {
|
||||
ItemStack item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config);
|
||||
@@ -97,4 +146,14 @@ public abstract class Cosmetic {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* While cosmetics registered in HMCC are made through a configuration, cosmetics registered from other plugins
|
||||
* may not and instead opt for {@link Cosmetic#Cosmetic(String, String, ItemStack, String, CosmeticSlot, boolean)}, which doesn't use a config.
|
||||
* This should be used only for reference.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public @Nullable ConfigurationNode getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents any object that can wear/hold cosmetics,
|
||||
* users, for example.
|
||||
*/
|
||||
public interface CosmeticHolder {
|
||||
@Nullable Cosmetic getCosmetic(@NotNull CosmeticSlot slot);
|
||||
|
||||
@NotNull ImmutableCollection<Cosmetic> getCosmetics();
|
||||
|
||||
void addCosmetic(@NotNull Cosmetic cosmetic, @Nullable Color color);
|
||||
|
||||
default void addCosmetic(@NotNull Cosmetic cosmetic) {
|
||||
addCosmetic(cosmetic, null);
|
||||
}
|
||||
|
||||
default void removeCosmetics() {
|
||||
// Small optimization could be made, but Concurrent modification prevents us from both getting and removing
|
||||
for (CosmeticSlot slot : CosmeticSlot.values().values()) {
|
||||
removeCosmeticSlot(slot);
|
||||
}
|
||||
}
|
||||
|
||||
void removeCosmeticSlot(@NotNull CosmeticSlot slot);
|
||||
|
||||
default void removeCosmeticSlot(@NotNull Cosmetic cosmetic) {
|
||||
removeCosmeticSlot(cosmetic.getSlot());
|
||||
}
|
||||
|
||||
default boolean hasCosmeticInSlot(@NotNull CosmeticSlot slot) {
|
||||
return getCosmetic(slot) != null;
|
||||
}
|
||||
|
||||
default boolean hasCosmeticInSlot(@NotNull Cosmetic cosmetic) {
|
||||
final var existingCosmetic = getCosmetic(cosmetic.getSlot());
|
||||
if (existingCosmetic == null) return false;
|
||||
return Objects.equals(cosmetic.getId(), existingCosmetic.getId());
|
||||
}
|
||||
|
||||
default boolean canEquipCosmetic(@NotNull Cosmetic cosmetic) {
|
||||
return canEquipCosmetic(cosmetic, false);
|
||||
}
|
||||
|
||||
boolean canEquipCosmetic(@NotNull Cosmetic cosmetic, boolean ignoreWardrobe);
|
||||
|
||||
boolean updateCosmetic(@NotNull CosmeticSlot slot);
|
||||
|
||||
boolean updateMovementCosmetic(@NotNull CosmeticSlot slot, final Location from, final Location to);
|
||||
|
||||
/**
|
||||
* Just for backwards compatibility, ensures that the given viewer and the given cosmetic holder
|
||||
* represent the same user.
|
||||
*
|
||||
* @param viewer the viewer
|
||||
* @param cosmeticHolder the cosmetic holder
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
static @NotNull CosmeticUser ensureSingleCosmeticUser(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder) {
|
||||
if (!(cosmeticHolder instanceof CosmeticUser user) || !user.getUniqueId().equals(viewer.getUniqueId())) {
|
||||
throw new IllegalStateException("This method does not support having a different viewer than" +
|
||||
" the same cosmetic holder. Needs to be updated to support the overload that takes a viewer and" +
|
||||
" a cosmetic holder instead of a single CosmeticUser.");
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* Allow custom implementations of a {@link Cosmetic}.
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class CosmeticProvider {
|
||||
protected static final Map<CosmeticSlot, BiFunction<String, ConfigurationNode, Cosmetic>> MAPPINGS = Map.ofEntries(
|
||||
Map.entry(CosmeticSlot.HELMET, CosmeticArmorType::new),
|
||||
Map.entry(CosmeticSlot.CHESTPLATE, CosmeticArmorType::new),
|
||||
Map.entry(CosmeticSlot.LEGGINGS, CosmeticArmorType::new),
|
||||
Map.entry(CosmeticSlot.BOOTS, CosmeticArmorType::new),
|
||||
Map.entry(CosmeticSlot.OFFHAND, CosmeticArmorType::new),
|
||||
|
||||
Map.entry(CosmeticSlot.BACKPACK, CosmeticBackpackType::new),
|
||||
|
||||
Map.entry(CosmeticSlot.BALLOON, CosmeticBalloonType::new)
|
||||
);
|
||||
|
||||
private static final String EXCEPTION_MESSAGE = "Unknown slot %s provided for mapping, if you registered your own CosmeticSlot please ensure that you've also registered a custom CosmeticProvider! Or if you have already registered a custom CosmeticProvider ensure it is registered in your plugins `onLoad` method instead of `onEnable`!";
|
||||
|
||||
/**
|
||||
* Construct the {@link Cosmetic}.
|
||||
* @param id the cosmetic id
|
||||
* @param config the configuration node of the cosmetic
|
||||
* @param slot the occupying slot of the cosmetic
|
||||
* @return the {@link Cosmetic}
|
||||
* @throws IllegalArgumentException if the provided cosmetic could not be mapped
|
||||
*/
|
||||
public @NotNull Cosmetic createCosmetic(String id, ConfigurationNode config, CosmeticSlot slot) throws IllegalArgumentException {
|
||||
final var mapper = MAPPINGS.get(slot);
|
||||
if(mapper == null) {
|
||||
throw new IllegalArgumentException(
|
||||
EXCEPTION_MESSAGE.formatted(slot)
|
||||
);
|
||||
}
|
||||
|
||||
return mapper.apply(id, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the plugin that is providing this {@link CosmeticProvider}
|
||||
* @return the plugin
|
||||
*/
|
||||
public abstract Plugin getProviderPlugin();
|
||||
|
||||
/**
|
||||
* Default Implementation.
|
||||
*/
|
||||
static class Default extends CosmeticProvider {
|
||||
public static final CosmeticProvider INSTANCE = new Default();
|
||||
|
||||
@Override
|
||||
public Plugin getProviderPlugin() {
|
||||
return HMCCosmeticsPlugin.getInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,81 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
public enum CosmeticSlot {
|
||||
HELMET,
|
||||
CHESTPLATE,
|
||||
LEGGINGS,
|
||||
BOOTS,
|
||||
MAINHAND,
|
||||
OFFHAND,
|
||||
BACKPACK,
|
||||
BALLOON,
|
||||
EMOTE
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Getter
|
||||
public class CosmeticSlot {
|
||||
private static final ConcurrentHashMap<String, CosmeticSlot> REGISTRY = new ConcurrentHashMap<>();
|
||||
|
||||
public static final CosmeticSlot HELMET = register("HELMET");
|
||||
public static final CosmeticSlot CHESTPLATE = register("CHESTPLATE");
|
||||
public static final CosmeticSlot LEGGINGS = register("LEGGINGS");
|
||||
public static final CosmeticSlot BOOTS = register("BOOTS");
|
||||
public static final CosmeticSlot MAINHAND = register("MAINHAND");
|
||||
public static final CosmeticSlot OFFHAND = register("OFFHAND");
|
||||
public static final CosmeticSlot BACKPACK = register("BACKPACK");
|
||||
public static final CosmeticSlot BALLOON = register("BALLOON");
|
||||
|
||||
private final String name;
|
||||
|
||||
private CosmeticSlot(@NotNull String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new slot with the given name. If a slot with the given name already exists, it will be returned.
|
||||
* @param name The name of the slot (This will automatically be converted into all UPPERCASE)
|
||||
* @return The slot that was registered or already exists.
|
||||
* @throws IllegalArgumentException if a cosmetic slot by that name has already been registered
|
||||
*/
|
||||
@NotNull
|
||||
public static CosmeticSlot register(@NotNull String name) {
|
||||
final String upperName = name.toUpperCase();
|
||||
if(REGISTRY.containsKey(upperName)) {
|
||||
throw new IllegalArgumentException("A cosmetic slot with name '" + name + "' is already registered.");
|
||||
}
|
||||
|
||||
final CosmeticSlot slot = new CosmeticSlot(upperName);
|
||||
REGISTRY.put(upperName, slot);
|
||||
return slot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An unmodifiable map of all the slots that have been registered.
|
||||
*/
|
||||
@NotNull
|
||||
public static Map<String, CosmeticSlot> values() {
|
||||
return Collections.unmodifiableMap(REGISTRY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slot with the given name.
|
||||
* @param name The name of the slot to get. This is automatically converted to all UPPERCASE.
|
||||
* @return The slot with the given name, or null if it does not exist.
|
||||
*/
|
||||
@Nullable
|
||||
public static CosmeticSlot valueOf(@NotNull String name) {
|
||||
final String upperName = name.toUpperCase();
|
||||
return REGISTRY.get(upperName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the registry contains a slot with the given name.
|
||||
* @param name The name of the slot to check for. This is automatically converted to all UPPERCASE.
|
||||
* @return True if the slot exists, false otherwise.
|
||||
*/
|
||||
public static boolean contains(@NotNull String name) {
|
||||
final String upperName = name.toUpperCase();
|
||||
return REGISTRY.containsKey(upperName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,26 +2,29 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.lojosho.shaded.configurate.CommentedConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.ConfigurateException;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Slf4j
|
||||
public class Cosmetics {
|
||||
|
||||
private static final HashBiMap<String, Cosmetic> COSMETICS = HashBiMap.create();
|
||||
|
||||
private static CosmeticProvider PROVIDER = CosmeticProvider.Default.INSTANCE;
|
||||
|
||||
public static void addCosmetic(Cosmetic cosmetic) {
|
||||
COSMETICS.put(cosmetic.getId(), cosmetic);
|
||||
}
|
||||
@@ -31,7 +34,7 @@ public class Cosmetics {
|
||||
}
|
||||
|
||||
public static void removeCosmetic(Cosmetic cosmetic) {
|
||||
COSMETICS.remove(cosmetic);
|
||||
COSMETICS.remove(cosmetic.getId());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -68,11 +71,12 @@ public class Cosmetics {
|
||||
File[] directoryListing = cosmeticFolder.listFiles();
|
||||
if (directoryListing == null) return;
|
||||
|
||||
for (File child : directoryListing) {
|
||||
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
|
||||
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
|
||||
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||
// Loads file
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
|
||||
CommentedConfigurationNode root;
|
||||
try {
|
||||
root = loader.load();
|
||||
@@ -81,12 +85,39 @@ public class Cosmetics {
|
||||
}
|
||||
setupCosmetics(root);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom {@link CosmeticProvider} to provide your own user implementation to
|
||||
* be used and queried.
|
||||
* @param provider the provider to register
|
||||
* @throws IllegalArgumentException if the provider is already registered by another plugin
|
||||
*/
|
||||
public static void registerProvider(final CosmeticProvider provider) {
|
||||
if(PROVIDER != CosmeticProvider.Default.INSTANCE) {
|
||||
throw new IllegalArgumentException("CosmeticProvider already registered by %s, this conflicts with %s attempting to register their own.".formatted(
|
||||
PROVIDER.getProviderPlugin().getName(),
|
||||
provider.getProviderPlugin().getName()
|
||||
));
|
||||
}
|
||||
|
||||
PROVIDER = provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the current {@link CosmeticProvider} being used.
|
||||
* @return the current {@link CosmeticProvider} being used
|
||||
*/
|
||||
public static CosmeticProvider getProvider() {
|
||||
return PROVIDER;
|
||||
}
|
||||
|
||||
private static void setupCosmetics(@NotNull CommentedConfigurationNode config) {
|
||||
for (ConfigurationNode cosmeticConfig : config.childrenMap().values()) {
|
||||
try {
|
||||
String id = cosmeticConfig.key().toString();
|
||||
MessagesUtil.sendDebugMessages("Attempting to add " + id);
|
||||
ConfigurationNode slotNode = cosmeticConfig.node("slot");
|
||||
@@ -94,19 +125,17 @@ public class Cosmetics {
|
||||
MessagesUtil.sendDebugMessages("Unable to create " + id + " because there is no slot defined!", Level.WARNING);
|
||||
continue;
|
||||
}
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, slotNode.getString())) {
|
||||
String slot = slotNode.getString("");
|
||||
CosmeticSlot cosmeticSlot = CosmeticSlot.valueOf(slot);
|
||||
if (cosmeticSlot == null) {
|
||||
MessagesUtil.sendDebugMessages("Unable to create " + id + " because " + slotNode.getString() + " is not a valid slot!", Level.WARNING);
|
||||
continue;
|
||||
}
|
||||
switch (CosmeticSlot.valueOf(cosmeticConfig.node("slot").getString())) {
|
||||
case BALLOON -> new CosmeticBalloonType(id, cosmeticConfig);
|
||||
case BACKPACK -> new CosmeticBackpackType(id, cosmeticConfig);
|
||||
case MAINHAND -> new CosmeticMainhandType(id, cosmeticConfig);
|
||||
case EMOTE -> new CosmeticEmoteType(id, cosmeticConfig);
|
||||
default -> new CosmeticArmorType(id, cosmeticConfig);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (Settings.isDebugEnabled()) e.printStackTrace();
|
||||
|
||||
try {
|
||||
addCosmetic(PROVIDER.createCosmetic(id, cosmeticConfig, cosmeticSlot));
|
||||
} catch(Exception ex) {
|
||||
log.error("Unable to construct cosmetic for {}, skipping processing it.", id, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic.behavior;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Updates cosmetics whenever a player moves.
|
||||
*/
|
||||
public interface CosmeticMovementBehavior {
|
||||
void dispatchMove(
|
||||
@NotNull final CosmeticUser user,
|
||||
@NotNull final Location from,
|
||||
@NotNull final Location to
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic.behavior;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Generic updates that happen every tick or when manually requested to be dispatched.
|
||||
*/
|
||||
public interface CosmeticUpdateBehavior {
|
||||
void dispatchUpdate(
|
||||
@NotNull final CosmeticUser user
|
||||
);
|
||||
}
|
||||
@@ -2,45 +2,64 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.behavior.CosmeticUpdateBehavior;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
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;
|
||||
|
||||
public class CosmeticArmorType extends Cosmetic {
|
||||
|
||||
public class CosmeticArmorType extends Cosmetic implements CosmeticUpdateBehavior {
|
||||
private final EquipmentSlot equipSlot;
|
||||
|
||||
public CosmeticArmorType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
this.equipSlot = InventoryUtils.getEquipmentSlot(getSlot());
|
||||
EquipmentSlot slot = HMCCInventoryUtils.getEquipmentSlot(getSlot());
|
||||
if (slot == null) {
|
||||
// Hypothetically it shouldn't be null, but it was happening on some random servers? Adding this just in case
|
||||
throw new IllegalArgumentException("Invalid slot for cosmetic armor type: " + getSlot() + " in " + id + " cosmetic config.");
|
||||
}
|
||||
this.equipSlot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||
if (player == null) return;
|
||||
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
||||
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
||||
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
|
||||
public void dispatchUpdate(@NotNull CosmeticUser user) {
|
||||
if (user.isInWardrobe()) return;
|
||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||
if (entity == null) return;
|
||||
if (Settings.getSlotOption(equipSlot).isRequireEmpty() && entity instanceof HumanEntity humanEntity) {
|
||||
if (!humanEntity.getInventory().getItem(equipSlot).getType().isAir()) return;
|
||||
}
|
||||
ItemStack item = getItem(user);
|
||||
if (item == null) return;
|
||||
PacketManager.equipmentSlotUpdate(entity.getEntityId(), equipSlot, item, HMCCPacketManager.getViewers(entity.getLocation()));
|
||||
}
|
||||
|
||||
public ItemStack getItem(@NotNull CosmeticUser user) {
|
||||
return getItem(user, user.getUserCosmeticItem(this));
|
||||
}
|
||||
|
||||
public ItemStack getItem(@NotNull CosmeticUser user, ItemStack cosmeticItem) {
|
||||
Player player = user.getPlayer();
|
||||
if (player == null) return null;
|
||||
|
||||
if (Settings.getSlotOption(equipSlot).isAddEnchantments()) {
|
||||
ItemStack equippedItem = player.getInventory().getItem(equipSlot);
|
||||
if (Settings.getShouldAddEnchants(equipSlot)) {
|
||||
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||
}
|
||||
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(player.getLocation()));
|
||||
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
|
||||
// Basically, if force offhand is off AND there is no item in an offhand slot, then the equipment packet to add the cosmetic
|
||||
return cosmeticItem;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public EquipmentSlot getEquipSlot() {
|
||||
return this.equipSlot;
|
||||
}
|
||||
|
||||
@@ -1,66 +1,125 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.behavior.CosmeticMovementBehavior;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.behavior.CosmeticUpdateBehavior;
|
||||
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 org.bukkit.Bukkit;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEntity;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.entity.Entity;
|
||||
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 java.util.logging.Level;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CosmeticBackpackType extends Cosmetic {
|
||||
|
||||
private final String modelName;
|
||||
private UserBackpackManager.BackpackType backpackType;
|
||||
@Getter
|
||||
public class CosmeticBackpackType extends Cosmetic implements CosmeticUpdateBehavior, CosmeticMovementBehavior {
|
||||
private int height = -1;
|
||||
private ItemStack firstPersonBackpack;
|
||||
|
||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
modelName = config.node("model").getString();
|
||||
backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
|
||||
if (!config.node("firstperson-item").virtual()) {
|
||||
this.firstPersonBackpack = generateItemStack(config.node("firstperson-item"));
|
||||
this.height = config.node("height").getInt(5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||
if (player == null) return;
|
||||
|
||||
Location loc = player.getLocation().clone().add(0, 2, 0);
|
||||
|
||||
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||
if (!user.getUserBackpackManager().getArmorStand().isValid()) {
|
||||
MessagesUtil.sendDebugMessages("Invalid Backpack detected! Respawning backpack, report this on the discord if this happens often!", Level.WARNING);
|
||||
user.respawnBackpack();
|
||||
public void dispatchUpdate(@NotNull CosmeticUser user) {
|
||||
Entity entity = user.getEntity();
|
||||
if(entity == null) {
|
||||
return;
|
||||
}
|
||||
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
|
||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
||||
|
||||
Location entityLocation = entity.getLocation();
|
||||
Location loc = entityLocation.clone().add(0, 2, 0);
|
||||
|
||||
UserBackpackManager backpackManager = user.getUserBackpackManager();
|
||||
if(backpackManager == null) return;
|
||||
|
||||
UserEntity entityManager = backpackManager.getEntityManager();
|
||||
if(entityManager == null) return;
|
||||
|
||||
entityManager.teleport(loc);
|
||||
entityManager.setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
||||
|
||||
int firstArmorStandId = backpackManager.getFirstArmorStandId();
|
||||
|
||||
List<Player> newViewers = entityManager.refreshViewers(loc);
|
||||
|
||||
if(!newViewers.isEmpty()) {
|
||||
HMCCPacketManager.spawnInvisibleArmorstand(firstArmorStandId, entityLocation, UUID.randomUUID(), newViewers);
|
||||
PacketManager.equipmentSlotUpdate(firstArmorStandId, EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), newViewers);
|
||||
|
||||
if (user.getPlayer() != null) {
|
||||
AttributeInstance scaleAttribute = user.getPlayer().getAttribute(Attribute.SCALE);
|
||||
if (scaleAttribute != null) {
|
||||
HMCCPacketManager.sendEntityScalePacket(user.getUserBackpackManager().getFirstArmorStandId(), scaleAttribute.getValue(), newViewers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
||||
// If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players
|
||||
if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), firstArmorStandId, entityManager.getViewers());
|
||||
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), firstArmorStandId, newViewers);
|
||||
|
||||
if (user.getUserBackpackManager().getBackpackType().equals(UserBackpackManager.BackpackType.FIRST_PERSON)) {
|
||||
user.getUserBackpackManager().teleportEffectEntity(loc);
|
||||
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getAreaEffectEntityId(), loc);
|
||||
PacketManager.sendRidingPacket(user.getUserBackpackManager().getAreaEffectEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
|
||||
if (isFirstPersonCompadible() && !user.isInWardrobe() && user.getPlayer() != null) {
|
||||
List<Player> owner = List.of(user.getPlayer());
|
||||
|
||||
ArrayList<Integer> particleCloud = backpackManager.getAreaEffectEntityId();
|
||||
for (int i = 0; i < particleCloud.size(); i++) {
|
||||
if (i == 0) {
|
||||
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||
} else {
|
||||
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||
}
|
||||
}
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), firstArmorStandId, owner);
|
||||
if (!user.isHidden()) {
|
||||
PacketManager.equipmentSlotUpdate(firstArmorStandId, EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
|
||||
}
|
||||
}
|
||||
|
||||
user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());
|
||||
user.getUserBackpackManager().showBackpack();
|
||||
backpackManager.showBackpack();
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
@Override
|
||||
public void dispatchMove(@NotNull CosmeticUser user, @NotNull Location from, @NotNull Location to) {
|
||||
@SuppressWarnings("DuplicatedCode") // thanks.
|
||||
Entity entity = user.getEntity();
|
||||
if(entity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
public UserBackpackManager.BackpackType getBackpackType() {
|
||||
return backpackType;
|
||||
Location entityLocation = entity.getLocation();
|
||||
Location loc = entityLocation.clone().add(0, 2, 0);
|
||||
|
||||
UserBackpackManager backpackManager = user.getUserBackpackManager();
|
||||
if(backpackManager == null) return;
|
||||
|
||||
UserEntity entityManager = backpackManager.getEntityManager();
|
||||
if(entityManager == null) return;
|
||||
|
||||
entityManager.teleport(loc);
|
||||
entityManager.setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
||||
}
|
||||
|
||||
public boolean isFirstPersonCompadible() {
|
||||
return firstPersonBackpack != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,50 +2,65 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.behavior.CosmeticMovementBehavior;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.behavior.CosmeticUpdateBehavior;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CosmeticBalloonType extends Cosmetic {
|
||||
public class CosmeticBalloonType extends Cosmetic implements CosmeticUpdateBehavior, CosmeticMovementBehavior {
|
||||
|
||||
@Getter
|
||||
private final String modelName;
|
||||
private List<String> dyableParts;
|
||||
private boolean showLead;
|
||||
@Getter
|
||||
private List<String> dyeableParts;
|
||||
@Getter
|
||||
private final boolean showLead;
|
||||
@Getter
|
||||
private Vector balloonOffset;
|
||||
|
||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
String modelId = config.node("model").getString();
|
||||
|
||||
showLead = config.node("show-lead").getBoolean(true);
|
||||
|
||||
ConfigurationNode balloonOffsetNode = config.node("balloon-offset");
|
||||
if (balloonOffsetNode.virtual())
|
||||
balloonOffset = Settings.getBalloonOffset();
|
||||
else
|
||||
balloonOffset = Settings.loadVector(balloonOffsetNode);
|
||||
|
||||
try {
|
||||
if (!config.node("dyable-parts").virtual()) {
|
||||
dyableParts = config.node("dyable-parts").getList(String.class);
|
||||
if (!config.node("dyeable-parts").virtual()) {
|
||||
dyeableParts = config.node("dyeable-parts").getList(String.class);
|
||||
}
|
||||
} catch (SerializationException e) {
|
||||
// Seriously?
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
if (modelId != null) modelId = modelId.toLowerCase(); // ME only accepts lowercase
|
||||
this.modelName = modelId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||
public void dispatchUpdate(@NotNull CosmeticUser user) {
|
||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||
UserBalloonManager userBalloonManager = user.getBalloonManager();
|
||||
|
||||
if (player == null || userBalloonManager == null) return;
|
||||
if (entity == null || userBalloonManager == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
|
||||
if (!userBalloonManager.getModelEntity().isValid()) {
|
||||
@@ -53,43 +68,59 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
return;
|
||||
}
|
||||
|
||||
Location newLocation = player.getLocation();
|
||||
Location newLocation = entity.getLocation();
|
||||
newLocation = newLocation.clone().add(getBalloonOffset());
|
||||
if (Settings.isBalloonHeadForward()) newLocation.setPitch(0);
|
||||
|
||||
if (!user.isHidden() && showLead) {
|
||||
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
||||
if (sendTo.isEmpty()) return;
|
||||
user.getBalloonManager().getPufferfish().spawnPufferfish(newLocation, sendTo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchMove(@NotNull CosmeticUser user, @NotNull Location from, @NotNull Location to) {
|
||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||
UserBalloonManager userBalloonManager = user.getBalloonManager();
|
||||
|
||||
if (entity == null || userBalloonManager == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
|
||||
if (!userBalloonManager.getModelEntity().isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location newLocation = entity.getLocation();
|
||||
Location currentLocation = user.getBalloonManager().getLocation();
|
||||
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
||||
newLocation = newLocation.clone().add(getBalloonOffset());
|
||||
if (Settings.isBalloonHeadForward()) newLocation.setPitch(0);
|
||||
|
||||
List<Player> viewer = PacketManager.getViewers(player.getLocation());
|
||||
viewer.add(player);
|
||||
List<Player> viewer = HMCCPacketManager.getViewers(entity.getLocation());
|
||||
|
||||
if (player.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
|
||||
if (entity.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
|
||||
userBalloonManager.getModelEntity().teleport(newLocation);
|
||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
return;
|
||||
}
|
||||
|
||||
Vector velocity = newLocation.toVector().subtract(currentLocation.toVector());
|
||||
userBalloonManager.setVelocity(velocity.multiply(1.1));
|
||||
userBalloonManager.setLocation(newLocation);
|
||||
userBalloonManager.setVelocity(velocity.multiply(1.1));
|
||||
|
||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
if (!user.getHidden() && showLead) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
MessagesUtil.sendDebugMessages("Balloon Cosmetic Update for " + user.getEntity().getName());
|
||||
MessagesUtil.sendDebugMessages("Ballon previous location is " + currentLocation);
|
||||
MessagesUtil.sendDebugMessages("Balloon location set to " + newLocation);
|
||||
MessagesUtil.sendDebugMessages("Balloon velocity set to " + velocity);
|
||||
|
||||
HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
HMCCPacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return this.modelName;
|
||||
}
|
||||
|
||||
public List<String> getDyableParts() {
|
||||
return dyableParts;
|
||||
}
|
||||
|
||||
public boolean isDyablePart(String name) {
|
||||
public boolean isDyeablePart(String name) {
|
||||
// If player does not define parts, dye whole model
|
||||
if (dyableParts == null) return true;
|
||||
if (dyableParts.isEmpty()) return true;
|
||||
return dyableParts.contains(name);
|
||||
}
|
||||
|
||||
public boolean isShowLead() {
|
||||
return showLead;
|
||||
if (dyeableParts == null) return true;
|
||||
if (dyeableParts.isEmpty()) return true;
|
||||
return dyeableParts.contains(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class CosmeticEmoteType extends Cosmetic {
|
||||
|
||||
private final String animationId;
|
||||
|
||||
public CosmeticEmoteType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
animationId = config.node("animation").getString();
|
||||
MessagesUtil.sendDebugMessages("CosmeticEmoteType Animation id " + animationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(CosmeticUser user) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
public void run(@NotNull CosmeticUser user) {
|
||||
user.getUserEmoteManager().playEmote(this);
|
||||
}
|
||||
|
||||
public String getAnimationId() {
|
||||
return animationId;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class CosmeticMainhandType extends Cosmetic {
|
||||
|
||||
public CosmeticMainhandType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
Player player = user.getPlayer();
|
||||
|
||||
PacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), PlayerUtils.getNearbyPlayers(player));
|
||||
}
|
||||
}
|
||||
@@ -2,37 +2,44 @@ package com.hibiscusmc.hmccosmetics.database;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||
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.NoneData;
|
||||
import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Database {
|
||||
|
||||
@Getter
|
||||
private static Data data;
|
||||
|
||||
@Deprecated
|
||||
private static InternalData INTERNAL_DATA = new InternalData();
|
||||
|
||||
private static final MySQLData MYSQL_DATA = new MySQLData();
|
||||
private static final SQLiteData SQLITE_DATA = new SQLiteData();
|
||||
private static final NoneData NONE_DATA = new NoneData();
|
||||
|
||||
public Database() {
|
||||
String databaseType = DatabaseSettings.getDatabaseType();
|
||||
data = SQLITE_DATA; // default
|
||||
if (databaseType.equalsIgnoreCase("MySQL")) {
|
||||
data = SQLITE_DATA; // default to SQLite, then check if it's anything different
|
||||
switch (databaseType.toLowerCase()) {
|
||||
case "mysql":
|
||||
data = MYSQL_DATA;
|
||||
break;
|
||||
case "sqlite":
|
||||
// already the default
|
||||
break;
|
||||
case "none":
|
||||
data = NONE_DATA;
|
||||
MessagesUtil.sendDebugMessages("Database is set to none. Data will not be saved.", Level.WARNING);
|
||||
break;
|
||||
default:
|
||||
MessagesUtil.sendDebugMessages("Invalid database type. Defaulting to SQLite.", Level.WARNING);
|
||||
}
|
||||
/* SQLite is the default database. Might change in the future, so keep code here in case.
|
||||
if (databaseType.equalsIgnoreCase("sqlite")) {
|
||||
data = SQLITE_DATA;
|
||||
}
|
||||
*/
|
||||
MessagesUtil.sendDebugMessages("Database is " + data);
|
||||
|
||||
setup();
|
||||
@@ -50,14 +57,10 @@ public class Database {
|
||||
data.save(CosmeticUsers.getUser(player));
|
||||
}
|
||||
|
||||
public static CosmeticUser get(UUID uniqueId) {
|
||||
public static CompletableFuture<UserData> get(UUID uniqueId) {
|
||||
return data.get(uniqueId);
|
||||
}
|
||||
|
||||
public static Data getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public static void clearData(UUID uniqueId) {
|
||||
data.clear(uniqueId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.hibiscusmc.hmccosmetics.database;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserData {
|
||||
|
||||
@Getter
|
||||
private UUID owner;
|
||||
@Setter
|
||||
@Getter
|
||||
private HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics;
|
||||
@Getter
|
||||
private ArrayList<CosmeticUser.HiddenReason> hiddenReasons;
|
||||
|
||||
public UserData(UUID owner) {
|
||||
this.owner = owner;
|
||||
this.cosmetics = new HashMap<>();
|
||||
this.hiddenReasons = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addCosmetic(CosmeticSlot slot, Cosmetic cosmetic, Integer color) {
|
||||
cosmetics.put(slot, Map.entry(cosmetic, color));
|
||||
}
|
||||
|
||||
public void addHiddenReason(CosmeticUser.HiddenReason reason) {
|
||||
hiddenReasons.add(reason);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,19 @@
|
||||
package com.hibiscusmc.hmccosmetics.database.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public abstract class Data {
|
||||
|
||||
@@ -24,38 +22,38 @@ public abstract class Data {
|
||||
public abstract void save(CosmeticUser user);
|
||||
|
||||
@Nullable
|
||||
public abstract CosmeticUser get(UUID uniqueId);
|
||||
public abstract CompletableFuture<UserData> get(UUID uniqueId);
|
||||
|
||||
public abstract void clear(UUID uniqueId);
|
||||
|
||||
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
|
||||
@NotNull
|
||||
public final String serializeData(@NotNull CosmeticUser user) {
|
||||
String data = "";
|
||||
if (user.getHidden()) {
|
||||
if (shouldHiddenSave(user.getHiddenReason())) {
|
||||
data = "HIDDEN=" + user.getHiddenReason();
|
||||
StringBuilder data = new StringBuilder();
|
||||
if (user.isHidden()) {
|
||||
for (CosmeticUser.HiddenReason reason : user.getHiddenReasons()) {
|
||||
if (shouldHiddenSave(reason)) data.append("HIDDEN=").append(reason);
|
||||
}
|
||||
}
|
||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
||||
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
||||
if (color != null) input = input + "&" + color.asRGB();
|
||||
if (data.length() == 0) {
|
||||
data = input;
|
||||
if (data.isEmpty()) {
|
||||
data.append(input);
|
||||
continue;
|
||||
}
|
||||
data = data + "," + input;
|
||||
data.append(",").append(input);
|
||||
}
|
||||
return data;
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||
boolean checkPermission = Settings.getForcePermissionJoin();
|
||||
public final HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> deserializeData(@NotNull String raw) {
|
||||
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = new HashMap<>();
|
||||
|
||||
String[] rawData = raw.split(",");
|
||||
ArrayList<CosmeticUser.HiddenReason> hiddenReason = new ArrayList<>();
|
||||
for (String a : rawData) {
|
||||
if (a == null || a.isEmpty()) continue;
|
||||
String[] splitData = a.split("=");
|
||||
@@ -64,9 +62,8 @@ public abstract class Data {
|
||||
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
|
||||
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
||||
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
||||
});
|
||||
if (Settings.isForceShowOnJoin()) continue;
|
||||
hiddenReason.add(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -75,31 +72,20 @@ public abstract class Data {
|
||||
String[] colorSplitData = splitData[1].split("&");
|
||||
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
||||
if (slot == null || cosmetic == null) continue;
|
||||
if (cosmetic.requiresPermission() && checkPermission) {
|
||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
cosmetics.put(slot, Map.of(cosmetic, Color.fromRGB(Integer.parseInt(colorSplitData[1]))));
|
||||
cosmetics.put(slot, Map.entry(cosmetic, Integer.parseInt(colorSplitData[1])));
|
||||
} else {
|
||||
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
||||
if (slot == null || cosmetic == null) continue;
|
||||
if (cosmetic.requiresPermission() && checkPermission) {
|
||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
HashMap<Cosmetic, Color> cosmeticColorHashMap = new HashMap<>();
|
||||
cosmeticColorHashMap.put(cosmetic, null);
|
||||
cosmetics.put(slot, cosmeticColorHashMap);
|
||||
cosmetics.put(slot, Map.entry(cosmetic, -1));
|
||||
}
|
||||
}
|
||||
|
||||
return cosmetics;
|
||||
}
|
||||
|
||||
private boolean shouldHiddenSave(CosmeticUser.@NotNull HiddenReason reason) {
|
||||
private boolean shouldHiddenSave(CosmeticUser.HiddenReason reason) {
|
||||
switch (reason) {
|
||||
case EMOTE, NONE -> {
|
||||
case EMOTE, NONE, GAMEMODE, WORLD, DISABLED, POTION -> {
|
||||
return false;
|
||||
}
|
||||
default -> {
|
||||
|
||||
@@ -1,66 +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;
|
||||
|
||||
@Deprecated
|
||||
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, serializeData(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 = deserializeData(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,13 +2,18 @@ package com.hibiscusmc.hmccosmetics.database.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MySQLData extends SQLData {
|
||||
|
||||
@@ -33,12 +38,14 @@ public class MySQLData extends SQLData {
|
||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||
try {
|
||||
openConnection();
|
||||
if (connection == null) throw new NullPointerException("Connection is null");
|
||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
||||
if (connection == null) throw new IllegalStateException("Connection is null");
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
||||
"(UUID varchar(36) PRIMARY KEY, " +
|
||||
"COSMETICS MEDIUMTEXT " +
|
||||
");").execute();
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
");")) {
|
||||
preparedStatement.execute();
|
||||
}
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
plugin.getLogger().severe("");
|
||||
plugin.getLogger().severe("");
|
||||
plugin.getLogger().severe("MySQL DATABASE CAN NOT BE REACHED.");
|
||||
@@ -55,8 +62,7 @@ public class MySQLData extends SQLData {
|
||||
@Override
|
||||
public void clear(UUID uniqueId) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||
try (PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;")) {
|
||||
preparedSt.setString(1, uniqueId.toString());
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
@@ -66,16 +72,10 @@ public class MySQLData extends SQLData {
|
||||
}
|
||||
|
||||
private void openConnection() throws SQLException {
|
||||
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// ...
|
||||
// });
|
||||
// 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
|
||||
if (isConnectionOpen()) return;
|
||||
if (connection != null) close(); // Close connection if still active
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace(); // If isConnectionOpen() throws error
|
||||
}
|
||||
@@ -84,17 +84,15 @@ public class MySQLData extends SQLData {
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, setupProperties());
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
System.out.println(e.getMessage());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
if (connection == null) throw new NullPointerException("Connection is null");
|
||||
if (connection == null) throw new IllegalStateException("Connection is null");
|
||||
connection.close();
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
System.out.println(e.getMessage());
|
||||
@@ -105,13 +103,12 @@ public class MySQLData extends SQLData {
|
||||
@NotNull
|
||||
private Properties setupProperties() {
|
||||
Properties props = new Properties();
|
||||
props.put("user", user);
|
||||
props.put("password", password);
|
||||
props.put("autoReconnect", "true");
|
||||
props.setProperty("user", user);
|
||||
props.setProperty("password", password);
|
||||
return props;
|
||||
}
|
||||
|
||||
private boolean isConnectionOpen() throws RuntimeException {
|
||||
private boolean isConnectionOpen() {
|
||||
try {
|
||||
return connection != null && !connection.isClosed();
|
||||
} catch (SQLException e) {
|
||||
@@ -124,13 +121,18 @@ public class MySQLData extends SQLData {
|
||||
PreparedStatement ps = null;
|
||||
|
||||
if (!isConnectionOpen()) {
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
||||
MessagesUtil.sendDebugMessages("The MySQL database connection is not open (Could the database been idle for to long?). Reconnecting...", Level.WARNING);
|
||||
try {
|
||||
openConnection();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (connection == null) throw new NullPointerException("Connection is null");
|
||||
if (connection == null) throw new IllegalStateException("Connection is null");
|
||||
ps = connection.prepareStatement(query);
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.hibiscusmc.hmccosmetics.database.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class NoneData extends Data {
|
||||
@Override
|
||||
public void setup() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(CosmeticUser user) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CompletableFuture<UserData> get(UUID uniqueId) {
|
||||
return CompletableFuture.completedFuture(new UserData(uniqueId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(UUID uniqueId) {
|
||||
// Nothing
|
||||
}
|
||||
}
|
||||
@@ -3,53 +3,46 @@ 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.database.UserData;
|
||||
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.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public abstract class SQLData extends Data {
|
||||
@Override
|
||||
@SuppressWarnings({"Duplicates", "resource"}) // Duplicate is from deprecated InternalData
|
||||
public CosmeticUser get(UUID uniqueId) {
|
||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
||||
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
|
||||
public CompletableFuture<UserData> get(UUID uniqueId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
UserData data = new UserData(uniqueId);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
||||
try (PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;")){
|
||||
preparedStatement.setString(1, uniqueId.toString());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
try (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));
|
||||
});
|
||||
}
|
||||
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = deserializeData(rawData);
|
||||
data.setCosmetics(cosmetics);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
});
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("resource")
|
||||
public void save(CosmeticUser user) {
|
||||
Runnable run = () -> {
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
||||
try (PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);")) {
|
||||
preparedSt.setString(1, user.getUniqueId().toString());
|
||||
preparedSt.setString(2, serializeData(user));
|
||||
preparedSt.executeUpdate();
|
||||
@@ -57,7 +50,7 @@ public abstract class SQLData extends Data {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
if (!HMCCosmeticsPlugin.isDisable()) {
|
||||
if (!HMCCosmeticsPlugin.getInstance().isDisabled()) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
||||
} else {
|
||||
run.run();
|
||||
|
||||
@@ -6,7 +6,10 @@ import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -32,10 +35,12 @@ public class SQLiteData extends SQLData {
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
||||
|
||||
openConnection();
|
||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
|
||||
"(UUID varchar(36) PRIMARY KEY, " +
|
||||
"COSMETICS MEDIUMTEXT " +
|
||||
");").execute();
|
||||
");")) {
|
||||
preparedStatement.execute();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -45,8 +50,7 @@ public class SQLiteData extends SQLData {
|
||||
@SuppressWarnings("resource")
|
||||
public void clear(UUID uniqueId) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||
try (PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;")){
|
||||
preparedSt.setString(1, uniqueId.toString());
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
@@ -56,11 +60,6 @@ public class SQLiteData extends SQLData {
|
||||
}
|
||||
|
||||
private void openConnection() throws SQLException {
|
||||
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// ...
|
||||
// });
|
||||
// connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
|
||||
|
||||
if (connection != null && !connection.isClosed()) return;
|
||||
|
||||
// Close Connection if still active
|
||||
@@ -71,7 +70,7 @@ public class SQLiteData extends SQLData {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
||||
} catch (SQLException e) {
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -80,11 +79,12 @@ public class SQLiteData extends SQLData {
|
||||
@Override
|
||||
public PreparedStatement preparedStatement(String query) {
|
||||
PreparedStatement ps = null;
|
||||
if (!isConnectionOpen()) {
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!isConnectionOpen()) {
|
||||
MessagesUtil.sendDebugMessages("Connection is not open");
|
||||
openConnection();
|
||||
}
|
||||
ps = connection.prepareStatement(query);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.api.PlayerMenuOpenEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuCloseEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Types;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeCosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
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.components.GuiType;
|
||||
import dev.triumphteam.gui.guis.Gui;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.AdventureUtils;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -19,93 +29,51 @@ import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Menu {
|
||||
|
||||
@Getter
|
||||
private final String id;
|
||||
@Getter
|
||||
private final String title;
|
||||
@Getter
|
||||
private final int rows;
|
||||
@Getter
|
||||
private final Long cooldown;
|
||||
@Getter
|
||||
private final ConfigurationNode config;
|
||||
@Getter
|
||||
private final String permissionNode;
|
||||
private final HashMap<Integer, List<MenuItem>> items;
|
||||
@Getter
|
||||
private final int refreshRate;
|
||||
@Getter
|
||||
private final boolean shading;
|
||||
|
||||
public Menu(String id, @NotNull ConfigurationNode config) {
|
||||
this.id = id;
|
||||
this.id = config.node("id").getString(id);
|
||||
this.config = config;
|
||||
|
||||
title = config.node("title").getString("chest");
|
||||
rows = config.node("rows").getInt(1);
|
||||
cooldown = config.node("click-cooldown").getLong(Settings.getDefaultMenuCooldown());
|
||||
permissionNode = config.node("permission").getString("");
|
||||
refreshRate = config.node("refresh-rate").getInt(-1);
|
||||
shading = config.node("shading").getBoolean(Settings.isDefaultShading());
|
||||
|
||||
items = new HashMap<>();
|
||||
setupItems();
|
||||
|
||||
Menus.addMenu(this);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public int getRows() {
|
||||
return this.getRows();
|
||||
}
|
||||
|
||||
public void openMenu(CosmeticUser user) {
|
||||
openMenu(user, false);
|
||||
}
|
||||
|
||||
public void openMenu(@NotNull CosmeticUser user, boolean ignorePermission) {
|
||||
Player player = user.getPlayer();
|
||||
if (player == null) return;
|
||||
if (!ignorePermission && !permissionNode.isEmpty()) {
|
||||
if (!player.hasPermission(permissionNode) && !player.isOp()) {
|
||||
MessagesUtil.sendMessage(player, "no-permission");
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Component component = Adventure.MINI_MESSAGE.deserialize(Placeholder.applyPapiPlaceholders(player, this.title));
|
||||
Gui gui = Gui.gui().
|
||||
title(component).
|
||||
rows(this.rows).
|
||||
create();
|
||||
|
||||
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
|
||||
gui = getItems(user, gui);
|
||||
|
||||
Gui finalGui = gui;
|
||||
|
||||
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
||||
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
});
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
finalGui.open(player);
|
||||
});
|
||||
|
||||
//gui.open(player);
|
||||
|
||||
}
|
||||
|
||||
@Contract("_, _ -> param2")
|
||||
private Gui getItems(@NotNull CosmeticUser user, Gui gui) {
|
||||
Player player = user.getPlayer();
|
||||
|
||||
private void setupItems() {
|
||||
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
||||
|
||||
List<String> slotString = null;
|
||||
List<String> slotString;
|
||||
try {
|
||||
slotString = config.node("slots").getList(String.class);
|
||||
} catch (SerializationException e) {
|
||||
@@ -118,53 +86,213 @@ public class Menu {
|
||||
|
||||
List<Integer> slots = getSlots(slotString);
|
||||
|
||||
|
||||
if (slots == null) {
|
||||
MessagesUtil.sendDebugMessages("Slot is null for " + config.key().toString());
|
||||
if (slots.isEmpty()) {
|
||||
MessagesUtil.sendDebugMessages("Slot is empty 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);
|
||||
MessagesUtil.sendDebugMessages("Unable to get valid item for " + config.key().toString() + " " + e.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
Type type = null;
|
||||
if (item == null) {
|
||||
MessagesUtil.sendDebugMessages("Something went wrong with the item creation for " + config.key().toString());
|
||||
continue;
|
||||
}
|
||||
|
||||
int priority = config.node("priority").getInt(1);
|
||||
|
||||
Type type = Types.getDefaultType();
|
||||
if (!config.node("type").virtual()) {
|
||||
String typeId = config.node("type").getString();
|
||||
String typeId = config.node("type").getString("");
|
||||
if (Types.isType(typeId)) type = Types.getType(typeId);
|
||||
}
|
||||
|
||||
ItemStack originalItem = item.clone();
|
||||
item = updateLore(user, item, type, config);
|
||||
for (Integer slot : slots) {
|
||||
MenuItem menuItem = new MenuItem(slots, item, type, priority, config);
|
||||
if (items.containsKey(slot)) {
|
||||
List<MenuItem> menuItems = items.get(slot);
|
||||
menuItems.add(menuItem);
|
||||
menuItems.sort(priorityCompare);
|
||||
items.put(slot, menuItems);
|
||||
} else {
|
||||
items.put(slot, new ArrayList<>(List.of(menuItem)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GuiItem guiItem = ItemBuilder.from(item).asGuiItem();
|
||||
public void openMenu(CosmeticUser user) {
|
||||
openMenu(user, false);
|
||||
}
|
||||
|
||||
Type finalType = type;
|
||||
guiItem.setAction(event -> {
|
||||
final ClickType clickType = event.getClick();
|
||||
if (finalType != null) finalType.run(user, config, clickType);
|
||||
public void openMenu(@NotNull CosmeticUser user, boolean ignorePermission) {
|
||||
Player player = user.getPlayer();
|
||||
if (player == null) return;
|
||||
openMenu(player, user, ignorePermission);
|
||||
}
|
||||
|
||||
for (int i : slots) {
|
||||
gui.updateItem(i, updateLore(user, originalItem.clone(), finalType, config));
|
||||
MessagesUtil.sendDebugMessages("Updated slot " + i);
|
||||
public void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder) {
|
||||
openMenu(viewer, cosmeticHolder, false);
|
||||
}
|
||||
|
||||
public void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, boolean ignorePermission) {
|
||||
if (!ignorePermission && !permissionNode.isEmpty()) {
|
||||
if (!viewer.hasPermission(permissionNode) && !viewer.isOp()) {
|
||||
MessagesUtil.sendMessage(viewer, "no-permission");
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Component component = AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(viewer, this.title));
|
||||
Gui gui = Gui.gui()
|
||||
.title(component)
|
||||
.type(GuiType.CHEST)
|
||||
.inventory((title, owner, type) -> Bukkit.createInventory(owner, rows * 9, title))
|
||||
.create();
|
||||
|
||||
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
|
||||
AtomicInteger taskid = new AtomicInteger(-1);
|
||||
gui.setOpenGuiAction(event -> {
|
||||
Runnable run = () -> {
|
||||
if (gui.getInventory().getViewers().isEmpty() && taskid.get() != -1) {
|
||||
Bukkit.getScheduler().cancelTask(taskid.get());
|
||||
}
|
||||
|
||||
updateMenu(viewer, cosmeticHolder, gui);
|
||||
};
|
||||
|
||||
if (refreshRate != -1) {
|
||||
taskid.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(HMCCosmeticsPlugin.getInstance(), run, 0, refreshRate));
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
});
|
||||
|
||||
MessagesUtil.sendDebugMessages("Added " + slots + " as " + guiItem + " in the menu");
|
||||
gui.setItem(slots, guiItem);
|
||||
gui.setCloseGuiAction(event -> {
|
||||
if (cosmeticHolder instanceof CosmeticUser user) {
|
||||
PlayerMenuCloseEvent closeEvent = new PlayerMenuCloseEvent(user, this, event.getReason());
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> Bukkit.getPluginManager().callEvent(closeEvent));
|
||||
}
|
||||
|
||||
if (taskid.get() != -1) Bukkit.getScheduler().cancelTask(taskid.get());
|
||||
});
|
||||
|
||||
Runnable openGuiTask = () -> {
|
||||
gui.open(viewer);
|
||||
updateMenu(viewer, cosmeticHolder, gui); // fixes shading? I know I do this twice but it's easier than writing a whole new class to deal with this shit
|
||||
};
|
||||
|
||||
// API
|
||||
if (cosmeticHolder instanceof CosmeticUser user) {
|
||||
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
openGuiTask.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Internal
|
||||
else {
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), openGuiTask);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMenu(Player viewer, CosmeticHolder cosmeticHolder, Gui gui) {
|
||||
StringBuilder title = new StringBuilder(this.title);
|
||||
|
||||
int row = 0;
|
||||
if (shading) {
|
||||
for (int i = 0; i < gui.getInventory().getSize(); i++) {
|
||||
// Handles the title
|
||||
if (i % 9 == 0) {
|
||||
if (row == 0) {
|
||||
title.append(Settings.getFirstRowShift()); // Goes back to the start of the gui
|
||||
} else {
|
||||
title.append(Settings.getSequentRowShift());
|
||||
}
|
||||
row += 1;
|
||||
} else {
|
||||
title.append(Settings.getIndividualColumnShift()); // Goes to the next slot
|
||||
}
|
||||
|
||||
boolean occupied = false;
|
||||
|
||||
if (items.containsKey(i)) {
|
||||
// Handles the items
|
||||
List<MenuItem> menuItems = items.get(i);
|
||||
MenuItem item = menuItems.get(0);
|
||||
updateItem(viewer, cosmeticHolder, gui, i);
|
||||
|
||||
if (item.type() instanceof TypeCosmetic) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(item.itemConfig().node("cosmetic").getString(""));
|
||||
if (cosmetic == null) continue;
|
||||
if (cosmeticHolder.hasCosmeticInSlot(cosmetic)) {
|
||||
title.append(Settings.getEquippedCosmeticColor());
|
||||
} else {
|
||||
if (cosmeticHolder.canEquipCosmetic(cosmetic, true)) {
|
||||
title.append(Settings.getEquipableCosmeticColor());
|
||||
} else {
|
||||
title.append(Settings.getLockedCosmeticColor());
|
||||
}
|
||||
}
|
||||
occupied = true;
|
||||
}
|
||||
}
|
||||
if (occupied) {
|
||||
title.append(Settings.getBackground().replaceAll("<row>", String.valueOf(row)));
|
||||
} else {
|
||||
title.append(Settings.getClearBackground().replaceAll("<row>", String.valueOf(row)));
|
||||
}
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("Updated menu with title " + title);
|
||||
gui.updateTitle(AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(viewer, title.toString())));
|
||||
} else {
|
||||
for (int i = 0; i < gui.getInventory().getSize(); i++) {
|
||||
if (items.containsKey(i)) {
|
||||
updateItem(viewer, cosmeticHolder, gui, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateItem(Player viewer, CosmeticHolder cosmeticHolder, Gui gui, int slot) {
|
||||
if (!items.containsKey(slot)) return;
|
||||
List<MenuItem> menuItems = items.get(slot);
|
||||
if (menuItems.isEmpty()) return;
|
||||
|
||||
for (MenuItem item : menuItems) {
|
||||
Type type = item.type();
|
||||
ItemStack modifiedItem = getMenuItem(viewer, cosmeticHolder, type, item.itemConfig(), item.item().clone(), slot);
|
||||
if (modifiedItem.getType().isAir()) continue;
|
||||
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
|
||||
guiItem.setAction(event -> {
|
||||
UUID uuid = viewer.getUniqueId();
|
||||
if (Settings.isMenuClickCooldown()) {
|
||||
Long userCooldown = Menus.getCooldown(uuid);
|
||||
if (userCooldown != 0 && (System.currentTimeMillis() - Menus.getCooldown(uuid) <= getCooldown())) {
|
||||
MessagesUtil.sendDebugMessages("Cooldown for " + viewer.getUniqueId() + " System time: " + System.currentTimeMillis() + " Cooldown: " + Menus.getCooldown(viewer.getUniqueId()) + " Difference: " + (System.currentTimeMillis() - Menus.getCooldown(viewer.getUniqueId())));
|
||||
MessagesUtil.sendMessage(viewer, "on-click-cooldown");
|
||||
return;
|
||||
} else {
|
||||
Menus.addCooldown(uuid, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("Updated Menu Item in slot number " + slot);
|
||||
final ClickType clickType = event.getClick();
|
||||
if (type != null) type.run(viewer, cosmeticHolder, item.itemConfig(), clickType);
|
||||
updateMenu(viewer, cosmeticHolder, gui);
|
||||
});
|
||||
|
||||
MessagesUtil.sendDebugMessages("Set an item in slot " + slot + " in the menu of " + getId());
|
||||
gui.updateItem(slot, guiItem);
|
||||
break;
|
||||
}
|
||||
return gui;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -174,8 +302,8 @@ public class Menu {
|
||||
for (String a : slotString) {
|
||||
if (a.contains("-")) {
|
||||
String[] split = a.split("-");
|
||||
int min = Integer.valueOf(split[0]);
|
||||
int max = Integer.valueOf(split[1]);
|
||||
int min = Integer.parseInt(split[0]);
|
||||
int max = Integer.parseInt(split[1]);
|
||||
slots.addAll(getSlots(min, max));
|
||||
} else {
|
||||
slots.add(Integer.valueOf(a));
|
||||
@@ -193,21 +321,17 @@ public class Menu {
|
||||
return slots;
|
||||
}
|
||||
|
||||
@Contract("_, _, _, _ -> param2")
|
||||
@Contract("_, _, _, _, _, _ -> param4")
|
||||
@NotNull
|
||||
private ItemStack updateLore(CosmeticUser user, @NotNull ItemStack itemStack, Type type, ConfigurationNode config) {
|
||||
if (itemStack.hasItemMeta()) {
|
||||
itemStack.setItemMeta(type.setLore(user, config, itemStack.getItemMeta()));
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public String getPermissionNode() {
|
||||
return permissionNode;
|
||||
private ItemStack getMenuItem(Player viewer, CosmeticHolder cosmeticHolder, Type type, ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||
if (!itemStack.hasItemMeta()) return itemStack;
|
||||
return type.setItem(viewer, cosmeticHolder, config, itemStack, slot);
|
||||
}
|
||||
|
||||
public boolean canOpen(Player player) {
|
||||
if (permissionNode.isEmpty()) return true;
|
||||
return player.isOp() || player.hasPermission(permissionNode);
|
||||
}
|
||||
|
||||
public static Comparator<MenuItem> priorityCompare = Comparator.comparing(MenuItem::priority).reversed();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record MenuItem(@NotNull List<Integer> slots, @NotNull ItemStack item, Type type, int priority, ConfigurationNode itemConfig) {
|
||||
|
||||
}
|
||||
@@ -3,28 +3,31 @@ package com.hibiscusmc.hmccosmetics.gui;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import me.lojosho.shaded.configurate.CommentedConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.ConfigurateException;
|
||||
import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader;
|
||||
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.ConfigurateException;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Menus {
|
||||
|
||||
private static final HashMap<String, Menu> MENUS = new HashMap<>();
|
||||
private static final HashMap<UUID, Long> COOLDOWNS = new HashMap<>();
|
||||
|
||||
public static void addMenu(Menu menu) {
|
||||
public static void addMenu(@NotNull Menu menu) {
|
||||
MENUS.put(menu.getId().toUpperCase(), menu);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Menu getMenu(@NotNull String id) {
|
||||
return MENUS.get(id.toUpperCase());
|
||||
}
|
||||
@@ -39,11 +42,18 @@ public class Menus {
|
||||
return MENUS.containsKey(id.toUpperCase());
|
||||
}
|
||||
|
||||
public static boolean hasMenu(Menu menu) {
|
||||
public static boolean hasMenu(@NotNull Menu menu) {
|
||||
return MENUS.containsValue(menu);
|
||||
}
|
||||
|
||||
public static Menu getDefaultMenu() { return Menus.getMenu(Settings.getDefaultMenu()); }
|
||||
public static boolean hasDefaultMenu() {
|
||||
return MENUS.containsKey(Settings.getDefaultMenu());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Menu getDefaultMenu() {
|
||||
return Menus.getMenu(Settings.getDefaultMenu());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<String> getMenuNames() {
|
||||
@@ -56,20 +66,36 @@ public class Menus {
|
||||
return names;
|
||||
}
|
||||
|
||||
public static Collection<Menu> values() {
|
||||
return MENUS.values();
|
||||
}
|
||||
|
||||
public static void addCooldown(UUID uuid, long time) {
|
||||
COOLDOWNS.put(uuid, time);
|
||||
}
|
||||
|
||||
public static Long getCooldown(UUID uuid) {
|
||||
return COOLDOWNS.getOrDefault(uuid, 0L);
|
||||
}
|
||||
|
||||
public static void removeCooldown(UUID uuid) {
|
||||
COOLDOWNS.remove(uuid);
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
MENUS.clear();
|
||||
COOLDOWNS.clear();
|
||||
|
||||
File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus");
|
||||
if (!cosmeticFolder.exists()) cosmeticFolder.mkdir();
|
||||
|
||||
File[] directoryListing = cosmeticFolder.listFiles();
|
||||
if (directoryListing == null) return;
|
||||
|
||||
for (File child : directoryListing) {
|
||||
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
||||
// Recursive file lookup
|
||||
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
|
||||
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
|
||||
if (child.toString().endsWith("yml") || child.toString().endsWith("yaml")) {
|
||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||
// Loads file
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
|
||||
CommentedConfigurationNode root;
|
||||
try {
|
||||
root = loader.load();
|
||||
@@ -77,12 +103,15 @@ public class Menus {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
new Menu(FilenameUtils.removeExtension(child.getName()), root);
|
||||
new Menu(FilenameUtils.removeExtension(child.getFileName().toString()), root);
|
||||
} catch (Exception e) {
|
||||
MessagesUtil.sendDebugMessages("Unable to create menu in " + child, Level.WARNING);
|
||||
if (Settings.isDebugEnabled()) e.printStackTrace();
|
||||
}
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("Unable to create menu in " + child.getFileName().toString(), Level.WARNING);
|
||||
if (Settings.isDebugMode()) e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class Action {
|
||||
@@ -16,5 +18,13 @@ public abstract class Action {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
run(CosmeticHolder.ensureSingleCosmeticUser(viewer, cosmeticHolder), raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Override {@link #run(Player, CosmeticHolder, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void run(CosmeticUser user, String raw);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.actions.*;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Actions {
|
||||
@@ -28,7 +31,6 @@ public class Actions {
|
||||
private static final ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
|
||||
private static final ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
|
||||
|
||||
|
||||
public static Action getAction(@NotNull String id) {
|
||||
return actions.get(id.toUpperCase());
|
||||
}
|
||||
@@ -41,16 +43,20 @@ public class Actions {
|
||||
actions.put(action.getId().toUpperCase(), action);
|
||||
}
|
||||
|
||||
public static void runActions(CosmeticUser user, @NotNull List<String> raw) {
|
||||
public static void runActions(Player viewer, CosmeticHolder cosmeticHolder, @NotNull List<String> raw) {
|
||||
for (String a : raw) {
|
||||
String id = StringUtils.substringBetween(a, "[", "]").toUpperCase();
|
||||
String id = StringUtils.substringBetween(a, "[", "]");
|
||||
String message = StringUtils.substringAfter(a, "] ");
|
||||
MessagesUtil.sendDebugMessages("ID is " + id + " // Raw Data is " + message);
|
||||
if (isAction(id)) {
|
||||
getAction(id).run(user, message);
|
||||
if (id != null && isAction(id.toUpperCase())) {
|
||||
getAction(id).run(viewer, cosmeticHolder, message);
|
||||
} else {
|
||||
MessagesUtil.sendDebugMessages("Possible ids: " + actions.keySet());
|
||||
MessagesUtil.sendDebugMessages("Invalid Action ID (" + id + ") used in menus (Full raw: '" + a + "'). Make sure all actions are properly typed out. Here are all possible actions: " + actions.keySet(), Level.WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void runActions(CosmeticUser user, @NotNull List<String> raw) {
|
||||
runActions(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionCloseMenu extends Action {
|
||||
@@ -10,8 +12,13 @@ public class ActionCloseMenu extends Action {
|
||||
super("close");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
viewer.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
user.getPlayer().closeInventory();
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionConsoleCommand extends Action {
|
||||
@@ -11,8 +15,15 @@ public class ActionConsoleCommand extends Action {
|
||||
super("console-command");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
// todo: some of these generalizations may require more specific implementations, for example,
|
||||
// todo: what if we wanted to execute console commands only for the cosmetic holder?
|
||||
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(Bukkit.getConsoleSender(), Hooks.processPlaceholders(viewer, raw));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(user.getPlayer(), raw);
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionCosmeticHide extends Action {
|
||||
@@ -11,8 +13,14 @@ public class ActionCosmeticHide extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (user.getHidden()) return;
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
if (!(cosmeticHolder instanceof CosmeticUser user)) return;
|
||||
if (user.isHidden()) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionCosmeticShow extends Action {
|
||||
@@ -11,11 +13,17 @@ public class ActionCosmeticShow extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (!user.getHidden()) return;
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
if (!(cosmeticHolder instanceof CosmeticUser user)) return;
|
||||
if (!user.isHidden()) return;
|
||||
|
||||
// Do not hide if it's already off for WG
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
||||
user.showCosmetics();
|
||||
if (!user.isHidden(CosmeticUser.HiddenReason.ACTION) && !user.isHidden(CosmeticUser.HiddenReason.COMMAND)) return;
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionCosmeticToggle extends Action {
|
||||
@@ -11,13 +13,19 @@ public class ActionCosmeticToggle extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
||||
user.showCosmetics();
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
if (!(cosmeticHolder instanceof CosmeticUser user)) return;
|
||||
if (user.isHidden()) {
|
||||
if (!user.isHidden(CosmeticUser.HiddenReason.ACTION) && !user.isHidden(CosmeticUser.HiddenReason.COMMAND)) return;
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
return;
|
||||
}
|
||||
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ActionEquip extends Action {
|
||||
|
||||
@@ -12,10 +14,15 @@ public class ActionEquip extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(raw);
|
||||
if (cosmetic == null) return;
|
||||
|
||||
user.addPlayerCosmetic(cosmetic);
|
||||
cosmeticHolder.addCosmetic(cosmetic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -16,7 +17,7 @@ public class ActionMenu extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
boolean ignorePermission = false;
|
||||
|
||||
raw = raw.replaceAll(" ", ""); // Removes all spaces
|
||||
@@ -33,6 +34,11 @@ public class ActionMenu extends Action {
|
||||
|
||||
Menu menu = Menus.getMenu(raw);
|
||||
MessagesUtil.sendDebugMessages(raw + " | " + ignorePermission);
|
||||
menu.openMenu(user, ignorePermission);
|
||||
menu.openMenu(viewer, cosmeticHolder, ignorePermission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionMessage extends Action {
|
||||
@@ -11,8 +13,13 @@ public class ActionMessage extends Action {
|
||||
super("message");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
MessagesUtil.sendMessageNoKey(viewer, raw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
MessagesUtil.sendMessageNoKey(user.getPlayer(), raw);
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
||||
@@ -24,7 +25,7 @@ public class ActionParticle extends Action {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void run(CosmeticUser user, @NotNull String raw) {
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
String[] rawString = raw.split(" ");
|
||||
ParticleType<?, ?> particleType = Particles.fromKey(NamespacedKey.minecraft(rawString[0].toLowerCase()));
|
||||
if (particleType == null) {
|
||||
@@ -42,10 +43,15 @@ public class ActionParticle extends Action {
|
||||
return;
|
||||
}
|
||||
|
||||
particle = ServerUtils.addParticleValues(particle, rawString);
|
||||
Location location = user.getPlayer().getLocation();
|
||||
for (Player player : PacketManager.getViewers(location)) {
|
||||
particle = HMCCServerUtils.addParticleValues(particle, rawString);
|
||||
Location location = viewer.getLocation();
|
||||
for (Player player : HMCCPacketManager.getViewers(location)) {
|
||||
particle.compile().send(player, location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, @NotNull String raw) {
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionPlayerCommand extends Action {
|
||||
@@ -11,8 +14,14 @@ public class ActionPlayerCommand extends Action {
|
||||
super("player-command");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
// todo: what if we wanted the cosmetic holder to execute the command instead
|
||||
viewer.performCommand(MessagesUtil.processStringNoKeyString(viewer, Hooks.processPlaceholders(viewer, raw)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
user.getPlayer().performCommand(MessagesUtil.processStringNoKeyString(user.getPlayer(), raw));
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
@@ -16,8 +17,7 @@ public class ActionSound extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, @NotNull String raw) {
|
||||
Player player = user.getPlayer();
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
String[] processedString = raw.split(" ");
|
||||
|
||||
String soundName = processedString[0];
|
||||
@@ -31,6 +31,11 @@ public class ActionSound extends Action {
|
||||
|
||||
MessagesUtil.sendDebugMessages("Attempting to play " + soundName, Level.INFO);
|
||||
|
||||
player.playSound(player.getLocation(), soundName, volume, pitch);
|
||||
viewer.playSound(viewer.getLocation(), soundName, volume, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, @NotNull String raw) {
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ActionUnequip extends Action {
|
||||
|
||||
@@ -12,10 +13,15 @@ public class ActionUnequip extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, raw)) return;
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, String raw) {
|
||||
if (!CosmeticSlot.contains(raw)) return;
|
||||
|
||||
CosmeticSlot slot = CosmeticSlot.valueOf(raw);
|
||||
user.removeCosmeticSlot(slot);
|
||||
cosmeticHolder.removeCosmeticSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
run(user.getPlayer(), user, raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +1,20 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.special;
|
||||
|
||||
import com.hibiscusmc.hmccolor.HMCColorApi;
|
||||
import com.hibiscusmc.hmccolor.gui.guis.Gui;
|
||||
import com.hibiscusmc.hmccolor.gui.guis.GuiItem;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DyeMenu {
|
||||
public interface DyeMenu {
|
||||
|
||||
/**
|
||||
* Overrideable method that is called when a player wishing to dye a menu.
|
||||
* After the method is called, the menu plugin itself is supposed to handle everything else, including adding the cosmetic to the CosmeticHolder
|
||||
*
|
||||
* @param viewer The player that is viewing the menu
|
||||
* @param cosmeticHolder The CosmeticHolder that is being dyed (Can be different from the viewer)
|
||||
* @param cosmetic (The cosmetic that is wished to be dyed)
|
||||
*/
|
||||
void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic);
|
||||
|
||||
public static void openMenu(@NotNull CosmeticUser user, Cosmetic cosmetic) {
|
||||
Player player = user.getPlayer();
|
||||
if (player == null) return;
|
||||
if (!Hooks.isActiveHook("HMCColor")) {
|
||||
addCosmetic(user, cosmetic, null);
|
||||
return;
|
||||
}
|
||||
ItemStack originalItem = user.getUserCosmeticItem(cosmetic);
|
||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
||||
|
||||
Gui gui = HMCColorApi.INSTANCE.colorMenu();
|
||||
gui.updateTitle(Placeholder.applyPapiPlaceholders(player, Settings.getDyeMenuName()));
|
||||
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
||||
gui.setDefaultTopClickAction(event -> {
|
||||
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
||||
ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot());
|
||||
if (item == null) return;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return;
|
||||
|
||||
Color color = meta instanceof LeatherArmorMeta leatherMeta ? leatherMeta.getColor() :
|
||||
meta instanceof PotionMeta potionMeta ? potionMeta.getColor() :
|
||||
meta instanceof MapMeta mapMeta ? mapMeta.getColor() : null;
|
||||
if (color == null) return;
|
||||
|
||||
addCosmetic(user, cosmetic, color);
|
||||
event.setCancelled(true);
|
||||
} else event.setCancelled(true);
|
||||
});
|
||||
|
||||
gui.setPlayerInventoryAction(event -> event.setCancelled(true));
|
||||
gui.setCloseGuiAction(event -> {});
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.special;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DyeMenuProvider {
|
||||
|
||||
private static DyeMenu instance = null;
|
||||
|
||||
/**
|
||||
* Sets the provider of the DyeMenu. Check {@link DyeMenuProvider#hasMenuProvider()} before attempting to set this,
|
||||
* it is locked once a dye menu has been set!
|
||||
* @param dyeMenu The dye menu implementation that wishes to be the provider.
|
||||
* @throws IllegalStateException IllegalStateException will be thrown if a dye menu provider already is set by another plugin.
|
||||
*/
|
||||
public static void setDyeMenuProvider(@NotNull DyeMenu dyeMenu) throws IllegalStateException {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("DyeMenu Implementation has already been set by another plugin.");
|
||||
}
|
||||
instance = dyeMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when wishing to dye a cosmetic to hand it off to the dye menu implementation
|
||||
* @param viewer The viewer of the menu
|
||||
* @param cosmeticHolder The cosmetic holder that the player viewer wishing to modify (could be themselves or another CosmeticHolder)
|
||||
* @param cosmetic The cosmetic the user wishes to dye
|
||||
* @throws IllegalStateException IllegalStateException will be thrown if the dye menu instance is null (Check {@link DyeMenuProvider#hasMenuProvider()} before calling)
|
||||
*/
|
||||
public static void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic) throws IllegalStateException {
|
||||
if (instance == null) {
|
||||
throw new IllegalStateException("Unable to open a dye menu without instance of it.");
|
||||
}
|
||||
instance.openMenu(viewer, cosmeticHolder, cosmetic);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does HMCC have a dye menu provider already set?
|
||||
* @return True if it is already set and locked; false if none have been set.
|
||||
*/
|
||||
public static boolean hasMenuProvider() {
|
||||
return instance != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.special.impl;
|
||||
|
||||
import com.hibiscusmc.hmccolor.HMCColorApi;
|
||||
import com.hibiscusmc.hmccolor.shaded.gui.guis.Gui;
|
||||
import com.hibiscusmc.hmccolor.shaded.gui.guis.GuiItem;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import me.lojosho.hibiscuscommons.util.AdventureUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class HMCColorDyeMenu implements DyeMenu {
|
||||
|
||||
@Override
|
||||
public void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic) {
|
||||
ItemStack originalItem = cosmetic.getItem();
|
||||
if (originalItem == null || !cosmetic.isDyeable()) return;
|
||||
|
||||
Gui gui = HMCColorApi.createColorMenu(viewer);
|
||||
gui.updateTitle(AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(viewer, Settings.getDyeMenuName())));
|
||||
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
||||
gui.setDefaultTopClickAction(event -> {
|
||||
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
||||
ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot());
|
||||
if (item == null) return;
|
||||
|
||||
Color color = NMSHandlers.getHandler().getUtilHandler().getColor(item);
|
||||
if (color == null) return;
|
||||
|
||||
addCosmetic(viewer, cosmeticHolder, cosmetic, color);
|
||||
event.setCancelled(true);
|
||||
} else event.setCancelled(true);
|
||||
});
|
||||
|
||||
gui.setPlayerInventoryAction(event -> event.setCancelled(true));
|
||||
gui.setCloseGuiAction(event -> {});
|
||||
gui.open(viewer);
|
||||
}
|
||||
|
||||
private void addCosmetic(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic, @Nullable Color color) {
|
||||
cosmeticHolder.addCosmetic(cosmetic, color);
|
||||
viewer.setItemOnCursor(new ItemStack(Material.AIR));
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
viewer.closeInventory();
|
||||
cosmeticHolder.updateCosmetic(cosmetic.getSlot());
|
||||
}, 2);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,23 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.type;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Type {
|
||||
|
||||
@@ -18,11 +32,87 @@ public abstract class Type {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void run(CosmeticUser user, ConfigurationNode config) {
|
||||
run(user, config, null);
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, ConfigurationNode config) {
|
||||
run(viewer, cosmeticHolder, config, null);
|
||||
}
|
||||
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, ConfigurationNode config, ClickType clickType) {
|
||||
run(CosmeticHolder.ensureSingleCosmeticUser(viewer, cosmeticHolder), config, clickType);
|
||||
}
|
||||
|
||||
public void run(CosmeticUser user, ConfigurationNode config) {
|
||||
final var player = user.getPlayer();
|
||||
if (player == null) return;
|
||||
run(player, user, config, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Override {@link #run(Player, CosmeticHolder, ConfigurationNode, ClickType)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void run(CosmeticUser user, ConfigurationNode config, ClickType clickType);
|
||||
|
||||
public abstract ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta);
|
||||
public ItemStack setItem(Player viewer, CosmeticHolder cosmeticHolder, ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||
return setItem(CosmeticHolder.ensureSingleCosmeticUser(viewer, cosmeticHolder), config, itemStack, slot);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Override {@link #setItem(Player, CosmeticHolder, ConfigurationNode, ItemStack, int)} instead.
|
||||
*/
|
||||
public abstract ItemStack setItem(CosmeticUser user, ConfigurationNode config, ItemStack itemStack, int slot);
|
||||
|
||||
@Contract("_, _ -> param2")
|
||||
@NotNull
|
||||
@SuppressWarnings("Duplicates")
|
||||
protected ItemMeta processItemMeta(Player viewer, @NotNull ItemMeta itemMeta) {
|
||||
// New implementation - Paper and forks
|
||||
// I know this is a kinda batshit way to do it (with serializing and deserializing MiniMessage)
|
||||
// But currently I can't think of another good way of doing it without a big refactor. I'll come back to this
|
||||
// At a later date.
|
||||
if (HibiscusCommonsPlugin.isOnPaper()) {
|
||||
List<Component> processedLore = new ArrayList<>();
|
||||
if (itemMeta.hasDisplayName()) {
|
||||
String displayName = MiniMessage.miniMessage().serialize(itemMeta.displayName());
|
||||
displayName = Hooks.processPlaceholders(viewer, displayName);
|
||||
itemMeta.displayName(MiniMessage.miniMessage().deserialize(displayName).decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE));
|
||||
}
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
for (Component loreLine : itemMeta.lore()) {
|
||||
String loreStringLine = MiniMessage.miniMessage().serialize(loreLine);
|
||||
loreStringLine = Hooks.processPlaceholders(viewer, loreStringLine);
|
||||
processedLore.add(MiniMessage.miniMessage().deserialize(loreStringLine).decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
||||
skullMeta.setOwner(Hooks.processPlaceholders(viewer, skullMeta.getOwner()));
|
||||
}
|
||||
}
|
||||
|
||||
itemMeta.lore(processedLore);
|
||||
} else {
|
||||
// Legacy implementation - Spigot
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
if (itemMeta.hasDisplayName()) {
|
||||
itemMeta.setDisplayName(Hooks.processPlaceholders(viewer, itemMeta.getDisplayName()));
|
||||
}
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
for (String loreLine : itemMeta.getLore()) {
|
||||
processedLore.add(Hooks.processPlaceholders(viewer, loreLine));
|
||||
}
|
||||
}
|
||||
|
||||
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
||||
skullMeta.setOwner(Hooks.processPlaceholders(viewer, skullMeta.getOwner()));
|
||||
}
|
||||
}
|
||||
itemMeta.setLore(processedLore);
|
||||
}
|
||||
|
||||
return itemMeta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,18 +10,43 @@ public class Types {
|
||||
|
||||
private static final HashMap<String, Type> types = new HashMap<>();
|
||||
|
||||
private static TypeCosmetic TYPE_COSMETIC = new TypeCosmetic();
|
||||
private static TypeEmpty TYPE_EMPTY = new TypeEmpty();
|
||||
private static final TypeCosmetic TYPE_COSMETIC = new TypeCosmetic();
|
||||
private static final TypeEmpty TYPE_EMPTY = new TypeEmpty();
|
||||
|
||||
/**
|
||||
* Get's a Menu Item type. Add custom menu item types with {@link #addType(Type)}
|
||||
* @param id A non-case sensitive ID
|
||||
* @return The type of Menu Item
|
||||
*/
|
||||
public static Type getType(@NotNull String id) {
|
||||
return types.get(id.toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a type is valid. Add custom menu item types with {@link #addType(Type)}
|
||||
* @param id A non-case sensitive ID
|
||||
* @return True if exists, False if not.
|
||||
*/
|
||||
public static boolean isType(@NotNull String id) {
|
||||
return types.containsKey(id.toUpperCase());
|
||||
}
|
||||
|
||||
public static void addType(Type type) {
|
||||
types.put(type.getId().toUpperCase(), type);
|
||||
/**
|
||||
* Adds a Menu Item Type to the types HashMap for reference. Menu Types will automatically be added using this method.
|
||||
* @param type A non-null {@link Type} that'll be added. ID should be unique; can't be duplicated
|
||||
*/
|
||||
public static boolean addType(@NotNull Type type) {
|
||||
String id = type.getId().toUpperCase();
|
||||
if (types.containsKey(id)) return false;
|
||||
types.put(id, type);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default menu item; {@link TypeEmpty}
|
||||
* @return The empty menu type.
|
||||
*/
|
||||
public static TypeEmpty getDefaultType() {
|
||||
return TYPE_EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +1,83 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.type.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenuProvider;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
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 me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TypeCosmetic extends Type {
|
||||
|
||||
public TypeCosmetic(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public TypeCosmetic() {
|
||||
super("cosmetic");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||
if (config.node("cosmetic").virtual()) return;
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, ConfigurationNode config, ClickType clickType) {
|
||||
MessagesUtil.sendDebugMessages("Running Cosmetic Click Type");
|
||||
if (config.node("cosmetic").virtual()) {
|
||||
MessagesUtil.sendDebugMessages("Cosmetic Config Field Virtual");
|
||||
return;
|
||||
}
|
||||
String cosmeticName = config.node("cosmetic").getString();
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||
Player player = user.getPlayer();
|
||||
if (cosmetic == null) {
|
||||
MessagesUtil.sendMessage(player, "invalid-cosmetic");
|
||||
MessagesUtil.sendDebugMessages("No Cosmetic Found");
|
||||
MessagesUtil.sendMessage(viewer, "invalid-cosmetic");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.canEquipCosmetic(cosmetic)) {
|
||||
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
||||
if (!cosmeticHolder.canEquipCosmetic(cosmetic)) {
|
||||
MessagesUtil.sendDebugMessages("No Cosmetic Permission");
|
||||
MessagesUtil.sendMessage(viewer, "no-cosmetic-permission");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isUnEquippingCosmetic = false;
|
||||
if (cosmeticHolder.getCosmetic(cosmetic.getSlot()) == cosmetic) isUnEquippingCosmetic = true;
|
||||
|
||||
String dyeClick = Settings.getCosmeticDyeClickType();
|
||||
String requiredClick;
|
||||
if (isUnEquippingCosmetic) requiredClick = Settings.getCosmeticUnEquipClickType();
|
||||
else requiredClick = Settings.getCosmeticEquipClickType();
|
||||
|
||||
MessagesUtil.sendDebugMessages("Required click type: " + requiredClick);
|
||||
MessagesUtil.sendDebugMessages("Click type: " + clickType.name());
|
||||
|
||||
final boolean isRequiredClick = requiredClick.equalsIgnoreCase("ANY") || requiredClick.equalsIgnoreCase(clickType.name());
|
||||
final boolean isDyeClick = dyeClick.equalsIgnoreCase("ANY") || dyeClick.equalsIgnoreCase(clickType.name());
|
||||
|
||||
if (!isRequiredClick) isUnEquippingCosmetic = false;
|
||||
|
||||
List<String> actionStrings = new ArrayList<>();
|
||||
ConfigurationNode actionConfig = config.node("actions");
|
||||
|
||||
MessagesUtil.sendDebugMessages("Running Actions");
|
||||
|
||||
try {
|
||||
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
||||
|
||||
@@ -62,106 +88,106 @@ public class TypeCosmetic extends Type {
|
||||
if (clickType.isRightClick()) {
|
||||
if (!actionConfig.node("right-click").virtual()) actionStrings.addAll(actionConfig.node("right-click").getList(String.class));
|
||||
}
|
||||
if (clickType.equals(ClickType.SHIFT_LEFT)) {
|
||||
if (!actionConfig.node("shift-left-click").virtual()) actionStrings.addAll(actionConfig.node("shift-left-click").getList(String.class));
|
||||
}
|
||||
if (clickType.equals(ClickType.SHIFT_RIGHT)) {
|
||||
if (!actionConfig.node("shift-right-click").virtual()) actionStrings.addAll(actionConfig.node("shift-right-click").getList(String.class));
|
||||
}
|
||||
}
|
||||
|
||||
if (user.getCosmetic(cosmetic.getSlot()) == cosmetic) {
|
||||
if (isUnEquippingCosmetic) {
|
||||
if (!actionConfig.node("on-unequip").virtual()) actionStrings.addAll(actionConfig.node("on-unequip").getList(String.class));
|
||||
MessagesUtil.sendDebugMessages("on-unequip");
|
||||
user.removeCosmeticSlot(cosmetic);
|
||||
cosmeticHolder.removeCosmeticSlot(cosmetic);
|
||||
} else {
|
||||
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
|
||||
MessagesUtil.sendDebugMessages("on-equip");
|
||||
MessagesUtil.sendDebugMessages("Preparing for on-equip with the following checks:");
|
||||
MessagesUtil.sendDebugMessages("CosmeticDyeable? " + cosmetic.isDyeable() + " / isDyeClick? " + isDyeClick + " / isHMCColorActive? " + Hooks.isActiveHook("HMCColor"));
|
||||
// TODO: Redo this
|
||||
if (cosmetic.isDyable()) {
|
||||
DyeMenu.openMenu(user, cosmetic);
|
||||
} else {
|
||||
user.addPlayerCosmetic(cosmetic);
|
||||
if (cosmetic.isDyeable() && isDyeClick && DyeMenuProvider.hasMenuProvider()) {
|
||||
DyeMenuProvider.openMenu(viewer, cosmeticHolder, cosmetic);
|
||||
} else if (isRequiredClick) {
|
||||
cosmeticHolder.addCosmetic(cosmetic);
|
||||
}
|
||||
}
|
||||
|
||||
Actions.runActions(user, actionStrings);
|
||||
Actions.runActions(viewer, cosmeticHolder, actionStrings);
|
||||
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Fixes issue with offhand cosmetics not appearing. Yes, I know this is dumb
|
||||
Runnable run = () -> user.updateCosmetic(cosmetic.getSlot());
|
||||
Runnable run = () -> cosmeticHolder.updateCosmetic(cosmetic.getSlot());
|
||||
if (cosmetic instanceof CosmeticArmorType) {
|
||||
if (((CosmeticArmorType) cosmetic).getEquipSlot().equals(EquipmentSlot.OFF_HAND)) {
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
run.run();
|
||||
MessagesUtil.sendDebugMessages("Finished Type Click Run");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemMeta setLore(CosmeticUser user, @NotNull ConfigurationNode config, ItemMeta itemMeta) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||
run(user.getPlayer(), user, config, clickType);
|
||||
}
|
||||
|
||||
if (config.node("cosmetic").virtual()) return processLoreLines(user, itemMeta);;
|
||||
@Override
|
||||
public ItemStack setItem(CosmeticUser user, ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||
return setItem(user.getPlayer(), user, config, itemStack, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setItem(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
|
||||
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processItemMeta(viewer, itemStack.getItemMeta()));
|
||||
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta?");
|
||||
|
||||
if (config.node("cosmetic").virtual()) {
|
||||
return itemStack;
|
||||
}
|
||||
String cosmeticName = config.node("cosmetic").getString();
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||
if (cosmetic == null) {
|
||||
return processLoreLines(user, itemMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if (user.canEquipCosmetic(cosmetic)) {
|
||||
return processLoreLines(user, itemMeta);
|
||||
} else {
|
||||
ConfigurationNode itemConfig = config.node("item");
|
||||
if (itemConfig.virtual()) return itemMeta;
|
||||
if (itemConfig.node("locked-name").virtual() && itemConfig.node("locked-lore").virtual()) {
|
||||
return processLoreLines(user, itemMeta);
|
||||
if (cosmeticHolder.hasCosmeticInSlot(cosmetic) && (!config.node("equipped-item").virtual() || !config.node("locked-equipped-item").virtual())) {
|
||||
MessagesUtil.sendDebugMessages("GUI Equipped Item");
|
||||
ConfigurationNode equippedItem = config.node(cosmeticHolder.canEquipCosmetic(cosmetic, true) && !config.node("equipped-item").virtual() ? "equipped-item" : "locked-equipped-item");
|
||||
try {
|
||||
if (equippedItem.node("material").virtual()) equippedItem.node("material").set(config.node("item", "material").getString());
|
||||
} catch (SerializationException e) {
|
||||
// Nothing >:)
|
||||
}
|
||||
try {
|
||||
List<String> lockedLore = itemMeta.getLore();
|
||||
String lockedName = itemMeta.getDisplayName();
|
||||
|
||||
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());
|
||||
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, equippedItem);
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (!itemConfig.node("locked-name").virtual()) {
|
||||
lockedName = StringUtils.parseStringToString(Utils.replaceIfNull(itemConfig.node("locked-name").getString(), ""));
|
||||
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processItemMeta(viewer, itemStack.getItemMeta()));
|
||||
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in equipped item?");
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if (Hooks.isActiveHook("PlaceHolderAPI")) {
|
||||
lockedName = PlaceholderAPI.setPlaceholders(user.getPlayer(), lockedName);
|
||||
if (!cosmeticHolder.canEquipCosmetic(cosmetic, true) && !config.node("locked-item").virtual()) {
|
||||
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 >:)
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
itemMeta.setLore(processedLore);
|
||||
return itemMeta;
|
||||
}
|
||||
|
||||
@Contract("_, _ -> param2")
|
||||
@NotNull
|
||||
@SuppressWarnings("Duplicates")
|
||||
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
for (String loreLine : itemMeta.getLore()) {
|
||||
if (Hooks.isActiveHook("PlaceholderAPI"))
|
||||
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
||||
processedLore.add(loreLine);
|
||||
}
|
||||
}
|
||||
|
||||
itemMeta.setLore(processedLore);
|
||||
return itemMeta;
|
||||
try {
|
||||
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, lockedItem);
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processItemMeta(viewer, itemStack.getItemMeta()));
|
||||
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in locked item?");
|
||||
return itemStack;
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.type.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -22,9 +23,10 @@ public class TypeEmpty extends Type {
|
||||
// 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 the code that's run when the item is clicked.
|
||||
// This is the code that's run when the item is clicked. The item is clicked by the "viewer" player in a menu for the
|
||||
// given "cosmeticHolder". They're the same player by default, but it's not guaranteed.
|
||||
@Override
|
||||
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||
public void run(Player viewer, CosmeticHolder cosmeticHolder, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||
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.
|
||||
|
||||
@@ -42,29 +44,42 @@ public class TypeEmpty extends Type {
|
||||
if (clickType.isRightClick()) {
|
||||
if (!actionConfig.node("right-click").virtual()) actionStrings.addAll(actionConfig.node("right-click").getList(String.class));
|
||||
}
|
||||
if (clickType.equals(ClickType.SHIFT_LEFT)) {
|
||||
if (!actionConfig.node("shift-left-click").virtual()) actionStrings.addAll(actionConfig.node("shift-left-click").getList(String.class));
|
||||
}
|
||||
if (clickType.equals(ClickType.SHIFT_RIGHT)) {
|
||||
if (!actionConfig.node("shift-right-click").virtual()) actionStrings.addAll(actionConfig.node("shift-right-click").getList(String.class));
|
||||
}
|
||||
}
|
||||
|
||||
// We run the actions once we got the raw strings from the config.
|
||||
Actions.runActions(user, actionStrings);
|
||||
Actions.runActions(viewer, cosmeticHolder, actionStrings);
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// backward-compatibility method, will not be required in the future
|
||||
@Override
|
||||
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
|
||||
final var player = user.getPlayer();
|
||||
if (player == null) return;
|
||||
run(player, user, config, clickType);
|
||||
}
|
||||
|
||||
// backward-compatibility method, will not be required in the future
|
||||
@Override
|
||||
public ItemStack setItem(CosmeticUser user, ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||
return setItem(user.getPlayer(), user, config, itemStack, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("Duplicates")
|
||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, @NotNull ItemMeta itemMeta) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
public ItemStack setItem(Player viewer, CosmeticHolder cosmeticHolder, ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
for (String loreLine : itemMeta.getLore()) {
|
||||
if (Hooks.isActiveHook("PlaceholderAPI"))
|
||||
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
||||
processedLore.add(loreLine);
|
||||
}
|
||||
}
|
||||
|
||||
return itemMeta;
|
||||
itemStack.setItemMeta(processItemMeta(viewer, 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.
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public Hook(@NotNull String id) {
|
||||
this.id = id;
|
||||
Hooks.addHook(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() { }
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id of this hook
|
||||
*
|
||||
* @return The unique id for this hook
|
||||
*/
|
||||
@NotNull
|
||||
public final String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookCMI;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookHMCColor;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookPremiumVanish;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.HookSuperVanish;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Hooks {
|
||||
|
||||
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
||||
private static HookOraxen ORAXEN_HOOK = new HookOraxen();
|
||||
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
||||
private static HookLooty LOOTY_HOOK = new HookLooty();
|
||||
private static HookMythic MYTHIC_HOOK = new HookMythic();
|
||||
private static HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
||||
private static HookPlaceholderAPI PAPI_HOOK = new HookPlaceholderAPI();
|
||||
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
||||
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
||||
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
||||
private static HookCMI CMI_HOOK = new HookCMI();
|
||||
|
||||
public static Hook getHook(@NotNull String id) {
|
||||
return hooks.get(id.toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean isItemHook(@NotNull String id) {
|
||||
return hooks.containsKey(id.toLowerCase());
|
||||
}
|
||||
|
||||
public static void addHook(Hook hook) {
|
||||
hooks.put(hook.getId().toLowerCase(), hook);
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
for (Hook hook : hooks.values()) {
|
||||
if (Bukkit.getPluginManager().getPlugin(hook.getId()) != null) {
|
||||
HMCCosmeticsPlugin.getInstance().getServer().getPluginManager().registerEvents(hook, HMCCosmeticsPlugin.getInstance());
|
||||
hook.setActive(true);
|
||||
hook.load();
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Successfully hooked into " + hook.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemStack getItem(@NotNull String raw) {
|
||||
if (!raw.contains(":")) {
|
||||
Material mat = Material.getMaterial(raw.toUpperCase());
|
||||
if (mat == null) return null;
|
||||
return new ItemStack(mat);
|
||||
}
|
||||
// Ex. Oraxen:BigSword
|
||||
// split[0] is the plugin name
|
||||
// split[1] is the item name
|
||||
String[] split = raw.split(":", 2);
|
||||
|
||||
if (!isItemHook(split[0])) return null;
|
||||
Hook hook = getHook(split[0]);
|
||||
if (!hook.hasEnabledItemHook()) return null;
|
||||
if (!hook.isActive()) return null;
|
||||
return hook.getItem(split[1]);
|
||||
}
|
||||
|
||||
public static boolean isActiveHook(String id) {
|
||||
Hook hook = getHook(id);
|
||||
if (hook == null) return false;
|
||||
return hook.isActive();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||
import me.lojosho.hibiscuscommons.hooks.HookFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -11,8 +12,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class HookHMCCosmetics extends Hook {
|
||||
public HookHMCCosmetics() {
|
||||
super("HMCCosmetics");
|
||||
setEnabledItemHook(true);
|
||||
super("HMCCosmetics", HookFlag.ITEM_SUPPORT);
|
||||
setActive(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,4 +26,3 @@ public class HookHMCCosmetics extends Hook {
|
||||
return cosmetic.getItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} to provide custom items
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class HookItemAdder extends Hook {
|
||||
private boolean enabled = false;
|
||||
|
||||
public HookItemAdder() {
|
||||
super("itemsadder");
|
||||
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
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
if (enabled) {
|
||||
CustomStack stack = CustomStack.getInstance(itemId);
|
||||
if (stack == null) return null;
|
||||
return stack.getItemStack();
|
||||
} else {
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
||||
// By default, it will only run once at startup, if hook setting is enabled
|
||||
if (enabled && !Settings.getItemsAdderReloadChange()) return;
|
||||
this.enabled = true;
|
||||
HMCCosmeticsPlugin.setup();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +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.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link com.mineinabyss.looty.LootyPlugin Looty} to provide custom items
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class HookLooty extends Hook {
|
||||
public HookLooty() {
|
||||
super("looty");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.looty.LootyPlugin Looty}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||
if (prefabKey == null) return null;
|
||||
return LootyFactory.INSTANCE.createFromPrefab(prefabKey);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import io.lumine.mythic.bukkit.MythicBukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
super("mythicmobs");
|
||||
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
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import io.th0rgal.oraxen.api.OraxenItems;
|
||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
super("oraxen");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
ItemBuilder builder = OraxenItems.getItemById(itemId);
|
||||
if (builder == null) return null;
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerWardrobeEnterEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerWardrobeLeaveEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import kr.toxicity.hud.api.BetterHud;
|
||||
import kr.toxicity.hud.api.player.HudPlayer;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class HookBetterHud extends Hook {
|
||||
|
||||
public HookBetterHud() {
|
||||
super("BetterHUD");
|
||||
setActive(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onPlayerEnterWardrobe(@NotNull PlayerWardrobeEnterEvent event) {
|
||||
if (!Settings.isWardrobeHideHud()) return;
|
||||
UUID uuid = event.getUniqueId();
|
||||
HudPlayer hudPlayer = BetterHud.getInstance().getPlayerManager().getHudPlayer(uuid);
|
||||
if (hudPlayer == null) return;
|
||||
hudPlayer.setHudEnabled(false);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onPlayerLeaveWardrobe(@NotNull PlayerWardrobeLeaveEvent event) {
|
||||
if (!Settings.isWardrobeHideHud()) return;
|
||||
UUID uuid = event.getUniqueId();
|
||||
HudPlayer hudPlayer = BetterHud.getInstance().getPlayerManager().getHudPlayer(uuid);
|
||||
if (hudPlayer == null) return;
|
||||
hudPlayer.setHudEnabled(true);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user