mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-07 12:37:14 +01:00
Compare commits
758 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55c52a83ac | ||
|
|
abb85e6d16 | ||
|
|
44ac2589a3 | ||
|
|
5ab5d06fc6 | ||
|
|
8814126d47 | ||
|
|
21902c5fa3 | ||
|
|
3e75070375 | ||
|
|
59ec9bee5a | ||
|
|
95896416e6 | ||
|
|
ebc62c6fd2 | ||
|
|
a065d620cb | ||
|
|
873c9bf727 | ||
|
|
3bf99821ef | ||
|
|
6d8f223591 | ||
|
|
3b34193caa | ||
|
|
757f6ee9ae | ||
|
|
c308769e6d | ||
|
|
98b7ef68ec | ||
|
|
62f6eb4e54 | ||
|
|
5f4839390c | ||
|
|
fb57b70546 | ||
|
|
ee392322c6 | ||
|
|
6f61c0eb31 | ||
|
|
db79cf6340 | ||
|
|
fa50fd14a5 | ||
|
|
085b09e019 | ||
|
|
6e3e64d3f8 | ||
|
|
400857f18b | ||
|
|
7111fef559 | ||
|
|
722279308a | ||
|
|
2d9f4fca77 | ||
|
|
cb5b9a8bb9 | ||
|
|
880ddc22b5 | ||
|
|
d378f782b4 | ||
|
|
1f2d969a69 | ||
|
|
cac79a26af | ||
|
|
8b078f9058 | ||
|
|
d3a5d01f55 | ||
|
|
9a677d46a1 | ||
|
|
8116cbb385 | ||
|
|
b9affd0879 | ||
|
|
ec8657015c | ||
|
|
38a86e6d2d | ||
|
|
35376e43ca | ||
|
|
1c233ec297 | ||
|
|
967dec09ff | ||
|
|
85aa6ae8ae | ||
|
|
83aad38b09 | ||
|
|
b0fb784079 | ||
|
|
84948101f4 | ||
|
|
5dea70532c | ||
|
|
403adeb217 | ||
|
|
a81ed63c0f | ||
|
|
38da700168 | ||
|
|
4a085682dc | ||
|
|
cfed3ce31b | ||
|
|
4c62318338 | ||
|
|
7247cbb9f7 | ||
|
|
9ed7a7ae56 | ||
|
|
9a356ceecf | ||
|
|
e0ac7b1c66 | ||
|
|
82230d8156 | ||
|
|
cda55f20aa | ||
|
|
0df7a01fd8 | ||
|
|
b49668ddee | ||
|
|
f14b081f0b | ||
|
|
b51fbf4e13 | ||
|
|
e48b6fe702 | ||
|
|
984f944daf | ||
|
|
0575c8cf41 | ||
|
|
c181d18f5e | ||
|
|
2e0d9eb846 | ||
|
|
33d1009d6a | ||
|
|
b16d62fb75 | ||
|
|
e019d6370c | ||
|
|
581b73dbc7 | ||
|
|
25f7eafe32 | ||
|
|
ef22d564f3 | ||
|
|
787a053d98 | ||
|
|
f31dd2bea9 | ||
|
|
5c8086150a | ||
|
|
b838d1c52a | ||
|
|
0a712e6530 | ||
|
|
272e2e7904 | ||
|
|
98082398fc | ||
|
|
c66806ecf8 | ||
|
|
c97f5aa5a6 | ||
|
|
c1487898a9 | ||
|
|
907ced6d7d | ||
|
|
ac771207c3 | ||
|
|
8b031576aa | ||
|
|
2d1a0ee157 | ||
|
|
b9e2bf9429 | ||
|
|
a35923a117 | ||
|
|
d5e96bd6a6 | ||
|
|
2523b6c094 | ||
|
|
7b230fc679 | ||
|
|
68f467ab29 | ||
|
|
068b5a31b2 | ||
|
|
882b7c5965 | ||
|
|
7a0be5edf8 | ||
|
|
e94328935d | ||
|
|
604fed36a4 | ||
|
|
403622d205 | ||
|
|
1cd4d93f7f | ||
|
|
a83ef75bf9 | ||
|
|
b96e535aaa | ||
|
|
2e67272aea | ||
|
|
2c7767e77d | ||
|
|
c4a046ff24 | ||
|
|
57fa68c896 | ||
|
|
b64f024eb2 | ||
|
|
c7a4900aa3 | ||
|
|
491abd6238 | ||
|
|
d3646a9874 | ||
|
|
af0b475330 | ||
|
|
d35a499e31 | ||
|
|
c0f824450e | ||
|
|
5b1a8ef4ba | ||
|
|
5623a00f9b | ||
|
|
4926907b47 | ||
|
|
32f3d14682 | ||
|
|
152105017d | ||
|
|
be956f52b0 | ||
|
|
195158b18b | ||
|
|
36fa9ac96d | ||
|
|
42cfe1dc80 | ||
|
|
92a7d54664 | ||
|
|
f91b4e3752 | ||
|
|
a497e05e55 | ||
|
|
74d8fec6bd | ||
|
|
28287c7fbd | ||
|
|
744cf6d8c0 | ||
|
|
ecd4c002c8 | ||
|
|
b4e60b7db5 | ||
|
|
e862abe0b4 | ||
|
|
2d946646f0 | ||
|
|
5ab61e0cd3 | ||
|
|
81ef464dad | ||
|
|
0ae0ddc9cb | ||
|
|
3d00d48106 | ||
|
|
7e902cae66 | ||
|
|
f4e4433b16 | ||
|
|
d5c371004c | ||
|
|
e246473782 | ||
|
|
4afad7f7b0 | ||
|
|
a0b177bdd8 | ||
|
|
40b1fe8d68 | ||
|
|
9ee4afa1e9 | ||
|
|
1cf66b130c | ||
|
|
c3cfc82eb3 | ||
|
|
3afb634e58 | ||
|
|
d888d9754b | ||
|
|
4c228ca4fb | ||
|
|
6cf987586e | ||
|
|
46d9a69534 | ||
|
|
af8cc09fca | ||
|
|
452c8ccd42 | ||
|
|
054c780fd1 | ||
|
|
83261eee49 | ||
|
|
3fca78626a | ||
|
|
a2456c582d | ||
|
|
b987916328 | ||
|
|
23ef4ecb62 | ||
|
|
8b7a217796 | ||
|
|
74ebb0bec0 | ||
|
|
794c8890e5 | ||
|
|
013e566a85 | ||
|
|
5a4a8c2e7e | ||
|
|
0b068470ac | ||
|
|
f3cb7635c2 | ||
|
|
8e21a76118 | ||
|
|
1dad2381e5 | ||
|
|
9767811cb9 | ||
|
|
e6fb6d5ec6 | ||
|
|
1acc621f2e | ||
|
|
d9bab03e3b | ||
|
|
9baf5f58ae | ||
|
|
077d64dc68 | ||
|
|
b8d5886cad | ||
|
|
52119682f3 | ||
|
|
651e14a797 | ||
|
|
0ac62d6b63 | ||
|
|
0be6b721cf | ||
|
|
0e0e36476a | ||
|
|
a56b3b62b9 | ||
|
|
883f1c1edf | ||
|
|
bfc30a8703 | ||
|
|
37c39ab734 | ||
|
|
35c47a8745 | ||
|
|
fadf14a316 | ||
|
|
1388a5278f | ||
|
|
3bc6ad0f06 | ||
|
|
bb149811d4 | ||
|
|
350a2be0ed | ||
|
|
b73d72cec7 | ||
|
|
7afb8ee36d | ||
|
|
1241c33ba0 | ||
|
|
631609af74 | ||
|
|
fe8d865657 | ||
|
|
50d4e14333 | ||
|
|
666ab468a1 | ||
|
|
151fb08db8 | ||
|
|
cd9074203c | ||
|
|
38d77ff4ca | ||
|
|
3ccbbe9c20 | ||
|
|
358a3bcab3 | ||
|
|
ca088227c3 | ||
|
|
69fd180c9b | ||
|
|
38e6e02e1b | ||
|
|
a71b8657f1 | ||
|
|
850633e792 | ||
|
|
348b075ac5 | ||
|
|
ce18d3b597 | ||
|
|
9d66d9d9a1 | ||
|
|
5fe9389dda | ||
|
|
e25a28b2a5 | ||
|
|
cfd289939e | ||
|
|
d168be94b1 | ||
|
|
511717a8d6 | ||
|
|
18fb194ce6 | ||
|
|
e11d551071 | ||
|
|
020f14d82c | ||
|
|
acb5728e65 | ||
|
|
cc235cfc01 | ||
|
|
894dcd0a2f | ||
|
|
41c9231664 | ||
|
|
31deef2a62 | ||
|
|
3ba29f1147 | ||
|
|
e969f37405 | ||
|
|
b9a5f4445f | ||
|
|
6f87955898 | ||
|
|
d68af58df5 | ||
|
|
6e1eb88585 | ||
|
|
0798d94449 | ||
|
|
aa68a481ee | ||
|
|
6f5853746d | ||
|
|
416fbc0e3e | ||
|
|
407714c13f | ||
|
|
aa13ddf17e | ||
|
|
d9da5a706c | ||
|
|
80446de15b | ||
|
|
0647f88de5 | ||
|
|
38099198d6 | ||
|
|
6f2f1f1cf1 | ||
|
|
5e4d3f7135 | ||
|
|
327078d8dd | ||
|
|
1b7fabf238 | ||
|
|
66025a6a1c | ||
|
|
04f2c85722 | ||
|
|
7b5ceb520f | ||
|
|
f7dc184899 | ||
|
|
4300bf7d1e | ||
|
|
5412b484f8 | ||
|
|
af2f625224 | ||
|
|
d2a4f038d0 | ||
|
|
7e28dc0a41 | ||
|
|
b82948c87a | ||
|
|
39c68e8f87 | ||
|
|
5a24387f3d | ||
|
|
cd429bd7d7 | ||
|
|
a383a73b24 | ||
|
|
7baaa5233d | ||
|
|
b35035390e | ||
|
|
1b0a3bc09d | ||
|
|
3817f52158 | ||
|
|
663f149d74 | ||
|
|
3da8f00664 | ||
|
|
c24c75c8c0 | ||
|
|
c401adee86 | ||
|
|
1dd3e1fc0d | ||
|
|
1f53daf416 | ||
|
|
8105beeee0 | ||
|
|
8c9a20c035 | ||
|
|
c1d2effe7e | ||
|
|
2eda4b1335 | ||
|
|
ff72450d3f | ||
|
|
a654262196 | ||
|
|
fa705e4572 | ||
|
|
e687a06d6e | ||
|
|
08c43d25e7 | ||
|
|
48da25659d | ||
|
|
905c9e83ee | ||
|
|
54ddc9fd4d | ||
|
|
fe0bb12d53 | ||
|
|
e6da5f291e | ||
|
|
d674893312 | ||
|
|
9da9e8c20f | ||
|
|
33c309ee8e | ||
|
|
62c3261a00 | ||
|
|
c393392b85 | ||
|
|
fbf91d6393 | ||
|
|
8d30c4c99d | ||
|
|
721904335d | ||
|
|
d79f9725bd | ||
|
|
eb2decb93d | ||
|
|
d2192e3195 | ||
|
|
c01acfba77 | ||
|
|
a494add04c | ||
|
|
059047905f | ||
|
|
fa717c34ef | ||
|
|
e16287405b | ||
|
|
afdf80bf00 | ||
|
|
ec7943fe0a | ||
|
|
6493963d8a | ||
|
|
c48e11bd70 | ||
|
|
b4f6831e54 | ||
|
|
6348c88c6f | ||
|
|
5fb45d13da | ||
|
|
5710972288 | ||
|
|
63955511a8 | ||
|
|
9a7790c808 | ||
|
|
3abc78ff64 | ||
|
|
c4789b7db0 | ||
|
|
d7a4acc2f5 | ||
|
|
dd7751332f | ||
|
|
7b50453294 | ||
|
|
fa7c30df80 | ||
|
|
89053354e9 | ||
|
|
ead63ca763 | ||
|
|
0fa592383f | ||
|
|
7df3a5c6e0 | ||
|
|
c4a2256fff | ||
|
|
9b6b558002 | ||
|
|
94bf5fea57 | ||
|
|
252802dcbe | ||
|
|
8932a92049 | ||
|
|
679ef90091 | ||
|
|
ac9b0c42b7 | ||
|
|
14d885392c | ||
|
|
0c102a1823 | ||
|
|
4c968f012d | ||
|
|
ba71486151 | ||
|
|
e1269d6c86 | ||
|
|
438a665b74 | ||
|
|
247a5cde8f | ||
|
|
aa9ac65d02 | ||
|
|
ba983f7fb3 | ||
|
|
af268c4941 | ||
|
|
4c4b1602d9 | ||
|
|
8c69a164b8 | ||
|
|
df8583df57 | ||
|
|
09e68e7510 | ||
|
|
2c223ffc87 | ||
|
|
5571ba5d70 | ||
|
|
b77b1b9649 | ||
|
|
bf9b34eb57 | ||
|
|
215fd7e3f0 | ||
|
|
aca624c2d3 | ||
|
|
5826390251 | ||
|
|
a91a5c85ba | ||
|
|
156243a549 | ||
|
|
eceb236121 | ||
|
|
71b5433326 | ||
|
|
2c8314200f | ||
|
|
0b70ea61aa | ||
|
|
ac31e107ad | ||
|
|
b9230ef9c5 | ||
|
|
06e6765870 | ||
|
|
5ac579e878 | ||
|
|
a4d8009ce4 | ||
|
|
0df265881a | ||
|
|
5dbd58076a | ||
|
|
c3922de323 | ||
|
|
0f118f12bc | ||
|
|
edd3153acd | ||
|
|
748b9f33f7 | ||
|
|
230e36c55e | ||
|
|
0f7294972e | ||
|
|
d14f319eb4 | ||
|
|
0927760d76 | ||
|
|
91af12f575 | ||
|
|
5dbbe01b95 | ||
|
|
30b5abda19 | ||
|
|
a8e996fa26 | ||
|
|
3f83312454 | ||
|
|
0b1bd1c265 | ||
|
|
b747720f36 | ||
|
|
be34f28fd3 | ||
|
|
9843d84ac3 | ||
|
|
37de42f4a7 | ||
|
|
5595bc144f | ||
|
|
9b2e7bb3ca | ||
|
|
8b5ead7a13 | ||
|
|
0c6dd5466c | ||
|
|
41275509b2 | ||
|
|
4e8b1b47d1 | ||
|
|
d0e62e6434 | ||
|
|
2086fcb299 | ||
|
|
b3ea920b41 | ||
|
|
001fa6bcf2 | ||
|
|
3a31c5cb78 | ||
|
|
20b2a69b5e | ||
|
|
682717660f | ||
|
|
7b7bfb7306 | ||
|
|
09043c6aaf | ||
|
|
f711500d80 | ||
|
|
8d6aa7c801 | ||
|
|
04968cb437 | ||
|
|
048c539fff | ||
|
|
501d1bbbdd | ||
|
|
e4a6faa22a | ||
|
|
c3bdc90168 | ||
|
|
79ec3c8f95 | ||
|
|
e9e4caf989 | ||
|
|
0b1a3ced9e | ||
|
|
b55261a62f | ||
|
|
8c633c8943 | ||
|
|
8757217fb6 | ||
|
|
8f796e3940 | ||
|
|
bf1527a40f | ||
|
|
a65de95b16 | ||
|
|
fb8572313e | ||
|
|
2fc28777b7 | ||
|
|
ffd493fea9 | ||
|
|
b207cbf03e | ||
|
|
72239801d8 | ||
|
|
33ff83d102 | ||
|
|
031625e241 | ||
|
|
ec127dbeb1 | ||
|
|
5d80119fcd | ||
|
|
f6c972c9a2 | ||
|
|
a0b256c17d | ||
|
|
a66cae9a6b | ||
|
|
7f6122f8b8 | ||
|
|
ee7257208a | ||
|
|
87ea46a4dd | ||
|
|
d221a3f38a | ||
|
|
f62980606a | ||
|
|
c2ab9f5b85 | ||
|
|
2c925983a8 | ||
|
|
375e743124 | ||
|
|
78f76c8343 | ||
|
|
33e4743e89 | ||
|
|
b9b7104f6b | ||
|
|
a45f420069 | ||
|
|
a7d92f569f | ||
|
|
73f55735b4 | ||
|
|
a15c6b4855 | ||
|
|
48f7ffe089 | ||
|
|
c607338003 | ||
|
|
66a7a6d199 | ||
|
|
1d7bf239ea | ||
|
|
43a5db7711 | ||
|
|
0e56ea9503 | ||
|
|
d640d801e6 | ||
|
|
b5c70dedcb | ||
|
|
a8bcf0e14d | ||
|
|
0c13004040 | ||
|
|
cc05a3508b | ||
|
|
458030c575 | ||
|
|
3b4641c26c | ||
|
|
9b03af17b6 | ||
|
|
72b2be4933 | ||
|
|
2f0f717d44 | ||
|
|
e3bef564f2 | ||
|
|
319be0e043 | ||
|
|
431483da89 | ||
|
|
d07376245c | ||
|
|
2aa6ac2b63 | ||
|
|
03a362817c | ||
|
|
2dc972423a | ||
|
|
4b43d35bcc | ||
|
|
350ec10186 | ||
|
|
0104e48b72 | ||
|
|
a88f7aab30 | ||
|
|
e91ed337cc | ||
|
|
32d5b7697d | ||
|
|
c23d35d219 | ||
|
|
6b04b6c39b | ||
|
|
021d5b1f47 | ||
|
|
b0f14c6e4e | ||
|
|
cd3a0f52d5 | ||
|
|
cc5835423f | ||
|
|
155fc0592a | ||
|
|
a163c72e93 | ||
|
|
562f6a852d | ||
|
|
bfb88781af | ||
|
|
ff4656bbe7 | ||
|
|
c44b08e2e9 | ||
|
|
4d14b583ff | ||
|
|
892f0727e8 | ||
|
|
3635ecb8b4 | ||
|
|
dd2981b13e | ||
|
|
ff60343089 | ||
|
|
fb77c42bba | ||
|
|
a65b9ad49e | ||
|
|
0ed32c7ddd | ||
|
|
f1350783fc | ||
|
|
5ac2efd9c6 | ||
|
|
a7247acbb3 | ||
|
|
0b3663ee87 | ||
|
|
ba9b38dd0e | ||
|
|
62bb68ee94 | ||
|
|
e96c6fb7ef | ||
|
|
c04c101de5 | ||
|
|
5ab2c05821 | ||
|
|
9b9e0e4b9e | ||
|
|
c3ee5bbdc0 | ||
|
|
fb70ba6403 | ||
|
|
f605db479b | ||
|
|
175308ecf5 | ||
|
|
2adf2845fd | ||
|
|
0438c67f7d | ||
|
|
47d6928b9f | ||
|
|
deee5a1c39 | ||
|
|
c9492564e0 | ||
|
|
0c826a288e | ||
|
|
093ba4d68c | ||
|
|
1478aabb5e | ||
|
|
07ac8e41c5 | ||
|
|
f0dccbd594 | ||
|
|
26fdedd989 | ||
|
|
d342c73f24 | ||
|
|
0a52ef7219 | ||
|
|
6a69ec833f | ||
|
|
b540127651 | ||
|
|
8fa0f73a46 | ||
|
|
077a221c3f | ||
|
|
301a1c9ac5 | ||
|
|
0db15f96ae | ||
|
|
9b2ea05875 | ||
|
|
27d8ae03e1 | ||
|
|
15e22ea115 | ||
|
|
f398854c68 | ||
|
|
29446c08b6 | ||
|
|
3d44f8ffdc | ||
|
|
61afb24d33 | ||
|
|
e8b5660eda | ||
|
|
d4744838ee | ||
|
|
32f3e21ab7 | ||
|
|
e6d57f81da | ||
|
|
818bf91c93 | ||
|
|
ac2c2b324e | ||
|
|
cf9d07a856 | ||
|
|
860239fa2b | ||
|
|
69f0ede0c6 | ||
|
|
480f13a3ce | ||
|
|
b99335e5b2 | ||
|
|
e83eba9226 | ||
|
|
278a5a4096 | ||
|
|
1cfa247f8c | ||
|
|
a3b2777d16 | ||
|
|
3c9f6ea520 | ||
|
|
15d2452b19 | ||
|
|
f582474fb1 | ||
|
|
b1662676f1 | ||
|
|
23943f41ad | ||
|
|
3cd665a159 | ||
|
|
4074192c0b | ||
|
|
59cd5982ad | ||
|
|
b3893c38db | ||
|
|
a3d6426084 | ||
|
|
30a194c75d | ||
|
|
6431bcdeca | ||
|
|
0d1978cece | ||
|
|
e7e9e81e85 | ||
|
|
ba22201311 | ||
|
|
f799835dd0 | ||
|
|
6f3dcf04fe | ||
|
|
6b03c38e40 | ||
|
|
f756fbb43b | ||
|
|
f84702e3b2 | ||
|
|
9c750f50a2 | ||
|
|
dcca454bad | ||
|
|
ffef826c94 | ||
|
|
15e0a293eb | ||
|
|
11ed822845 | ||
|
|
1e4af86172 | ||
|
|
5f9dffc3c7 | ||
|
|
93e83efb57 | ||
|
|
0d9485ddec | ||
|
|
1248010566 | ||
|
|
d68fe7067c | ||
|
|
e16497618c | ||
|
|
4cfd419565 | ||
|
|
f52bdbc458 | ||
|
|
433dd7020c | ||
|
|
4fef2dd82a | ||
|
|
1e6fb502a6 | ||
|
|
b56ab1408e | ||
|
|
5dae844181 | ||
|
|
329b46c042 | ||
|
|
e2dd16cf1c | ||
|
|
dc244849a1 | ||
|
|
736de5b633 | ||
|
|
b31767ba4a | ||
|
|
ae06fcd807 | ||
|
|
7108ffbb31 | ||
|
|
7a6b6d7ce4 | ||
|
|
549a30b502 | ||
|
|
c64946173b | ||
|
|
5bca9dc41f | ||
|
|
5c830d7102 | ||
|
|
400c0d5b5d | ||
|
|
c53d5b2abf | ||
|
|
a842095fff | ||
|
|
c6e36fec2c | ||
|
|
fa7eeb5852 | ||
|
|
b6bfe3f3ef | ||
|
|
d6cfc8beae | ||
|
|
83c35ced32 | ||
|
|
b9bdb3167a | ||
|
|
dfec6c4c8b | ||
|
|
35838aa229 | ||
|
|
ee0df86f84 | ||
|
|
0650de95d6 | ||
|
|
279f1d0c07 | ||
|
|
5a8738e711 | ||
|
|
00b95461b6 | ||
|
|
a74f78bd73 | ||
|
|
9d35f4c3e6 | ||
|
|
325cd2d284 | ||
|
|
d4f0eb91ef | ||
|
|
5ab228d1d8 | ||
|
|
64e0f7e500 | ||
|
|
7998d4d666 | ||
|
|
2a91d34a65 | ||
|
|
ac717c7600 | ||
|
|
e13b91cb22 | ||
|
|
fdfca9da42 | ||
|
|
1556e15a1a | ||
|
|
7691dd93ad | ||
|
|
2c13acfd30 | ||
|
|
40f1fcbce2 | ||
|
|
456958d647 | ||
|
|
7c404db56b | ||
|
|
18cfd438b8 | ||
|
|
d5e27252cf | ||
|
|
3fe0f0143c | ||
|
|
61a71b9e73 | ||
|
|
e542dabd52 | ||
|
|
9cde086436 | ||
|
|
fe02939466 | ||
|
|
f1c2315055 | ||
|
|
9681c518fc | ||
|
|
762bb409d3 | ||
|
|
0394ba284b | ||
|
|
3e9dcdb53c | ||
|
|
ddfaf4105d | ||
|
|
5b1df7c42a | ||
|
|
7555bb0f97 | ||
|
|
ab96120911 | ||
|
|
7371a576d6 | ||
|
|
5d5ceb5902 | ||
|
|
125d02fecd | ||
|
|
8c98a214f8 | ||
|
|
2a3e8dcec1 | ||
|
|
a996d9039e | ||
|
|
cfba92bf14 | ||
|
|
41f408226e | ||
|
|
58cfa92136 | ||
|
|
f3309b76d1 | ||
|
|
04bfa1e721 | ||
|
|
dc894c6212 | ||
|
|
7c7025fdbb | ||
|
|
97a4eca0a7 | ||
|
|
5e4110b1b3 | ||
|
|
d1e3047445 | ||
|
|
c72515912d | ||
|
|
eb5a93dce2 | ||
|
|
7cb3b3b7ec | ||
|
|
c648d6a541 | ||
|
|
2d72e274e3 | ||
|
|
b73d00e169 | ||
|
|
5065623ab0 | ||
|
|
8698449e5d | ||
|
|
722e987b93 | ||
|
|
a00cbf4be3 | ||
|
|
f235c60bef | ||
|
|
a1d69cd25f | ||
|
|
f7504b99ca | ||
|
|
02669e2435 | ||
|
|
3d2fca277f | ||
|
|
3e6d10e203 | ||
|
|
f828857ce3 | ||
|
|
eeb9c8d5db | ||
|
|
6d38f411ba | ||
|
|
542ffd6b7b | ||
|
|
2a559fd240 | ||
|
|
51844cd291 | ||
|
|
ec9d6295fb | ||
|
|
19a80c2d26 | ||
|
|
12a358fbd0 | ||
|
|
0982505574 | ||
|
|
e3d71843ac | ||
|
|
364635cd06 | ||
|
|
d3844711bc | ||
|
|
81038dab80 | ||
|
|
514e25454d | ||
|
|
203f02029c | ||
|
|
eb20a80b37 | ||
|
|
c2dc51c728 | ||
|
|
c38ecfc16c | ||
|
|
105b116529 | ||
|
|
6a78ff88d3 | ||
|
|
dcc8dad4ea | ||
|
|
cee6984818 | ||
|
|
8a751cddd5 | ||
|
|
91d370d883 | ||
|
|
18854647bf | ||
|
|
97fd3a3b5d | ||
|
|
0f8ce0c6c3 | ||
|
|
9d43b743a2 | ||
|
|
e43b7bf205 | ||
|
|
9412fed9ad | ||
|
|
c7de89bebe | ||
|
|
cc02c126b5 | ||
|
|
aed0d288f7 | ||
|
|
b4a914314a | ||
|
|
f6ba24e46f | ||
|
|
745f7926a6 | ||
|
|
62c93465f2 | ||
|
|
0e733b6933 | ||
|
|
2e28647497 | ||
|
|
9b2b6992c7 | ||
|
|
81aa425616 | ||
|
|
e932fabe64 | ||
|
|
9901e8bc24 | ||
|
|
8c15cdf7cb | ||
|
|
fc453a9d7f | ||
|
|
a232294b11 | ||
|
|
8c829417a7 | ||
|
|
94ce9d6a6e | ||
|
|
a843369ebd | ||
|
|
8e3c942282 | ||
|
|
d2945539b3 | ||
|
|
0281e5e346 | ||
|
|
c76baeae1c | ||
|
|
d12c746630 | ||
|
|
3f9205d2df | ||
|
|
fbdd789dbe | ||
|
|
b521fe4a1f | ||
|
|
b24b127ad5 | ||
|
|
8a12d324e3 | ||
|
|
51975cbe40 | ||
|
|
f6e6394a74 | ||
|
|
466509c578 | ||
|
|
ee86fa7460 | ||
|
|
7f767cb222 | ||
|
|
c3499416f3 | ||
|
|
3bcffa0112 | ||
|
|
529399e486 | ||
|
|
0ce8dd5096 | ||
|
|
8b1227e6b7 | ||
|
|
a887aad9ac | ||
|
|
f5fc7f26b7 | ||
|
|
620bc01620 | ||
|
|
6362c9618d | ||
|
|
d053881549 | ||
|
|
3605ba4262 | ||
|
|
499a46898e | ||
|
|
49595c641c | ||
|
|
98fbceeb1d | ||
|
|
592f093566 | ||
|
|
63134f4d74 | ||
|
|
8b4a2517c0 | ||
|
|
a78b5fe712 |
9
.github/CODEOWNERS
vendored
Normal file
9
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Assigns extendedclip and PiggyPiglet for any PR unless a check below matches.
|
||||
#
|
||||
* @PiggyPiglet @darbyjack
|
||||
|
||||
#
|
||||
# Assigns Andre601 to any PR that targets the wiki folder.
|
||||
#
|
||||
*.md @Andre601
|
||||
117
.github/CONTRIBUTING.md
vendored
117
.github/CONTRIBUTING.md
vendored
@@ -1,64 +1,67 @@
|
||||
[issue]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request_placeholderapi.md
|
||||
[Discord]: https://helpch.at/discord
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
[issue]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new
|
||||
[discord]: https://helpch.at/discord
|
||||
[code of conduct]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/CODE_OF_CONDUCT.md
|
||||
[wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/wiki
|
||||
[master]: https://github.com/PlaceholderAPI/PlaceholderAPI/tree/master
|
||||
[docs-wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki
|
||||
[style]: https://github.com/PlaceholderAPI/PlaceholderAPI/tree/master/config/style
|
||||
|
||||
# Contributing
|
||||
# Contributing Guidelines
|
||||
We welcome everyone to contribute towards the PlaceholderAPI Project, but doing so will require you to follow specific rules to keep a consistent and welcoming way of contributing.
|
||||
|
||||
When contributing to this repository, please first discuss the change you wish to make via [issue] or through [Discord] with the owners of this repository before making a change.
|
||||
If you have any questions about contributions towards the project, feel free to contact us on our [Discord Server][discord].
|
||||
|
||||
Please note we have a code of conduct, please follow it in all your interactions with the project.
|
||||
## Issues
|
||||
Like any other project can you encounter bugs or a feature is missing for you in the plugin.
|
||||
For that, you can open an [issue] to report a bug, or suggest a new feature to be added.
|
||||
|
||||
## Pull Request Process
|
||||
When doing so, make sure you follow rules below:
|
||||
|
||||
1. Update the README.md with details of changes if it is affected by those changes.
|
||||
2. Try to prevent any breaking changes affecting the end-user (Developers using the API).
|
||||
Mention any breaking changes that could affect the end-user.
|
||||
3. Document any public methods that the end-user might use.
|
||||
### Follow the template
|
||||
We have issue templates to help us get the required information more easily. Please follow the provided template when either filing a bug report or feature request.
|
||||
Your issue may be closed without warning for not following the template.
|
||||
|
||||
### Use the latest version
|
||||
When it comes to bug reports should you always check first, that you're using the latest release of PlaceholderAPI.
|
||||
Often the bug you've encountered, is fixed in a newer version.
|
||||
|
||||
The same rules apply when making a feature request.
|
||||
|
||||
### No duplicate issue
|
||||
Make sure that there aren't any existing issues relating to the problem, which are still open, or are closed with a solution/explanation.
|
||||
Opening a separate issue for a bug report or feature request, that already exists on the issue tracker only slows down the process of fixing the bug or implementing the feature.
|
||||
|
||||
If an issue with the bug or feature you want to report/suggest exists, comment on it with your info (bug reports) or give it a :thumbsup: (Feature Request) to show that this is important for you.
|
||||
|
||||
### Issue isn't caused by external source
|
||||
PlaceholderAPI provides a feature to have expansions (separate jar files) for placeholders. This gives it a possability that an issue you encounter is caused by said expansions or a separate plugin that uses those expansions.
|
||||
In those cases should you report the issue to the issue tracker of the expansion or plugin.
|
||||
|
||||
## Pull requests
|
||||
As an open source project we are welcoming all contributions to improve PlaceholderAPI, being it changes to its code, or contributions to its documentation such as the [Wiki] or the Javadocs.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> When contributing, make sure to both base of and target the mentioned branch. Pull requests targeting the wrong branch may get closed without a warning.
|
||||
|
||||
### Code contributions
|
||||
> **Source and Target Branch:** [`master`][master]
|
||||
|
||||
When contributing towards the code of PlaceholderAPI, be it new features or just bug fixes, your changes should follow the general code styling used in the project.
|
||||
You can find the necessary files in the [`config/style`][style] directory of this repository.
|
||||
|
||||
### Javadocs contributions
|
||||
> **Source and Target Branch:** [`master`][master]*
|
||||
|
||||
Javadocs changes should usually be combined with [code contributions](#code-contributions) when possible, but if not, make sure the changes are significant enough to warrant a new build on our CI server.
|
||||
|
||||
\*This branch may change in the future.
|
||||
|
||||
### Wiki contributions
|
||||
> **Source and Target Branch:** [`wiki`][docs-wiki]
|
||||
|
||||
The Wiki of PlaceholderAPI is located on its own dedicated branch, hosting all the assets and files that get used to create it through the usage of GitHub Actions and GitHub Pages.
|
||||
We welcome contributions that update outdated information, add new expansions/plugins supporting PlaceholderAPI or even correct spelling mistakes and typos.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
### Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
### Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
### Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
### Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
### Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at our [Discord]. All
|
||||
complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
### Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
We have a [Code of Conduct] to maintain a welcoming atmosphere in this project.
|
||||
If your contributions go against the Code of Conduct, linked above, we reserve the right to deny or revert your contributions.
|
||||
|
||||
48
.github/ISSUE_TEMPLATE/bug_report.md
vendored
48
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,48 +0,0 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Report bugs of PlaceholderAPI with this template
|
||||
|
||||
---
|
||||
|
||||
## Please read
|
||||
This template is only for reporting bugs of PlaceholderAPI!
|
||||
If you want to request changes to the code of PlaceholderAPI, use the [Request change (PlaceholderAPI)] template.
|
||||
For changes to the wiki use the [Request change (Wiki)] template.
|
||||
|
||||
Please also make sure that you use the [latest release][Spigot] or the latest [developement build][Jenkins] and that your bug isn't already reported on the [issues] page.
|
||||
|
||||
**Please report issues with expansions/placeholders to the corresponding issue tracker! Only report it here if you can't find any place to report it!**
|
||||
|
||||
### Issue
|
||||
> What is the issue? Describe it like you would tell a friend.
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
|
||||
|
||||
### Expected behaviour
|
||||
> What should PlaceholderAPI do?
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
|
||||
|
||||
### Actual behaviour
|
||||
> What does PlaceholderAPI actually do?
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
|
||||
|
||||
### How to reproduce
|
||||
> What steps did you made, to get this bug?
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
1.
|
||||
|
||||
### Installed expansions
|
||||
> Please list all expansions that are displayed when running `/papi list`
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
|
||||
|
||||
|
||||
<!-- DO NOT ALTER ANYTHING BELOW THIS LINE! -->
|
||||
|
||||
[Request change (Wiki)]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request_wiki.md
|
||||
[Request change (PlaceholderAPI)]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request_placeholderapi.md
|
||||
[Spigot]: https://www.spigotmc.org/resources/6245/
|
||||
[Jenkins]: http://ci.extendedclip.com/job/PlaceholderAPI/
|
||||
[issues]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues
|
||||
103
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
103
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
name: Bug Report
|
||||
description: Found a Bug about PlaceholderAPI? Use this template to report it!
|
||||
labels:
|
||||
- "Type: Issue (Unconfirmed)"
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |-
|
||||
Thank you for taking your time and opening a Bug Report.
|
||||
In order for us to process this Bug Report as fast and efficient as possible do we ask you to read the form carefully and provide any requested information.
|
||||
Required fields are marked with an asterisk symbol (`*`)
|
||||
|
||||
Also, always make sure to use the latest Release from [Spigot](https://www.spigotmc.org/resources/6245/) or the latest Development Build from our [Jenkins Server](http://ci.extendedclip.com/job/PlaceholderAPI/) to make sure that your issue isn't already fixed.
|
||||
|
||||
**DO NOT REPORT ISSUES WITH EXPANSIONS AND/OR PLACEHOLDERS. USE THE APPROPRIATE ISSUE TRACKER FOR THOSE!**
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Confirmation
|
||||
description: Please make sure to have followed the following checks.
|
||||
options:
|
||||
- label: My issue isn't already found on the Issue tracker.
|
||||
required: true
|
||||
- label: My issue is about **PlaceholderAPI** and not any expansion or external plugin
|
||||
required: true
|
||||
- label: The issue isn't already fixed in a Spigot Release or Development Build.
|
||||
required: true
|
||||
- label: The [Common Issues](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Common-Issues) page doesn't mention this issue.
|
||||
required: true
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: "Type"
|
||||
description: |-
|
||||
What kind of Bug do you encounter?
|
||||
|
||||
- `Plugin Bug`: PlaceholderAPI doesn't startup properly.
|
||||
- `API Bug`: A method you use didn't work or has an unexpected result.
|
||||
- `Plugin/Server Incompatability`: PlaceholderAPI either doesn't support a specific Server Type/Version or has conflicts with another plugin.
|
||||
multiple: false
|
||||
options:
|
||||
- "Plugin Bug"
|
||||
- "API Bug"
|
||||
- "Plugin/Server Incompatability"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "What happens?"
|
||||
description: "What bug are you encountering? Try to explain it as detailed as possible."
|
||||
placeholder: "PlaceholderAPI does this when I do that..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Expected Behaviour"
|
||||
description: "What behaviour did you expect from PlaceholderAPI?"
|
||||
placeholder: "PlaceholderAPI should actually do..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "How to Reproduce"
|
||||
description: |-
|
||||
List the steps on how to reproduce this Bug.
|
||||
Post any Code-examples in the `Additional Information` field below when you selected `API Bug`.
|
||||
placeholder: |-
|
||||
1. Do this
|
||||
2. ...
|
||||
3. Profit!
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: "dump"
|
||||
attributes:
|
||||
label: "`/papi dump` Output"
|
||||
description: |-
|
||||
Please execute the `/papi dump` command and provide the generated URL from it.
|
||||
If you can't execute the command (i.e. PlaceholderAPI doesn't start up) can you put N/A here and mention the issue in the `Additional Information` field.
|
||||
placeholder: "https://paste.helpch.at/dump.log"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: "console"
|
||||
attributes:
|
||||
label: "Console Log"
|
||||
description: |-
|
||||
Get the latest content of your `latest.log` file an upload it to https://paste.helpch.at
|
||||
Take the generated URL and paste it into this field.
|
||||
placeholder: "https://paste.helpch.at/latest.log"
|
||||
- type: input
|
||||
id: "error"
|
||||
attributes:
|
||||
label: "Errors"
|
||||
description: |-
|
||||
Upload any errors you find to https://paste.helpch.at and post the link in the field below.
|
||||
placeholder: "https://paste.helpch.at/error.log"
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Additional Info"
|
||||
description: |-
|
||||
Add any extra info you think is nessesary for this Bug report.
|
||||
- If you selected `API Bug` will you need to include code-examples here to reproduce the issue.
|
||||
- If you selected `Plugin/Server Incompatability` should you include extra Server info such as a Timings or Spark-Report or info about the plugin in question.
|
||||
placeholder: "Put any extra info you like into this field..."
|
||||
@@ -1,42 +0,0 @@
|
||||
---
|
||||
name: Request change (PlaceholderAPI)
|
||||
about: Request a update/change of the PlaceholderAPI-code
|
||||
|
||||
---
|
||||
|
||||
## Please read
|
||||
This template is only for requesting new functions to be added to PlaceholderAPI or for old one to be changed!
|
||||
Please use the [Request change (Wiki)] template to ask for additions/changes to the wiki.
|
||||
For reporting bugs of PlaceholderAPI use the [Bug report] template.
|
||||
|
||||
Also make sure that the [wiki] doesn't already mention such a function/change and that there isn't a issue about this change on the [issues] page.
|
||||
|
||||
We recommend to [open a Pull Request][Pull Requests] for making changes to PlaceholderAPI's code.
|
||||
|
||||
### Type
|
||||
> What kind of request is this? (Multiple selections possible)
|
||||
<!--
|
||||
Please select the right options by replacing the [ ] with a [x]
|
||||
-->
|
||||
- [ ] New function for PlaceholderAPI.
|
||||
A new function that developers could use.
|
||||
- [ ] Change to code (Internal).
|
||||
Changes to code that won't affect the end-user.
|
||||
- [ ] Change to code (External).
|
||||
Changes to code that will affect the end-user (breaks stuff).
|
||||
- [ ] Other: __________ <!-- Use this if none of the above matches your request -->
|
||||
|
||||
### Info
|
||||
> What is the change?
|
||||
> Please provide as much information (including links, images and code-snippeds) as possible.
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
|
||||
|
||||
|
||||
<!-- DO NOT ALTER ANYTHING BELOW THIS LINE! -->
|
||||
|
||||
[Request change (Wiki)]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request_wiki.md
|
||||
[Bug report]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=bug_report.md
|
||||
[issues]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues
|
||||
[wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
|
||||
[Pull Requests]: https://github.com/PlaceholderAPI/PlaceholderAPI/pulls
|
||||
38
.github/ISSUE_TEMPLATE/change_request_wiki.md
vendored
38
.github/ISSUE_TEMPLATE/change_request_wiki.md
vendored
@@ -1,38 +0,0 @@
|
||||
---
|
||||
name: Request change (Wiki)
|
||||
about: Request a update/change of a wiki-page
|
||||
|
||||
---
|
||||
|
||||
## Please read
|
||||
This template is only for requesting new information to be added to the wiki or for updating of already existing information!
|
||||
Please use the [Request change (PlaceholderAPI)] template to ask for additions/changes to the plugin PlaceholderAPI.
|
||||
For reporting bugs of PlaceholderAPI use the [Bug report] template.
|
||||
|
||||
Also make sure that the [wiki] doesn't already have the change and that there isn't a issue about this change on the [issues] page.
|
||||
|
||||
### Type
|
||||
> What kind of change is it? (Multiple selections possible)
|
||||
<!--
|
||||
Please select the right one, by changing the [ ] to [x]
|
||||
-->
|
||||
- [ ] New plugin/expansion supporting PlaceholderAPI.
|
||||
A new plugin/expansion uses and/or provides placeholders.
|
||||
- [ ] Placeholder(s) changed.
|
||||
An already listed expansion/plugin has new placeholders or old ones have changed.
|
||||
- [ ] Plugin/Expansion no longer supports PlaceholderAPI and/or was deleted.
|
||||
- [ ] Other: __________ <!-- Use this if none of the above matches your request -->
|
||||
|
||||
### Info
|
||||
> Please provide any information that is useful including links and images.
|
||||
> For plugins/expansion providing new placeholders or updating old ones, provide the placeholders (that have changed)
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
|
||||
|
||||
|
||||
<!-- DO NOT ALTER ANYTHING BELOW THIS LINE! -->
|
||||
|
||||
[Request change (PlaceholderAPI)]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request_placeholderapi.md
|
||||
[Bug report]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=bug_report.md
|
||||
[issues]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues
|
||||
[wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
|
||||
6
.github/ISSUE_TEMPLATE/config.yml
vendored
6
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -9,3 +9,9 @@ contact_links:
|
||||
- name: Hastebin
|
||||
url: https://paste.helpch.at
|
||||
about: Use our Hastebin-site for sharing errors and configuration files.
|
||||
- name: Update Wiki
|
||||
url: https://github.com/PlaceholderAPI/PlaceholderAPI/pulls
|
||||
about: Please make a Pull request towards the "wiki" folder to update the wiki.
|
||||
- name: Questions
|
||||
url: https://github.com/PlaceholderAPI/PlaceholderAPI/discussions
|
||||
about: If you have any questions, ask them in our Discussions Page.
|
||||
|
||||
62
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
62
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
name: Feature Request
|
||||
description: Suggest a new Feature for PlaceholderAPI
|
||||
labels:
|
||||
- "Type: Enhancement"
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |-
|
||||
Thank you for taking the time in creating this Feature Request.
|
||||
In order to process your feature request as fast and efficiently as possible do we ask you to fill out any required fields (Indicated with a red asterisk (`*`)) with the requested information.
|
||||
|
||||
If you have any further questions should you either [join our Discord Server](https://helpch.at/discord) or [ask in our Discussions](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions).
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Confirmation
|
||||
description: Please make sure to have followed the following checks.
|
||||
options:
|
||||
- label: I checked the Issues and Pull request tab for any existing issues or PRs.
|
||||
required: true
|
||||
- label: My Feature Request is for **PlaceholderAPI** and not any expansion or other plugin.
|
||||
required: true
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: "Type"
|
||||
description: "What type is your Suggestion? Select all that match."
|
||||
multiple: true
|
||||
options:
|
||||
- "New API feature"
|
||||
- "New config option"
|
||||
- "Minor Code improvement (Won't affect Servers)"
|
||||
- "Major Code improvement (Will affect Servers)"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Description"
|
||||
description: |-
|
||||
Give a detailed explanation about your Feature request and why it would be beneficial for PlaceholderAPI.
|
||||
Just saying "It's cool!" or "I need it" don't count as valid reasons. It needs to have a clear benefit for **other** players too.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Code Example"
|
||||
description: |-
|
||||
Do you have any Code Snippets that you want to share with us? Paste it here!
|
||||
Note that the input will automatically be rendered as Java code, so you won't need to put it into a code block yourself.
|
||||
render: java
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Jar file"
|
||||
description: |-
|
||||
If you already have a PlaceholderAPI Jar with the requested changes would we love to get a download link for it.
|
||||
If you don't have a download link can you leave this field empty or provide "N/A" as a response.
|
||||
placeholder: "https://cdn.discordapp.com/..."
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Additional Information"
|
||||
description: |-
|
||||
Add any extra info you think is nessesary for this Feature request.
|
||||
- When you selected `Major Code improvement (Will affect Servers)` should you mention what will break when people update.
|
||||
placeholder: "Put any extra info you like into this field..."
|
||||
25
.github/PULL_REQUEST_TEMPLATE.md
vendored
25
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,8 +1,13 @@
|
||||
## Please read
|
||||
Please make sure you checked the following:
|
||||
- You checked the [Pull requests] page for any upcoming changes.
|
||||
- You documented any public code that the end-user might use.
|
||||
- You followed the [contributing file]
|
||||
<!--
|
||||
### Please read ###
|
||||
Please make sure you checked the following:
|
||||
|
||||
- You checked the Pull requests page for any upcoming changes.
|
||||
- You documented any public code that the end-user might use.
|
||||
- You followed the contributing file (https://github.com/PlaceholderAPI/PlaceholderAPI/tree/master/.github/CONTRIBUTING.md).
|
||||
-->
|
||||
|
||||
## Pull Request
|
||||
|
||||
### Type
|
||||
<!--
|
||||
@@ -14,12 +19,10 @@ Please make sure you checked the following:
|
||||
- [ ] Other: __________ <!-- Use this if none of the above matches your request -->
|
||||
|
||||
### Description
|
||||
> Provide additional information if needed.
|
||||
<!-- Please type below this line -->
|
||||
<!-- What does your Pull request change? -->
|
||||
|
||||
Closes N/A <!-- If your PR is based on an issue, change "N/A" to the issue ID (#id) -->
|
||||
|
||||
|
||||
<!-- DO NOT ALTER ANYTHING BELOW THIS LINE! -->
|
||||
|
||||
[Pull requests]: https://github.com/PlaceholderAPI/PlaceholderAPI/pulls
|
||||
[contributing file]: https://github.com/PlaceholderAPI/PlaceholderAPI/tree/master/.github/CONTRIBUTING.md
|
||||
[Wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
|
||||
[Wiki]: https://wiki.placeholderapi.com
|
||||
|
||||
145
.github/label-commenter-config.yml
vendored
Normal file
145
.github/label-commenter-config.yml
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
comment:
|
||||
footer: "\
|
||||
----\n\n
|
||||
> [!NOTE]\n
|
||||
> *This is an automated response created by a **GitHub Action***<br>
|
||||
> *Mentioning the bot won't have any effect!*
|
||||
"
|
||||
|
||||
labels:
|
||||
- name: 'Type: Issue (Expansion)'
|
||||
labeled:
|
||||
issue:
|
||||
body: |-
|
||||
Hello @{{ issue.user.login }},
|
||||
|
||||
The issue you encountered is caused by an Expansion and not PlaceholderAPI itself.
|
||||
This issue-tracker is reserved for Bug reports and feature requests towards PlaceholderAPI.
|
||||
|
||||
Please report this issue to the Expansion's main issue-tracker.
|
||||
A list of known Expansion repositories and their issue trackers can be found [here](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions/510#discussion-63812).
|
||||
action: close
|
||||
- name: 'Type: Duplicate'
|
||||
labeled:
|
||||
issue:
|
||||
body: |-
|
||||
Your issue is already known and a separate issue with the exact same report/feature request already exist.
|
||||
|
||||
Please comment on the already existing issue with your information instead of opening your own.
|
||||
action: close
|
||||
- name: 'Problem: More info required'
|
||||
labeled:
|
||||
issue:
|
||||
body: |-
|
||||
Hello @{{ issue.user.login }},
|
||||
|
||||
Your issue unfortunately lacks certain information that we require in order to help you with your issue.
|
||||
Please make sure you provide the following information:
|
||||
|
||||
- Currently used Versions of your server (`/version`) and PlaceholderAPI (`/version PlaceholderAPI`)
|
||||
- Currently installed Expansions (`/papi list`)
|
||||
- Currently installed Plugins (`/pl`)
|
||||
- Any additional information requested by users in this issue.
|
||||
|
||||
The easiest way to provide those information is through the `/papi dump` command which posts the required information to https://paste.helpch.at and gives a URL to share.
|
||||
unlabeled:
|
||||
issue:
|
||||
body: |-
|
||||
Thank you for providing additional information.
|
||||
We will take a look at the issue you encounter and come back to you with a possible solution.
|
||||
- name: 'Type: Invalid'
|
||||
labeled:
|
||||
issue:
|
||||
body: |-
|
||||
Your issue has beeen marked as invalid.
|
||||
This means that it either doesn't follow any provided template, or isn't related to PlaceholderAPI.
|
||||
|
||||
Please make sure to use one of the issue templates and provide the requested information.
|
||||
Currently available Templates are:
|
||||
|
||||
- [Bug Report](https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?labels=Type%3A+Issue+%28Unconfirmed%29&template=bug_report.yml)
|
||||
- [Feature Request](https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?labels=Type%3A+Enhancement&template=feature_request.yml)
|
||||
|
||||
If you want changes to be made towards the Wiki, would we encourage you to [Make a Pull request](https://github.com/PlaceholderAPI/PlaceholderAPI/pulls).
|
||||
You can find more information about this process on the [Wiki's Readme](https://github.com/PlaceholderAPI/PlaceholderAPI/blob/wiki/README.md).
|
||||
|
||||
It is recommended to [join our Discord Server](https://helpch.at/discord) as you often receive a faster response compared to the issue tracker here.
|
||||
Questions about PlaceholderAPI should be asked in our [Discussions](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions).
|
||||
action: close
|
||||
pr:
|
||||
body: |-
|
||||
Your Pull request has been marked as **invalid**.
|
||||
This means that it doesn't follow our [Contributing Guidelines](https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/.github/CONTRIBUTING.md).
|
||||
|
||||
Here is a small summary of what you should know:
|
||||
|
||||
- Pull requests for PlaceholderAPI should target the `master` branch.
|
||||
- Pull requests for the Wiki should target the `wiki` branch.
|
||||
|
||||
Don't hesitate to ask us any questions.
|
||||
action: close
|
||||
- name: 'Type: Invalid (Wiki)'
|
||||
labeled:
|
||||
pr:
|
||||
body: |-
|
||||
Your Wiki Pull request has been marked as **invalid**.
|
||||
|
||||
Pull requests targeting the Wiki need to target the `wiki` branch.
|
||||
More information can be found on the [Wiki README](https://github.com/PlaceholderAPI/PlaceholderAPI/blob/wiki/README.md).
|
||||
action: close
|
||||
- name: 'Target: Wiki'
|
||||
labeled:
|
||||
issue:
|
||||
body: |-
|
||||
Hello @{{ issue.user.login }},
|
||||
|
||||
Thank you for reaching out to us about the wiki.
|
||||
We would like to inform you, that you are able to directly commit your changes to the wiki through a Pull request.
|
||||
When doing so, make sure you follow these steps:
|
||||
|
||||
- The Pull request is based on AND targets the [`wiki`](https://github.com/PlaceholderAPI/PlaceholderAPI/tree/wiki) branch of the Repository.
|
||||
- You followed the general Styling Guidelines mentioned in the wiki's [README](https://github.com/PlaceholderAPI/PlaceholderAPI/blob/wiki/README.md) file.
|
||||
|
||||
If you have any questions about submitting a PR for the wiki or have any other questions don't hesitate to ask us about it.
|
||||
- name: 'Type: Not a bug'
|
||||
labeled:
|
||||
issue:
|
||||
body: |-
|
||||
The issue you encounter is not considered a bug and rather an intentional behaviour of PlaceholderAPI and/or one of its expansions.
|
||||
If you still believe that it is a bug, provide more information and a maintainer of this repository may look at it more closely.
|
||||
|
||||
Before providing more info, always make sure to use the latest version of PlaceholderAPI, as the issue you encounter might already be fixed in a newer version.
|
||||
Optionally can you also try out [development builds](https://ci.extendedclip.com/job/PlaceholderAPI/) and see if the issue was fixed there.
|
||||
action: close
|
||||
unlabeled:
|
||||
issue:
|
||||
body: After further investigation is the issue you encounter indeed considered a bug and we will try to fix it as soon as possible.
|
||||
action: open
|
||||
- name: 'Status: Inactive'
|
||||
labeled:
|
||||
issue:
|
||||
body: |-
|
||||
The issue has been marked as **inactive** which means it didn't recieve any responses from the Author ({{ issue.user.login }}) for a long period of time.
|
||||
To keep the issue-tracker clean and up to date do we close issues that haven't received any responses for a long time.
|
||||
|
||||
If you're the Author of this issue and the reported problem is still present, make sure to respond with additional info to this issue, so that we can reopen it.
|
||||
**Do not create a new issue for the same problem!**
|
||||
action: close
|
||||
unlabeled:
|
||||
issue:
|
||||
body: The issue received a response from the Author who confirms this to still be prominent and has therefore been reopened.
|
||||
action: open
|
||||
- name: 'Type: Question'
|
||||
labeled:
|
||||
issue:
|
||||
body: |-
|
||||
Hello @{{ issue.user.login }},
|
||||
|
||||
Thank you for reaching out to us for getting Support with PlaceholderAPI.
|
||||
We would like to inform you, that we have [Discussions](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions) that you can use for asking questions.
|
||||
Just head over there and click the "New discussion" button to create a new post.
|
||||
|
||||
Remember to first read the [READ ME](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions/507) post to not face any issues.
|
||||
|
||||
For questions do we recommend to use the [(2) Support](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions/categories/-2-support) category.
|
||||
You can also use the Discussion to submit Feature requests (Feature requests through issues are still accepted tho).
|
||||
24
.github/release.yml
vendored
Normal file
24
.github/release.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# This file is used to automatically draft new release changelogs in GitHub.
|
||||
# Read more: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
|
||||
#
|
||||
changelog:
|
||||
exclude:
|
||||
labels:
|
||||
- 'Action: No Changelog'
|
||||
categories:
|
||||
- title: 'Breaking Changes'
|
||||
labels:
|
||||
- 'Type: Breaking'
|
||||
- title: 'Additions'
|
||||
labels:
|
||||
- 'Type: New Feature'
|
||||
- title: 'Changes'
|
||||
labels:
|
||||
- 'Type: Enhancement'
|
||||
- title: 'Fixes'
|
||||
labels:
|
||||
- 'Type: Bugfix'
|
||||
- title: 'Other changes'
|
||||
labels:
|
||||
- '*' # Catch every other PR not labeled with an "exclude" label.
|
||||
25
.github/workflows/label_comment.yml
vendored
Normal file
25
.github/workflows/label_comment.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Comment
|
||||
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- labeled
|
||||
- unlabeled
|
||||
pull_request_target:
|
||||
types:
|
||||
- labeled
|
||||
- unlabeled
|
||||
|
||||
jobs:
|
||||
give_comment:
|
||||
if: github.event.issue.state == 'open' || github.event.pull_request.state == 'open'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: master
|
||||
- name: Send Issue/Pull request comment
|
||||
uses: peaceiris/actions-label-commenter@v1.8.2
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
33
.github/workflows/pr_build_jars.yml
vendored
Normal file
33
.github/workflows/pr_build_jars.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: "Test compiling against Java 8, 11 and 16"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- development
|
||||
paths:
|
||||
- "../../spigot/**"
|
||||
- "../../paper/**"
|
||||
- "build.gradle.kts"
|
||||
- "settings.gradle.kts"
|
||||
|
||||
jobs:
|
||||
testBuilds:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
java-version: [8, 11, 16]
|
||||
name: "Compile jar against ${{ matrix.java-version }}"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Checkout Code"
|
||||
uses: actions/checkout@v2
|
||||
- name: "Prepare Java ${{ matrix.java-version }}"
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: "adopt"
|
||||
java-version: "${{ matrix.java-version }}"
|
||||
- name: "Make build.gradle executable"
|
||||
run: "chmod +x gradlew"
|
||||
- name: "Build jar with Java ${{ matrix.java-version }}"
|
||||
run: "./gradlew shadowJar"
|
||||
49
.github/workflows/wiki.yml
vendored
49
.github/workflows/wiki.yml
vendored
@@ -1,49 +0,0 @@
|
||||
#
|
||||
# This is a GitHub Action that allows us to auto-update the wiki
|
||||
# when a Pull request changes specific files in a folder.
|
||||
#
|
||||
name: Update Wiki
|
||||
|
||||
on:
|
||||
push:
|
||||
#
|
||||
# Only trigger when the push changes any files in the wiki-folder.
|
||||
#
|
||||
paths:
|
||||
- 'wiki/**'
|
||||
branches:
|
||||
- 'master'
|
||||
#
|
||||
# Releases cause this action to also fire.
|
||||
# Using this prevents this problem.
|
||||
#
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Checkout Code'
|
||||
uses: actions/Checkout@v2
|
||||
- name: 'Update Wiki'
|
||||
uses: docker://decathlon/wiki-page-creator-action:latest
|
||||
env:
|
||||
#
|
||||
# We can use the E-Mail and Name of the GitHub Actions account
|
||||
# for our convenience.
|
||||
#
|
||||
ACTION_MAIL: 'actions@github.com'
|
||||
ACTION_NAME: 'github-actions[bot]'
|
||||
GH_PAT: '${{ secrets.WORKFLOWPAT }}'
|
||||
OWNER: 'PlaceholderAPI'
|
||||
REPO_NAME: 'PlaceholderAPI'
|
||||
#
|
||||
# We only want to target files in the wiki folder
|
||||
#
|
||||
MD_FOLDER: 'wiki'
|
||||
WIKI_PUSH_MESSAGE: 'Updating wiki from commit ${{ github.event.after }}'
|
||||
#
|
||||
# We skip/ignore the README.md file in the Wiki folder
|
||||
#
|
||||
SKIP_MD: README.md
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,8 @@
|
||||
.idea/
|
||||
.gradle/
|
||||
.vscode/
|
||||
server/
|
||||
build/
|
||||
out/
|
||||
*.iml
|
||||
libs/
|
||||
51
CODE_OF_CONDUCT.md
Normal file
51
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,51 @@
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
|
||||
[discord]: https://helpch.at/discord
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
### Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
### Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
### Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
### Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
### Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team on their [discord server][discord]. All
|
||||
complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
### Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
26
README.md
26
README.md
@@ -7,15 +7,20 @@
|
||||
|
||||
[discord]: https://helpch.at/discord
|
||||
[spigot]: https://www.spigotmc.org/resources/6245/
|
||||
[Expansions cloud]: https://api.extendedclip.com/home
|
||||
[hangar]: https://hangar.papermc.io/HelpChat/PlaceholderAPI
|
||||
[modrinth]: https://modrinth.com/plugin/placeholderapi
|
||||
[Expansions cloud]: https://ecloud.placeholderapi.com
|
||||
[placeholder list]: https://helpch.at/placeholders
|
||||
[statistics]: https://bstats.org/plugin/bukkit/PlaceholderAPI
|
||||
|
||||
[ci]: http://ci.extendedclip.com/job/PlaceholderAPI/
|
||||
[ciImg]: http://ci.extendedclip.com/buildStatus/icon?job=PlaceholderAPI
|
||||
|
||||
[APIversionImg]: https://img.shields.io/nexus/r/http/repo.extendedclip.com/me.clip/placeholderapi.svg?label=API-Version
|
||||
[logo]: https://i.imgur.com/Ea4PURv.png
|
||||
[APIversionImg]: https://repo.extendedclip.com/api/badge/latest/releases/me/clip/placeholderapi?name=API%20Version
|
||||
[logo]: https://wiki.placeholderapi.com/assets/img/papi-logo.png
|
||||
|
||||
[contributing]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/.github/CONTRIBUTING.md
|
||||
[placeholderexpansion]: https://wiki.placeholderapi.com/developers/creating-a-placeholderexpansion/
|
||||
<!-- The stuff above isn't visible in the readme -->
|
||||
|
||||
[![logo]][spigot]
|
||||
@@ -25,12 +30,15 @@
|
||||
# Information
|
||||
[PlaceholderAPI][spigot] is a plugin for Spigot servers that allows server owners to display information from various plugins with a uniform format.
|
||||
|
||||
Support for specific plugins are provided either by the plugin itself or through expansions. The expansions may be downloaded in-game through the PAPI Expansion Cloud. There are currently over 150+ expansions that support a wide variety of plugins, such as Essentials, Factions, LuckPerms, and Vault.
|
||||
Support for specific plugins are provided either by the plugin itself or through expansions. The expansions may be downloaded in-game through the PAPI Expansion Cloud. There are currently over 240+ expansions that support a wide variety of plugins, such as Essentials, Factions, LuckPerms, and Vault.
|
||||
|
||||
PlaceholderAPI has been downloaded over 300,000 times and has been used concurrently on over 20,000 servers, which makes it a must-have for a server of any type or scale.
|
||||
PlaceholderAPI has been downloaded over 1,700,000 times on Spigot and has been used concurrently on over 45,000 servers, which makes it a must-have for a server of any type or scale.
|
||||
|
||||
<!-- TODO: Add contributing section -->
|
||||
<!-- TODO: Add expansion creation section (possibly add to a wiki?) -->
|
||||
## Contribute
|
||||
If you would like to contribute towards PlaceholderAPI should you take a look at our [Contributing file][contributing] for the ins and outs on how you can do that and what you need to keep in mind.
|
||||
|
||||
## Create an Expansion
|
||||
If you would like to create your own Placeholder Expansion for PlaceholderAPI, take a look at our [Wiki][placeholderexpansion] which contains a detailed tutorial on how you can achieve this.
|
||||
|
||||
## Support
|
||||
- [Issue Tracker][issues]
|
||||
@@ -38,7 +46,9 @@ PlaceholderAPI has been downloaded over 300,000 times and has been used concurre
|
||||
|
||||
## Quick Links
|
||||
- [CI Server][ci]
|
||||
- [Expansions cloud]
|
||||
- [Expansions Cloud]
|
||||
- [Placeholder List]
|
||||
- [Spigot Page][spigot]
|
||||
- [Hangar Page][hangar]
|
||||
- [Modrinth Page][modrinth]
|
||||
- [Plugin Statistics][statistics]
|
||||
|
||||
106
build.gradle
106
build.gradle
@@ -1,106 +0,0 @@
|
||||
plugins {
|
||||
id "java"
|
||||
id "maven-publish"
|
||||
id "net.minecrell.licenser" version "0.4.1"
|
||||
id "com.github.johnrengelman.shadow" version "6.0.0"
|
||||
}
|
||||
|
||||
group "me.clip"
|
||||
version "2.10.7"
|
||||
|
||||
description "An awesome placeholder provider!"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven({ url = "https://rayzr.dev/repo/" })
|
||||
maven({ url = "https://repo.codemc.org/repository/maven-public" })
|
||||
maven({ url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" })
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "com.google.code.gson:gson:2.8.6"
|
||||
implementation "org.bstats:bstats-bukkit:1.5"
|
||||
implementation "me.rayzr522:jsonmessage:1.2.1"
|
||||
|
||||
compileOnly "org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT"
|
||||
compileOnly "org.jetbrains:annotations:19.0.0"
|
||||
|
||||
testImplementation "org.openjdk.jmh:jmh-core:1.23"
|
||||
testImplementation "org.openjdk.jmh:jmh-generator-annprocess:1.23"
|
||||
|
||||
testCompile "org.junit.jupiter:junit-jupiter-engine:5.6.2"
|
||||
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.6.2"
|
||||
}
|
||||
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
processResources {
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
filter ReplaceTokens, tokens: [
|
||||
name: rootProject.name,
|
||||
version: project.version.toString(),
|
||||
description: project.description
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveClassifier.set("")
|
||||
|
||||
relocate "org.bstats", "me.clip.placeholderapi.metrics"
|
||||
relocate "com.google.gson", "me.clip.placeholderapi.libs.gson"
|
||||
relocate "me.rayzr522.jsonmessage", "me.clip.placeholderapi.libs.jsonmessage"
|
||||
}
|
||||
|
||||
license {
|
||||
header = file("headers/header.txt")
|
||||
|
||||
ext {
|
||||
year = 2020
|
||||
}
|
||||
|
||||
include "**/*.java"
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
test.compileClasspath += configurations.compileOnly
|
||||
test.runtimeClasspath += configurations.compileOnly
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
|
||||
if (version.contains("-DEV-")) {
|
||||
url = uri("https://repo.extendedclip.com/content/repositories/dev/")
|
||||
} else {
|
||||
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
}
|
||||
|
||||
credentials {
|
||||
username = System.getenv("JENKINS_USER")
|
||||
password = System.getenv("JENKINS_PASS")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from(components.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publish.dependsOn clean, test, jar
|
||||
80
build.gradle.kts
Normal file
80
build.gradle.kts
Normal file
@@ -0,0 +1,80 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("com.gradleup.shadow") version "9.3.1"
|
||||
}
|
||||
|
||||
group = "at.helpch"
|
||||
version = "1.0.5-DEV-${System.getProperty("BUILD_NUMBER")}"
|
||||
|
||||
description = "An awesome placeholder provider!"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
|
||||
maven {
|
||||
url = uri("https://repo.codemc.io/repository/hytale/")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.yaml:snakeyaml:2.5")
|
||||
|
||||
compileOnly("com.hypixel.hytale:Server:2026.01.17-4b0f30090")
|
||||
compileOnlyApi("org.jetbrains:annotations:23.0.0")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
|
||||
disableAutoTargetJvm()
|
||||
}
|
||||
|
||||
val javaComponent: SoftwareComponent = components["java"]
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
eachFile { expand("version" to project.version) }
|
||||
}
|
||||
|
||||
withType<ShadowJar> {
|
||||
archiveClassifier.set("hytale")
|
||||
|
||||
relocate("org.yaml.snakeyaml", "at.helpch.placeholderapi.libs.yaml")
|
||||
|
||||
exclude("META-INF/versions/**")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
artifactId = "placeholderapi-hytale"
|
||||
from(javaComponent)
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
if ("-DEV" in version.toString()) {
|
||||
url = uri("https://repo.extendedclip.com/snapshots")
|
||||
} else {
|
||||
url = uri("https://repo.extendedclip.com/releases")
|
||||
}
|
||||
|
||||
credentials {
|
||||
username = System.getenv("JENKINS_USER")
|
||||
password = System.getenv("JENKINS_PASS")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publish.get().setDependsOn(listOf(build.get()))
|
||||
}
|
||||
7
config/headers/jsonmessage.txt
Normal file
7
config/headers/jsonmessage.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2018-2026 Peter Blood
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
569
config/style/daddystyle.xml
Normal file
569
config/style/daddystyle.xml
Normal file
@@ -0,0 +1,569 @@
|
||||
<code_scheme name="DaddyStyle" version="173">
|
||||
<option name="OTHER_INDENT_OPTIONS">
|
||||
<value>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="RIGHT_MARGIN" value="100" />
|
||||
<AndroidXmlCodeStyleSettings>
|
||||
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
||||
<option name="LAYOUT_SETTINGS">
|
||||
<value>
|
||||
<option name="INSERT_BLANK_LINE_BEFORE_TAG" value="false" />
|
||||
</value>
|
||||
</option>
|
||||
</AndroidXmlCodeStyleSettings>
|
||||
<JSCodeStyleSettings version="0">
|
||||
<option name="INDENT_CHAINED_CALLS" value="false" />
|
||||
</JSCodeStyleSettings>
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
|
||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
|
||||
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
|
||||
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
|
||||
<value />
|
||||
</option>
|
||||
<option name="IMPORT_LAYOUT_TABLE">
|
||||
<value>
|
||||
<package name="" withSubpackages="true" static="true" />
|
||||
<emptyLine />
|
||||
<package name="" withSubpackages="true" static="false" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
|
||||
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
|
||||
<option name="JD_P_AT_EMPTY_LINES" value="false" />
|
||||
<option name="JD_KEEP_EMPTY_PARAMETER" value="false" />
|
||||
<option name="JD_KEEP_EMPTY_EXCEPTION" value="false" />
|
||||
<option name="JD_KEEP_EMPTY_RETURN" value="false" />
|
||||
</JavaCodeStyleSettings>
|
||||
<Objective-C>
|
||||
<option name="INDENT_NAMESPACE_MEMBERS" value="0" />
|
||||
<option name="INDENT_C_STRUCT_MEMBERS" value="2" />
|
||||
<option name="INDENT_CLASS_MEMBERS" value="2" />
|
||||
<option name="INDENT_VISIBILITY_KEYWORDS" value="1" />
|
||||
<option name="INDENT_INSIDE_CODE_BLOCK" value="2" />
|
||||
<option name="KEEP_STRUCTURES_IN_ONE_LINE" value="true" />
|
||||
<option name="FUNCTION_PARAMETERS_WRAP" value="5" />
|
||||
<option name="FUNCTION_CALL_ARGUMENTS_WRAP" value="5" />
|
||||
<option name="TEMPLATE_CALL_ARGUMENTS_WRAP" value="5" />
|
||||
<option name="TEMPLATE_CALL_ARGUMENTS_ALIGN_MULTILINE" value="true" />
|
||||
<option name="ALIGN_INIT_LIST_IN_COLUMNS" value="false" />
|
||||
<option name="SPACE_BEFORE_SUPERCLASS_COLON" value="false" />
|
||||
</Objective-C>
|
||||
<Objective-C-extensions>
|
||||
<option name="GENERATE_INSTANCE_VARIABLES_FOR_PROPERTIES" value="ASK" />
|
||||
<option name="RELEASE_STYLE" value="IVAR" />
|
||||
<option name="TYPE_QUALIFIERS_PLACEMENT" value="BEFORE" />
|
||||
<file>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||
</file>
|
||||
<class>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||
</class>
|
||||
<extensions>
|
||||
<pair source="cc" header="h" />
|
||||
<pair source="c" header="h" />
|
||||
</extensions>
|
||||
</Objective-C-extensions>
|
||||
<Python>
|
||||
<option name="USE_CONTINUATION_INDENT_FOR_ARGUMENTS" value="true" />
|
||||
</Python>
|
||||
<TypeScriptCodeStyleSettings version="0">
|
||||
<option name="INDENT_CHAINED_CALLS" value="false" />
|
||||
</TypeScriptCodeStyleSettings>
|
||||
<XML>
|
||||
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
|
||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||
</XML>
|
||||
<codeStyleSettings language="CSS">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="ECMA Script Level 4">
|
||||
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1" />
|
||||
<option name="EXTENDS_LIST_WRAP" value="1" />
|
||||
<option name="BINARY_OPERATION_WRAP" value="1" />
|
||||
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
|
||||
<option name="TERNARY_OPERATION_WRAP" value="1" />
|
||||
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
||||
<option name="FOR_STATEMENT_WRAP" value="1" />
|
||||
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||
<option name="FOR_BRACE_FORCE" value="3" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="HTML">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
|
||||
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
||||
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||
<option name="ALIGN_MULTILINE_RESOURCES" value="false" />
|
||||
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1" />
|
||||
<option name="EXTENDS_LIST_WRAP" value="1" />
|
||||
<option name="THROWS_KEYWORD_WRAP" value="1" />
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
||||
<option name="BINARY_OPERATION_WRAP" value="1" />
|
||||
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
|
||||
<option name="TERNARY_OPERATION_WRAP" value="1" />
|
||||
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
||||
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
|
||||
<option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" />
|
||||
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
|
||||
<option name="FOR_STATEMENT_WRAP" value="1" />
|
||||
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
||||
<option name="WRAP_COMMENTS" value="true" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||
<option name="FOR_BRACE_FORCE" value="3" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JSON">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JavaScript">
|
||||
<option name="RIGHT_MARGIN" value="80" />
|
||||
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1" />
|
||||
<option name="BINARY_OPERATION_WRAP" value="1" />
|
||||
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
|
||||
<option name="TERNARY_OPERATION_WRAP" value="1" />
|
||||
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
||||
<option name="FOR_STATEMENT_WRAP" value="1" />
|
||||
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||
<option name="FOR_BRACE_FORCE" value="3" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="ObjectiveC">
|
||||
<option name="RIGHT_MARGIN" value="80" />
|
||||
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
|
||||
<option name="BLANK_LINES_BEFORE_IMPORTS" value="0" />
|
||||
<option name="BLANK_LINES_AFTER_IMPORTS" value="0" />
|
||||
<option name="BLANK_LINES_AROUND_CLASS" value="0" />
|
||||
<option name="BLANK_LINES_AROUND_METHOD" value="0" />
|
||||
<option name="BLANK_LINES_AROUND_METHOD_IN_INTERFACE" value="0" />
|
||||
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="false" />
|
||||
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
|
||||
<option name="FOR_STATEMENT_WRAP" value="1" />
|
||||
<option name="ASSIGNMENT_WRAP" value="1" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="PROTO">
|
||||
<option name="RIGHT_MARGIN" value="80" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Python">
|
||||
<option name="RIGHT_MARGIN" value="80" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="SASS">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="SCSS">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="TypeScript">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:.*Style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_width</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_height</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_weight</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_margin</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_marginTop</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_marginBottom</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_marginStart</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_marginEnd</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_marginLeft</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_marginRight</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:layout_.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:padding</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:paddingTop</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:paddingBottom</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:paddingStart</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:paddingEnd</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:paddingLeft</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:paddingRight</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res-auto</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_NAMESPACE>http://schemas.android.com/tools</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="protobuf">
|
||||
<option name="RIGHT_MARGIN" value="80" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
6
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Tue Jul 14 23:27:02 AWST 2020
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
285
gradlew
vendored
Normal file → Executable file
285
gradlew
vendored
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,67 +17,101 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@@ -106,80 +140,105 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
34
gradlew.bat
vendored
34
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,8 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -54,7 +55,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@@ -64,21 +65,6 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
@@ -86,17 +72,19 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'PlaceholderAPI'
|
||||
1
settings.gradle.kts
Normal file
1
settings.gradle.kts
Normal file
@@ -0,0 +1 @@
|
||||
rootProject.name = "PlaceholderAPI"
|
||||
330
src/main/java/at/helpch/placeholderapi/PlaceholderAPI.java
Normal file
330
src/main/java/at/helpch/placeholderapi/PlaceholderAPI.java
Normal file
@@ -0,0 +1,330 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import at.helpch.placeholderapi.expansion.Relational;
|
||||
import at.helpch.placeholderapi.replacer.CharsReplacer;
|
||||
import at.helpch.placeholderapi.replacer.MessageReplacer;
|
||||
import at.helpch.placeholderapi.replacer.Replacer;
|
||||
import at.helpch.placeholderapi.replacer.Replacer.Closure;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class PlaceholderAPI {
|
||||
|
||||
private static final Replacer REPLACER_PERCENT = new CharsReplacer(Closure.PERCENT);
|
||||
private static final Replacer REPLACER_BRACKET = new CharsReplacer(Closure.BRACKET);
|
||||
|
||||
static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
|
||||
static final Pattern BRACKET_PLACEHOLDER_PATTERN = Pattern.compile("[{]([^{}]+)[}]");
|
||||
static final Pattern RELATIONAL_PLACEHOLDER_PATTERN = Pattern
|
||||
.compile("[%](rel_)([^%]+)[%]");
|
||||
|
||||
|
||||
private PlaceholderAPI() {
|
||||
}
|
||||
|
||||
// === Current API ===
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text Text to set the placeholder values in
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static String setPlaceholders(final PlayerRef player,
|
||||
@NotNull final String text) {
|
||||
return REPLACER_PERCENT.apply(text, player,
|
||||
PlaceholderAPIPlugin.instance().localExpansionManager()::getExpansion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param original Message to set the placeholder values in
|
||||
* @return Message containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static Message setPlaceholders(final PlayerRef player,
|
||||
@NotNull final Message original) {
|
||||
return MessageReplacer.replace(original, str -> setPlaceholders(player, str));
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text List of Strings to set the placeholder values in
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static List<String> setPlaceholders(final PlayerRef player,
|
||||
@NotNull final List<String> text) {
|
||||
return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Translates all placeholders into their corresponding values.
|
||||
// * <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
// *
|
||||
// * @param player Player to parse the placeholders against
|
||||
// * @param original List of Messages to set the placeholder values in
|
||||
// * @return List of Message containing all translated placeholders
|
||||
// */
|
||||
// @NotNull
|
||||
// public static List<Message> setPlaceholders(final Player player,
|
||||
// @NotNull final List<Message> original) {
|
||||
// return original.stream().map(msg -> setPlaceholders(player, msg)).collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Translates all placeholders into their corresponding values.
|
||||
// * <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
// *
|
||||
// * @param player Player to parse the placeholders against
|
||||
// * @param text Text to set the placeholder values in
|
||||
// * @return String containing all translated placeholders
|
||||
// */
|
||||
// @NotNull
|
||||
// public static String setPlaceholders(final Player player, @NotNull String text) {
|
||||
// return setPlaceholders(((OfflinePlayer) player), text);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Translates all placeholders into their corresponding values.
|
||||
// * <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
// *
|
||||
// * @param player Player to parse the placeholders against
|
||||
// * @param text List of Strings to set the placeholder values in
|
||||
// * @return String containing all translated placeholders
|
||||
// */
|
||||
// @NotNull
|
||||
// public static List<String> setPlaceholders(final Player player, @NotNull List<@NotNull String> text) {
|
||||
// return setPlaceholders(((OfflinePlayer) player), text);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text Text to set the placeholder values in
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static String setBracketPlaceholders(final PlayerRef player,
|
||||
@NotNull final String text) {
|
||||
return REPLACER_BRACKET.apply(text, player,
|
||||
PlaceholderAPIPlugin.instance().localExpansionManager()::getExpansion);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Message setBracketPlaceholders(final PlayerRef player,
|
||||
@NotNull final Message original) {
|
||||
return MessageReplacer.replace(original, str -> setBracketPlaceholders(player, str));
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text List of Strings to set the placeholder values in
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static List<@NotNull String> setBracketPlaceholders(final PlayerRef player,
|
||||
@NotNull final List<@NotNull String> text) {
|
||||
return text.stream().map(line -> setBracketPlaceholders(player, line))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Translates all placeholders into their corresponding values.
|
||||
// * <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
||||
// *
|
||||
// * @param player Player to parse the placeholders against
|
||||
// * @param text Text to set the placeholder values in
|
||||
// * @return String containing all translated placeholders
|
||||
// */
|
||||
// @NotNull
|
||||
// public static String setBracketPlaceholders(Player player, @NotNull String text) {
|
||||
// return setBracketPlaceholders((OfflinePlayer) player, text);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Translates all placeholders into their corresponding values.
|
||||
// * <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
||||
// *
|
||||
// * @param player Player to parse the placeholders against
|
||||
// * @param text List of Strings to set the placeholder values in
|
||||
// * @return String containing all translated placeholders
|
||||
// */
|
||||
// @NotNull
|
||||
// public static List<String> setBracketPlaceholders(Player player, @NotNull List<String> text) {
|
||||
// return setBracketPlaceholders((OfflinePlayer) player, text);
|
||||
// }
|
||||
|
||||
/**
|
||||
* set relational placeholders in the text specified placeholders are matched with the pattern
|
||||
* {@literal %<rel_(identifier)_(params)>%} when set with this method
|
||||
*
|
||||
* @param one First player to compare
|
||||
* @param two Second player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @return The text containing the parsed relational placeholders
|
||||
*/
|
||||
public static String setRelationalPlaceholders(PlayerRef one, PlayerRef two, String text) {
|
||||
final Matcher matcher = RELATIONAL_PLACEHOLDER_PATTERN.matcher(text);
|
||||
|
||||
while (matcher.find()) {
|
||||
final String format = matcher.group(2);
|
||||
final int index = format.indexOf("_");
|
||||
|
||||
if (index <= 0 || index >= format.length()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String identifier = format.substring(0, index).toLowerCase(Locale.ROOT);
|
||||
String params = format.substring(index + 1);
|
||||
final PlaceholderExpansion expansion = PlaceholderAPIPlugin.instance()
|
||||
.localExpansionManager().getExpansion(identifier);
|
||||
|
||||
if (!(expansion instanceof Relational)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String value = ((Relational) expansion).onPlaceholderRequest(one, two, params);
|
||||
|
||||
if (value != null) {
|
||||
text = text.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement(value));
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate placeholders in the provided List based on the relation of the two provided players.
|
||||
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<param>%}.
|
||||
*
|
||||
* @param one Player to compare
|
||||
* @param two Player to compare
|
||||
* @param text text to parse the placeholder values to
|
||||
* @return The text containing the parsed relational placeholders
|
||||
*/
|
||||
public static List<String> setRelationalPlaceholders(PlayerRef one, PlayerRef two, List<String> text) {
|
||||
return text.stream().map(line -> setRelationalPlaceholders(one, two, line))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a specific placeholder identifier is currently registered
|
||||
*
|
||||
* @param identifier The identifier to check
|
||||
* @return true if identifier is already registered
|
||||
*/
|
||||
public static boolean isRegistered(@NotNull final String identifier) {
|
||||
return PlaceholderAPIPlugin.instance().localExpansionManager()
|
||||
.findExpansionByIdentifier(identifier).isPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all registered placeholder identifiers
|
||||
*
|
||||
* @return A Set of type String containing the identifiers of all registered expansions.
|
||||
*/
|
||||
@NotNull
|
||||
public static Set<String> getRegisteredIdentifiers() {
|
||||
return Set
|
||||
.copyOf(PlaceholderAPIPlugin.instance().localExpansionManager().getIdentifiers());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the normal placeholder pattern.
|
||||
*
|
||||
* @return Regex Pattern of {@literal [%]([^%]+)[%]}
|
||||
*/
|
||||
public static Pattern getPlaceholderPattern() {
|
||||
return PLACEHOLDER_PATTERN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bracket placeholder pattern.
|
||||
*
|
||||
* @return Regex Pattern of {@literal [{]([^{}]+)[}]}
|
||||
*/
|
||||
public static Pattern getBracketPlaceholderPattern() {
|
||||
return BRACKET_PLACEHOLDER_PATTERN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the relational placeholder pattern.
|
||||
*
|
||||
* @return Regex Pattern of {@literal [%](rel_)([^%]+)[%]}
|
||||
*/
|
||||
public static Pattern getRelationalPlaceholderPattern() {
|
||||
return RELATIONAL_PLACEHOLDER_PATTERN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a String contains any PlaceholderAPI placeholders ({@literal
|
||||
* %<identifier>_<params>%}).
|
||||
*
|
||||
* @param text String to check
|
||||
* @return true if String contains any matches to the normal placeholder pattern, false otherwise
|
||||
*/
|
||||
public static boolean containsPlaceholders(String text) {
|
||||
return text != null && PLACEHOLDER_PATTERN.matcher(text).find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a String contains any PlaceholderAPI bracket placeholders ({@literal
|
||||
* {<identifier>_<params>}}).
|
||||
*
|
||||
* @param text String to check
|
||||
* @return true if String contains any matches to the bracket placeholder pattern, false otherwise
|
||||
*/
|
||||
public static boolean containsBracketPlaceholders(String text) {
|
||||
return text != null && BRACKET_PLACEHOLDER_PATTERN.matcher(text).find();
|
||||
}
|
||||
|
||||
public static String booleanValue(final boolean value) {
|
||||
return value ? PlaceholderAPIPlugin.instance().configManager().config().booleanValue().trueValue() : PlaceholderAPIPlugin.instance().configManager().config().booleanValue().falseValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package at.helpch.placeholderapi;
|
||||
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommandRouter;
|
||||
import at.helpch.placeholderapi.configuration.ConfigManager;
|
||||
import at.helpch.placeholderapi.expansion.manager.CloudExpansionManager;
|
||||
import at.helpch.placeholderapi.expansion.manager.LocalExpansionManager;
|
||||
import com.hypixel.hytale.event.EventPriority;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import com.hypixel.hytale.server.core.console.ConsoleSender;
|
||||
import com.hypixel.hytale.server.core.event.events.BootEvent;
|
||||
import com.hypixel.hytale.server.core.event.events.PrepareUniverseEvent;
|
||||
import com.hypixel.hytale.server.core.event.events.player.PlayerDisconnectEvent;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlaceholderAPIPlugin extends JavaPlugin {
|
||||
private final ConfigManager configManager = new ConfigManager(this);
|
||||
private final LocalExpansionManager localExpansionManager = new LocalExpansionManager(this);
|
||||
private final CloudExpansionManager cloudExpansionManager = new CloudExpansionManager(this);
|
||||
|
||||
private static PlaceholderAPIPlugin instance;
|
||||
|
||||
public static PlaceholderAPIPlugin instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public PlaceholderAPIPlugin(@NotNull final JavaPluginInit init) {
|
||||
super(init);
|
||||
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
configManager.setup();
|
||||
getEventRegistry().register(PlayerDisconnectEvent.class, localExpansionManager::onQuit);
|
||||
getEventRegistry().register(EventPriority.LAST, BootEvent.class, this::onServerLoad);
|
||||
|
||||
if (configManager.config().cloudEnabled()) {
|
||||
cloudExpansionManager.load();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void start() {
|
||||
getCommandRegistry().registerCommand(new PlaceholderCommandRouter(this));
|
||||
|
||||
// localExpansionManager().load(ConsoleSender.INSTANCE);
|
||||
|
||||
super.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutdown() {
|
||||
super.shutdown();
|
||||
}
|
||||
|
||||
public void reloadPlugin(@NotNull final CommandSender sender) {
|
||||
localExpansionManager.kill();
|
||||
// configManager.save();
|
||||
configManager.setup();
|
||||
|
||||
localExpansionManager.load(sender);
|
||||
|
||||
if (configManager.config().cloudEnabled()) {
|
||||
cloudExpansionManager.load();
|
||||
} else {
|
||||
cloudExpansionManager.kill();
|
||||
}
|
||||
}
|
||||
|
||||
public LocalExpansionManager localExpansionManager() {
|
||||
return localExpansionManager;
|
||||
}
|
||||
|
||||
public ConfigManager configManager() {
|
||||
return configManager;
|
||||
}
|
||||
|
||||
public CloudExpansionManager cloudExpansionManager() {
|
||||
return cloudExpansionManager;
|
||||
}
|
||||
|
||||
private void onServerLoad(BootEvent event) {
|
||||
localExpansionManager.load(ConsoleSender.INSTANCE);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,11 +18,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.expansion;
|
||||
package at.helpch.placeholderapi;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface Relational {
|
||||
|
||||
String onPlaceholderRequest(Player one, Player two, String identifier);
|
||||
public interface PlaceholderHook {
|
||||
@Nullable
|
||||
String onPlaceholderRequest(final PlayerRef player, @NotNull final String params);
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public abstract class PlaceholderCommand {
|
||||
|
||||
@NotNull
|
||||
private final String label;
|
||||
@NotNull
|
||||
private final Set<String> alias;
|
||||
|
||||
private Set<String> permissions = new HashSet<>();
|
||||
|
||||
|
||||
protected PlaceholderCommand(@NotNull final String label, @NotNull final String... alias) {
|
||||
this.label = label;
|
||||
this.alias = Set.of(alias);
|
||||
|
||||
setPermissions("placeholderapi.*");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Stream<PlaceholderCommand> filterByPermission(@NotNull final CommandSender sender,
|
||||
@NotNull final Stream<PlaceholderCommand> commands) {
|
||||
return commands.filter(target -> target.getPermissions().stream().anyMatch(sender::hasPermission));
|
||||
}
|
||||
|
||||
public static void suggestByParameter(@NotNull final Stream<String> possible,
|
||||
@NotNull final List<String> suggestions, @Nullable final String parameter) {
|
||||
if (parameter == null) {
|
||||
possible.forEach(suggestions::add);
|
||||
} else {
|
||||
possible.filter(suggestion -> suggestion.toLowerCase(Locale.ROOT).startsWith(parameter.toLowerCase(Locale.ROOT)))
|
||||
.forEach(suggestions::add);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public final Set<String> getAlias() {
|
||||
return Set.copyOf(alias);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public final Set<String> getLabels() {
|
||||
final Set<String> set = new HashSet<>();
|
||||
set.add(label);
|
||||
set.addAll(alias);
|
||||
return set;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Set<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(@NotNull final String @NotNull ... permissions) {
|
||||
this.permissions.addAll(Arrays.asList(permissions));
|
||||
}
|
||||
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
|
||||
}
|
||||
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands;
|
||||
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.impl.cloud.CommandECloud;
|
||||
import at.helpch.placeholderapi.commands.impl.local.*;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.*;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class PlaceholderCommandRouter extends AbstractCommand {
|
||||
|
||||
@Unmodifiable
|
||||
private static final List<PlaceholderCommand> COMMANDS = List.of(new CommandHelp(),
|
||||
new CommandInfo(),
|
||||
new CommandList(),
|
||||
new CommandDump(),
|
||||
new CommandECloud(),
|
||||
new CommandParse(),
|
||||
new CommandReload(),
|
||||
new CommandVersion(),
|
||||
new CommandExpansionRegister(),
|
||||
new CommandExpansionUnregister());
|
||||
|
||||
|
||||
@NotNull
|
||||
private final PlaceholderAPIPlugin plugin;
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
private final Map<String, PlaceholderCommand> commands;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "papi";
|
||||
}
|
||||
|
||||
public PlaceholderCommandRouter(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||
super("papi", "papi");
|
||||
addAliases("placeholderapi");
|
||||
setAllowsExtraArguments(true);
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
final Map<String, PlaceholderCommand> commands = new HashMap<>();
|
||||
|
||||
for (final PlaceholderCommand command : COMMANDS) {
|
||||
command.getLabels().forEach(label -> commands.put(label, command));
|
||||
}
|
||||
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canGeneratePermission() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable CompletableFuture<Void> execute(@NotNull final CommandContext context) {
|
||||
final String[] args = context.getInputString().replace("papi", "").replace("placeholderapi", "").trim().split(" ");
|
||||
final CommandSender sender = context.sender();
|
||||
|
||||
if (args.length == 0 || args[0].isBlank()) {
|
||||
final PlaceholderCommand fallback = commands.get("version");
|
||||
if (fallback != null) {
|
||||
fallback.evaluate(plugin, sender, "", Collections.emptyList());
|
||||
}
|
||||
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
final String search = args[0].toLowerCase(Locale.ROOT);
|
||||
final PlaceholderCommand target = commands.get(search);
|
||||
|
||||
if (target == null) {
|
||||
sender.sendMessage(Message.raw("Unknown command ").color(Color.RED).insert(Message.raw(search).color(Color.GRAY)));
|
||||
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
final Set<String> permissions = target.getPermissions();
|
||||
if (permissions.stream().noneMatch(sender::hasPermission)) {
|
||||
sender.sendMessage(Message.raw("You do not have permission to do this!").color(Color.RED));
|
||||
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
target
|
||||
.evaluate(plugin, sender, search, Arrays.asList(Arrays.copyOfRange(args, 1, args.length)));
|
||||
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class CommandECloud extends PlaceholderCommand {
|
||||
|
||||
@Unmodifiable
|
||||
private static final List<PlaceholderCommand> COMMANDS = List
|
||||
.of(new CommandECloudClear(),
|
||||
new CommandECloudStatus(),
|
||||
new CommandECloudUpdate(),
|
||||
new CommandECloudRefresh(),
|
||||
new CommandECloudDownload(),
|
||||
new CommandECloudExpansionInfo(),
|
||||
new CommandECloudExpansionList(),
|
||||
new CommandECloudExpansionPlaceholders());
|
||||
|
||||
static {
|
||||
COMMANDS
|
||||
.forEach(command -> command.setPermissions("placeholderapi.ecloud." + command.getLabel()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
private final Map<String, PlaceholderCommand> commands;
|
||||
|
||||
|
||||
public CommandECloud() {
|
||||
super("ecloud");
|
||||
|
||||
final Map<String, PlaceholderCommand> commands = new HashMap<>();
|
||||
|
||||
for (final PlaceholderCommand command : COMMANDS) {
|
||||
command.getLabels().forEach(label -> commands.put(label, command));
|
||||
}
|
||||
|
||||
this.commands = commands;
|
||||
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud");
|
||||
COMMANDS.stream().map(PlaceholderCommand::getPermissions).flatMap(Set::stream).forEach(this::setPermissions);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
Message message = Message.empty()
|
||||
.insert(Message.raw("PlaceholderAPI ").color(Color.CYAN).bold(true))
|
||||
.insert(Message.raw("- ").color(Color.DARK_GRAY))
|
||||
.insert(Message.raw("eCloud Help Menu ").color(Color.GRAY))
|
||||
.insert(Message.raw("-\n").color(Color.DARK_GRAY));
|
||||
|
||||
final List<String[]> commands = List.of(
|
||||
new String[]{"ecloud status", "View status of the eCloud"},
|
||||
new String[]{"ecloud list <all/{author}/installed> {page}", "List all/author specific available expansions"},
|
||||
new String[]{"ecloud info <expansion name> {version}", "View information about a specific expansion available on the eCloud"},
|
||||
new String[]{"ecloud placeholders <expansion name>", "View placeholders for an expansion"},
|
||||
new String[]{"ecloud download <expansion name> {version}", "Download an expansion from the eCloud"},
|
||||
new String[]{"ecloud update <expansion name/all>", "Update a specific/all installed expansions"},
|
||||
new String[]{"ecloud refresh", "Fetch the most up to date list of expansions available."},
|
||||
new String[]{"ecloud clear", "Clear the expansion cloud cache."}
|
||||
);
|
||||
|
||||
for (String[] command : commands) {
|
||||
message = message.insert(Message.raw("\n/papi ").color(Color.CYAN))
|
||||
.insert(Message.raw(command[0]).color(Color.WHITE))
|
||||
.insert(Message.raw("\n " + command[1]).color(Color.GRAY));
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
|
||||
// Msg.msg(sender,
|
||||
// "&b&lPlaceholderAPI &8- &7eCloud Help Menu &8- ",
|
||||
// " ",
|
||||
// "&b/papi &fecloud status",
|
||||
// " &7&oView status of the eCloud",
|
||||
// "&b/papi &fecloud list <all/{author}/installed> {page}",
|
||||
// " &7&oList all/author specific available expansions",
|
||||
// "&b/papi &fecloud info <expansion name> {version}",
|
||||
// " &7&oView information about a specific expansion available on the eCloud",
|
||||
// "&b/papi &fecloud placeholders <expansion name>",
|
||||
// " &7&oView placeholders for an expansion",
|
||||
// "&b/papi &fecloud download <expansion name> {version}",
|
||||
// " &7&oDownload an expansion from the eCloud",
|
||||
// "&b/papi &fecloud update <expansion name/all>",
|
||||
// " &7&oUpdate a specific/all installed expansions",
|
||||
// "&b/papi &fecloud refresh",
|
||||
// " &7&oFetch the most up to date list of expansions available.",
|
||||
// "&b/papi &fecloud clear",
|
||||
// " &7&oClear the expansion cloud cache.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final String search = params.get(0).toLowerCase(Locale.ROOT);
|
||||
final PlaceholderCommand target = commands.get(search);
|
||||
|
||||
if (target == null) {
|
||||
sender.sendMessage(Message.raw("Unknown command ").color(Color.RED).insert(Message.raw("ecloud " + search).color(Color.GRAY)));
|
||||
// Msg.msg(sender, "&cUnknown command &7ecloud " + search);
|
||||
return;
|
||||
}
|
||||
|
||||
final Set<String> permissions = target.getPermissions();
|
||||
if (permissions.stream().noneMatch(sender::hasPermission)) {
|
||||
sender.sendMessage(Message.raw("You do not have permission to do this!").color(Color.RED));
|
||||
// Msg.msg(sender, "&cYou do not have permission to do this!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.configManager().config().cloudEnabled()) {
|
||||
sender.sendMessage(Message.raw("The eCloud Manager is not enabled! To enable it, set 'cloud_enabled' to true and reload the plugin."));
|
||||
// Msg.msg(sender, "&cThe eCloud Manager is not enabled! To enable it, set 'cloud_enabled' to true and reload the plugin.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.getLabel().equalsIgnoreCase("refresh") && plugin.cloudExpansionManager().isEmpty()) {
|
||||
sender.sendMessage(Message.raw("There is no available data from the eCloud. Please try running ").color(Color.RED)
|
||||
.insert(Message.raw("/papi ecloud refresh").color(Color.WHITE))
|
||||
.insert(Message.raw(" If this does not resolve the issue, the eCloud may be blocked by your firewall, server host or service provider.\n\n").color(Color.RED))
|
||||
.insert(Message.raw("More information: ").color(Color.RED))
|
||||
.insert(Message.raw("https://placeholderapi.com/ecloud-blocked").color(Color.WHITE).bold(true).italic(true).link("https://placeholderapi.com/ecloud-blocked")));
|
||||
// Msg.msg(sender, "&cThere is no available data from the eCloud. Please try running &f/papi ecloud refresh&c. If this does not resolve the issue, the eCloud may be blocked by your firewall, server host, or service provider.\n\nMore information: &fhttps://placeholderapi.com/ecloud-blocked");
|
||||
return;
|
||||
}
|
||||
|
||||
target.evaluate(plugin, sender, search, params.subList(1, params.size()));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
// @NotNull final CommandSender sender, @NotNull final String alias,
|
||||
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
// if (params.size() <= 1) {
|
||||
// final Stream<String> targets = filterByPermission(sender, commands.values().stream())
|
||||
// .map(PlaceholderCommand::getLabels).flatMap(Collection::stream);
|
||||
// suggestByParameter(targets, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
//
|
||||
// return; // send sub commands
|
||||
// }
|
||||
//
|
||||
// final String search = params.get(0).toLowerCase(Locale.ROOT);
|
||||
// final PlaceholderCommand target = commands.get(search);
|
||||
//
|
||||
// if (target == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// target.complete(plugin, sender, search, params.subList(1, params.size()), suggestions);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandECloudClear extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudClear() {
|
||||
super("clear");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
plugin.cloudExpansionManager().clean();
|
||||
sender.sendMessage(Message.raw("The eCloud cache has been cleared!").color(Color.GREEN));
|
||||
// Msg.msg(sender,
|
||||
// "&aThe eCloud cache has been cleared!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandECloudDownload extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudDownload() {
|
||||
super("download");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.download");
|
||||
}
|
||||
|
||||
private boolean isBlockedExpansion(String name) {
|
||||
String env = System.getenv("PAPI_BLOCKED_EXPANSIONS");
|
||||
if (env == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Arrays.stream(env.split(","))
|
||||
.anyMatch(s -> s.equalsIgnoreCase(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must supply the name of an expansion.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must supply the name of an expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBlockedExpansion(params.get(0))) {
|
||||
sender.sendMessage(Message.raw("This expansion can't be downloaded.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cThis expansion can't be downloaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion expansion = plugin.cloudExpansionManager()
|
||||
.findCloudExpansionByName(params.get(0)).orElse(null);
|
||||
if (expansion == null) {
|
||||
sender.sendMessage(Message.raw("Failed to find an expansion named: ").color(Color.GREEN).insert(Message.raw(params.get(0)).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cFailed to find an expansion named: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion.Version version;
|
||||
if (params.size() < 2) {
|
||||
version = expansion.getVersion(expansion.getLatestVersion());
|
||||
if (version == null) {
|
||||
sender.sendMessage(Message.raw("Could not find latest version for expansion.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cCould not find latest version for expansion.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
version = expansion.getVersion(params.get(1));
|
||||
if (version == null) {
|
||||
sender.sendMessage(Message.raw("Could not find specified version: ").color(Color.RED)
|
||||
.insert(Message.raw(params.get(0) + "\n").color(Color.WHITE))
|
||||
.insert(Message.raw("Available versions: ").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.getAvailableVersions().toString()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cCould not find specified version: &f" + params.get(1),
|
||||
// "&7Available versions: &f" + expansion.getAvailableVersions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!version.isVerified()) {
|
||||
sender.sendMessage(Message.raw("The expansion: '").color(Color.RED)
|
||||
.insert(Message.raw(params.get(0)).color(Color.WHITE))
|
||||
.insert(Message.raw("' is not verified and can only be downloaded manually from ").color(Color.RED))
|
||||
.insert(Message.raw("https://ecloud.placeholderapi.com").color(Color.WHITE)));
|
||||
// Msg.msg(sender, "&cThe expansion '&f" + params.get(0) + "&c' is not verified and can only be downloaded manually from &fhttps://ecloud.placeholderapi.com");
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cloudExpansionManager().downloadExpansion(expansion, version)
|
||||
.whenComplete((file, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage(Message.raw("Failed to download expansion: ").color(Color.RED).insert(Message.raw(exception.getMessage()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cFailed to download expansion: &f" + exception.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(Message.raw("Successfully downloaded expansion ").color(Color.GREEN)
|
||||
.insert(Message.raw(expansion.getName() + " [" + version.getVersion() + "] ").color(Color.WHITE))
|
||||
.insert(Message.raw("to file: ").color(Color.GREEN))
|
||||
.insert(Message.raw(file.getName()).color(Color.WHITE))
|
||||
.insert(Message.raw("\nMake sure to type ").color(Color.GREEN))
|
||||
.insert(Message.raw("/papi reload ").color(Color.GREEN))
|
||||
.insert(Message.raw("to enable your new expansion!").color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&aSuccessfully downloaded expansion &f" + expansion.getName() + " [" + version
|
||||
// .getVersion() + "] &ato file: &f" + file.getName(),
|
||||
// "&aMake sure to type &f/papi reload &ato enable your new expansion!");
|
||||
|
||||
plugin.cloudExpansionManager().load();
|
||||
});
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
// @NotNull final CommandSender sender, @NotNull final String alias,
|
||||
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
// if (params.size() > 2) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (params.size() <= 1) {
|
||||
// final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values()
|
||||
// .stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
|
||||
// suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager()
|
||||
// .findCloudExpansionByName(params.get(0));
|
||||
// if (!expansion.isPresent()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// suggestByParameter(expansion.get().getAvailableVersions().stream(), suggestions, params.get(1));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandECloudExpansionInfo extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudExpansionInfo() {
|
||||
super("info");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.info");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must specify the name of the expansion.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must specify the name of the expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion expansion = plugin.cloudExpansionManager()
|
||||
.findCloudExpansionByName(params.get(0)).orElse(null);
|
||||
if (expansion == null) {
|
||||
sender.sendMessage(Message.raw("There is no expansion with the name: ").color(Color.RED).insert(Message.raw(params.get(0)).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cThere is no expansion with the name: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
Message message = Message.raw("Expansion: ").color(Color.CYAN)
|
||||
.insert(Message.raw(expansion.getName()).color(expansion.shouldUpdate() ? Color.YELLOW : Color.GREEN))
|
||||
.insert(Message.raw("\nAuthor: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getAuthor()).color(Color.WHITE))
|
||||
.insert(Message.raw("\n"));
|
||||
|
||||
if (params.size() < 2) {
|
||||
message = message
|
||||
.insert(Message.raw("Latest Version: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getLatestVersion()).color(Color.WHITE))
|
||||
.insert(Message.raw("\nReleased: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getTimeSinceLastUpdate() + " ago").color(Color.WHITE))
|
||||
.insert(Message.raw("\nVerified: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getVersion().isVerified() ? "YES" : "NO")
|
||||
.color(expansion.getVersion().isVerified() ? Color.GREEN : Color.RED)
|
||||
.bold(true))
|
||||
.insert(Message.raw("\nRelease Notes: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getVersion().getReleaseNotes()).color(Color.WHITE))
|
||||
.insert(Message.raw("\n"));
|
||||
} else {
|
||||
final CloudExpansion.Version version = expansion.getVersion(params.get(1));
|
||||
if (version == null) {
|
||||
sender.sendMessage(Message.raw("Could not find specified version: ").color(Color.RED)
|
||||
.insert(Message.raw(params.get(1)).color(Color.WHITE))
|
||||
.insert(Message.raw("\nVersions: ").color(Color.GREEN))
|
||||
.insert(Message.raw(expansion.getAvailableVersions().toString()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cCould not find specified version: &f" + params.get(1),
|
||||
// "&aVersions: &f" + expansion.getAvailableVersions());
|
||||
return;
|
||||
}
|
||||
|
||||
message = message
|
||||
.insert(Message.raw("Version: ").color(Color.CYAN))
|
||||
.insert(Message.raw(version.getVersion()).color(Color.WHITE))
|
||||
.insert(Message.raw("\nVerified: ").color(Color.CYAN))
|
||||
.insert(Message.raw(version.isVerified() ? "YES" : "NO")
|
||||
.color(version.isVerified() ? Color.GREEN : Color.RED)
|
||||
.bold(true))
|
||||
.insert(Message.raw("\nRelease Notes: ").color(Color.CYAN))
|
||||
.insert(Message.raw(version.getReleaseNotes()).color(Color.WHITE))
|
||||
.insert(Message.raw("\nDownload URL: ").color(Color.CYAN))
|
||||
.insert(Message.raw(version.getUrl()).color(Color.WHITE))
|
||||
.insert(Message.raw("\n"));
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
// @NotNull final CommandSender sender, @NotNull final String alias,
|
||||
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
// if (params.size() > 2) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (params.size() <= 1) {
|
||||
// final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values()
|
||||
// .stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
|
||||
// suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager()
|
||||
// .findCloudExpansionByName(params.get(0));
|
||||
// if (!expansion.isPresent()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// suggestByParameter(expansion.get().getAvailableVersions().stream(), suggestions, params.get(1));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import at.helpch.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandECloudExpansionList extends PlaceholderCommand {
|
||||
|
||||
private static final int PAGE_SIZE = 10;
|
||||
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, String> EXPANSION_LATEST_VERSION =
|
||||
CloudExpansion::getLatestVersion;
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, String> EXPANSION_CURRENT_VERSION =
|
||||
expansion -> PlaceholderAPIPlugin.instance().localExpansionManager()
|
||||
.findExpansionByName(expansion.getName()).map(PlaceholderExpansion::getVersion)
|
||||
.orElse("Unknown");
|
||||
|
||||
|
||||
@Unmodifiable
|
||||
private static final Set<String> OPTIONS = Set.of("all", "installed");
|
||||
|
||||
|
||||
public CommandECloudExpansionList() {
|
||||
super("list");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.list");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<CloudExpansion> getExpansions(@NotNull final String target,
|
||||
@NotNull final PlaceholderAPIPlugin plugin) {
|
||||
switch (target.toLowerCase(Locale.ROOT)) {
|
||||
case "all":
|
||||
return plugin.cloudExpansionManager().getCloudExpansions().values();
|
||||
case "installed":
|
||||
return plugin.cloudExpansionManager().getCloudExpansionsInstalled().values();
|
||||
default:
|
||||
return plugin.cloudExpansionManager().getCloudExpansionsByAuthor(target).values();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<CloudExpansion> getPage(@NotNull final List<CloudExpansion> expansions,
|
||||
final int page) {
|
||||
final int head = (page * PAGE_SIZE);
|
||||
final int tail = Math.min(expansions.size(), head + PAGE_SIZE);
|
||||
|
||||
if (expansions.size() < head) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return expansions.subList(head, tail);
|
||||
}
|
||||
|
||||
public static Message buildExpansionTitle(@NotNull final String target, final int page) {
|
||||
Message title;
|
||||
switch (target.toLowerCase(Locale.ROOT)) {
|
||||
case "all":
|
||||
title = Message.raw("All Expansions").color(Color.CYAN);
|
||||
break;
|
||||
case "installed":
|
||||
title = Message.raw("Installed Expansions").color(Color.CYAN);
|
||||
break;
|
||||
default:
|
||||
title = Message.raw("Expansions by ").color(Color.CYAN)
|
||||
.insert(Message.raw(target).color(Color.WHITE));
|
||||
break;
|
||||
}
|
||||
|
||||
if (page == -1) {
|
||||
return title.insert(Message.raw("\n"));
|
||||
}
|
||||
|
||||
return title
|
||||
.insert(Message.raw(" Page").color(Color.CYAN))
|
||||
.insert(Message.raw(": ").color(Color.GRAY))
|
||||
.insert(Message.raw(String.valueOf(page)).color(Color.GREEN));
|
||||
}
|
||||
|
||||
private static Message getMessage(@NotNull final List<CloudExpansion> expansions,
|
||||
final int page, final int limit, @NotNull final String target) {
|
||||
Message message = Message.empty();
|
||||
|
||||
for (int index = 0; index < expansions.size(); index++) {
|
||||
final CloudExpansion expansion = expansions.get(index);
|
||||
Message line = Message.empty();
|
||||
|
||||
final int expansionNumber = index + ((page - 1) * PAGE_SIZE) + 1;
|
||||
line = line.insert(Message.raw(expansionNumber + ". ").color(Color.DARK_GRAY));
|
||||
|
||||
final Color expansionColour;
|
||||
|
||||
if (expansion.shouldUpdate()) {
|
||||
expansionColour = Color.YELLOW;
|
||||
} else {
|
||||
if (expansion.hasExpansion()) {
|
||||
expansionColour = Color.GREEN;
|
||||
} else {
|
||||
expansionColour = Color.GRAY;
|
||||
}
|
||||
}
|
||||
|
||||
line = line.insert(Message.raw(expansion.getName()).color(expansionColour));
|
||||
|
||||
// line = line.click(ClickEvent.suggestCommand("/papi ecloud download " + expansion.getName()));
|
||||
//
|
||||
// final TextComponent.Builder hoverText = text("Click to download this expansion!", AQUA)
|
||||
// .append(newline()).append(newline())
|
||||
// .append(text("Author: ", AQUA)).append(text(expansion.getAuthor(), WHITE))
|
||||
// .append(newline())
|
||||
// .append(text("Verified: ", AQUA)).append(text(expansion.getVersion().isVerified() ? "✔" : "❌", expansion.getVersion().isVerified() ? GREEN : RED, TextDecoration.BOLD))
|
||||
// .append(newline())
|
||||
// .append(text("Released: ", AQUA)).append(text(format.format(expansion.getLastUpdate()), WHITE))
|
||||
// .toBuilder();
|
||||
//
|
||||
// Optional.ofNullable(expansion.getDescription())
|
||||
// .filter(description -> !description.isEmpty())
|
||||
// .ifPresent(description -> hoverText.append(newline()).append(newline())
|
||||
// .append(text(description.replace("\r", "").trim(), WHITE))
|
||||
// );
|
||||
|
||||
// line.hoverEvent(HoverEvent.showText(hoverText.build()));
|
||||
|
||||
if (index != expansions.size() - 1) {
|
||||
line.insert(Message.raw("\n"));
|
||||
}
|
||||
|
||||
message = message.insert(line);
|
||||
}
|
||||
|
||||
if (limit > 1) {
|
||||
message = message.insert("\n");
|
||||
|
||||
// Message left = Message.raw("◀", page > 1 ? GRAY : DARK_GRAY).toBuilder();
|
||||
|
||||
// if (page > 1) {
|
||||
// left.clickEvent(ClickEvent.runCommand("/papi ecloud list " + target + " " + (page - 1)));
|
||||
// }
|
||||
//
|
||||
// final TextComponent.Builder right = text("▶", page < limit ? GRAY : DARK_GRAY).toBuilder();
|
||||
|
||||
// if (page < limit) {
|
||||
// right.clickEvent(ClickEvent.runCommand("/papi ecloud list " + target + " " + (page + 1)));
|
||||
// }
|
||||
|
||||
message = message.insert(Message.raw(" - " + page + " - ").color(Color.GREEN));
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private static Message buildExpansionTable(@NotNull final List<CloudExpansion> expansions,
|
||||
final int startIndex,
|
||||
@NotNull final String versionTitle,
|
||||
@NotNull final Function<CloudExpansion, String> versionFunction) {
|
||||
final List<List<String>> rows = new ArrayList<>();
|
||||
rows.add(List.of("#", "Name", "Author", "Verified", versionTitle));
|
||||
|
||||
int counter = startIndex;
|
||||
for (final CloudExpansion expansion : expansions) {
|
||||
rows.add(List.of(
|
||||
counter++ + ".",
|
||||
expansion.getName(),
|
||||
expansion.getAuthor(),
|
||||
expansion.getVersion().isVerified() ? "Y" : "N",
|
||||
versionFunction.apply(expansion)
|
||||
));
|
||||
}
|
||||
|
||||
final int columnCount = rows.getFirst().size();
|
||||
final int[] widths = new int[columnCount];
|
||||
for (final List<String> row : rows) {
|
||||
for (int i = 0; i < columnCount; i++) {
|
||||
widths[i] = Math.max(widths[i], row.get(i).length());
|
||||
}
|
||||
}
|
||||
|
||||
final List<Color> headerColors = List.of(
|
||||
Color.WHITE,
|
||||
new Color(85, 85, 255),
|
||||
new Color(85, 85, 255),
|
||||
new Color(85, 85, 255),
|
||||
new Color(85, 85, 255)
|
||||
);
|
||||
|
||||
Message message = Message.empty();
|
||||
message = message.insert(buildTableRow(rows.getFirst(), headerColors, widths));
|
||||
message = message.insert(Message.raw("\n"));
|
||||
|
||||
final int separatorLength = Arrays.stream(widths).sum() + (columnCount * 2);
|
||||
message = message.insert(Message.raw("-".repeat(separatorLength)).color(Color.DARK_GRAY));
|
||||
|
||||
if (rows.size() > 1) {
|
||||
message = message.insert(Message.raw("\n"));
|
||||
}
|
||||
|
||||
for (int rowIndex = 1; rowIndex < rows.size(); rowIndex++) {
|
||||
final List<String> row = rows.get(rowIndex);
|
||||
final CloudExpansion expansion = expansions.get(rowIndex - 1);
|
||||
|
||||
final Color nameColor = expansion.shouldUpdate()
|
||||
? Color.YELLOW
|
||||
: (expansion.hasExpansion() ? Color.GREEN : Color.GRAY);
|
||||
|
||||
final List<Color> rowColors = List.of(
|
||||
Color.DARK_GRAY,
|
||||
nameColor,
|
||||
Color.WHITE,
|
||||
expansion.getVersion().isVerified() ? Color.GREEN : Color.RED,
|
||||
Color.WHITE
|
||||
);
|
||||
|
||||
message = message.insert(buildTableRow(row, rowColors, widths));
|
||||
if (rowIndex < rows.size() - 1) {
|
||||
message = message.insert(Message.raw("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private static Message buildTableRow(@NotNull final List<String> columns,
|
||||
@NotNull final List<Color> colors,
|
||||
@NotNull final int[] widths) {
|
||||
Message row = Message.empty();
|
||||
|
||||
for (int i = 0; i < columns.size(); i++) {
|
||||
final String padded = padRight(columns.get(i), widths[i] + 2);
|
||||
row = row.insert(Message.raw(padded).color(colors.get(i)));
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String padRight(@NotNull final String text, final int length) {
|
||||
if (text.length() >= length) {
|
||||
return text;
|
||||
}
|
||||
return text + " ".repeat(length - text.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must specify an option. [all, {author}, installed]").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must specify an option. [all, {author}, installed]");
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean installed = params.get(0).equalsIgnoreCase("installed");
|
||||
final List<CloudExpansion> expansions = new ArrayList<>(getExpansions(params.get(0), plugin));
|
||||
|
||||
if (expansions.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("No expansions available to list.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cNo expansions available to list.");
|
||||
return;
|
||||
}
|
||||
|
||||
expansions
|
||||
.sort(plugin.configManager().config().cloudSorting());
|
||||
|
||||
if (!(sender instanceof Player) && params.size() < 2) {
|
||||
final Message message = buildExpansionTitle(params.get(0), -1)
|
||||
.insert(buildExpansionTable(
|
||||
expansions,
|
||||
1,
|
||||
installed ? "Version" : "Latest Version",
|
||||
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION));
|
||||
|
||||
sender.sendMessage(message);
|
||||
// Msg.msg(sender, builder.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
final int page;
|
||||
|
||||
if (params.size() < 2) {
|
||||
page = 1;
|
||||
} else {
|
||||
//noinspection UnstableApiUsage
|
||||
Integer parsed/* = Ints.tryParse(params.get(1))*/;
|
||||
|
||||
try {
|
||||
parsed = Integer.parseInt(params.get(1));
|
||||
} catch (Exception e) {
|
||||
parsed = null;
|
||||
}
|
||||
|
||||
if (parsed == null) {
|
||||
sender.sendMessage(Message.raw("Page number must be an integer.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cPage number must be an integer.");
|
||||
return;
|
||||
}
|
||||
|
||||
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
||||
|
||||
if (parsed < 1 || parsed > limit) {
|
||||
sender.sendMessage(Message.raw("Page number must be in the range [1.." + limit + "]").color(Color.RED)); //todo: not exact
|
||||
// Msg.msg(sender,
|
||||
// "&cPage number must be in the range &8[&a1&7..&a" + limit + "&8]");
|
||||
return;
|
||||
}
|
||||
|
||||
page = parsed;
|
||||
}
|
||||
|
||||
final List<CloudExpansion> values = getPage(expansions, page - 1);
|
||||
|
||||
final Message title = buildExpansionTitle(params.get(0), page);
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
final Message message = title.insert(buildExpansionTable(
|
||||
values,
|
||||
((page - 1) * PAGE_SIZE) + 1,
|
||||
installed ? "Version" : "Latest Version",
|
||||
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION));
|
||||
|
||||
sender.sendMessage(message);
|
||||
// Msg.msg(sender, builder.toString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(title);
|
||||
// Msg.msg(sender, builder.toString());
|
||||
|
||||
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
||||
|
||||
|
||||
final Message message = getMessage(values, page, limit, params.get(0));
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
// @NotNull final CommandSender sender, @NotNull final String alias,
|
||||
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
// if (params.size() > 2) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (params.size() <= 1) {
|
||||
// suggestByParameter(
|
||||
// Sets.union(OPTIONS, plugin.getCloudExpansionManager().getCloudExpansionAuthors())
|
||||
// .stream(), suggestions, params.isEmpty() ? null : params.get(0));
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// suggestByParameter(IntStream.rangeClosed(1,
|
||||
// (int) Math.ceil((double) getExpansions(params.get(0), plugin).size() / PAGE_SIZE))
|
||||
// .mapToObj(Objects::toString), suggestions, params.get(1));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandECloudExpansionPlaceholders extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudExpansionPlaceholders() {
|
||||
super("placeholders");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.placeholders");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must specify the name of the expansion.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must specify the name of the expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion expansion = plugin.cloudExpansionManager()
|
||||
.findCloudExpansionByName(params.get(0)).orElse(null);
|
||||
if (expansion == null) {
|
||||
sender.sendMessage(Message.raw("There is no expansion with the name: ").color(Color.RED).insert(Message.raw(params.getFirst()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cThere is no expansion with the name: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> placeholders = expansion.getPlaceholders();
|
||||
if (placeholders == null || placeholders.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("The expansion specified does not have placeholders listed.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cThe expansion specified does not have placeholders listed.");
|
||||
return;
|
||||
}
|
||||
|
||||
// final List<List<String>> partitions = Lists
|
||||
// .partition(placeholders.stream().sorted().collect(Collectors.toList()), 10);
|
||||
final List<List<String>> partitions = new ArrayList<>(IntStream.range(0, placeholders.size()).boxed().collect(Collectors.groupingBy(i -> i/10, Collectors.mapping(placeholders::get, Collectors.toList()))).values());
|
||||
|
||||
Message message = Message.raw(" ").color(Color.ORANGE)
|
||||
.insert(Message.raw(String.valueOf(placeholders.size())).color(Color.ORANGE))
|
||||
.insert(Message.raw(" placeholders: ").color(Color.GRAY));
|
||||
|
||||
for (int i = 0; i < partitions.size(); i++) {
|
||||
if (i == 0) {
|
||||
message = message.insert(Message.raw("\n"));
|
||||
}
|
||||
|
||||
final List<String> partition = partitions.get(i);
|
||||
for (int j = 0; j < partition.size(); j++) {
|
||||
message = message.insert(Message.raw(partition.get(j)).color(Color.GREEN));
|
||||
if (j < partition.size() - 1) {
|
||||
message = message.insert(Message.raw(", ").color(Color.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
if (i < partitions.size() - 1) {
|
||||
message = message.insert(Message.raw("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
// Msg.msg(sender,
|
||||
// "&6" + placeholders.size() + "&7 placeholders: &a",
|
||||
// partitions.stream().map(partition -> String.join(", ", partition))
|
||||
// .collect(Collectors.joining("\n")));
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
// @NotNull final CommandSender sender, @NotNull final String alias,
|
||||
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
// if (params.size() > 1) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final Stream<String> names = plugin.getCloudExpansionManager()
|
||||
// .getCloudExpansions()
|
||||
// .values()
|
||||
// .stream()
|
||||
// .map(CloudExpansion::getName)
|
||||
// .map(name -> name.replace(' ', '_'));
|
||||
//
|
||||
// suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandECloudRefresh extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudRefresh() {
|
||||
super("refresh");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.refresh");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
plugin.cloudExpansionManager().load();
|
||||
|
||||
sender.sendMessage(Message.raw("The eCloud manager has been refreshed!").color(Color.GREEN));
|
||||
// Msg.msg(sender,
|
||||
// "&aThe eCloud manager has been refreshed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.manager.CloudExpansionManager;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandECloudStatus extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudStatus() {
|
||||
super("status");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.status");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
final CloudExpansionManager manager = plugin.cloudExpansionManager();
|
||||
|
||||
final int updateCount = manager.getCloudUpdateCount();
|
||||
final int authorCount = manager.getCloudExpansionAuthorCount();
|
||||
final int expansionCount = manager.getCloudExpansions().size();
|
||||
|
||||
Message message = Message.raw("There are ").color(Color.CYAN)
|
||||
.insert(Message.raw(String.valueOf(expansionCount)).color(Color.GREEN))
|
||||
.insert(Message.raw(" expansions available on the eCloud.\n").color(Color.CYAN))
|
||||
.insert(Message.raw("A total of ").color(Color.GRAY))
|
||||
.insert(Message.raw(String.valueOf(authorCount)).color(Color.WHITE))
|
||||
.insert(Message.raw(" authors have contributed Hytale expansions to the eCloud.\n").color(Color.GRAY));
|
||||
|
||||
if (updateCount > 0) {
|
||||
message = message
|
||||
.insert(Message.raw("You have ").color(Color.YELLOW))
|
||||
.insert(Message.raw(String.valueOf(updateCount)).color(Color.WHITE))
|
||||
.insert(Message.raw(updateCount > 1 ? " expansions" : " expansion").color(Color.YELLOW))
|
||||
.insert(Message.raw(" installed that ").color(Color.YELLOW))
|
||||
.insert(Message.raw(updateCount > 1 ? "have an" : "has an").color(Color.YELLOW))
|
||||
.insert(Message.raw(" update available.").color(Color.YELLOW));
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
// Msg.msg(sender, builder.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import at.helpch.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import at.helpch.placeholderapi.util.Futures;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
/**
|
||||
* please don't flame me for this code, I will fix this shit later.
|
||||
*/
|
||||
public final class CommandECloudUpdate extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudUpdate() {
|
||||
super("update");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.update");
|
||||
}
|
||||
|
||||
private static CompletableFuture<List<@Nullable Class<? extends PlaceholderExpansion>>> downloadAndDiscover(
|
||||
@NotNull final List<CloudExpansion> expansions, @NotNull final PlaceholderAPIPlugin plugin) {
|
||||
return expansions.stream()
|
||||
.map(expansion -> plugin.cloudExpansionManager()
|
||||
.downloadExpansion(expansion, expansion.getVersion()))
|
||||
.map(future -> future.thenCompose(plugin.localExpansionManager()::findExpansionInFile))
|
||||
.collect(Futures.collector());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must define 'all' or the name of an expansion to update.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must define 'all' or the name of an expansion to update.");
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean multiple = params.get(0).equalsIgnoreCase("all");
|
||||
final List<CloudExpansion> expansions = new ArrayList<>();
|
||||
|
||||
// gather target expansions
|
||||
if (multiple) {
|
||||
expansions.addAll(plugin.cloudExpansionManager().getCloudExpansionsInstalled().values());
|
||||
} else {
|
||||
plugin.cloudExpansionManager().findCloudExpansionByName(params.get(0))
|
||||
.ifPresent(expansions::add);
|
||||
}
|
||||
|
||||
// remove the ones that are the latest version
|
||||
expansions.removeIf(expansion -> !expansion.shouldUpdate());
|
||||
|
||||
if (expansions.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("No updates available for " + (!multiple ? "this expansion." : "your active expansions.")).color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cNo updates available for " + (!multiple ? "this expansion."
|
||||
// : "your active expansions."));
|
||||
return;
|
||||
}
|
||||
|
||||
Message expansionList = Message.raw("[").color(Color.DARK_GRAY);
|
||||
for (int i = 0; i < expansions.size(); i++) {
|
||||
if (i > 0) {
|
||||
expansionList = expansionList.insert(Message.raw(", ").color(Color.GRAY));
|
||||
}
|
||||
expansionList = expansionList.insert(Message.raw(expansions.get(i).getName()).color(Color.ORANGE));
|
||||
}
|
||||
expansionList = expansionList.insert(Message.raw("]").color(Color.DARK_GRAY));
|
||||
|
||||
sender.sendMessage(Message.raw("Updating expansions: ").color(Color.GREEN)
|
||||
.insert(expansionList));
|
||||
// Msg.msg(sender,
|
||||
// "&aUpdating expansions: " + expansions.stream().map(CloudExpansion::getName)
|
||||
// .collect(Collectors.joining("&7, &6", "&8[&6", "&8]&r")));
|
||||
|
||||
Futures.onMainThread(plugin, downloadAndDiscover(expansions, plugin), (classes, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage(Message.raw("Failed to update expansions: ").color(Color.RED).insert(Message.raw(exception.getMessage()).color(Color.YELLOW)));
|
||||
// Msg.msg(sender,
|
||||
// "&cFailed to update expansions: &e" + exception.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(Message.raw("Successfully downloaded updates, registering new versions.").color(Color.GREEN));
|
||||
// Msg.msg(sender,
|
||||
// "&aSuccessfully downloaded updates, registering new versions.");
|
||||
|
||||
final List<PlaceholderExpansion> registered = classes.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(plugin.localExpansionManager()::register)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.toList();
|
||||
|
||||
Message registeredMessage = Message.raw("Registered expansions:\n").color(Color.GRAY);
|
||||
for (int i = 0; i < registered.size(); i++) {
|
||||
final PlaceholderExpansion expansion = registered.get(i);
|
||||
registeredMessage = registeredMessage
|
||||
.insert(Message.raw(" ").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.getName()).color(Color.GREEN))
|
||||
.insert(Message.raw(" ").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.getVersion()).color(Color.WHITE));
|
||||
|
||||
if (i < registered.size() - 1) {
|
||||
registeredMessage = registeredMessage.insert(Message.raw("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(registeredMessage);
|
||||
// Msg.msg(sender,
|
||||
// "&7Registered expansions:", message);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
// @NotNull final CommandSender sender, @NotNull final String alias,
|
||||
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
// if (params.size() > 1) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final List<CloudExpansion> installed = Lists
|
||||
// .newArrayList(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
|
||||
// installed.removeIf(expansion -> !expansion.shouldUpdate());
|
||||
//
|
||||
// if (!installed.isEmpty() && (params.isEmpty() || "all"
|
||||
// .startsWith(params.get(0).toLowerCase(Locale.ROOT)))) {
|
||||
// suggestions.add("all");
|
||||
// }
|
||||
//
|
||||
// suggestByParameter(
|
||||
// installed.stream().map(CloudExpansion::getName).map(name -> name.replace(" ", "_")),
|
||||
// suggestions, params.isEmpty() ? null : params.get(0));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.local;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.common.plugin.AuthorInfo;
|
||||
import com.hypixel.hytale.common.util.java.ManifestUtil;
|
||||
import com.hypixel.hytale.server.core.HytaleServer;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import com.hypixel.hytale.server.core.plugin.PluginBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class CommandDump extends PlaceholderCommand {
|
||||
|
||||
@NotNull
|
||||
private static final String URL = "https://paste.helpch.at/";
|
||||
|
||||
@NotNull
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
@NotNull
|
||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||
.ofLocalizedDateTime(FormatStyle.LONG)
|
||||
.withLocale(Locale.US)
|
||||
.withZone(ZoneId.of("UTC"));
|
||||
|
||||
|
||||
public CommandDump() {
|
||||
super("dump");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.dump");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
postDump(makeDump(plugin)).whenComplete((key, exception) -> {
|
||||
if (exception != null) {
|
||||
plugin.getLogger().atWarning().log("failed to post dump details ", exception);
|
||||
|
||||
sender.sendMessage(Message.raw("Failed to post dump details, check console.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cFailed to post dump details, check console.");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(Message.raw("Successfully posted dump: ").color(Color.GREEN).insert(Message.raw(URL + key).color(Color.WHITE).bold(true).italic(true).link(URL + key)));
|
||||
// Msg.msg(sender,
|
||||
// "&aSuccessfully posted dump: " + URL + key);
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private CompletableFuture<String> postDump(@NotNull final String dump) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
final HttpURLConnection connection = ((HttpURLConnection) new URL(URL + "documents")
|
||||
.openConnection());
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
|
||||
connection.setDoOutput(true);
|
||||
|
||||
connection.connect();
|
||||
|
||||
try (final OutputStream stream = connection.getOutputStream()) {
|
||||
stream.write(dump.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
try (final InputStream stream = connection.getInputStream()) {
|
||||
final String json = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)).lines().collect(Collectors.joining(System.lineSeparator()));
|
||||
return gson.fromJson(json, JsonObject.class).get("key").getAsString();
|
||||
}
|
||||
} catch (final IOException ex) {
|
||||
throw new CompletionException(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String makeDump(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("Generated: ")
|
||||
.append(DATE_FORMAT.format(Instant.now()))
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("PlaceholderAPI: ")
|
||||
.append(plugin.getManifest().getVersion())
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Expansions Registered:")
|
||||
.append('\n');
|
||||
|
||||
final List<PlaceholderExpansion> expansions = plugin.localExpansionManager()
|
||||
.getExpansions()
|
||||
.stream()
|
||||
.sorted(
|
||||
Comparator.comparing(PlaceholderExpansion::getIdentifier)
|
||||
.thenComparing(PlaceholderExpansion::getAuthor)
|
||||
)
|
||||
.toList();
|
||||
|
||||
int size = expansions.stream().map(e -> e.getIdentifier().length())
|
||||
.max(Integer::compareTo)
|
||||
.orElse(0);
|
||||
|
||||
for (final PlaceholderExpansion expansion : expansions) {
|
||||
builder.append(" ")
|
||||
.append(String.format("%-" + size + "s", expansion.getIdentifier()))
|
||||
.append(" [Author: ")
|
||||
.append(expansion.getAuthor())
|
||||
.append(", Version: ")
|
||||
.append(expansion.getVersion())
|
||||
.append("]\n");
|
||||
|
||||
}
|
||||
|
||||
builder.append('\n');
|
||||
|
||||
builder.append("Expansions Directory:")
|
||||
.append('\n');
|
||||
|
||||
final String[] jars = plugin.localExpansionManager()
|
||||
.getExpansionsFolder()
|
||||
.list((dir, name) -> name.toLowerCase(Locale.ROOT).endsWith(".jar"));
|
||||
|
||||
|
||||
if (jars == null) {
|
||||
builder.append(" ¨[Warning]: Could not load jar files from expansions folder.");
|
||||
} else {
|
||||
for (final String jar : jars) {
|
||||
builder.append(" ")
|
||||
.append(jar)
|
||||
.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
builder.append('\n');
|
||||
|
||||
builder.append("Server Info: ")
|
||||
.append(ManifestUtil.getImplementationVersion()) // hytale version
|
||||
.append("\n");
|
||||
|
||||
builder.append("Java Version: ")
|
||||
.append(System.getProperty("java.version"))
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Plugin Info:")
|
||||
.append('\n');
|
||||
|
||||
List<PluginBase> plugins = HytaleServer.get().getPluginManager().getPlugins().stream()
|
||||
.sorted(Comparator.comparing(PluginBase::getName))
|
||||
.toList();
|
||||
|
||||
size = plugins.stream().map(pl -> pl.getName().length())
|
||||
.max(Integer::compareTo)
|
||||
.orElse(0);
|
||||
|
||||
for (final PluginBase other : plugins) {
|
||||
builder.append(" ")
|
||||
.append(String.format("%-" + size + "s", other.getName()))
|
||||
.append(" [Authors: [")
|
||||
.append(other.getManifest().getAuthors().stream()
|
||||
.map(AuthorInfo::getName)
|
||||
.collect(Collectors.joining(", ")))
|
||||
.append("], Version: ")
|
||||
.append(other.getManifest().getVersion())
|
||||
.append("]")
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.local;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import at.helpch.placeholderapi.expansion.manager.LocalExpansionManager;
|
||||
import at.helpch.placeholderapi.util.Futures;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandExpansionRegister extends PlaceholderCommand {
|
||||
|
||||
public CommandExpansionRegister() {
|
||||
super("register");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.register");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must specify the name of an expansion file.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must specify the name of an expansion file.");
|
||||
return;
|
||||
}
|
||||
|
||||
final LocalExpansionManager manager = plugin.localExpansionManager();
|
||||
|
||||
final File file = new File(manager.getExpansionsFolder(), params.getFirst());
|
||||
if (!file.exists() || !file.getParentFile().equals(manager.getExpansionsFolder())) {
|
||||
sender.sendMessage(Message.raw("The file ").color(Color.RED).insert(Message.raw(file.getName()).color(Color.WHITE)).insert(Message.raw(" doesn't exist!").color(Color.RED)));
|
||||
// Msg.msg(sender,
|
||||
// "&cThe file &f" + file.getName() + "&c doesn't exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
Futures.onMainThread(plugin, manager.findExpansionInFile(file), (clazz, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage(Message.raw("Failed to find expansion in file: ").color(Color.RED).insert(Message.raw(file.toString()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cFailed to find expansion in file: &f" + file);
|
||||
|
||||
plugin.getLogger()
|
||||
.atWarning().log("failed to find expansion in file: " + file, exception);
|
||||
return;
|
||||
}
|
||||
|
||||
if (clazz == null) {
|
||||
sender.sendMessage(Message.raw("No expansion class found in file: ").color(Color.RED).insert(Message.raw(file.toString()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cNo expansion class found in file: &f" + file);
|
||||
return;
|
||||
}
|
||||
|
||||
final Optional<PlaceholderExpansion> expansion = manager.register(clazz);
|
||||
if (!expansion.isPresent()) {
|
||||
sender.sendMessage(Message.raw("Failed to register expansion from ").color(Color.RED).insert(Message.raw(params.getFirst()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cFailed to register expansion from &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(Message.raw("Sucessfully registered expansion: ").color(Color.GREEN).insert(Message.raw(expansion.get().getName()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&aSuccessfully registered expansion: &f" + expansion.get().getName());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
// @NotNull final CommandSender sender, @NotNull final String alias,
|
||||
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
// if (params.size() > 1) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final String[] fileNames = plugin.getLocalExpansionManager().getExpansionsFolder()
|
||||
// .list((dir, name) -> name.endsWith(".jar"));
|
||||
// if (fileNames == null || fileNames.length == 0) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// suggestByParameter(Arrays.stream(fileNames), suggestions,
|
||||
// params.isEmpty() ? null : params.get(0));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.local;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandExpansionUnregister extends PlaceholderCommand {
|
||||
|
||||
public CommandExpansionUnregister() {
|
||||
super("unregister");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.unregister");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must specify the name of the expansion.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must specify the name of the expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
final Optional<PlaceholderExpansion> expansion = plugin.localExpansionManager()
|
||||
.findExpansionByName(params.get(0));
|
||||
if (!expansion.isPresent()) {
|
||||
sender.sendMessage(Message.raw("There is no expansion loaded with the identifier: ").color(Color.RED).insert(Message.raw(params.getFirst()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cThere is no expansion loaded with the identifier: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
// final String message = !expansion.get().unregister() ?
|
||||
// "&cFailed to unregister expansion: &f" :
|
||||
// "&aSuccessfully unregistered expansion: &f";
|
||||
final Message message = !expansion.get().unregister() ?
|
||||
Message.raw("Failed to unregister expansion: ").color(Color.RED) :
|
||||
Message.raw("Successfully unregistered expansion: ").color(Color.GREEN);
|
||||
|
||||
sender.sendMessage(message.insert(Message.raw(expansion.get().getName()).color(Color.WHITE)));
|
||||
// sender.sendMessage(Message.raw(message + exp));
|
||||
// Msg.msg(sender, message + expansion.get().getName());
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
// @NotNull final CommandSender sender, @NotNull final String alias,
|
||||
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
// if (params.size() > 1) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions,
|
||||
// params.isEmpty() ? null : params.get(0));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.local;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import com.hypixel.hytale.common.plugin.PluginManifest;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandHelp extends PlaceholderCommand {
|
||||
|
||||
public CommandHelp() {
|
||||
super("help");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.help");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
final PluginManifest description = plugin.getManifest();
|
||||
// final PluginDescriptionFile description = plugin.getDescription();
|
||||
|
||||
final Message message = Message.raw("PlaceholderAPI ").color(Color.CYAN).bold(true)
|
||||
.insert(Message.raw("- ").color(Color.DARK_GRAY).bold(false))
|
||||
.insert(Message.raw("Help Menu ").color(Color.WHITE).bold(false))
|
||||
.insert(Message.raw("- ").color(Color.DARK_GRAY).bold(false))
|
||||
.insert(Message.raw("(").color(Color.GRAY).bold(false))
|
||||
.insert(Message.raw(description.getVersion().toString()).color(Color.WHITE).bold(false))
|
||||
.insert(Message.raw(")").color(Color.GRAY).bold(false))
|
||||
.insert(Message.raw("\n"))
|
||||
.insert(genCommandMsg("bcparse", "<me|--null|player name> <message>", "Parse a message with placeholders and broadcast it"))
|
||||
.insert(genCommandMsg("cmdparse", "<me|player> <command with placeholders>", "Parse a message with relational placeholders"))
|
||||
.insert(genCommandMsg("dump", null, "Dump all relevant information needed to help debug issues into a paste link."))
|
||||
.insert(genCommandMsg("info", "<placeholder name>", "View information for a specific expansion"))
|
||||
.insert(genCommandMsg("list", null, "List active expansions"))
|
||||
.insert(genCommandMsg("parse", "<me|--null|player name> <message>", "Parse a message with placeholders"))
|
||||
.insert(genCommandMsg("parserel", "<player one> <player two> <message>", "Parse a message with relational placeholders"))
|
||||
.insert(genCommandMsg("register", "<file name>", "Register an expansion by the name of the file"))
|
||||
.insert(genCommandMsg("reload", null, "Reload the config of PAPI"))
|
||||
.insert(genCommandMsg("unregister", "<expansion name>", "Unregister an expansion by name"))
|
||||
.insert(genCommandMsg("version", null, "View plugin info/version"));
|
||||
|
||||
sender.sendMessage(message);
|
||||
|
||||
|
||||
// Msg.msg(sender,
|
||||
// "&b&lPlaceholderAPI &8- &7Help Menu &8- &7(&f" + description.getVersion() + "&7)",
|
||||
// " ",
|
||||
// "&b/papi &fbcparse &9<me|--null|player name> <message>",
|
||||
// " &7&oParse a message with placeholders and broadcast it",
|
||||
// "&b/papi &fcmdparse &9<me|player> <command with placeholders>",
|
||||
// " &7&oParse a message with relational placeholders",
|
||||
// "&b/papi &fdump",
|
||||
// " &7&oDump all relevant information needed to help debug issues into a paste link.",
|
||||
// "&b/papi &finfo &9<placeholder name>",
|
||||
// " &7&oView information for a specific expansion",
|
||||
// "&b/papi &flist",
|
||||
// " &7&oList active expansions",
|
||||
// "&b/papi &fparse &9<me|--null|player name> <message>",
|
||||
// " &7&oParse a message with placeholders",
|
||||
// "&b/papi &fparserel &9<player one> <player two> <message>",
|
||||
// " &7&oParse a message with relational placeholders",
|
||||
// "&b/papi &fregister &9<file name>",
|
||||
// " &7&oRegister an expansion by the name of the file",
|
||||
// "&b/papi &freload",
|
||||
// " &7&oReload the config of PAPI",
|
||||
// "&b/papi &funregister &9<expansion name>",
|
||||
// " &7&oUnregister an expansion by name",
|
||||
// "&b/papi &fversion",
|
||||
// " &7&oView plugin info/version");
|
||||
}
|
||||
|
||||
private Message genCommandMsg(@NotNull final String command, @Nullable final String arguments,
|
||||
@NotNull final String description) {
|
||||
Message message = Message.raw("\n/papi ").color(Color.CYAN)
|
||||
.insert(Message.raw(command).color(Color.WHITE));
|
||||
|
||||
if (arguments != null) {
|
||||
message = message.insert(" " + arguments).color(Color.CYAN);
|
||||
}
|
||||
|
||||
return message
|
||||
.insert(Message.raw("\n " + description).color(Color.gray).bold(false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.local;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandInfo extends PlaceholderCommand {
|
||||
|
||||
public CommandInfo() {
|
||||
super("info");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.info");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must specify the name of the expansion.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must specify the name of the expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
final PlaceholderExpansion expansion = plugin.localExpansionManager()
|
||||
.findExpansionByIdentifier(params.get(0)).orElse(null);
|
||||
if (expansion == null) {
|
||||
sender.sendMessage(Message.raw("There is no expansion loaded with the identifier: ").color(Color.RED).insert(Message.raw(params.getFirst()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cThere is no expansion loaded with the identifier: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
Message message = Message.empty()
|
||||
.insert(Message.raw("Placeholder expansion info for:").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.getName() + "\n").color(Color.WHITE))
|
||||
.insert(Message.raw("Status: ").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.isRegistered() ? "Registered" : "Not Registered").color(expansion.isRegistered() ? Color.GREEN : Color.RED))
|
||||
.insert("\n");
|
||||
|
||||
final String author = expansion.getAuthor();
|
||||
if (author != null) {
|
||||
message = message.insert(Message.raw("Author: ").color(Color.GRAY))
|
||||
.insert(Message.raw(author + "\n").color(Color.WHITE));
|
||||
// builder.append("&7Author: &r")
|
||||
// .append(author)
|
||||
// .append('\n');
|
||||
}
|
||||
|
||||
final String version = expansion.getVersion();
|
||||
if (version != null) {
|
||||
message = message.insert(Message.raw("Version: ").color(Color.GRAY))
|
||||
.insert(Message.raw(version + "\n").color(Color.WHITE));
|
||||
|
||||
// builder.append("&7Version: &r")
|
||||
// .append(version)
|
||||
// .append('\n');
|
||||
}
|
||||
|
||||
final String requiredPlugin = expansion.getRequiredPlugin();
|
||||
if (requiredPlugin != null) {
|
||||
message = message.insert(Message.raw("Requires plugin: ").color(Color.GRAY))
|
||||
.insert(Message.raw(requiredPlugin + '\n').color(Color.WHITE));
|
||||
|
||||
// builder.append("&7Requires plugin: &r")
|
||||
// .append(requiredPlugin)
|
||||
// .append('\n');
|
||||
}
|
||||
|
||||
final List<String> placeholders = expansion.getPlaceholders();
|
||||
if (placeholders != null && !placeholders.isEmpty()) {
|
||||
message = message.insert(Message.raw("-- ").color(Color.DARK_GRAY))
|
||||
.insert(Message.raw("Placeholders ").color(Color.GRAY))
|
||||
.insert(Message.raw("--\n").color(Color.DARK_GRAY));
|
||||
// builder.append("&8&m-- &7Placeholders &8&m--&r")
|
||||
// .append('\n');
|
||||
|
||||
for (final String placeholder : placeholders) {
|
||||
message = message.insert(Message.raw(placeholder + "\n").color(Color.WHITE));
|
||||
// builder.append(placeholder)
|
||||
// .append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
|
||||
|
||||
// Msg.msg(sender, builder.toString());
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
// @NotNull final CommandSender sender, @NotNull final String alias,
|
||||
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
// if (params.size() > 1) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions,
|
||||
// params.isEmpty() ? null : params.get(0));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.local;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPI;
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandList extends PlaceholderCommand {
|
||||
|
||||
public CommandList() {
|
||||
super("list");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.list");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
final List<String> identifiers = new ArrayList<>(PlaceholderAPI.getRegisteredIdentifiers());
|
||||
if (identifiers.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("There are no placeholder hooks active!").color(Color.RED));
|
||||
// Msg.msg(sender, "&cThere are no placeholder hooks active!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final List<List<String>> partitions = new ArrayList<>(IntStream.range(0, identifiers.size()).boxed().collect(Collectors.groupingBy(i -> i/10, Collectors.mapping(identifiers::get, Collectors.toList()))).values());
|
||||
// final List<List<String>> partitions = Lists
|
||||
// .partition(identifiers.stream().sorted().collect(Collectors.toList()), 10);
|
||||
|
||||
Message message = Message.raw("A total of ").color(Color.GRAY)
|
||||
.insert(Message.raw(identifiers.size() + " ").color(Color.WHITE))
|
||||
.insert(Message.raw("placeholder hook(s) are active: ").color(Color.GRAY));
|
||||
|
||||
for (int i = 0; i < partitions.size(); ++i) {
|
||||
final List<String> partition = partitions.get(i);
|
||||
|
||||
for (int j = 0; j < partition.size(); ++j) {
|
||||
message = message.insert(Message.raw(partition.get(j)).color(Color.GREEN));
|
||||
|
||||
if (j != partition.size() - 1) {
|
||||
message = message.insert(Message.raw(", ").color(Color.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
if (i != partitions.size() - 1) {
|
||||
message = message.insert(Message.raw("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
|
||||
// Msg.msg(sender,
|
||||
// "&7A total of &f" + identifiers.size() + "&7 placeholder hook(s) are active: &a",
|
||||
// partitions.stream().map(partition -> String.join("&7, &a", partition))
|
||||
// .collect(Collectors.joining("\n")));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.local;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPI;
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.NameMatching;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import com.hypixel.hytale.server.core.universe.Universe;
|
||||
import com.hypixel.hytale.server.core.universe.world.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandParse extends PlaceholderCommand {
|
||||
|
||||
public CommandParse() {
|
||||
super("parse", "bcparse", "parserel", "cmdparse");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.parse");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
final Runnable logic = () -> {
|
||||
switch (alias.toLowerCase(Locale.ROOT)) {
|
||||
case "parserel":
|
||||
evaluateParseRelation(sender, params);
|
||||
break;
|
||||
case "parse":
|
||||
evaluateParseSingular(sender, params, false, false);
|
||||
break;
|
||||
case "bcparse":
|
||||
evaluateParseSingular(sender, params, true, false);
|
||||
break;
|
||||
case "cmdparse":
|
||||
evaluateParseSingular(sender, params, false, true);
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
final World world;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
world = ((Player) sender).getWorld();
|
||||
} else if (sender instanceof PlayerRef) {
|
||||
UUID uuid = ((PlayerRef) sender).getWorldUuid();
|
||||
world = uuid == null ? Universe.get().getDefaultWorld() : Universe.get().getWorld(uuid);
|
||||
} else {
|
||||
world = Universe.get().getDefaultWorld();
|
||||
}
|
||||
|
||||
if (world != null) {
|
||||
world.execute(logic);
|
||||
} else {
|
||||
logic.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateParseSingular(@NotNull final CommandSender sender,
|
||||
@NotNull @Unmodifiable final List<String> params, final boolean broadcast,
|
||||
final boolean command) {
|
||||
if (params.size() < 2) {
|
||||
sender.sendMessage(Message.raw("You must provide a target and a message: ").color(Color.RED)
|
||||
.insert(Message.raw("/papi ").color(Color.CYAN))
|
||||
.insert(Message.raw(command ? "cmdparse" : (broadcast ? "bcparse" : "parse")).color(Color.CYAN))
|
||||
.insert(Message.raw(" {target}").color(Color.GRAY))
|
||||
.insert(Message.raw(" {message}").color(Color.GREEN)));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerRef player;
|
||||
|
||||
if ("me".equalsIgnoreCase(params.getFirst())) {
|
||||
if (!(sender instanceof Player) && !(sender instanceof PlayerRef)) {
|
||||
sender.sendMessage(Message.raw("You must be a player to use ").color(Color.RED).insert(Message.raw("me").color(Color.GRAY)).insert(Message.raw(" as a target!").color(Color.RED)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
player = ((Player) sender).getPlayerRef();
|
||||
} else {
|
||||
player = (PlayerRef) sender;
|
||||
}
|
||||
} else if ("--null".equalsIgnoreCase(params.get(0))) {
|
||||
player = null;
|
||||
} else {
|
||||
final PlayerRef target = resolvePlayer(params.get(0));
|
||||
if (target == null) {
|
||||
sender.sendMessage(Message.raw("Failed to find player: ").color(Color.RED).insert(Message.raw(params.get(0)).color(Color.WHITE)));
|
||||
return;
|
||||
}
|
||||
|
||||
player = target;
|
||||
}
|
||||
|
||||
final String message = PlaceholderAPI
|
||||
.setPlaceholders(player, String.join(" ", params.subList(1, params.size())));
|
||||
|
||||
if (command) {
|
||||
sender.sendMessage(Message.raw("To be implemented")); // todo: implement
|
||||
return;
|
||||
}
|
||||
|
||||
if (broadcast) {
|
||||
Universe.get().sendMessage(Message.raw(message));
|
||||
} else {
|
||||
sender.sendMessage(Message.raw(message));
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateParseRelation(@NotNull final CommandSender sender,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.size() < 3) {
|
||||
sender.sendMessage(Message.raw("You must supply two targets, and a message: ").color(Color.RED)
|
||||
.insert(Message.raw("/papi parserel ").color(Color.CYAN))
|
||||
.insert(Message.raw("{target one} {target two} ").color(Color.GRAY))
|
||||
.insert(Message.raw("{message}").color(Color.GREEN)));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerRef playerOne;
|
||||
|
||||
if ("me".equalsIgnoreCase(params.get(0))) {
|
||||
if (!(sender instanceof Player) && !(sender instanceof PlayerRef)) {
|
||||
sender.sendMessage(Message.raw("You must be a player to use ").color(Color.RED)
|
||||
.insert(Message.raw("me").color(Color.GRAY))
|
||||
.insert(Message.raw(" as a target!").color(Color.RED)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
playerOne = ((Player) sender).getPlayerRef();
|
||||
} else {
|
||||
playerOne = (PlayerRef) sender;
|
||||
}
|
||||
} else {
|
||||
playerOne = resolvePlayer(params.get(0));
|
||||
}
|
||||
|
||||
if (playerOne == null) {
|
||||
sender.sendMessage(Message.raw("Failed to find player: ").color(Color.RED).insert(Message.raw(params.get(0)).color(Color.WHITE)));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerRef playerTwo;
|
||||
|
||||
if ("me".equalsIgnoreCase(params.get(1))) {
|
||||
if (!(sender instanceof Player) && !(sender instanceof PlayerRef)) {
|
||||
sender.sendMessage(Message.raw("You must be a player to use ").color(Color.RED).insert(Message.raw("me").color(Color.GRAY)).insert(Message.raw(" as a target!").color(Color.RED)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
playerTwo = ((Player) sender).getPlayerRef();
|
||||
} else {
|
||||
playerTwo = (PlayerRef) sender;
|
||||
}
|
||||
} else {
|
||||
playerTwo = resolvePlayer(params.get(1));
|
||||
}
|
||||
|
||||
if (playerTwo == null) {
|
||||
sender.sendMessage(Message.raw("Failed to find player: ").color(Color.RED).insert(Message.raw(params.get(1)).color(Color.WHITE)));
|
||||
return;
|
||||
}
|
||||
|
||||
final String message = PlaceholderAPI
|
||||
.setRelationalPlaceholders(playerOne, playerTwo,
|
||||
String.join(" ", params.subList(2, params.size())));
|
||||
|
||||
sender.sendMessage(Message.raw(message));
|
||||
}
|
||||
|
||||
|
||||
private void completeParseSingular(@NotNull final CommandSender sender,
|
||||
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
if (params.size() <= 1) {
|
||||
if (sender instanceof Player && (params.isEmpty() || "me"
|
||||
.startsWith(params.get(0).toLowerCase(Locale.ROOT)))) {
|
||||
suggestions.add("me");
|
||||
}
|
||||
|
||||
if ("--null".startsWith(params.get(0).toLowerCase(Locale.ROOT))) {
|
||||
suggestions.add("--null");
|
||||
}
|
||||
|
||||
final Stream<String> names = Universe.get().getPlayers().stream().map(PlayerRef::getUsername);
|
||||
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final String name = params.get(params.size() - 1);
|
||||
if (!name.startsWith("%") || name.endsWith("%")) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int index = name.indexOf('_');
|
||||
if (index == -1) {
|
||||
return; // no arguments supplied yet
|
||||
}
|
||||
|
||||
final PlaceholderExpansion expansion = PlaceholderAPIPlugin.instance()
|
||||
.localExpansionManager().findExpansionByIdentifier(name.substring(1, index))
|
||||
.orElse(null);
|
||||
if (expansion == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Set<String> possible = new HashSet<>(expansion.getPlaceholders());
|
||||
|
||||
PlaceholderAPIPlugin.instance()
|
||||
.cloudExpansionManager()
|
||||
.findCloudExpansionByName(expansion.getName())
|
||||
.ifPresent(cloud -> possible.addAll(cloud.getPlaceholders()));
|
||||
|
||||
suggestByParameter(possible.stream(), suggestions, params.get(params.size() - 1));
|
||||
}
|
||||
|
||||
// private void completeParseRelation(@NotNull @Unmodifiable final List<String> params,
|
||||
// @NotNull final List<String> suggestions) {
|
||||
// if (params.size() > 2) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final Stream<String> names = Bukkit.getOnlinePlayers().stream().map(Player::getName);
|
||||
// suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(params.size() - 1));
|
||||
// }
|
||||
|
||||
|
||||
@Nullable
|
||||
private PlayerRef resolvePlayer(@NotNull final String name) {
|
||||
// Player target = Universe.get().getPlayerByUsername(name, NameMatching.EXACT);
|
||||
// final Optional<Player> target = world.getPlayers().stream().filter(player -> player.getDisplayName().equals(name)).findAny();
|
||||
//
|
||||
// if (target.isEmpty()) {
|
||||
// // Not the best option, but Spigot doesn't offer a good replacement (as usual)
|
||||
//// target = Bukkit.getOfflinePlayer(name);
|
||||
////
|
||||
//// return target.hasPlayedBefore() ? target : null;
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return target.get();
|
||||
return Universe.get().getPlayerByUsername(name, NameMatching.EXACT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,28 +18,28 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.local;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
package at.helpch.placeholderapi.commands.impl.local;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class CommandReload extends PlaceholderCommand
|
||||
{
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public CommandReload()
|
||||
{
|
||||
super("reload");
|
||||
}
|
||||
public final class CommandReload extends PlaceholderCommand {
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
plugin.reloadConf(sender);
|
||||
}
|
||||
public CommandReload() {
|
||||
super("reload");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
plugin.reloadPlugin(sender);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.local;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import com.hypixel.hytale.common.plugin.AuthorInfo;
|
||||
import com.hypixel.hytale.common.plugin.PluginManifest;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CommandVersion extends PlaceholderCommand {
|
||||
|
||||
public CommandVersion() {
|
||||
super("version");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.version");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
final PluginManifest description = plugin.getManifest();
|
||||
|
||||
sender.sendMessage(Message.empty()
|
||||
.insert(Message.raw("PlaceholderAPI ").color(Color.CYAN).bold(true))
|
||||
.insert(Message.raw("(").color(Color.GRAY))
|
||||
.insert(Message.raw(description.getVersion().toString()).color(Color.WHITE))
|
||||
.insert(Message.raw(")").color(Color.GRAY))
|
||||
.insert(Message.raw("\nAuthor: ").color(Color.GRAY))
|
||||
.insert(Message.raw(description.getAuthors().stream().map(AuthorInfo::getName).collect(Collectors.joining(", "))).color(Color.WHITE))
|
||||
.insert(Message.raw("\nPAPI Commands: ").color(Color.GRAY))
|
||||
.insert(Message.raw("/papi ").color(Color.CYAN))
|
||||
.insert(Message.raw("help").color(Color.WHITE))
|
||||
.insert(Message.raw("\neCloud Commands: ").color(Color.GRAY))
|
||||
.insert(Message.raw("/papi ").color(Color.CYAN))
|
||||
.insert(Message.raw("ecloud").color(Color.WHITE)));
|
||||
|
||||
// Msg.msg(sender,
|
||||
// "&b&lPlaceholderAPI &7(&f" + description.getVersion() + "&7)",
|
||||
// "&7Author: &f" + description.getAuthors().stream().map(AuthorInfo::getName).collect(Collectors.joining(", ")),
|
||||
// "&7PAPI Commands: &b/papi &fhelp",
|
||||
// "&7eCloud Commands&8: &b/papi &fecloud");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package at.helpch.placeholderapi.configuration;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record BooleanValue(@NotNull String trueValue, @NotNull String falseValue) {
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package at.helpch.placeholderapi.configuration;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import com.google.gson.FieldNamingPolicy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.hypixel.hytale.logger.HytaleLogger;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class ConfigManager {
|
||||
private static final Yaml YAML;
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
|
||||
.create();
|
||||
// .registerTypeAdapter()
|
||||
private static final Pattern LINE_DELIMITER = Pattern.compile("\n");
|
||||
|
||||
static {
|
||||
final DumperOptions options = new DumperOptions();
|
||||
options.setPrettyFlow(true);
|
||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
YAML = new Yaml(options);
|
||||
}
|
||||
|
||||
private final JavaPlugin main;
|
||||
private final HytaleLogger logger;
|
||||
private PlaceholderAPIConfig config;
|
||||
|
||||
public ConfigManager(@NotNull final JavaPlugin main) {
|
||||
this.main = main;
|
||||
this.logger = main.getLogger();
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
final String content;
|
||||
|
||||
try {
|
||||
final Path file = createFile("/config.yml", main.getDataDirectory().toString() + "/config.yml");
|
||||
|
||||
if (file != null) {
|
||||
content = Files.readString(file);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<String, Object> data = YAML.load(content);
|
||||
config = GSON.fromJson(GSON.toJsonTree(data), PlaceholderAPIConfig.class);
|
||||
}
|
||||
|
||||
public PlaceholderAPIConfig config() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
final Map<String, Object> map = GSON.fromJson(GSON.toJsonTree(config), new TypeToken<Map<String, Object>>(){}.getType());
|
||||
final String yaml = YAML.dump(map);
|
||||
final Path path = Paths.get(main.getDataDirectory().toString() + "/config.yml");
|
||||
Files.write(path, Arrays.asList(LINE_DELIMITER.split(yaml)), StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
} catch (Exception e) {
|
||||
logger.atSevere().log("Something went wrong when saving config.yml: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> T convertExpansion(@NotNull final Map<String, Object> expansionConfig, @NotNull final Class<T> type) {
|
||||
return GSON.fromJson(GSON.toJsonTree(expansionConfig), type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Path createFile(@NotNull final String internalPath, @NotNull final String externalPath) {
|
||||
final Path file = Paths.get(externalPath);
|
||||
|
||||
if (Files.exists(file)) {
|
||||
return file;
|
||||
}
|
||||
|
||||
final Optional<Path> parent = Optional.ofNullable(file.getParent());
|
||||
|
||||
try {
|
||||
if (parent.isPresent()) {
|
||||
Files.createDirectories(parent.get());
|
||||
}
|
||||
|
||||
Files.createFile(file);
|
||||
} catch (IOException e) {
|
||||
logger.atSevere().log("Something went wrong when trying to create ", file);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (exportResource(internalPath, externalPath)) {
|
||||
return file;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean exportResource(@NotNull final String internalPath, @NotNull final String externalPath) {
|
||||
try {
|
||||
Files.copy(PlaceholderAPIPlugin.class.getResourceAsStream(internalPath), Paths.get(externalPath),
|
||||
StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.atSevere().log("Something went wrong when moving internal: ", internalPath, " to ", externalPath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.configuration;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import at.helpch.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum ExpansionSort implements Comparator<CloudExpansion> {
|
||||
|
||||
NAME(Comparator.comparing(CloudExpansion::getName)),
|
||||
AUTHOR(Comparator.comparing(CloudExpansion::getAuthor)),
|
||||
LATEST(Comparator.comparing(CloudExpansion::getLastUpdate).reversed());
|
||||
|
||||
|
||||
@NotNull
|
||||
private final Comparator<CloudExpansion> comparator;
|
||||
|
||||
ExpansionSort(@NotNull final Comparator<CloudExpansion> comparator) {
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final int compare(final CloudExpansion expansion1, final CloudExpansion expansion2) {
|
||||
return comparator.compare(expansion1, expansion2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.configuration;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class PlaceholderAPIConfig {
|
||||
private boolean cloudEnabled;
|
||||
private boolean debugMode;
|
||||
private ExpansionSort cloudSorting;
|
||||
private BooleanValue booleanValue;
|
||||
private String dateFormat;
|
||||
private Map<String, Object> expansions;
|
||||
|
||||
public PlaceholderAPIConfig(boolean cloudEnabled, boolean debugMode, @NotNull ExpansionSort cloudSorting,
|
||||
@NotNull BooleanValue booleanValue, @NotNull String dateFormat) {
|
||||
this.cloudEnabled = cloudEnabled;
|
||||
this.debugMode = debugMode;
|
||||
this.cloudSorting = cloudSorting;
|
||||
this.booleanValue = booleanValue;
|
||||
this.dateFormat = dateFormat;
|
||||
this.expansions = new HashMap<>();
|
||||
}
|
||||
|
||||
public PlaceholderAPIConfig(boolean cloudEnabled, boolean debugMode, @NotNull ExpansionSort cloudSorting,
|
||||
@NotNull BooleanValue booleanValue, @NotNull String dateFormat, Map<String, Object> expansions) {
|
||||
this.cloudEnabled = cloudEnabled;
|
||||
this.debugMode = debugMode;
|
||||
this.cloudSorting = cloudSorting;
|
||||
this.booleanValue = booleanValue;
|
||||
this.dateFormat = dateFormat;
|
||||
this.expansions = expansions;
|
||||
}
|
||||
|
||||
public boolean cloudEnabled() {
|
||||
return cloudEnabled;
|
||||
}
|
||||
|
||||
public void cloudEnabled(final boolean value) {
|
||||
cloudEnabled = value;
|
||||
}
|
||||
|
||||
public boolean debugMode() {
|
||||
return debugMode;
|
||||
}
|
||||
|
||||
public void debugMode(final boolean value) {
|
||||
debugMode = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExpansionSort cloudSorting() {
|
||||
return cloudSorting;
|
||||
}
|
||||
|
||||
public void cloudSorting(@NotNull final ExpansionSort value) {
|
||||
cloudSorting = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BooleanValue booleanValue() {
|
||||
return booleanValue;
|
||||
}
|
||||
|
||||
public void booleanValue(@NotNull final BooleanValue value) {
|
||||
booleanValue = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String dateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void dateFormat(@NotNull final String value) {
|
||||
dateFormat = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<String, Object> expansions() {
|
||||
return expansions;
|
||||
}
|
||||
|
||||
public void expansions(@NotNull final Map<String, Object> value) {
|
||||
expansions = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.events;
|
||||
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.event.ICancellable;
|
||||
import com.hypixel.hytale.event.IEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event indicates that a <b>single</b> {@link PlaceholderExpansion PlaceholderExpansion} has
|
||||
* been registered in PlaceholderAPI.
|
||||
*
|
||||
* <p>To know when <b>all</b> Expansions have been registered, use the
|
||||
* {@link at.helpch.placeholderapi.events.ExpansionsLoadedEvent ExpansionsLoadedEvent} instead.
|
||||
*/
|
||||
public final class ExpansionRegisterEvent implements IEvent<Void>, ICancellable {
|
||||
@NotNull
|
||||
private final PlaceholderExpansion expansion;
|
||||
private boolean cancelled;
|
||||
|
||||
public ExpansionRegisterEvent(@NotNull final PlaceholderExpansion expansion) {
|
||||
this.expansion = expansion;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link PlaceholderExpansion PlaceholderExpansion} that was registered in PlaceholderAPI.
|
||||
* <br>The PlaceholderExpansion will be available for use when the event
|
||||
* {@link #isCancelled() was not cancelled}!
|
||||
*
|
||||
* @return Current instance of the registered {@link PlaceholderExpansion PlaceholderExpansion}
|
||||
*/
|
||||
@NotNull
|
||||
public PlaceholderExpansion getExpansion() {
|
||||
return expansion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this event was cancelled or not.
|
||||
* <br>A cancelled Event will result in the {@link #getExpansion() PlaceholderExpansion} NOT
|
||||
* being added to PlaceholderAPI's internal list and will therefore be considered not registered
|
||||
* anymore.
|
||||
*
|
||||
* @return Whether the event has been cancelled or not.
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.events;
|
||||
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.event.IEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event indicates that a {@link PlaceholderExpansion PlaceholderExpansion} has been
|
||||
* unregistered by PlaceholderAPI.
|
||||
*
|
||||
* <p>Note that this event is triggered <b>before</b> the PlaceholderExpansion is completely
|
||||
* removed.
|
||||
* <br>This includes removing any Listeners, stopping active tasks and clearing the cache of
|
||||
* the PlaceholderExpansion.
|
||||
*/
|
||||
public final class ExpansionUnregisterEvent implements IEvent<ExpansionUnregisterEvent> {
|
||||
@NotNull
|
||||
private final PlaceholderExpansion expansion;
|
||||
|
||||
public ExpansionUnregisterEvent(@NotNull final PlaceholderExpansion expansion) {
|
||||
this.expansion = expansion;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link PlaceholderExpansion PlaceholderExpansion} that was unregistered.
|
||||
*
|
||||
* @return The {@link PlaceholderExpansion PlaceholderExpansion} instance.
|
||||
*/
|
||||
@NotNull
|
||||
public PlaceholderExpansion getExpansion() {
|
||||
return expansion;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.events;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.event.IEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event indicated that <b>all</b> {@link PlaceholderExpansion PlaceholderExpansions} have
|
||||
* been registered in PlaceholderAPI and can now be used.
|
||||
* <br>This even will also be triggered whenever PlaceholderAPI gets reloaded.
|
||||
*
|
||||
* <p>All PlaceholderExpansions, except for those loaded by plugins, are loaded
|
||||
* after Spigot triggered its ServerLoadEvent (1.13+), or after PlaceholderAPI has been enabled.
|
||||
*/
|
||||
public class ExpansionsLoadedEvent implements IEvent<ExpansionsLoadedEvent> {
|
||||
|
||||
private final List<PlaceholderExpansion> expansions;
|
||||
|
||||
public ExpansionsLoadedEvent(List<PlaceholderExpansion> expansions) {
|
||||
this.expansions = Collections.unmodifiableList(expansions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unmodifiable list of {@link PlaceholderExpansion PlaceholderExpansions} that
|
||||
* have been registered by PlaceholderAPI.
|
||||
*
|
||||
* <p><b>This list does not include manually registered PlaceholderExpansions.</b>
|
||||
*
|
||||
* @return List of {@link PlaceholderExpansion registered PlaceholderExpansions}.
|
||||
*/
|
||||
@NotNull
|
||||
public final List<PlaceholderExpansion> getExpansions() {
|
||||
return expansions;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,9 +18,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.exceptions;
|
||||
package at.helpch.placeholderapi.exceptions;
|
||||
|
||||
public final class NoDefaultCommandException extends RuntimeException {
|
||||
|
||||
public NoDefaultCommandException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,12 +18,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.expansion;
|
||||
package at.helpch.placeholderapi.expansion;
|
||||
|
||||
/**
|
||||
* This interface allows a class which extends a {@link PlaceholderExpansion} to have the clear
|
||||
* method called when the implementing expansion is unregistered from PlaceholderAPI. This is useful
|
||||
* if we want to do things when the implementing hook is unregistered
|
||||
* Classes implementing this interface will have a {@link #clear() clear void} that is called
|
||||
* by PlaceholderAPI whenever the {@link at.helpch.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion}
|
||||
* is unregistered.
|
||||
*
|
||||
* <p>This allows you to execute things such as clearing internal caches, saving data to files, etc.
|
||||
*
|
||||
* @author Ryan McCarthy
|
||||
*/
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,14 +18,16 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.expansion;
|
||||
package at.helpch.placeholderapi.expansion;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
|
||||
/**
|
||||
* This interface allows a class which extends a {@link PlaceholderExpansion} to have the cleanup
|
||||
* method called every time a player leaves the server. This is useful if we want to clean up after
|
||||
* the player
|
||||
* Classes implementing this interface will have a {@link #cleanup(PlayerRef) cleanup void} that is
|
||||
* called by PlaceholderAPI whenever a Player leaves the server.
|
||||
*
|
||||
* <p>This can be useful for cases where you keep data of the player in a cache or similar
|
||||
* and want to free up space whenever they leave.
|
||||
*
|
||||
* @author Ryan McCarthy
|
||||
*/
|
||||
@@ -36,5 +38,5 @@ public interface Cleanable {
|
||||
*
|
||||
* @param p (@link Player} who left the server
|
||||
*/
|
||||
void cleanup(Player p);
|
||||
void cleanup(PlayerRef p);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.expansion;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Implementing this interface allows {@link at.helpch.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansions}
|
||||
* allows you to map an object to a section of yaml in the main config.yml.
|
||||
*
|
||||
* <p>The entries will be added under {@code expansions} as their own section.
|
||||
* <h2>Example:</h2>
|
||||
*
|
||||
* <pre><code>
|
||||
* expansions:
|
||||
* myexpansion:
|
||||
* foo: "bar"
|
||||
* </code></pre>
|
||||
*
|
||||
* <p><b>The configuration is set before the PlaceholderExpansion is registered!</b>
|
||||
*
|
||||
* @author Ryan McCarthy
|
||||
*/
|
||||
public interface Configurable<T> {
|
||||
|
||||
@NotNull
|
||||
Class<T> provideConfigType();
|
||||
|
||||
@NotNull
|
||||
T provideDefault();
|
||||
|
||||
// /**
|
||||
// * The map returned by this method will be used to set config options in PlaceholderAPI's config.yml.
|
||||
// *
|
||||
// * <p>The key and value pairs are set under a section named after your
|
||||
// * {@link at.helpch.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion} in the
|
||||
// * {@code expansions} section of the config.
|
||||
// *
|
||||
// * @return Map of config path / values which need to be added / removed from the PlaceholderAPI
|
||||
// * config.yml file
|
||||
// */
|
||||
// Map<String, Object> getDefaults();
|
||||
}
|
||||
@@ -0,0 +1,546 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.expansion;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.PlaceholderHook;
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.component.Store;
|
||||
import com.hypixel.hytale.server.core.HytaleServer;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.plugin.PluginBase;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Any class extending this will be able to get registered as a PlaceholderExpansion.
|
||||
* <br>The registration either happens automatically when the jar file containing a
|
||||
* class extending this one is located under the {@code PlaceholderAPI/expansions}
|
||||
* directory or when the {@link #register()} method is called by said class.
|
||||
*/
|
||||
public abstract class PlaceholderExpansion implements PlaceholderHook {
|
||||
private static final Pattern PATH_DELIMITER = Pattern.compile(".");
|
||||
|
||||
/**
|
||||
* The type is {@link Type#INTERNAL} by default.
|
||||
* For external expansions, the type is updated on {@link at.helpch.placeholderapi.expansion.manager.LocalExpansionManager#register(Class) register}.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
protected Type expansionType = Type.INTERNAL;
|
||||
|
||||
/**
|
||||
* The placeholder identifier of this expansion. May not contain {@literal %},
|
||||
* {@literal {}} or _
|
||||
*
|
||||
* @return placeholder identifier that is associated with this expansion
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String getIdentifier();
|
||||
|
||||
/**
|
||||
* The author of this expansion
|
||||
*
|
||||
* @return name of the author for this expansion
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String getAuthor();
|
||||
|
||||
/**
|
||||
* The version of this expansion
|
||||
*
|
||||
* @return current version of this expansion
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String getVersion();
|
||||
|
||||
/**
|
||||
* The name of this expansion
|
||||
*
|
||||
* @return {@link #getIdentifier()} by default, name of this expansion if specified
|
||||
*/
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return getIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the plugin that this expansion hooks into. by default will null
|
||||
*
|
||||
* @return plugin name that this expansion requires to function
|
||||
*/
|
||||
@Nullable
|
||||
public String getRequiredPlugin() {
|
||||
return getPlugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* The placeholders associated with this expansion
|
||||
*
|
||||
* @return placeholder list that this expansion provides
|
||||
*/
|
||||
@NotNull
|
||||
public List<String> getPlaceholders() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expansions that do not use the ecloud and instead register from the dependency should set this
|
||||
* to true to ensure that your placeholder expansion is not unregistered when the papi reload
|
||||
* command is used
|
||||
*
|
||||
* @return if this expansion should persist through placeholder reloads
|
||||
*/
|
||||
public boolean persist() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if this placeholder identifier has already been registered
|
||||
*
|
||||
* @return true if the identifier for this expansion is already registered
|
||||
*/
|
||||
public final boolean isRegistered() {
|
||||
return getPlaceholderAPI().localExpansionManager().findExpansionByIdentifier(getIdentifier())
|
||||
.map(it -> it.equals(this)).orElse(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If any requirements need to be checked before this expansion should register, you can check
|
||||
* them here
|
||||
*
|
||||
* @return true if this hook meets all the requirements to register
|
||||
*/
|
||||
public boolean canRegister() {
|
||||
return getRequiredPlugin() == null
|
||||
|| HytaleServer.get().getPluginManager().getPlugins().stream().map(PluginBase::getName).anyMatch(getRequiredPlugin()::equals);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to register this PlaceholderExpansion
|
||||
*
|
||||
* @return true if this expansion is now registered with PlaceholderAPI
|
||||
*/
|
||||
public boolean register() {
|
||||
return getPlaceholderAPI().localExpansionManager().register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to unregister this PlaceholderExpansion
|
||||
*
|
||||
* @return true if this expansion is now unregistered with PlaceholderAPI
|
||||
*/
|
||||
public final boolean unregister() {
|
||||
return getPlaceholderAPI().localExpansionManager().unregister(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Quick getter for the {@link PlaceholderAPIPlugin} instance
|
||||
*
|
||||
* @return {@link PlaceholderAPIPlugin} instance
|
||||
*/
|
||||
@NotNull
|
||||
public final PlaceholderAPIPlugin getPlaceholderAPI() {
|
||||
return PlaceholderAPIPlugin.instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the expansion
|
||||
*
|
||||
* @return the type of the expansion
|
||||
* @since 2.11.4
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Type getExpansionType() {
|
||||
return expansionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of the expansion
|
||||
*
|
||||
* @param expansionType the new type
|
||||
* @since 2.11.4
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public void setExpansionType(Type expansionType) {
|
||||
this.expansionType = expansionType;
|
||||
}
|
||||
|
||||
// === Configuration ===
|
||||
|
||||
// /**
|
||||
// * Gets the ConfigurationSection of the expansion located in the config.yml of PlaceholderAPI or
|
||||
// * null when not specified.
|
||||
// * <br>You may use the {@link Configurable} interface to define default values set
|
||||
// *
|
||||
// * @return ConfigurationSection that this expansion has.
|
||||
// */
|
||||
// @NotNull
|
||||
// public final Map<String, Object> getExpansionConfig() {
|
||||
// return (Map<String, Object>) getPlaceholderAPI().configManager().config().expansions().getOrDefault(getIdentifier(), new HashMap<>());
|
||||
// }
|
||||
|
||||
@Nullable
|
||||
public final <T> T getExpansionConfig(@NotNull final Class<? extends Configurable<T>> configurableType) {
|
||||
return (T) getPlaceholderAPI().configManager().config().expansions().getOrDefault(getIdentifier(), null);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Gets the ConfigurationSection relative to the {@link #getConfigSection() default one} set
|
||||
// * by the expansion or null when the default ConfigurationSection is null
|
||||
// *
|
||||
// * @param path The path to get the ConfigurationSection from. This is relative to the default section
|
||||
// * @return ConfigurationSection relative to the default section
|
||||
// */
|
||||
// @Nullable
|
||||
// public final ConfigurationSection getConfigSection(@NotNull final String path) {
|
||||
// final ConfigurationSection section = getConfigSection();
|
||||
// return section == null ? null : section.getConfigurationSection(path);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Gets the Object relative to the config section set
|
||||
// * by the expansion or the provided Default Object, when the default ConfigurationSection is null
|
||||
// *
|
||||
// * @param path The path to get the Object from. This is relative to the default section
|
||||
// * @param def The default Object to return when the ConfigurationSection returns null
|
||||
// * @return Object from the provided path or the default one provided
|
||||
// */
|
||||
// @Nullable
|
||||
// @Contract("_, !null -> !null")
|
||||
// public final Object get(@NotNull final String path, final Object def) {
|
||||
// return get(new ArrayDeque<>(Arrays.asList(PATH_DELIMITER.split(path))), def, getExpansionConfig());
|
||||
// }
|
||||
//
|
||||
// private Object get(@NotNull final Queue<String> path, final Object def, @NotNull final Map<String, Object> map) {
|
||||
// if (path.size() == 1) {
|
||||
// return map.getOrDefault(path.poll(), def);
|
||||
// }
|
||||
//
|
||||
// Object obj = map.get(path.poll());
|
||||
//
|
||||
// if (!(obj instanceof Map<?, ?>)) {
|
||||
// return def;
|
||||
// }
|
||||
//
|
||||
// return get(path, def, (Map<String, Object>) obj);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the int relative to the config section set
|
||||
// * by the expansion or the provided Default int, when the default ConfigurationSection is null
|
||||
// *
|
||||
// * @param path The path to get the int from. This is relative to the default section
|
||||
// * @param def The default int to return when the ConfigurationSection returns null
|
||||
// * @return int from the provided path or the default one provided
|
||||
// */
|
||||
// public final int getInt(@NotNull final String path, final int def) {
|
||||
// final Object obj = get(path, def);
|
||||
//
|
||||
// if (!(obj instanceof Integer)) {
|
||||
// return def;
|
||||
// }
|
||||
//
|
||||
// return (Integer) obj;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the long relative to the config section set
|
||||
// * by the expansion or the provided Default long, when the default ConfigurationSection is null
|
||||
// *
|
||||
// * @param path The path to get the long from. This is relative to the default section
|
||||
// * @param def The default long to return when the ConfigurationSection returns null
|
||||
// * @return long from the provided path or the default one provided
|
||||
// */
|
||||
// public final long getLong(@NotNull final String path, final long def) {
|
||||
// final Object obj = get(path, def);
|
||||
//
|
||||
// if (!(obj instanceof Long) ) {
|
||||
// return def;
|
||||
// }
|
||||
//
|
||||
// return (Long) obj;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the double relative to the config section set
|
||||
// * by the expansion or the provided Default double, when the default ConfigurationSection is null
|
||||
// *
|
||||
// * @param path The path to get the double from. This is relative to the default section
|
||||
// * @param def The default double to return when the ConfigurationSection returns null
|
||||
// * @return double from the provided path or the default one provided
|
||||
// */
|
||||
// public final double getDouble(@NotNull final String path, final double def) {
|
||||
// final Object obj = get(path, def);
|
||||
//
|
||||
// if (!(obj instanceof Double) ) {
|
||||
// return def;
|
||||
// }
|
||||
//
|
||||
// return (Double) obj;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the String relative to the config section set
|
||||
// * by the expansion or the provided Default String, when the default ConfigurationSection is null
|
||||
// *
|
||||
// * @param path The path to get the String from. This is relative to the default section
|
||||
// * @param def The default String to return when the ConfigurationSection returns null. Can be null
|
||||
// * @return String from the provided path or the default one provided
|
||||
// */
|
||||
// @Nullable
|
||||
// @Contract("_, !null -> !null")
|
||||
// public final String getString(@NotNull final String path, @Nullable final String def) {
|
||||
// final Object obj = get(path, def);
|
||||
//
|
||||
// if (!(obj instanceof String)) {
|
||||
// return def;
|
||||
// }
|
||||
//
|
||||
// return (String) obj;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets a String List relative to the config section set
|
||||
// * by the expansion or an empty List, when the default ConfigurationSection is null
|
||||
// *
|
||||
// * @param path The path to get the String list from. This is relative to the default section
|
||||
// * @return String list from the provided path or an empty list
|
||||
// */
|
||||
// @NotNull
|
||||
// public final List<String> getStringList(@NotNull final String path) {
|
||||
// final Object obj = get(path, new ArrayList<>());
|
||||
//
|
||||
// if (!(obj instanceof List<?>)) {
|
||||
// return new ArrayList<>();
|
||||
// }
|
||||
//
|
||||
// return (List<String>) obj;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the boolean relative to the config section set
|
||||
// * by the expansion or the default boolean, when the default ConfigurationSection is null
|
||||
// *
|
||||
// * @param path The path to get the boolean from. This is relative to the default section
|
||||
// * @param def The default boolean to return when the ConfigurationSection is null
|
||||
// * @return boolean from the provided path or the default one provided
|
||||
// */
|
||||
// public final boolean getBoolean(@NotNull final String path, final boolean def) {
|
||||
// final Object obj = get(path, def);
|
||||
//
|
||||
// if (!(obj instanceof Boolean)) {
|
||||
// return def;
|
||||
// }
|
||||
//
|
||||
// return (Boolean) obj;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Whether the config section contains the provided path
|
||||
// * or not. This will return {@code false} when either the default section is null, or doesn't
|
||||
// * contain the provided path
|
||||
// *
|
||||
// * @param path The path to check
|
||||
// * @return true when the default ConfigurationSection is not null and contains the path, false otherwise
|
||||
// */
|
||||
// public final boolean configurationContains(@NotNull final String path) {
|
||||
// final Object obj = get(path, null);
|
||||
//
|
||||
// return obj == null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Logs the provided message with the provided Level in the console.
|
||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
||||
*
|
||||
* @param level The Level at which the message should be logged with
|
||||
* @param msg The message to log
|
||||
*/
|
||||
public void log(Level level, String msg) {
|
||||
getPlaceholderAPI().getLogger().at(level).log("[" + getName() + "] " + msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the provided message and Throwable with the provided Level in the console.
|
||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
||||
*
|
||||
* @param level The Level at which the message should be logged with
|
||||
* @param msg The message to log
|
||||
* @param throwable The Throwable to log
|
||||
*/
|
||||
public void log(Level level, String msg, Throwable throwable) {
|
||||
getPlaceholderAPI().getLogger().at(level).log("[" + getName() + "] " + msg, throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the provided message with Level "info".
|
||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
||||
*
|
||||
* @param msg The message to log
|
||||
*/
|
||||
public void info(String msg) {
|
||||
log(Level.INFO, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the provided message with Level "warning".
|
||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
||||
*
|
||||
* @param msg The message to log
|
||||
*/
|
||||
public void warning(String msg) {
|
||||
log(Level.WARNING, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the provided message with Level "severe" (error).
|
||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
||||
*
|
||||
* @param msg The message to log
|
||||
*/
|
||||
public void severe(String msg) {
|
||||
log(Level.SEVERE, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the provided message and Throwable with Level "severe" (error).
|
||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
||||
*
|
||||
* @param msg The message to log
|
||||
* @param throwable The Throwable to log
|
||||
*/
|
||||
public void severe(String msg, Throwable throwable) {
|
||||
log(Level.SEVERE, msg, throwable);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the provided Object is an instance of this PlaceholderExpansion.
|
||||
* <br>This method will perform the following checks in order:
|
||||
* <br><ul>
|
||||
* <li>Checks if Object equals the class. Returns true when equal and continues otherwise</li>
|
||||
* <li>Checks if the Object is an instance of a PlaceholderExpansion. Returns false if not</li>
|
||||
* <li>Checks if the Object's Identifier, Author and version equal the one of this class</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param o The Object to check
|
||||
* @return true or false depending on the above mentioned checks
|
||||
*/
|
||||
@Override
|
||||
public final boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof PlaceholderExpansion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PlaceholderExpansion expansion = (PlaceholderExpansion) o;
|
||||
|
||||
return getIdentifier().equals(expansion.getIdentifier()) &&
|
||||
getAuthor().equals(expansion.getAuthor()) &&
|
||||
getVersion().equals(expansion.getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String containing the Expansion's name, author and version
|
||||
*
|
||||
* @return String containing name, author and version of the expansion
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return String.format("PlaceholderExpansion[name: '%s', author: '%s', version: '%s', type: '%s']", getName(),
|
||||
getAuthor(), getVersion(), getExpansionType());
|
||||
}
|
||||
|
||||
// === Deprecated API ===
|
||||
|
||||
/**
|
||||
* @return The plugin name.
|
||||
* @deprecated As of versions greater than 2.8.7, use {@link #getRequiredPlugin()}
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.13.0")
|
||||
public String getPlugin() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The description of the expansion.
|
||||
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to show a description
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.13.0")
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The link for the expansion.
|
||||
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to display a link
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.13.0")
|
||||
public String getLink() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* An expansion provided by a plugin is considered internal
|
||||
*/
|
||||
INTERNAL,
|
||||
|
||||
/**
|
||||
* An expansion loaded from the expansions folder is considered external
|
||||
*/
|
||||
EXTERNAL
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Player player(@NotNull final PlayerRef target) {
|
||||
final Ref<EntityStore> ref = target.getReference();
|
||||
|
||||
if (ref == null || !ref.isValid()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Store<EntityStore> store = ref.getStore();
|
||||
|
||||
return store.isInThread() ? store.getComponent(ref, Player.getComponentType()) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.expansion;
|
||||
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
|
||||
/**
|
||||
* Implementing this interface allows your {@link at.helpch.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion}
|
||||
* to be used as a relational placeholder expansion.
|
||||
*
|
||||
* <p>Relational placeholders take two Players as input and are always prefixed with {@code rel_},
|
||||
* so {@code %foo_bar%} becomes {@code %rel_foo_bar%}
|
||||
*/
|
||||
public interface Relational {
|
||||
|
||||
/**
|
||||
* This method is called whenever a placeholder starting with {@code rel_} is called.
|
||||
*
|
||||
* @param one The first player used for the placeholder.
|
||||
* @param two The second player used for the placeholder.
|
||||
* @param identifier The text right after the expansion's name (%expansion_<b>identifier</b>%)
|
||||
* @return Parsed String from the expansion.
|
||||
*/
|
||||
String onPlaceholderRequest(PlayerRef one, PlayerRef two, String identifier);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,20 +18,26 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.expansion;
|
||||
|
||||
package at.helpch.placeholderapi.expansion;
|
||||
|
||||
/**
|
||||
* Implementing this interface adds the {@link #start() start} and {@link #stop() stop} void
|
||||
* methods to your {@link at.helpch.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion}.
|
||||
*
|
||||
* <p>This can be used to execute methods and tasks whenever the PlaceholderExpansion has been
|
||||
* successfully (un)registered.
|
||||
*/
|
||||
public interface Taskable {
|
||||
|
||||
/**
|
||||
* Called when the implementing class has successfully been registered to the placeholder map
|
||||
* Tasks that need to be performed when this expansion is registered should go here
|
||||
* Called when the implementing class has successfully been registered to the placeholder map.
|
||||
* <br>Tasks that need to be performed when this expansion is registered should go here
|
||||
*/
|
||||
void start();
|
||||
|
||||
/**
|
||||
* Called when the implementing class has been unregistered from PlaceholderAPI Tasks that need to
|
||||
* be performed when this expansion has unregistered should go here
|
||||
* Called when the implementing class has been unregistered from PlaceholderAPI.
|
||||
* <br>Tasks that need to be performed when this expansion has unregistered should go here
|
||||
*/
|
||||
void stop();
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,14 +18,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.expansion.cloud;
|
||||
|
||||
import me.clip.placeholderapi.util.TimeUtil;
|
||||
package at.helpch.placeholderapi.expansion.cloud;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import at.helpch.placeholderapi.util.TimeUtil;
|
||||
|
||||
|
||||
public class CloudExpansion {
|
||||
|
||||
@@ -37,8 +37,7 @@ public class CloudExpansion {
|
||||
dependency_url;
|
||||
|
||||
private boolean hasExpansion,
|
||||
shouldUpdate,
|
||||
verified;
|
||||
shouldUpdate;
|
||||
|
||||
private long last_update,
|
||||
ratings_count;
|
||||
@@ -136,10 +135,6 @@ public class CloudExpansion {
|
||||
this.shouldUpdate = shouldUpdate;
|
||||
}
|
||||
|
||||
public boolean isVerified() {
|
||||
return verified;
|
||||
}
|
||||
|
||||
public long getLastUpdate() {
|
||||
return last_update;
|
||||
}
|
||||
@@ -172,8 +167,10 @@ public class CloudExpansion {
|
||||
this.versions = versions;
|
||||
}
|
||||
|
||||
public class Version {
|
||||
public static class Version {
|
||||
|
||||
private String url, version, release_notes;
|
||||
private boolean verified;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
@@ -198,5 +195,13 @@ public class CloudExpansion {
|
||||
public void setReleaseNotes(String release_notes) {
|
||||
this.release_notes = release_notes;
|
||||
}
|
||||
|
||||
public boolean isVerified() {
|
||||
return verified;
|
||||
}
|
||||
|
||||
public void setVerified(boolean verified) {
|
||||
this.verified = verified;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.expansion.manager;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import at.helpch.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import com.hypixel.hytale.logger.HytaleLogger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class CloudExpansionManager {
|
||||
|
||||
@NotNull
|
||||
private static final String API_URL = "https://ecloud.placeholderapi.com/api/v3/?platform=hytale";
|
||||
|
||||
@NotNull
|
||||
private static final Gson GSON = new Gson();
|
||||
@NotNull
|
||||
private static final Type TYPE = new TypeToken<Map<String, CloudExpansion>>() {}.getType();
|
||||
|
||||
@NotNull
|
||||
private final Collector<CloudExpansion, ?, Map<String, CloudExpansion>> INDEXED_NAME_COLLECTOR = Collectors
|
||||
.toMap(CloudExpansionManager::toIndexName, Function.identity());
|
||||
|
||||
|
||||
@NotNull
|
||||
private final PlaceholderAPIPlugin plugin;
|
||||
private final HytaleLogger logger;
|
||||
|
||||
@NotNull
|
||||
private final Map<String, CloudExpansion> cache = new HashMap<>();
|
||||
@NotNull
|
||||
private final Map<String, CompletableFuture<File>> await = new ConcurrentHashMap<>();
|
||||
|
||||
private final ExecutorService ASYNC_EXECUTOR =
|
||||
Executors.newCachedThreadPool(new LoggingThreadFactory("placeholderapi-io-#%1$d"));
|
||||
|
||||
public CloudExpansionManager(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.logger = plugin.getLogger();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String toIndexName(@NotNull final String name) {
|
||||
return name.toLowerCase(Locale.ROOT).replace(' ', '_');
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String toIndexName(@NotNull final CloudExpansion expansion) {
|
||||
return toIndexName(expansion.getName());
|
||||
}
|
||||
|
||||
public void load() {
|
||||
clean();
|
||||
fetch();
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
clean();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public Map<String, CloudExpansion> getCloudExpansions() {
|
||||
return Map.copyOf(cache);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return cache.isEmpty();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public Map<String, CloudExpansion> getCloudExpansionsInstalled() {
|
||||
if (cache.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
return cache.values()
|
||||
.stream()
|
||||
.filter(CloudExpansion::hasExpansion)
|
||||
.collect(INDEXED_NAME_COLLECTOR);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public Map<String, CloudExpansion> getCloudExpansionsByAuthor(@NotNull final String author) {
|
||||
if (cache.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
return cache.values()
|
||||
.stream()
|
||||
.filter(expansion -> author.equalsIgnoreCase(expansion.getAuthor()))
|
||||
.collect(INDEXED_NAME_COLLECTOR);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public Set<String> getCloudExpansionAuthors() {
|
||||
return cache.values().stream().map(CloudExpansion::getAuthor).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public int getCloudExpansionAuthorCount() {
|
||||
return getCloudExpansionAuthors().size();
|
||||
}
|
||||
|
||||
public int getCloudUpdateCount() {
|
||||
return ((int) plugin.localExpansionManager()
|
||||
.getExpansions()
|
||||
.stream()
|
||||
.filter(expansion -> findCloudExpansionByName(expansion.getName())
|
||||
.map(CloudExpansion::shouldUpdate).orElse(false))
|
||||
.count());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Optional<CloudExpansion> findCloudExpansionByName(@NotNull final String name) {
|
||||
return Optional.ofNullable(cache.get(toIndexName(name)));
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
cache.clear();
|
||||
|
||||
await.values().forEach(future -> future.cancel(true));
|
||||
await.clear();
|
||||
}
|
||||
|
||||
public void fetch() {
|
||||
logger.at(Level.INFO).log("Fetching available expansion information...");
|
||||
|
||||
ASYNC_EXECUTOR.submit(
|
||||
() -> {
|
||||
// a defence tactic! use ConcurrentHashMap instead of normal HashMap
|
||||
Map<String, CloudExpansion> values = new ConcurrentHashMap<>();
|
||||
try {
|
||||
final URI uri = new URI(API_URL);
|
||||
final URLConnection connection = uri.toURL().openConnection();
|
||||
final String json;
|
||||
|
||||
try (final InputStream input = connection.getInputStream()) {
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
|
||||
json = reader.lines().collect(Collectors.joining(System.lineSeparator()));
|
||||
}
|
||||
|
||||
//noinspection UnstableApiUsage
|
||||
// String json = Resources.toString(new URL(API_URL), StandardCharsets.UTF_8);
|
||||
values.putAll(GSON.fromJson(json, TYPE));
|
||||
|
||||
List<String> toRemove = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, CloudExpansion> entry : values.entrySet()) {
|
||||
CloudExpansion expansion = entry.getValue();
|
||||
if (expansion.getLatestVersion() == null
|
||||
|| expansion.getVersion(expansion.getLatestVersion()) == null) {
|
||||
toRemove.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
for (String name : toRemove) {
|
||||
values.remove(name);
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
logger.atWarning().log("There is no data available from the eCloud. Please try running /papi refresh. If this does not resolve the issue, the eCloud may be blocked by your firewall, server host, or service provider.\n\nMore information: https://placeholderapi.com/ecloud-blocked", e);
|
||||
} catch (Throwable e) {
|
||||
// ugly swallowing of every throwable, but we have to be defensive
|
||||
logger.atWarning().log("Failed to download expansion information", e);
|
||||
}
|
||||
|
||||
// loop through what's left on the main thread
|
||||
plugin
|
||||
.getTaskRegistry()
|
||||
.registerTask(CompletableFuture.runAsync(
|
||||
() -> {
|
||||
try {
|
||||
for (Map.Entry<String, CloudExpansion> entry : values.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
CloudExpansion expansion = entry.getValue();
|
||||
|
||||
expansion.setName(name);
|
||||
|
||||
Optional<PlaceholderExpansion> localOpt =
|
||||
plugin.localExpansionManager().findExpansionByName(name);
|
||||
if (localOpt.isPresent()) {
|
||||
PlaceholderExpansion local = localOpt.get();
|
||||
if (local.isRegistered()) {
|
||||
expansion.setHasExpansion(true);
|
||||
expansion.setShouldUpdate(
|
||||
!local.getVersion().equalsIgnoreCase(expansion.getLatestVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
cache.put(toIndexName(expansion), expansion);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// ugly swallowing of every throwable, but we have to be defensive
|
||||
logger.atWarning().log("Failed to download expansion information", e);
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isDownloading(@NotNull final CloudExpansion expansion) {
|
||||
return await.containsKey(toIndexName(expansion));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CompletableFuture<File> downloadExpansion(@NotNull final CloudExpansion expansion,
|
||||
@NotNull final CloudExpansion.Version version) {
|
||||
final CompletableFuture<File> previous = await.get(toIndexName(expansion));
|
||||
if (previous != null) {
|
||||
return previous;
|
||||
}
|
||||
|
||||
final File file = new File(plugin.localExpansionManager().getExpansionsFolder(),
|
||||
"Expansion-" + toIndexName(expansion) + ".jar");
|
||||
|
||||
final CompletableFuture<File> download = CompletableFuture.supplyAsync(() -> {
|
||||
try (final ReadableByteChannel source = Channels.newChannel(new URL(version.getUrl())
|
||||
.openStream()); final FileOutputStream target = new FileOutputStream(file)) {
|
||||
target.getChannel().transferFrom(source, 0, Long.MAX_VALUE);
|
||||
} catch (final IOException ex) {
|
||||
throw new CompletionException(ex);
|
||||
}
|
||||
return file;
|
||||
}, ASYNC_EXECUTOR);
|
||||
|
||||
download.whenCompleteAsync((value, exception) -> {
|
||||
await.remove(toIndexName(expansion));
|
||||
|
||||
if (exception != null) {
|
||||
logger.atSevere().log("Failed to download %s:%s %s", expansion.getName(), expansion.getVersion(), exception);
|
||||
}
|
||||
}, ASYNC_EXECUTOR);
|
||||
|
||||
await.put(toIndexName(expansion), download);
|
||||
|
||||
return download;
|
||||
}
|
||||
|
||||
private static final class LoggingThreadFactory implements ThreadFactory {
|
||||
private final ThreadFactory backing = Executors.defaultThreadFactory();
|
||||
private final String format;
|
||||
private final AtomicLong count = new AtomicLong(0);
|
||||
|
||||
private LoggingThreadFactory(@NotNull final String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread newThread(@NotNull final Runnable r) {
|
||||
final Thread thread = backing.newThread(r);
|
||||
thread.setName(String.format(format, count.getAndIncrement()));
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.expansion.manager;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import at.helpch.placeholderapi.configuration.ConfigManager;
|
||||
import at.helpch.placeholderapi.configuration.PlaceholderAPIConfig;
|
||||
import at.helpch.placeholderapi.events.ExpansionRegisterEvent;
|
||||
import at.helpch.placeholderapi.events.ExpansionUnregisterEvent;
|
||||
import at.helpch.placeholderapi.events.ExpansionsLoadedEvent;
|
||||
import at.helpch.placeholderapi.expansion.Cacheable;
|
||||
import at.helpch.placeholderapi.expansion.Cleanable;
|
||||
import at.helpch.placeholderapi.expansion.Configurable;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import at.helpch.placeholderapi.expansion.Taskable;
|
||||
import at.helpch.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import at.helpch.placeholderapi.util.FileUtil;
|
||||
import at.helpch.placeholderapi.util.Futures;
|
||||
import com.hypixel.hytale.common.plugin.PluginIdentifier;
|
||||
import com.hypixel.hytale.event.IEventDispatcher;
|
||||
import com.hypixel.hytale.logger.HytaleLogger;
|
||||
import com.hypixel.hytale.server.core.HytaleServer;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import com.hypixel.hytale.server.core.event.events.player.PlayerDisconnectEvent;
|
||||
import com.hypixel.hytale.server.core.plugin.PluginBase;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
public final class LocalExpansionManager /*implements Listener*/ {
|
||||
|
||||
@NotNull
|
||||
private static final String EXPANSIONS_FOLDER_NAME = "expansions";
|
||||
|
||||
@NotNull
|
||||
private static final Set<MethodSignature> ABSTRACT_EXPANSION_METHODS = Arrays.stream(PlaceholderExpansion.class.getDeclaredMethods())
|
||||
.filter(method -> Modifier.isAbstract(method.getModifiers()))
|
||||
.map(method -> new MethodSignature(method.getName(), method.getParameterTypes()))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
@NotNull
|
||||
private final File folder;
|
||||
@NotNull
|
||||
private final PlaceholderAPIPlugin plugin;
|
||||
private final HytaleLogger logger;
|
||||
private final ConfigManager configManager;
|
||||
|
||||
@NotNull
|
||||
private final Map<String, PlaceholderExpansion> expansions = new ConcurrentHashMap<>();
|
||||
private final ReentrantLock expansionsLock = new ReentrantLock();
|
||||
|
||||
|
||||
public LocalExpansionManager(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.folder = new File(plugin.getDataDirectory().toString(), EXPANSIONS_FOLDER_NAME);
|
||||
this.logger = plugin.getLogger();
|
||||
this.configManager = plugin.configManager();
|
||||
|
||||
if (!this.folder.exists() && !folder.mkdirs()) {
|
||||
logger.atWarning().log("Failed to create expansions folder!");
|
||||
}
|
||||
}
|
||||
|
||||
public void load(@NotNull final CommandSender sender) {
|
||||
registerAll(sender);
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
unregisterAll();
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public File getExpansionsFolder() {
|
||||
return folder;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public Collection<String> getIdentifiers() {
|
||||
expansionsLock.lock();
|
||||
try {
|
||||
return Set.copyOf(expansions.keySet());
|
||||
} finally {
|
||||
expansionsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public Collection<PlaceholderExpansion> getExpansions() {
|
||||
expansionsLock.lock();
|
||||
try {
|
||||
return Set.copyOf(expansions.values());
|
||||
} finally {
|
||||
expansionsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PlaceholderExpansion getExpansion(@NotNull final String identifier) {
|
||||
expansionsLock.lock();
|
||||
try {
|
||||
return expansions.get(identifier.toLowerCase(Locale.ROOT));
|
||||
} finally {
|
||||
expansionsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Optional<PlaceholderExpansion> findExpansionByName(@NotNull final String name) {
|
||||
expansionsLock.lock();
|
||||
try {
|
||||
PlaceholderExpansion bestMatch = null;
|
||||
for (Map.Entry<String, PlaceholderExpansion> entry : expansions.entrySet()) {
|
||||
PlaceholderExpansion expansion = entry.getValue();
|
||||
if (expansion.getName().equalsIgnoreCase(name)) {
|
||||
bestMatch = expansion;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Optional.ofNullable(bestMatch);
|
||||
} finally {
|
||||
expansionsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Optional<PlaceholderExpansion> findExpansionByIdentifier(
|
||||
@NotNull final String identifier) {
|
||||
return Optional.ofNullable(getExpansion(identifier));
|
||||
}
|
||||
|
||||
|
||||
public Optional<PlaceholderExpansion> register(
|
||||
@NotNull final Class<? extends PlaceholderExpansion> clazz) {
|
||||
try {
|
||||
final PlaceholderExpansion expansion = createExpansionInstance(clazz);
|
||||
|
||||
if (expansion == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
Objects.requireNonNull(expansion.getAuthor(), "The expansion author is null!");
|
||||
Objects.requireNonNull(expansion.getIdentifier(), "The expansion identifier is null!");
|
||||
Objects.requireNonNull(expansion.getVersion(), "The expansion version is null!");
|
||||
|
||||
if (expansion.getRequiredPlugin() != null && !expansion.getRequiredPlugin().isEmpty()) {
|
||||
if (HytaleServer.get().getPluginManager().getPlugin(PluginIdentifier.fromString(expansion.getRequiredPlugin())) == null) {
|
||||
logger.atWarning().log("Cannot load expansion %s due to a missing plugin: %s", expansion.getIdentifier(),
|
||||
expansion.getRequiredPlugin());
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
expansion.setExpansionType(PlaceholderExpansion.Type.EXTERNAL);
|
||||
|
||||
if (!expansion.register()) {
|
||||
logger.atWarning().log("Cannot load expansion %s due to an unknown issue.", expansion.getIdentifier());
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return Optional.of(expansion);
|
||||
} catch (LinkageError | NullPointerException ex) {
|
||||
final String reason;
|
||||
|
||||
if (ex instanceof LinkageError) {
|
||||
reason = " (Is a dependency missing?)";
|
||||
} else {
|
||||
reason = " - One of its properties is null which is not allowed!";
|
||||
}
|
||||
|
||||
logger.atSevere().log("Failed to load expansion class %s%s", ex, clazz.getSimpleName(), reason);
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to register a {@link PlaceholderExpansion}
|
||||
*
|
||||
* @param expansion the expansion to register
|
||||
* @return if the expansion was registered
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public boolean register(@NotNull final PlaceholderExpansion expansion) {
|
||||
final String identifier = expansion.getIdentifier().toLowerCase(Locale.ROOT);
|
||||
|
||||
if (expansion instanceof Configurable<?> configurable) {
|
||||
final PlaceholderAPIConfig config = configManager.config();
|
||||
|
||||
if (config.expansions() == null) {
|
||||
config.expansions(new HashMap<>());
|
||||
}
|
||||
|
||||
if (!config.expansions().containsKey(expansion.getIdentifier())) {
|
||||
config.expansions().put(expansion.getIdentifier(), configurable.provideDefault());
|
||||
configManager.save();
|
||||
} else {
|
||||
final Object expansionConfig = configManager.convertExpansion((Map<String, Object>) config.expansions().get(expansion.getIdentifier()), configurable.provideConfigType());
|
||||
config.expansions().put(expansion.getIdentifier(), expansionConfig);
|
||||
}
|
||||
}
|
||||
|
||||
if (!expansion.canRegister()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Avoid loading two external expansions with the same identifier
|
||||
if (expansion.getExpansionType() == PlaceholderExpansion.Type.EXTERNAL && expansions.containsKey(identifier)) {
|
||||
logger.atWarning().log("Failed to load external expansion %s. Identifier is already in use.", expansion.getIdentifier());
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (expansion instanceof VersionSpecific) {
|
||||
// VersionSpecific nms = (VersionSpecific) expansion;
|
||||
// if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion())) {
|
||||
// Msg.warn("Your server version is incompatible with expansion %s %s",
|
||||
// expansion.getIdentifier(), expansion.getVersion());
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
final PlaceholderExpansion removed = getExpansion(identifier);
|
||||
if (removed != null && !removed.unregister()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ExpansionRegisterEvent event = new ExpansionRegisterEvent(expansion);
|
||||
final IEventDispatcher<ExpansionRegisterEvent, ExpansionRegisterEvent> eventDispatcher = HytaleServer.get().getEventBus().dispatchFor(ExpansionRegisterEvent.class);
|
||||
if (eventDispatcher.hasListener()) {
|
||||
eventDispatcher.dispatch(event);
|
||||
}
|
||||
|
||||
// Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
expansionsLock.lock();
|
||||
try {
|
||||
expansions.put(identifier, expansion);
|
||||
} finally {
|
||||
expansionsLock.unlock();
|
||||
}
|
||||
|
||||
// if (expansion instanceof Listener) {
|
||||
// Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);
|
||||
// }
|
||||
|
||||
logger.at(Level.INFO).log(
|
||||
"Successfully registered %s expansion: %s [%s]",
|
||||
expansion.getExpansionType().name().toLowerCase(),
|
||||
expansion.getIdentifier(),
|
||||
expansion.getVersion()
|
||||
);
|
||||
|
||||
if (expansion instanceof Taskable) {
|
||||
((Taskable) expansion).start();
|
||||
}
|
||||
|
||||
// Check eCloud for updates only if the expansion is external
|
||||
if (configManager.config().cloudEnabled() && expansion.getExpansionType() == PlaceholderExpansion.Type.EXTERNAL) {
|
||||
final Optional<CloudExpansion> cloudExpansionOptional = plugin.cloudExpansionManager().findCloudExpansionByName(identifier);
|
||||
if (cloudExpansionOptional.isPresent()) {
|
||||
CloudExpansion cloudExpansion = cloudExpansionOptional.get();
|
||||
cloudExpansion.setHasExpansion(true);
|
||||
cloudExpansion.setShouldUpdate(!cloudExpansion.getLatestVersion().equals(expansion.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public boolean unregister(@NotNull final PlaceholderExpansion expansion) {
|
||||
if (expansions.remove(expansion.getIdentifier().toLowerCase(Locale.ROOT)) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IEventDispatcher<ExpansionUnregisterEvent, ExpansionUnregisterEvent> eventDispatcher = HytaleServer.get().getEventBus().dispatchFor(ExpansionUnregisterEvent.class);
|
||||
if (eventDispatcher.hasListener()) {
|
||||
eventDispatcher.dispatch(new ExpansionUnregisterEvent(expansion));
|
||||
}
|
||||
|
||||
// if (expansion instanceof Listener) {
|
||||
// HandlerList.unregisterAll((Listener) expansion);
|
||||
// }
|
||||
|
||||
if (expansion instanceof Taskable) {
|
||||
((Taskable) expansion).stop();
|
||||
}
|
||||
|
||||
if (expansion instanceof Cacheable) {
|
||||
((Cacheable) expansion).clear();
|
||||
}
|
||||
|
||||
if (configManager.config().cloudEnabled()) {
|
||||
plugin.cloudExpansionManager().findCloudExpansionByName(expansion.getName())
|
||||
.ifPresent(cloud -> {
|
||||
cloud.setHasExpansion(false);
|
||||
cloud.setShouldUpdate(false);
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void registerAll(@NotNull final CommandSender sender) {
|
||||
logger.at(Level.INFO).log("Placeholder expansion registration initializing...");
|
||||
|
||||
Futures.onMainThread(plugin, findExpansionsOnDisk(), (classes, exception) -> {
|
||||
if (exception != null) {
|
||||
logger.atSevere().log("Failed to load class files of expansion.", exception);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<PlaceholderExpansion> registered = classes.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(this::register)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final long needsUpdate = registered.stream()
|
||||
.map(expansion -> plugin.cloudExpansionManager().findCloudExpansionByName(expansion.getName()).orElse(null))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(CloudExpansion::shouldUpdate)
|
||||
.count();
|
||||
Message message = Message.raw(registered.size() + "").color(registered.isEmpty() ? Color.YELLOW : Color.GREEN)
|
||||
.insert(" placeholder hook(s) registered!");
|
||||
|
||||
if (needsUpdate > 0) {
|
||||
message = message.insert(" ")
|
||||
.insert(Message.raw(needsUpdate + " placeholder hook(s) have an update available.").color(Color.YELLOW));
|
||||
}
|
||||
|
||||
// logger.at(Level.INFO).log(message.toString());
|
||||
sender.sendMessage(message);
|
||||
|
||||
final IEventDispatcher<ExpansionsLoadedEvent, ExpansionsLoadedEvent> eventDispatcher = HytaleServer.get().getEventBus().dispatchFor(ExpansionsLoadedEvent.class);
|
||||
if (eventDispatcher.hasListener()) {
|
||||
eventDispatcher.dispatch(new ExpansionsLoadedEvent(registered));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void unregisterAll() {
|
||||
for (final PlaceholderExpansion expansion : new HashSet<>(expansions.values())) {
|
||||
if (expansion.persist()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
expansion.unregister();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CompletableFuture<@NotNull List<@Nullable Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk() {
|
||||
File[] files = folder.listFiles((dir, name) -> name.endsWith(".jar"));
|
||||
if (files == null) {
|
||||
return CompletableFuture.completedFuture(Collections.emptyList());
|
||||
}
|
||||
|
||||
return Arrays.stream(files)
|
||||
.map(this::findExpansionInFile)
|
||||
.collect(Futures.collector());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CompletableFuture<@Nullable Class<? extends PlaceholderExpansion>> findExpansionInFile(
|
||||
@NotNull final File file) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
final Class<? extends PlaceholderExpansion> expansionClass = FileUtil.findClass(file, PlaceholderExpansion.class);
|
||||
|
||||
if (expansionClass == null) {
|
||||
logger.atSevere().log("Failed to load expansion %s, as it does not have a class which"
|
||||
+ " extends PlaceholderExpansion", file.getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<MethodSignature> expansionMethods = Arrays.stream(expansionClass.getDeclaredMethods())
|
||||
.map(method -> new MethodSignature(method.getName(), method.getParameterTypes()))
|
||||
.collect(Collectors.toSet());
|
||||
if (!expansionMethods.containsAll(ABSTRACT_EXPANSION_METHODS)) {
|
||||
logger.atSevere().log("Failed to load expansion %s, as it does not have the required"
|
||||
+ " methods declared for a PlaceholderExpansion.", file.getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
return expansionClass;
|
||||
} catch (VerifyError | NoClassDefFoundError e) {
|
||||
logger.atSevere().log("Failed to load expansion %s (is a dependency missing?)", e, file.getName());
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
logger.atSevere().log("Failed to load expansion file: " + file.getAbsolutePath(), e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public PlaceholderExpansion createExpansionInstance(
|
||||
@NotNull final Class<? extends PlaceholderExpansion> clazz) throws LinkageError {
|
||||
try {
|
||||
return clazz.getDeclaredConstructor().newInstance();
|
||||
} catch (final Exception ex) {
|
||||
if (ex.getCause() instanceof LinkageError) {
|
||||
throw ((LinkageError) ex.getCause());
|
||||
}
|
||||
|
||||
logger.atWarning().log("There was an issue with loading an expansion.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void onQuit(@NotNull final PlayerDisconnectEvent event) {
|
||||
for (final PlaceholderExpansion expansion : getExpansions()) {
|
||||
if (!(expansion instanceof Cleanable)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
((Cleanable) expansion).cleanup(event.getPlayerRef());
|
||||
}
|
||||
}
|
||||
|
||||
// @EventHandler(priority = EventPriority.HIGH)
|
||||
//todo: hytale has no plugin disable event as of yet :(
|
||||
// public void onPluginDisable() {
|
||||
// final String name = event.getPlugin().getName();
|
||||
// if (name.equals(plugin.getName())) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// for (final PlaceholderExpansion expansion : getExpansions()) {
|
||||
// if (!name.equalsIgnoreCase(expansion.getRequiredPlugin())) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// expansion.unregister();
|
||||
// Msg.info("Unregistered placeholder expansion %s", expansion.getIdentifier());
|
||||
// Msg.info("Reason: required plugin %s was disabled.", name);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.expansion.manager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class MethodSignature {
|
||||
private final String name;
|
||||
private final Class<?>[] params;
|
||||
|
||||
protected MethodSignature(String name, Class<?>[] params) {
|
||||
this.name = name;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Class<?>[] getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MethodSignature that = (MethodSignature) o;
|
||||
return Objects.equals(name, that.name) && Arrays.equals(params, that.params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Objects.hash(name);
|
||||
result = 31 * result + Arrays.hashCode(params);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.replacer;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class CharsReplacer implements Replacer {
|
||||
|
||||
@NotNull
|
||||
private final Closure closure;
|
||||
|
||||
public CharsReplacer(@NotNull final Closure closure) {
|
||||
this.closure = closure;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String apply(@NotNull final String text, @Nullable final PlayerRef player,
|
||||
@NotNull final Function<String, @Nullable PlaceholderExpansion> lookup) {
|
||||
final char[] chars = text.toCharArray();
|
||||
final StringBuilder builder = new StringBuilder(text.length());
|
||||
|
||||
final StringBuilder identifier = new StringBuilder();
|
||||
final StringBuilder parameters = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
final char l = chars[i];
|
||||
|
||||
if (l != closure.head || i + 1 >= chars.length) {
|
||||
builder.append(l);
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean identified = false;
|
||||
boolean invalid = true;
|
||||
boolean hadSpace = false;
|
||||
|
||||
while (++i < chars.length) {
|
||||
final char p = chars[i];
|
||||
|
||||
if (p == ' ' && !identified) {
|
||||
hadSpace = true;
|
||||
break;
|
||||
}
|
||||
if (p == closure.tail) {
|
||||
invalid = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (p == '_' && !identified) {
|
||||
identified = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identified) {
|
||||
parameters.append(p);
|
||||
} else {
|
||||
identifier.append(p);
|
||||
}
|
||||
}
|
||||
|
||||
final String identifierString = identifier.toString();
|
||||
final String lowercaseIdentifierString = identifierString.toLowerCase(Locale.ROOT);
|
||||
final String parametersString = parameters.toString();
|
||||
|
||||
identifier.setLength(0);
|
||||
parameters.setLength(0);
|
||||
|
||||
if (invalid) {
|
||||
builder.append(closure.head).append(identifierString);
|
||||
|
||||
if (identified) {
|
||||
builder.append('_').append(parametersString);
|
||||
}
|
||||
|
||||
if (hadSpace) {
|
||||
builder.append(' ');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
final PlaceholderExpansion placeholder = lookup.apply(lowercaseIdentifierString);
|
||||
if (placeholder == null) {
|
||||
builder.append(closure.head).append(identifierString);
|
||||
|
||||
if (identified) {
|
||||
builder.append('_');
|
||||
}
|
||||
|
||||
builder.append(parametersString).append(closure.tail);
|
||||
continue;
|
||||
}
|
||||
|
||||
final String replacement = placeholder.onPlaceholderRequest(player, parametersString);
|
||||
if (replacement == null) {
|
||||
builder.append(closure.head).append(identifierString);
|
||||
|
||||
if (identified) {
|
||||
builder.append('_');
|
||||
}
|
||||
|
||||
builder.append(parametersString).append(closure.tail);
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.append(replacement);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package at.helpch.placeholderapi.replacer;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPI;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class MessageReplacer {
|
||||
@NotNull
|
||||
public static Message replace(@NotNull final Message original, @NotNull final Function<String, String> setPlaceholders) {
|
||||
if (original.getFormattedMessage().rawText == null) {
|
||||
return original;
|
||||
}
|
||||
|
||||
String replaced = setPlaceholders.apply(original.getFormattedMessage().rawText);
|
||||
String link = original.getFormattedMessage().link == null ? null : setPlaceholders.apply(original.getFormattedMessage().link);
|
||||
|
||||
List<Message> newChildren = original.getChildren().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(child -> replace(child, setPlaceholders))
|
||||
.toList();
|
||||
|
||||
Message message = Message.raw(replaced);
|
||||
|
||||
if (original.getColor() != null) {
|
||||
message = message.color(original.getColor());
|
||||
}
|
||||
|
||||
if (link != null) {
|
||||
message = message.link(link);
|
||||
}
|
||||
|
||||
int bold = original.getFormattedMessage().bold.getValue();
|
||||
if (bold != 0) {
|
||||
message = message.bold(bold != 1);
|
||||
}
|
||||
|
||||
int italic = original.getFormattedMessage().italic.getValue();
|
||||
if (italic != 0) {
|
||||
message = message.italic(italic != 1);
|
||||
}
|
||||
|
||||
return message.insertAll(newChildren);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,35 +18,34 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.replacer;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
package at.helpch.placeholderapi.replacer;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface Replacer
|
||||
{
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@NotNull
|
||||
String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup);
|
||||
public interface Replacer {
|
||||
|
||||
@NotNull
|
||||
String apply(@NotNull final String text, @Nullable final PlayerRef player,
|
||||
@NotNull final Function<String, @Nullable PlaceholderExpansion> lookup);
|
||||
|
||||
|
||||
enum Closure
|
||||
{
|
||||
BRACKET('{', '}'),
|
||||
PERCENT('%', '%');
|
||||
enum Closure {
|
||||
BRACKET('{', '}'),
|
||||
PERCENT('%', '%');
|
||||
|
||||
|
||||
public final char head, tail;
|
||||
public final char head, tail;
|
||||
|
||||
Closure(final char head, final char tail)
|
||||
{
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
}
|
||||
}
|
||||
Closure(final char head, final char tail) {
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
77
src/main/java/at/helpch/placeholderapi/util/FileUtil.java
Normal file
77
src/main/java/at/helpch/placeholderapi/util/FileUtil.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
|
||||
public class FileUtil {
|
||||
|
||||
@Nullable
|
||||
public static <T> Class<? extends T> findClass(@NotNull final File file,
|
||||
@NotNull final Class<T> clazz) throws IOException, ClassNotFoundException {
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final URL jar = file.toURI().toURL();
|
||||
final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader());
|
||||
final List<String> matches = new ArrayList<>();
|
||||
final List<Class<? extends T>> classes = new ArrayList<>();
|
||||
|
||||
try (final JarInputStream stream = new JarInputStream(jar.openStream())) {
|
||||
JarEntry entry;
|
||||
while ((entry = stream.getNextJarEntry()) != null) {
|
||||
final String name = entry.getName();
|
||||
if (name.isEmpty() || !name.endsWith(".class")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
matches.add(name.substring(0, name.lastIndexOf('.')).replace('/', '.'));
|
||||
}
|
||||
|
||||
for (final String match : matches) {
|
||||
try {
|
||||
final Class<?> loaded = loader.loadClass(match);
|
||||
if (clazz.isAssignableFrom(loaded)) {
|
||||
classes.add(loaded.asSubclass(clazz));
|
||||
}
|
||||
} catch (final NoClassDefFoundError ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (classes.isEmpty()) {
|
||||
loader.close();
|
||||
return null;
|
||||
}
|
||||
return classes.get(0);
|
||||
}
|
||||
|
||||
}
|
||||
71
src/main/java/at/helpch/placeholderapi/util/Format.java
Normal file
71
src/main/java/at/helpch/placeholderapi/util/Format.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.util;
|
||||
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
import static java.util.Arrays.stream;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static java.util.stream.IntStream.range;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* For the record, I am not sorry.
|
||||
*/
|
||||
public final class Format {
|
||||
|
||||
private Format() {}
|
||||
|
||||
@NotNull
|
||||
public static Optional<List<String>> tablify(@NotNull final Align align,
|
||||
@NotNull final List<List<String>> rows) {
|
||||
return findSpacing(rows)
|
||||
.map(spacing -> buildFormat(align, spacing))
|
||||
.map(format -> rows.stream()
|
||||
.map(
|
||||
row -> String.format(format, row.toArray()).substring(align == Align.RIGHT ? 2 : 0))
|
||||
.collect(toList()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String buildFormat(@NotNull final Align align, final int[] spacing) {
|
||||
return stream(spacing)
|
||||
.mapToObj(space -> "%" + (align == Align.LEFT ? "-" : "") + (space + 2) + "s")
|
||||
.collect(joining());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Optional<int[]> findSpacing(@NotNull final List<List<String>> rows) {
|
||||
return rows.stream()
|
||||
.map(row -> row.stream().mapToInt(String::length).toArray())
|
||||
.reduce((l, r) -> range(0, min(l.length, r.length)).map(i -> max(l[i], r[i])).toArray());
|
||||
}
|
||||
|
||||
public enum Align {
|
||||
LEFT, RIGHT
|
||||
}
|
||||
|
||||
}
|
||||
75
src/main/java/at/helpch/placeholderapi/util/Futures.java
Normal file
75
src/main/java/at/helpch/placeholderapi/util/Futures.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import com.hypixel.hytale.server.core.HytaleServer;
|
||||
import com.hypixel.hytale.server.core.universe.Universe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class Futures {
|
||||
|
||||
private Futures() {}
|
||||
|
||||
|
||||
public static <T> void onMainThread(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CompletableFuture<T> future,
|
||||
@NotNull final BiConsumer<T, Throwable> consumer) {
|
||||
future.whenComplete((value, exception) -> {
|
||||
HytaleServer.SCHEDULED_EXECUTOR.execute(() -> consumer.accept(value, exception));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static <T> Collector<CompletableFuture<T>, ?, CompletableFuture<List<T>>> collector() {
|
||||
return Collectors.collectingAndThen(Collectors.toList(), Futures::of);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static <T> CompletableFuture<List<T>> of(
|
||||
@NotNull final Stream<CompletableFuture<T>> futures) {
|
||||
return of(futures.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> CompletableFuture<List<T>> of(
|
||||
@NotNull final Collection<CompletableFuture<T>> futures) {
|
||||
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
||||
.thenApplyAsync($ -> awaitCompletion(futures));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static <T> List<T> awaitCompletion(
|
||||
@NotNull final Collection<CompletableFuture<T>> futures) {
|
||||
return futures.stream().map(CompletableFuture::join).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.util;
|
||||
package at.helpch.placeholderapi.util;
|
||||
|
||||
public enum TimeFormat {
|
||||
DAYS,
|
||||
96
src/main/java/at/helpch/placeholderapi/util/TimeUtil.java
Normal file
96
src/main/java/at/helpch/placeholderapi/util/TimeUtil.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.helpch.placeholderapi.util;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class TimeUtil {
|
||||
|
||||
public static String getRemaining(final int seconds, final TimeFormat type) {
|
||||
return getRemaining((long) seconds, type);
|
||||
}
|
||||
|
||||
public static String getRemaining(final long seconds, final TimeFormat type) {
|
||||
switch (type) {
|
||||
default:
|
||||
return String.valueOf(seconds);
|
||||
|
||||
case SECONDS:
|
||||
return String.valueOf(seconds % 60);
|
||||
|
||||
case MINUTES:
|
||||
return String.valueOf((seconds / 60) % 60);
|
||||
|
||||
case HOURS:
|
||||
return String.valueOf((seconds / 3600) % 24);
|
||||
|
||||
case DAYS:
|
||||
return String.valueOf(seconds / 86400);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given value with s, m, h and d (seconds, minutes, hours and days)
|
||||
*
|
||||
* @param duration {@link Duration} (eg, Duration.of(20, {@link ChronoUnit#SECONDS}) for 20
|
||||
* seconds)
|
||||
* @return formatted time
|
||||
*/
|
||||
public static String getTime(final Duration duration) {
|
||||
return getTime(duration.getSeconds());
|
||||
}
|
||||
|
||||
public static String getTime(final int seconds) {
|
||||
return getTime((long) seconds);
|
||||
}
|
||||
|
||||
public static String getTime(long seconds) {
|
||||
final StringJoiner joiner = new StringJoiner(" ");
|
||||
|
||||
long minutes = seconds / 60;
|
||||
long hours = minutes / 60;
|
||||
final long days = hours / 24;
|
||||
|
||||
seconds %= 60;
|
||||
minutes %= 60;
|
||||
hours %= 24;
|
||||
|
||||
if (days > 0) {
|
||||
joiner.add(days + "d");
|
||||
}
|
||||
|
||||
if (hours > 0) {
|
||||
joiner.add(hours + "h");
|
||||
}
|
||||
|
||||
if (minutes > 0) {
|
||||
joiner.add(minutes + "m");
|
||||
}
|
||||
|
||||
if (seconds > 0) {
|
||||
joiner.add(seconds + "s");
|
||||
}
|
||||
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,601 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.expansion.Relational;
|
||||
import me.clip.placeholderapi.replacer.CharsReplacer;
|
||||
import me.clip.placeholderapi.replacer.Replacer;
|
||||
import me.clip.placeholderapi.replacer.Replacer.Closure;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class PlaceholderAPI
|
||||
{
|
||||
|
||||
private static final Replacer REPLACER_PERCENT = new CharsReplacer(Closure.PERCENT);
|
||||
private static final Replacer REPLACER_BRACKET = new CharsReplacer(Closure.BRACKET);
|
||||
|
||||
|
||||
@Deprecated
|
||||
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
|
||||
@Deprecated
|
||||
private static final Pattern BRACKET_PLACEHOLDER_PATTERN = Pattern.compile("[{]([^{}]+)[}]");
|
||||
@Deprecated
|
||||
private static final Pattern RELATIONAL_PLACEHOLDER_PATTERN = Pattern.compile("[%](rel_)([^%]+)[%]");
|
||||
|
||||
|
||||
private PlaceholderAPI()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// === Current API ===
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text Text to set the placeholder values in
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static String setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text)
|
||||
{
|
||||
return REPLACER_PERCENT.apply(text, player, PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()::getExpansion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text List of Strings to set the placeholder values in
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static List<String> setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<@NotNull String> text)
|
||||
{
|
||||
return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text Text to set the placeholder values in
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static String setBracketPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text)
|
||||
{
|
||||
return REPLACER_BRACKET.apply(text, player, PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()::getExpansion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text List of Strings to set the placeholder values in
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static List<String> setBracketPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<@NotNull String> text)
|
||||
{
|
||||
return text.stream().map(line -> setBracketPlaceholders(player, line)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a specific placeholder identifier is currently registered
|
||||
*
|
||||
* @param identifier The identifier to check
|
||||
* @return true if identifier is already registered
|
||||
*/
|
||||
public static boolean isRegistered(@NotNull final String identifier)
|
||||
{
|
||||
return PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByIdentifier(identifier).isPresent();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all registered placeholder identifiers
|
||||
*
|
||||
* @return All registered placeholder identifiers
|
||||
*/
|
||||
@NotNull
|
||||
public static Set<String> getRegisteredIdentifiers()
|
||||
{
|
||||
return ImmutableSet.copyOf(PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().getIdentifiers());
|
||||
}
|
||||
|
||||
|
||||
// === Deprecated API ===
|
||||
|
||||
/**
|
||||
* Get map of registered placeholders
|
||||
*
|
||||
* @return Copy of the internal placeholder map
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static Map<String, PlaceholderHook> getPlaceholders()
|
||||
{
|
||||
throw new UnsupportedOperationException("PlaceholderAPI no longer provides a view of the placeholder's map!\n" +
|
||||
"Use: PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByIdentifier(String)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>You set the pattern yourself through this method.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text Text to set the placeholder values in
|
||||
* @param pattern The pattern to match placeholders to. Capture group 1 must contain an underscore separating the
|
||||
* identifier from the params
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return The text containing the parsed placeholders
|
||||
* @deprecated Please use {@link #setPlaceholders(OfflinePlayer, String)} instead
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text, @NotNull final Pattern pattern, final boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>You set the pattern yourself through this method.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text List of Strings to set the placeholder values in
|
||||
* @param pattern The pattern to match placeholders to. Capture group 1 must contain an underscore separating the
|
||||
* identifier from the params
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return String containing all translated placeholders
|
||||
* @deprecated Please use {@link #setPlaceholders(OfflinePlayer, List)} instead
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static List<String> setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<String> text, @NotNull final Pattern pattern, final boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static Set<PlaceholderExpansion> getExpansions()
|
||||
{
|
||||
Set<PlaceholderExpansion> set = getPlaceholders().values().stream()
|
||||
.filter(PlaceholderExpansion.class::isInstance).map(PlaceholderExpansion.class::cast)
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
|
||||
return ImmutableSet.copyOf(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a String contains any PlaceholderAPI placeholders ({@literal %<identifier>_<params>%}).
|
||||
*
|
||||
* @param text String to check
|
||||
* @return true if String contains any registered placeholder identifiers, false otherwise
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean containsPlaceholders(String text)
|
||||
{
|
||||
return text != null && PLACEHOLDER_PATTERN.matcher(text).find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a String contains any PlaceholderAPI bracket placeholders ({@literal {<identifier>_<params>}}).
|
||||
*
|
||||
* @param text String to check
|
||||
* @return true if String contains any registered placeholder identifiers, false otherwise
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean containsBracketPlaceholders(String text)
|
||||
{
|
||||
return text != null && BRACKET_PLACEHOLDER_PATTERN.matcher(text).find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text List of Strings to set the placeholder values in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return String containing all translated placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> setBracketPlaceholders(OfflinePlayer player, List<String> text, boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text List of Strings to set the placeholder values in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return String containing all translated placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text, boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>You set the pattern yourself through this method.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text List of Strings to set the placeholder values in
|
||||
* @param pattern The pattern to match placeholders to. Capture group 1 must contain an underscore separating the
|
||||
* identifier from the params
|
||||
* @return String containing all translated placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text, Pattern pattern)
|
||||
{
|
||||
return setPlaceholders(player, text, pattern, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text Text to set the placeholder values in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return String containing all translated placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setBracketPlaceholders(OfflinePlayer player, String text, boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||
*
|
||||
* @param player Player to parse the placeholder against
|
||||
* @param text Text to parse the placeholders in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return The text containing the parsed placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setPlaceholders(OfflinePlayer player, String text, boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>You set the pattern yourself through this method.
|
||||
*
|
||||
* @param player Player to parse the placeholders against
|
||||
* @param text Text to set the placeholder values in
|
||||
* @param pattern The pattern to match placeholders to. Capture group 1 must contain an underscore separating the
|
||||
* identifier from the params
|
||||
* @return The text containing the parsed placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setPlaceholders(OfflinePlayer player, String text, Pattern pattern)
|
||||
{
|
||||
return setPlaceholders(player, text, pattern, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate placeholders in the provided List based on the relation of the two provided players.
|
||||
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<param>%}.
|
||||
*
|
||||
* @param one Player to compare
|
||||
* @param two Player to compare
|
||||
* @param text text to parse the placeholder values to
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text)
|
||||
{
|
||||
return setRelationalPlaceholders(one, two, text, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate placeholders in the provided list based on the relation of the two provided players.
|
||||
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<params>%}.
|
||||
*
|
||||
* @param one First player to compare
|
||||
* @param two Second player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text, boolean colorize)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return text.stream()
|
||||
.map(line -> setRelationalPlaceholders(one, two, line, colorize))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* set relational placeholders in the text specified placeholders are matched with the pattern
|
||||
* %<rel_(identifier)_(params)>% when set with this method
|
||||
*
|
||||
* @param one First player to compare
|
||||
* @param two Second player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setRelationalPlaceholders(Player one, Player two, String text)
|
||||
{
|
||||
return setRelationalPlaceholders(one, two, text, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* set relational placeholders in the text specified placeholders are matched with the pattern
|
||||
* %<rel_(identifier)_(params)>% when set with this method
|
||||
*
|
||||
* @param one Player to compare
|
||||
* @param two Player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setRelationalPlaceholders(Player one, Player two, String text, boolean colorize)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().getExpansionsCount() == 0)
|
||||
{
|
||||
return colorize ? Msg.color(text) : text;
|
||||
}
|
||||
|
||||
final Matcher matcher = RELATIONAL_PLACEHOLDER_PATTERN.matcher(text);
|
||||
final Map<String, PlaceholderHook> hooks = getPlaceholders();
|
||||
|
||||
while (matcher.find())
|
||||
{
|
||||
final String format = matcher.group(2);
|
||||
final int index = format.indexOf("_");
|
||||
|
||||
if (index <= 0 || index >= format.length())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String identifier = format.substring(0, index).toLowerCase();
|
||||
String params = format.substring(index + 1);
|
||||
final PlaceholderHook hook = hooks.get(identifier);
|
||||
|
||||
if (!(hook instanceof Relational))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String value = ((Relational) hook).onPlaceholderRequest(one, two, params);
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
text = text.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement(value));
|
||||
}
|
||||
}
|
||||
|
||||
return colorize ? Msg.color(text) : text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the placeholder pattern for the default placeholders.
|
||||
*
|
||||
* @return The pattern for {@literal %<identifier>_<params>%}
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static Pattern getPlaceholderPattern()
|
||||
{
|
||||
return PLACEHOLDER_PATTERN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the placeholder pattern for the bracket placeholders.
|
||||
*
|
||||
* @return The pattern for {@literal {<identifier>_<params>}}
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static Pattern getBracketPlaceholderPattern()
|
||||
{
|
||||
return BRACKET_PLACEHOLDER_PATTERN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the placeholder pattern for the relational placeholders.
|
||||
*
|
||||
* @return The pattern for {@literal %rel_<identifier>_<params>%}
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static Pattern getRelationalPlaceholderPattern()
|
||||
{
|
||||
return RELATIONAL_PLACEHOLDER_PATTERN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static Set<String> getRegisteredPlaceholderPlugins()
|
||||
{
|
||||
return getRegisteredIdentifiers();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static Set<String> getExternalPlaceholderPlugins()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setPlaceholders(Player player, String text)
|
||||
{
|
||||
return setPlaceholders(((OfflinePlayer) player), text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setPlaceholders(Player player, String text, boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static List<String> setPlaceholders(Player player, List<String> text)
|
||||
{
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static List<String> setPlaceholders(Player player, List<String> text, boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setBracketPlaceholders(Player player, String text)
|
||||
{
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static String setBracketPlaceholders(Player player, String text, boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static List<String> setBracketPlaceholders(Player player, List<String> text)
|
||||
{
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public static List<String> setBracketPlaceholders(Player player, List<String> text, boolean colorize)
|
||||
{
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi;
|
||||
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommandRouter;
|
||||
import me.clip.placeholderapi.configuration.PlaceholderAPIConfig;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.expansion.Version;
|
||||
import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
|
||||
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
|
||||
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
|
||||
import me.clip.placeholderapi.updatechecker.UpdateChecker;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Yes I have a shit load of work to do...
|
||||
*
|
||||
* @author Ryan McCarthy
|
||||
*/
|
||||
public final class PlaceholderAPIPlugin extends JavaPlugin
|
||||
{
|
||||
|
||||
@NotNull
|
||||
private static final Version VERSION;
|
||||
|
||||
static
|
||||
{
|
||||
final String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
|
||||
boolean isSpigot;
|
||||
try
|
||||
{
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
isSpigot = true;
|
||||
}
|
||||
catch (final ExceptionInInitializerError | ClassNotFoundException ignored)
|
||||
{
|
||||
isSpigot = false;
|
||||
}
|
||||
|
||||
VERSION = new Version(version, isSpigot);
|
||||
}
|
||||
|
||||
private static PlaceholderAPIPlugin instance;
|
||||
|
||||
@NotNull
|
||||
private final PlaceholderAPIConfig config = new PlaceholderAPIConfig(this);
|
||||
|
||||
@NotNull
|
||||
private final LocalExpansionManager localExpansionManager = new LocalExpansionManager(this);
|
||||
@NotNull
|
||||
private final CloudExpansionManager cloudExpansionManager = new CloudExpansionManager(this);
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
instance = this;
|
||||
|
||||
saveDefaultConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
setupCommand();
|
||||
setupMetrics();
|
||||
setupExpansions();
|
||||
|
||||
if (config.isCloudEnabled())
|
||||
{
|
||||
getCloudExpansionManager().load();
|
||||
}
|
||||
|
||||
if (config.checkUpdates())
|
||||
{
|
||||
new UpdateChecker(this).fetch();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
getCloudExpansionManager().kill();
|
||||
getLocalExpansionManager().kill();
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
|
||||
instance = null;
|
||||
}
|
||||
|
||||
|
||||
public void reloadConf(@NotNull final CommandSender sender)
|
||||
{
|
||||
getLocalExpansionManager().kill();
|
||||
|
||||
reloadConfig();
|
||||
|
||||
getLocalExpansionManager().load(sender);
|
||||
|
||||
if (config.isCloudEnabled())
|
||||
{
|
||||
getCloudExpansionManager().load();
|
||||
}
|
||||
else
|
||||
{
|
||||
getCloudExpansionManager().kill();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public LocalExpansionManager getLocalExpansionManager()
|
||||
{
|
||||
return localExpansionManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CloudExpansionManager getCloudExpansionManager()
|
||||
{
|
||||
return cloudExpansionManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the configuration class for PlaceholderAPI.
|
||||
*
|
||||
* @return PlaceholderAPIConfig instance
|
||||
*/
|
||||
@NotNull
|
||||
public PlaceholderAPIConfig getPlaceholderAPIConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
private void setupCommand()
|
||||
{
|
||||
final PluginCommand pluginCommand = getCommand("placeholderapi");
|
||||
if (pluginCommand == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final PlaceholderCommandRouter router = new PlaceholderCommandRouter(this);
|
||||
pluginCommand.setExecutor(router);
|
||||
pluginCommand.setTabCompleter(router);
|
||||
}
|
||||
|
||||
private void setupMetrics()
|
||||
{
|
||||
final Metrics metrics = new Metrics(this);
|
||||
metrics.addCustomChart(new Metrics.SimplePie("using_expansion_cloud", () -> getPlaceholderAPIConfig().isCloudEnabled() ? "yes" : "no"));
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("using_spigot", () -> getServerVersion().isSpigot() ? "yes" : "no"));
|
||||
|
||||
metrics.addCustomChart(new Metrics.AdvancedPie("expansions_used", () -> {
|
||||
final Map<String, Integer> values = new HashMap<>();
|
||||
|
||||
for (final PlaceholderExpansion expansion : getLocalExpansionManager().getExpansions())
|
||||
{
|
||||
values.put(expansion.getRequiredPlugin() == null ? expansion.getIdentifier() : expansion.getRequiredPlugin(), 1);
|
||||
}
|
||||
|
||||
return values;
|
||||
}));
|
||||
}
|
||||
|
||||
private void setupExpansions()
|
||||
{
|
||||
Bukkit.getPluginManager().registerEvents(getLocalExpansionManager(), this);
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName("org.bukkit.event.server.ServerLoadEvent");
|
||||
new ServerLoadEventListener(this);
|
||||
}
|
||||
catch (final ExceptionInInitializerError | ClassNotFoundException ignored)
|
||||
{
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> getLocalExpansionManager().load(Bukkit.getConsoleSender()), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the static instance of the main class for PlaceholderAPI. This class is not the actual API
|
||||
* class, this is the main class that extends JavaPlugin. For most API methods, use static methods
|
||||
* available from the class: {@link PlaceholderAPI}
|
||||
*
|
||||
* @return PlaceholderAPIPlugin instance
|
||||
*/
|
||||
@NotNull
|
||||
public static PlaceholderAPIPlugin getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the configurable {@linkplain String} value that should be returned when a boolean is true
|
||||
*
|
||||
* @return string value of true
|
||||
*/
|
||||
@NotNull
|
||||
public static String booleanTrue()
|
||||
{
|
||||
return getInstance().getPlaceholderAPIConfig().booleanTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configurable {@linkplain String} value that should be returned when a boolean is false
|
||||
*
|
||||
* @return string value of false
|
||||
*/
|
||||
@NotNull
|
||||
public static String booleanFalse()
|
||||
{
|
||||
return getInstance().getPlaceholderAPIConfig().booleanFalse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configurable {@linkplain SimpleDateFormat} object that is used to parse time for
|
||||
* generic time based placeholders
|
||||
*
|
||||
* @return date format
|
||||
*/
|
||||
@NotNull
|
||||
public static SimpleDateFormat getDateFormat()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new SimpleDateFormat(getInstance().getPlaceholderAPIConfig().dateFormat());
|
||||
}
|
||||
catch (final IllegalArgumentException ex)
|
||||
{
|
||||
getInstance().getLogger().log(Level.WARNING, "configured date format is invalid", ex);
|
||||
return new SimpleDateFormat("MM/dd/yy HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Version getServerVersion()
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @deprecated This class will be completely removed in the next release, please use {@link me.clip.placeholderapi.expansion.PlaceholderExpansion}
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.NonExtendable
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public abstract class PlaceholderHook
|
||||
{
|
||||
|
||||
/**
|
||||
* called when a placeholder value is requested from this hook
|
||||
*
|
||||
* @param player {@link OfflinePlayer} to request the placeholder value for, null if not needed for a
|
||||
* player
|
||||
* @param params String passed to the hook to determine what value to return
|
||||
* @return value for the requested player and params
|
||||
* @deprecated This method will be completely removed, please use {@link me.clip.placeholderapi.expansion.PlaceholderExpansion#onRequest(OfflinePlayer, String)}
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public String onRequest(@Nullable final OfflinePlayer player, @NotNull final String params)
|
||||
{
|
||||
if (player != null && player.isOnline())
|
||||
{
|
||||
return onPlaceholderRequest((Player) player, params);
|
||||
}
|
||||
|
||||
return onPlaceholderRequest(null, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* called when a placeholder is requested from this hook
|
||||
*
|
||||
* @param player {@link Player} to request the placeholder value for, null if not needed for a player
|
||||
* @param params String passed to the hook to determine what value to return
|
||||
* @return value for the requested player and params
|
||||
*
|
||||
* @deprecated This method will be completely removed, please use {@link me.clip.placeholderapi.expansion.PlaceholderExpansion#onRequest(OfflinePlayer, String)}
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
||||
public String onPlaceholderRequest(@Nullable final Player player, @NotNull final String params)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class PlaceholderCommand
|
||||
{
|
||||
|
||||
@NotNull
|
||||
private final String label;
|
||||
@NotNull
|
||||
private final Set<String> alias;
|
||||
|
||||
@Nullable
|
||||
private String permission;
|
||||
|
||||
|
||||
protected PlaceholderCommand(@NotNull final String label, @NotNull final String... alias)
|
||||
{
|
||||
this.label = label;
|
||||
this.alias = Sets.newHashSet(alias);
|
||||
|
||||
setPermission("placeholderapi." + label);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public final String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public final Set<String> getAlias()
|
||||
{
|
||||
return ImmutableSet.copyOf(alias);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
public final Set<String> getLabels()
|
||||
{
|
||||
return ImmutableSet.<String>builder().add(label).addAll(alias).build();
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public final String getPermission()
|
||||
{
|
||||
return permission;
|
||||
}
|
||||
|
||||
public void setPermission(@NotNull final String permission)
|
||||
{
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static Stream<PlaceholderCommand> filterByPermission(@NotNull final CommandSender sender, @NotNull final Stream<PlaceholderCommand> commands)
|
||||
{
|
||||
return commands.filter(target -> target.getPermission() == null || sender.hasPermission(target.getPermission()));
|
||||
}
|
||||
|
||||
public static void suggestByParameter(@NotNull final Stream<String> possible, @NotNull final List<String> suggestions, @Nullable final String parameter)
|
||||
{
|
||||
if (parameter == null)
|
||||
{
|
||||
possible.forEach(suggestions::add);
|
||||
}
|
||||
else
|
||||
{
|
||||
possible.filter(suggestion -> suggestion.toLowerCase().startsWith(parameter.toLowerCase())).forEach(suggestions::add);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.impl.cloud.CommandECloud;
|
||||
import me.clip.placeholderapi.commands.impl.local.CommandDump;
|
||||
import me.clip.placeholderapi.commands.impl.local.CommandExpansionRegister;
|
||||
import me.clip.placeholderapi.commands.impl.local.CommandExpansionUnregister;
|
||||
import me.clip.placeholderapi.commands.impl.local.CommandHelp;
|
||||
import me.clip.placeholderapi.commands.impl.local.CommandInfo;
|
||||
import me.clip.placeholderapi.commands.impl.local.CommandList;
|
||||
import me.clip.placeholderapi.commands.impl.local.CommandParse;
|
||||
import me.clip.placeholderapi.commands.impl.local.CommandReload;
|
||||
import me.clip.placeholderapi.commands.impl.local.CommandVersion;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class PlaceholderCommandRouter implements CommandExecutor, TabCompleter
|
||||
{
|
||||
|
||||
@Unmodifiable
|
||||
private static final List<PlaceholderCommand> COMMANDS = ImmutableList.of(new CommandHelp(),
|
||||
new CommandInfo(),
|
||||
new CommandList(),
|
||||
new CommandDump(),
|
||||
new CommandECloud(),
|
||||
new CommandParse(),
|
||||
new CommandReload(),
|
||||
new CommandVersion(),
|
||||
new CommandExpansionRegister(),
|
||||
new CommandExpansionUnregister());
|
||||
|
||||
|
||||
@NotNull
|
||||
private final PlaceholderAPIPlugin plugin;
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
private final Map<String, PlaceholderCommand> commands;
|
||||
|
||||
|
||||
public PlaceholderCommandRouter(@NotNull final PlaceholderAPIPlugin plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
|
||||
final ImmutableMap.Builder<String, PlaceholderCommand> commands = ImmutableMap.builder();
|
||||
|
||||
for (final PlaceholderCommand command : COMMANDS)
|
||||
{
|
||||
command.getLabels().forEach(label -> commands.put(label, command));
|
||||
}
|
||||
|
||||
this.commands = commands.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull final CommandSender sender, @NotNull final Command command, @NotNull final String alias, @NotNull final String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
final PlaceholderCommand fallback = commands.get("version");
|
||||
if (fallback != null)
|
||||
{
|
||||
fallback.evaluate(plugin, sender, "", Collections.emptyList());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
final String search = args[0].toLowerCase();
|
||||
final PlaceholderCommand target = commands.get(search);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
Msg.msg(sender, "&cUnknown command &7" + search);
|
||||
return true;
|
||||
}
|
||||
|
||||
final String permission = target.getPermission();
|
||||
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission))
|
||||
{
|
||||
Msg.msg(sender, "&cYou do not have permission to do this!");
|
||||
return true;
|
||||
}
|
||||
|
||||
target.evaluate(plugin, sender, search, Arrays.asList(Arrays.copyOfRange(args, 1, args.length)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull final CommandSender sender, @NotNull final Command command, @NotNull final String alias, @NotNull final String[] args)
|
||||
{
|
||||
final List<String> suggestions = new ArrayList<>();
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
final PlaceholderCommand target = this.commands.get(args[0].toLowerCase());
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
target.complete(plugin, sender, args[0].toLowerCase(), Arrays.asList(Arrays.copyOfRange(args, 1, args.length)), suggestions);
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
final Stream<String> targets = PlaceholderCommand.filterByPermission(sender, commands.values().stream()).map(PlaceholderCommand::getLabels).flatMap(Collection::stream);
|
||||
PlaceholderCommand.suggestByParameter(targets, suggestions, args.length == 0 ? null : args[0]);
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class CommandECloud extends PlaceholderCommand
|
||||
{
|
||||
|
||||
@Unmodifiable
|
||||
private static final List<PlaceholderCommand> COMMANDS = ImmutableList.of(new CommandECloudClear(),
|
||||
new CommandECloudToggle(),
|
||||
new CommandECloudStatus(),
|
||||
new CommandECloudUpdate(),
|
||||
new CommandECloudRefresh(),
|
||||
new CommandECloudDownload(),
|
||||
new CommandECloudExpansionInfo(),
|
||||
new CommandECloudExpansionList(),
|
||||
new CommandECloudExpansionPlaceholders());
|
||||
|
||||
static
|
||||
{
|
||||
COMMANDS.forEach(command -> command.setPermission("placeholderapi.ecloud." + command.getLabel()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Unmodifiable
|
||||
private final Map<String, PlaceholderCommand> commands;
|
||||
|
||||
|
||||
public CommandECloud()
|
||||
{
|
||||
super("ecloud");
|
||||
|
||||
final ImmutableMap.Builder<String, PlaceholderCommand> commands = ImmutableMap.builder();
|
||||
|
||||
for (final PlaceholderCommand command : COMMANDS)
|
||||
{
|
||||
command.getLabels().forEach(label -> commands.put(label, command));
|
||||
}
|
||||
|
||||
this.commands = commands.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&b&lPlaceholderAPI &8- &7eCloud Help Menu &8- ",
|
||||
" ",
|
||||
"&b/papi &fecloud status",
|
||||
" &7&oView status of the eCloud",
|
||||
"&b/papi &fecloud list <all/{author}/installed> {page}",
|
||||
" &7&oList all/author specific available expansions",
|
||||
"&b/papi &fecloud info <expansion name> {version}",
|
||||
" &7&oView information about a specific expansion available on the eCloud",
|
||||
"&b/papi &fecloud placeholders <expansion name>",
|
||||
" &7&oView placeholders for an expansion",
|
||||
"&b/papi &fecloud download <expansion name> {version}",
|
||||
" &7&oDownload an expansion from the eCloud",
|
||||
"&b/papi &fecloud refresh",
|
||||
" &7&oFetch the most up to date list of expansions available.",
|
||||
"&b/papi &fecloud clear",
|
||||
" &7&oClear the expansion cloud cache.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final String search = params.get(0).toLowerCase();
|
||||
final PlaceholderCommand target = commands.get(search);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
Msg.msg(sender, "&cUnknown command &7ecloud " + search);
|
||||
return;
|
||||
}
|
||||
|
||||
final String permission = target.getPermission();
|
||||
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission))
|
||||
{
|
||||
Msg.msg(sender, "&cYou do not have permission to do this!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(target instanceof CommandECloudToggle) && !plugin.getPlaceholderAPIConfig().isCloudEnabled())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cThe eCloud Manager is not enabled!");
|
||||
return;
|
||||
}
|
||||
|
||||
target.evaluate(plugin, sender, search, params.subList(1, params.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() <= 1)
|
||||
{
|
||||
final Stream<String> targets = filterByPermission(sender, commands.values().stream()).map(PlaceholderCommand::getLabels).flatMap(Collection::stream);
|
||||
suggestByParameter(targets, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
|
||||
return; // send sub commands
|
||||
}
|
||||
|
||||
final String search = params.get(0).toLowerCase();
|
||||
final PlaceholderCommand target = commands.get(search);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
target.complete(plugin, sender, search, params.subList(1, params.size()), suggestions);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class CommandECloudClear extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandECloudClear()
|
||||
{
|
||||
super("clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
plugin.getCloudExpansionManager().clean();
|
||||
Msg.msg(sender,
|
||||
"&aThe eCloud cache has been cleared!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class CommandECloudDownload extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandECloudDownload()
|
||||
{
|
||||
super("download");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cYou must supply the name of an eCloud expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).orElse(null);
|
||||
if (expansion == null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cCould not find expansion named: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion.Version version;
|
||||
if (params.size() < 2)
|
||||
{
|
||||
version = expansion.getVersion(expansion.getLatestVersion());
|
||||
if (version == null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cCould not find latest version for expansion.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
version = expansion.getVersion(params.get(1));
|
||||
if (version == null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cCould not find specified version: &f" + params.get(1),
|
||||
"&7Versions: &a" + expansion.getAvailableVersions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getCloudExpansionManager().downloadExpansion(expansion, version).whenComplete((file, exception) -> {
|
||||
if (exception != null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cFailed to download expansion: &e" + exception.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Msg.msg(sender,
|
||||
"&aSuccessfully downloaded expansion to file: &e" + file.getName());
|
||||
|
||||
plugin.getCloudExpansionManager().clean();
|
||||
plugin.getCloudExpansionManager().fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() > 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.size() <= 1)
|
||||
{
|
||||
final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values().stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
|
||||
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0));
|
||||
if (!expansion.isPresent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
suggestByParameter(expansion.get().getAvailableVersions().stream(), suggestions, params.get(1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class CommandECloudExpansionInfo extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandECloudExpansionInfo()
|
||||
{
|
||||
super("info");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cYou must specify the name of the expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).orElse(null);
|
||||
if (expansion == null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cThere is no expansion with the name: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("&bExpansion: &f")
|
||||
.append(expansion.shouldUpdate() ? "&e" : "&a")
|
||||
.append(expansion.getName())
|
||||
.append('\n')
|
||||
.append("&bAuthor: &f")
|
||||
.append(expansion.getAuthor())
|
||||
.append('\n')
|
||||
.append("&bVerified: ")
|
||||
.append(expansion.isVerified() ? "&a&l✔" : "&c&l❌")
|
||||
.append('\n');
|
||||
|
||||
if (params.size() < 2)
|
||||
{
|
||||
builder.append("&bLatest Version: &f")
|
||||
.append(expansion.getLatestVersion())
|
||||
.append('\n')
|
||||
.append("&bReleased: &f")
|
||||
.append(expansion.getTimeSinceLastUpdate())
|
||||
.append(" ago")
|
||||
.append('\n')
|
||||
.append("&bRelease Notes: &f")
|
||||
.append(expansion.getVersion().getReleaseNotes())
|
||||
.append('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
final CloudExpansion.Version version = expansion.getVersion(params.get(1));
|
||||
if (version == null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cCould not find specified version: &f" + params.get(1),
|
||||
"&7Versions: &a" + expansion.getAvailableVersions());
|
||||
return;
|
||||
}
|
||||
|
||||
builder.append("&bVersion: &f")
|
||||
.append(version.getVersion())
|
||||
.append('\n')
|
||||
.append("&bRelease Notes: &f")
|
||||
.append(version.getReleaseNotes())
|
||||
.append('\n')
|
||||
.append("&bDownload URL: &f")
|
||||
.append(version.getUrl())
|
||||
.append('\n');
|
||||
}
|
||||
|
||||
Msg.msg(sender, builder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() > 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.size() <= 1)
|
||||
{
|
||||
final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values().stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
|
||||
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0));
|
||||
if (!expansion.isPresent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
suggestByParameter(expansion.get().getAvailableVersions().stream(), suggestions, params.get(1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,360 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.primitives.Ints;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.configuration.ExpansionSort;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import me.clip.placeholderapi.util.Format;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import me.rayzr522.jsonmessage.JSONMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public final class CommandECloudExpansionList extends PlaceholderCommand
|
||||
{
|
||||
|
||||
private static final int PAGE_SIZE = 10;
|
||||
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_NAME =
|
||||
expansion -> (expansion.shouldUpdate() ? "&6" : expansion.hasExpansion() ? "&a" : "&7") + expansion.getName();
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_AUTHOR =
|
||||
expansion -> "&f" + expansion.getAuthor();
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_VERIFIED =
|
||||
expansion -> expansion.isVerified() ? "&aY" : "&cN";
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_LATEST_VERSION =
|
||||
expansion -> "&f" + expansion.getLatestVersion();
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_CURRENT_VERSION =
|
||||
expansion -> "&f" + PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByName(expansion.getName()).map(PlaceholderExpansion::getVersion).orElse("Unknown");
|
||||
|
||||
|
||||
@Unmodifiable
|
||||
private static final Set<String> OPTIONS = ImmutableSet.of("all", "installed");
|
||||
|
||||
|
||||
public CommandECloudExpansionList()
|
||||
{
|
||||
super("list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cYou must specify an option. [all, {author}, installed]");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final boolean installed = params.get(0).equalsIgnoreCase("installed");
|
||||
final List<CloudExpansion> expansions = Lists.newArrayList(getExpansions(params.get(0), plugin));
|
||||
|
||||
if (expansions.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cNo expansions available to list.");
|
||||
return;
|
||||
}
|
||||
|
||||
expansions.sort(plugin.getPlaceholderAPIConfig().getExpansionSort().orElse(ExpansionSort.LATEST));
|
||||
|
||||
if (!(sender instanceof Player) && params.size() < 2)
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
addExpansionTitle(builder, params.get(0), -1);
|
||||
addExpansionTable(expansions,
|
||||
builder,
|
||||
1,
|
||||
installed ? "&9Version" : "&9Latest Version",
|
||||
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION);
|
||||
|
||||
Msg.msg(sender, builder.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
final int page;
|
||||
|
||||
if (params.size() < 2)
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//noinspection UnstableApiUsage
|
||||
final Integer parsed = Ints.tryParse(params.get(1));
|
||||
if (parsed == null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cPage number must be an integer.");
|
||||
return;
|
||||
}
|
||||
|
||||
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
||||
|
||||
if (parsed < 1 || parsed > limit)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cPage number must be in the range &8[&a1&7..&a" + limit + "&8]");
|
||||
return;
|
||||
}
|
||||
|
||||
page = parsed;
|
||||
}
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final List<CloudExpansion> values = getPage(expansions, page - 1);
|
||||
|
||||
addExpansionTitle(builder, params.get(0), page);
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
addExpansionTable(values,
|
||||
builder,
|
||||
((page - 1) * PAGE_SIZE) + 1,
|
||||
installed ? "&9Version" : "&9Latest Version",
|
||||
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION);
|
||||
|
||||
Msg.msg(sender, builder.toString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Msg.msg(sender, builder.toString());
|
||||
|
||||
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
||||
|
||||
final JSONMessage message = getMessage(values, page, limit, params.get(0));
|
||||
message.send(((Player) sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() > 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.size() <= 1)
|
||||
{
|
||||
suggestByParameter(Sets.union(OPTIONS, plugin.getCloudExpansionManager().getCloudExpansionAuthors()).stream(), suggestions, params.isEmpty() ? null : params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
suggestByParameter(IntStream.rangeClosed(1, (int) Math.ceil((double) getExpansions(params.get(0), plugin).size() / PAGE_SIZE)).mapToObj(Objects::toString), suggestions, params.get(1));
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private static Collection<CloudExpansion> getExpansions(@NotNull final String target, @NotNull final PlaceholderAPIPlugin plugin)
|
||||
{
|
||||
switch (target.toLowerCase())
|
||||
{
|
||||
case "all":
|
||||
return plugin.getCloudExpansionManager().getCloudExpansions().values();
|
||||
case "installed":
|
||||
return plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values();
|
||||
default:
|
||||
return plugin.getCloudExpansionManager().getCloudExpansionsByAuthor(target).values();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<CloudExpansion> getPage(@NotNull final List<CloudExpansion> expansions, final int page)
|
||||
{
|
||||
final int head = (page * PAGE_SIZE);
|
||||
final int tail = Math.min(expansions.size(), head + PAGE_SIZE);
|
||||
|
||||
if (expansions.size() < head)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return expansions.subList(head, tail);
|
||||
}
|
||||
|
||||
public static void addExpansionTitle(@NotNull final StringBuilder builder, @NotNull final String target, final int page)
|
||||
{
|
||||
switch (target.toLowerCase())
|
||||
{
|
||||
case "all":
|
||||
builder.append("&bAll Expansions");
|
||||
break;
|
||||
case "installed":
|
||||
builder.append("&bInstalled Expansions");
|
||||
break;
|
||||
default:
|
||||
builder.append("&bExpansions by &6")
|
||||
.append(target);
|
||||
break;
|
||||
}
|
||||
|
||||
if (page == -1)
|
||||
{
|
||||
builder.append('\n');
|
||||
return;
|
||||
}
|
||||
|
||||
builder.append(" &bPage&7: &a")
|
||||
.append(page)
|
||||
.append("&r")
|
||||
.append('\n');
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private static JSONMessage getMessage(@NotNull final List<CloudExpansion> expansions, final int page, final int limit, @NotNull final String target)
|
||||
{
|
||||
final SimpleDateFormat format = PlaceholderAPIPlugin.getDateFormat();
|
||||
|
||||
final StringBuilder tooltip = new StringBuilder();
|
||||
final JSONMessage message = JSONMessage.create();
|
||||
|
||||
for (int index = 0; index < expansions.size(); index++)
|
||||
{
|
||||
final CloudExpansion expansion = expansions.get(index);
|
||||
|
||||
tooltip.append("&bClick to download this expansion!")
|
||||
.append('\n')
|
||||
.append('\n')
|
||||
.append("&bAuthor: &f")
|
||||
.append(expansion.getAuthor())
|
||||
.append('\n')
|
||||
.append("&bVerified: ")
|
||||
.append(expansion.isVerified() ? "&a&l✔&r" : "&c&l❌&r")
|
||||
.append('\n')
|
||||
.append("&bLatest Version: &f")
|
||||
.append(expansion.getLatestVersion())
|
||||
.append('\n')
|
||||
.append("&bReleased: &f")
|
||||
.append(format.format(expansion.getLastUpdate()));
|
||||
|
||||
final String description = expansion.getDescription();
|
||||
if (description != null && !description.isEmpty())
|
||||
{
|
||||
tooltip.append('\n')
|
||||
.append('\n')
|
||||
.append("&f")
|
||||
.append(description.replace("\r", "").trim());
|
||||
}
|
||||
|
||||
message.then(Msg.color("&8" + (index + ((page - 1) * PAGE_SIZE) + 1) + ".&r " + (expansion.shouldUpdate() ? "&6" : expansion.hasExpansion() ? "&a" : "&7") + expansion.getName()));
|
||||
|
||||
message.tooltip(Msg.color(tooltip.toString()));
|
||||
message.suggestCommand("/papi ecloud download " + expansion.getName());
|
||||
|
||||
if (index < expansions.size() - 1)
|
||||
{
|
||||
message.newline();
|
||||
}
|
||||
|
||||
tooltip.setLength(0);
|
||||
}
|
||||
|
||||
if (limit > 1)
|
||||
{
|
||||
message.newline();
|
||||
|
||||
message.then("◀")
|
||||
.color(page > 1 ? ChatColor.GRAY : ChatColor.DARK_GRAY);
|
||||
if (page > 1)
|
||||
{
|
||||
message.runCommand("/papi ecloud list " + target + " " + (page - 1));
|
||||
}
|
||||
|
||||
message.then(" " + page + " ").color(ChatColor.GREEN);
|
||||
|
||||
message.then("▶")
|
||||
.color(page < limit ? ChatColor.GRAY : ChatColor.DARK_GRAY);
|
||||
if (page < limit)
|
||||
{
|
||||
message.runCommand("/papi ecloud list " + target + " " + (page + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private static void addExpansionTable(@NotNull final List<CloudExpansion> expansions, @NotNull final StringBuilder message, final int startIndex, @NotNull final String versionTitle, @NotNull final Function<CloudExpansion, Object> versionFunction)
|
||||
{
|
||||
final Map<String, Function<CloudExpansion, Object>> functions = new LinkedHashMap<>();
|
||||
|
||||
final AtomicInteger counter = new AtomicInteger(startIndex);
|
||||
functions.put("&f", expansion -> "&8" + counter.getAndIncrement() + ".");
|
||||
|
||||
functions.put("&9Name", EXPANSION_NAME);
|
||||
functions.put("&9Author", EXPANSION_AUTHOR);
|
||||
functions.put("&9Verified", EXPANSION_VERIFIED);
|
||||
functions.put(versionTitle, versionFunction);
|
||||
|
||||
final List<List<String>> rows = new ArrayList<>();
|
||||
|
||||
rows.add(0, new ArrayList<>(functions.keySet()));
|
||||
|
||||
for (final CloudExpansion expansion : expansions)
|
||||
{
|
||||
rows.add(functions.values().stream().map(function -> function.apply(expansion)).map(Objects::toString).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
final List<String> table = Format.tablify(Format.Align.LEFT, rows).orElse(Collections.emptyList());
|
||||
if (table.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
table.add(1, "&8" + Strings.repeat("-", table.get(0).length() - (rows.get(0).size() * 2)));
|
||||
|
||||
message.append(String.join("\n", table));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class CommandECloudExpansionPlaceholders extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandECloudExpansionPlaceholders()
|
||||
{
|
||||
super("placeholders");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cYou must specify the name of the expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).orElse(null);
|
||||
if (expansion == null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cThere is no expansion with the name: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> placeholders = expansion.getPlaceholders();
|
||||
if (placeholders == null || placeholders.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cThat expansion does not have placeholders listed.");
|
||||
return;
|
||||
}
|
||||
|
||||
final List<List<String>> partitions = Lists.partition(placeholders.stream().sorted().collect(Collectors.toList()), 10);
|
||||
|
||||
Msg.msg(sender,
|
||||
"&6" + placeholders.size() + "&7 placeholders: &a",
|
||||
partitions.stream().map(partition -> " " + String.join(", ", partition)).collect(Collectors.joining("\n")));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Stream<String> names = plugin.getCloudExpansionManager()
|
||||
.getCloudExpansions()
|
||||
.values()
|
||||
.stream()
|
||||
.map(CloudExpansion::getName)
|
||||
.map(name -> name.replace(' ', '_'));
|
||||
|
||||
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class CommandECloudRefresh extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandECloudRefresh()
|
||||
{
|
||||
super("refresh");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
plugin.getCloudExpansionManager().clean();
|
||||
plugin.getCloudExpansionManager().fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
||||
|
||||
Msg.msg(sender,
|
||||
"&aThe eCloud Manager has been refreshed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class CommandECloudStatus extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandECloudStatus()
|
||||
{
|
||||
super("status");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
final CloudExpansionManager manager = plugin.getCloudExpansionManager();
|
||||
|
||||
final int updateCount = manager.getCloudUpdateCount();
|
||||
final int authorCount = manager.getCloudExpansionAuthorCount();
|
||||
final int expansionCount = manager.getCloudExpansions().size();
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("&bThere are &a").append(expansionCount).append("&b expansions available on the eCloud.").append('\n');
|
||||
builder.append("&7A total of &f").append(authorCount).append("&7 authors have contributed to the eCloud.").append('\n');
|
||||
|
||||
if (updateCount > 0)
|
||||
{
|
||||
builder.append("&eYou have &a").append(updateCount).append("&e expansions installed that have updates available.");
|
||||
}
|
||||
|
||||
Msg.msg(sender,builder.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class CommandECloudToggle extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandECloudToggle()
|
||||
{
|
||||
super("toggle", "enable", "disable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
final boolean desiredState;
|
||||
final boolean currentState = plugin.getPlaceholderAPIConfig().isCloudEnabled();
|
||||
|
||||
switch (alias.toLowerCase())
|
||||
{
|
||||
case "enable":
|
||||
desiredState = true;
|
||||
break;
|
||||
case "disable":
|
||||
desiredState = false;
|
||||
break;
|
||||
default:
|
||||
desiredState = !currentState;
|
||||
break;
|
||||
}
|
||||
|
||||
if (desiredState == currentState)
|
||||
{
|
||||
Msg.msg(sender, "&7The eCloud Manager is already " + (desiredState ? "enabled" : "disabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getPlaceholderAPIConfig().setCloudEnabled(desiredState);
|
||||
|
||||
if (desiredState)
|
||||
{
|
||||
plugin.getCloudExpansionManager().load();
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.getCloudExpansionManager().kill();
|
||||
}
|
||||
|
||||
Msg.msg(sender, "&aThe eCloud Manager has been " + (desiredState ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||
import me.clip.placeholderapi.util.Futures;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* please don't flame me for this code, I will fix this shit later.
|
||||
*/
|
||||
public final class CommandECloudUpdate extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandECloudUpdate()
|
||||
{
|
||||
super("update");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cYou must define 'all' or the name of an expansion to update.");
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean multiple = params.get(0).equalsIgnoreCase("all");
|
||||
final List<CloudExpansion> expansions = new ArrayList<>();
|
||||
|
||||
// gather target expansions
|
||||
if (multiple)
|
||||
{
|
||||
expansions.addAll(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).ifPresent(expansions::add);
|
||||
}
|
||||
|
||||
// remove the ones that are the latest version
|
||||
expansions.removeIf(expansion -> !expansion.shouldUpdate());
|
||||
|
||||
if (expansions.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cNo updates available for " + (!multiple ? "this expansion." : "your active expansions."));
|
||||
return;
|
||||
}
|
||||
|
||||
Msg.msg(sender,
|
||||
"&aUpdating expansions: " + expansions.stream().map(CloudExpansion::getName).collect(Collectors.joining("&7, &6", "&8[&6", "&8]&r")));
|
||||
|
||||
|
||||
Futures.onMainThread(plugin, downloadAndDiscover(expansions, plugin), (classes, exception) -> {
|
||||
if (exception != null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cFailed to update expansions: &e" + exception.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Msg.msg(sender,
|
||||
"&aSuccessfully downloaded updates, registering new versions.");
|
||||
|
||||
|
||||
final String message = classes.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(plugin.getLocalExpansionManager()::register)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.map(expansion -> " &a" + expansion.getName() + " &f" + expansion.getVersion())
|
||||
.collect(Collectors.joining("\n"));
|
||||
|
||||
Msg.msg(sender,
|
||||
"&7Registered expansions:", message);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final List<CloudExpansion> installed = Lists.newArrayList(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
|
||||
installed.removeIf(expansion -> !expansion.shouldUpdate());
|
||||
|
||||
if (!installed.isEmpty() && (params.isEmpty() || "all".startsWith(params.get(0).toLowerCase())))
|
||||
{
|
||||
suggestions.add("all");
|
||||
}
|
||||
|
||||
suggestByParameter(installed.stream().map(CloudExpansion::getName).map(name -> name.replace(" ", "_")), suggestions, params.isEmpty() ? null : params.get(0));
|
||||
}
|
||||
|
||||
|
||||
private static CompletableFuture<List<@Nullable Class<? extends PlaceholderExpansion>>> downloadAndDiscover(@NotNull final List<CloudExpansion> expansions, @NotNull final PlaceholderAPIPlugin plugin)
|
||||
{
|
||||
return expansions.stream()
|
||||
.map(expansion -> plugin.getCloudExpansionManager().downloadExpansion(expansion, expansion.getVersion()))
|
||||
.map(future -> future.thenCompose(plugin.getLocalExpansionManager()::findExpansionInFile))
|
||||
.collect(Futures.collector());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
package me.clip.placeholderapi.commands.impl.local;
|
||||
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.gson.JsonParser;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class CommandDump extends PlaceholderCommand
|
||||
{
|
||||
|
||||
@NotNull
|
||||
private static final String URL = "https://paste.helpch.at/";
|
||||
|
||||
@NotNull
|
||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG)
|
||||
.withLocale(Locale.US)
|
||||
.withZone(ZoneId.of("UTC"));
|
||||
|
||||
|
||||
public CommandDump()
|
||||
{
|
||||
super("dump");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
postDump(makeDump(plugin)).whenComplete((key, exception) -> {
|
||||
if (exception != null)
|
||||
{
|
||||
plugin.getLogger().log(Level.WARNING, "failed to post dump details", exception);
|
||||
|
||||
Msg.msg(sender,
|
||||
"&cFailed to post dump details, check console.");
|
||||
return;
|
||||
}
|
||||
|
||||
Msg.msg(sender,
|
||||
"&aSuccessfully posted dump: " + URL + key);
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private CompletableFuture<String> postDump(@NotNull final String dump)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try
|
||||
{
|
||||
final HttpURLConnection connection = ((HttpURLConnection) new URL(URL + "documents").openConnection());
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
|
||||
connection.setDoOutput(true);
|
||||
|
||||
connection.connect();
|
||||
|
||||
try (final OutputStream stream = connection.getOutputStream())
|
||||
{
|
||||
stream.write(dump.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
try (final InputStream stream = connection.getInputStream())
|
||||
{
|
||||
//noinspection UnstableApiUsage
|
||||
final String json = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
return JsonParser.parseString(json).getAsJsonObject().get("key").getAsString();
|
||||
}
|
||||
}
|
||||
catch (final IOException ex)
|
||||
{
|
||||
throw new CompletionException(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String makeDump(@NotNull final PlaceholderAPIPlugin plugin)
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("Generated: ")
|
||||
.append(DATE_FORMAT.format(Instant.now()))
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("PlaceholderAPI: ")
|
||||
.append(plugin.getDescription().getVersion())
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Expansions Registered:")
|
||||
.append('\n');
|
||||
|
||||
|
||||
final Map<String, List<PlaceholderExpansion>> expansions = plugin.getLocalExpansionManager()
|
||||
.getExpansions()
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(PlaceholderExpansion::getAuthor));
|
||||
|
||||
for (final Map.Entry<String, List<PlaceholderExpansion>> expansionsByAuthor : expansions.entrySet())
|
||||
{
|
||||
builder.append(" ")
|
||||
.append(expansionsByAuthor.getKey())
|
||||
.append(": ")
|
||||
.append('\n');
|
||||
|
||||
for (final PlaceholderExpansion expansion : expansionsByAuthor.getValue())
|
||||
{
|
||||
builder.append(" ")
|
||||
.append(expansion.getName())
|
||||
.append(':')
|
||||
.append(expansion.getVersion())
|
||||
.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
builder.append('\n');
|
||||
|
||||
builder.append("Expansions Directory:")
|
||||
.append('\n');
|
||||
|
||||
final String[] jars = plugin.getLocalExpansionManager()
|
||||
.getExpansionsFolder()
|
||||
.list((dir, name) -> name.toLowerCase().endsWith(".jar"));
|
||||
|
||||
for (final String jar : jars)
|
||||
{
|
||||
builder.append(" ")
|
||||
.append(jar)
|
||||
.append('\n');
|
||||
}
|
||||
|
||||
builder.append('\n');
|
||||
|
||||
|
||||
builder.append("Server Info: ")
|
||||
.append(plugin.getServer().getBukkitVersion())
|
||||
.append('/')
|
||||
.append(plugin.getServer().getVersion())
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Plugin Info:")
|
||||
.append('\n');
|
||||
|
||||
for (final Plugin other : plugin.getServer().getPluginManager().getPlugins())
|
||||
{
|
||||
builder.append(" ")
|
||||
.append(other.getName())
|
||||
.append(": ")
|
||||
.append(other.getDescription().getVersion())
|
||||
.append('\n');
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.local;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
|
||||
import me.clip.placeholderapi.util.Futures;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class CommandExpansionRegister extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandExpansionRegister()
|
||||
{
|
||||
super("register");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.size() < 1)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cYou must specify the name of an expansion file.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final LocalExpansionManager manager = plugin.getLocalExpansionManager();
|
||||
|
||||
final File file = new File(manager.getExpansionsFolder(), params.get(0));
|
||||
if (!file.exists())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cThe file &f" + file.getName() + "&c doesn't exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
Futures.onMainThread(plugin, manager.findExpansionInFile(file), (clazz, exception) -> {
|
||||
if (exception != null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cFailed to find expansion in file: &f" + file);
|
||||
|
||||
plugin.getLogger().log(Level.WARNING, "failed to find expansion in file: " + file, exception);
|
||||
return;
|
||||
}
|
||||
|
||||
if (clazz == null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cNo expansion class found in file: &f" + file);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Optional<PlaceholderExpansion> expansion = manager.register(clazz);
|
||||
if (!expansion.isPresent())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cFailed to register expansion from &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
Msg.msg(sender,
|
||||
"&aSuccessfully registered expansion: &f" + expansion.get().getName());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String[] fileNames = plugin.getLocalExpansionManager().getExpansionsFolder().list((dir, name) -> name.endsWith(".jar"));
|
||||
if (fileNames == null || fileNames.length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
suggestByParameter(Arrays.stream(fileNames), suggestions, params.isEmpty() ? null : params.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.local;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public final class CommandExpansionUnregister extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandExpansionUnregister()
|
||||
{
|
||||
super("unregister");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cYou must specify the name of the expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
final Optional<PlaceholderExpansion> expansion = plugin.getLocalExpansionManager().findExpansionByName(params.get(0));
|
||||
if (!expansion.isPresent())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cThere is no expansion loaded with the identifier: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final String message = !expansion.get().unregister() ?
|
||||
"&cFailed to unregister expansion: &f" :
|
||||
"&aSuccessfully unregistered expansion: &f";
|
||||
|
||||
Msg.msg(sender, message + expansion.get().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions, params.isEmpty() ? null : params.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.local;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class CommandHelp extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandHelp()
|
||||
{
|
||||
super("help");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
final PluginDescriptionFile description = plugin.getDescription();
|
||||
|
||||
Msg.msg(sender,
|
||||
"&b&lPlaceholderAPI &8- &7Help Menu &8- &7(&f" + description.getVersion() + "&7)",
|
||||
" ",
|
||||
"&b/papi",
|
||||
" &7&oView plugin info/version",
|
||||
"&b/papi &freload",
|
||||
" &7&oReload the config of PAPI",
|
||||
"&b/papi &flist",
|
||||
" &7&oList active expansions",
|
||||
"&b/papi &finfo &9<placeholder name>",
|
||||
" &7&oView information for a specific expansion",
|
||||
"&b/papi &fparse &9<me/player name> <message>",
|
||||
" &7&oParse a message with placeholders",
|
||||
"&b/papi &fbcparse &9<me/player name> <message>",
|
||||
" &7&oParse a message with placeholders and broadcast it",
|
||||
"&b/papi &fparserel &9<player one> <player two> <message>",
|
||||
" &7&oParse a message with relational placeholders",
|
||||
"&b/papi &fregister &9<file name>",
|
||||
" &7&oRegister an expansion by the name of the file",
|
||||
"&b/papi &funregister &9<expansion name>",
|
||||
" &7&oUnregister an expansion by name");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.local;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class CommandInfo extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandInfo()
|
||||
{
|
||||
super("info");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.isEmpty())
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cYou must specify the name of the expansion.");
|
||||
return;
|
||||
}
|
||||
|
||||
final PlaceholderExpansion expansion = plugin.getLocalExpansionManager().findExpansionByName(params.get(0)).orElse(null);
|
||||
if (expansion == null)
|
||||
{
|
||||
Msg.msg(sender,
|
||||
"&cThere is no expansion loaded with the identifier: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("&7Placeholder expansion info for: &r")
|
||||
.append(expansion.getName())
|
||||
.append('\n')
|
||||
.append("&7Status: &r")
|
||||
.append(expansion.isRegistered() ? "&aRegistered" : "7cNotRegistered")
|
||||
.append('\n');
|
||||
|
||||
final String author = expansion.getAuthor();
|
||||
if (author != null)
|
||||
{
|
||||
builder.append("&7Author: &r")
|
||||
.append(author)
|
||||
.append('\n');
|
||||
}
|
||||
|
||||
final String version = expansion.getVersion();
|
||||
if (version != null)
|
||||
{
|
||||
builder.append("&7Version: &r")
|
||||
.append(version)
|
||||
.append('\n');
|
||||
}
|
||||
|
||||
final String requiredPlugin = expansion.getRequiredPlugin();
|
||||
if (requiredPlugin != null)
|
||||
{
|
||||
builder.append("&7Requires plugin: &r")
|
||||
.append(requiredPlugin)
|
||||
.append('\n');
|
||||
}
|
||||
|
||||
final List<String> placeholders = expansion.getPlaceholders();
|
||||
if (placeholders != null && !placeholders.isEmpty())
|
||||
{
|
||||
builder.append("&8&m-- &7Placeholders &8&m--&r")
|
||||
.append('\n');
|
||||
|
||||
for (final String placeholder : placeholders)
|
||||
{
|
||||
builder.append(placeholder)
|
||||
.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
Msg.msg(sender, builder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions, params.isEmpty() ? null : params.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.local;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class CommandList extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandList()
|
||||
{
|
||||
super("list");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
final Set<String> identifiers = PlaceholderAPI.getRegisteredIdentifiers();
|
||||
if (identifiers.isEmpty())
|
||||
{
|
||||
Msg.msg(sender, "&6There are no placeholder hooks active!");
|
||||
return;
|
||||
}
|
||||
|
||||
final List<List<String>> partitions = Lists.partition(identifiers.stream().sorted().collect(Collectors.toList()), 10);
|
||||
|
||||
Msg.msg(sender,
|
||||
"&6" + identifiers.size() + "&7 placeholder hook(s) active: &a",
|
||||
partitions.stream().map(partition -> " " + String.join(", ", partition)).collect(Collectors.joining("\n")));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.local;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class CommandParse extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandParse()
|
||||
{
|
||||
super("parse", "bcparse", "parserel", "cmdparse");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
switch (alias.toLowerCase())
|
||||
{
|
||||
case "parserel":
|
||||
evaluateParseRelation(sender, params);
|
||||
break;
|
||||
case "parse":
|
||||
evaluateParseSingular(sender, params, false, false);
|
||||
break;
|
||||
case "bcparse":
|
||||
evaluateParseSingular(sender, params, true, false);
|
||||
break;
|
||||
case "cmdparse":
|
||||
evaluateParseSingular(sender, params, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
switch (alias.toLowerCase())
|
||||
{
|
||||
case "parserel":
|
||||
completeParseRelation(params, suggestions);
|
||||
break;
|
||||
case "parse":
|
||||
case "bcparse":
|
||||
case "cmdparse":
|
||||
completeParseSingular(sender, params, suggestions);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void evaluateParseSingular(@NotNull final CommandSender sender, @NotNull @Unmodifiable final List<String> params, final boolean broadcast, final boolean command)
|
||||
{
|
||||
if (params.size() < 2)
|
||||
{
|
||||
Msg.msg(sender, "&cYou must supply a target, and a message: &b/papi " + (broadcast ? "bcparse" : "parse") + " &7{target} &a{message}");
|
||||
return;
|
||||
}
|
||||
|
||||
@NotNull final OfflinePlayer player;
|
||||
|
||||
if ("me".equalsIgnoreCase(params.get(0)))
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
Msg.msg(sender, "&cYou must be a player to use &7me&c as a target!");
|
||||
return;
|
||||
}
|
||||
|
||||
player = ((Player) sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
final OfflinePlayer target = resolvePlayer(params.get(0));
|
||||
if (target == null)
|
||||
{
|
||||
Msg.msg(sender, "&cFailed to find player: &7" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
player = target;
|
||||
}
|
||||
|
||||
final String message = PlaceholderAPI.setPlaceholders(player, String.join(" ", params.subList(1, params.size())));
|
||||
|
||||
if (command)
|
||||
{
|
||||
Bukkit.dispatchCommand(sender, message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (broadcast)
|
||||
{
|
||||
Msg.broadcast(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
Msg.msg(sender, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.spigot().sendMessage(TextComponent.fromLegacyText(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateParseRelation(@NotNull final CommandSender sender, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
if (params.size() < 3)
|
||||
{
|
||||
Msg.msg(sender, "&cYou must supply two targets, and a message: &b/papi parserel &7{target one} {target two} &a{message}");
|
||||
return;
|
||||
}
|
||||
|
||||
final OfflinePlayer targetOne = resolvePlayer(params.get(0));
|
||||
if (targetOne == null || !targetOne.isOnline())
|
||||
{
|
||||
Msg.msg(sender, "&cFailed to find player: &7" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final OfflinePlayer targetTwo = resolvePlayer(params.get(1));
|
||||
if (targetTwo == null || !targetTwo.isOnline())
|
||||
{
|
||||
Msg.msg(sender, "&cFailed to find player: &7" + params.get(1));
|
||||
return;
|
||||
}
|
||||
|
||||
final String message = PlaceholderAPI.setRelationalPlaceholders(((Player) targetOne), ((Player) targetTwo), String.join(" ", params.subList(2, params.size())));
|
||||
Msg.msg(sender, message);
|
||||
}
|
||||
|
||||
|
||||
private void completeParseSingular(@NotNull final CommandSender sender, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() <= 1)
|
||||
{
|
||||
if (sender instanceof Player && (params.isEmpty() || "me".startsWith(params.get(0).toLowerCase())))
|
||||
{
|
||||
suggestions.add("me");
|
||||
}
|
||||
|
||||
final Stream<String> names = Bukkit.getOnlinePlayers().stream().map(Player::getName);
|
||||
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final String name = params.get(params.size() - 1);
|
||||
if (!name.startsWith("%") || name.endsWith("%"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int index = name.indexOf('_');
|
||||
if (index == -1)
|
||||
{
|
||||
return; // no arguments supplied yet
|
||||
}
|
||||
|
||||
final PlaceholderExpansion expansion = PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByIdentifier(name.substring(1, index)).orElse(null);
|
||||
if (expansion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Set<String> possible = new HashSet<>(expansion.getPlaceholders());
|
||||
|
||||
PlaceholderAPIPlugin.getInstance()
|
||||
.getCloudExpansionManager()
|
||||
.findCloudExpansionByName(expansion.getName())
|
||||
.ifPresent(cloud -> possible.addAll(cloud.getPlaceholders()));
|
||||
|
||||
suggestByParameter(possible.stream(), suggestions, params.get(params.size() - 1));
|
||||
}
|
||||
|
||||
private void completeParseRelation(@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
||||
{
|
||||
if (params.size() > 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Stream<String> names = Bukkit.getOnlinePlayers().stream().map(Player::getName);
|
||||
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(params.size() - 1));
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private OfflinePlayer resolvePlayer(@NotNull final String name)
|
||||
{
|
||||
OfflinePlayer target = Bukkit.getPlayer(name);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
target = Bukkit.getOfflinePlayer(name); // this is probably not a great idea.
|
||||
}
|
||||
|
||||
return target.hasPlayedBefore() ? target : null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* This file is part of PlaceholderAPI
|
||||
*
|
||||
* PlaceholderAPI
|
||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
||||
*
|
||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.clip.placeholderapi.commands.impl.local;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class CommandVersion extends PlaceholderCommand
|
||||
{
|
||||
|
||||
public CommandVersion()
|
||||
{
|
||||
super("version");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
||||
{
|
||||
final PluginDescriptionFile description = plugin.getDescription();
|
||||
|
||||
Msg.msg(sender,
|
||||
"&b&lPlaceholderAPI &e(&f" + description.getVersion() + "&e)",
|
||||
"&fAuthors&8: &6" + description.getAuthors(),
|
||||
"&fPAPI Commands&8: &b/papi &7help",
|
||||
"&feCloud Commands&8: &b/papi &7ecloud");
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user