mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2025-11-09 08:45:08 +01:00
Compare commits
541 Commits
2.10.7
...
deprecated
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79940ff164 | ||
|
|
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.
|
||||||
|
#
|
||||||
|
* @extendedclip @PiggyPiglet
|
||||||
|
|
||||||
|
#
|
||||||
|
# Assigns Andre601 to any PR that targets the wiki folder.
|
||||||
|
#
|
||||||
|
/wiki/ @Andre601
|
||||||
102
.github/CONTRIBUTING.md
vendored
102
.github/CONTRIBUTING.md
vendored
@@ -1,64 +1,52 @@
|
|||||||
[issue]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request_placeholderapi.md
|
[issue]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new
|
||||||
[Discord]: https://helpch.at/discord
|
[discord]: https://helpch.at/discord
|
||||||
[homepage]: http://contributor-covenant.org
|
[code of conduct]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/CODE_OF_CONDUCT.md
|
||||||
[version]: http://contributor-covenant.org/version/1/4/
|
[wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/docs/wiki/wiki
|
||||||
|
[dev]: https://github.com/PlaceholderAPI/PlaceholderAPI/tree/development
|
||||||
|
[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.
|
### Follow the template
|
||||||
2. Try to prevent any breaking changes affecting the end-user (Developers using the API).
|
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.
|
||||||
Mention any breaking changes that could affect the end-user.
|
Your issue may be closed without warning for not following the template.
|
||||||
3. Document any public methods that the end-user might use.
|
|
||||||
|
### 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 are we welcoming all contributions to improve PlaceholderAPI, being it changes to its code like bug fixes or new features, or contributions to its documentation such as the [Wiki] or the Javadoc.
|
||||||
|
|
||||||
|
### Code contributions
|
||||||
|
Any contributions to PlaceholderAPI's code should be done towards the [`development`][dev] branch. Targeting the `master` branch in your Pull request may get it closed without warning.
|
||||||
|
Additionally should you follow the project's codestyle which you can find in the [`config/style`][style] directory.
|
||||||
|
|
||||||
|
### Wiki/Javadoc contributions
|
||||||
|
If your pull request only targets the [wiki] or only changes the javadoc comments of PlaceholderAPI (And not its actual code), it should be to `docs/wiki` branch.
|
||||||
|
The develop branch should only be targeted when you also change some of PlaceholderAPI's code.
|
||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
We have a [Code of Conduct] to maintain a welcoming atmosphere in this project.
|
||||||
### Our Pledge
|
If your contributions go against the Code of Conduct, linked above, we reserve the right to deny or revert your contributions.
|
||||||
|
|
||||||
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]
|
|
||||||
|
|||||||
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
|
|
||||||
101
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
101
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
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
|
||||||
|
- 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
|
- name: Hastebin
|
||||||
url: https://paste.helpch.at
|
url: https://paste.helpch.at
|
||||||
about: Use our Hastebin-site for sharing errors and configuration files.
|
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..."
|
||||||
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,8 +1,13 @@
|
|||||||
## Please read
|
<!--
|
||||||
Please make sure you checked the following:
|
### Please read ###
|
||||||
- You checked the [Pull requests] page for any upcoming changes.
|
Please make sure you checked the following:
|
||||||
- You documented any public code that the end-user might use.
|
|
||||||
- You followed the [contributing file]
|
- 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
|
### Type
|
||||||
<!--
|
<!--
|
||||||
@@ -14,12 +19,10 @@ Please make sure you checked the following:
|
|||||||
- [ ] Other: __________ <!-- Use this if none of the above matches your request -->
|
- [ ] Other: __________ <!-- Use this if none of the above matches your request -->
|
||||||
|
|
||||||
### Description
|
### Description
|
||||||
> Provide additional information if needed.
|
<!-- What does your Pull request change? -->
|
||||||
<!-- Please type below this line -->
|
|
||||||
|
Closes N/A <!-- If your PR is based on an issue, change "N/A" the the issue ID (#id) -->
|
||||||
|
|
||||||
|
|
||||||
<!-- DO NOT ALTER ANYTHING BELOW THIS LINE! -->
|
<!-- 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://github.com/PlaceholderAPI/PlaceholderAPI/wiki
|
||||||
|
|||||||
135
.github/label-commenter-config.yml
vendored
Normal file
135
.github/label-commenter-config.yml
vendored
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
comment:
|
||||||
|
footer: "\
|
||||||
|
----\n\n
|
||||||
|
> *This is an automated response created by a **GitHub Action***\n
|
||||||
|
> *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 and PlaceholderAPI
|
||||||
|
- Currently installed Expansions
|
||||||
|
- Currently installed Plugins
|
||||||
|
|
||||||
|
The easiest way to provide those information is through the `/papi dumb` 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 in any way.
|
||||||
|
|
||||||
|
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?template=bug_report.md)
|
||||||
|
- [Feature Request](https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=feature_request.md)
|
||||||
|
|
||||||
|
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/master/wiki/README.md).
|
||||||
|
|
||||||
|
It is recommended to [join our Discord Server](https://helpch.at/discord) as you often receive 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 `development` branch.
|
||||||
|
- Pull requests for the Wiki should target the `docs/wiki` branch.
|
||||||
|
|
||||||
|
Don't hesitate to ask us any questions.
|
||||||
|
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 now 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 [`docs/wiki`](https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki) branch of the Repository.
|
||||||
|
- You only made changes to the files inside the [`wiki`](https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki/wiki) folder.
|
||||||
|
- You followed the general Styling Guidelines mentioned in the wiki's [README](https://github.com/PlaceholderAPI/PlaceholderAPI/blob/docs/wiki/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.
|
||||||
|
**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 now 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 }}
|
||||||
31
.github/workflows/pr_build_jars.yml
vendored
Normal file
31
.github/workflows/pr_build_jars.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
name: "Test compiling against Java 8, 11 and 16"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- development
|
||||||
|
paths:
|
||||||
|
- "src/**"
|
||||||
|
- "build.gradle"
|
||||||
|
|
||||||
|
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"
|
||||||
27
.github/workflows/wiki.yml
vendored
27
.github/workflows/wiki.yml
vendored
@@ -12,7 +12,7 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- 'wiki/**'
|
- 'wiki/**'
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'docs/wiki'
|
||||||
#
|
#
|
||||||
# Releases cause this action to also fire.
|
# Releases cause this action to also fire.
|
||||||
# Using this prevents this problem.
|
# Using this prevents this problem.
|
||||||
@@ -27,23 +27,10 @@ jobs:
|
|||||||
- name: 'Checkout Code'
|
- name: 'Checkout Code'
|
||||||
uses: actions/Checkout@v2
|
uses: actions/Checkout@v2
|
||||||
- name: 'Update Wiki'
|
- name: 'Update Wiki'
|
||||||
uses: docker://decathlon/wiki-page-creator-action:latest
|
uses: Andrew-Chen-Wang/github-wiki-action@v2
|
||||||
env:
|
env:
|
||||||
#
|
WIKI_DIR: wiki/
|
||||||
# We can use the E-Mail and Name of the GitHub Actions account
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# for our convenience.
|
GH_MAIL: 'actions@github.com'
|
||||||
#
|
GH_NAME: 'github-actions[bot]'
|
||||||
ACTION_MAIL: 'actions@github.com'
|
EXCLUDED_FILES: 'README.md'
|
||||||
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
|
|
||||||
|
|||||||
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]
|
||||||
18
README.md
18
README.md
@@ -14,8 +14,11 @@
|
|||||||
[ci]: http://ci.extendedclip.com/job/PlaceholderAPI/
|
[ci]: http://ci.extendedclip.com/job/PlaceholderAPI/
|
||||||
[ciImg]: http://ci.extendedclip.com/buildStatus/icon?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
|
[APIversionImg]: https://img.shields.io/nexus/placeholderapi/me.clip/placeholderapi?server=https%3A%2F%2Frepo.extendedclip.com&label=API%20Version
|
||||||
[logo]: https://i.imgur.com/Ea4PURv.png
|
[logo]: https://raw.githubusercontent.com/PlaceholderAPI/PlaceholderAPI/master/wiki/img/papi-logo.png
|
||||||
|
|
||||||
|
[contributing]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/.github/CONTRIBUTING.md
|
||||||
|
[placeholderexpansion]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/PlaceholderExpansion
|
||||||
<!-- The stuff above isn't visible in the readme -->
|
<!-- The stuff above isn't visible in the readme -->
|
||||||
|
|
||||||
[![logo]][spigot]
|
[![logo]][spigot]
|
||||||
@@ -27,10 +30,13 @@
|
|||||||
|
|
||||||
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 150+ 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 750,000 times and has been used concurrently on over 35,000 servers, which makes it a must-have for a server of any type or scale.
|
||||||
|
|
||||||
<!-- TODO: Add contributing section -->
|
## Contribute
|
||||||
<!-- TODO: Add expansion creation section (possibly add to a wiki?) -->
|
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
|
## Support
|
||||||
- [Issue Tracker][issues]
|
- [Issue Tracker][issues]
|
||||||
@@ -38,7 +44,7 @@ PlaceholderAPI has been downloaded over 300,000 times and has been used concurre
|
|||||||
|
|
||||||
## Quick Links
|
## Quick Links
|
||||||
- [CI Server][ci]
|
- [CI Server][ci]
|
||||||
- [Expansions cloud]
|
- [Expansions Cloud]
|
||||||
- [Placeholder List]
|
- [Placeholder List]
|
||||||
- [Spigot Page][spigot]
|
- [Spigot Page][spigot]
|
||||||
- [Plugin Statistics][statistics]
|
- [Plugin Statistics][statistics]
|
||||||
|
|||||||
103
build.gradle
103
build.gradle
@@ -1,89 +1,97 @@
|
|||||||
|
import org.apache.tools.ant.filters.ReplaceTokens
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "java"
|
id "java"
|
||||||
id "maven-publish"
|
id "maven-publish"
|
||||||
id "net.minecrell.licenser" version "0.4.1"
|
id "org.cadixdev.licenser" version "0.6.1"
|
||||||
id "com.github.johnrengelman.shadow" version "6.0.0"
|
id "com.github.johnrengelman.shadow" version "7.1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group "me.clip"
|
group "me.clip"
|
||||||
version "2.10.7"
|
version "2.10.10-DEV-${System.getProperty("BUILD_NUMBER")}"
|
||||||
|
|
||||||
description "An awesome placeholder provider!"
|
description "An awesome placeholder provider!"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
maven({ url = "https://oss.sonatype.org/content/repositories/snapshots/" })
|
||||||
|
|
||||||
maven({ url = "https://rayzr.dev/repo/" })
|
mavenCentral()
|
||||||
maven({ url = "https://repo.codemc.org/repository/maven-public" })
|
mavenLocal()
|
||||||
|
|
||||||
|
maven({ url = "https://repo.codemc.org/repository/maven-public/" })
|
||||||
maven({ url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" })
|
maven({ url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" })
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.google.code.gson:gson:2.8.6"
|
implementation "org.bstats:bstats-bukkit:2.2.1"
|
||||||
implementation "org.bstats:bstats-bukkit:1.5"
|
implementation "net.kyori:adventure-platform-bukkit:4.0.1"
|
||||||
implementation "me.rayzr522:jsonmessage:1.2.1"
|
|
||||||
|
|
||||||
compileOnly "org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT"
|
compileOnly "org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT"
|
||||||
compileOnly "org.jetbrains:annotations:19.0.0"
|
compileOnly "org.jetbrains:annotations:22.0.0"
|
||||||
|
|
||||||
testImplementation "org.openjdk.jmh:jmh-core:1.23"
|
testImplementation "org.openjdk.jmh:jmh-core:1.32"
|
||||||
testImplementation "org.openjdk.jmh:jmh-generator-annprocess:1.23"
|
testImplementation "org.openjdk.jmh:jmh-generator-annprocess:1.32"
|
||||||
|
|
||||||
testCompile "org.junit.jupiter:junit-jupiter-engine:5.6.2"
|
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.8.1"
|
||||||
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.6.2"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
import org.apache.tools.ant.filters.ReplaceTokens
|
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
filter ReplaceTokens, tokens: [name: rootProject.name, version: project.version.toString(), description: project.description]
|
||||||
filter ReplaceTokens, tokens: [
|
}
|
||||||
name: rootProject.name,
|
|
||||||
version: project.version.toString(),
|
java {
|
||||||
description: project.description
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
]
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
|
||||||
|
withJavadocJar()
|
||||||
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
tasks.withType(Javadoc) {
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
failOnError false
|
||||||
|
options.addStringOption('Xdoclint:none', '-quiet')
|
||||||
|
options.addStringOption('encoding', 'UTF-8')
|
||||||
|
options.addStringOption('charSet', 'UTF-8')
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
archiveClassifier.set("")
|
archiveClassifier.set("")
|
||||||
|
|
||||||
relocate "org.bstats", "me.clip.placeholderapi.metrics"
|
relocate "org.bstats", "me.clip.placeholderapi.metrics"
|
||||||
relocate "com.google.gson", "me.clip.placeholderapi.libs.gson"
|
relocate "net.kyori", "me.clip.placeholderapi.libs.kyori"
|
||||||
relocate "me.rayzr522.jsonmessage", "me.clip.placeholderapi.libs.jsonmessage"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
license {
|
license {
|
||||||
header = file("headers/header.txt")
|
include '**/*.java'
|
||||||
|
|
||||||
ext {
|
matching('**/*.java') {
|
||||||
year = 2020
|
header = file('config/headers/main.txt')
|
||||||
}
|
}
|
||||||
|
|
||||||
include "**/*.java"
|
ext {
|
||||||
|
year = 2021
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
configurations {
|
||||||
test.compileClasspath += configurations.compileOnly
|
testImplementation {
|
||||||
test.runtimeClasspath += configurations.compileOnly
|
extendsFrom(compileOnly)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
|
if (version.contains("-DEV")) {
|
||||||
if (version.contains("-DEV-")) {
|
|
||||||
url = uri("https://repo.extendedclip.com/content/repositories/dev/")
|
url = uri("https://repo.extendedclip.com/content/repositories/dev/")
|
||||||
} else {
|
} else {
|
||||||
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||||
@@ -97,8 +105,25 @@ publishing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
from(components.java)
|
artifactId = "placeholderapi"
|
||||||
|
|
||||||
|
from components.java
|
||||||
|
|
||||||
|
pom.withXml {
|
||||||
|
|
||||||
|
// some are having issues with bstats so we might need to add that to the pom as well
|
||||||
|
|
||||||
|
asNode().appendNode("packaging", "jar")
|
||||||
|
asNode().remove(asNode().get("dependencies"))
|
||||||
|
|
||||||
|
def dependenciesNode = asNode().appendNode("dependencies")
|
||||||
|
// jetbrains annotations
|
||||||
|
def jetbrainsAnnotations = dependenciesNode.appendNode("dependency")
|
||||||
|
jetbrainsAnnotations.appendNode("groupId", "org.jetbrains")
|
||||||
|
jetbrainsAnnotations.appendNode("artifactId", "annotations")
|
||||||
|
jetbrainsAnnotations.appendNode("version", "19.0.0")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
config/headers/jsonmessage.txt
Normal file
7
config/headers/jsonmessage.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Copyright (c) 2018-2021 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.
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,5 @@
|
|||||||
#Tue Jul 14 23:27:02 AWST 2020
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
269
gradlew
vendored
Normal file → Executable file
269
gradlew
vendored
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright <20> 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with 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 <20>$var<61>, <20>${var}<7D>, <20>${var:-default}<7D>, <20>${var+SET}<7D>,
|
||||||
|
# <20>${var#prefix}<7D>, <20>${var%suffix}<7D>, and <20>$( cmd )<29>;
|
||||||
|
# * compound commands having a testable exit status, especially <20>case<73>;
|
||||||
|
# * various built-in commands including <20>command<6E>, <20>set<65>, and <20>ulimit<69>.
|
||||||
|
#
|
||||||
|
# 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/master/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
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=${0##*/}
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# 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"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
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 [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
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."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
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.
|
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
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -106,80 +140,95 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
warn "Could not query maximum file descriptor limit"
|
||||||
fi
|
esac
|
||||||
ulimit -n $MAX_FD
|
case $MAX_FD in #(
|
||||||
if [ $? -ne 0 ] ; then
|
'' | soft) :;; #(
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
*)
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
else
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
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" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --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
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
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 \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# 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" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
21
gradlew.bat
vendored
21
gradlew.bat
vendored
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -54,7 +54,7 @@ goto fail
|
|||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
@@ -64,21 +64,6 @@ echo location of your Java installation.
|
|||||||
|
|
||||||
goto fail
|
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
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
@@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@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
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -21,6 +21,11 @@
|
|||||||
package me.clip.placeholderapi;
|
package me.clip.placeholderapi;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import me.clip.placeholderapi.expansion.Relational;
|
import me.clip.placeholderapi.expansion.Relational;
|
||||||
import me.clip.placeholderapi.replacer.CharsReplacer;
|
import me.clip.placeholderapi.replacer.CharsReplacer;
|
||||||
@@ -29,38 +34,22 @@ import me.clip.placeholderapi.replacer.Replacer.Closure;
|
|||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
public final class PlaceholderAPI {
|
||||||
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_PERCENT = new CharsReplacer(Closure.PERCENT);
|
||||||
private static final Replacer REPLACER_BRACKET = new CharsReplacer(Closure.BRACKET);
|
private static final Replacer REPLACER_BRACKET = new CharsReplacer(Closure.BRACKET);
|
||||||
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
|
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
|
||||||
@Deprecated
|
|
||||||
private static final Pattern BRACKET_PLACEHOLDER_PATTERN = Pattern.compile("[{]([^{}]+)[}]");
|
private static final Pattern BRACKET_PLACEHOLDER_PATTERN = Pattern.compile("[{]([^{}]+)[}]");
|
||||||
@Deprecated
|
private static final Pattern RELATIONAL_PLACEHOLDER_PATTERN = Pattern
|
||||||
private static final Pattern RELATIONAL_PLACEHOLDER_PATTERN = Pattern.compile("[%](rel_)([^%]+)[%]");
|
.compile("[%](rel_)([^%]+)[%]");
|
||||||
|
|
||||||
|
|
||||||
private PlaceholderAPI()
|
private PlaceholderAPI() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// === Current API ===
|
// === Current API ===
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,9 +61,10 @@ public final class PlaceholderAPI
|
|||||||
* @return String containing all translated placeholders
|
* @return String containing all translated placeholders
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text)
|
public static String setPlaceholders(final OfflinePlayer player,
|
||||||
{
|
@NotNull final String text) {
|
||||||
return REPLACER_PERCENT.apply(text, player, PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()::getExpansion);
|
return REPLACER_PERCENT.apply(text, player,
|
||||||
|
PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()::getExpansion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,171 +76,22 @@ public final class PlaceholderAPI
|
|||||||
* @return String containing all translated placeholders
|
* @return String containing all translated placeholders
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<String> setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<@NotNull String> text)
|
public static List<String> setPlaceholders(final OfflinePlayer player,
|
||||||
{
|
@NotNull final List<@NotNull String> text) {
|
||||||
return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList());
|
return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates all placeholders into their corresponding values.
|
* Translates all placeholders into their corresponding values.
|
||||||
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
||||||
*
|
*
|
||||||
* @param player Player to parse the placeholders against
|
* @param player Player to parse the placeholders against
|
||||||
* @param text Text to set the placeholder values in
|
* @param text Text to set the placeholder values in
|
||||||
* @return String containing all translated placeholders
|
* @return String containing all translated placeholders
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String setBracketPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text)
|
public static String setPlaceholders(final Player player, @NotNull String text) {
|
||||||
{
|
return setPlaceholders(((OfflinePlayer) player), 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -259,86 +100,104 @@ public final class PlaceholderAPI
|
|||||||
*
|
*
|
||||||
* @param player Player to parse the placeholders against
|
* @param player Player to parse the placeholders against
|
||||||
* @param text List of Strings to set the placeholder values in
|
* @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
|
* @return String containing all translated placeholders
|
||||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@NotNull
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
public static List<String> setPlaceholders(final Player player, @NotNull List<@NotNull String> text) {
|
||||||
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text, boolean colorize)
|
return setPlaceholders(((OfflinePlayer) player), text);
|
||||||
{
|
|
||||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates all placeholders into their corresponding values.
|
* Translates all placeholders into their corresponding values.
|
||||||
* <br>You set the pattern yourself through this method.
|
* <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 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 player Player to parse the placeholders against
|
||||||
* @param text Text to set the placeholder values in
|
* @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
|
* @return String containing all translated placeholders
|
||||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@NotNull
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
public static String setBracketPlaceholders(final OfflinePlayer player,
|
||||||
public static String setBracketPlaceholders(OfflinePlayer player, String text, boolean colorize)
|
@NotNull final String text) {
|
||||||
{
|
return REPLACER_BRACKET.apply(text, player,
|
||||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
|
PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()::getExpansion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates all placeholders into their corresponding values.
|
* Translates all placeholders into their corresponding values.
|
||||||
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
|
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
||||||
*
|
*
|
||||||
* @param player Player to parse the placeholder against
|
* @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(final OfflinePlayer 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
|
||||||
|
*/
|
||||||
|
public static String setBracketPlaceholders(Player player, 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
|
||||||
|
*/
|
||||||
|
public static List<String> setBracketPlaceholders(Player player, 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
|
* @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
|
||||||
* @return The text containing the parsed placeholders
|
|
||||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static String setRelationalPlaceholders(Player one, Player two, String text) {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
final Matcher matcher = RELATIONAL_PLACEHOLDER_PATTERN.matcher(text);
|
||||||
public static String setPlaceholders(OfflinePlayer player, String text, boolean colorize)
|
|
||||||
{
|
while (matcher.find()) {
|
||||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
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();
|
||||||
* Translates all placeholders into their corresponding values.
|
String params = format.substring(index + 1);
|
||||||
* <br>You set the pattern yourself through this method.
|
final PlaceholderExpansion expansion = PlaceholderAPIPlugin.getInstance()
|
||||||
*
|
.getLocalExpansionManager().getExpansion(identifier);
|
||||||
* @param player Player to parse the placeholders against
|
|
||||||
* @param text Text to set the placeholder values in
|
if (!(expansion instanceof Relational)) {
|
||||||
* @param pattern The pattern to match placeholders to. Capture group 1 must contain an underscore separating the
|
continue;
|
||||||
* identifier from the params
|
}
|
||||||
* @return The text containing the parsed placeholders
|
|
||||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
final String value = ((Relational) expansion).onPlaceholderRequest(one, two, params);
|
||||||
*/
|
|
||||||
@Deprecated
|
if (value != null) {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
text = text.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement(value));
|
||||||
public static String setPlaceholders(OfflinePlayer player, String text, Pattern pattern)
|
}
|
||||||
{
|
}
|
||||||
return setPlaceholders(player, text, pattern, true);
|
|
||||||
|
return Msg.color(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,253 +208,80 @@ public final class PlaceholderAPI
|
|||||||
* @param two Player to compare
|
* @param two Player to compare
|
||||||
* @param text text to parse the placeholder values to
|
* @param text text to parse the placeholder values to
|
||||||
* @return The text containing the parsed relational placeholders
|
* @return The text containing the parsed relational placeholders
|
||||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text) {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
return text.stream().map(line -> setRelationalPlaceholders(one, two, line))
|
||||||
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());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set relational placeholders in the text specified placeholders are matched with the pattern
|
* Check if a specific placeholder identifier is currently registered
|
||||||
* %<rel_(identifier)_(params)>% when set with this method
|
|
||||||
*
|
*
|
||||||
* @param one First player to compare
|
* @param identifier The identifier to check
|
||||||
* @param two Second player to compare
|
* @return true if identifier is already registered
|
||||||
* @param text Text to parse the placeholders in
|
|
||||||
* @return The text containing the parsed relational placeholders
|
|
||||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static boolean isRegistered(@NotNull final String identifier) {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
return PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()
|
||||||
public static String setRelationalPlaceholders(Player one, Player two, String text)
|
.findExpansionByIdentifier(identifier).isPresent();
|
||||||
{
|
|
||||||
return setRelationalPlaceholders(one, two, text, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set relational placeholders in the text specified placeholders are matched with the pattern
|
* Get all registered placeholder identifiers
|
||||||
* %<rel_(identifier)_(params)>% when set with this method
|
|
||||||
*
|
*
|
||||||
* @param one Player to compare
|
* @return A Set of type String containing the identifiers of all registered expansions.
|
||||||
* @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
|
@NotNull
|
||||||
@SuppressWarnings("DuplicatedCode")
|
public static Set<String> getRegisteredIdentifiers() {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
return ImmutableSet
|
||||||
public static String setRelationalPlaceholders(Player one, Player two, String text, boolean colorize)
|
.copyOf(PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().getIdentifiers());
|
||||||
{
|
|
||||||
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.
|
* Get the normal placeholder pattern.
|
||||||
*
|
*
|
||||||
* @return The pattern for {@literal %<identifier>_<params>%}
|
* @return Regex Pattern of {@literal [%]([^%]+)[%]}
|
||||||
* @deprecated Will be removed in a future release.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static Pattern getPlaceholderPattern() {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
|
||||||
public static Pattern getPlaceholderPattern()
|
|
||||||
{
|
|
||||||
return PLACEHOLDER_PATTERN;
|
return PLACEHOLDER_PATTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the placeholder pattern for the bracket placeholders.
|
* Get the bracket placeholder pattern.
|
||||||
*
|
*
|
||||||
* @return The pattern for {@literal {<identifier>_<params>}}
|
* @return Regex Pattern of {@literal [{]([^{}]+)[}]}
|
||||||
* @deprecated Will be removed in a future release.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static Pattern getBracketPlaceholderPattern() {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
|
||||||
public static Pattern getBracketPlaceholderPattern()
|
|
||||||
{
|
|
||||||
return BRACKET_PLACEHOLDER_PATTERN;
|
return BRACKET_PLACEHOLDER_PATTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the placeholder pattern for the relational placeholders.
|
* Get the relational placeholder pattern.
|
||||||
*
|
*
|
||||||
* @return The pattern for {@literal %rel_<identifier>_<params>%}
|
* @return Regex Pattern of {@literal [%](rel_)([^%]+)[%]}
|
||||||
* @deprecated Will be removed in a future release.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static Pattern getRelationalPlaceholderPattern() {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
|
||||||
public static Pattern getRelationalPlaceholderPattern()
|
|
||||||
{
|
|
||||||
return RELATIONAL_PLACEHOLDER_PATTERN;
|
return RELATIONAL_PLACEHOLDER_PATTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Will be removed in a future release.
|
* 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
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static boolean containsPlaceholders(String text) {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
return text != null && PLACEHOLDER_PATTERN.matcher(text).find();
|
||||||
public static Set<String> getRegisteredPlaceholderPlugins()
|
|
||||||
{
|
|
||||||
return getRegisteredIdentifiers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Will be removed in a future release.
|
* 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
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static boolean containsBracketPlaceholders(String text) {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
return text != null && BRACKET_PLACEHOLDER_PATTERN.matcher(text).find();
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi;
|
package me.clip.placeholderapi;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommandRouter;
|
import me.clip.placeholderapi.commands.PlaceholderCommandRouter;
|
||||||
import me.clip.placeholderapi.configuration.PlaceholderAPIConfig;
|
import me.clip.placeholderapi.configuration.PlaceholderAPIConfig;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
@@ -28,7 +32,11 @@ import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
|
|||||||
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
|
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
|
||||||
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
|
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
|
||||||
import me.clip.placeholderapi.updatechecker.UpdateChecker;
|
import me.clip.placeholderapi.updatechecker.UpdateChecker;
|
||||||
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
|
import net.kyori.adventure.text.serializer.craftbukkit.MinecraftComponentSerializer;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
|
import org.bstats.charts.AdvancedPie;
|
||||||
|
import org.bstats.charts.SimplePie;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
@@ -36,42 +44,31 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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...
|
* Yes I have a shit load of work to do...
|
||||||
*
|
*
|
||||||
* @author Ryan McCarthy
|
* @author Ryan McCarthy
|
||||||
*/
|
*/
|
||||||
public final class PlaceholderAPIPlugin extends JavaPlugin
|
public final class PlaceholderAPIPlugin extends JavaPlugin {
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final Version VERSION;
|
private static final Version VERSION;
|
||||||
|
private static PlaceholderAPIPlugin instance;
|
||||||
|
|
||||||
static
|
static {
|
||||||
{
|
|
||||||
final String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
final String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||||
|
|
||||||
boolean isSpigot;
|
boolean isSpigot;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
Class.forName("org.spigotmc.SpigotConfig");
|
Class.forName("org.spigotmc.SpigotConfig");
|
||||||
isSpigot = true;
|
isSpigot = true;
|
||||||
}
|
} catch (final ExceptionInInitializerError | ClassNotFoundException ignored) {
|
||||||
catch (final ExceptionInInitializerError | ClassNotFoundException ignored)
|
|
||||||
{
|
|
||||||
isSpigot = false;
|
isSpigot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSION = new Version(version, isSpigot);
|
VERSION = new Version(version, isSpigot);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PlaceholderAPIPlugin instance;
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final PlaceholderAPIConfig config = new PlaceholderAPIConfig(this);
|
private final PlaceholderAPIConfig config = new PlaceholderAPIConfig(this);
|
||||||
|
|
||||||
@@ -80,138 +77,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final CloudExpansionManager cloudExpansionManager = new CloudExpansionManager(this);
|
private final CloudExpansionManager cloudExpansionManager = new CloudExpansionManager(this);
|
||||||
|
|
||||||
|
private BukkitAudiences adventure;
|
||||||
@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
|
* Gets the static instance of the main class for PlaceholderAPI. This class is not the actual API
|
||||||
@@ -221,20 +87,17 @@ public final class PlaceholderAPIPlugin extends JavaPlugin
|
|||||||
* @return PlaceholderAPIPlugin instance
|
* @return PlaceholderAPIPlugin instance
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static PlaceholderAPIPlugin getInstance()
|
public static PlaceholderAPIPlugin getInstance() {
|
||||||
{
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the configurable {@linkplain String} value that should be returned when a boolean is true
|
* Get the configurable {@linkplain String} value that should be returned when a boolean is true
|
||||||
*
|
*
|
||||||
* @return string value of true
|
* @return string value of true
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String booleanTrue()
|
public static String booleanTrue() {
|
||||||
{
|
|
||||||
return getInstance().getPlaceholderAPIConfig().booleanTrue();
|
return getInstance().getPlaceholderAPIConfig().booleanTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,8 +107,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin
|
|||||||
* @return string value of false
|
* @return string value of false
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String booleanFalse()
|
public static String booleanFalse() {
|
||||||
{
|
|
||||||
return getInstance().getPlaceholderAPIConfig().booleanFalse();
|
return getInstance().getPlaceholderAPIConfig().booleanFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,23 +118,141 @@ public final class PlaceholderAPIPlugin extends JavaPlugin
|
|||||||
* @return date format
|
* @return date format
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static SimpleDateFormat getDateFormat()
|
public static SimpleDateFormat getDateFormat() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
return new SimpleDateFormat(getInstance().getPlaceholderAPIConfig().dateFormat());
|
return new SimpleDateFormat(getInstance().getPlaceholderAPIConfig().dateFormat());
|
||||||
}
|
} catch (final IllegalArgumentException ex) {
|
||||||
catch (final IllegalArgumentException ex)
|
|
||||||
{
|
|
||||||
getInstance().getLogger().log(Level.WARNING, "configured date format is invalid", ex);
|
getInstance().getLogger().log(Level.WARNING, "configured date format is invalid", ex);
|
||||||
return new SimpleDateFormat("MM/dd/yy HH:mm:ss");
|
return new SimpleDateFormat("MM/dd/yy HH:mm:ss");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Version getServerVersion() {
|
||||||
public static Version getServerVersion()
|
|
||||||
{
|
|
||||||
return VERSION;
|
return VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
instance = this;
|
||||||
|
|
||||||
|
saveDefaultConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
setupCommand();
|
||||||
|
setupMetrics();
|
||||||
|
setupExpansions();
|
||||||
|
|
||||||
|
adventure = BukkitAudiences.create(this);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
adventure.close();
|
||||||
|
adventure = null;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public BukkitAudiences getAdventure() {
|
||||||
|
if(adventure == null) {
|
||||||
|
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return adventure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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, 438);
|
||||||
|
metrics.addCustomChart(new SimplePie("using_expansion_cloud",
|
||||||
|
() -> getPlaceholderAPIConfig().isCloudEnabled() ? "yes" : "no"));
|
||||||
|
|
||||||
|
metrics.addCustomChart(new SimplePie("using_spigot", () -> getServerVersion().isSpigot() ? "yes" : "no"));
|
||||||
|
|
||||||
|
metrics.addCustomChart(new 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -22,55 +22,22 @@ package me.clip.placeholderapi;
|
|||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
public abstract class PlaceholderHook {
|
||||||
* @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
|
@Nullable
|
||||||
@Deprecated
|
public String onRequest(final OfflinePlayer player, @NotNull final String params) {
|
||||||
public String onRequest(@Nullable final OfflinePlayer player, @NotNull final String params)
|
if (player != null && player.isOnline()) {
|
||||||
{
|
|
||||||
if (player != null && player.isOnline())
|
|
||||||
{
|
|
||||||
return onPlaceholderRequest((Player) player, params);
|
return onPlaceholderRequest((Player) player, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
return onPlaceholderRequest(null, 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
|
@Nullable
|
||||||
@Deprecated
|
public String onPlaceholderRequest(final Player player, @NotNull final String params) {
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
|
||||||
public String onPlaceholderRequest(@Nullable final Player player, @NotNull final String params)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -22,18 +22,16 @@ package me.clip.placeholderapi.commands;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public abstract class PlaceholderCommand {
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class PlaceholderCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final String label;
|
private final String label;
|
||||||
@@ -44,75 +42,66 @@ public abstract class PlaceholderCommand
|
|||||||
private String permission;
|
private String permission;
|
||||||
|
|
||||||
|
|
||||||
protected PlaceholderCommand(@NotNull final String label, @NotNull final String... alias)
|
protected PlaceholderCommand(@NotNull final String label, @NotNull final String... alias) {
|
||||||
{
|
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.alias = Sets.newHashSet(alias);
|
this.alias = Sets.newHashSet(alias);
|
||||||
|
|
||||||
setPermission("placeholderapi." + label);
|
setPermission("placeholderapi." + label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public final String getLabel()
|
public final String getLabel() {
|
||||||
{
|
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
public final Set<String> getAlias()
|
public final Set<String> getAlias() {
|
||||||
{
|
|
||||||
return ImmutableSet.copyOf(alias);
|
return ImmutableSet.copyOf(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
public final Set<String> getLabels()
|
public final Set<String> getLabels() {
|
||||||
{
|
|
||||||
return ImmutableSet.<String>builder().add(label).addAll(alias).build();
|
return ImmutableSet.<String>builder().add(label).addAll(alias).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public final String getPermission()
|
public final String getPermission() {
|
||||||
{
|
|
||||||
return permission;
|
return permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermission(@NotNull final String permission)
|
public void setPermission(@NotNull final String permission) {
|
||||||
{
|
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
@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)
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -22,6 +22,13 @@ package me.clip.placeholderapi.commands;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.impl.cloud.CommandECloud;
|
import me.clip.placeholderapi.commands.impl.cloud.CommandECloud;
|
||||||
import me.clip.placeholderapi.commands.impl.local.CommandDump;
|
import me.clip.placeholderapi.commands.impl.local.CommandDump;
|
||||||
@@ -41,11 +48,7 @@ import org.bukkit.command.TabCompleter;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.*;
|
public final class PlaceholderCommandRouter implements CommandExecutor, TabCompleter {
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public final class PlaceholderCommandRouter implements CommandExecutor, TabCompleter
|
|
||||||
{
|
|
||||||
|
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
private static final List<PlaceholderCommand> COMMANDS = ImmutableList.of(new CommandHelp(),
|
private static final List<PlaceholderCommand> COMMANDS = ImmutableList.of(new CommandHelp(),
|
||||||
@@ -67,14 +70,12 @@ public final class PlaceholderCommandRouter implements CommandExecutor, TabCompl
|
|||||||
private final Map<String, PlaceholderCommand> commands;
|
private final Map<String, PlaceholderCommand> commands;
|
||||||
|
|
||||||
|
|
||||||
public PlaceholderCommandRouter(@NotNull final PlaceholderAPIPlugin plugin)
|
public PlaceholderCommandRouter(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
final ImmutableMap.Builder<String, PlaceholderCommand> commands = ImmutableMap.builder();
|
final ImmutableMap.Builder<String, PlaceholderCommand> commands = ImmutableMap.builder();
|
||||||
|
|
||||||
for (final PlaceholderCommand command : COMMANDS)
|
for (final PlaceholderCommand command : COMMANDS) {
|
||||||
{
|
|
||||||
command.getLabels().forEach(label -> commands.put(label, command));
|
command.getLabels().forEach(label -> commands.put(label, command));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,13 +84,11 @@ public final class PlaceholderCommandRouter implements CommandExecutor, TabCompl
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull final CommandSender sender, @NotNull final Command command, @NotNull final String alias, @NotNull final String[] args)
|
public boolean onCommand(@NotNull final CommandSender sender, @NotNull final Command command,
|
||||||
{
|
@NotNull final String alias, @NotNull final String[] args) {
|
||||||
if (args.length == 0)
|
if (args.length == 0) {
|
||||||
{
|
|
||||||
final PlaceholderCommand fallback = commands.get("version");
|
final PlaceholderCommand fallback = commands.get("version");
|
||||||
if (fallback != null)
|
if (fallback != null) {
|
||||||
{
|
|
||||||
fallback.evaluate(plugin, sender, "", Collections.emptyList());
|
fallback.evaluate(plugin, sender, "", Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,42 +98,42 @@ public final class PlaceholderCommandRouter implements CommandExecutor, TabCompl
|
|||||||
final String search = args[0].toLowerCase();
|
final String search = args[0].toLowerCase();
|
||||||
final PlaceholderCommand target = commands.get(search);
|
final PlaceholderCommand target = commands.get(search);
|
||||||
|
|
||||||
if (target == null)
|
if (target == null) {
|
||||||
{
|
|
||||||
Msg.msg(sender, "&cUnknown command &7" + search);
|
Msg.msg(sender, "&cUnknown command &7" + search);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String permission = target.getPermission();
|
final String permission = target.getPermission();
|
||||||
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission))
|
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission)) {
|
||||||
{
|
|
||||||
Msg.msg(sender, "&cYou do not have permission to do this!");
|
Msg.msg(sender, "&cYou do not have permission to do this!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.evaluate(plugin, sender, search, Arrays.asList(Arrays.copyOfRange(args, 1, args.length)));
|
target
|
||||||
|
.evaluate(plugin, sender, search, Arrays.asList(Arrays.copyOfRange(args, 1, args.length)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@NotNull final CommandSender sender, @NotNull final Command command, @NotNull final String alias, @NotNull final String[] args)
|
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<>();
|
final List<String> suggestions = new ArrayList<>();
|
||||||
|
|
||||||
if (args.length > 1)
|
if (args.length > 1) {
|
||||||
{
|
|
||||||
final PlaceholderCommand target = this.commands.get(args[0].toLowerCase());
|
final PlaceholderCommand target = this.commands.get(args[0].toLowerCase());
|
||||||
|
|
||||||
if (target != null)
|
if (target != null) {
|
||||||
{
|
target.complete(plugin, sender, args[0].toLowerCase(),
|
||||||
target.complete(plugin, sender, args[0].toLowerCase(), Arrays.asList(Arrays.copyOfRange(args, 1, args.length)), suggestions);
|
Arrays.asList(Arrays.copyOfRange(args, 1, args.length)), suggestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return suggestions;
|
return suggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Stream<String> targets = PlaceholderCommand.filterByPermission(sender, commands.values().stream()).map(PlaceholderCommand::getLabels).flatMap(Collection::stream);
|
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]);
|
PlaceholderCommand.suggestByParameter(targets, suggestions, args.length == 0 ? null : args[0]);
|
||||||
|
|
||||||
return suggestions;
|
return suggestions;
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -22,6 +22,10 @@ package me.clip.placeholderapi.commands.impl.cloud;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
@@ -29,16 +33,11 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.Collection;
|
public final class CommandECloud extends PlaceholderCommand {
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public final class CommandECloud extends PlaceholderCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
private static final List<PlaceholderCommand> COMMANDS = ImmutableList.of(new CommandECloudClear(),
|
private static final List<PlaceholderCommand> COMMANDS = ImmutableList
|
||||||
|
.of(new CommandECloudClear(),
|
||||||
new CommandECloudToggle(),
|
new CommandECloudToggle(),
|
||||||
new CommandECloudStatus(),
|
new CommandECloudStatus(),
|
||||||
new CommandECloudUpdate(),
|
new CommandECloudUpdate(),
|
||||||
@@ -48,9 +47,9 @@ public final class CommandECloud extends PlaceholderCommand
|
|||||||
new CommandECloudExpansionList(),
|
new CommandECloudExpansionList(),
|
||||||
new CommandECloudExpansionPlaceholders());
|
new CommandECloudExpansionPlaceholders());
|
||||||
|
|
||||||
static
|
static {
|
||||||
{
|
COMMANDS
|
||||||
COMMANDS.forEach(command -> command.setPermission("placeholderapi.ecloud." + command.getLabel()));
|
.forEach(command -> command.setPermission("placeholderapi.ecloud." + command.getLabel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -58,14 +57,12 @@ public final class CommandECloud extends PlaceholderCommand
|
|||||||
private final Map<String, PlaceholderCommand> commands;
|
private final Map<String, PlaceholderCommand> commands;
|
||||||
|
|
||||||
|
|
||||||
public CommandECloud()
|
public CommandECloud() {
|
||||||
{
|
|
||||||
super("ecloud");
|
super("ecloud");
|
||||||
|
|
||||||
final ImmutableMap.Builder<String, PlaceholderCommand> commands = ImmutableMap.builder();
|
final ImmutableMap.Builder<String, PlaceholderCommand> commands = ImmutableMap.builder();
|
||||||
|
|
||||||
for (final PlaceholderCommand command : COMMANDS)
|
for (final PlaceholderCommand command : COMMANDS) {
|
||||||
{
|
|
||||||
command.getLabels().forEach(label -> commands.put(label, command));
|
command.getLabels().forEach(label -> commands.put(label, command));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,13 +71,15 @@ public final class CommandECloud extends PlaceholderCommand
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.isEmpty())
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
if (params.isEmpty()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&b&lPlaceholderAPI &8- &7eCloud Help Menu &8- ",
|
"&b&lPlaceholderAPI &8- &7eCloud Help Menu &8- ",
|
||||||
" ",
|
" ",
|
||||||
|
"&b/papi &fenable/disable/toggle",
|
||||||
|
" &7&oEnable or disable the eCloud",
|
||||||
"&b/papi &fecloud status",
|
"&b/papi &fecloud status",
|
||||||
" &7&oView status of the eCloud",
|
" &7&oView status of the eCloud",
|
||||||
"&b/papi &fecloud list <all/{author}/installed> {page}",
|
"&b/papi &fecloud list <all/{author}/installed> {page}",
|
||||||
@@ -91,6 +90,8 @@ public final class CommandECloud extends PlaceholderCommand
|
|||||||
" &7&oView placeholders for an expansion",
|
" &7&oView placeholders for an expansion",
|
||||||
"&b/papi &fecloud download <expansion name> {version}",
|
"&b/papi &fecloud download <expansion name> {version}",
|
||||||
" &7&oDownload an expansion from the eCloud",
|
" &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",
|
"&b/papi &fecloud refresh",
|
||||||
" &7&oFetch the most up to date list of expansions available.",
|
" &7&oFetch the most up to date list of expansions available.",
|
||||||
"&b/papi &fecloud clear",
|
"&b/papi &fecloud clear",
|
||||||
@@ -102,21 +103,19 @@ public final class CommandECloud extends PlaceholderCommand
|
|||||||
final String search = params.get(0).toLowerCase();
|
final String search = params.get(0).toLowerCase();
|
||||||
final PlaceholderCommand target = commands.get(search);
|
final PlaceholderCommand target = commands.get(search);
|
||||||
|
|
||||||
if (target == null)
|
if (target == null) {
|
||||||
{
|
|
||||||
Msg.msg(sender, "&cUnknown command &7ecloud " + search);
|
Msg.msg(sender, "&cUnknown command &7ecloud " + search);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String permission = target.getPermission();
|
final String permission = target.getPermission();
|
||||||
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission))
|
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission)) {
|
||||||
{
|
|
||||||
Msg.msg(sender, "&cYou do not have permission to do this!");
|
Msg.msg(sender, "&cYou do not have permission to do this!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(target instanceof CommandECloudToggle) && !plugin.getPlaceholderAPIConfig().isCloudEnabled())
|
if (!(target instanceof CommandECloudToggle) && !plugin.getPlaceholderAPIConfig()
|
||||||
{
|
.isCloudEnabled()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cThe eCloud Manager is not enabled!");
|
"&cThe eCloud Manager is not enabled!");
|
||||||
return;
|
return;
|
||||||
@@ -126,11 +125,12 @@ public final class CommandECloud extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() <= 1)
|
@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);
|
final Stream<String> targets = filterByPermission(sender, commands.values().stream())
|
||||||
|
.map(PlaceholderCommand::getLabels).flatMap(Collection::stream);
|
||||||
suggestByParameter(targets, suggestions, params.isEmpty() ? null : params.get(0));
|
suggestByParameter(targets, suggestions, params.isEmpty() ? null : params.get(0));
|
||||||
|
|
||||||
return; // send sub commands
|
return; // send sub commands
|
||||||
@@ -139,8 +139,7 @@ public final class CommandECloud extends PlaceholderCommand
|
|||||||
final String search = params.get(0).toLowerCase();
|
final String search = params.get(0).toLowerCase();
|
||||||
final PlaceholderCommand target = commands.get(search);
|
final PlaceholderCommand target = commands.get(search);
|
||||||
|
|
||||||
if (target == null)
|
if (target == null) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
@@ -27,19 +28,16 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandECloudClear extends PlaceholderCommand {
|
||||||
|
|
||||||
public final class CommandECloudClear extends PlaceholderCommand
|
public CommandECloudClear() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandECloudClear()
|
|
||||||
{
|
|
||||||
super("clear");
|
super("clear");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
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().clean();
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&aThe eCloud cache has been cleared!");
|
"&aThe eCloud cache has been cleared!");
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||||
@@ -28,93 +31,85 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandECloudDownload extends PlaceholderCommand {
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public final class CommandECloudDownload extends PlaceholderCommand
|
public CommandECloudDownload() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandECloudDownload()
|
|
||||||
{
|
|
||||||
super("download");
|
super("download");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.isEmpty())
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
if (params.isEmpty()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cYou must supply the name of an eCloud expansion.");
|
"&cYou must supply the name of an expansion.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CloudExpansion expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).orElse(null);
|
final CloudExpansion expansion = plugin.getCloudExpansionManager()
|
||||||
if (expansion == null)
|
.findCloudExpansionByName(params.get(0)).orElse(null);
|
||||||
{
|
if (expansion == null) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cCould not find expansion named: &f" + params.get(0));
|
"&cFailed to find an expansion named: &f" + params.get(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CloudExpansion.Version version;
|
final CloudExpansion.Version version;
|
||||||
if (params.size() < 2)
|
if (params.size() < 2) {
|
||||||
{
|
|
||||||
version = expansion.getVersion(expansion.getLatestVersion());
|
version = expansion.getVersion(expansion.getLatestVersion());
|
||||||
if (version == null)
|
if (version == null) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cCould not find latest version for expansion.");
|
"&cCould not find latest version for expansion.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
version = expansion.getVersion(params.get(1));
|
version = expansion.getVersion(params.get(1));
|
||||||
if (version == null)
|
if (version == null) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cCould not find specified version: &f" + params.get(1),
|
"&cCould not find specified version: &f" + params.get(1),
|
||||||
"&7Versions: &a" + expansion.getAvailableVersions());
|
"&7Available versions: &f" + expansion.getAvailableVersions());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getCloudExpansionManager().downloadExpansion(expansion, version).whenComplete((file, exception) -> {
|
plugin.getCloudExpansionManager().downloadExpansion(expansion, version)
|
||||||
if (exception != null)
|
.whenComplete((file, exception) -> {
|
||||||
{
|
if (exception != null) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cFailed to download expansion: &e" + exception.getMessage());
|
"&cFailed to download expansion: &f" + exception.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&aSuccessfully downloaded expansion to file: &e" + file.getName());
|
"&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.getCloudExpansionManager().clean();
|
plugin.getCloudExpansionManager().clean();
|
||||||
plugin.getCloudExpansionManager().fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
plugin.getCloudExpansionManager()
|
||||||
|
.fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() > 2)
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
{
|
if (params.size() > 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.size() <= 1)
|
if (params.size() <= 1) {
|
||||||
{
|
final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values()
|
||||||
final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values().stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
|
.stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
|
||||||
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0));
|
final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager()
|
||||||
if (!expansion.isPresent())
|
.findCloudExpansionByName(params.get(0));
|
||||||
{
|
if (!expansion.isPresent()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||||
@@ -28,31 +31,25 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandECloudExpansionInfo extends PlaceholderCommand {
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public final class CommandECloudExpansionInfo extends PlaceholderCommand
|
public CommandECloudExpansionInfo() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandECloudExpansionInfo()
|
|
||||||
{
|
|
||||||
super("info");
|
super("info");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.isEmpty())
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
if (params.isEmpty()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cYou must specify the name of the expansion.");
|
"&cYou must specify the name of the expansion.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CloudExpansion expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).orElse(null);
|
final CloudExpansion expansion = plugin.getCloudExpansionManager()
|
||||||
if (expansion == null)
|
.findCloudExpansionByName(params.get(0)).orElse(null);
|
||||||
{
|
if (expansion == null) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cThere is no expansion with the name: &f" + params.get(0));
|
"&cThere is no expansion with the name: &f" + params.get(0));
|
||||||
return;
|
return;
|
||||||
@@ -71,8 +68,7 @@ public final class CommandECloudExpansionInfo extends PlaceholderCommand
|
|||||||
.append(expansion.isVerified() ? "&a&l✔" : "&c&l❌")
|
.append(expansion.isVerified() ? "&a&l✔" : "&c&l❌")
|
||||||
.append('\n');
|
.append('\n');
|
||||||
|
|
||||||
if (params.size() < 2)
|
if (params.size() < 2) {
|
||||||
{
|
|
||||||
builder.append("&bLatest Version: &f")
|
builder.append("&bLatest Version: &f")
|
||||||
.append(expansion.getLatestVersion())
|
.append(expansion.getLatestVersion())
|
||||||
.append('\n')
|
.append('\n')
|
||||||
@@ -83,15 +79,12 @@ public final class CommandECloudExpansionInfo extends PlaceholderCommand
|
|||||||
.append("&bRelease Notes: &f")
|
.append("&bRelease Notes: &f")
|
||||||
.append(expansion.getVersion().getReleaseNotes())
|
.append(expansion.getVersion().getReleaseNotes())
|
||||||
.append('\n');
|
.append('\n');
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
final CloudExpansion.Version version = expansion.getVersion(params.get(1));
|
final CloudExpansion.Version version = expansion.getVersion(params.get(1));
|
||||||
if (version == null)
|
if (version == null) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cCould not find specified version: &f" + params.get(1),
|
"&cCould not find specified version: &f" + params.get(1),
|
||||||
"&7Versions: &a" + expansion.getAvailableVersions());
|
"&aVersions: &f" + expansion.getAvailableVersions());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,23 +103,23 @@ public final class CommandECloudExpansionInfo extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() > 2)
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
{
|
if (params.size() > 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.size() <= 1)
|
if (params.size() <= 1) {
|
||||||
{
|
final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values()
|
||||||
final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values().stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
|
.stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
|
||||||
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0));
|
final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager()
|
||||||
if (!expansion.isPresent())
|
.findCloudExpansionByName(params.get(0));
|
||||||
{
|
if (!expansion.isPresent()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -25,6 +25,12 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.configuration.ExpansionSort;
|
import me.clip.placeholderapi.configuration.ExpansionSort;
|
||||||
@@ -32,35 +38,28 @@ import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
|||||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||||
import me.clip.placeholderapi.util.Format;
|
import me.clip.placeholderapi.util.Format;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
import me.rayzr522.jsonmessage.JSONMessage;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import static net.kyori.adventure.text.Component.*;
|
||||||
import java.util.ArrayList;
|
import static net.kyori.adventure.text.format.NamedTextColor.*;
|
||||||
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
|
public final class CommandECloudExpansionList extends PlaceholderCommand {
|
||||||
{
|
|
||||||
|
|
||||||
private static final int PAGE_SIZE = 10;
|
private static final int PAGE_SIZE = 10;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final Function<CloudExpansion, Object> EXPANSION_NAME =
|
private static final Function<CloudExpansion, Object> EXPANSION_NAME =
|
||||||
expansion -> (expansion.shouldUpdate() ? "&6" : expansion.hasExpansion() ? "&a" : "&7") + expansion.getName();
|
expansion -> (expansion.shouldUpdate() ? "&6" : expansion.hasExpansion() ? "&a" : "&7")
|
||||||
|
+ expansion.getName();
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final Function<CloudExpansion, Object> EXPANSION_AUTHOR =
|
private static final Function<CloudExpansion, Object> EXPANSION_AUTHOR =
|
||||||
expansion -> "&f" + expansion.getAuthor();
|
expansion -> "&f" + expansion.getAuthor();
|
||||||
@@ -72,43 +71,202 @@ public final class CommandECloudExpansionList extends PlaceholderCommand
|
|||||||
expansion -> "&f" + expansion.getLatestVersion();
|
expansion -> "&f" + expansion.getLatestVersion();
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final Function<CloudExpansion, Object> EXPANSION_CURRENT_VERSION =
|
private static final Function<CloudExpansion, Object> EXPANSION_CURRENT_VERSION =
|
||||||
expansion -> "&f" + PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByName(expansion.getName()).map(PlaceholderExpansion::getVersion).orElse("Unknown");
|
expansion -> "&f" + PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()
|
||||||
|
.findExpansionByName(expansion.getName()).map(PlaceholderExpansion::getVersion)
|
||||||
|
.orElse("Unknown");
|
||||||
|
|
||||||
|
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
private static final Set<String> OPTIONS = ImmutableSet.of("all", "installed");
|
private static final Set<String> OPTIONS = ImmutableSet.of("all", "installed");
|
||||||
|
|
||||||
|
|
||||||
public CommandECloudExpansionList()
|
public CommandECloudExpansionList() {
|
||||||
{
|
|
||||||
super("list");
|
super("list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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 &f")
|
||||||
|
.append(target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page == -1) {
|
||||||
|
builder.append('\n');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.append(" &bPage&7: &a")
|
||||||
|
.append(page)
|
||||||
|
.append("&r");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Component getMessage(@NotNull final List<CloudExpansion> expansions,
|
||||||
|
final int page, final int limit, @NotNull final String target) {
|
||||||
|
final SimpleDateFormat format = PlaceholderAPIPlugin.getDateFormat();
|
||||||
|
|
||||||
|
final TextComponent.Builder message = text();
|
||||||
|
|
||||||
|
for (int index = 0; index < expansions.size(); index++) {
|
||||||
|
final CloudExpansion expansion = expansions.get(index);
|
||||||
|
final TextComponent.Builder line = text();
|
||||||
|
|
||||||
|
final int expansionNumber = index + ((page - 1) * PAGE_SIZE) + 1;
|
||||||
|
line.append(text(expansionNumber + ". ", DARK_GRAY));
|
||||||
|
|
||||||
|
final NamedTextColor expansionColour;
|
||||||
|
|
||||||
|
if (expansion.shouldUpdate()) {
|
||||||
|
expansionColour = GOLD;
|
||||||
|
} else {
|
||||||
|
if (expansion.hasExpansion()) {
|
||||||
|
expansionColour = GREEN;
|
||||||
|
} else {
|
||||||
|
expansionColour = GRAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
line.append(text(expansion.getName(), expansionColour));
|
||||||
|
|
||||||
|
line.clickEvent(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.isVerified() ? "✔" : "❌", expansion.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.append(newline());
|
||||||
|
}
|
||||||
|
|
||||||
|
message.append(line.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (limit > 1) {
|
||||||
|
message.append(newline());
|
||||||
|
|
||||||
|
final TextComponent.Builder left = text("â—€", 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.append(left, text(" " + page + " ", GREEN), right);
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.isEmpty())
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
if (params.isEmpty()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cYou must specify an option. [all, {author}, installed]");
|
"&cYou must specify an option. [all, {author}, installed]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final boolean installed = params.get(0).equalsIgnoreCase("installed");
|
final boolean installed = params.get(0).equalsIgnoreCase("installed");
|
||||||
final List<CloudExpansion> expansions = Lists.newArrayList(getExpansions(params.get(0), plugin));
|
final List<CloudExpansion> expansions = Lists
|
||||||
|
.newArrayList(getExpansions(params.get(0), plugin));
|
||||||
|
|
||||||
if (expansions.isEmpty())
|
if (expansions.isEmpty()) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cNo expansions available to list.");
|
"&cNo expansions available to list.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
expansions.sort(plugin.getPlaceholderAPIConfig().getExpansionSort().orElse(ExpansionSort.LATEST));
|
expansions
|
||||||
|
.sort(plugin.getPlaceholderAPIConfig().getExpansionSort().orElse(ExpansionSort.LATEST));
|
||||||
|
|
||||||
if (!(sender instanceof Player) && params.size() < 2)
|
if (!(sender instanceof Player) && params.size() < 2) {
|
||||||
{
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
addExpansionTitle(builder, params.get(0), -1);
|
addExpansionTitle(builder, params.get(0), -1);
|
||||||
@@ -124,16 +282,12 @@ public final class CommandECloudExpansionList extends PlaceholderCommand
|
|||||||
|
|
||||||
final int page;
|
final int page;
|
||||||
|
|
||||||
if (params.size() < 2)
|
if (params.size() < 2) {
|
||||||
{
|
|
||||||
page = 1;
|
page = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
//noinspection UnstableApiUsage
|
//noinspection UnstableApiUsage
|
||||||
final Integer parsed = Ints.tryParse(params.get(1));
|
final Integer parsed = Ints.tryParse(params.get(1));
|
||||||
if (parsed == null)
|
if (parsed == null) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cPage number must be an integer.");
|
"&cPage number must be an integer.");
|
||||||
return;
|
return;
|
||||||
@@ -141,8 +295,7 @@ public final class CommandECloudExpansionList extends PlaceholderCommand
|
|||||||
|
|
||||||
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
||||||
|
|
||||||
if (parsed < 1 || parsed > limit)
|
if (parsed < 1 || parsed > limit) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cPage number must be in the range &8[&a1&7..&a" + limit + "&8]");
|
"&cPage number must be in the range &8[&a1&7..&a" + limit + "&8]");
|
||||||
return;
|
return;
|
||||||
@@ -156,8 +309,7 @@ public final class CommandECloudExpansionList extends PlaceholderCommand
|
|||||||
|
|
||||||
addExpansionTitle(builder, params.get(0), page);
|
addExpansionTitle(builder, params.get(0), page);
|
||||||
|
|
||||||
if (!(sender instanceof Player))
|
if (!(sender instanceof Player)) {
|
||||||
{
|
|
||||||
addExpansionTable(values,
|
addExpansionTable(values,
|
||||||
builder,
|
builder,
|
||||||
((page - 1) * PAGE_SIZE) + 1,
|
((page - 1) * PAGE_SIZE) + 1,
|
||||||
@@ -173,188 +325,28 @@ public final class CommandECloudExpansionList extends PlaceholderCommand
|
|||||||
|
|
||||||
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
||||||
|
|
||||||
final JSONMessage message = getMessage(values, page, limit, params.get(0));
|
final Component message = getMessage(values, page, limit, params.get(0));
|
||||||
message.send(((Player) sender));
|
plugin.getAdventure().player((Player) sender).sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() > 2)
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
{
|
if (params.size() > 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.size() <= 1)
|
if (params.size() <= 1) {
|
||||||
{
|
suggestByParameter(
|
||||||
suggestByParameter(Sets.union(OPTIONS, plugin.getCloudExpansionManager().getCloudExpansionAuthors()).stream(), suggestions, params.isEmpty() ? null : params.get(0));
|
Sets.union(OPTIONS, plugin.getCloudExpansionManager().getCloudExpansionAuthors())
|
||||||
|
.stream(), suggestions, params.isEmpty() ? null : params.get(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestByParameter(IntStream.rangeClosed(1, (int) Math.ceil((double) getExpansions(params.get(0), plugin).size() / PAGE_SIZE)).mapToObj(Objects::toString), suggestions, params.get(1));
|
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -21,6 +21,9 @@
|
|||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||||
@@ -29,57 +32,52 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandECloudExpansionPlaceholders extends PlaceholderCommand {
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public final class CommandECloudExpansionPlaceholders extends PlaceholderCommand
|
public CommandECloudExpansionPlaceholders() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandECloudExpansionPlaceholders()
|
|
||||||
{
|
|
||||||
super("placeholders");
|
super("placeholders");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.isEmpty())
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
if (params.isEmpty()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cYou must specify the name of the expansion.");
|
"&cYou must specify the name of the expansion.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CloudExpansion expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).orElse(null);
|
final CloudExpansion expansion = plugin.getCloudExpansionManager()
|
||||||
if (expansion == null)
|
.findCloudExpansionByName(params.get(0)).orElse(null);
|
||||||
{
|
if (expansion == null) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cThere is no expansion with the name: &f" + params.get(0));
|
"&cThere is no expansion with the name: &f" + params.get(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> placeholders = expansion.getPlaceholders();
|
final List<String> placeholders = expansion.getPlaceholders();
|
||||||
if (placeholders == null || placeholders.isEmpty())
|
if (placeholders == null || placeholders.isEmpty()) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cThat expansion does not have placeholders listed.");
|
"&cThe expansion specified does not have placeholders listed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<List<String>> partitions = Lists.partition(placeholders.stream().sorted().collect(Collectors.toList()), 10);
|
final List<List<String>> partitions = Lists
|
||||||
|
.partition(placeholders.stream().sorted().collect(Collectors.toList()), 10);
|
||||||
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&6" + placeholders.size() + "&7 placeholders: &a",
|
"&6" + placeholders.size() + "&7 placeholders: &a",
|
||||||
partitions.stream().map(partition -> " " + String.join(", ", partition)).collect(Collectors.joining("\n")));
|
partitions.stream().map(partition -> String.join(", ", partition))
|
||||||
|
.collect(Collectors.joining("\n")));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() > 1)
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
{
|
if (params.size() > 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
@@ -27,24 +28,22 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandECloudRefresh extends PlaceholderCommand {
|
||||||
|
|
||||||
public final class CommandECloudRefresh extends PlaceholderCommand
|
public CommandECloudRefresh() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandECloudRefresh()
|
|
||||||
{
|
|
||||||
super("refresh");
|
super("refresh");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
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().clean();
|
||||||
plugin.getCloudExpansionManager().fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
plugin.getCloudExpansionManager()
|
||||||
|
.fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
||||||
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&aThe eCloud Manager has been refreshed!");
|
"&aThe eCloud manager has been refreshed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
|
import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
|
||||||
@@ -28,19 +29,16 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandECloudStatus extends PlaceholderCommand {
|
||||||
|
|
||||||
public final class CommandECloudStatus extends PlaceholderCommand
|
public CommandECloudStatus() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandECloudStatus()
|
|
||||||
{
|
|
||||||
super("status");
|
super("status");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
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 CloudExpansionManager manager = plugin.getCloudExpansionManager();
|
||||||
|
|
||||||
final int updateCount = manager.getCloudUpdateCount();
|
final int updateCount = manager.getCloudUpdateCount();
|
||||||
@@ -49,15 +47,18 @@ public final class CommandECloudStatus extends PlaceholderCommand
|
|||||||
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
builder.append("&bThere are &a").append(expansionCount).append("&b expansions available on the eCloud.").append('\n');
|
builder.append("&bThere are &a").append(expansionCount)
|
||||||
builder.append("&7A total of &f").append(authorCount).append("&7 authors have contributed to the eCloud.").append('\n');
|
.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)
|
if (updateCount > 0) {
|
||||||
{
|
builder.append("&eYou have &f").append(updateCount)
|
||||||
builder.append("&eYou have &a").append(updateCount).append("&e expansions installed that have updates available.");
|
.append(updateCount > 1 ? "&e expansions" : "&e expansion").append("installed that ")
|
||||||
|
.append(updateCount > 1 ? "have an" : "has an").append(" update available.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg.msg(sender,builder.toString());
|
Msg.msg(sender, builder.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
@@ -27,24 +28,20 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandECloudToggle extends PlaceholderCommand {
|
||||||
|
|
||||||
public final class CommandECloudToggle extends PlaceholderCommand
|
public CommandECloudToggle() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandECloudToggle()
|
|
||||||
{
|
|
||||||
super("toggle", "enable", "disable");
|
super("toggle", "enable", "disable");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
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 desiredState;
|
||||||
final boolean currentState = plugin.getPlaceholderAPIConfig().isCloudEnabled();
|
final boolean currentState = plugin.getPlaceholderAPIConfig().isCloudEnabled();
|
||||||
|
|
||||||
switch (alias.toLowerCase())
|
switch (alias.toLowerCase()) {
|
||||||
{
|
|
||||||
case "enable":
|
case "enable":
|
||||||
desiredState = true;
|
desiredState = true;
|
||||||
break;
|
break;
|
||||||
@@ -56,20 +53,16 @@ public final class CommandECloudToggle extends PlaceholderCommand
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desiredState == currentState)
|
if (desiredState == currentState) {
|
||||||
{
|
|
||||||
Msg.msg(sender, "&7The eCloud Manager is already " + (desiredState ? "enabled" : "disabled"));
|
Msg.msg(sender, "&7The eCloud Manager is already " + (desiredState ? "enabled" : "disabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getPlaceholderAPIConfig().setCloudEnabled(desiredState);
|
plugin.getPlaceholderAPIConfig().setCloudEnabled(desiredState);
|
||||||
|
|
||||||
if (desiredState)
|
if (desiredState) {
|
||||||
{
|
|
||||||
plugin.getCloudExpansionManager().load();
|
plugin.getCloudExpansionManager().load();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
plugin.getCloudExpansionManager().kill();
|
plugin.getCloudExpansionManager().kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -21,6 +21,12 @@
|
|||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
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;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
@@ -32,30 +38,29 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
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.
|
* please don't flame me for this code, I will fix this shit later.
|
||||||
*/
|
*/
|
||||||
public final class CommandECloudUpdate extends PlaceholderCommand
|
public final class CommandECloudUpdate extends PlaceholderCommand {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandECloudUpdate()
|
public CommandECloudUpdate() {
|
||||||
{
|
|
||||||
super("update");
|
super("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.getCloudExpansionManager()
|
||||||
|
.downloadExpansion(expansion, expansion.getVersion()))
|
||||||
|
.map(future -> future.thenCompose(plugin.getLocalExpansionManager()::findExpansionInFile))
|
||||||
|
.collect(Futures.collector());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.isEmpty())
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
if (params.isEmpty()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cYou must define 'all' or the name of an expansion to update.");
|
"&cYou must define 'all' or the name of an expansion to update.");
|
||||||
return;
|
return;
|
||||||
@@ -65,32 +70,29 @@ public final class CommandECloudUpdate extends PlaceholderCommand
|
|||||||
final List<CloudExpansion> expansions = new ArrayList<>();
|
final List<CloudExpansion> expansions = new ArrayList<>();
|
||||||
|
|
||||||
// gather target expansions
|
// gather target expansions
|
||||||
if (multiple)
|
if (multiple) {
|
||||||
{
|
|
||||||
expansions.addAll(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
|
expansions.addAll(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
|
||||||
}
|
} else {
|
||||||
else
|
plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0))
|
||||||
{
|
.ifPresent(expansions::add);
|
||||||
plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).ifPresent(expansions::add);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the ones that are the latest version
|
// remove the ones that are the latest version
|
||||||
expansions.removeIf(expansion -> !expansion.shouldUpdate());
|
expansions.removeIf(expansion -> !expansion.shouldUpdate());
|
||||||
|
|
||||||
if (expansions.isEmpty())
|
if (expansions.isEmpty()) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cNo updates available for " + (!multiple ? "this expansion." : "your active expansions."));
|
"&cNo updates available for " + (!multiple ? "this expansion."
|
||||||
|
: "your active expansions."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&aUpdating expansions: " + expansions.stream().map(CloudExpansion::getName).collect(Collectors.joining("&7, &6", "&8[&6", "&8]&r")));
|
"&aUpdating expansions: " + expansions.stream().map(CloudExpansion::getName)
|
||||||
|
.collect(Collectors.joining("&7, &6", "&8[&6", "&8]&r")));
|
||||||
|
|
||||||
Futures.onMainThread(plugin, downloadAndDiscover(expansions, plugin), (classes, exception) -> {
|
Futures.onMainThread(plugin, downloadAndDiscover(expansions, plugin), (classes, exception) -> {
|
||||||
if (exception != null)
|
if (exception != null) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cFailed to update expansions: &e" + exception.getMessage());
|
"&cFailed to update expansions: &e" + exception.getMessage());
|
||||||
return;
|
return;
|
||||||
@@ -99,7 +101,6 @@ public final class CommandECloudUpdate extends PlaceholderCommand
|
|||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&aSuccessfully downloaded updates, registering new versions.");
|
"&aSuccessfully downloaded updates, registering new versions.");
|
||||||
|
|
||||||
|
|
||||||
final String message = classes.stream()
|
final String message = classes.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(plugin.getLocalExpansionManager()::register)
|
.map(plugin.getLocalExpansionManager()::register)
|
||||||
@@ -115,31 +116,25 @@ public final class CommandECloudUpdate extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() > 1)
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
{
|
if (params.size() > 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<CloudExpansion> installed = Lists.newArrayList(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
|
final List<CloudExpansion> installed = Lists
|
||||||
|
.newArrayList(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
|
||||||
installed.removeIf(expansion -> !expansion.shouldUpdate());
|
installed.removeIf(expansion -> !expansion.shouldUpdate());
|
||||||
|
|
||||||
if (!installed.isEmpty() && (params.isEmpty() || "all".startsWith(params.get(0).toLowerCase())))
|
if (!installed.isEmpty() && (params.isEmpty() || "all"
|
||||||
{
|
.startsWith(params.get(0).toLowerCase()))) {
|
||||||
suggestions.add("all");
|
suggestions.add("all");
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestByParameter(installed.stream().map(CloudExpansion::getName).map(name -> name.replace(" ", "_")), suggestions, params.isEmpty() ? null : params.get(0));
|
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,7 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of PlaceholderAPI
|
||||||
|
*
|
||||||
|
* PlaceholderAPI
|
||||||
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
|
*
|
||||||
|
* PlaceholderAPI is 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;
|
package me.clip.placeholderapi.commands.impl.local;
|
||||||
|
|
||||||
import com.google.common.io.CharStreams;
|
import com.google.common.io.CharStreams;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
@@ -22,37 +43,40 @@ import java.time.Instant;
|
|||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.FormatStyle;
|
import java.time.format.FormatStyle;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class CommandDump extends PlaceholderCommand
|
public final class CommandDump extends PlaceholderCommand {
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final String URL = "https://paste.helpch.at/";
|
private static final String URL = "https://paste.helpch.at/";
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG)
|
private static final Gson gson = new Gson();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||||
|
.ofLocalizedDateTime(FormatStyle.LONG)
|
||||||
.withLocale(Locale.US)
|
.withLocale(Locale.US)
|
||||||
.withZone(ZoneId.of("UTC"));
|
.withZone(ZoneId.of("UTC"));
|
||||||
|
|
||||||
|
|
||||||
public CommandDump()
|
public CommandDump() {
|
||||||
{
|
|
||||||
super("dump");
|
super("dump");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
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) -> {
|
postDump(makeDump(plugin)).whenComplete((key, exception) -> {
|
||||||
if (exception != null)
|
if (exception != null) {
|
||||||
{
|
|
||||||
plugin.getLogger().log(Level.WARNING, "failed to post dump details", exception);
|
plugin.getLogger().log(Level.WARNING, "failed to post dump details", exception);
|
||||||
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
@@ -66,40 +90,34 @@ public final class CommandDump extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private CompletableFuture<String> postDump(@NotNull final String dump)
|
private CompletableFuture<String> postDump(@NotNull final String dump) {
|
||||||
{
|
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
try
|
try {
|
||||||
{
|
final HttpURLConnection connection = ((HttpURLConnection) new URL(URL + "documents")
|
||||||
final HttpURLConnection connection = ((HttpURLConnection) new URL(URL + "documents").openConnection());
|
.openConnection());
|
||||||
connection.setRequestMethod("POST");
|
connection.setRequestMethod("POST");
|
||||||
connection.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
|
connection.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
|
||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
|
|
||||||
connection.connect();
|
connection.connect();
|
||||||
|
|
||||||
try (final OutputStream stream = connection.getOutputStream())
|
try (final OutputStream stream = connection.getOutputStream()) {
|
||||||
{
|
|
||||||
stream.write(dump.getBytes(StandardCharsets.UTF_8));
|
stream.write(dump.getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
try (final InputStream stream = connection.getInputStream())
|
try (final InputStream stream = connection.getInputStream()) {
|
||||||
{
|
|
||||||
//noinspection UnstableApiUsage
|
//noinspection UnstableApiUsage
|
||||||
final String json = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
final String json = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||||
return JsonParser.parseString(json).getAsJsonObject().get("key").getAsString();
|
return gson.fromJson(json, JsonObject.class).get("key").getAsString();
|
||||||
}
|
}
|
||||||
}
|
} catch (final IOException ex) {
|
||||||
catch (final IOException ex)
|
|
||||||
{
|
|
||||||
throw new CompletionException(ex);
|
throw new CompletionException(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private String makeDump(@NotNull final PlaceholderAPIPlugin plugin)
|
private String makeDump(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||||
{
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
builder.append("Generated: ")
|
builder.append("Generated: ")
|
||||||
@@ -113,29 +131,33 @@ public final class CommandDump extends PlaceholderCommand
|
|||||||
builder.append("Expansions Registered:")
|
builder.append("Expansions Registered:")
|
||||||
.append('\n');
|
.append('\n');
|
||||||
|
|
||||||
|
final List<PlaceholderExpansion> expansions = plugin.getLocalExpansionManager()
|
||||||
final Map<String, List<PlaceholderExpansion>> expansions = plugin.getLocalExpansionManager()
|
|
||||||
.getExpansions()
|
.getExpansions()
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.groupingBy(PlaceholderExpansion::getAuthor));
|
.sorted(Comparator.comparing(PlaceholderExpansion::getIdentifier))
|
||||||
|
.sorted(Comparator.comparing(PlaceholderExpansion::getAuthor))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
for (final Map.Entry<String, List<PlaceholderExpansion>> expansionsByAuthor : expansions.entrySet())
|
int size = 0;
|
||||||
{
|
|
||||||
builder.append(" ")
|
|
||||||
.append(expansionsByAuthor.getKey())
|
|
||||||
.append(": ")
|
|
||||||
.append('\n');
|
|
||||||
|
|
||||||
for (final PlaceholderExpansion expansion : expansionsByAuthor.getValue())
|
for (final String name : expansions.stream().map(PlaceholderExpansion::getIdentifier)
|
||||||
{
|
.collect(Collectors.toList())) {
|
||||||
builder.append(" ")
|
if (name.length() > size) {
|
||||||
.append(expansion.getName())
|
size = name.length();
|
||||||
.append(':')
|
|
||||||
.append(expansion.getVersion())
|
|
||||||
.append('\n');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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('\n');
|
||||||
|
|
||||||
builder.append("Expansions Directory:")
|
builder.append("Expansions Directory:")
|
||||||
@@ -145,8 +167,7 @@ public final class CommandDump extends PlaceholderCommand
|
|||||||
.getExpansionsFolder()
|
.getExpansionsFolder()
|
||||||
.list((dir, name) -> name.toLowerCase().endsWith(".jar"));
|
.list((dir, name) -> name.toLowerCase().endsWith(".jar"));
|
||||||
|
|
||||||
for (final String jar : jars)
|
for (final String jar : jars) {
|
||||||
{
|
|
||||||
builder.append(" ")
|
builder.append(" ")
|
||||||
.append(jar)
|
.append(jar)
|
||||||
.append('\n');
|
.append('\n');
|
||||||
@@ -154,26 +175,39 @@ public final class CommandDump extends PlaceholderCommand
|
|||||||
|
|
||||||
builder.append('\n');
|
builder.append('\n');
|
||||||
|
|
||||||
|
|
||||||
builder.append("Server Info: ")
|
builder.append("Server Info: ")
|
||||||
.append(plugin.getServer().getBukkitVersion())
|
.append(plugin.getServer().getBukkitVersion())
|
||||||
.append('/')
|
.append('/')
|
||||||
.append(plugin.getServer().getVersion())
|
.append(plugin.getServer().getVersion())
|
||||||
|
.append("\n");
|
||||||
|
|
||||||
|
builder.append("Java Version: ")
|
||||||
|
.append(System.getProperty("java.version"))
|
||||||
.append("\n\n");
|
.append("\n\n");
|
||||||
|
|
||||||
builder.append("Plugin Info:")
|
builder.append("Plugin Info:")
|
||||||
.append('\n');
|
.append('\n');
|
||||||
|
|
||||||
for (final Plugin other : plugin.getServer().getPluginManager().getPlugins())
|
List<Plugin> plugins = Arrays.stream(plugin.getServer().getPluginManager().getPlugins())
|
||||||
{
|
.sorted(Comparator.comparing(Plugin::getName))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (final String pluginName : plugins.stream().map(Plugin::getName)
|
||||||
|
.collect(Collectors.toList())) {
|
||||||
|
if (pluginName.length() > size) {
|
||||||
|
size = pluginName.length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final Plugin other : plugins) {
|
||||||
builder.append(" ")
|
builder.append(" ")
|
||||||
.append(other.getName())
|
.append(String.format("%-" + size + "s", other.getName()))
|
||||||
.append(": ")
|
.append(" [Version: ")
|
||||||
.append(other.getDescription().getVersion())
|
.append(other.getDescription().getVersion())
|
||||||
.append('\n');
|
.append("]")
|
||||||
|
.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,11 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.local;
|
package me.clip.placeholderapi.commands.impl.local;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.logging.Level;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
@@ -30,62 +35,49 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.io.File;
|
public final class CommandExpansionRegister extends PlaceholderCommand {
|
||||||
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() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandExpansionRegister()
|
|
||||||
{
|
|
||||||
super("register");
|
super("register");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() < 1)
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
if (params.size() < 1) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cYou must specify the name of an expansion file.");
|
"&cYou must specify the name of an expansion file.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final LocalExpansionManager manager = plugin.getLocalExpansionManager();
|
final LocalExpansionManager manager = plugin.getLocalExpansionManager();
|
||||||
|
|
||||||
final File file = new File(manager.getExpansionsFolder(), params.get(0));
|
final File file = new File(manager.getExpansionsFolder(), params.get(0));
|
||||||
if (!file.exists())
|
if (!file.exists()) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cThe file &f" + file.getName() + "&c doesn't exist!");
|
"&cThe file &f" + file.getName() + "&c doesn't exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Futures.onMainThread(plugin, manager.findExpansionInFile(file), (clazz, exception) -> {
|
Futures.onMainThread(plugin, manager.findExpansionInFile(file), (clazz, exception) -> {
|
||||||
if (exception != null)
|
if (exception != null) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cFailed to find expansion in file: &f" + file);
|
"&cFailed to find expansion in file: &f" + file);
|
||||||
|
|
||||||
plugin.getLogger().log(Level.WARNING, "failed to find expansion in file: " + file, exception);
|
plugin.getLogger()
|
||||||
|
.log(Level.WARNING, "failed to find expansion in file: " + file, exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clazz == null)
|
if (clazz == null) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cNo expansion class found in file: &f" + file);
|
"&cNo expansion class found in file: &f" + file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final Optional<PlaceholderExpansion> expansion = manager.register(clazz);
|
final Optional<PlaceholderExpansion> expansion = manager.register(clazz);
|
||||||
if (!expansion.isPresent())
|
if (!expansion.isPresent()) {
|
||||||
{
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cFailed to register expansion from &f" + params.get(0));
|
"&cFailed to register expansion from &f" + params.get(0));
|
||||||
return;
|
return;
|
||||||
@@ -98,20 +90,21 @@ public final class CommandExpansionRegister extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() > 1)
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
{
|
if (params.size() > 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] fileNames = plugin.getLocalExpansionManager().getExpansionsFolder().list((dir, name) -> name.endsWith(".jar"));
|
final String[] fileNames = plugin.getLocalExpansionManager().getExpansionsFolder()
|
||||||
if (fileNames == null || fileNames.length == 0)
|
.list((dir, name) -> name.endsWith(".jar"));
|
||||||
{
|
if (fileNames == null || fileNames.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestByParameter(Arrays.stream(fileNames), suggestions, params.isEmpty() ? null : params.get(0));
|
suggestByParameter(Arrays.stream(fileNames), suggestions,
|
||||||
|
params.isEmpty() ? null : params.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.local;
|
package me.clip.placeholderapi.commands.impl.local;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
@@ -29,36 +31,30 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandExpansionUnregister extends PlaceholderCommand {
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public final class CommandExpansionUnregister extends PlaceholderCommand
|
public CommandExpansionUnregister() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandExpansionUnregister()
|
|
||||||
{
|
|
||||||
super("unregister");
|
super("unregister");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.isEmpty())
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
if (params.isEmpty()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cYou must specify the name of the expansion.");
|
"&cYou must specify the name of the expansion.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Optional<PlaceholderExpansion> expansion = plugin.getLocalExpansionManager().findExpansionByName(params.get(0));
|
final Optional<PlaceholderExpansion> expansion = plugin.getLocalExpansionManager()
|
||||||
if (!expansion.isPresent())
|
.findExpansionByName(params.get(0));
|
||||||
{
|
if (!expansion.isPresent()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cThere is no expansion loaded with the identifier: &f" + params.get(0));
|
"&cThere is no expansion loaded with the identifier: &f" + params.get(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final String message = !expansion.get().unregister() ?
|
final String message = !expansion.get().unregister() ?
|
||||||
"&cFailed to unregister expansion: &f" :
|
"&cFailed to unregister expansion: &f" :
|
||||||
"&aSuccessfully unregistered expansion: &f";
|
"&aSuccessfully unregistered expansion: &f";
|
||||||
@@ -67,14 +63,15 @@ public final class CommandExpansionUnregister extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() > 1)
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
{
|
if (params.size() > 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions, params.isEmpty() ? null : params.get(0));
|
suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions,
|
||||||
|
params.isEmpty() ? null : params.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.local;
|
package me.clip.placeholderapi.commands.impl.local;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
@@ -28,43 +29,44 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandHelp extends PlaceholderCommand {
|
||||||
|
|
||||||
public final class CommandHelp extends PlaceholderCommand
|
public CommandHelp() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandHelp()
|
|
||||||
{
|
|
||||||
super("help");
|
super("help");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
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();
|
final PluginDescriptionFile description = plugin.getDescription();
|
||||||
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&b&lPlaceholderAPI &8- &7Help Menu &8- &7(&f" + description.getVersion() + "&7)",
|
"&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>",
|
"&b/papi &fbcparse &9<me/player name> <message>",
|
||||||
" &7&oParse a message with placeholders and broadcast it",
|
" &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/player name> <message>",
|
||||||
|
" &7&oParse a message with placeholders",
|
||||||
"&b/papi &fparserel &9<player one> <player two> <message>",
|
"&b/papi &fparserel &9<player one> <player two> <message>",
|
||||||
" &7&oParse a message with relational placeholders",
|
" &7&oParse a message with relational placeholders",
|
||||||
"&b/papi &fregister &9<file name>",
|
"&b/papi &fregister &9<file name>",
|
||||||
" &7&oRegister an expansion by the name of the file",
|
" &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>",
|
"&b/papi &funregister &9<expansion name>",
|
||||||
" &7&oUnregister an expansion by name");
|
" &7&oUnregister an expansion by name",
|
||||||
|
"&b/papi &fversion",
|
||||||
|
" &7&oView plugin info/version");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.local;
|
package me.clip.placeholderapi.commands.impl.local;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
@@ -29,29 +30,25 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandInfo extends PlaceholderCommand {
|
||||||
|
|
||||||
public final class CommandInfo extends PlaceholderCommand
|
public CommandInfo() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandInfo()
|
|
||||||
{
|
|
||||||
super("info");
|
super("info");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.isEmpty())
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
if (params.isEmpty()) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cYou must specify the name of the expansion.");
|
"&cYou must specify the name of the expansion.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlaceholderExpansion expansion = plugin.getLocalExpansionManager().findExpansionByName(params.get(0)).orElse(null);
|
final PlaceholderExpansion expansion = plugin.getLocalExpansionManager()
|
||||||
if (expansion == null)
|
.findExpansionByIdentifier(params.get(0)).orElse(null);
|
||||||
{
|
if (expansion == null) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cThere is no expansion loaded with the identifier: &f" + params.get(0));
|
"&cThere is no expansion loaded with the identifier: &f" + params.get(0));
|
||||||
return;
|
return;
|
||||||
@@ -67,37 +64,32 @@ public final class CommandInfo extends PlaceholderCommand
|
|||||||
.append('\n');
|
.append('\n');
|
||||||
|
|
||||||
final String author = expansion.getAuthor();
|
final String author = expansion.getAuthor();
|
||||||
if (author != null)
|
if (author != null) {
|
||||||
{
|
|
||||||
builder.append("&7Author: &r")
|
builder.append("&7Author: &r")
|
||||||
.append(author)
|
.append(author)
|
||||||
.append('\n');
|
.append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
final String version = expansion.getVersion();
|
final String version = expansion.getVersion();
|
||||||
if (version != null)
|
if (version != null) {
|
||||||
{
|
|
||||||
builder.append("&7Version: &r")
|
builder.append("&7Version: &r")
|
||||||
.append(version)
|
.append(version)
|
||||||
.append('\n');
|
.append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
final String requiredPlugin = expansion.getRequiredPlugin();
|
final String requiredPlugin = expansion.getRequiredPlugin();
|
||||||
if (requiredPlugin != null)
|
if (requiredPlugin != null) {
|
||||||
{
|
|
||||||
builder.append("&7Requires plugin: &r")
|
builder.append("&7Requires plugin: &r")
|
||||||
.append(requiredPlugin)
|
.append(requiredPlugin)
|
||||||
.append('\n');
|
.append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> placeholders = expansion.getPlaceholders();
|
final List<String> placeholders = expansion.getPlaceholders();
|
||||||
if (placeholders != null && !placeholders.isEmpty())
|
if (placeholders != null && !placeholders.isEmpty()) {
|
||||||
{
|
|
||||||
builder.append("&8&m-- &7Placeholders &8&m--&r")
|
builder.append("&8&m-- &7Placeholders &8&m--&r")
|
||||||
.append('\n');
|
.append('\n');
|
||||||
|
|
||||||
for (final String placeholder : placeholders)
|
for (final String placeholder : placeholders) {
|
||||||
{
|
|
||||||
builder.append(placeholder)
|
builder.append(placeholder)
|
||||||
.append('\n');
|
.append('\n');
|
||||||
}
|
}
|
||||||
@@ -107,14 +99,15 @@ public final class CommandInfo extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
if (params.size() > 1)
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
{
|
if (params.size() > 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions, params.isEmpty() ? null : params.get(0));
|
suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions,
|
||||||
|
params.isEmpty() ? null : params.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -21,6 +21,9 @@
|
|||||||
package me.clip.placeholderapi.commands.impl.local;
|
package me.clip.placeholderapi.commands.impl.local;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
@@ -29,34 +32,30 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandList extends PlaceholderCommand {
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public final class CommandList extends PlaceholderCommand
|
public CommandList() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandList()
|
|
||||||
{
|
|
||||||
super("list");
|
super("list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
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();
|
final Set<String> identifiers = PlaceholderAPI.getRegisteredIdentifiers();
|
||||||
if (identifiers.isEmpty())
|
if (identifiers.isEmpty()) {
|
||||||
{
|
Msg.msg(sender, "&cThere are no placeholder hooks active!");
|
||||||
Msg.msg(sender, "&6There are no placeholder hooks active!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<List<String>> partitions = Lists.partition(identifiers.stream().sorted().collect(Collectors.toList()), 10);
|
final List<List<String>> partitions = Lists
|
||||||
|
.partition(identifiers.stream().sorted().collect(Collectors.toList()), 10);
|
||||||
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&6" + identifiers.size() + "&7 placeholder hook(s) active: &a",
|
"&7A total of &f" + identifiers.size() + "&7 placeholder hook(s) are active: &a",
|
||||||
partitions.stream().map(partition -> " " + String.join(", ", partition)).collect(Collectors.joining("\n")));
|
partitions.stream().map(partition -> String.join("&7, &a", partition))
|
||||||
|
.collect(Collectors.joining("\n")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.local;
|
package me.clip.placeholderapi.commands.impl.local;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
@@ -34,27 +38,18 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.Collection;
|
public final class CommandParse extends PlaceholderCommand {
|
||||||
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() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandParse()
|
|
||||||
{
|
|
||||||
super("parse", "bcparse", "parserel", "cmdparse");
|
super("parse", "bcparse", "parserel", "cmdparse");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
switch (alias.toLowerCase())
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
{
|
switch (alias.toLowerCase()) {
|
||||||
case "parserel":
|
case "parserel":
|
||||||
evaluateParseRelation(sender, params);
|
evaluateParseRelation(sender, params);
|
||||||
break;
|
break;
|
||||||
@@ -71,10 +66,10 @@ public final class CommandParse extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public void complete(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
switch (alias.toLowerCase())
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
{
|
switch (alias.toLowerCase()) {
|
||||||
case "parserel":
|
case "parserel":
|
||||||
completeParseRelation(params, suggestions);
|
completeParseRelation(params, suggestions);
|
||||||
break;
|
break;
|
||||||
@@ -87,31 +82,28 @@ public final class CommandParse extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void evaluateParseSingular(@NotNull final CommandSender sender, @NotNull @Unmodifiable final List<String> params, final boolean broadcast, final boolean command)
|
private void evaluateParseSingular(@NotNull final CommandSender sender,
|
||||||
{
|
@NotNull @Unmodifiable final List<String> params, final boolean broadcast,
|
||||||
if (params.size() < 2)
|
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}");
|
Msg.msg(sender,
|
||||||
|
"&cYou must supply a target, and a message: &b/papi " + (broadcast ? "bcparse" : "parse")
|
||||||
|
+ " &7{target} &a{message}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull final OfflinePlayer player;
|
@NotNull final OfflinePlayer player;
|
||||||
|
|
||||||
if ("me".equalsIgnoreCase(params.get(0)))
|
if ("me".equalsIgnoreCase(params.get(0))) {
|
||||||
{
|
if (!(sender instanceof Player)) {
|
||||||
if (!(sender instanceof Player))
|
|
||||||
{
|
|
||||||
Msg.msg(sender, "&cYou must be a player to use &7me&c as a target!");
|
Msg.msg(sender, "&cYou must be a player to use &7me&c as a target!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player = ((Player) sender);
|
player = ((Player) sender);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
final OfflinePlayer target = resolvePlayer(params.get(0));
|
final OfflinePlayer target = resolvePlayer(params.get(0));
|
||||||
if (target == null)
|
if (target == null) {
|
||||||
{
|
|
||||||
Msg.msg(sender, "&cFailed to find player: &7" + params.get(0));
|
Msg.msg(sender, "&cFailed to find player: &7" + params.get(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,64 +111,57 @@ public final class CommandParse extends PlaceholderCommand
|
|||||||
player = target;
|
player = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String message = PlaceholderAPI.setPlaceholders(player, String.join(" ", params.subList(1, params.size())));
|
final String message = PlaceholderAPI
|
||||||
|
.setPlaceholders(player, String.join(" ", params.subList(1, params.size())));
|
||||||
|
|
||||||
if (command)
|
if (command) {
|
||||||
{
|
|
||||||
Bukkit.dispatchCommand(sender, message);
|
Bukkit.dispatchCommand(sender, message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (broadcast)
|
if (broadcast) {
|
||||||
{
|
|
||||||
Msg.broadcast(message);
|
Msg.broadcast(message);
|
||||||
}
|
} else {
|
||||||
else
|
if (!(sender instanceof Player)) {
|
||||||
{
|
|
||||||
if (!(sender instanceof Player))
|
|
||||||
{
|
|
||||||
Msg.msg(sender, message);
|
Msg.msg(sender, message);
|
||||||
}
|
} else {
|
||||||
else
|
((Player) sender).spigot().sendMessage(TextComponent.fromLegacyText(message));
|
||||||
{
|
|
||||||
sender.spigot().sendMessage(TextComponent.fromLegacyText(message));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void evaluateParseRelation(@NotNull final CommandSender sender, @NotNull @Unmodifiable final List<String> params)
|
private void evaluateParseRelation(@NotNull final CommandSender sender,
|
||||||
{
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
if (params.size() < 3)
|
if (params.size() < 3) {
|
||||||
{
|
Msg.msg(sender,
|
||||||
Msg.msg(sender, "&cYou must supply two targets, and a message: &b/papi parserel &7{target one} {target two} &a{message}");
|
"&cYou must supply two targets, and a message: &b/papi parserel &7{target one} {target two} &a{message}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final OfflinePlayer targetOne = resolvePlayer(params.get(0));
|
final OfflinePlayer targetOne = resolvePlayer(params.get(0));
|
||||||
if (targetOne == null || !targetOne.isOnline())
|
if (targetOne == null || !targetOne.isOnline()) {
|
||||||
{
|
Msg.msg(sender, "&cFailed to find player: &f" + params.get(0));
|
||||||
Msg.msg(sender, "&cFailed to find player: &7" + params.get(0));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final OfflinePlayer targetTwo = resolvePlayer(params.get(1));
|
final OfflinePlayer targetTwo = resolvePlayer(params.get(1));
|
||||||
if (targetTwo == null || !targetTwo.isOnline())
|
if (targetTwo == null || !targetTwo.isOnline()) {
|
||||||
{
|
Msg.msg(sender, "&cFailed to find player: &f" + params.get(1));
|
||||||
Msg.msg(sender, "&cFailed to find player: &7" + params.get(1));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String message = PlaceholderAPI.setRelationalPlaceholders(((Player) targetOne), ((Player) targetTwo), String.join(" ", params.subList(2, params.size())));
|
final String message = PlaceholderAPI
|
||||||
|
.setRelationalPlaceholders(((Player) targetOne), ((Player) targetTwo),
|
||||||
|
String.join(" ", params.subList(2, params.size())));
|
||||||
Msg.msg(sender, message);
|
Msg.msg(sender, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void completeParseSingular(@NotNull final CommandSender sender, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
private void completeParseSingular(@NotNull final CommandSender sender,
|
||||||
{
|
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||||
if (params.size() <= 1)
|
if (params.size() <= 1) {
|
||||||
{
|
if (sender instanceof Player && (params.isEmpty() || "me"
|
||||||
if (sender instanceof Player && (params.isEmpty() || "me".startsWith(params.get(0).toLowerCase())))
|
.startsWith(params.get(0).toLowerCase()))) {
|
||||||
{
|
|
||||||
suggestions.add("me");
|
suggestions.add("me");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,20 +172,19 @@ public final class CommandParse extends PlaceholderCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String name = params.get(params.size() - 1);
|
final String name = params.get(params.size() - 1);
|
||||||
if (!name.startsWith("%") || name.endsWith("%"))
|
if (!name.startsWith("%") || name.endsWith("%")) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int index = name.indexOf('_');
|
final int index = name.indexOf('_');
|
||||||
if (index == -1)
|
if (index == -1) {
|
||||||
{
|
|
||||||
return; // no arguments supplied yet
|
return; // no arguments supplied yet
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlaceholderExpansion expansion = PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByIdentifier(name.substring(1, index)).orElse(null);
|
final PlaceholderExpansion expansion = PlaceholderAPIPlugin.getInstance()
|
||||||
if (expansion == null)
|
.getLocalExpansionManager().findExpansionByIdentifier(name.substring(1, index))
|
||||||
{
|
.orElse(null);
|
||||||
|
if (expansion == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,10 +198,9 @@ public final class CommandParse extends PlaceholderCommand
|
|||||||
suggestByParameter(possible.stream(), suggestions, params.get(params.size() - 1));
|
suggestByParameter(possible.stream(), suggestions, params.get(params.size() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void completeParseRelation(@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
|
private void completeParseRelation(@NotNull @Unmodifiable final List<String> params,
|
||||||
{
|
@NotNull final List<String> suggestions) {
|
||||||
if (params.size() > 2)
|
if (params.size() > 2) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,16 +210,17 @@ public final class CommandParse extends PlaceholderCommand
|
|||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private OfflinePlayer resolvePlayer(@NotNull final String name)
|
private OfflinePlayer resolvePlayer(@NotNull final String name) {
|
||||||
{
|
OfflinePlayer target = Bukkit.getPlayerExact(name);
|
||||||
OfflinePlayer target = Bukkit.getPlayer(name);
|
|
||||||
|
|
||||||
if (target == null)
|
if (target == null) {
|
||||||
{
|
// Not the best option, but Spigot doesn't offer a good replacement (as usual)
|
||||||
target = Bukkit.getOfflinePlayer(name); // this is probably not a great idea.
|
target = Bukkit.getOfflinePlayer(name);
|
||||||
}
|
|
||||||
|
|
||||||
return target.hasPlayedBefore() ? target : null;
|
return target.hasPlayedBefore() ? target : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,25 +20,23 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.local;
|
package me.clip.placeholderapi.commands.impl.local;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandReload extends PlaceholderCommand {
|
||||||
|
|
||||||
public final class CommandReload extends PlaceholderCommand
|
public CommandReload() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandReload()
|
|
||||||
{
|
|
||||||
super("reload");
|
super("reload");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
{
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
plugin.reloadConf(sender);
|
plugin.reloadConf(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.local;
|
package me.clip.placeholderapi.commands.impl.local;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
@@ -28,27 +29,24 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
public final class CommandVersion extends PlaceholderCommand {
|
||||||
|
|
||||||
public final class CommandVersion extends PlaceholderCommand
|
public CommandVersion() {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandVersion()
|
|
||||||
{
|
|
||||||
super("version");
|
super("version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
|
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();
|
final PluginDescriptionFile description = plugin.getDescription();
|
||||||
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&b&lPlaceholderAPI &e(&f" + description.getVersion() + "&e)",
|
"&b&lPlaceholderAPI &7(&f" + description.getVersion() + "&7)",
|
||||||
"&fAuthors&8: &6" + description.getAuthors(),
|
"&7Author: &f" + description.getAuthors(),
|
||||||
"&fPAPI Commands&8: &b/papi &7help",
|
"&7PAPI Commands: &b/papi &fhelp",
|
||||||
"&feCloud Commands&8: &b/papi &7ecloud");
|
"&7eCloud Commands&8: &b/papi &fecloud");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of PlaceholderAPI
|
||||||
|
*
|
||||||
|
* PlaceholderAPI
|
||||||
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
|
*
|
||||||
|
* PlaceholderAPI is 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.configuration;
|
package me.clip.placeholderapi.configuration;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Comparator;
|
public enum ExpansionSort implements Comparator<CloudExpansion> {
|
||||||
|
|
||||||
public enum ExpansionSort implements Comparator<CloudExpansion>
|
|
||||||
{
|
|
||||||
|
|
||||||
NAME(Comparator.comparing(CloudExpansion::getName)),
|
NAME(Comparator.comparing(CloudExpansion::getName)),
|
||||||
AUTHOR(Comparator.comparing(CloudExpansion::getAuthor)),
|
AUTHOR(Comparator.comparing(CloudExpansion::getAuthor)),
|
||||||
@@ -16,15 +34,13 @@ public enum ExpansionSort implements Comparator<CloudExpansion>
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final Comparator<CloudExpansion> comparator;
|
private final Comparator<CloudExpansion> comparator;
|
||||||
|
|
||||||
ExpansionSort(@NotNull final Comparator<CloudExpansion> comparator)
|
ExpansionSort(@NotNull final Comparator<CloudExpansion> comparator) {
|
||||||
{
|
|
||||||
this.comparator = comparator;
|
this.comparator = comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int compare(final CloudExpansion expansion1, final CloudExpansion expansion2)
|
public final int compare(final CloudExpansion expansion1, final CloudExpansion expansion2) {
|
||||||
{
|
|
||||||
return comparator.compare(expansion1, expansion2);
|
return comparator.compare(expansion1, expansion2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,86 +20,72 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.configuration;
|
package me.clip.placeholderapi.configuration;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Optional;
|
public final class PlaceholderAPIConfig {
|
||||||
|
|
||||||
public final class PlaceholderAPIConfig
|
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final PlaceholderAPIPlugin plugin;
|
private final PlaceholderAPIPlugin plugin;
|
||||||
|
|
||||||
public PlaceholderAPIConfig(@NotNull final PlaceholderAPIPlugin plugin)
|
public PlaceholderAPIConfig(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean checkUpdates()
|
public boolean checkUpdates() {
|
||||||
{
|
|
||||||
return plugin.getConfig().getBoolean("check_updates");
|
return plugin.getConfig().getBoolean("check_updates");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean cloudAllowUnverifiedExpansions()
|
public boolean cloudAllowUnverifiedExpansions() {
|
||||||
{
|
|
||||||
return plugin.getConfig().getBoolean("cloud_allow_unverified_expansions");
|
return plugin.getConfig().getBoolean("cloud_allow_unverified_expansions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isCloudEnabled()
|
public boolean isCloudEnabled() {
|
||||||
{
|
|
||||||
return plugin.getConfig().getBoolean("cloud_enabled");
|
return plugin.getConfig().getBoolean("cloud_enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCloudEnabled(boolean state)
|
public void setCloudEnabled(boolean state) {
|
||||||
{
|
|
||||||
plugin.getConfig().set("cloud_enabled", state);
|
plugin.getConfig().set("cloud_enabled", state);
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isDebugMode()
|
public boolean isDebugMode() {
|
||||||
{
|
|
||||||
return plugin.getConfig().getBoolean("debug", false);
|
return plugin.getConfig().getBoolean("debug", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Optional<ExpansionSort> getExpansionSort()
|
public Optional<ExpansionSort> getExpansionSort() {
|
||||||
{
|
final String option = plugin.getConfig()
|
||||||
final String option = plugin.getConfig().getString("cloud_sorting", ExpansionSort.LATEST.name());
|
.getString("cloud_sorting", ExpansionSort.LATEST.name());
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
//noinspection ConstantConditions (bad spigot annotation)
|
//noinspection ConstantConditions (bad spigot annotation)
|
||||||
return Optional.of(ExpansionSort.valueOf(option.toUpperCase()));
|
return Optional.of(ExpansionSort.valueOf(option.toUpperCase()));
|
||||||
}
|
} catch (final IllegalArgumentException ignored) {
|
||||||
catch (final IllegalArgumentException ignored)
|
|
||||||
{
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String dateFormat()
|
public String dateFormat() {
|
||||||
{
|
|
||||||
//noinspection ConstantConditions (bad spigot annotation)
|
//noinspection ConstantConditions (bad spigot annotation)
|
||||||
return plugin.getConfig().getString("date_format", "MM/dd/yy HH:mm:ss");
|
return plugin.getConfig().getString("date_format", "MM/dd/yy HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String booleanTrue()
|
public String booleanTrue() {
|
||||||
{
|
|
||||||
//noinspection ConstantConditions (bad spigot annotation)
|
//noinspection ConstantConditions (bad spigot annotation)
|
||||||
return plugin.getConfig().getString("boolean.true", "true");
|
return plugin.getConfig().getString("boolean.true", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String booleanFalse()
|
public String booleanFalse() {
|
||||||
{
|
|
||||||
//noinspection ConstantConditions (bad spigot annotation)
|
//noinspection ConstantConditions (bad spigot annotation)
|
||||||
return plugin.getConfig().getString("boolean.false", "false");
|
return plugin.getConfig().getString("boolean.false", "false");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -26,54 +26,63 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public final class ExpansionRegisterEvent extends Event implements Cancellable
|
/**
|
||||||
{
|
* 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 me.clip.placeholderapi.events.ExpansionsLoadedEvent ExpansionsLoadedEvent} instead.
|
||||||
|
*/
|
||||||
|
public final class ExpansionRegisterEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
||||||
|
|
||||||
private boolean cancelled;
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final PlaceholderExpansion expansion;
|
private final PlaceholderExpansion expansion;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public ExpansionRegisterEvent(@NotNull final PlaceholderExpansion expansion)
|
public ExpansionRegisterEvent(@NotNull final PlaceholderExpansion expansion) {
|
||||||
{
|
|
||||||
this.expansion = expansion;
|
this.expansion = expansion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public PlaceholderExpansion getExpansion()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
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
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled() {
|
||||||
{
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancelled)
|
public void setCancelled(boolean cancelled) {
|
||||||
{
|
|
||||||
this.cancelled = cancelled;
|
this.cancelled = cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return HANDLERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static HandlerList getHandlerList()
|
|
||||||
{
|
|
||||||
return HANDLERS;
|
return HANDLERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -25,40 +25,45 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public final class ExpansionUnregisterEvent extends Event
|
/**
|
||||||
{
|
* 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 extends Event {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final PlaceholderExpansion expansion;
|
private final PlaceholderExpansion expansion;
|
||||||
|
|
||||||
public ExpansionUnregisterEvent(@NotNull final PlaceholderExpansion expansion)
|
public ExpansionUnregisterEvent(@NotNull final PlaceholderExpansion expansion) {
|
||||||
{
|
|
||||||
this.expansion = expansion;
|
this.expansion = expansion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public PlaceholderExpansion getExpansion()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return expansion;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers()
|
|
||||||
{
|
|
||||||
return HANDLERS;
|
return HANDLERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link PlaceholderExpansion PlaceholderExpansion} that was unregistered.
|
||||||
|
*
|
||||||
|
* @return The {@link PlaceholderExpansion PlaceholderExpansion} instance.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public PlaceholderExpansion getExpansion() {
|
||||||
|
return expansion;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static HandlerList getHandlerList()
|
@Override
|
||||||
{
|
public HandlerList getHandlers() {
|
||||||
return HANDLERS;
|
return HANDLERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of PlaceholderAPI
|
||||||
|
*
|
||||||
|
* PlaceholderAPI
|
||||||
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
|
*
|
||||||
|
* PlaceholderAPI is 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.events;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
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 extends Event {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -29,8 +29,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* @deprecated This event is no longer used.
|
* @deprecated This event is no longer used.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public final class PlaceholderHookUnloadEvent extends Event
|
public final class PlaceholderHookUnloadEvent extends Event {
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
@@ -41,36 +40,30 @@ public final class PlaceholderHookUnloadEvent extends Event
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final PlaceholderHook placeholderHook;
|
private final PlaceholderHook placeholderHook;
|
||||||
|
|
||||||
public PlaceholderHookUnloadEvent(@NotNull final String plugin, @NotNull final PlaceholderHook placeholderHook)
|
public PlaceholderHookUnloadEvent(@NotNull final String plugin,
|
||||||
{
|
@NotNull final PlaceholderHook placeholderHook) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.placeholderHook = placeholderHook;
|
this.placeholderHook = placeholderHook;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getHookName()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getHookName() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public PlaceholderHook getHook()
|
public PlaceholderHook getHook() {
|
||||||
{
|
|
||||||
return placeholderHook;
|
return placeholderHook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return HANDLERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static HandlerList getHandlerList()
|
|
||||||
{
|
|
||||||
return HANDLERS;
|
return HANDLERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
package me.clip.placeholderapi.exceptions;
|
package me.clip.placeholderapi.exceptions;
|
||||||
|
|
||||||
public final class NoDefaultCommandException extends RuntimeException {
|
public final class NoDefaultCommandException extends RuntimeException {
|
||||||
|
|
||||||
public NoDefaultCommandException(final String message) {
|
public NoDefaultCommandException(final String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -21,9 +21,11 @@
|
|||||||
package me.clip.placeholderapi.expansion;
|
package me.clip.placeholderapi.expansion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface allows a class which extends a {@link PlaceholderExpansion} to have the clear
|
* Classes implementing this interface will have a {@link #clear() clear void} that is called
|
||||||
* method called when the implementing expansion is unregistered from PlaceholderAPI. This is useful
|
* by PlaceholderAPI whenever the {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion}
|
||||||
* if we want to do things when the implementing hook is unregistered
|
* is unregistered.
|
||||||
|
*
|
||||||
|
* <p>This allows you to execute things such as clearing internal caches, saving data to files, etc.
|
||||||
*
|
*
|
||||||
* @author Ryan McCarthy
|
* @author Ryan McCarthy
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -23,9 +23,11 @@ package me.clip.placeholderapi.expansion;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface allows a class which extends a {@link PlaceholderExpansion} to have the cleanup
|
* Classes implementing this interface will have a {@link #cleanup(Player) cleanup void} that is
|
||||||
* method called every time a player leaves the server. This is useful if we want to clean up after
|
* called by PlaceholderAPI whenever a Player leaves the server.
|
||||||
* the player
|
*
|
||||||
|
* <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
|
* @author Ryan McCarthy
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -23,18 +23,32 @@ package me.clip.placeholderapi.expansion;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any {@link PlaceholderExpansion} class which implements configurable will have any options listed
|
* Implementing this interface allows {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansions}
|
||||||
* in the getDefaults map automatically added to the PlaceholderAPI config.yml file
|
* to set a list of default configuration values through the {@link #getDefaults() getDefaults method}
|
||||||
|
* that should be added to the config.yml of PlaceholderAPI.
|
||||||
|
*
|
||||||
|
* <p>The entries will be added under {@code expansions} as their own section.
|
||||||
|
* <h2>Example:</h2>
|
||||||
|
* returning a Map with key {@code foo} and value {@code bar} will result in the following config entry:
|
||||||
|
*
|
||||||
|
* <pre><code>
|
||||||
|
* expansions:
|
||||||
|
* myexpansion:
|
||||||
|
* foo: "bar"
|
||||||
|
* </code></pre>
|
||||||
|
*
|
||||||
|
* <p><b>The configuration is set before the PlaceholderExpansion is registered!</b>
|
||||||
*
|
*
|
||||||
* @author Ryan McCarthy
|
* @author Ryan McCarthy
|
||||||
*/
|
*/
|
||||||
public interface Configurable {
|
public interface Configurable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be called before the implementing class is registered to obtain a map of
|
* The map returned by this method will be used to set config options in PlaceholderAPI's config.yml.
|
||||||
* configuration options that the implementing class needs These paths and values will be added to
|
*
|
||||||
* the PlaceholderAPI config.yml in the configuration section expansions.(placeholder
|
* <p>The key and value pairs are set under a section named after your
|
||||||
* identifier).(your key): (your value)
|
* {@link me.clip.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
|
* @return Map of config path / values which need to be added / removed from the PlaceholderAPI
|
||||||
* config.yml file
|
* config.yml file
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -39,7 +39,11 @@ public enum NMSVersion {
|
|||||||
SPIGOT_1_13_R2("v1_13_R2"),
|
SPIGOT_1_13_R2("v1_13_R2"),
|
||||||
SPIGOT_1_14_R1("v1_14_R1"),
|
SPIGOT_1_14_R1("v1_14_R1"),
|
||||||
SPIGOT_1_15_R1("v1_15_R1"),
|
SPIGOT_1_15_R1("v1_15_R1"),
|
||||||
SPIGOT_1_16_R1("v1_16_R1");
|
SPIGOT_1_16_R1("v1_16_R1"),
|
||||||
|
SPIGOT_1_16_R2("v1_16_R2"),
|
||||||
|
SPIGOT_1_16_R3("v1_16_R3"),
|
||||||
|
SPIGOT_1_17_R1("v1_17_R1"),
|
||||||
|
SPIGOT_1_18_R1("v1_18_R1");
|
||||||
|
|
||||||
private final String version;
|
private final String version;
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,25 +20,28 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.expansion;
|
package me.clip.placeholderapi.expansion;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.PlaceholderHook;
|
import me.clip.placeholderapi.PlaceholderHook;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
/**
|
||||||
import java.util.List;
|
* Any class extending this will be able to get registered as a PlaceholderExpansion.
|
||||||
import java.util.Objects;
|
* <br>The registration either happens automatically when the jar file containing a
|
||||||
|
* class extending this one is located under the {@code PlaceholderAPI/expansions}
|
||||||
public abstract class PlaceholderExpansion extends PlaceholderHook
|
* directory or when the {@link #register()} method is called by said class.
|
||||||
{
|
*/
|
||||||
|
public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder identifier of this expansion
|
* The placeholder identifier of this expansion. May not contain {@literal %},
|
||||||
|
* {@literal {}} or _
|
||||||
*
|
*
|
||||||
* @return placeholder identifier that is associated with this expansion
|
* @return placeholder identifier that is associated with this expansion
|
||||||
*/
|
*/
|
||||||
@@ -61,22 +64,13 @@ public abstract class PlaceholderExpansion extends PlaceholderHook
|
|||||||
@NotNull
|
@NotNull
|
||||||
public abstract String getVersion();
|
public abstract String getVersion();
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override /* override for now >:) */
|
|
||||||
public String onRequest(@Nullable final OfflinePlayer player, @NotNull final String params)
|
|
||||||
{
|
|
||||||
return super.onRequest(player, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of this expansion
|
* The name of this expansion
|
||||||
*
|
*
|
||||||
* @return {@link #getIdentifier()} by default, name of this expansion if specified
|
* @return {@link #getIdentifier()} by default, name of this expansion if specified
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
|
||||||
return getIdentifier();
|
return getIdentifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,9 +80,8 @@ public abstract class PlaceholderExpansion extends PlaceholderHook
|
|||||||
* @return plugin name that this expansion requires to function
|
* @return plugin name that this expansion requires to function
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getRequiredPlugin()
|
public String getRequiredPlugin() {
|
||||||
{
|
return null;
|
||||||
return getPlugin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,8 +90,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook
|
|||||||
* @return placeholder list that this expansion provides
|
* @return placeholder list that this expansion provides
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<String> getPlaceholders()
|
public List<String> getPlaceholders() {
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,8 +102,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook
|
|||||||
*
|
*
|
||||||
* @return if this expansion should persist through placeholder reloads
|
* @return if this expansion should persist through placeholder reloads
|
||||||
*/
|
*/
|
||||||
public boolean persist()
|
public boolean persist() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,9 +112,9 @@ public abstract class PlaceholderExpansion extends PlaceholderHook
|
|||||||
*
|
*
|
||||||
* @return true if the identifier for this expansion is already registered
|
* @return true if the identifier for this expansion is already registered
|
||||||
*/
|
*/
|
||||||
public final boolean isRegistered()
|
public final boolean isRegistered() {
|
||||||
{
|
return getPlaceholderAPI().getLocalExpansionManager().findExpansionByIdentifier(getIdentifier())
|
||||||
return getPlaceholderAPI().getLocalExpansionManager().findExpansionByIdentifier(getIdentifier()).map(it -> it.equals(this)).orElse(false);
|
.map(it -> it.equals(this)).orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -133,21 +124,18 @@ public abstract class PlaceholderExpansion extends PlaceholderHook
|
|||||||
*
|
*
|
||||||
* @return true if this hook meets all the requirements to register
|
* @return true if this hook meets all the requirements to register
|
||||||
*/
|
*/
|
||||||
public boolean canRegister()
|
public boolean canRegister() {
|
||||||
{
|
return getRequiredPlugin() == null
|
||||||
return getRequiredPlugin() == null || Bukkit.getPluginManager().getPlugin(getRequiredPlugin()) != null;
|
|| Bukkit.getPluginManager().getPlugin(getRequiredPlugin()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to register this PlaceholderExpansion
|
* Attempt to register this PlaceholderExpansion
|
||||||
*
|
*
|
||||||
* @return true if this expansion is now registered with PlaceholderAPI
|
* @return true if this expansion is now registered with PlaceholderAPI
|
||||||
* @deprecated This is going to be final in the future, startup and shutdown logic will have their own methods soon.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public boolean register() {
|
||||||
public boolean register()
|
return getPlaceholderAPI().getLocalExpansionManager().register(this);
|
||||||
{
|
|
||||||
return canRegister() && getPlaceholderAPI().getLocalExpansionManager().register(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,8 +143,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook
|
|||||||
*
|
*
|
||||||
* @return true if this expansion is now unregistered with PlaceholderAPI
|
* @return true if this expansion is now unregistered with PlaceholderAPI
|
||||||
*/
|
*/
|
||||||
public final boolean unregister()
|
public final boolean unregister() {
|
||||||
{
|
|
||||||
return getPlaceholderAPI().getLocalExpansionManager().unregister(this);
|
return getPlaceholderAPI().getLocalExpansionManager().unregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,83 +154,228 @@ public abstract class PlaceholderExpansion extends PlaceholderHook
|
|||||||
* @return {@link PlaceholderAPIPlugin} instance
|
* @return {@link PlaceholderAPIPlugin} instance
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public final PlaceholderAPIPlugin getPlaceholderAPI()
|
public final PlaceholderAPIPlugin getPlaceholderAPI() {
|
||||||
{
|
|
||||||
return PlaceholderAPIPlugin.getInstance();
|
return PlaceholderAPIPlugin.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// === Configuration ===
|
// === 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 epxpansion has.
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public final ConfigurationSection getConfigSection()
|
public final ConfigurationSection getConfigSection() {
|
||||||
{
|
|
||||||
return getPlaceholderAPI().getConfig().getConfigurationSection("expansions." + getIdentifier());
|
return getPlaceholderAPI().getConfig().getConfigurationSection("expansions." + getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
@Nullable
|
||||||
public final ConfigurationSection getConfigSection(@NotNull final String path)
|
public final ConfigurationSection getConfigSection(@NotNull final String path) {
|
||||||
{
|
|
||||||
final ConfigurationSection section = getConfigSection();
|
final ConfigurationSection section = getConfigSection();
|
||||||
return section == null ? null : section.getConfigurationSection(path);
|
return section == null ? null : section.getConfigurationSection(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Object relative to the {@link #getConfigSection() default ConfigurationSection} 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
|
@Nullable
|
||||||
@Contract("_, !null -> !null")
|
@Contract("_, !null -> !null")
|
||||||
public final Object get(@NotNull final String path, final Object def)
|
public final Object get(@NotNull final String path, final Object def) {
|
||||||
{
|
|
||||||
final ConfigurationSection section = getConfigSection();
|
final ConfigurationSection section = getConfigSection();
|
||||||
return section == null ? def : section.get(path, def);
|
return section == null ? def : section.get(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getInt(@NotNull final String path, final int def)
|
/**
|
||||||
{
|
* Gets the int relative to the {@link #getConfigSection() default ConfigurationSection} 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 ConfigurationSection section = getConfigSection();
|
final ConfigurationSection section = getConfigSection();
|
||||||
return section == null ? def : section.getInt(path, def);
|
return section == null ? def : section.getInt(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final long getLong(@NotNull final String path, final long def)
|
/**
|
||||||
{
|
* Gets the long relative to the {@link #getConfigSection() default ConfigurationSection} 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 ConfigurationSection section = getConfigSection();
|
final ConfigurationSection section = getConfigSection();
|
||||||
return section == null ? def : section.getLong(path, def);
|
return section == null ? def : section.getLong(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final double getDouble(@NotNull final String path, final double def)
|
/**
|
||||||
{
|
* Gets the double relative to the {@link #getConfigSection() default ConfigurationSection} 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 ConfigurationSection section = getConfigSection();
|
final ConfigurationSection section = getConfigSection();
|
||||||
return section == null ? def : section.getDouble(path, def);
|
return section == null ? def : section.getDouble(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the String relative to the {@link #getConfigSection() default ConfigurationSection} 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
|
@Nullable
|
||||||
@Contract("_, !null -> !null")
|
@Contract("_, !null -> !null")
|
||||||
public final String getString(@NotNull final String path, @Nullable final String def)
|
public final String getString(@NotNull final String path, @Nullable final String def) {
|
||||||
{
|
|
||||||
final ConfigurationSection section = getConfigSection();
|
final ConfigurationSection section = getConfigSection();
|
||||||
return section == null ? def : section.getString(path, def);
|
return section == null ? def : section.getString(path, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a String List relative to the {@link #getConfigSection() default ConfigurationSection} 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
|
@NotNull
|
||||||
public final List<String> getStringList(@NotNull final String path)
|
public final List<String> getStringList(@NotNull final String path) {
|
||||||
{
|
|
||||||
final ConfigurationSection section = getConfigSection();
|
final ConfigurationSection section = getConfigSection();
|
||||||
return section == null ? Collections.emptyList() : section.getStringList(path);
|
return section == null ? Collections.emptyList() : section.getStringList(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean configurationContains(@NotNull final String path)
|
/**
|
||||||
{
|
* Gets the boolean relative to the {@link #getConfigSection() default ConfigurationSection} 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 ConfigurationSection section = getConfigSection();
|
||||||
|
return section == null ? def : section.getBoolean(path, def);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the {@link #getConfigSection() default ConfigurationSection} 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 ConfigurationSection section = getConfigSection();
|
final ConfigurationSection section = getConfigSection();
|
||||||
return section != null && section.contains(path);
|
return section != null && section.contains(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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().log(level, "[" + 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().log(level, "[" + 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
|
@Override
|
||||||
public final boolean equals(final Object o)
|
public final boolean equals(final Object o) {
|
||||||
{
|
if (this == o) {
|
||||||
if (this == o)
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(o instanceof PlaceholderExpansion))
|
if (!(o instanceof PlaceholderExpansion)) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,48 +386,14 @@ public abstract class PlaceholderExpansion extends PlaceholderHook
|
|||||||
getVersion().equals(expansion.getVersion());
|
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
|
@Override
|
||||||
public final int hashCode()
|
public final String toString() {
|
||||||
{
|
return String.format("PlaceholderExpansion[name: '%s', author: '%s', version: '%s']", getName(),
|
||||||
return Objects.hash(getIdentifier(), getAuthor(), getVersion());
|
getAuthor(), getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final String toString()
|
|
||||||
{
|
|
||||||
return String.format("PlaceholderExpansion[name: '%s', author: '%s', version: '%s']", getName(), getAuthor(), getVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
// === Deprecated API ===
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated As of versions greater than 2.8.7, use {@link #getRequiredPlugin()}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
|
||||||
public String getPlugin()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to show a description
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
|
||||||
public String getDescription()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to display a link
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
|
|
||||||
public String getLink()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -22,7 +22,22 @@ package me.clip.placeholderapi.expansion;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementing this interface allows your {@link me.clip.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 {
|
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(Player one, Player two, String identifier);
|
String onPlaceholderRequest(Player one, Player two, String identifier);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,18 +20,24 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.expansion;
|
package me.clip.placeholderapi.expansion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementing this interface adds the {@link #start() start} and {@link #stop() stop} void
|
||||||
|
* methods to your {@link me.clip.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 {
|
public interface Taskable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the implementing class has successfully been registered to the placeholder map
|
* 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
|
* <br>Tasks that need to be performed when this expansion is registered should go here
|
||||||
*/
|
*/
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the implementing class has been unregistered from PlaceholderAPI Tasks that need to
|
* Called when the implementing class has been unregistered from PlaceholderAPI.
|
||||||
* be performed when this expansion has unregistered should go here
|
* <br>Tasks that need to be performed when this expansion has unregistered should go here
|
||||||
*/
|
*/
|
||||||
void stop();
|
void stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -34,6 +34,8 @@ public interface VersionSpecific {
|
|||||||
* This method is called before the expansion is attempted to be registered The server version
|
* This method is called before the expansion is attempted to be registered The server version
|
||||||
* will be passed to this method so you know what version the server is currently running.
|
* will be passed to this method so you know what version the server is currently running.
|
||||||
*
|
*
|
||||||
|
* @param v The {@link Version} to check against
|
||||||
|
*
|
||||||
* @return true if your expansion is compatible with the version the server is running.
|
* @return true if your expansion is compatible with the version the server is running.
|
||||||
*/
|
*/
|
||||||
boolean isCompatibleWith(Version v);
|
boolean isCompatibleWith(Version v);
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,11 +20,10 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.expansion.cloud;
|
package me.clip.placeholderapi.expansion.cloud;
|
||||||
|
|
||||||
import me.clip.placeholderapi.util.TimeUtil;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import me.clip.placeholderapi.util.TimeUtil;
|
||||||
|
|
||||||
|
|
||||||
public class CloudExpansion {
|
public class CloudExpansion {
|
||||||
@@ -173,6 +172,7 @@ public class CloudExpansion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class Version {
|
public class Version {
|
||||||
|
|
||||||
private String url, version, release_notes;
|
private String url, version, release_notes;
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -22,14 +22,9 @@ package me.clip.placeholderapi.expansion.manager;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.io.Resources;
|
import com.google.common.io.Resources;
|
||||||
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
|
||||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -38,17 +33,29 @@ import java.net.URL;
|
|||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collector;
|
import java.util.stream.Collector;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
public final class CloudExpansionManager
|
public final class CloudExpansionManager {
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final String API_URL = "http://api.extendedclip.com/v2/";
|
private static final String API_URL = "http://api.extendedclip.com/v2/";
|
||||||
@@ -59,7 +66,8 @@ public final class CloudExpansionManager
|
|||||||
private static final Type TYPE = new TypeToken<Map<String, CloudExpansion>>() {}.getType();
|
private static final Type TYPE = new TypeToken<Map<String, CloudExpansion>>() {}.getType();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Collector<CloudExpansion, ?, Map<String, CloudExpansion>> INDEXED_NAME_COLLECTOR = Collectors.toMap(CloudExpansionManager::toIndexName, Function.identity());
|
private final Collector<CloudExpansion, ?, Map<String, CloudExpansion>> INDEXED_NAME_COLLECTOR = Collectors
|
||||||
|
.toMap(CloudExpansionManager::toIndexName, Function.identity());
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -70,38 +78,43 @@ public final class CloudExpansionManager
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final Map<String, CompletableFuture<File>> await = new ConcurrentHashMap<>();
|
private final Map<String, CompletableFuture<File>> await = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private final ExecutorService ASYNC_EXECUTOR =
|
||||||
|
Executors.newCachedThreadPool(
|
||||||
|
new ThreadFactoryBuilder().setNameFormat("placeholderapi-io-#%1$d").build());
|
||||||
|
|
||||||
public CloudExpansionManager(@NotNull final PlaceholderAPIPlugin plugin)
|
public CloudExpansionManager(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static String toIndexName(@NotNull final String name) {
|
||||||
|
return name.toLowerCase().replace(' ', '_');
|
||||||
|
}
|
||||||
|
|
||||||
public void load()
|
@NotNull
|
||||||
{
|
private static String toIndexName(@NotNull final CloudExpansion expansion) {
|
||||||
|
return toIndexName(expansion.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
clean();
|
clean();
|
||||||
fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kill()
|
public void kill() {
|
||||||
{
|
|
||||||
clean();
|
clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
public Map<String, CloudExpansion> getCloudExpansions()
|
public Map<String, CloudExpansion> getCloudExpansions() {
|
||||||
{
|
|
||||||
return ImmutableMap.copyOf(cache);
|
return ImmutableMap.copyOf(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
public Map<String, CloudExpansion> getCloudExpansionsInstalled()
|
public Map<String, CloudExpansion> getCloudExpansionsInstalled() {
|
||||||
{
|
if (cache.isEmpty()) {
|
||||||
if (cache.isEmpty())
|
|
||||||
{
|
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,10 +126,8 @@ public final class CloudExpansionManager
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
public Map<String, CloudExpansion> getCloudExpansionsByAuthor(@NotNull final String author)
|
public Map<String, CloudExpansion> getCloudExpansionsByAuthor(@NotNull final String author) {
|
||||||
{
|
if (cache.isEmpty()) {
|
||||||
if (cache.isEmpty())
|
|
||||||
{
|
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,161 +139,142 @@ public final class CloudExpansionManager
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
public Set<String> getCloudExpansionAuthors()
|
public Set<String> getCloudExpansionAuthors() {
|
||||||
{
|
|
||||||
return cache.values().stream().map(CloudExpansion::getAuthor).collect(Collectors.toSet());
|
return cache.values().stream().map(CloudExpansion::getAuthor).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCloudExpansionAuthorCount() {
|
||||||
public int getCloudExpansionAuthorCount()
|
|
||||||
{
|
|
||||||
return getCloudExpansionAuthors().size();
|
return getCloudExpansionAuthors().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCloudUpdateCount()
|
public int getCloudUpdateCount() {
|
||||||
{
|
|
||||||
return ((int) plugin.getLocalExpansionManager()
|
return ((int) plugin.getLocalExpansionManager()
|
||||||
.getExpansions()
|
.getExpansions()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(expansion -> findCloudExpansionByName(expansion.getName()).map(CloudExpansion::shouldUpdate).orElse(false))
|
.filter(expansion -> findCloudExpansionByName(expansion.getName())
|
||||||
|
.map(CloudExpansion::shouldUpdate).orElse(false))
|
||||||
.count());
|
.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Optional<CloudExpansion> findCloudExpansionByName(@NotNull final String name)
|
public Optional<CloudExpansion> findCloudExpansionByName(@NotNull final String name) {
|
||||||
{
|
|
||||||
return Optional.ofNullable(cache.get(toIndexName(name)));
|
return Optional.ofNullable(cache.get(toIndexName(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clean() {
|
||||||
public void clean()
|
|
||||||
{
|
|
||||||
cache.clear();
|
cache.clear();
|
||||||
|
|
||||||
await.values().forEach(future -> future.cancel(true));
|
await.values().forEach(future -> future.cancel(true));
|
||||||
await.clear();
|
await.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fetch(final boolean allowUnverified)
|
public void fetch(final boolean allowUnverified) {
|
||||||
{
|
|
||||||
plugin.getLogger().info("Fetching available expansion information...");
|
plugin.getLogger().info("Fetching available expansion information...");
|
||||||
|
|
||||||
CompletableFuture<Map<String, CloudExpansion>> future = CompletableFuture.supplyAsync(() -> {
|
ASYNC_EXECUTOR.submit(
|
||||||
final Map<String, CloudExpansion> values = new HashMap<>();
|
() -> {
|
||||||
|
// a defence tactic! use ConcurrentHashMap instead of normal HashMap
|
||||||
try
|
Map<String, CloudExpansion> values = new ConcurrentHashMap<>();
|
||||||
{
|
try {
|
||||||
//noinspection UnstableApiUsage
|
//noinspection UnstableApiUsage
|
||||||
final String json = Resources.toString(new URL(API_URL), StandardCharsets.UTF_8);
|
String json = Resources.toString(new URL(API_URL), StandardCharsets.UTF_8);
|
||||||
values.putAll(GSON.fromJson(json, TYPE));
|
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());
|
||||||
|
}
|
||||||
|
if (!allowUnverified && !expansion.isVerified()) {
|
||||||
|
toRemove.add(entry.getKey());
|
||||||
}
|
}
|
||||||
catch (final IOException ex)
|
|
||||||
{
|
|
||||||
throw new CompletionException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
values.values().removeIf(value -> value.getLatestVersion() == null || value.getVersion(value.getLatestVersion()) == null);
|
for (String name : toRemove) {
|
||||||
|
values.remove(name);
|
||||||
return values;
|
}
|
||||||
});
|
} catch (Throwable e) {
|
||||||
|
// ugly swallowing of every throwable, but we have to be defensive
|
||||||
|
plugin.getLogger().log(Level.WARNING, "Failed to download expansion information", e);
|
||||||
if (!allowUnverified)
|
|
||||||
{
|
|
||||||
future = future.thenApplyAsync((values) -> {
|
|
||||||
values.values().removeIf(expansion -> !expansion.isVerified());
|
|
||||||
return values;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// loop thru what's left on the main thread
|
||||||
|
plugin
|
||||||
|
.getServer()
|
||||||
|
.getScheduler()
|
||||||
|
.runTask(
|
||||||
|
plugin,
|
||||||
|
() -> {
|
||||||
|
try {
|
||||||
|
for (Map.Entry<String, CloudExpansion> entry : values.entrySet()) {
|
||||||
|
String name = entry.getKey();
|
||||||
|
CloudExpansion expansion = entry.getValue();
|
||||||
|
|
||||||
future = future.thenApplyAsync((values) -> {
|
|
||||||
|
|
||||||
values.forEach((name, expansion) -> {
|
|
||||||
expansion.setName(name);
|
expansion.setName(name);
|
||||||
|
|
||||||
final Optional<PlaceholderExpansion> local = plugin.getLocalExpansionManager().findExpansionByName(name);
|
Optional<PlaceholderExpansion> localOpt =
|
||||||
if (local.isPresent() && local.get().isRegistered())
|
plugin.getLocalExpansionManager().findExpansionByName(name);
|
||||||
{
|
if (localOpt.isPresent()) {
|
||||||
|
PlaceholderExpansion local = localOpt.get();
|
||||||
|
if (local.isRegistered()) {
|
||||||
expansion.setHasExpansion(true);
|
expansion.setHasExpansion(true);
|
||||||
expansion.setShouldUpdate(!local.get().getVersion().equals(expansion.getLatestVersion()));
|
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
|
||||||
|
plugin
|
||||||
|
.getLogger()
|
||||||
|
.log(Level.WARNING, "Failed to download expansion information", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return values;
|
|
||||||
});
|
|
||||||
|
|
||||||
future.whenComplete((expansions, exception) -> {
|
|
||||||
|
|
||||||
if (exception != null)
|
|
||||||
{
|
|
||||||
plugin.getLogger().log(Level.WARNING, "failed to download expansion information", exception);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (final CloudExpansion expansion : expansions.values())
|
|
||||||
{
|
|
||||||
this.cache.put(toIndexName(expansion), expansion);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDownloading(@NotNull final CloudExpansion expansion) {
|
||||||
public boolean isDownloading(@NotNull final CloudExpansion expansion)
|
|
||||||
{
|
|
||||||
return await.containsKey(toIndexName(expansion));
|
return await.containsKey(toIndexName(expansion));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public CompletableFuture<File> downloadExpansion(@NotNull final CloudExpansion expansion, @NotNull final CloudExpansion.Version version)
|
public CompletableFuture<File> downloadExpansion(@NotNull final CloudExpansion expansion,
|
||||||
{
|
@NotNull final CloudExpansion.Version version) {
|
||||||
final CompletableFuture<File> previous = await.get(toIndexName(expansion));
|
final CompletableFuture<File> previous = await.get(toIndexName(expansion));
|
||||||
if (previous != null)
|
if (previous != null) {
|
||||||
{
|
|
||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
final File file = new File(plugin.getLocalExpansionManager().getExpansionsFolder(), "Expansion-" + toIndexName(expansion) + ".jar");
|
final File file = new File(plugin.getLocalExpansionManager().getExpansionsFolder(),
|
||||||
|
"Expansion-" + toIndexName(expansion) + ".jar");
|
||||||
|
|
||||||
final CompletableFuture<File> download = CompletableFuture.supplyAsync(() -> {
|
final CompletableFuture<File> download = CompletableFuture.supplyAsync(() -> {
|
||||||
try (final ReadableByteChannel source = Channels.newChannel(new URL(version.getUrl()).openStream()); final FileOutputStream target = new FileOutputStream(file))
|
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);
|
target.getChannel().transferFrom(source, 0, Long.MAX_VALUE);
|
||||||
}
|
} catch (final IOException ex) {
|
||||||
catch (final IOException ex)
|
|
||||||
{
|
|
||||||
throw new CompletionException(ex);
|
throw new CompletionException(ex);
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
});
|
}, ASYNC_EXECUTOR);
|
||||||
|
|
||||||
download.whenCompleteAsync((value, exception) -> {
|
download.whenCompleteAsync((value, exception) -> {
|
||||||
await.remove(toIndexName(expansion));
|
await.remove(toIndexName(expansion));
|
||||||
|
|
||||||
if (exception != null)
|
if (exception != null) {
|
||||||
{
|
plugin.getLogger().log(Level.SEVERE,
|
||||||
plugin.getLogger().log(Level.SEVERE, "failed to download " + expansion.getName() + ":" + version.getVersion(), exception);
|
"failed to download " + expansion.getName() + ":" + version.getVersion(), exception);
|
||||||
}
|
}
|
||||||
});
|
}, ASYNC_EXECUTOR);
|
||||||
|
|
||||||
await.put(toIndexName(expansion), download);
|
await.put(toIndexName(expansion), download);
|
||||||
|
|
||||||
return download;
|
return download;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static String toIndexName(@NotNull final String name)
|
|
||||||
{
|
|
||||||
return name.toLowerCase().replace(' ', '_');
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static String toIndexName(@NotNull final CloudExpansion expansion)
|
|
||||||
{
|
|
||||||
return toIndexName(expansion.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -25,6 +25,7 @@ import com.google.common.collect.Sets;
|
|||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.events.ExpansionRegisterEvent;
|
import me.clip.placeholderapi.events.ExpansionRegisterEvent;
|
||||||
import me.clip.placeholderapi.events.ExpansionUnregisterEvent;
|
import me.clip.placeholderapi.events.ExpansionUnregisterEvent;
|
||||||
|
import me.clip.placeholderapi.events.ExpansionsLoadedEvent;
|
||||||
import me.clip.placeholderapi.expansion.*;
|
import me.clip.placeholderapi.expansion.*;
|
||||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||||
import me.clip.placeholderapi.util.FileUtil;
|
import me.clip.placeholderapi.util.FileUtil;
|
||||||
@@ -45,22 +46,25 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class LocalExpansionManager implements Listener
|
public final class LocalExpansionManager implements Listener {
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final String EXPANSIONS_FOLDER_NAME = "expansions";
|
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
|
@NotNull
|
||||||
private final File folder;
|
private final File folder;
|
||||||
@@ -68,135 +72,152 @@ public final class LocalExpansionManager implements Listener
|
|||||||
private final PlaceholderAPIPlugin plugin;
|
private final PlaceholderAPIPlugin plugin;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Map<String, PlaceholderExpansion> expansions = new HashMap<>();
|
private final Map<String, PlaceholderExpansion> expansions = new ConcurrentHashMap<>();
|
||||||
|
private final ReentrantLock expansionsLock = new ReentrantLock();
|
||||||
|
|
||||||
|
|
||||||
public LocalExpansionManager(@NotNull final PlaceholderAPIPlugin plugin)
|
public LocalExpansionManager(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.folder = new File(plugin.getDataFolder(), EXPANSIONS_FOLDER_NAME);
|
this.folder = new File(plugin.getDataFolder(), EXPANSIONS_FOLDER_NAME);
|
||||||
|
|
||||||
if (!this.folder.exists() && !folder.mkdirs())
|
if (!this.folder.exists() && !folder.mkdirs()) {
|
||||||
{
|
|
||||||
plugin.getLogger().log(Level.WARNING, "failed to create expansions folder!");
|
plugin.getLogger().log(Level.WARNING, "failed to create expansions folder!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(@NotNull final CommandSender sender)
|
public void load(@NotNull final CommandSender sender) {
|
||||||
{
|
|
||||||
registerAll(sender);
|
registerAll(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kill()
|
public void kill() {
|
||||||
{
|
|
||||||
unregisterAll();
|
unregisterAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public File getExpansionsFolder()
|
public File getExpansionsFolder() {
|
||||||
{
|
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpansionsCount()
|
|
||||||
{
|
|
||||||
return expansions.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
public Collection<String> getIdentifiers()
|
public Collection<String> getIdentifiers() {
|
||||||
{
|
expansionsLock.lock();
|
||||||
|
try {
|
||||||
return ImmutableSet.copyOf(expansions.keySet());
|
return ImmutableSet.copyOf(expansions.keySet());
|
||||||
|
} finally {
|
||||||
|
expansionsLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
public Collection<PlaceholderExpansion> getExpansions()
|
public Collection<PlaceholderExpansion> getExpansions() {
|
||||||
{
|
expansionsLock.lock();
|
||||||
|
try {
|
||||||
return ImmutableSet.copyOf(expansions.values());
|
return ImmutableSet.copyOf(expansions.values());
|
||||||
|
} finally {
|
||||||
|
expansionsLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public PlaceholderExpansion getExpansion(@NotNull final String identifier)
|
public PlaceholderExpansion getExpansion(@NotNull final String identifier) {
|
||||||
{
|
expansionsLock.lock();
|
||||||
|
try {
|
||||||
return expansions.get(identifier.toLowerCase());
|
return expansions.get(identifier.toLowerCase());
|
||||||
|
} finally {
|
||||||
|
expansionsLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public Optional<PlaceholderExpansion> findExpansionByName(@NotNull final String name)
|
|
||||||
{
|
|
||||||
return expansions.values().stream().filter(expansion -> name.equalsIgnoreCase(expansion.getName())).findFirst();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Optional<PlaceholderExpansion> findExpansionByIdentifier(@NotNull final String identifier)
|
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));
|
return Optional.ofNullable(getExpansion(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Optional<PlaceholderExpansion> register(@NotNull final Class<? extends PlaceholderExpansion> clazz)
|
public Optional<PlaceholderExpansion> register(
|
||||||
{
|
@NotNull final Class<? extends PlaceholderExpansion> clazz) {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
final PlaceholderExpansion expansion = createExpansionInstance(clazz);
|
final PlaceholderExpansion expansion = createExpansionInstance(clazz);
|
||||||
if (expansion == null || !expansion.register())
|
|
||||||
{
|
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.register()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.of(expansion);
|
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!";
|
||||||
}
|
}
|
||||||
catch (final LinkageError ex)
|
|
||||||
{
|
plugin.getLogger().severe("Failed to load expansion class " + clazz.getSimpleName() +
|
||||||
plugin.getLogger().severe("expansion class " + clazz.getSimpleName() + " is outdated: \n" +
|
reason);
|
||||||
"Failed to load due to a [" + ex.getClass().getSimpleName() + "], attempted to use " + ex.getMessage());
|
plugin.getLogger().log(Level.SEVERE, "", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Do not call this method yourself, use {@link PlaceholderExpansion#register()}
|
|
||||||
*/
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public boolean register(@NotNull final PlaceholderExpansion expansion)
|
public boolean register(@NotNull final PlaceholderExpansion expansion) {
|
||||||
{
|
final String identifier = expansion.getIdentifier().toLowerCase();
|
||||||
final String identifier = expansion.getIdentifier();
|
|
||||||
|
|
||||||
if (expansion instanceof Configurable)
|
if (!expansion.canRegister()) {
|
||||||
{
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expansion instanceof Configurable) {
|
||||||
Map<String, Object> defaults = ((Configurable) expansion).getDefaults();
|
Map<String, Object> defaults = ((Configurable) expansion).getDefaults();
|
||||||
String pre = "expansions." + expansion.getIdentifier() + ".";
|
String pre = "expansions." + identifier + ".";
|
||||||
FileConfiguration cfg = plugin.getConfig();
|
FileConfiguration cfg = plugin.getConfig();
|
||||||
boolean save = false;
|
boolean save = false;
|
||||||
|
|
||||||
if (defaults != null)
|
if (defaults != null) {
|
||||||
{
|
for (Map.Entry<String, Object> entries : defaults.entrySet()) {
|
||||||
for (Map.Entry<String, Object> entries : defaults.entrySet())
|
if (entries.getKey() == null || entries.getKey().isEmpty()) {
|
||||||
{
|
|
||||||
if (entries.getKey() == null || entries.getKey().isEmpty())
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries.getValue() == null)
|
if (entries.getValue() == null) {
|
||||||
{
|
if (cfg.contains(pre + entries.getKey())) {
|
||||||
if (cfg.contains(pre + entries.getKey()))
|
|
||||||
{
|
|
||||||
save = true;
|
save = true;
|
||||||
cfg.set(pre + entries.getKey(), null);
|
cfg.set(pre + entries.getKey(), null);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (!cfg.contains(pre + entries.getKey())) {
|
||||||
{
|
|
||||||
if (!cfg.contains(pre + entries.getKey()))
|
|
||||||
{
|
|
||||||
save = true;
|
save = true;
|
||||||
cfg.set(pre + entries.getKey(), entries.getValue());
|
cfg.set(pre + entries.getKey(), entries.getValue());
|
||||||
}
|
}
|
||||||
@@ -204,97 +225,88 @@ public final class LocalExpansionManager implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (save)
|
if (save) {
|
||||||
{
|
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expansion instanceof VersionSpecific)
|
if (expansion instanceof VersionSpecific) {
|
||||||
{
|
|
||||||
VersionSpecific nms = (VersionSpecific) expansion;
|
VersionSpecific nms = (VersionSpecific) expansion;
|
||||||
if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion()))
|
if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion())) {
|
||||||
{
|
plugin.getLogger().warning("Your server version is not compatible with expansion " +
|
||||||
plugin.getLogger().info("Your server version is not compatible with expansion: " + expansion.getIdentifier() + " version: " + expansion.getVersion());
|
expansion.getIdentifier() + " " + expansion.getVersion());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlaceholderExpansion removed = expansions.get(expansion.getIdentifier());
|
final PlaceholderExpansion removed = getExpansion(identifier);
|
||||||
if (removed != null && !removed.unregister())
|
if (removed != null && !removed.unregister()) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ExpansionRegisterEvent event = new ExpansionRegisterEvent(expansion);
|
final ExpansionRegisterEvent event = new ExpansionRegisterEvent(expansion);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled())
|
if (event.isCancelled()) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
expansions.put(expansion.getIdentifier(), expansion);
|
expansionsLock.lock();
|
||||||
|
try {
|
||||||
|
expansions.put(identifier, expansion);
|
||||||
|
} finally {
|
||||||
|
expansionsLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
if (expansion instanceof Listener)
|
if (expansion instanceof Listener) {
|
||||||
{
|
|
||||||
Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);
|
Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getLogger().info("Successfully registered expansion: " + expansion.getIdentifier());
|
plugin.getLogger().info("Successfully registered expansion: " + expansion.getIdentifier() +
|
||||||
|
" [" + expansion.getVersion() + "]");
|
||||||
|
|
||||||
if (expansion instanceof Taskable)
|
if (expansion instanceof Taskable) {
|
||||||
{
|
|
||||||
((Taskable) expansion).start();
|
((Taskable) expansion).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getPlaceholderAPIConfig().isCloudEnabled())
|
if (plugin.getPlaceholderAPIConfig().isCloudEnabled()) {
|
||||||
{
|
final Optional<CloudExpansion> cloudExpansionOptional =
|
||||||
final Optional<CloudExpansion> cloudExpansion = plugin.getCloudExpansionManager().findCloudExpansionByName(identifier);
|
plugin.getCloudExpansionManager().findCloudExpansionByName(identifier);
|
||||||
if (cloudExpansion.isPresent())
|
if (cloudExpansionOptional.isPresent()) {
|
||||||
{
|
CloudExpansion cloudExpansion = cloudExpansionOptional.get();
|
||||||
cloudExpansion.get().setHasExpansion(true);
|
cloudExpansion.setHasExpansion(true);
|
||||||
cloudExpansion.get().setShouldUpdate(!cloudExpansion.get().getLatestVersion().equals(expansion.getVersion()));
|
cloudExpansion.setShouldUpdate(
|
||||||
|
!cloudExpansion.getLatestVersion().equals(expansion.getVersion()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Do not call this method yourself, use {@link PlaceholderExpansion#unregister()}
|
|
||||||
*/
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public boolean unregister(@NotNull final PlaceholderExpansion expansion)
|
public boolean unregister(@NotNull final PlaceholderExpansion expansion) {
|
||||||
{
|
if (expansions.remove(expansion.getIdentifier()) == null) {
|
||||||
if (expansions.remove(expansion.getIdentifier()) == null)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new ExpansionUnregisterEvent(expansion));
|
Bukkit.getPluginManager().callEvent(new ExpansionUnregisterEvent(expansion));
|
||||||
|
|
||||||
|
if (expansion instanceof Listener) {
|
||||||
if (expansion instanceof Listener)
|
|
||||||
{
|
|
||||||
HandlerList.unregisterAll((Listener) expansion);
|
HandlerList.unregisterAll((Listener) expansion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expansion instanceof Taskable)
|
if (expansion instanceof Taskable) {
|
||||||
{
|
|
||||||
((Taskable) expansion).stop();
|
((Taskable) expansion).stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expansion instanceof Cacheable)
|
if (expansion instanceof Cacheable) {
|
||||||
{
|
|
||||||
((Cacheable) expansion).clear();
|
((Cacheable) expansion).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getPlaceholderAPIConfig().isCloudEnabled())
|
if (plugin.getPlaceholderAPIConfig().isCloudEnabled()) {
|
||||||
{
|
plugin.getCloudExpansionManager().findCloudExpansionByName(expansion.getName())
|
||||||
plugin.getCloudExpansionManager().findCloudExpansionByName(expansion.getName()).ifPresent(cloud -> {
|
.ifPresent(cloud -> {
|
||||||
cloud.setHasExpansion(false);
|
cloud.setHasExpansion(false);
|
||||||
cloud.setShouldUpdate(false);
|
cloud.setShouldUpdate(false);
|
||||||
});
|
});
|
||||||
@@ -304,30 +316,51 @@ public final class LocalExpansionManager implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void registerAll(@NotNull final CommandSender sender)
|
private void registerAll(@NotNull final CommandSender sender) {
|
||||||
{
|
|
||||||
plugin.getLogger().info("Placeholder expansion registration initializing...");
|
plugin.getLogger().info("Placeholder expansion registration initializing...");
|
||||||
|
|
||||||
Futures.onMainThread(plugin, findExpansionsOnDisk(), (classes, exception) -> {
|
Futures.onMainThread(plugin, findExpansionsOnDisk(), (classes, exception) -> {
|
||||||
if (exception != null)
|
if (exception != null) {
|
||||||
{
|
|
||||||
plugin.getLogger().log(Level.SEVERE, "failed to load class files of expansions", exception);
|
plugin.getLogger().log(Level.SEVERE, "failed to load class files of expansions", exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final long registered = classes.stream().map(this::register).filter(Optional::isPresent).count();
|
final List<PlaceholderExpansion> registered = classes.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(this::register)
|
||||||
|
.filter(Optional::isPresent)
|
||||||
|
.map(Optional::get)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
Msg.msg(sender,
|
final long needsUpdate = registered.stream()
|
||||||
registered == 0 ? "&6No expansions were registered!" : registered + "&a placeholder hooks successfully registered!");
|
.map(expansion -> plugin.getCloudExpansionManager().findCloudExpansionByName(expansion.getName()).orElse(null))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(CloudExpansion::shouldUpdate)
|
||||||
|
.count();
|
||||||
|
|
||||||
|
StringBuilder message = new StringBuilder(registered.size() == 0 ? "&6" : "&a")
|
||||||
|
.append(registered.size())
|
||||||
|
.append(' ')
|
||||||
|
.append("placeholder hook(s) registered!");
|
||||||
|
|
||||||
|
if (needsUpdate > 0) {
|
||||||
|
message.append(' ')
|
||||||
|
.append("&6")
|
||||||
|
.append(needsUpdate)
|
||||||
|
.append(' ')
|
||||||
|
.append("placeholder hook(s) have an update available.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Msg.msg(sender, message.toString());
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().callEvent(new ExpansionsLoadedEvent(registered));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unregisterAll()
|
private void unregisterAll() {
|
||||||
{
|
for (final PlaceholderExpansion expansion : Sets.newHashSet(expansions.values())) {
|
||||||
for (final PlaceholderExpansion expansion : Sets.newHashSet(expansions.values()))
|
if (expansion.persist()) {
|
||||||
{
|
|
||||||
if (expansion.persist())
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,31 +368,47 @@ public final class LocalExpansionManager implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public CompletableFuture<@NotNull List<@NotNull Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk()
|
public CompletableFuture<@NotNull List<@Nullable Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk() {
|
||||||
{
|
File[] files = folder.listFiles((dir, name) -> name.endsWith(".jar"));
|
||||||
return Arrays.stream(folder.listFiles((dir, name) -> name.endsWith(".jar")))
|
if(files == null){
|
||||||
|
return CompletableFuture.completedFuture(Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Arrays.stream(files)
|
||||||
.map(this::findExpansionInFile)
|
.map(this::findExpansionInFile)
|
||||||
.collect(Futures.collector());
|
.collect(Futures.collector());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public CompletableFuture<@Nullable Class<? extends PlaceholderExpansion>> findExpansionInFile(@NotNull final File file)
|
public CompletableFuture<@Nullable Class<? extends PlaceholderExpansion>> findExpansionInFile(
|
||||||
{
|
@NotNull final File file) {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
try
|
try {
|
||||||
{
|
final Class<? extends PlaceholderExpansion> expansionClass = FileUtil.findClass(file, PlaceholderExpansion.class);
|
||||||
return FileUtil.findClass(file, PlaceholderExpansion.class);
|
|
||||||
}
|
if (expansionClass == null) {
|
||||||
catch (final VerifyError ex)
|
plugin.getLogger().severe("Failed to load Expansion: " + file.getName() + ", as it does not have" +
|
||||||
{
|
" a class which extends PlaceholderExpansion.");
|
||||||
plugin.getLogger().severe("expansion file " + file.getName() + " is outdated: \n" +
|
|
||||||
"Failed to load due to a [" + ex.getClass().getSimpleName() + "], attempted to use" + ex.getMessage().substring(ex.getMessage().lastIndexOf(' ')));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (final Exception ex)
|
|
||||||
{
|
Set<MethodSignature> expansionMethods = Arrays.stream(expansionClass.getDeclaredMethods())
|
||||||
|
.map(method -> new MethodSignature(method.getName(), method.getParameterTypes()))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
if (!expansionMethods.containsAll(ABSTRACT_EXPANSION_METHODS)) {
|
||||||
|
plugin.getLogger().severe("Failed to load Expansion: " + file.getName() + ", as it does not have the" +
|
||||||
|
" required methods declared for a PlaceholderExpansion.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return expansionClass;
|
||||||
|
} catch (final VerifyError ex) {
|
||||||
|
plugin.getLogger().severe("Failed to load Expansion class " + file.getName() +
|
||||||
|
" (Is a dependency missing?)");
|
||||||
|
plugin.getLogger().severe("Cause: " + ex.getClass().getSimpleName() + " " + ex.getMessage());
|
||||||
|
return null;
|
||||||
|
} catch (final Exception ex) {
|
||||||
throw new CompletionException(ex);
|
throw new CompletionException(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -367,32 +416,26 @@ public final class LocalExpansionManager implements Listener
|
|||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public PlaceholderExpansion createExpansionInstance(@NotNull final Class<? extends PlaceholderExpansion> clazz) throws LinkageError
|
public PlaceholderExpansion createExpansionInstance(
|
||||||
{
|
@NotNull final Class<? extends PlaceholderExpansion> clazz) throws LinkageError {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
return clazz.getDeclaredConstructor().newInstance();
|
return clazz.getDeclaredConstructor().newInstance();
|
||||||
}
|
} catch (final Exception ex) {
|
||||||
catch (final Exception ex)
|
if (ex.getCause() instanceof LinkageError) {
|
||||||
{
|
|
||||||
if (ex.getCause() instanceof LinkageError)
|
|
||||||
{
|
|
||||||
throw ((LinkageError) ex.getCause());
|
throw ((LinkageError) ex.getCause());
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getLogger().log(Level.SEVERE, "Failed to load placeholder expansion from class: " + clazz.getName(), ex);
|
plugin.getLogger().warning("There was an issue with loading an expansion.");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuit(@NotNull final PlayerQuitEvent event)
|
public void onQuit(@NotNull final PlayerQuitEvent event) {
|
||||||
{
|
for (final PlaceholderExpansion expansion : getExpansions()) {
|
||||||
for (final PlaceholderExpansion expansion : getExpansions())
|
if (!(expansion instanceof Cleanable)) {
|
||||||
{
|
|
||||||
if (!(expansion instanceof Cleanable))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,18 +444,14 @@ public final class LocalExpansionManager implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPluginDisable(@NotNull final PluginDisableEvent event)
|
public void onPluginDisable(@NotNull final PluginDisableEvent event) {
|
||||||
{
|
|
||||||
final String name = event.getPlugin().getName();
|
final String name = event.getPlugin().getName();
|
||||||
if (name.equals(plugin.getName()))
|
if (name.equals(plugin.getName())) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final PlaceholderExpansion expansion : getExpansions())
|
for (final PlaceholderExpansion expansion : getExpansions()) {
|
||||||
{
|
if (!name.equalsIgnoreCase(expansion.getRequiredPlugin())) {
|
||||||
if (!name.equalsIgnoreCase(expansion.getRequiredPlugin()))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package me.clip.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -28,14 +28,12 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.server.ServerLoadEvent;
|
import org.bukkit.event.server.ServerLoadEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public final class ServerLoadEventListener implements Listener
|
public final class ServerLoadEventListener implements Listener {
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final PlaceholderAPIPlugin plugin;
|
private final PlaceholderAPIPlugin plugin;
|
||||||
|
|
||||||
public ServerLoadEventListener(@NotNull final PlaceholderAPIPlugin plugin)
|
public ServerLoadEventListener(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
@@ -44,16 +42,15 @@ public final class ServerLoadEventListener implements Listener
|
|||||||
/**
|
/**
|
||||||
* This method will be called when the server is first loaded
|
* This method will be called when the server is first loaded
|
||||||
* <p>
|
* <p>
|
||||||
* The goal of the method is to register all the expansions as soon as possible
|
* The goal of the method is to register all the expansions as soon as possible especially before
|
||||||
* especially before players can join
|
* players can join
|
||||||
* <p>
|
* <p>
|
||||||
* This will ensure no issues with expansions and hooks.
|
* This will ensure no issues with expansions and hooks.
|
||||||
*
|
*
|
||||||
* @param event the server load event
|
* @param event the server load event
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerLoad(@NotNull final ServerLoadEvent event)
|
public void onServerLoad(@NotNull final ServerLoadEvent event) {
|
||||||
{
|
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
plugin.getLocalExpansionManager().load(Bukkit.getConsoleSender());
|
plugin.getLocalExpansionManager().load(Bukkit.getConsoleSender());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,60 +20,53 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.replacer;
|
package me.clip.placeholderapi.replacer;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.function.Function;
|
public final class CharsReplacer implements Replacer {
|
||||||
|
|
||||||
public final class CharsReplacer implements Replacer
|
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Closure closure;
|
private final Closure closure;
|
||||||
|
|
||||||
public CharsReplacer(@NotNull final Closure closure)
|
public CharsReplacer(@NotNull final Closure closure) {
|
||||||
{
|
|
||||||
this.closure = closure;
|
this.closure = closure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup)
|
public String apply(@NotNull final String text, @Nullable final OfflinePlayer player,
|
||||||
{
|
@NotNull final Function<String, @Nullable PlaceholderExpansion> lookup) {
|
||||||
final char[] chars = text.toCharArray();
|
final char[] chars = text.toCharArray();
|
||||||
final StringBuilder builder = new StringBuilder(text.length());
|
final StringBuilder builder = new StringBuilder(text.length());
|
||||||
|
|
||||||
final StringBuilder identifier = new StringBuilder();
|
final StringBuilder identifier = new StringBuilder();
|
||||||
final StringBuilder parameters = new StringBuilder();
|
final StringBuilder parameters = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i < chars.length; i++)
|
for (int i = 0; i < chars.length; i++) {
|
||||||
{
|
|
||||||
final char l = chars[i];
|
final char l = chars[i];
|
||||||
|
|
||||||
if (l == '&' && ++i < chars.length)
|
if (l == '&' && ++i < chars.length) {
|
||||||
{
|
|
||||||
final char c = Character.toLowerCase(chars[i]);
|
final char c = Character.toLowerCase(chars[i]);
|
||||||
|
|
||||||
if (c != '0' && c != '1' && c != '2' && c != '3' && c != '4' && c != '5' && c != '6' && c != '7' && c != '8' && c != '9' && c != 'a' && c != 'b' && c != 'c' && c != 'd' && c != 'e' && c != 'f' && c != 'k' && c != 'l' && c != 'm' && c != 'o' && c != 'r' && c != 'x')
|
if (c != '0' && c != '1' && c != '2' && c != '3' && c != '4' && c != '5' && c != '6'
|
||||||
{
|
&& c != '7' && c != '8' && c != '9' && c != 'a' && c != 'b' && c != 'c' && c != 'd'
|
||||||
|
&& c != 'e' && c != 'f' && c != 'k' && c != 'l' && c != 'm' && c != 'n' && c != 'o' && c != 'r'
|
||||||
|
&& c != 'x') {
|
||||||
builder.append(l).append(chars[i]);
|
builder.append(l).append(chars[i]);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
builder.append(ChatColor.COLOR_CHAR);
|
builder.append(ChatColor.COLOR_CHAR);
|
||||||
|
|
||||||
if (c != 'x')
|
if (c != 'x') {
|
||||||
{
|
|
||||||
builder.append(chars[i]);
|
builder.append(chars[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i > 1 && chars[i - 2] == '\\') /*allow escaping &x*/)
|
if ((i > 1 && chars[i - 2] == '\\') /*allow escaping &x*/) {
|
||||||
{
|
|
||||||
builder.setLength(builder.length() - 2);
|
builder.setLength(builder.length() - 2);
|
||||||
builder.append('&').append(chars[i]);
|
builder.append('&').append(chars[i]);
|
||||||
continue;
|
continue;
|
||||||
@@ -82,10 +75,8 @@ public final class CharsReplacer implements Replacer
|
|||||||
builder.append(c);
|
builder.append(c);
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (++j <= 6)
|
while (++j <= 6) {
|
||||||
{
|
if (i + j >= chars.length) {
|
||||||
if (i + j >= chars.length)
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,83 +84,72 @@ public final class CharsReplacer implements Replacer
|
|||||||
builder.append(ChatColor.COLOR_CHAR).append(x);
|
builder.append(ChatColor.COLOR_CHAR).append(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j == 7)
|
if (j == 7) {
|
||||||
{
|
|
||||||
i += 6;
|
i += 6;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
builder.setLength(builder.length() - (j * 2)); // undo &x parsing
|
builder.setLength(builder.length() - (j * 2)); // undo &x parsing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l != closure.head || i + 1 >= chars.length)
|
if (l != closure.head || i + 1 >= chars.length) {
|
||||||
{
|
|
||||||
builder.append(l);
|
builder.append(l);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean identified = false;
|
boolean identified = false;
|
||||||
boolean oopsitsbad = true;
|
boolean oopsitsbad = true;
|
||||||
|
boolean hadSpace = false;
|
||||||
|
|
||||||
while (++i < chars.length)
|
while (++i < chars.length) {
|
||||||
{
|
|
||||||
final char p = chars[i];
|
final char p = chars[i];
|
||||||
|
|
||||||
if (p == ' ' && !identified)
|
if (p == ' ' && !identified) {
|
||||||
{
|
hadSpace = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (p == closure.tail)
|
if (p == closure.tail) {
|
||||||
{
|
|
||||||
oopsitsbad = false;
|
oopsitsbad = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p == '_' && !identified)
|
if (p == '_' && !identified) {
|
||||||
{
|
|
||||||
identified = true;
|
identified = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (identified)
|
if (identified) {
|
||||||
{
|
|
||||||
parameters.append(p);
|
parameters.append(p);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
identifier.append(p);
|
identifier.append(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String identifierString = identifier.toString();
|
final String identifierString = identifier.toString().toLowerCase();
|
||||||
final String parametersString = parameters.toString();
|
final String parametersString = parameters.toString();
|
||||||
|
|
||||||
identifier.setLength(0);
|
identifier.setLength(0);
|
||||||
parameters.setLength(0);
|
parameters.setLength(0);
|
||||||
|
|
||||||
if (oopsitsbad)
|
if (oopsitsbad) {
|
||||||
{
|
|
||||||
builder.append(closure.head).append(identifierString);
|
builder.append(closure.head).append(identifierString);
|
||||||
|
|
||||||
if (identified)
|
if (identified) {
|
||||||
{
|
|
||||||
builder.append('_').append(parametersString);
|
builder.append('_').append(parametersString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hadSpace) {
|
||||||
builder.append(' ');
|
builder.append(' ');
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlaceholderExpansion placeholder = lookup.apply(identifierString);
|
final PlaceholderExpansion placeholder = lookup.apply(identifierString);
|
||||||
if (placeholder == null)
|
if (placeholder == null) {
|
||||||
{
|
|
||||||
builder.append(closure.head).append(identifierString);
|
builder.append(closure.head).append(identifierString);
|
||||||
|
|
||||||
if (identified)
|
if (identified) {
|
||||||
{
|
|
||||||
builder.append('_');
|
builder.append('_');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,12 +158,10 @@ public final class CharsReplacer implements Replacer
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String replacement = placeholder.onRequest(player, parametersString);
|
final String replacement = placeholder.onRequest(player, parametersString);
|
||||||
if (replacement == null)
|
if (replacement == null) {
|
||||||
{
|
|
||||||
builder.append(closure.head).append(identifierString);
|
builder.append(closure.head).append(identifierString);
|
||||||
|
|
||||||
if (identified)
|
if (identified) {
|
||||||
{
|
|
||||||
builder.append('_');
|
builder.append('_');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +169,7 @@ public final class CharsReplacer implements Replacer
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.append(replacement);
|
builder.append(ChatColor.translateAlternateColorCodes('&', replacement));
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,48 +20,44 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.replacer;
|
package me.clip.placeholderapi.replacer;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.function.Function;
|
public final class RegexReplacer implements Replacer {
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public final class RegexReplacer implements Replacer
|
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
|
|
||||||
public RegexReplacer(@NotNull final Closure closure)
|
public RegexReplacer(@NotNull final Closure closure) {
|
||||||
{
|
this.pattern = Pattern.compile(String
|
||||||
this.pattern = Pattern.compile(String.format("\\%s((?<identifier>[a-zA-Z0-9]+)_)(?<parameters>[^%s%s]+)\\%s", closure.head, closure.head, closure.tail, closure.tail));
|
.format("\\%s((?<identifier>[a-zA-Z0-9]+)_)(?<parameters>[^%s%s]+)\\%s", closure.head,
|
||||||
|
closure.head, closure.tail, closure.tail));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup)
|
public String apply(@NotNull final String text, @Nullable final OfflinePlayer player,
|
||||||
{
|
@NotNull final Function<String, @Nullable PlaceholderExpansion> lookup) {
|
||||||
final Matcher matcher = pattern.matcher(text);
|
final Matcher matcher = pattern.matcher(text);
|
||||||
if (!matcher.find())
|
if (!matcher.find()) {
|
||||||
{
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuffer builder = new StringBuffer();
|
final StringBuffer builder = new StringBuffer();
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
final String identifier = matcher.group("identifier");
|
final String identifier = matcher.group("identifier");
|
||||||
final String parameters = matcher.group("parameters");
|
final String parameters = matcher.group("parameters");
|
||||||
|
|
||||||
final PlaceholderExpansion expansion = lookup.apply(identifier);
|
final PlaceholderExpansion expansion = lookup.apply(identifier);
|
||||||
if (expansion == null)
|
if (expansion == null) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,30 +20,27 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.replacer;
|
package me.clip.placeholderapi.replacer;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.function.Function;
|
public interface Replacer {
|
||||||
|
|
||||||
public interface Replacer
|
|
||||||
{
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup);
|
String apply(@NotNull final String text, @Nullable final OfflinePlayer player,
|
||||||
|
@NotNull final Function<String, @Nullable PlaceholderExpansion> lookup);
|
||||||
|
|
||||||
|
|
||||||
enum Closure
|
enum Closure {
|
||||||
{
|
|
||||||
BRACKET('{', '}'),
|
BRACKET('{', '}'),
|
||||||
PERCENT('%', '%');
|
PERCENT('%', '%');
|
||||||
|
|
||||||
|
|
||||||
public final char head, tail;
|
public final char head, tail;
|
||||||
|
|
||||||
Closure(final char head, final char tail)
|
Closure(final char head, final char tail) {
|
||||||
{
|
|
||||||
this.head = head;
|
this.head = head;
|
||||||
this.tail = tail;
|
this.tail = tail;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,6 +20,11 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.updatechecker;
|
package me.clip.placeholderapi.updatechecker;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -28,11 +33,6 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
public class UpdateChecker implements Listener {
|
public class UpdateChecker implements Listener {
|
||||||
|
|
||||||
private final int RESOURCE_ID = 6245;
|
private final int RESOURCE_ID = 6245;
|
||||||
@@ -91,17 +91,24 @@ public class UpdateChecker implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String plV = toReadable(pluginVersion);
|
int[] plV = toReadable(pluginVersion);
|
||||||
String spV = toReadable(spigotVersion);
|
int[] spV = toReadable(spigotVersion);
|
||||||
return plV.compareTo(spV) < 0;
|
|
||||||
|
if (plV[0] < spV[0]) {
|
||||||
|
return true;
|
||||||
|
} else if ((plV[1] < spV[1])) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return plV[2] < spV[2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toReadable(String version) {
|
private int[] toReadable(String version) {
|
||||||
if (version.contains("-DEV-")) {
|
if (version.contains("-DEV")) {
|
||||||
version = version.split("-DEV-")[0];
|
version = version.split("-DEV")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return version.replaceAll("\\.", "");
|
return Arrays.stream(version.split("\\.")).mapToInt(Integer::parseInt).toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -32,53 +32,46 @@ import java.util.List;
|
|||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarInputStream;
|
import java.util.jar.JarInputStream;
|
||||||
|
|
||||||
public class FileUtil
|
public class FileUtil {
|
||||||
{
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static <T> Class<? extends T> findClass(@NotNull final File file, @NotNull final Class<T> clazz) throws IOException, ClassNotFoundException
|
public static <T> Class<? extends T> findClass(@NotNull final File file,
|
||||||
{
|
@NotNull final Class<T> clazz) throws IOException, ClassNotFoundException {
|
||||||
if (!file.exists())
|
if (!file.exists()) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final URL jar = file.toURI().toURL();
|
final URL jar = file.toURI().toURL();
|
||||||
|
final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader());
|
||||||
final List<String> matches = new ArrayList<>();
|
final List<String> matches = new ArrayList<>();
|
||||||
final List<Class<? extends T>> classes = new ArrayList<>();
|
final List<Class<? extends T>> classes = new ArrayList<>();
|
||||||
|
|
||||||
|
try (final JarInputStream stream = new JarInputStream(jar.openStream())) {
|
||||||
try (final JarInputStream stream = new JarInputStream(jar.openStream()); final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader()))
|
|
||||||
{
|
|
||||||
JarEntry entry;
|
JarEntry entry;
|
||||||
while ((entry = stream.getNextJarEntry()) != null)
|
while ((entry = stream.getNextJarEntry()) != null) {
|
||||||
{
|
|
||||||
final String name = entry.getName();
|
final String name = entry.getName();
|
||||||
if (name == null || name.isEmpty() || !name.endsWith(".class"))
|
if (name.isEmpty() || !name.endsWith(".class")) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
matches.add(name.substring(0, name.lastIndexOf('.')).replace('/', '.'));
|
matches.add(name.substring(0, name.lastIndexOf('.')).replace('/', '.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final String match : matches)
|
for (final String match : matches) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
final Class<?> loaded = loader.loadClass(match);
|
final Class<?> loaded = loader.loadClass(match);
|
||||||
if (clazz.isAssignableFrom(loaded))
|
if (clazz.isAssignableFrom(loaded)) {
|
||||||
{
|
|
||||||
classes.add(loaded.asSubclass(clazz));
|
classes.add(loaded.asSubclass(clazz));
|
||||||
}
|
}
|
||||||
}
|
} catch (final NoClassDefFoundError ignored) {
|
||||||
catch (final NoClassDefFoundError ignored)
|
|
||||||
{ }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return classes.isEmpty() ? null : classes.get(0);
|
if (classes.isEmpty()) {
|
||||||
|
loader.close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return classes.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,11 +20,6 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.util;
|
package me.clip.placeholderapi.util;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static java.lang.Math.max;
|
import static java.lang.Math.max;
|
||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
import static java.util.Arrays.stream;
|
import static java.util.Arrays.stream;
|
||||||
@@ -32,47 +27,44 @@ import static java.util.stream.Collectors.joining;
|
|||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
import static java.util.stream.IntStream.range;
|
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.
|
* For the record, I am not sorry.
|
||||||
*/
|
*/
|
||||||
public final class Format
|
public final class Format {
|
||||||
{
|
|
||||||
|
|
||||||
private Format()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
public enum Align
|
|
||||||
{
|
|
||||||
LEFT, RIGHT
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private Format() {}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Optional<List<String>> tablify(@NotNull final Align align, @NotNull final List<List<String>> rows)
|
public static Optional<List<String>> tablify(@NotNull final Align align,
|
||||||
{
|
@NotNull final List<List<String>> rows) {
|
||||||
return findSpacing(rows)
|
return findSpacing(rows)
|
||||||
.map(spacing -> buildFormat(align, spacing))
|
.map(spacing -> buildFormat(align, spacing))
|
||||||
.map(format -> rows.stream()
|
.map(format -> rows.stream()
|
||||||
.map(row -> String.format(format, row.toArray()).substring(align == Align.RIGHT ? 2 : 0))
|
.map(
|
||||||
|
row -> String.format(format, row.toArray()).substring(align == Align.RIGHT ? 2 : 0))
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static String buildFormat(@NotNull final Align align, @NotNull final int[] spacing)
|
private static String buildFormat(@NotNull final Align align, @NotNull final int[] spacing) {
|
||||||
{
|
|
||||||
return stream(spacing)
|
return stream(spacing)
|
||||||
.mapToObj(space -> "%" + (align == Align.LEFT ? "-" : "") + (space + 2) + "s")
|
.mapToObj(space -> "%" + (align == Align.LEFT ? "-" : "") + (space + 2) + "s")
|
||||||
.collect(joining());
|
.collect(joining());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Optional<int[]> findSpacing(@NotNull final List<List<String>> rows)
|
private static Optional<int[]> findSpacing(@NotNull final List<List<String>> rows) {
|
||||||
{
|
|
||||||
return rows.stream()
|
return rows.stream()
|
||||||
.map(row -> row.stream().mapToInt(String::length).toArray())
|
.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());
|
.reduce((l, r) -> range(0, min(l.length, r.length)).map(i -> max(l[i], r[i])).toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Align {
|
||||||
|
LEFT, RIGHT
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,24 @@
|
|||||||
package me.clip.placeholderapi.util;
|
/*
|
||||||
|
* This file is part of PlaceholderAPI
|
||||||
|
*
|
||||||
|
* PlaceholderAPI
|
||||||
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
|
*
|
||||||
|
* PlaceholderAPI is 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
package me.clip.placeholderapi.util;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -11,23 +27,22 @@ import java.util.function.BiConsumer;
|
|||||||
import java.util.stream.Collector;
|
import java.util.stream.Collector;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public final class Futures
|
public final class Futures {
|
||||||
{
|
|
||||||
|
|
||||||
private Futures()
|
private Futures() {}
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
public static <T> void onMainThread(@NotNull final Plugin plugin, @NotNull final CompletableFuture<T> future, @NotNull final BiConsumer<T, Throwable> consumer)
|
public static <T> void onMainThread(@NotNull final Plugin plugin,
|
||||||
{
|
@NotNull final CompletableFuture<T> future,
|
||||||
|
@NotNull final BiConsumer<T, Throwable> consumer) {
|
||||||
future.whenComplete((value, exception) -> {
|
future.whenComplete((value, exception) -> {
|
||||||
if (Bukkit.isPrimaryThread())
|
if (Bukkit.isPrimaryThread()) {
|
||||||
{
|
|
||||||
consumer.accept(value, exception);
|
consumer.accept(value, exception);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(value, exception));
|
Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(value, exception));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -35,28 +50,27 @@ public final class Futures
|
|||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static <T> Collector<CompletableFuture<T>, ?, CompletableFuture<List<T>>> collector()
|
public static <T> Collector<CompletableFuture<T>, ?, CompletableFuture<List<T>>> collector() {
|
||||||
{
|
|
||||||
return Collectors.collectingAndThen(Collectors.toList(), Futures::of);
|
return Collectors.collectingAndThen(Collectors.toList(), Futures::of);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static <T> CompletableFuture<List<T>> of(@NotNull final Stream<CompletableFuture<T>> futures)
|
public static <T> CompletableFuture<List<T>> of(
|
||||||
{
|
@NotNull final Stream<CompletableFuture<T>> futures) {
|
||||||
return of(futures.collect(Collectors.toList()));
|
return of(futures.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static <T> CompletableFuture<List<T>> of(@NotNull final Collection<CompletableFuture<T>> futures)
|
public static <T> CompletableFuture<List<T>> of(
|
||||||
{
|
@NotNull final Collection<CompletableFuture<T>> futures) {
|
||||||
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
||||||
.thenApplyAsync($ -> awaitCompletion(futures));
|
.thenApplyAsync($ -> awaitCompletion(futures));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static <T> List<T> awaitCompletion(@NotNull final Collection<CompletableFuture<T>> futures)
|
private static <T> List<T> awaitCompletion(
|
||||||
{
|
@NotNull final Collection<CompletableFuture<T>> futures) {
|
||||||
return futures.stream().map(CompletableFuture::join).collect(Collectors.toList());
|
return futures.stream().map(CompletableFuture::join).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -20,39 +20,33 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.util;
|
package me.clip.placeholderapi.util;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
public final class Msg {
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public final class Msg
|
public static void msg(@NotNull final CommandSender sender, @NotNull final String... messages) {
|
||||||
{
|
if (messages.length == 0) {
|
||||||
|
|
||||||
public static void msg(@NotNull final CommandSender sender, @NotNull final String... messages)
|
|
||||||
{
|
|
||||||
if (messages.length == 0)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Arrays.stream(messages).map(Msg::color).collect(Collectors.joining("\n")));
|
sender.sendMessage(Arrays.stream(messages).map(Msg::color).collect(Collectors.joining("\n")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcast(@NotNull final String... messages)
|
public static void broadcast(@NotNull final String... messages) {
|
||||||
{
|
if (messages.length == 0) {
|
||||||
if (messages.length == 0)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.broadcastMessage(Arrays.stream(messages).map(Msg::color).collect(Collectors.joining("\n")));
|
Bukkit.broadcastMessage(
|
||||||
|
Arrays.stream(messages).map(Msg::color).collect(Collectors.joining("\n")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String color(@NotNull final String text)
|
public static String color(@NotNull final String text) {
|
||||||
{
|
|
||||||
return ChatColor.translateAlternateColorCodes('&', text);
|
return ChatColor.translateAlternateColorCodes('&', text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
@@ -22,149 +22,75 @@ package me.clip.placeholderapi.util;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
public class TimeUtil {
|
public class TimeUtil {
|
||||||
|
|
||||||
public static String getRemaining(int seconds, TimeFormat type) {
|
public static String getRemaining(final int seconds, final TimeFormat type) {
|
||||||
if (seconds < 60) {
|
return getRemaining((long) seconds, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getRemaining(final long seconds, final TimeFormat type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DAYS:
|
default:
|
||||||
case HOURS:
|
return String.valueOf(seconds);
|
||||||
case MINUTES:
|
|
||||||
return "0";
|
|
||||||
case SECONDS:
|
case SECONDS:
|
||||||
return String.valueOf(seconds);
|
return String.valueOf(seconds % 60);
|
||||||
}
|
|
||||||
|
|
||||||
return String.valueOf(seconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
int minutes = seconds / 60;
|
|
||||||
int s = 60 * minutes;
|
|
||||||
int secondsLeft = seconds - s;
|
|
||||||
|
|
||||||
if (minutes < 60) {
|
|
||||||
switch (type) {
|
|
||||||
case DAYS:
|
|
||||||
case HOURS:
|
|
||||||
return "0";
|
|
||||||
case MINUTES:
|
case MINUTES:
|
||||||
return String.valueOf(minutes);
|
return String.valueOf((seconds / 60) % 60);
|
||||||
case SECONDS:
|
|
||||||
return String.valueOf(secondsLeft);
|
|
||||||
}
|
|
||||||
|
|
||||||
return String.valueOf(seconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minutes < 1440) {
|
|
||||||
int hours = minutes / 60;
|
|
||||||
int inMins = 60 * hours;
|
|
||||||
int leftOver = minutes - inMins;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case DAYS:
|
|
||||||
return "0";
|
|
||||||
case HOURS:
|
case HOURS:
|
||||||
return String.valueOf(hours);
|
return String.valueOf((seconds / 3600) % 24);
|
||||||
case MINUTES:
|
|
||||||
return String.valueOf(leftOver);
|
|
||||||
case SECONDS:
|
|
||||||
return String.valueOf(secondsLeft);
|
|
||||||
}
|
|
||||||
|
|
||||||
return String.valueOf(seconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
int days = minutes / 1440;
|
|
||||||
int inMins = 1440 * days;
|
|
||||||
int leftOver = minutes - inMins;
|
|
||||||
|
|
||||||
if (leftOver < 60) {
|
|
||||||
switch (type) {
|
|
||||||
case DAYS:
|
case DAYS:
|
||||||
return String.valueOf(days);
|
return String.valueOf(seconds / 86400);
|
||||||
case HOURS:
|
|
||||||
return String.valueOf(0);
|
|
||||||
case MINUTES:
|
|
||||||
return String.valueOf(leftOver);
|
|
||||||
case SECONDS:
|
|
||||||
return String.valueOf(secondsLeft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.valueOf(seconds);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
int hours = leftOver / 60;
|
|
||||||
int hoursInMins = 60 * hours;
|
|
||||||
int minsLeft = leftOver - hoursInMins;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case DAYS:
|
|
||||||
return String.valueOf(days);
|
|
||||||
case HOURS:
|
|
||||||
return String.valueOf(hours);
|
|
||||||
case MINUTES:
|
|
||||||
return String.valueOf(minsLeft);
|
|
||||||
case SECONDS:
|
|
||||||
return String.valueOf(secondsLeft);
|
|
||||||
}
|
|
||||||
|
|
||||||
return String.valueOf(seconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getTime(int seconds) {
|
|
||||||
return getTime(Duration.ofSeconds(seconds));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format the given value with s, m, h and d (seconds, minutes, hours and days)
|
* 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)
|
* @param duration {@link Duration} (eg, Duration.of(20, {@link ChronoUnit#SECONDS}) for 20
|
||||||
|
* seconds)
|
||||||
* @return formatted time
|
* @return formatted time
|
||||||
*/
|
*/
|
||||||
public static String getTime(final Duration duration) {
|
public static String getTime(final Duration duration) {
|
||||||
final StringBuilder builder = new StringBuilder();
|
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 seconds = duration.getSeconds();
|
|
||||||
long minutes = seconds / 60;
|
long minutes = seconds / 60;
|
||||||
long hours = minutes / 60;
|
long hours = minutes / 60;
|
||||||
long days = hours / 24;
|
final long days = hours / 24;
|
||||||
|
|
||||||
seconds %= 60;
|
seconds %= 60;
|
||||||
minutes %= 60;
|
minutes %= 60;
|
||||||
hours %= 60;
|
hours %= 24;
|
||||||
days %= 24;
|
|
||||||
|
|
||||||
if (seconds > 0) {
|
if (days > 0) {
|
||||||
builder.insert(0, seconds + "s");
|
joiner.add(days + "d");
|
||||||
}
|
|
||||||
|
|
||||||
if (minutes > 0) {
|
|
||||||
if (builder.length() > 0) {
|
|
||||||
builder.insert(0, ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.insert(0, minutes + "m");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
if (builder.length() > 0) {
|
joiner.add(hours + "h");
|
||||||
builder.insert(0, ' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.insert(0, hours + "h");
|
if (minutes > 0) {
|
||||||
|
joiner.add(minutes + "m");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (days > 0) {
|
if (seconds > 0) {
|
||||||
if (builder.length() > 0) {
|
joiner.add(seconds + "s");
|
||||||
builder.insert(0, ' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.insert(0, days + "d");
|
return joiner.toString();
|
||||||
}
|
|
||||||
|
|
||||||
return builder.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -29,8 +29,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public interface Values
|
public interface Values {
|
||||||
{
|
|
||||||
|
|
||||||
String SMALL_TEXT = "My name is %player_name%";
|
String SMALL_TEXT = "My name is %player_name%";
|
||||||
String LARGE_TEXT = "My name is %player_name% and my location is (%player_x%, %player_y%, %player_z%), this placeholder is invalid %server_name%";
|
String LARGE_TEXT = "My name is %player_name% and my location is (%player_x%, %player_y%, %player_z%), this placeholder is invalid %server_name%";
|
||||||
@@ -44,8 +43,7 @@ public interface Values
|
|||||||
Replacer REGEX_REPLACER = new RegexReplacer(Replacer.Closure.PERCENT);
|
Replacer REGEX_REPLACER = new RegexReplacer(Replacer.Closure.PERCENT);
|
||||||
|
|
||||||
|
|
||||||
final class MockPlayerPlaceholderExpansion extends PlaceholderExpansion
|
final class MockPlayerPlaceholderExpansion extends PlaceholderExpansion {
|
||||||
{
|
|
||||||
|
|
||||||
public static final String PLAYER_X = "10";
|
public static final String PLAYER_X = "10";
|
||||||
public static final String PLAYER_Y = "20";
|
public static final String PLAYER_Y = "20";
|
||||||
@@ -55,36 +53,30 @@ public interface Values
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier()
|
public String getIdentifier() {
|
||||||
{
|
|
||||||
return "player";
|
return "player";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getAuthor()
|
public String getAuthor() {
|
||||||
{
|
|
||||||
return "Sxtanna";
|
return "Sxtanna";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getVersion()
|
public String getVersion() {
|
||||||
{
|
|
||||||
return "1.0";
|
return "1.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onRequest(@Nullable final OfflinePlayer player, @NotNull final String params)
|
public String onRequest(@Nullable final OfflinePlayer player, @NotNull final String params) {
|
||||||
{
|
|
||||||
final String[] parts = params.split("_");
|
final String[] parts = params.split("_");
|
||||||
if (parts.length == 0)
|
if (parts.length == 0) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (parts[0])
|
switch (parts[0]) {
|
||||||
{
|
|
||||||
case "name":
|
case "name":
|
||||||
return PLAYER_NAME;
|
return PLAYER_NAME;
|
||||||
case "x":
|
case "x":
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -23,30 +23,25 @@ package me.clip.placeholderapi.replacer;
|
|||||||
import me.clip.placeholderapi.Values;
|
import me.clip.placeholderapi.Values;
|
||||||
import org.openjdk.jmh.annotations.Benchmark;
|
import org.openjdk.jmh.annotations.Benchmark;
|
||||||
|
|
||||||
public class ReplacerBenchmarks
|
public class ReplacerBenchmarks {
|
||||||
{
|
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public void measureCharsReplacerSmallText()
|
public void measureCharsReplacerSmallText() {
|
||||||
{
|
|
||||||
Values.CHARS_REPLACER.apply(Values.SMALL_TEXT, null, Values.PLACEHOLDERS::get);
|
Values.CHARS_REPLACER.apply(Values.SMALL_TEXT, null, Values.PLACEHOLDERS::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public void measureRegexReplacerSmallText()
|
public void measureRegexReplacerSmallText() {
|
||||||
{
|
|
||||||
Values.REGEX_REPLACER.apply(Values.SMALL_TEXT, null, Values.PLACEHOLDERS::get);
|
Values.REGEX_REPLACER.apply(Values.SMALL_TEXT, null, Values.PLACEHOLDERS::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public void measureCharsReplacerLargeText()
|
public void measureCharsReplacerLargeText() {
|
||||||
{
|
|
||||||
Values.CHARS_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get);
|
Values.CHARS_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public void measureRegexReplacerLargeText()
|
public void measureRegexReplacerLargeText() {
|
||||||
{
|
|
||||||
Values.REGEX_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get);
|
Values.REGEX_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* This file is part of PlaceholderAPI
|
* This file is part of PlaceholderAPI
|
||||||
*
|
*
|
||||||
* PlaceholderAPI
|
* PlaceholderAPI
|
||||||
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
|
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
||||||
*
|
*
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
* PlaceholderAPI free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -20,47 +20,51 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.replacer;
|
package me.clip.placeholderapi.replacer;
|
||||||
|
|
||||||
import me.clip.placeholderapi.Values;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_NAME;
|
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_NAME;
|
||||||
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_X;
|
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_X;
|
||||||
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_Y;
|
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_Y;
|
||||||
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_Z;
|
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_Z;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public final class ReplacerUnitTester
|
import me.clip.placeholderapi.Values;
|
||||||
{
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public final class ReplacerUnitTester {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCharsReplacerProducesExpectedSingleValue()
|
void testCharsReplacerProducesExpectedSingleValue() {
|
||||||
{
|
assertEquals(PLAYER_NAME,
|
||||||
assertEquals(PLAYER_NAME, Values.CHARS_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
|
Values.CHARS_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRegexReplacerProducesExpectedSingleValue()
|
void testRegexReplacerProducesExpectedSingleValue() {
|
||||||
{
|
assertEquals(PLAYER_NAME,
|
||||||
assertEquals(PLAYER_NAME, Values.REGEX_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
|
Values.REGEX_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCharsReplacerProducesExpectedSentence()
|
void testCharsReplacerProducesExpectedSentence() {
|
||||||
{
|
assertEquals(String.format(
|
||||||
assertEquals(String.format("My name is %s and my location is (%s, %s, %s), this placeholder is invalid %%server_name%%", PLAYER_NAME, PLAYER_X, PLAYER_Y, PLAYER_Z), Values.CHARS_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get));
|
"My name is %s and my location is (%s, %s, %s), this placeholder is invalid %%server_name%%",
|
||||||
|
PLAYER_NAME, PLAYER_X, PLAYER_Y, PLAYER_Z),
|
||||||
|
Values.CHARS_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRegexReplacerProducesExpectedSentence()
|
void testRegexReplacerProducesExpectedSentence() {
|
||||||
{
|
assertEquals(String.format(
|
||||||
assertEquals(String.format("My name is %s and my location is (%s, %s, %s), this placeholder is invalid %%server_name%%", PLAYER_NAME, PLAYER_X, PLAYER_Y, PLAYER_Z), Values.REGEX_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get));
|
"My name is %s and my location is (%s, %s, %s), this placeholder is invalid %%server_name%%",
|
||||||
|
PLAYER_NAME, PLAYER_X, PLAYER_Y, PLAYER_Z),
|
||||||
|
Values.REGEX_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testResultsAreTheSameAsReplacement()
|
void testResultsAreTheSameAsReplacement() {
|
||||||
{
|
final String resultChars = Values.CHARS_REPLACER
|
||||||
final String resultChars = Values.CHARS_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get);
|
.apply("%player_name%", null, Values.PLACEHOLDERS::get);
|
||||||
final String resultRegex = Values.REGEX_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get);
|
final String resultRegex = Values.REGEX_REPLACER
|
||||||
|
.apply("%player_name%", null, Values.PLACEHOLDERS::get);
|
||||||
|
|
||||||
assertEquals(resultChars, resultRegex);
|
assertEquals(resultChars, resultRegex);
|
||||||
|
|
||||||
@@ -68,28 +72,28 @@ public final class ReplacerUnitTester
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testResultsAreTheSameNoReplacement()
|
void testResultsAreTheSameNoReplacement() {
|
||||||
{
|
final String resultChars = Values.CHARS_REPLACER
|
||||||
final String resultChars = Values.CHARS_REPLACER.apply("%player_location%", null, Values.PLACEHOLDERS::get);
|
.apply("%player_location%", null, Values.PLACEHOLDERS::get);
|
||||||
final String resultRegex = Values.REGEX_REPLACER.apply("%player_location%", null, Values.PLACEHOLDERS::get);
|
final String resultRegex = Values.REGEX_REPLACER
|
||||||
|
.apply("%player_location%", null, Values.PLACEHOLDERS::get);
|
||||||
|
|
||||||
assertEquals(resultChars, resultRegex);
|
assertEquals(resultChars, resultRegex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCharsReplacerIgnoresMalformed()
|
void testCharsReplacerIgnoresMalformed() {
|
||||||
{
|
|
||||||
final String text = "10% and %hello world 15%";
|
final String text = "10% and %hello world 15%";
|
||||||
|
|
||||||
assertEquals(text, Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
|
assertEquals(text, Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCharsReplacerHandlesEscapedHex()
|
void testCharsReplacerHandlesEscapedHex() {
|
||||||
{
|
final String text = "\\&xffffffThis should not change.";
|
||||||
final String text = "\\&xFFFFFFThis should not change.";
|
|
||||||
|
|
||||||
assertEquals(text.substring(1), Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
|
assertEquals(text.substring(1),
|
||||||
|
Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
362
wiki/Commands.md
362
wiki/Commands.md
@@ -27,213 +27,213 @@ This page shows all commands, including with a detailed description of what ever
|
|||||||
|
|
||||||
- **[Other Commands](#other-commands)**
|
- **[Other Commands](#other-commands)**
|
||||||
- [`/papi dump`](#papi-dump)
|
- [`/papi dump`](#papi-dump)
|
||||||
|
- [`/papi help`](#papi-help)
|
||||||
- [`/papi reload`](#papi-reload)
|
- [`/papi reload`](#papi-reload)
|
||||||
|
- [`/papi version`](#papi-version)
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
### Parse Commands
|
### Parse Commands
|
||||||
These commands are used to parse placeholders into their respective values. Useful for debugging.
|
These commands are used to parse placeholders into their respective values. Useful for debugging.
|
||||||
|
|
||||||
#### `/papi bcparse`
|
- #### `/papi bcparse`
|
||||||
**Description**:
|
**Description**:
|
||||||
Parses placeholders of a String and broadcasts the result to all players.
|
Parses placeholders of a String and broadcasts the result to all players.
|
||||||
|
|
||||||
**Arguments**:
|
**Arguments**:
|
||||||
* `<player|me>` - The Player to parse values of the placeholder (Use `me` for yourself).
|
* `<player|me>` - The Player to parse values of the placeholder (Use `me` for yourself).
|
||||||
* `<Text with placeholders>` - The text to parse.
|
* `<Text with placeholders>` - The text to parse.
|
||||||
|
|
||||||
**Example**:
|
**Example**:
|
||||||
```
|
```
|
||||||
/papi bcparse funnycube My name is %player_name%!
|
/papi bcparse funnycube My name is %player_name%!
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- #### `/papi cmdparse`
|
||||||
|
**Description**:
|
||||||
|
Parses placeholders of a String and executes it as a command.
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
- `<player|me>` - The player to parse placeholders against. Use `me` for yourself.
|
||||||
|
- `<Command with placeholders>` - The Text to parse and execute as command. Please leave away the `/` of the command.
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```
|
||||||
|
/papi cmdparse funnycube say My name is %player_name%!
|
||||||
|
```
|
||||||
|
|
||||||
|
- #### `/papi parse`
|
||||||
|
**Description**:
|
||||||
|
Parses the placeholders in a given text and shows the result.
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
* `<player|me>` - The Player to parse values of the placeholder (Use `me` for yourself).
|
||||||
|
* `<Text with placeholders>` - The text to parse.
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```
|
||||||
|
/papi parse funnycube My group is %vault_group%
|
||||||
|
```
|
||||||
|
|
||||||
|
- #### `/papi parserel`
|
||||||
|
**Description**:
|
||||||
|
Parses a relational placeholder.
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
* `<player1>` - The first player.
|
||||||
|
* `<player2>` - the second player to compare with.
|
||||||
|
* `<Text with placeholders>` - The actual placeholder to parse.
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```
|
||||||
|
/papi parserel funnycube extended_clip %placeholder%
|
||||||
|
```
|
||||||
|
|
||||||
----
|
----
|
||||||
#### `/papi cmdparse`
|
|
||||||
**Description**:
|
|
||||||
Parses placeholders of a String and executes it as a command.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
- `<player|me>` - The player to parse placeholders against. Use `me` for yourself.
|
|
||||||
- `<Command with placeholders>` - The Text to parse and execute as command. Please leave away the `/` of the command.
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```
|
|
||||||
/papi cmdparse funnycube say My name is %player_name%!
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi parse`
|
|
||||||
**Description**:
|
|
||||||
Parses the placeholders in a given text and shows the result.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
* `<player|me>` - The Player to parse values of the placeholder (Use `me` for yourself).
|
|
||||||
* `<Text with placeholders>` - The text to parse.
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```
|
|
||||||
/papi parse funnycube My group is %vault_group%
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi parserel`
|
|
||||||
**Description**:
|
|
||||||
Parses a relational placeholder.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
* `<player1>` - The first player.
|
|
||||||
* `<player2>` - the second player to compare with.
|
|
||||||
* `<Text with placeholders>` - The actual placeholder to parse.
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```
|
|
||||||
/papi parserel funnycube extended_clip %placeholder%
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
### eCloud Commands
|
### eCloud Commands
|
||||||
These commands all start with `/papi ecloud` and are used for things related about the [[Expansion Cloud]].
|
These commands all start with `/papi ecloud` and are used for things related about the [[Expansion Cloud]].
|
||||||
|
|
||||||
#### `/papi ecloud clear`
|
- #### `/papi ecloud clear`
|
||||||
**Description**:
|
**Description**:
|
||||||
Clears the cache for the eCloud.
|
Clears the cache for the eCloud.
|
||||||
|
|
||||||
|
- #### `/papi ecloud disable`
|
||||||
|
**Description**:
|
||||||
|
Disables the connection to the eCloud.
|
||||||
|
|
||||||
|
- #### `/papi ecloud download`
|
||||||
|
**Description**:
|
||||||
|
Allows you to download an expansion from the eCloud
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
- `<expansion>` - The expansion to download.
|
||||||
|
- `[version]` - The specific version of the expansion to download (Optional)
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```
|
||||||
|
/papi ecloud download Vault
|
||||||
|
/papi ecloud download Vault 1.5.2
|
||||||
|
```
|
||||||
|
|
||||||
|
- #### `/papi ecloud enable`
|
||||||
|
**Description**:
|
||||||
|
Enables the connection to the eCloud
|
||||||
|
|
||||||
|
- #### `/papi ecloud info`
|
||||||
|
**Description**:
|
||||||
|
Gives information about a specific Expansion.
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
- `<expansion>` - The Expansion to retrieve information from.
|
||||||
|
- `[version]` - The Expansion's version to get information from.
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```
|
||||||
|
/papi ecloud info Vault
|
||||||
|
```
|
||||||
|
|
||||||
|
- #### `/papi ecloud list`
|
||||||
|
**Description**:
|
||||||
|
Lists either all Expansions on the eCloud, only those by a specific author or only those that you have [installed](#papi-ecloud-download).
|
||||||
|
Installed Expansions show as green in the list and Expansions that are installed and have an update available show as gold.
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
- `<all|<author>|installed>` - List all Expansions, Expansions of a specific author or all Expnansions you have installed.
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```
|
||||||
|
/papi ecloud list all
|
||||||
|
/papi ecloud list clip
|
||||||
|
/papi ecloud list installed
|
||||||
|
```
|
||||||
|
|
||||||
|
- #### `/papi ecloud placeholders`
|
||||||
|
**Description**:
|
||||||
|
List all placeholders of an Expansion.
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
- `<expansion>` - The Expansion to list placeholders of.
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```
|
||||||
|
/papi ecloud placeholders Vault
|
||||||
|
```
|
||||||
|
|
||||||
|
- #### `/papi ecloud refresh`
|
||||||
|
**Description**:
|
||||||
|
Refresh the cached data from the eCloud.
|
||||||
|
|
||||||
|
- #### `/papi ecloud status`
|
||||||
|
**Description**:
|
||||||
|
Displays the actual Status of the eCloud.
|
||||||
|
|
||||||
----
|
----
|
||||||
#### `/papi ecloud disable`
|
|
||||||
**Description**:
|
|
||||||
Disables the connection to the eCloud.
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi ecloud download`
|
|
||||||
**Description**:
|
|
||||||
Allows you to download an expansion from the eCloud
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
- `<expansion>` - The expansion to download.
|
|
||||||
- `[version]` - The specific version of the expansion to download (Optional)
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```
|
|
||||||
/papi ecloud download Vault
|
|
||||||
/papi ecloud download Vault 1.5.2
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi ecloud enable`
|
|
||||||
**Description**:
|
|
||||||
Enables the connection to the eCloud
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi ecloud info`
|
|
||||||
**Description**:
|
|
||||||
Gives information about a specific Expansion.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
- `<expansion>` - The Expansion to retrieve information from.
|
|
||||||
- `[version]` - The Expansion's version to get information from.
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```
|
|
||||||
/papi ecloud info Vault
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi ecloud list`
|
|
||||||
**Description**:
|
|
||||||
Lists either all Expansions on the eCloud, only those by a specific author or only those that you have [installed](#papi-ecloud-download).
|
|
||||||
Installed Expansions show as green in the list and Expansions that are installed and have an update available show as gold.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
- `<all|<author>|installed>` - List all Expansions, Expansions of a specific author or all Expnansions you have installed.
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```
|
|
||||||
/papi ecloud list all
|
|
||||||
/papi ecloud list clip
|
|
||||||
/papi ecloud list installed
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi ecloud placeholders`
|
|
||||||
**Description**:
|
|
||||||
List all placeholders of an Expansion.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
- `<expansion>` - The Expansion to list placeholders of.
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```
|
|
||||||
/papi ecloud placeholders Vault
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi ecloud refresh`
|
|
||||||
**Description**:
|
|
||||||
Refresh the cached data from the eCloud.
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi ecloud status`
|
|
||||||
**Description**:
|
|
||||||
Displays the actual Status of the eCloud.
|
|
||||||
|
|
||||||
----
|
|
||||||
### Expansion Commands
|
### Expansion Commands
|
||||||
These commands can be used to manage the expansions that you have currently installed.
|
These commands can be used to manage the expansions that you have currently installed.
|
||||||
|
|
||||||
#### `/papi info`
|
- #### `/papi info`
|
||||||
**Description**:
|
**Description**:
|
||||||
Gives you information about the specified Expansion.
|
Gives you information about the specified Expansion.
|
||||||
|
|
||||||
**Argument(s)**:
|
**Argument(s)**:
|
||||||
- `<expansion>` - The Expansion to get info from (Needs to be registered and active).
|
- `<expansion>` - The Expansion to get info from (Needs to be registered and active).
|
||||||
|
|
||||||
**Example**:
|
**Example**:
|
||||||
```
|
```
|
||||||
/papi info Vault
|
/papi info Vault
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- #### `/papi list`
|
||||||
|
**Description**:
|
||||||
|
Lists all active/registered expansions.
|
||||||
|
This is different to [/papi ecloud list installed](#papi-ecloud-list) in the fact, that it also includes expansions that were installed through a plugin (That aren't a separate jar-file) and it also doesn't show which one have updates available.
|
||||||
|
|
||||||
|
- #### `/papi register`
|
||||||
|
**Description**:
|
||||||
|
Registers an expansion from a specified filename.
|
||||||
|
This is useful in cases, where you downloaded the expansion manually and don't want to restart the server.
|
||||||
|
The file needs to be inside `/plugins/PlaceholderAPI/expansions`.
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
- `<filename>` - The file to register (including the file-extension).
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```
|
||||||
|
/papi register MyExpansion.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
- #### `/papi unregister`
|
||||||
|
**Description**:
|
||||||
|
Unregisters the specified expansion.
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
- `<filename>` - The expansion to unregister.
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```
|
||||||
|
/papi unregister MyExpansion.jar
|
||||||
|
```
|
||||||
|
|
||||||
----
|
----
|
||||||
#### `/papi list`
|
|
||||||
**Description**:
|
|
||||||
Lists all active/registered expansions.
|
|
||||||
This is different to [/papi ecloud list installed](#papi-ecloud-list) in the fact, that it also includes expansions that were installed through a plugin (That aren't a separate jar-file) and it also doesn't show which one have updates available.
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi register`
|
|
||||||
**Description**:
|
|
||||||
Registers an expansion from a specified filename.
|
|
||||||
This is useful in cases, where you downloaded the expansion manually and don't want to restart the server.
|
|
||||||
The file needs to be inside `/plugins/PlaceholderAPI/expansions`.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
- `<filename>` - The file to register (including the file-extension).
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```
|
|
||||||
/papi register MyExpansion.jar
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
#### `/papi unregister`
|
|
||||||
**Description**:
|
|
||||||
Unregisters the specified expansion.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
- `<filename>` - The expansion to unregister.
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```
|
|
||||||
/papi unregister MyExpansion.jar
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
### Other Commands
|
### Other Commands
|
||||||
These are other commands of PlaceholderAPI that don't fit any of the above categories.
|
These are other commands of PlaceholderAPI that don't fit any of the above categories.
|
||||||
|
|
||||||
#### `/papi dump`
|
- #### `/papi dump`
|
||||||
**Description**:
|
**Description**:
|
||||||
Pastes useful information from PlaceholderAPI such as plugin version, server version and installed expansions to https://paste.helpch.at for simple sharing and support.
|
Pastes useful information from PlaceholderAPI such as plugin version, server version and installed expansions to https://paste.helpch.at for simple sharing and support.
|
||||||
|
|
||||||
#### `/papi reload`
|
- #### `/papi help`
|
||||||
**Description**:
|
**Description**:
|
||||||
Reloads the config settings.
|
Displays all the commands PlaceholderAPI currently offers.
|
||||||
You need to use this command after [downloading Expansions](#papi-ecloud-download) from the eCloud or they won't be properly registered.
|
|
||||||
|
- #### `/papi reload`
|
||||||
|
**Description**:
|
||||||
|
Reloads the config settings.
|
||||||
|
You need to use this command after [downloading Expansions](#papi-ecloud-download) from the eCloud or they won't be properly registered.
|
||||||
|
|
||||||
|
- #### `/papi version`
|
||||||
|
**Description**:
|
||||||
|
Shows the current version and authors of PlaceholderAPI.
|
||||||
|
|||||||
55
wiki/FAQ.md
55
wiki/FAQ.md
@@ -1,16 +1,30 @@
|
|||||||
|
[readme]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/docs/wiki/wiki/README.md
|
||||||
|
|
||||||
Here are frequently asked questions about stuff related to PlaceholderAPI.
|
Here are frequently asked questions about stuff related to PlaceholderAPI.
|
||||||
|
|
||||||
## It only shows %placeholder% and not the variable
|
## It only shows `%placeholder%` and not the variable
|
||||||
Make sure, that you've tried the following steps:
|
When a plugin or `/papi parse me %placeholder%` only returns the placeholder itself and no value should you check for the following things:
|
||||||
- PlaceholderAPI is installed and running (Shows green in `/pl` and responds to the `/papi` command)
|
|
||||||
- You downloaded the expansion with `/papi ecloud download [expansion]`
|
### The expansion is actually installed.
|
||||||
A list of available expansions and their placeholders can be found [[here|Placeholders]]!
|
In many cases is the cause that the expansion of the placeholder is missing.
|
||||||
Also note that not all placeholders are in a seperate expansion. Some are "hardcoded" into a plugin.
|
Just execute `/papi ecloud download <name of expansion>` followed by `/papi reload` to activate it. You can find a list of Expansions and their Placeholders [[on this page|Placeholders]].
|
||||||
- You reloaded PlaceholderAPI with `/papi reload` after downloading an expansion.
|
|
||||||
- Any possible dependency for the expansion (Plugin) is installed and running.
|
**NOTE!**
|
||||||
- The placeholder doesn't contain any typos.
|
Not all placeholders come in their own expansion. Some plugins *hardcode* them in and load them on startup, when hooking into PlaceholderAPI.
|
||||||
- The plugin that should use the placeholder actually supports PlaceholderAPI.
|
|
||||||
For a list of plugins supporting PlaceholderAPI go [[here|Plugins-using-PlaceholderAPI]].
|
### Plugin actualls supports PlaceholderAPI
|
||||||
|
It can happen that the plugin you use to display the placeholder in doesn't support PlaceholderAPI. In such a case check, if the parse command returns the actual value of a placeholder.
|
||||||
|
If that is the case while the plugin is still displaying the placeholder, can this be an indicator of the plugin not supporting PlaceholderAPI.
|
||||||
|
|
||||||
|
You can find a list of plugins supporting PlaceholderAPI [[here|Plugins-using-PlaceholderAPI]].
|
||||||
|
Just make sure that "Supports placeholders" has a check mark in front of it.
|
||||||
|
|
||||||
|
### No typo in the placeholder
|
||||||
|
Double-check that the placeholder you set doesn't contain a typo. You can use `/papi ecloud placeholders <expansion>` (replace `<expansion>` with the name of the expansion) to get a list of all the placeholders the expansion may have.
|
||||||
|
Keep in mind that this only works for separate expansions on the eCloud and not for those that are loaded by plugins.
|
||||||
|
|
||||||
|
### Plugin is enabled
|
||||||
|
If an expansion depends on a plugin, make sure you have the plugin installed and that it is enabled (Shows green in `/pl`).
|
||||||
|
|
||||||
## I can't download the expansion
|
## I can't download the expansion
|
||||||
Make sure, that the connection to the cloud (https://api.extendedclip.com) isn't blocked by a firewall or similar.
|
Make sure, that the connection to the cloud (https://api.extendedclip.com) isn't blocked by a firewall or similar.
|
||||||
@@ -20,3 +34,22 @@ If both checks failed, go to the cloud-page and download the jar manually. Put i
|
|||||||
|
|
||||||
## How can other plugins use my placeholders with PlaceholderAPI?
|
## How can other plugins use my placeholders with PlaceholderAPI?
|
||||||
A tutorial can be found [[here|Hook into PlaceholderAPI]]!
|
A tutorial can be found [[here|Hook into PlaceholderAPI]]!
|
||||||
|
|
||||||
|
## Can I help on this wiki?
|
||||||
|
You sure can!
|
||||||
|
We welcome contributions to our wiki by everyone. If you found a typo or want to improve this wiki in another way, head over to the [Wiki's readme file][readme] to find out about how you can contribute towards this wiki.
|
||||||
|
|
||||||
|
## PlaceholderAPI is posting an error about an outdated expansion?
|
||||||
|
```
|
||||||
|
[00:00:01 ERROR]: [PlaceholderAPI] Failed to load Expansion class <expansion> (Is a dependency missing?)
|
||||||
|
[00:00:01 ERROR]: [PlaceholderAPI] Cause: NoClassDefFoundError <path>
|
||||||
|
```
|
||||||
|
|
||||||
|
If you receive the above error, try to do the following steps:
|
||||||
|
|
||||||
|
- Make sure any required dependency of the mentioned expansion (e.g. a plugin) is installed.
|
||||||
|
- Make sure you use the latest version supported for the server version you use.
|
||||||
|
- If you downloaded the jar from the ecloud, make sure it isn't malformed/corrupted.
|
||||||
|
|
||||||
|
If the issue persists after you've done those checks, report it to the author of the expansion.
|
||||||
|
In most cases is the issue that either a dependency is missing or that the expansion tries to use outdated methods from PlaceholderAPI.
|
||||||
|
|||||||
75
wiki/Home.md
75
wiki/Home.md
@@ -1,5 +1,5 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://i.imgur.com/puadJ8Z.png" alt="PlaceholderAPI">
|
<img src="https://raw.githubusercontent.com/PlaceholderAPI/PlaceholderAPI/master/wiki/img/wiki-logo.png" alt="PlaceholderAPI">
|
||||||
</p>
|
</p>
|
||||||
This wiki gives you information on how to create placeholders in your plugin that can be used in other plugins, how to use other placeholders inside your plugin, or how to make an expansion.
|
This wiki gives you information on how to create placeholders in your plugin that can be used in other plugins, how to use other placeholders inside your plugin, or how to make an expansion.
|
||||||
It also has a list with all available placeholders (Work in progress).
|
It also has a list with all available placeholders (Work in progress).
|
||||||
@@ -7,10 +7,12 @@ It also has a list with all available placeholders (Work in progress).
|
|||||||
### Setup
|
### Setup
|
||||||
**[[Hook into PlaceholderAPI]]**
|
**[[Hook into PlaceholderAPI]]**
|
||||||
- [[First steps|Hook-into-PlaceholderAPI#first-steps]]
|
- [[First steps|Hook-into-PlaceholderAPI#first-steps]]
|
||||||
- [[Adding placeholders to PlaceholderAPI|Hook-into-PlaceholderAPI#adding-placeholders-to-placeholderapi]]
|
- [[Adding placeholders to PlaceholderAPI|PlaceholderExpansion]]
|
||||||
- [[PlaceholderExpansion]]
|
- [[Common Parts|PlaceholderExpansion#common-parts]]
|
||||||
- [[Without an external plugin|PlaceholderExpansion#without-an-external-plugin]]
|
- [[Without an external plugin|PlaceholderExpansion#without-a-plugin]]
|
||||||
- [[With external plugin|PlaceholderExpansion#with-external-plugin]]
|
- [[With an external Plugin (Separate Jar)|PlaceholderExpansion#with-a-plugin-external-jar]]
|
||||||
|
- [[With an external Plugin (Internal class)|PlaceholderExpansion#with-a-plugin-internal-class]]
|
||||||
|
- [[Relational Placeholders|PlaceholderExpansion#relational-placeholders]]
|
||||||
- [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]]
|
- [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]]
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
@@ -19,39 +21,7 @@ It also has a list with all available placeholders (Work in progress).
|
|||||||
**[[FAQ]]**
|
**[[FAQ]]**
|
||||||
**[[Plugins using PlaceholderAPI]]**
|
**[[Plugins using PlaceholderAPI]]**
|
||||||
**[[Placeholders]]**
|
**[[Placeholders]]**
|
||||||
- [[PAPI-placeholders|Placeholders#papi-placeholders-1]]
|
- [[Standalone|Placeholders#standalone]]
|
||||||
- [[Advancements|Placeholders#advancements]]
|
|
||||||
- [[Animations|Placeholders#animations]]
|
|
||||||
- [[Armor|Placeholders#armor]]
|
|
||||||
- [[ASCII|Placeholders#ASCII]]
|
|
||||||
- [[BungeeCord|Placeholders#bungeecord]]
|
|
||||||
- [[CheckItem|Placeholders#checkitem]]
|
|
||||||
- [[CooldownBar|Placeholders#cooldownbar]]
|
|
||||||
- [[Formatter|Placeholders#formatter]]
|
|
||||||
- [[Javascript|Placeholders#javascript]]
|
|
||||||
- [[ListPlayers|Placeholders#listplayer]]
|
|
||||||
- [[LocalTime|Placeholders#localtime]]
|
|
||||||
- [[Math|Placeholders#math]]
|
|
||||||
- [[MVdW placeholders|Placeholders#mvdw-placeholders]]
|
|
||||||
- [[OtherPlayer|Placeholders#otherplayer]]
|
|
||||||
- [[ParseNear|Placeholders#parsenear]]
|
|
||||||
- [[ParseOther|Placeholders#parseother]]
|
|
||||||
- [[Pinger|Placeholders#pinger]]
|
|
||||||
- [[Player|Placeholders#player]]
|
|
||||||
- [[PlayerList|Placeholders#playerlist]]
|
|
||||||
- [[Plugin|Placeholders#plugin]]
|
|
||||||
- [[Progress|Placeholders#progress]]
|
|
||||||
- [[RainbowColor|Placeholders#rainbowcolor]]
|
|
||||||
- [[RandomColor|Placeholders#randomcolor]]
|
|
||||||
- [[RedisBungee|Placeholders#redisbungee]]
|
|
||||||
- [[RelCon|Placeholders#relcon]]
|
|
||||||
- [[ScoreboardObjectives|Placeholders#scoreboardobjectives]]
|
|
||||||
- [[Server|Placeholders#server]]
|
|
||||||
- [[Sound|Placeholders#sound]]
|
|
||||||
- [[Spectators|Placeholders#spectators]]
|
|
||||||
- [[Statistic|Placeholders#statistic]]
|
|
||||||
|
|
||||||
- [[Plugin-placeholders|Placeholders#plugin-placeholders-1]]
|
|
||||||
- [[A|Placeholders#a]]
|
- [[A|Placeholders#a]]
|
||||||
- [[B|Placeholders#b]]
|
- [[B|Placeholders#b]]
|
||||||
- [[C|Placeholders#c]]
|
- [[C|Placeholders#c]]
|
||||||
@@ -75,4 +45,33 @@ It also has a list with all available placeholders (Work in progress).
|
|||||||
- [[U|Placeholders#u]]
|
- [[U|Placeholders#u]]
|
||||||
- [[V|Placeholders#v]]
|
- [[V|Placeholders#v]]
|
||||||
- [[W|Placeholders#w]]
|
- [[W|Placeholders#w]]
|
||||||
|
- [[X|Placeholders#x]]
|
||||||
|
- [[Y|Placeholders#y]]
|
||||||
- [[Z|Placeholders#z]]
|
- [[Z|Placeholders#z]]
|
||||||
|
- [[Plugin-placeholders|Placeholders#plugin-placeholders-1]]
|
||||||
|
- [[A|Placeholders#a-1]]
|
||||||
|
- [[B|Placeholders#b-1]]
|
||||||
|
- [[C|Placeholders#c-1]]
|
||||||
|
- [[D|Placeholders#d-1]]
|
||||||
|
- [[E|Placeholders#e-1]]
|
||||||
|
- [[F|Placeholders#f-1]]
|
||||||
|
- [[G|Placeholders#g-1]]
|
||||||
|
- [[H|Placeholders#h-1]]
|
||||||
|
- [[I|Placeholders#i-1]]
|
||||||
|
- [[J|Placeholders#j-1]]
|
||||||
|
- [[K|Placeholders#k-1]]
|
||||||
|
- [[L|Placeholders#l-1]]
|
||||||
|
- [[M|Placeholders#m-1]]
|
||||||
|
- [[N|Placeholders#n-1]]
|
||||||
|
- [[O|Placeholders#o-1]]
|
||||||
|
- [[P|Placeholders#p-1]]
|
||||||
|
- [[Q|Placeholders#q-1]]
|
||||||
|
- [[R|Placeholders#r-1]]
|
||||||
|
- [[S|Placeholders#s-1]]
|
||||||
|
- [[T|Placeholders#t-1]]
|
||||||
|
- [[U|Placeholders#u-1]]
|
||||||
|
- [[V|Placeholders#v-1]]
|
||||||
|
- [[W|Placeholders#w-1]]
|
||||||
|
- [[X|Placeholders#x-1]]
|
||||||
|
- [[Y|Placeholders#y-1]]
|
||||||
|
- [[Z|Placeholders#z-1]]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[APIBadge]: https://img.shields.io/nexus/r/http/repo.extendedclip.com/me.clip/placeholderapi.svg?label=API-Version
|
[APIBadge]: https://img.shields.io/nexus/placeholderapi/me.clip/placeholderapi?server=https%3A%2F%2Frepo.extendedclip.com&label=API%20Version
|
||||||
|
|
||||||
[SpigotBadge]: https://img.shields.io/spiget/version/6245?label=Spigot
|
[SpigotBadge]: https://img.shields.io/spiget/version/6245?label=Spigot
|
||||||
[Spigot]: https://spigotmc.org/resources/6245
|
[Spigot]: https://spigotmc.org/resources/6245
|
||||||
@@ -116,13 +116,18 @@ public class JoinExample extends JavaPlugin implements Listener {
|
|||||||
*/
|
*/
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Could not find PlaceholderAPI!! Plugin can not work without it!");
|
/*
|
||||||
|
* We inform about the fact that PlaceholderAPI isn't installed and then
|
||||||
|
* disable this plugin to prevent issues.
|
||||||
|
*/
|
||||||
|
getLogger().warn("Could not find PlaceholderAPI! This plugin is required.");
|
||||||
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onJoin(PlayerJoinEvent event) {
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
String joinText = "%player_name% &ajoined the server! He/she is rank &f%vault_rank%";
|
String joinText = "%player_name% &ajoined the server! They are rank &f%vault_rank%";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We parse the placeholders using "setPlaceholders"
|
* We parse the placeholders using "setPlaceholders"
|
||||||
@@ -131,7 +136,7 @@ public class JoinExample extends JavaPlugin implements Listener {
|
|||||||
*/
|
*/
|
||||||
joinText = PlaceholderAPI.setPlaceholders(event.getPlayer(), joinText);
|
joinText = PlaceholderAPI.setPlaceholders(event.getPlayer(), joinText);
|
||||||
|
|
||||||
event.setJoinMessage(withPlaceholdersSet);
|
event.setJoinMessage(joinText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -1,411 +1,381 @@
|
|||||||
|
[placeholderexpansion]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java
|
||||||
|
|
||||||
|
[playerexpansion]: https://github.com/PlaceholderAPI/Player-Expansion
|
||||||
|
[serverexpansion]: https://github.com/PlaceholderAPI/Server-Expansion
|
||||||
|
[mathexpansion]: https://github.com/Andre601/Math-expansion
|
||||||
|
|
||||||
|
[relational]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/src/main/java/me/clip/placeholderapi/expansion/Relational.java
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This page covers how you can use the `PlaceholderExpansion` to add own placeholders to PlaceholderAPI, which then can be used by other plugins.
|
This page will cover how you can create your own [`PlaceholderExpansion`][placeholderexpansion] which you can either [[Upload to the eCloud|Expansion cloud]] or integrate into your own plugin.
|
||||||
|
|
||||||
PlaceholderAPI is using Expansions for its placeholders, with PlaceholderAPI providing the core. Users can download Expansions from the cloud server using commands in-game or by going [here](https://api.extendedclip.com/home/) if they want to use the placeholder.
|
It's worth noting that PlaceholderAPI relies on expansions being installed. PlaceholderAPI only acts as the core replacing utility while the expansions allow other plugins to use any installed placeholder in their own messages.
|
||||||
|
You can download Expansions either directly from the eCloud yourself, or download them through the [[download command of PlaceholderAPI|Commands#papi-ecloud-download]].
|
||||||
|
|
||||||
## Note
|
## Table of Contents
|
||||||
You can either make a separate jar file, to upload it to the expansion-cloud (recommended) or have it as a local class inside your plugin.
|
|
||||||
|
|
||||||
## Examples
|
- [Getting started](#getting-started)
|
||||||
There are multiple methods and ways you can use the PlaceholderExpansion.
|
- [Common Parts](#common-parts)
|
||||||
Those depend on what you want to display through the placeholders in the end.
|
- [Without a Plugin](#without-a-plugin)
|
||||||
|
- [With a Plugin (External Jar)](#with-a-plugin-external-jar)
|
||||||
|
- [With a Plugin (Internal Class)](#with-a-plugin-internal-class)
|
||||||
|
- [Register the Expansion](#register-the-expansion)
|
||||||
|
- [Relational Placeholders](#relational-placeholders)
|
||||||
|
- [Notes about Relational Placeholders](#notes-about-relational-placeholders)
|
||||||
|
|
||||||
* [Without external plugin](#without-external-plugin)
|
## Getting started
|
||||||
* [With external plugin](#with-external-plugin)
|
For starters, you need to decide what type of [`PlaceholderExpansion`][placeholderexpansion] you want to create. There are various ways to create an expansion. This page will cover the most common ones.
|
||||||
* [Separate jar](#separate-jar)
|
|
||||||
* [Internal class](#internal-class)
|
|
||||||
|
|
||||||
### Without an external plugin
|
### Common Parts
|
||||||
This part here covers how you create an expansion that doesn't require any external/additional plugins to function.
|
All shown examples will share the same common parts that belong to the [`PlaceholderExpansion`][placeholderexpansion] class.
|
||||||
Examples of such expansions are:
|
In order to not repeat the same basic info for each method throughout this page, and to greatly reduce its overall length, we will cover the most basic/necessary ones here.
|
||||||
- [Player expansion](/PlaceholderAPI/Player-Expansion)
|
|
||||||
- [Math expansion](https://github.com/Andre601/Math-Expansion)
|
|
||||||
- [Statistics expansion](/PlaceholderAPI/Statistics-Expansion)
|
|
||||||
|
|
||||||
Since it would be weird (and also make no real sense) to have this inside your plugin, we assume you make a separate jar-file as an expansion.
|
#### Basic PlaceholderExpansion Structure
|
||||||
|
|
||||||
To begin, first make the class extend the `PlaceholderExpansion` and add the required methods:
|
|
||||||
```java
|
```java
|
||||||
package at.helpch.placeholderapi.example.expansions;
|
package at.helpch.placeholderapi.example.expansions;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
|
||||||
/**
|
|
||||||
* This class will automatically register as a placeholder expansion
|
|
||||||
* when a jar including this class is added to the directory
|
|
||||||
* {@code /plugins/PlaceholderAPI/expansions} on your server.
|
|
||||||
* <br>
|
|
||||||
* <br>If you create such a class inside your own plugin, you have to
|
|
||||||
* register it manually in your plugins {@code onEnable()} by using
|
|
||||||
* {@code new YourExpansionClass().register();}
|
|
||||||
*/
|
|
||||||
public class SomeExpansion extends PlaceholderExpansion {
|
public class SomeExpansion extends PlaceholderExpansion {
|
||||||
|
|
||||||
/**
|
|
||||||
* This method should always return true unless we
|
|
||||||
* have a dependency we need to make sure is on the server
|
|
||||||
* for our placeholders to work!
|
|
||||||
*
|
|
||||||
* @return always true since we do not have any dependencies.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRegister(){
|
public String getAuthor() {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the person who created this expansion should go here.
|
|
||||||
*
|
|
||||||
* @return The name of the author as a String.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getAuthor(){
|
|
||||||
return "someauthor";
|
return "someauthor";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The placeholder identifier should go here.
|
|
||||||
* <br>This is what tells PlaceholderAPI to call our onRequest
|
|
||||||
* method to obtain a value if a placeholder starts with our
|
|
||||||
* identifier.
|
|
||||||
* <br>This must be unique and can not contain % or _
|
|
||||||
*
|
|
||||||
* @return The identifier in {@code %<identifier>_<value>%} as String.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier(){
|
public String getIdentifier() {
|
||||||
return "example";
|
return "example";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the version of this expansion.
|
|
||||||
* <br>You don't have to use numbers, since it is set as a String.
|
|
||||||
*
|
|
||||||
* @return The version as a String.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion(){
|
public String getVersion() {
|
||||||
return "1.0.0";
|
return "1.0.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the method called when a placeholder with our identifier
|
|
||||||
* is found and needs a value.
|
|
||||||
* <br>We specify the value identifier in this method.
|
|
||||||
* <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* A {@link org.bukkit.OfflinePlayer OfflinePlayer}.
|
|
||||||
* @param identifier
|
|
||||||
* A String containing the identifier/value.
|
|
||||||
*
|
|
||||||
* @return Possibly-null String of the requested identifier.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String onRequest(OfflinePlayer player, String identifier){
|
|
||||||
|
|
||||||
// %example_placeholder1%
|
|
||||||
if(identifier.equals("placeholder1")){
|
|
||||||
return "placeholder1 works";
|
|
||||||
}
|
|
||||||
|
|
||||||
// %example_placeholder2%
|
|
||||||
if(identifier.equals("placeholder2")){
|
|
||||||
return "placeholder2 works";
|
|
||||||
}
|
|
||||||
|
|
||||||
// We return null if an invalid placeholder (f.e. %example_placeholder3%)
|
|
||||||
// was provided
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Let's quickly break down the different methods you have to implement.
|
||||||
|
|
||||||
|
- #### getAuthor
|
||||||
|
This method allows you to set the name of the expansion's author.
|
||||||
|
- #### getIdentifier
|
||||||
|
The identifier is the part in the placeholder that is between the first `%` (Or `{` if bracket placeholders are used) and the first `_`.
|
||||||
|
Because of that can you not use `%`, `{`, `}` or `_` in youd identifier.
|
||||||
|
|
||||||
|
If you still want to use those symbols can you override the `getName()` method to display a different name.
|
||||||
|
- #### getVersion
|
||||||
|
This is a string, which means it can contain more than just a number. This is used to determine if a new update is available or not when the expansion is shared on the eCloud.
|
||||||
|
For expansions that are part of a plugin, this does not really matter.
|
||||||
|
|
||||||
|
Those are all the neccessary parts for your PlaceholderExpansion.
|
||||||
|
Any other methods that are part of the [`PlaceholderExpansion`][placeholderexpansion] class are optional and will usually not be used, or will default to a specific value. Please read the Javadoc comments of those methods for more information.
|
||||||
|
|
||||||
|
You must choose between one of these two methods for handling the actual parsing of placeholders:
|
||||||
|
|
||||||
|
- #### onRequest(OfflinePlayer, String)
|
||||||
|
If not explicitly set, this will automatically call [`onPlaceholderRequest(Player, String)`](#onplaceholderrequestplayer-string).
|
||||||
|
This method is recommended as it allows the usage of `null` and can therefore be used in placeholders that don't require a valid player to be used.
|
||||||
|
- #### onPlaceholderRequest(Player, String)
|
||||||
|
If not set, this method will return `null` which PlaceholderAPI sees as an invalid placeholder.
|
||||||
|
|
||||||
----
|
----
|
||||||
|
## Without a Plugin
|
||||||
|
An expansion does not always need a plugin to rely on. If the placeholders it provides can return values from just the server itself or some other source (i.e. Java itself), then it can work independently.
|
||||||
|
|
||||||
### With external plugin
|
Common examples of such Expansions are:
|
||||||
Those examples here applies to people who want to provide information from their own plugin through placeholders from PlaceholderAPI.
|
|
||||||
There exists a repository showcasing an [example-expansion](/PlaceholderAPI/Example-Expansion) with what you can/should do.
|
|
||||||
|
|
||||||
In our examples do we have the plugin `SomePlugin` and want to show certain placeholders with it.
|
- [Player Expansion][playerexpansion]
|
||||||
|
- [Server Expansion][serverexpansion]
|
||||||
|
- [Math Expansion][mathexpansion]
|
||||||
|
|
||||||
There are two ways to actually get information from your plugin and they only are different in if you have the expansion as a separate jar-file or as an internal class.
|
These kinds of expansions don't require any additional plugins to function.
|
||||||
|
When creating such an expansion is it recommended to use [`onRequest(OfflinePlayer, String)`](#onrequestofflineplayer-string).
|
||||||
|
|
||||||
#### Separate jar
|
#### Full Example
|
||||||
In our separate jar do we have to make some checks, to be sure, that the required plugin is installed and running.
|
Please see the [Common parts](#common-parts) section for info on the other methods.
|
||||||
The below code shows how the class can look like in case the plugin doesn't have a public and easy to access API.
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
package at.helpch.placeholderapi.example.expansions;
|
package at.helpch.placeholderapi.example.expansions;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import at.helpch.placeholderapi.example.SomePlugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class will automatically register as a placeholder expansion
|
|
||||||
* when a jar including this class is added to the directory
|
|
||||||
* {@code /plugins/PlaceholderAPI/expansions} on your server.
|
|
||||||
* <br>
|
|
||||||
* <br>If you create such a class inside your own plugin, you have to
|
|
||||||
* register it manually in your plugins {@code onEbale()} by using
|
|
||||||
* {@code new YourExpansionClass().register();}
|
|
||||||
*/
|
|
||||||
public class SomeExpansion extends PlaceholderExpansion {
|
public class SomeExpansion extends PlaceholderExpansion {
|
||||||
|
|
||||||
// We get an instance of the plugin later.
|
|
||||||
private SomePlugin plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Since this expansion requires api access to the plugin "SomePlugin"
|
|
||||||
* we must check if said plugin is on the server or not.
|
|
||||||
*
|
|
||||||
* @return true or false depending on if the required plugin is installed.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRegister(){
|
public String getAuthor() {
|
||||||
return (plugin = (SomePlugin) Bukkit.getPluginManager().getPlugin(getRequiredPlugin())) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the person who created this expansion should go here.
|
|
||||||
*
|
|
||||||
* @return The name of the author as a String.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getAuthor(){
|
|
||||||
return "someauthor";
|
return "someauthor";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The placeholder identifier should go here.
|
|
||||||
* <br>This is what tells PlaceholderAPI to call our onRequest
|
|
||||||
* method to obtain a value if a placeholder starts with our
|
|
||||||
* identifier.
|
|
||||||
* <br>This must be unique and can not contain % or _
|
|
||||||
*
|
|
||||||
* @return The identifier in {@code %<identifier>_<value>%} as String.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier(){
|
public String getIdentifier() {
|
||||||
return "someplugin";
|
return "example";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* if the expansion requires another plugin as a dependency, the
|
|
||||||
* proper name of the dependency should go here.
|
|
||||||
* <br>Set this to {@code null} if your placeholders do not require
|
|
||||||
* another plugin to be installed on the server for them to work.
|
|
||||||
* <br>
|
|
||||||
* <br>This is extremely important to set your plugin here, since if
|
|
||||||
* you don't do it, your expansion will throw errors.
|
|
||||||
*
|
|
||||||
* @return The name of our dependency.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getRequiredPlugin(){
|
public String getVersion() {
|
||||||
return "SomePlugin";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the version of this expansion.
|
|
||||||
* <br>You don't have to use numbers, since it is set as a String.
|
|
||||||
*
|
|
||||||
* @return The version as a String.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getVersion(){
|
|
||||||
return "1.0.0";
|
return "1.0.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the method called when a placeholder with our identifier
|
|
||||||
* is found and needs a value.
|
|
||||||
* <br>We specify the value identifier in this method.
|
|
||||||
* <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* A {@link org.bukkit.Player Player}.
|
|
||||||
* @param identifier
|
|
||||||
* A String containing the identifier/value.
|
|
||||||
*
|
|
||||||
* @return possibly-null String of the requested identifier.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String onPlaceholderRequest(Player player, String identifier){
|
public String onRequest(OfflinePlayer player, String params) {
|
||||||
|
if(params.equalsIgnoreCase("name")) {
|
||||||
if(p == null){
|
return player == null ? null : player.getName(); // "name" requires the player to be valid
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// %someplugin_placeholder1%
|
if(params.equalsIgnoreCase("placeholder1")) {
|
||||||
if(identifier.equals("placeholder1")){
|
return "Placeholder Text 1";
|
||||||
return plugin.getConfig().getString("placeholder1", "value doesnt exist");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// %someplugin_placeholder2%
|
if(params.equalsIgnoreCase("placeholder2")) {
|
||||||
if(identifier.equals("placeholder2")){
|
return "Placeholder Text 2";
|
||||||
return plugin.getConfig().getString("placeholder2", "value doesnt exist");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We return null if an invalid placeholder (f.e. %someplugin_placeholder3%)
|
return null; // Placeholder is unknown by the Expansion
|
||||||
// was provided
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
----
|
----
|
||||||
#### Internal class
|
## With a Plugin (External Jar)
|
||||||
You can have the class inside your plugin.
|
If your expansion relies on a plugin to provide its placeholder values, you will need to override a few more methods to make sure everything will work correctly.
|
||||||
This has some advantages but can also have some disadvantages.
|
|
||||||
If you include a PlaceholderExpansion class in your plugin, you MUST add an override the persist() method to return true
|
Your expansion will need to override the `getRequiredPlugin()` method to return the name of the plugin your expansion depends on.
|
||||||
otherwise, if PlaceholderAPI is reloaded, your expansion will be unregistered and lost forever.
|
PlaceholderAPI automatically checks if this method will either return null, or if the name defined results in a non-null plugin.
|
||||||
|
|
||||||
|
It is worth noting that it is a bit more difficult to make a separate jar file that depends on a plugin, as it will require the plugin to have some sort of accessible API in order to get the required values.
|
||||||
|
One way to bypass this is to override the `canRegister()` method with the following code:
|
||||||
|
|
||||||
|
```java
|
||||||
|
private SomePlugin plugin = null; // This would be the plugin your expansion depends on
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canregister() {
|
||||||
|
// This sets plugin to the SomePlugin instance you get through the PluginManager
|
||||||
|
return (plugin = (SomePlugin) Bukkit.getPluginManager().getPlugin(getRequiredPlugin())) != null;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Using this code-snippet, you can get a direct instance of the plugin and access things such as config values.
|
||||||
|
With that said, it is recommended instead to use an API if one is available, as this kind of plugin access is a relatively poor approach.
|
||||||
|
|
||||||
|
#### Full Example
|
||||||
|
Please see the [Common parts](#common-parts) section for info on the other methods.
|
||||||
|
|
||||||
|
```java
|
||||||
|
package at.helpch.placeholderapi.example.expansions;
|
||||||
|
|
||||||
|
import at.helpch.placeholderapi.example.SomePlugin;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
|
||||||
|
public class SomeExpansion extends PlaceholderExpansion {
|
||||||
|
|
||||||
|
private SomePlugin plugin; // This instance is assigned in canRegister()
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAuthor() {
|
||||||
|
return "someauthor";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "example";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return "1.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPlugin() {
|
||||||
|
return "SomePlugin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canRegister() {
|
||||||
|
return (plugin = (SomePlugin) Bukkit.getPluginManager().getPlugin(getRequiredPlugin())) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onRequest(OfflinePlayer player, String params) {
|
||||||
|
if(params.equalsIgnoreCase("placeholder1")){
|
||||||
|
return plugin.getConfig().getString("placeholders.placeholder1", "default1");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(params.equalsIgnoreCase("placeholder2")){
|
||||||
|
return plugin.getConfig().getString("placeholders.placeholder2", "default2");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null; // Placeholder is unknown by the expansion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
----
|
||||||
|
## With a Plugin (Internal Class)
|
||||||
|
The way expansions are handled when they are part of the plugin itself is fairly similar to when you [make an expansion without a plugin dependency](#without-a-plugin).
|
||||||
|
|
||||||
|
In fact, you don't even have to override the `getRequiredPlugin()` and `canRegister()` methods as it is always guaranteed that the plugin is available.
|
||||||
|
Something worth noting, however, is that you need to override the `persist()` method and make it return true. This ensures that the expansion won't be unregistered by PlaceholderAPI whenever it is reloaded.
|
||||||
|
|
||||||
|
Finally, you can also use dependency injection as an easier way to access a plugin's methods.
|
||||||
|
Here is a small code example of how dependency injection may look:
|
||||||
|
|
||||||
|
```java
|
||||||
|
public class SomeExpansion extends PlaceholderExpansion {
|
||||||
|
private final SomePlugin plugin; // The instance is created in the constructor and won't be modified, so it can be final
|
||||||
|
|
||||||
|
public SomeExpansion(SomePlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Full Example
|
||||||
|
Please see the [Common parts](#common-parts) section for info on the other methods.
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
package at.helpch.placeholderapi.example.expansions;
|
package at.helpch.placeholderapi.example.expansions;
|
||||||
|
|
||||||
|
import at.helpch.placeholderapi.example.SomePlugin;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import at.helpch.placeholderapi.example.SomePlugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class will be registered through the register-method in the
|
|
||||||
* plugins onEnable-method.
|
|
||||||
*/
|
|
||||||
public class SomeExpansion extends PlaceholderExpansion {
|
public class SomeExpansion extends PlaceholderExpansion {
|
||||||
|
|
||||||
private SomePlugin plugin;
|
private final SomePlugin plugin;
|
||||||
|
|
||||||
/**
|
public SomeExpansion(SomePlugin plugin) {
|
||||||
* Since we register the expansion inside our own plugin, we
|
|
||||||
* can simply use this method here to get an instance of our
|
|
||||||
* plugin.
|
|
||||||
*
|
|
||||||
* @param plugin
|
|
||||||
* The instance of our plugin.
|
|
||||||
*/
|
|
||||||
public SomeExpansion(SomePlugin plugin){
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Because this is an internal class,
|
|
||||||
* you must override this method to let PlaceholderAPI know to not unregister your expansion class when
|
|
||||||
* PlaceholderAPI is reloaded
|
|
||||||
*
|
|
||||||
* @return true to persist through reloads
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean persist(){
|
public String getAuthor() {
|
||||||
return true;
|
return "someauthor";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Because this is a internal class, this check is not needed
|
|
||||||
* and we can simply return {@code true}
|
|
||||||
*
|
|
||||||
* @return Always true since it's an internal class.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRegister(){
|
public String getIdentifier() {
|
||||||
return true;
|
return "example";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the person who created this expansion should go here.
|
|
||||||
* <br>For convienience do we return the author from the plugin.yml
|
|
||||||
*
|
|
||||||
* @return The name of the author as a String.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getAuthor(){
|
public String getVersion() {
|
||||||
return plugin.getDescription().getAuthors().toString();
|
return "1.0.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The placeholder identifier should go here.
|
|
||||||
* <br>This is what tells PlaceholderAPI to call our onRequest
|
|
||||||
* method to obtain a value if a placeholder starts with our
|
|
||||||
* identifier.
|
|
||||||
* <br>This must be unique and can not contain % or _
|
|
||||||
*
|
|
||||||
* @return The identifier in {@code %<identifier>_<value>%} as String.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier(){
|
public boolean persist() {
|
||||||
return "someplugin";
|
return true; // This is required or else PlaceholderAPI will unregister the Expansion on reload
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the version of the expansion.
|
|
||||||
* <br>You don't have to use numbers, since it is set as a String.
|
|
||||||
*
|
|
||||||
* For convienience do we return the version from the plugin.yml
|
|
||||||
*
|
|
||||||
* @return The version as a String.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion(){
|
public String onRequest(OfflinePlayer player, String params) {
|
||||||
return plugin.getDescription().getVersion();
|
if(params.equalsIgnoreCase("placeholder1")){
|
||||||
|
return plugin.getConfig().getString("placeholders.placeholder1", "default1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
if(params.equalsIgnoreCase("placeholder2")) {
|
||||||
* This is the method called when a placeholder with our identifier
|
return plugin.getConfig().getString("placeholders.placeholder2", "default2");
|
||||||
* is found and needs a value.
|
|
||||||
* <br>We specify the value identifier in this method.
|
|
||||||
* <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* A {@link org.bukkit.Player Player}.
|
|
||||||
* @param identifier
|
|
||||||
* A String containing the identifier/value.
|
|
||||||
*
|
|
||||||
* @return possibly-null String of the requested identifier.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String onPlaceholderRequest(Player player, String identifier){
|
|
||||||
|
|
||||||
if(player == null){
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// %someplugin_placeholder1%
|
return null; // Placeholder is unknown by the Expansion
|
||||||
if(identifier.equals("placeholder1")){
|
|
||||||
return plugin.getConfig().getString("placeholder1", "value doesnt exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
// %someplugin_placeholder2%
|
|
||||||
if(identifier.equals("placeholder2")){
|
|
||||||
return plugin.getConfig().getString("placeholder2", "value doesnt exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
// We return null if an invalid placeholder (f.e. %someplugin_placeholder3%)
|
|
||||||
// was provided
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
As you can see is this method pretty similar to the one without any external plugins, since we can get an instance of our plugin much easier and also have a 100% guarantee that the plugin is installed and running.
|
### Register the Expansion
|
||||||
|
To register the expansion, you will need to call the `register()` method yourself.
|
||||||
|
This should be done in your plugin's `onEnable()` method after you make sure that PlaceholderAPI is installed and enabled.
|
||||||
|
|
||||||
Our final step now is to register the class and its placeholders. The plugin doesn't do this on its own.
|
|
||||||
To achieve this, add the following to your `onEnable()` section (Use your expansion name of course):
|
|
||||||
```java
|
```java
|
||||||
package at.helpch.placeholderapi.example
|
package at.helpch.placeholderapi.example
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class SomePlugin extends JavaPlugin{
|
public class SomePlugin extends JavaPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable(){
|
public void onEnable() {
|
||||||
// Small check to make sure that PlaceholderAPI is installed
|
// Small check to make sure that PlaceholderAPI is installed
|
||||||
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null){
|
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
new SomeExpansion(this).register();
|
new SomeExpansion(this).register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
----
|
||||||
|
## Relational Placeholders
|
||||||
|
Relational Placeholders are a bit more specific compared to the previous examples.
|
||||||
|
While they do use the same [common parts](#common-parts) that the other examples do, they have a different method to return placeholders.
|
||||||
|
|
||||||
|
In order to use the relational placeholders feature, you will need to implement the [`Relational`][relational] interface, which in return adds the `onPlaceholderRequest(Player, Player, String)` method to use.
|
||||||
|
|
||||||
|
#### Full Example
|
||||||
|
Please see the [Common parts](#common-parts) section for info on the other methods.
|
||||||
|
|
||||||
|
In this example, we use the [Internal class setup](#with-a-plugin-internal-jar) and `SomePlugin` has an `areFriends(Player, Player)` method that returns true or false based on if the given players are friends.
|
||||||
|
|
||||||
|
```java
|
||||||
|
package at.helpch.placeholderapi.example.expansions;
|
||||||
|
|
||||||
|
import at.helpch.placeholderapi.example.SomePlugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Player;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import me.clip.placeholderapi.expansion.Relational;
|
||||||
|
|
||||||
|
public class SomeExpansion extends PlaceholderExpansion implements Relational {
|
||||||
|
|
||||||
|
private final SomePlugin plugin;
|
||||||
|
|
||||||
|
public SomeExpansion(SomePlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAuthor() {
|
||||||
|
return "someauthor";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "example";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return "1.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean persist() {
|
||||||
|
return true; // This is required or else PlaceholderAPI will unregister the Expansion on reload
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onPlaceholderRequest(Player one, Player two, String identifier) {
|
||||||
|
if(one == null || two == null)
|
||||||
|
return null; // We require both Players to be online
|
||||||
|
|
||||||
|
if(params.equalsIgnoreCase("friend")) {
|
||||||
|
if(plugin.areFriends(one, two)) {
|
||||||
|
return ChatColor.GREEN + one.getName() + " and " + two.getName() + " are friends!";
|
||||||
|
} else {
|
||||||
|
return ChatColor.GREEN + one.getName() + " and " + two.getName() + " are not friends!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null; // Placeholder is unknown by the Expansion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Notes about Relational Placeholders
|
||||||
|
Relational placeholders will always start with `%rel_` to properly identify them.
|
||||||
|
So in the above example, the full placeholder will look like `%rel_example_friend%`.
|
||||||
|
|||||||
8841
wiki/Placeholders.md
8841
wiki/Placeholders.md
File diff suppressed because it is too large
Load Diff
@@ -41,9 +41,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[Advanced Abilities](https://www.spigotmc.org/resources/21983/)**
|
- **[Advanced Abilities](https://www.spigotmc.org/resources/21983/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#advanced-abilities]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#advanced-abilities]]**]
|
||||||
- **[Advanced Achievements](https://www.spigotmc.org/resources/6239/)**
|
- **[Advanced Achievements](https://www.spigotmc.org/resources/83466/)**
|
||||||
- [x] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#advanced-achievements]]**]
|
||||||
- **[AdvancedAFK](https://www.spigotmc.org/resources/60761/)**
|
- **[AdvancedAFK](https://www.spigotmc.org/resources/60761/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#advancedafk]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#advancedafk]]**]
|
||||||
@@ -62,6 +62,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[ajParkour](https://www.spigotmc.org/resources/60909/)**
|
- **[ajParkour](https://www.spigotmc.org/resources/60909/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#ajparkour]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#ajparkour]]**]
|
||||||
|
- **[AlonsoLevels](https://www.spigotmc.org/resources/83380/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#alonsolevels]]**]
|
||||||
- **[AnimatedBoard](https://www.spigotmc.org/resources/13632/)**
|
- **[AnimatedBoard](https://www.spigotmc.org/resources/13632/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
@@ -86,6 +89,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[AsyncKeepAlive](https://www.spigotmc.org/resources/64676/)**
|
- **[AsyncKeepAlive](https://www.spigotmc.org/resources/64676/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#asynckeepalive]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#asynckeepalive]]**]
|
||||||
|
- **[Ath](https://www.spigotmc.org/resources/87124/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#ath]]**]
|
||||||
- **[AutoCommandsPlus](https://www.spigotmc.org/resources/11083/)**
|
- **[AutoCommandsPlus](https://www.spigotmc.org/resources/11083/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
@@ -116,6 +122,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[BentoBox](https://github.com/BentoBoxWorld/BentoBox)**
|
- **[BentoBox](https://github.com/BentoBoxWorld/BentoBox)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#bentobox]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#bentobox]]**]
|
||||||
|
- **[BetonQuest](https://www.spigotmc.org/resources/2117/)
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#betonquest]]**]
|
||||||
- **[Big Doors Opener](https://www.spigotmc.org/resources/80805/)**
|
- **[Big Doors Opener](https://www.spigotmc.org/resources/80805/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
@@ -134,6 +143,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[BossVote](https://www.spigotmc.org/resources/16497/)**
|
- **[BossVote](https://www.spigotmc.org/resources/16497/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
|
- **[Boxing](https://www.spigotmc.org/resources/83879/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#boxing]]**]
|
||||||
- **[Broadcaster Plugin](https://dev.bukkit.org/projects/broadcaster-plugin)**
|
- **[Broadcaster Plugin](https://dev.bukkit.org/projects/broadcaster-plugin)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
@@ -188,9 +200,12 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[Clans](https://www.spigotmc.org/resources/34696/)**
|
- **[Clans](https://www.spigotmc.org/resources/34696/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#clans]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#clans]]**]
|
||||||
- **[Clans](https://www.spigotmc.org/resources/78415/)**
|
- **[ClansFree](https://www.spigotmc.org/resources/78415/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#clans-1]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#clansfree]]**]
|
||||||
|
- **[ClansPro](https://www.spigotmc.org/resources/87515/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#clanspro]]**]
|
||||||
- **[ClicksPerSecond](https://www.spigotmc.org/resources/57214/)**
|
- **[ClicksPerSecond](https://www.spigotmc.org/resources/57214/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
@@ -233,6 +248,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[CustomHelp](https://www.spigotmc.org/resources/20606/)**
|
- **[CustomHelp](https://www.spigotmc.org/resources/20606/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
|
- **[Custom Items](https://www.spigotmc.org/resources/63848/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#custom-items]]**]
|
||||||
- **[CustomSigns](https://www.spigotmc.org/resources/63569/)**
|
- **[CustomSigns](https://www.spigotmc.org/resources/63569/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
@@ -256,7 +274,7 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
- **[DeluxeMenus](https://www.spigotmc.org/resources/11734/)**
|
- **[DeluxeMenus](https://www.spigotmc.org/resources/11734/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [x] Provides own placeholders. [**[[Link|Placeholder#deluxemenus]]**]
|
||||||
- **[DeluxeTags](https://www.spigotmc.org/resources/4390/)**
|
- **[DeluxeTags](https://www.spigotmc.org/resources/4390/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#deluxetags]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#deluxetags]]**]
|
||||||
@@ -386,6 +404,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[HoloBlock](https://www.spigotmc.org/resources/43192/)**
|
- **[HoloBlock](https://www.spigotmc.org/resources/43192/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#holoblock]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#holoblock]]**]
|
||||||
|
- **[HoloMobHealth](https://www.spigotmc.org/resources/75975/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [ ] Provides own placeholders. [Link]
|
||||||
- **[HPWizard](https://www.spigotmc.org/resources/26821/)**
|
- **[HPWizard](https://www.spigotmc.org/resources/26821/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#hpwizard]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#hpwizard]]**]
|
||||||
@@ -398,6 +419,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[InteractionVisualizer](https://www.spigotmc.org/resources/77050/)**
|
- **[InteractionVisualizer](https://www.spigotmc.org/resources/77050/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#interactionvisualizer]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#interactionvisualizer]]**]
|
||||||
|
- **[InteractiveChat](https://www.spigotmc.org/resources/75870/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#interactivechat]]**]
|
||||||
- **[IslandRate (ASkyBlock Addon)](https://www.spigotmc.org/resources/53519/)**
|
- **[IslandRate (ASkyBlock Addon)](https://www.spigotmc.org/resources/53519/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#islandrate-askyblock-addon]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#islandrate-askyblock-addon]]**]
|
||||||
@@ -437,6 +461,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
|
|
||||||
----
|
----
|
||||||
## L
|
## L
|
||||||
|
- **[Lands](https://www.spigotmc.org/resources/53313/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#lands]]**]
|
||||||
- **[LastLoginAPI](https://www.spigotmc.org/resources/66348/)**
|
- **[LastLoginAPI](https://www.spigotmc.org/resources/66348/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#lastloginapi]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#lastloginapi]]**]
|
||||||
@@ -452,6 +479,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[LemonMobCoins](https://www.spigotmc.org/resources/59402/)**
|
- **[LemonMobCoins](https://www.spigotmc.org/resources/59402/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#lemonmobcoins]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#lemonmobcoins]]**]
|
||||||
|
- **[LevelledMobs](https://www.spigotmc.org/resources/levelledmobs-for-1-14-x-1-17-x.74304/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#levelledmobs]]**]
|
||||||
- **[LuckPerms](https://www.spigotmc.org/resources/28140/)**
|
- **[LuckPerms](https://www.spigotmc.org/resources/28140/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#luckperms]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#luckperms]]**]
|
||||||
@@ -533,6 +563,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[Nameless Plugin](https://www.spigotmc.org/resources/59032/)**
|
- **[Nameless Plugin](https://www.spigotmc.org/resources/59032/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#nameless-plugin]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#nameless-plugin]]**]
|
||||||
|
- **[NameMC-API-ServersMC](https://www.spigotmc.org/resources/88871/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders##namemc-api-serversmc]]**]
|
||||||
- **[Nicknamer](https://www.spigotmc.org/resources/5341/)**
|
- **[Nicknamer](https://www.spigotmc.org/resources/5341/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#nicknamer]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#nicknamer]]**]
|
||||||
@@ -554,9 +587,15 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[OnTime](http://dev.bukkit.org/bukkit-plugins/ontime/)**
|
- **[OnTime](http://dev.bukkit.org/bukkit-plugins/ontime/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#ontime]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#ontime]]**]
|
||||||
|
- **[OpEconomy](https://www.spigotmc.org/resources/95674)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#opeconomy]]**]
|
||||||
- **[OreAnnouncer](https://www.spigotmc.org/resources/33464/)**
|
- **[OreAnnouncer](https://www.spigotmc.org/resources/33464/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#oreannouncer]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#oreannouncer]]**]
|
||||||
|
- **[OreMarket](https://www.spigotmc.org/resources/91015/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#oremarket]]**]
|
||||||
- **[Outpost](https://www.spigotmc.org/resources/38657/)**
|
- **[Outpost](https://www.spigotmc.org/resources/38657/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#outpost]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#outpost]]**]
|
||||||
@@ -603,11 +642,14 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
- **[PowerRanks](https://www.spigotmc.org/resources/64696/)**
|
- **[PowerRanks](https://www.spigotmc.org/resources/64696/)**
|
||||||
- [ ] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#powerranks]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#powerranks]]**]
|
||||||
- **[PremiumVanish](https://www.spigotmc.org/resources/14404/)**
|
- **[PremiumVanish](https://www.spigotmc.org/resources/14404/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#premiumvanish]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#premiumvanish]]**]
|
||||||
|
- **[Prison](https://www.spigotmc.org/resources/1223/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#prison]]**]
|
||||||
- **[PrisonMines](https://www.spigotmc.org/resources/4046/)**
|
- **[PrisonMines](https://www.spigotmc.org/resources/4046/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#prisonmines]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#prisonmines]]**]
|
||||||
@@ -672,12 +714,18 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[RankedHelp](https://www.spigotmc.org/resources/61919/)**
|
- **[RankedHelp](https://www.spigotmc.org/resources/61919/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
|
- **[RankJoin](https://www.spigotmc.org/resources/67551/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [ ] Provides own placeholders. [Link]
|
||||||
- **[Rankup](https://www.spigotmc.org/resources/17933/)**
|
- **[Rankup](https://www.spigotmc.org/resources/17933/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#rankup]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#rankup]]**]
|
||||||
- **[RawMSG](https://www.spigotmc.org/resources/35864/)**
|
- **[RawMSG](https://www.spigotmc.org/resources/35864/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders.
|
- [ ] Provides own placeholders.
|
||||||
|
- **[RealisticWorldGenerator](https://www.spigotmc.org/resources/15905/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#realisticworldgenerator]]**]
|
||||||
- **[RecentFind (Treasures Add-on)](https://www.spigotmc.org/resources/33366/)**
|
- **[RecentFind (Treasures Add-on)](https://www.spigotmc.org/resources/33366/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#recentfind]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#recentfind]]**]
|
||||||
@@ -690,6 +738,12 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[RestrictedDimensions](http://spigotmc.org/resources/80574/)**
|
- **[RestrictedDimensions](http://spigotmc.org/resources/80574/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#restricteddimensions]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#restricteddimensions]]**]
|
||||||
|
- **[RocketJoin](https://www.spigotmc.org/resources/82520/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [ ] Provides own placeholders. [Link]
|
||||||
|
- **[RocketPlaceholders](https://www.spigotmc.org/resources/82678/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#rocketplaceholders]]**]
|
||||||
- **[RogueParkour](https://www.spigotmc.org/resources/26563/)**
|
- **[RogueParkour](https://www.spigotmc.org/resources/26563/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#rogueparkour]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#rogueparkour]]**]
|
||||||
@@ -705,6 +759,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[RPGInventory](https://www.spigotmc.org/resources/12498/)**
|
- **[RPGInventory](https://www.spigotmc.org/resources/12498/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#rpginventory]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#rpginventory]]**]
|
||||||
|
- **[RTP](https://www.spigotmc.org/resources/94812/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#rtp]]**]
|
||||||
|
|
||||||
----
|
----
|
||||||
## S
|
## S
|
||||||
@@ -717,6 +774,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[Skellett (Skript Add-on)](https://forums.skunity.com/resources/24/)**
|
- **[Skellett (Skript Add-on)](https://forums.skunity.com/resources/24/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
|
- **[Seasons](https://www.spigotmc.org/resources/39298/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#seasons]]**]
|
||||||
- **[SellAll](https://www.spigotmc.org/resources/1221/)**
|
- **[SellAll](https://www.spigotmc.org/resources/1221/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#sellall]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#sellall]]**]
|
||||||
@@ -735,6 +795,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[SimpleClans](https://www.spigotmc.org/resources/5269/)**
|
- **[SimpleClans](https://www.spigotmc.org/resources/5269/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#simpleclans]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#simpleclans]]**]
|
||||||
|
- **[SimpleCoins](https://dev.bukkit.org/projects/simplecoins)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#simplecoins]]**]
|
||||||
- **[SimpleCoinsAPI](https://www.spigotmc.org/resources/1432/)**
|
- **[SimpleCoinsAPI](https://www.spigotmc.org/resources/1432/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#simplecoinsapi]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#simplecoinsapi]]**]
|
||||||
@@ -750,6 +813,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[SkillAPI](https://www.spigotmc.org/resources/4824/)**
|
- **[SkillAPI](https://www.spigotmc.org/resources/4824/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#skillapi]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#skillapi]]**]
|
||||||
|
- **[SkinsRestorer](https://www.spigotmc.org/resources/2124/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#skinsrestorer]]**]
|
||||||
- **[Skript](https://github.com/bensku/Skript)**
|
- **[Skript](https://github.com/bensku/Skript)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#skript]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#skript]]**]
|
||||||
@@ -783,9 +849,15 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[Staff Facilities](https://www.spigotmc.org/resources/13097/)**
|
- **[Staff Facilities](https://www.spigotmc.org/resources/13097/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#staff-facilities]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#staff-facilities]]**]
|
||||||
|
- **[Staff++](https://www.spigotmc.org/resources/staff.83562/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#staffplusplus]]**]
|
||||||
- **[Statz](https://www.spigotmc.org/resources/25969/)**
|
- **[Statz](https://www.spigotmc.org/resources/25969/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#statz]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#statz]]**]
|
||||||
|
- **[Streaming Drops](https://www.spigotmc.org/resources/76996/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#streaming-drops]]**]
|
||||||
- **[StrikePractice 2](https://www.spigotmc.org/resources/46906/)**
|
- **[StrikePractice 2](https://www.spigotmc.org/resources/46906/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#strikepractice-2]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#strikepractice-2]]**]
|
||||||
@@ -822,9 +894,15 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[Thirst](https://www.spigotmc.org/resources/3316/)**
|
- **[Thirst](https://www.spigotmc.org/resources/3316/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#thirst]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#thirst]]**]
|
||||||
|
- **[TicketGUI](https://www.spigotmc.org/resources/68968/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#ticketgui]]**]
|
||||||
- **[Timed Rewards](https://www.spigotmc.org/resources/34008/)**
|
- **[Timed Rewards](https://www.spigotmc.org/resources/34008/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#timed-rewards]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#timed-rewards]]**]
|
||||||
|
- **[TimeManager](https://www.spigotmc.org/resources/44344/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#timemanager]]**]
|
||||||
- **[Time Tokens](https://www.spigotmc.org/resources/75441/)**
|
- **[Time Tokens](https://www.spigotmc.org/resources/75441/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#time-tokens]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#time-tokens]]**]
|
||||||
@@ -840,12 +918,18 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[Tokens](https://www.spigotmc.org/resources/71941/)**
|
- **[Tokens](https://www.spigotmc.org/resources/71941/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#tokens]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#tokens]]**]
|
||||||
|
- **[TokensPlus](https://www.spigotmc.org/resources/90507/)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#tokensplus]]**]
|
||||||
- **[Towny](https://github.com/TownyAdvanced/Towny)**
|
- **[Towny](https://github.com/TownyAdvanced/Towny)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#towny]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#towny]]**]
|
||||||
- **[TownyChat](https://github.com/TownyAdvanced/TownyChat)**
|
- **[TownyChat](https://github.com/TownyAdvanced/TownyChat)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#townychat]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#townychat]]**]
|
||||||
|
- **[TpLogin](https://www.spigotmc.org/resources/21692/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [ ] Provides own placeholders. [Link]
|
||||||
- **[TransmuteIt](https://www.spigotmc.org/resources/76287/)**
|
- **[TransmuteIt](https://www.spigotmc.org/resources/76287/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#transmuteIt]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#transmuteIt]]**]
|
||||||
@@ -858,6 +942,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[TrickOrTreat](https://www.spigotmc.org/resources/61370/)**
|
- **[TrickOrTreat](https://www.spigotmc.org/resources/61370/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#trickortreat]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#trickortreat]]**]
|
||||||
|
- **[Two Factor Authentication](https://www.spigotmc.org/resources/85594/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#twofactorauthentication]]**]
|
||||||
|
|
||||||
----
|
----
|
||||||
## U
|
## U
|
||||||
@@ -870,6 +957,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[UltimateBossBar](https://www.spigotmc.org/resources/19303/)**
|
- **[UltimateBossBar](https://www.spigotmc.org/resources/19303/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders.
|
- [ ] Provides own placeholders.
|
||||||
|
- **[UltimateClaims](https://songoda.com/marketplace/product/65)**
|
||||||
|
- [ ] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#ultimateclaims]]**]
|
||||||
- **[UltimateSigns](https://www.spigotmc.org/resources/72462/)**
|
- **[UltimateSigns](https://www.spigotmc.org/resources/72462/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders.
|
- [ ] Provides own placeholders.
|
||||||
@@ -909,6 +999,9 @@ If your plugin isn't shown here and you want it to be added, [open an issue](/Pl
|
|||||||
- **[VentureChat](https://www.spigotmc.org/resources/771/)**
|
- **[VentureChat](https://www.spigotmc.org/resources/771/)**
|
||||||
- [x] Supports placeholders.
|
- [x] Supports placeholders.
|
||||||
- [ ] Provides own placeholders. [Link]
|
- [ ] Provides own placeholders. [Link]
|
||||||
|
- **[VenturahCalendar](https://www.spigotmc.org/resources/94096/)**
|
||||||
|
- [x] Supports placeholders.
|
||||||
|
- [x] Provides own placeholders. [**[[Link|Placeholders#venturacalendar]]**]
|
||||||
- **[ViaVersion](https://www.spigotmc.org/resources/19254/)**
|
- **[ViaVersion](https://www.spigotmc.org/resources/19254/)**
|
||||||
- [ ] Supports placeholders.
|
- [ ] Supports placeholders.
|
||||||
- [x] Provides own placeholders. [**[[Link|Placeholders#viaversion]]**]
|
- [x] Provides own placeholders. [**[[Link|Placeholders#viaversion]]**]
|
||||||
|
|||||||
215
wiki/README.md
215
wiki/README.md
@@ -1,82 +1,181 @@
|
|||||||
[Wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
|
[wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
|
||||||
[Placeholders]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders
|
|
||||||
[Plugins using PlaceholderAPI]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders
|
[placeholders]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders
|
||||||
|
[using_papi]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Plugins-using-PlaceholderAPI
|
||||||
|
|
||||||
|
[discord]: https://discord.gg/HelpChat
|
||||||
|
[discussion]: https://github.com/PlaceholderAPI/PlaceholderAPI/discussions
|
||||||
|
|
||||||
|
[andre]: https://github.com/Andre601
|
||||||
|
[andrew]: https://github.com/Andrew-Chen-Wang
|
||||||
|
[action]: https://github.com/Andrew-Chen-Wang/github-wiki-action
|
||||||
|
|
||||||
|
<!-- Images -->
|
||||||
|
[branch-selector]: https://user-images.githubusercontent.com/11576465/132779328-8571458a-d63d-4c25-b920-96aa16ae0058.png
|
||||||
|
[upstream_up-to-date]: https://user-images.githubusercontent.com/11576465/132779917-96f19239-077d-44ed-98e7-6a76f305b33a.png
|
||||||
|
[upstream_needs_update]: https://user-images.githubusercontent.com/11576465/132779798-1fe3dc72-a6c2-41eb-a8bc-95793671f384.png
|
||||||
|
[create_branch]: https://user-images.githubusercontent.com/11576465/132780127-45599156-1400-40c9-b865-351574786873.png
|
||||||
|
|
||||||
# Wiki
|
# Wiki
|
||||||
This is the wiki folder. It contains all pages that you can find in our [Wiki].
|
Welcome to the Wiki folder!
|
||||||
It allows you to suggest changes through Pull request while keeping a simple way for us to maintain the wiki, without granting everyone push rights to it.
|
|
||||||
|
|
||||||
If you want to contribute towards the wiki would we highly recommend to follow the below contributing Guidelines, to keep the overal style of the wiki intact.
|
This folder contains all the files of the [PlaceholderAPI Wiki][wiki].
|
||||||
|
It allows you to contribute towards the wiki and us to have more control about what changes are commited to it.
|
||||||
|
|
||||||
## Adding your resource(s)
|
## Contrbuting to the wiki
|
||||||
If you have one or multiple resources that support PlaceholderAPI (being it by just supporting placeholders from other plugins, or providing your own) can you add them to the wiki in the following ways.
|
If you want to contribute towards the wiki, will you need to follow the below instructions to not get your Pull request closed without a warning.
|
||||||
|
|
||||||
### [Plugins using PlaceholderAPI]
|
### Fork the Repository (Not wiki!)
|
||||||
You should always add your resource to this page, no matter if it only supports placeholders or also provides its own.
|
> Already having a fork? Skip to the [next Step](#select-target-branch)!
|
||||||
|
|
||||||
The format of a plugin is always as follows:
|
You need to make a fork of the PlaceholderAPI Repository to contribute towards the wiki.
|
||||||
```md
|
To do this, click the "Fork" button on the top-right corner of the site and select the account you want your fork to be created on. This will also show you any already existing forks of this Repository that you may have.
|
||||||
- **[:name](:url)**
|
|
||||||
- [?] Supports placeholders.
|
|
||||||
- [?] Provides own placeholders. [:link]
|
|
||||||
```
|
|
||||||
|
|
||||||
A quick summary over the different parts:
|
The forking process should only take a few seconds and you should be redirected to your fork afterwards.
|
||||||
|
|
||||||
- `:name` is the name of your resource. The resources are ordered by alphabet and if yours has the same name as another one listed, add it __below__ the other resource.
|
### Select target branch
|
||||||
- `:url` should be replaced with a URL to your resource page (Spigot, dev.bukkit, etc.). If you use Spigot, make sure to remove any text after the `/resources/` and only leave the ID. For example will https://www.spigotmc.org/resources/placeholderapi.6245/ become https://www.spigotmc.org/resources/6245/.
|
All main changes to the wiki are made on the dedicated `docs/wiki` branch.
|
||||||
If you don't have your resource on any resource page can you either ommit the URL (Just provide the name) or provide a link to its source, if available.
|
Before you try to make any changes should you make sure that you have the `docs/wiki` branch selected. To do that, check the button next to the `X branches` text. If it says anything other than `docs/wiki` will you need to click it and select the right branch.
|
||||||
- `?` should be replaced with either an `x` or a space depending on wether your plugin supports the option or not. So the `[?]` becomes either `[x]` or `[ ]`
|
|
||||||
- `:link` depends on wether your plugin provides own placeholders or not. If it doesn't, then you can just give `Link`. If it does provide placeholders, make sure to provide `[[Link|Placeholders#:name]]` where `:name` would be the name of your resource in the [Placeholders] page.
|
|
||||||
|
|
||||||
### [Placeholders]
|
![branch-selector]
|
||||||
If your plugin provides its own placeholders through an extension is it recommendet to add this extension to the [Placeholders] page.
|
|
||||||
This page is split up into two sections: PAPI Placeholders and Plugin Placeholders.
|
|
||||||
|
|
||||||
PAPI Placeholders are extensions that don't require an external plugin or other dependency to function normally. Common examples are the Player or Server extensions.
|
### Fetch Changes from Upstream
|
||||||
The Plugin Placeholders are extensions that require a plugin or other dependency to function. They are often used to provide values from one pluging (e.g. Vault) to another plugin through the help of PlaceholderAPI.
|
This is only required when you already had a fork and didn't update it for some time.
|
||||||
|
|
||||||
The overall structure of an entry is always the same:
|
While you're on the `docs/wiki` branch, click the `Fetch upstream` text located right below the green `Code` button.
|
||||||
````md
|
Depending on the status of your branch can the prompt show different outcomes:
|
||||||
- ### **[:name](:url)**
|
|
||||||
> :command
|
|
||||||
|
|
||||||
```
|
- `This branch is not behind the upstream PlaceholderAPI:docs/wiki`
|
||||||
:placeholders
|
Your fork's `docs/wiki` branch is up-to-date with the latest changes from Upstream (This Repository). You don't have to update anything.
|
||||||
```
|
![upstream_up-to-date]
|
||||||
----
|
- `Fetch and merge <number> upstream commits from PlaceholderAPI:docs/wiki`
|
||||||
|
This is shown when your fork's branch is outdated and upstream (This Repository) has changes. Click the `Fetch and merge` button to fetch the latest commits and update your fork's `docs/wiki` branch.
|
||||||
|
![upstream_needs_update]
|
||||||
|
|
||||||
|
### Commit changes
|
||||||
|
To commit changes will you need to choose, if you want to directly commit to your fork's `docs/wiki` branch, or make a dedicated branch for it.
|
||||||
|
|
||||||
|
#### Make separate branch (Optional)
|
||||||
|
If you want to have a dedicated branch for it, will you need to click the button saying `docs/wiki`, type in the small text field the name of the branch you want to use and click the text saying `Create branch: <branch> from 'docs/wiki'`
|
||||||
|
|
||||||
|
![create_branch]
|
||||||
|
|
||||||
|
After that should you now have a separate branch that is based of the `docs/wiki` branch and you can finally commit changes to it.
|
||||||
|
|
||||||
|
#### Formatting
|
||||||
|
The wiki uses normal Markdown formatting with some special design-rules you need to keep in mind.
|
||||||
|
These rules are as follows:
|
||||||
|
|
||||||
|
- Unordered lists need to start with a `-` and not `*`. This is to not get it confused with *italic text* which uses single `*` characters.
|
||||||
|
- New lines in lists need to keep their indends. This means you need to add two spaces at the start to keep the text in the same line.
|
||||||
|
Example:
|
||||||
|
```markdown
|
||||||
|
- Line 1
|
||||||
|
Line 2
|
||||||
|
```
|
||||||
|
- Use the `[[Page]]` and `[[Text|Page]]` format to link to other wiki pages. While those aren't rendered in the wiki folder will they render in the final wiki pages.
|
||||||
|
- External links should be set as Refernce Links, which means they are set as `[text]: link` at the top of the page and then used either through `[text]` or `[display text][text]` througout the page.
|
||||||
|
|
||||||
|
#### Adding new Expansion
|
||||||
|
When you add a new expansion to the wiki's [Placeholder page][placeholders] will you need to follow the following format:
|
||||||
|
````markdown
|
||||||
|
- ### [:name](:link)
|
||||||
|
> :command
|
||||||
|
|
||||||
|
:text
|
||||||
|
|
||||||
|
```
|
||||||
|
:placeholders
|
||||||
|
```
|
||||||
````
|
````
|
||||||
|
|
||||||
- `:name` is the name of your resource. The resources are ordered by alphabet and if yours has the same name as another one listed, add it __below__ the other resource.
|
There are a few extra rules you need to also keep in mind:
|
||||||
- `:url` should be replaced with a URL to your resource page (Spigot, dev.bukkit, etc.). If you use Spigot, make sure to remove any text after the `/resources/` and only leave the ID. For example will https://www.spigotmc.org/resources/placeholderapi.6245/ become https://www.spigotmc.org/resources/6245/.
|
|
||||||
If you don't have your resource on any resource page can you either ommit the URL (Just provide the name) or provide a link to its source, if available.
|
|
||||||
- `:command` depends on if your extension is available on the eCloud or is build into your resource. If you have it on the eCloud should you provide `/papi ecloud download :name` where `:name` is the name your expansion has on the eCloud.
|
|
||||||
If your extension is build into your resource can you just set `NO DOWNLOAD COMMAND` instead.
|
|
||||||
- `:placeholders` would be a list of all placeholders that your extension offers (Sorted by alphabet). If your placeholders support multiple variables like item names, should you use either `<text>` or `[text]` depending on if it is required or optional.
|
|
||||||
|
|
||||||
Always keep an empty line in between the `----` and the next entry below it.
|
- `:name` would be the name of your Expansion, not the plugin (Unless it is integrated into your plugin).
|
||||||
If your extension is at the very bottom of the page can you ommit the `----`.
|
- Only embed a link, if your Expansion requires a plugin to function.
|
||||||
|
- When linking to a Spigot page, make sure to sanitze the link.
|
||||||
|
This means that f.e. https://www.spigotmc.org/resources/placeholderapi.6245/ becomes https://www.spigotmc.org/resources/6245/
|
||||||
|
- `:command` should be replaced with either the PlaceholderAPI command to download your expansion from the eCloud (`/papi ecloud download :name`) or with `NO DOWNLOAD COMMAND` if no separate download is available.
|
||||||
|
- `:text` is optional and should only be provided to link to additional documentation, your own placeholder list, or explain more complicated placeholders/features.
|
||||||
|
- `:placeholders` will be the list of placeholders your expansion provides.
|
||||||
|
Please avoid specific examples (i.e. `%placeholder_player_user123%`) and instead use `<>` and `[]` to mark required and optional options respecively (`%placeholder_player_<player>%`)
|
||||||
|
|
||||||
You will also need to add your extension's name to the list at the very top in the format `- **[:name](#:name)**` where `:name` is the extension name.
|
**Note:**
|
||||||
|
When your Expansion's entry is after and/or before other entries will you need to add `----` before or after it to separate it from other entries.
|
||||||
|
|
||||||
## Other Wiki pages
|
##### Example:
|
||||||
Please follow these general guidelines when editing any other pages.
|
````markdown
|
||||||
|
- ### SomeExpansion
|
||||||
|
> NO DOWNLOAD COMMAND
|
||||||
|
|
||||||
### Linking
|
```
|
||||||
Linking should always be done through either the reference option or through the Wiki link option.
|
%someexpansion_placeholder%
|
||||||
When the link leads to a page on the wiki should you use either `[[:page]]` or `[[:name|:page]]` where `:page` would be the name of the Wiki page (Case sensitive) and `:name` the text that would be displayed instead.
|
```
|
||||||
When linking to a section within a Wiki page should you link to it using a hashtag (`#`). For example would linking to the player extension result in `[[Placeholders#player]]` (Always have the section lowercase.
|
|
||||||
However, when you link to a section in the same wiki page should you do it in the format `[:name](#:section)` where `:name` is the text to display and `:section` is the name of the section.
|
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
When you link to an external page that isn't part of the wiki should you do it as a reference link (Exception is the above mentioned cases for resources and extensions).
|
- ### YourExpansion
|
||||||
You do this by adding `[:name]: :url` at the top of the page where `:name` is the reference name to use and `:url` is the url to link to.
|
> NO DOWNLOAD COMMAND
|
||||||
|
|
||||||
You can then just use either `[:name]` or `[:display_text][:name]` to link to the url you set (`:display_text` could be any text (including spaces) to display).
|
```
|
||||||
Reference links are case-insensitive.
|
%yourexpansion_placeholder%
|
||||||
|
```
|
||||||
|
|
||||||
This system allows us to easly maintain the links without the need to update a URL on several places within the page.
|
----
|
||||||
|
|
||||||
### Lists
|
- ### AnotherExpansion
|
||||||
Lists should always be started with a hyphen (`-`) to better distinguish it from other formatting characters like the asterisk (`*`) used for bold or italic text.
|
> NO DOWNLOAD COMMAND
|
||||||
|
|
||||||
|
```
|
||||||
|
%anotherexpansion_placeholder%
|
||||||
|
```
|
||||||
|
````
|
||||||
|
|
||||||
|
After you added your expansion to this page will you also need to add an entry to the list at the top of the page.
|
||||||
|
You do so by adding `- **[:text](#:name)**` to the list, where `:text` is the text to display (Usually the name you set) and `:name` is the name you just set. If your expansion shares the exact same name as another entry on the page will you need to make sure that your expansion is listed **after** the other one AND that the list-entry has a `-1` appended to `#:name` (So f.e. `#expansion` becomes `#expansion-1`).
|
||||||
|
|
||||||
|
Finally can you now commit your changes and move forward to the [Plugins using PlaceholderAPI][using_papi] page in the wiki folder.
|
||||||
|
|
||||||
|
#### Adding new plugin
|
||||||
|
This step is only required if you either add a new plugin to the list, or you added an Expansion that is included in your own plugin.
|
||||||
|
|
||||||
|
Similar to the [Placeholders page][placeholders] does this page follow a specific format which we will explain real quick.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
- [:name](:link)
|
||||||
|
- [?] Supports placeholders.
|
||||||
|
- [?] Provides own placeholders. [:page]
|
||||||
|
```
|
||||||
|
|
||||||
|
Here are the following rules:
|
||||||
|
|
||||||
|
- `:name` needs to be replaced with the Name of your plugin.
|
||||||
|
- `:link` needs to be the link of the plugin's resource page.
|
||||||
|
- If no resource page is available can a GitHub repository be linked (if available) or the link omited altogether)
|
||||||
|
- When linking to a Spigot page, make sure to sanitze the link.
|
||||||
|
This means that f.e. https://www.spigotmc.org/resources/placeholderapi.6245/ becomes https://www.spigotmc.org/resources/6245/
|
||||||
|
- `[?]` needs to be replaced with either `[ ]` or `[x]` depending on whether the mentioned option is supported or not.
|
||||||
|
- `:page` needs to replace with the right value, depending on the conditions.
|
||||||
|
- If your plugin provides own Placeholders for other plugins to use can you set `**[[Link|Placeholders#:name]]**` where `:name` is the title you set in the placeholders page.
|
||||||
|
- If your plugin does not provide own placeholders will you need to set `Link`.
|
||||||
|
|
||||||
|
### Make a Pull request
|
||||||
|
After you made your changes is it time to make a Pull request.
|
||||||
|
|
||||||
|
When you go to the upstream repository, should GitHub already show you a notification that you have commits to PR. Click the `Compare & pull request` button to proceed.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
By default will GitHub select the `master` branch as the target, which is not what we want. To fix this, click the button saying `base:master` and select the `docs/wiki` branch.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Finally, fill out the Pull request template and submit the Pull request.
|
||||||
|
Congratulations! You've successfully made a Pull request for the wiki.
|
||||||
|
|
||||||
|
### Questions?
|
||||||
|
If you have any questions, do not hesitate to ask in the [HelpChat Discord][discord] or [open a new discussion][discussion] in this repository. We will be happy to help you.
|
||||||
|
|
||||||
|
### Credits
|
||||||
|
- The Wiki is maintained by [Andre601][andre].
|
||||||
|
- We use the [GitHub Wiki Action][action] by [Andrew-Chen-Wang][andrew] to update the PlaceholderAPI wiki through GitHub Actions.
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
|
[papi]: https://placeholderapi.com
|
||||||
|
|
||||||
[discordImg]: https://img.shields.io/discord/164280494874165248.svg?logo=discord&label=Discord&colorB=7289DA
|
[discordImg]: https://img.shields.io/discord/164280494874165248.svg?logo=discord&label=Discord&colorB=7289DA
|
||||||
[discord]: https://helpch.at/discord
|
[discord]: https://helpch.at/discord
|
||||||
|
|
||||||
[jenkinsImg]: https://img.shields.io/badge/Download%20from-Jenkins-brightgreen.svg
|
[jenkinsImg]: https://img.shields.io/badge/Download%20from-Jenkins-brightgreen.svg
|
||||||
[jenkins]: http://ci.extendedclip.com/job/PlaceholderAPI/
|
[jenkins]: http://ci.extendedclip.com/job/PlaceholderAPI/
|
||||||
|
|
||||||
[licenseImg]: https://img.shields.io/github/license/PlaceholderAPI/PlaceholderAPI.svg
|
[licenseImg]: https://img.shields.io/github/license/PlaceholderAPI/PlaceholderAPI.svg
|
||||||
[license]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/LICENSE
|
[license]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/LICENSE
|
||||||
|
|
||||||
[issuesImg]: https://img.shields.io/github/issues-raw/PlaceholderAPI/PlaceholderAPI.svg?logo=github&logoColor=white
|
[issuesImg]: https://img.shields.io/github/issues-raw/PlaceholderAPI/PlaceholderAPI.svg?logo=github&logoColor=white
|
||||||
[issues]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues
|
[issues]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues
|
||||||
[versionImg]: https://img.shields.io/nexus/r/http/repo.extendedclip.com/me.clip/placeholderapi.svg?label=API-Version
|
|
||||||
|
[versionImg]: https://img.shields.io/nexus/placeholderapi/me.clip/placeholderapi?server=https%3A%2F%2Frepo.extendedclip.com&label=API%20Version
|
||||||
[plugin-page]: https://spigotmc.org/resources/6245
|
[plugin-page]: https://spigotmc.org/resources/6245
|
||||||
|
|
||||||
|
> © 2015 - 2021 [PlaceholderAPI Team][papi]
|
||||||
> Thanks for using PlaceholderAPI.
|
> Thanks for using PlaceholderAPI.
|
||||||
>
|
>
|
||||||
> **[Plugin-page]** | **[[Placeholders]]** | **[[Plugins using PlaceholderAPI]]** | **[[Hook into PlaceholderAPI]]**
|
> **[Plugin-page]** | **[[Placeholders]]** | **[[Plugins using PlaceholderAPI]]** | **[[Hook into PlaceholderAPI]]**
|
||||||
|
>
|
||||||
![versionImg] [![jenkinsImg]][jenkins] [![licenseImg]][license] [![issuesImg]][issues] [![discordImg]][discord]
|
> ![versionImg] [![jenkinsImg]][jenkins] [![licenseImg]][license] [![issuesImg]][issues] [![discordImg]][discord]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://i.imgur.com/Adp7xdh.png" alt="PlaceholderAPI">
|
<img src="https://raw.githubusercontent.com/PlaceholderAPI/PlaceholderAPI/docs/wiki/wiki/img/icon.png" alt="PlaceholderAPI">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
**[[Main page|Home]]**
|
**[[Main page|Home]]**
|
||||||
@@ -7,10 +7,12 @@
|
|||||||
### Setup
|
### Setup
|
||||||
**[[Hook into PlaceholderAPI]]**
|
**[[Hook into PlaceholderAPI]]**
|
||||||
- [[First steps|Hook-into-PlaceholderAPI#first-steps]]
|
- [[First steps|Hook-into-PlaceholderAPI#first-steps]]
|
||||||
- [[Adding placeholders to PlaceholderAPI|Hook-into-PlaceholderAPI#adding-placeholders-to-placeholderapi]]
|
- [[Adding placeholders to PlaceholderAPI|PlaceholderExpansion]]
|
||||||
- [[PlaceholderExpansion]]
|
- [[Common Parts|PlaceholderExpansion#common-parts]]
|
||||||
- [[Without an external plugin|PlaceholderExpansion#without-an-external-plugin]]
|
- [[Without an external plugin|PlaceholderExpansion#without-a-plugin]]
|
||||||
- [[With external plugin|PlaceholderExpansion#with-external-plugin]]
|
- [[With an external Plugin (Separate Jar)|PlaceholderExpansion#with-a-plugin-external-jar]]
|
||||||
|
- [[With an external Plugin (Internal class)|PlaceholderExpansion#with-a-plugin-internal-class]]
|
||||||
|
- [[Relational Placeholders|PlaceholderExpansion#relational-placeholders]]
|
||||||
- [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]]
|
- [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]]
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
@@ -19,39 +21,7 @@
|
|||||||
**[[FAQ]]**
|
**[[FAQ]]**
|
||||||
**[[Plugins using PlaceholderAPI]]**
|
**[[Plugins using PlaceholderAPI]]**
|
||||||
**[[Placeholders]]**
|
**[[Placeholders]]**
|
||||||
- [[PAPI-placeholders|Placeholders#papi-placeholders-1]]
|
- [[Standalone|Placeholders#standalone]]
|
||||||
- [[Advancements|Placeholders#advancements]]
|
|
||||||
- [[Animations|Placeholders#animations]]
|
|
||||||
- [[Armor|Placeholders#armor]]
|
|
||||||
- [[ASCII|Placeholders#ASCII]]
|
|
||||||
- [[BungeeCord|Placeholders#bungeecord]]
|
|
||||||
- [[CheckItem|Placeholders#checkitem]]
|
|
||||||
- [[CooldownBar|Placeholders#cooldownbar]]
|
|
||||||
- [[Formatter|Placeholders#formatter]]
|
|
||||||
- [[Javascript|Placeholders#javascript]]
|
|
||||||
- [[ListPlayers|Placeholders#listplayer]]
|
|
||||||
- [[LocalTime|Placeholders#localtime]]
|
|
||||||
- [[Math|Placeholders#math]]
|
|
||||||
- [[MVdW placeholders|Placeholders#mvdw-placeholders]]
|
|
||||||
- [[OtherPlayer|Placeholders#otherplayer]]
|
|
||||||
- [[ParseNear|Placeholders#parsenear]]
|
|
||||||
- [[ParseOther|Placeholders#parseother]]
|
|
||||||
- [[Pinger|Placeholders#pinger]]
|
|
||||||
- [[Player|Placeholders#player]]
|
|
||||||
- [[PlayerList|Placeholders#playerlist]]
|
|
||||||
- [[Plugin|Placeholders#plugin]]
|
|
||||||
- [[Progress|Placeholders#progress]]
|
|
||||||
- [[RainbowColor|Placeholders#rainbowcolor]]
|
|
||||||
- [[RandomColor|Placeholders#randomcolor]]
|
|
||||||
- [[RedisBungee|Placeholders#redisbungee]]
|
|
||||||
- [[RelCon|Placeholders#relcon]]
|
|
||||||
- [[ScoreboardObjectives|Placeholders#scoreboardobjectives]]
|
|
||||||
- [[Server|Placeholders#server]]
|
|
||||||
- [[Sound|Placeholders#sound]]
|
|
||||||
- [[Spectators|Placeholders#spectators]]
|
|
||||||
- [[Statistic|Placeholders#statistic]]
|
|
||||||
|
|
||||||
- [[Plugin-placeholders|Placeholders#plugin-placeholders-1]]
|
|
||||||
- [[A|Placeholders#a]]
|
- [[A|Placeholders#a]]
|
||||||
- [[B|Placeholders#b]]
|
- [[B|Placeholders#b]]
|
||||||
- [[C|Placeholders#c]]
|
- [[C|Placeholders#c]]
|
||||||
@@ -75,4 +45,33 @@
|
|||||||
- [[U|Placeholders#u]]
|
- [[U|Placeholders#u]]
|
||||||
- [[V|Placeholders#v]]
|
- [[V|Placeholders#v]]
|
||||||
- [[W|Placeholders#w]]
|
- [[W|Placeholders#w]]
|
||||||
|
- [[X|Placeholders#x]]
|
||||||
|
- [[Y|Placeholders#y]]
|
||||||
- [[Z|Placeholders#z]]
|
- [[Z|Placeholders#z]]
|
||||||
|
- [[Plugin-placeholders|Placeholders#plugin-placeholders-1]]
|
||||||
|
- [[A|Placeholders#a-1]]
|
||||||
|
- [[B|Placeholders#b-1]]
|
||||||
|
- [[C|Placeholders#c-1]]
|
||||||
|
- [[D|Placeholders#d-1]]
|
||||||
|
- [[E|Placeholders#e-1]]
|
||||||
|
- [[F|Placeholders#f-1]]
|
||||||
|
- [[G|Placeholders#g-1]]
|
||||||
|
- [[H|Placeholders#h-1]]
|
||||||
|
- [[I|Placeholders#i-1]]
|
||||||
|
- [[J|Placeholders#j-1]]
|
||||||
|
- [[K|Placeholders#k-1]]
|
||||||
|
- [[L|Placeholders#l-1]]
|
||||||
|
- [[M|Placeholders#m-1]]
|
||||||
|
- [[N|Placeholders#n-1]]
|
||||||
|
- [[O|Placeholders#o-1]]
|
||||||
|
- [[P|Placeholders#p-1]]
|
||||||
|
- [[Q|Placeholders#q-1]]
|
||||||
|
- [[R|Placeholders#r-1]]
|
||||||
|
- [[S|Placeholders#s-1]]
|
||||||
|
- [[T|Placeholders#t-1]]
|
||||||
|
- [[U|Placeholders#u-1]]
|
||||||
|
- [[V|Placeholders#v-1]]
|
||||||
|
- [[W|Placeholders#w-1]]
|
||||||
|
- [[X|Placeholders#x-1]]
|
||||||
|
- [[Y|Placeholders#y-1]]
|
||||||
|
- [[Z|Placeholders#z-1]]
|
||||||
|
|||||||
BIN
wiki/img/icon.png
Normal file
BIN
wiki/img/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 96 KiB |
BIN
wiki/img/papi-logo.png
Normal file
BIN
wiki/img/papi-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
wiki/img/wiki-logo.png
Normal file
BIN
wiki/img/wiki-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user