Compare commits

..

172 Commits

Author SHA1 Message Date
Sxtanna
68402d244b bumped to 2.10.7 2020-07-28 17:36:39 -04:00
Sxtanna
81225dafbc updated parse command completer to suggest available placeholders 2020-07-28 16:09:30 -04:00
Sxtanna
74bd22eb0c updated char replacer to have spaces in placeholder parameters 2020-07-28 15:18:15 -04:00
Sxtanna
a6ab3a2a03 updated to publish dev builds to the dev repo 2020-07-28 14:47:37 -04:00
Sxtanna
9ef5cedfd6 updated to use credentials from the environment 2020-07-28 14:06:51 -04:00
Sxtanna
8f9b999e5a updated to publish to clip nexus repo 2020-07-28 13:47:28 -04:00
Sxtanna
f9156209e7 Merge remote-tracking branch 'origin/master' 2020-07-28 12:58:24 -04:00
Sxtanna
77d0654a29 updated build to use maven publish plugin 2020-07-28 12:58:06 -04:00
Sxtanna
300eb64d89 removed benchmarks for shitty replacer 2020-07-28 12:57:08 -04:00
Andre_601
ff01f83a09 Let's hope the wiki actions works this time
Update navigation
2020-07-28 18:52:11 +02:00
Andre_601
c28eab1697 Update Home.md navigation 2020-07-28 18:51:48 +02:00
Andre_601
7a322e0bb8 Update sidebar navigation 2020-07-28 18:50:17 +02:00
Andre_601
731e177859 Use short actions e-mail 2020-07-28 18:03:40 +02:00
Andre_601
1beb2ef3da Use Personal/Private Access Token 2020-07-28 17:58:41 +02:00
Andre_601
5047b0cdee Add Wiki update action (#373)
* First step to make automated wiki action

* Add wiki folder and files

* Only trigger on master branch

* Add dump command

* Update Plugins-using-PlaceholderAPI.md

* Create README.md

* Update README.md

* Ignore the readme file

* Update files from wiki

* Update wiki pages
2020-07-28 11:07:41 -04:00
Andre_601
5cc65c880a Move links down in the templates (#379)
* Move links down in the templates

* Add wiki option to PR template
2020-07-28 11:07:08 -04:00
Sxtanna
b73a6916cb updated classes with contract annotations 2020-07-27 11:40:58 -04:00
Sxtanna
134086f6a9 updated fileutil to load *vomit* all classes, closes #381 2020-07-27 11:39:11 -04:00
PiggyPiglet
1993b2cd82 replaced single quote from merge with double quote 2020-07-27 15:23:32 +08:00
PiggyPiglet
9291184534 Merge remote-tracking branch 'origin/master' 2020-07-27 15:23:11 +08:00
PiggyPiglet
6d502db694 Licensed all files
Added licensing plugin
2020-07-27 15:21:35 +08:00
Sxtanna
f61b6acfa8 updated placeholderexpansion to define its own unregister method 2020-07-26 23:01:12 -04:00
Sxtanna
8360511c50 rewrote discovery and registration code to be composable and higher level 2020-07-26 21:02:55 -04:00
Sxtanna
ee33de5ec8 removed final from deprecated methods, restored fallback for getRequiredPlugin 2020-07-26 21:01:12 -04:00
Sxtanna
a160f3abc9 updated to further phase out PlaceholderHook, added contracts to expansion methods 2020-07-26 18:46:00 -04:00
Sxtanna
b63f10f749 lets pretend no one saw this. 2020-07-26 18:36:50 -04:00
Sxtanna
86002f50e6 updated to phase out PlaceholderHook 2020-07-26 18:03:31 -04:00
Sxtanna
c3e0c1fb64 updated gson 2.8.5 -> 2.8.6 2020-07-26 17:32:28 -04:00
Sxtanna
b464590491 added dump command, closes #366 2020-07-26 16:26:42 -04:00
Sxtanna
65f04ba70e updated cloud expansion list to be sorted via a configuration option of values [name, author, latest]. closes #363 2020-07-26 13:39:33 -04:00
Andre_601
a7a4b46821 Merge pull request #328 from Andre601/patch-2
Added "Installed expansions" section
2020-07-26 13:12:06 +02:00
Sxtanna
07cd344123 updated local expansion to not catch potential linkage errors, and report them. closes #377 2020-07-25 23:57:19 -04:00
Sxtanna
30ead2ae4b fixed spacing 2020-07-25 23:54:09 -04:00
Sxtanna
9339192f88 updated ecloud list command to use new table utility, added message for when no expansions can be listed 2020-07-25 22:38:41 -04:00
Sxtanna
6eb1ecc212 Implemented general purpose table utility 2020-07-25 22:35:56 -04:00
Sxtanna
973484066a updated ecloud list command to not paginate by default in console, closes #375 2020-07-25 14:57:10 -04:00
Sxtanna
f177da8ef7 updated parse tab completer to consider the "cmdparse" alias 2020-07-25 13:08:26 -04:00
Sxtanna
d1b50c3db4 updated parse tab completer to call method inversely 2020-07-25 13:07:59 -04:00
Sxtanna
fb7a3ec99d added tab completion to the update command 2020-07-25 12:55:44 -04:00
Sxtanna
6caed4c23c updated plugin.yml to include permission for update command 2020-07-25 12:55:44 -04:00
Sxtanna
f7c2e72c1e added ecloud update command 2020-07-25 12:55:44 -04:00
Sxtanna
85b9fc36da updated local manager to allow for reregistering expansions 2020-07-25 12:55:44 -04:00
Sxtanna
5861f9fe6a updated register command to attempt registration on the main thread. (event bullshit I think) 2020-07-25 12:02:34 -04:00
Sxtanna
b6ec478dd6 updated ecloud list command to print to console in a table format. 2020-07-25 10:24:19 -04:00
Sxtanna
89061e6437 fixed ordering of methods 2020-07-24 19:45:28 -04:00
Sxtanna
50cee40531 updated LocalExpansionManager to accept a command sender to notify of load completion details 2020-07-24 19:02:17 -04:00
Sxtanna
00ced0495d I don't know how this happened, please don't flame me. ty. 2020-07-24 18:51:19 -04:00
Sxtanna
4e37f9f52a Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/main/java/me/clip/placeholderapi/expansion/manager/CloudExpansionManager.java
2020-07-24 18:51:07 -04:00
Sxtanna
e57a0600f1 Managers Update (#368)
* added google codestyle plugin

* updated managers to make more sense, removed old

* updated cloud expansion manager to cache with index name
2020-07-24 18:49:18 -04:00
Sxtanna
f4466059ac Merge branch 'master' into managers 2020-07-24 15:54:00 -04:00
Sxtanna
dd183b4031 Merge remote-tracking branch 'origin/master' 2020-07-24 14:47:46 -04:00
Sxtanna
5ef360e3fe updated build.gradle formatting, and added missing values 2020-07-24 14:47:30 -04:00
Andre_601
ffe7680795 Fix missing line break in expansion list command. 2020-07-24 14:40:58 -04:00
Sxtanna
cbbb2f27e4 Merge branch 'master' into managers
# Conflicts:
#	build.gradle
#	src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionList.java
#	src/main/java/me/clip/placeholderapi/expansion/cloud/ExpansionCloudManager.java
2020-07-24 14:34:54 -04:00
Sxtanna
f3ba9d588e updated managers to make more sense, removed old 2020-07-24 14:30:57 -04:00
extendedclip
623fd68ccc eCloud list outputs expansion information on a single line instead of multiple. Fixes #367 2020-07-24 12:40:07 -04:00
Glare
5fec3b53d0 Merge pull request #365 from PlaceholderAPI/fix-gradle-resolve 2020-07-24 10:49:32 -05:00
darbyjack
ffe2bb28ba Fix gradle resolve 2020-07-24 10:48:37 -05:00
Sxtanna
651de80a01 updated expansion list command to send messages using json 2020-07-24 11:04:12 -04:00
Sxtanna
4c586d1803 updated cloud manager to not be weird 2020-07-24 11:04:12 -04:00
Sxtanna
60a74258ec added google codestyle plugin 2020-07-24 08:26:20 -04:00
PiggyPiglet
7d091f3cf4 Merge pull request #361 from PlaceholderAPI/casing
fixed ecloud casing
2020-07-24 17:54:42 +08:00
PiggyPiglet
34a0bff760 removed apostrophe, apparently that particular rule doesn't apply to "its". 2020-07-24 17:37:33 +08:00
PiggyPiglet
51abc00e51 added a missing apostrophe 2020-07-24 17:35:21 +08:00
PiggyPiglet
3429d69f9d Fixed more casings 2020-07-24 17:32:39 +08:00
PiggyPiglet
79b8dd73a5 Fixed missed casings 2020-07-24 17:25:34 +08:00
Sxtanna
fccf0d5bb8 fixed ecloud casing 2020-07-24 05:21:43 -04:00
PiggyPiglet
e0e02f38b6 convert gstring to string 2020-07-24 16:32:18 +08:00
PiggyPiglet
d1bc2f598f fixed build number 2020-07-24 16:27:11 +08:00
PiggyPiglet
9d38d9b1a0 Merge pull request #359 from PlaceholderAPI/gradle
Gradle
2020-07-24 15:51:18 +08:00
PiggyPiglet
8b3f37b61e Merge branch 'master' into gradle 2020-07-24 15:50:17 +08:00
Sxtanna
6fade3fb93 removed obsolete EZPlaceholderHook 2020-07-24 01:39:17 -04:00
Sxtanna
b7d1c6969e Commands rewrite (#357)
* began rewriting command system

* began rewriting command system

* updated formatting

* added new info command

* added new reload command

* updated new parse command to support all three parsing types

* added new commands to command router

* deleted old unused commands

* removed parserel

* added new expansion register and unregister commands

* deleted unused commands

* fixed annotation order

* added labels helper to command

* updated alias method to return an immutable view

* updated params param with unmodifiable annotation

* updated router to build an immutable map of the commands

* began rewriting command system

* updated formatting

* added new info command

* added new reload command

* updated new parse command to support all three parsing types

* added new commands to command router

* deleted old unused commands

* removed parserel

* added new expansion register and unregister commands

* deleted unused commands

* fixed annotation order

* added labels helper to command

* updated alias method to return an immutable view

* updated params param with unmodifiable annotation

* updated router to build an immutable map of the commands

* updated plugin class to use new command router

* updated switch to break on parse match

* updated register completions to suggest file names

* updated router to allow entering labels in any case

* updated parse command to send message to players as components

* added command dispatching parsing

* moved new commands into local package

* added helper functions for filtering and suggesting

* updated imports, updated tab completion to use helper functions

* added start of ecloud commands

* replace ecloud enable and disable commands with single toggle command evaluator

* deleted unused commands

* updated commands to use helper functions for suggesting

* updated downloading to use completablefuture, updated all methods to use streams exclusively

* updated to use the config instead of a null check

* deleted old commands system

* finished new command system

* updated to use new method from cloud manager

* fixed annotation ordering and added missing annotations

* updated ecloud subcommands to have a more specific permission

* updated plugin.yml with the new permissions, (and also fixed its formatting)

* fixed annotations intellij missed

* this should probably be there...
2020-07-24 01:29:11 -04:00
Sxtanna
21ca434e72 added unit test for hex code escaping 2020-07-23 12:02:04 -04:00
Sxtanna
d63d7dc5f8 updated char replacer to support hex colors, and escaping &x 2020-07-22 23:59:39 -04:00
Sxtanna
f47eef7442 updated plugin class to be less painful to look at, 2020-07-22 20:42:53 -04:00
Sxtanna
9631b087b3 updated server load listener to be final, and to automatically unregister itself when done 2020-07-22 20:41:27 -04:00
Sxtanna
d7b947ddad finalized config, added nullability annotations 2020-07-22 20:40:47 -04:00
Sxtanna
656f9ad03c updated expansion manager to actually... manage expansions 2020-07-22 20:40:15 -04:00
Sxtanna
0a4150d63e updated fileutil to ignore NCDFEs, and to print exceptions 2020-07-21 16:04:24 -04:00
Sxtanna
377d091ae2 added back deprecated online player method 2020-07-21 12:25:38 -04:00
Sxtanna
bdf8a1bcc1 reformatted event classes, added nullability annotations, made classes final. 2020-07-21 11:56:57 -04:00
Sxtanna
ee78fc1775 updated char replacer to better handle malformed input 2020-07-21 01:48:59 -04:00
Sxtanna
9ddb21220f updated shadow, added test dependencies for jmh and junit 2020-07-20 20:13:32 -04:00
Sxtanna
47e336c1fe Merge branch 'master' into gradle
# Conflicts:
#	pom.xml
2020-07-20 20:07:38 -04:00
Sxtanna
a2a736d909 undeprecated bracket placeholder methods, 2020-07-20 19:50:36 -04:00
Sxtanna
9217147827 Merge pull request #355 from Andre601/patch-3
Add missing @deprecated notes to methods
2020-07-20 19:26:56 -04:00
Andre_601
53736888a5 grammar 2020-07-21 01:26:21 +02:00
Andre601
75004f08d0 Add deprecation notice to all methods
Was it so hard to do a Ctrl+C, Ctrl+V?
2020-07-21 01:20:26 +02:00
Andre_601
51f61f61af Add missing deprecation notices. 2020-07-21 01:06:37 +02:00
Sxtanna
e7ce84e7fc cleaned up fileutil and expansion manager 2020-07-20 18:55:37 -04:00
Sxtanna
42992de312 updated with null contracts, immutability, and early returns. 2020-07-20 18:22:08 -04:00
Sxtanna
45b3ebfbc2 updated to use new char replacer, deprecated all older functions, defined null contracts, and immutability. 2020-07-20 18:16:46 -04:00
Sxtanna
3b3892e7d6 updated placeholder hook to define immutability and null contracts, deprecated online player function 2020-07-20 18:14:13 -04:00
Sxtanna
9060ea6bd3 updated to use new closure 2020-07-20 17:38:18 -04:00
extendedclip
49012dc6b2 here 2020-07-20 17:23:27 -04:00
Sxtanna
9d73893cc8 replacer api, unit tests, and benchmarks (#354)
* added abstracted replacer api, and both char and regex based implementations

* added test dependencies for jmh and junit

* added unit tests and benchmarks for the replacer implementations

* updated replacers to accept specific closure types, added test to verify malformed placeholder handling

* updated jmh to 1.23, updated junit to 5.6.2
2020-07-20 16:59:25 -04:00
extendedclip
4ce0b03852 Revert "Performance Improvements (#340)"
This reverts commit 54d5757d
2020-07-20 16:57:16 -04:00
Glare
8972f7cff4 Merge pull request #352 from Sxtanna/master
POM fixes.
2020-07-19 15:22:24 -05:00
Sxtanna
d2223f83b8 removed server dependency, added provided dependency for log4j-core 2020-07-19 09:16:09 -04:00
Sxtanna
b4d6b047af moved compiler source and target to properties 2020-07-19 09:12:58 -04:00
Crypto Morin
54d5757d0a Performance Improvements (#340)
* Performance Improvements

* More Optimizations

* Even More Optimizations & Cleanups

* Almost a recode I guess
2020-07-16 12:32:22 -04:00
PiggyPiglet
ca8fb3117f fixed resource processing variables 2020-07-15 01:00:01 +08:00
PiggyPiglet
bc0535e2f4 Converted to gradle 2020-07-15 00:56:49 +08:00
extendedclip
f9f59f1f96 Merge the multiple static blocks 2020-07-14 10:24:01 -04:00
extendedclip
f205146c75 Rename ecloud commands to be prefixed with Ecloud to avoid confusion 2020-07-14 10:21:29 -04:00
darbyjack
0634a9cd9b Switch back to the official JSONMessages 2020-07-14 08:18:06 -05:00
Frcsty
3e396a97b0 Changed command system (#304)
* Save Cacheable expansions data on shutdown

* Prepare for 1.16

* 1.16.1 is out apparently

* Further fixes, still not done

* Inline JSONMessages & fix for 1.16

* Done :O

* Done for real now, (hopefully)

* Changed to static instead of DI for plugin instance

* Cleanup

* Modified tab completions. Removed extra command.

* Apparently this is needed

* Started cleaning stuff up

basically just pushing so I can continue on laptop

* did more cleaning, probs like half way done

* more cleaning. reverted back to a min arg system somewhat similar to what frosty had, but less boilerplate.

* Started debugging and fixing runtime/compile errors

* Fixed bugs, still needs thorough testing

* Re-enable metrics

* relocated stuff again

* - Remove json message relocation
- uncomment other relocations
- reformat pom
- remove useless scope declaration
- Fix metrics constructor
- Switch commands to use inline json message

Co-authored-by: iGabyTM <contactgabytm@gmail.com>
Co-authored-by: darbyjack <admin@glaremasters.me>
Co-authored-by: PiggyPiglet <noreply@piggypiglet.me>
2020-07-13 15:27:59 -04:00
Andre_601
9316636939 Added "Installed expansions" section 2020-06-13 18:16:42 +02:00
extendedclip
82fa8d7393 Added 1.15 2020-05-02 23:16:46 -04:00
extendedclip
83abb8b728 Bump to 2.10.7 dev 2020-05-02 23:16:03 -04:00
extendedclip
feed418ccf 2.10.6 release 2020-05-02 22:52:18 -04:00
Glare
a2868cbc4f Merge pull request #294 from PlaceholderAPI/fixes/first-time-parse
Fixes the super old issue of not being able to parse on first join
2020-04-26 12:19:09 -05:00
darbyjack
43d134cbe3 Fixes the super old issue of not being able to parse on first join 2020-04-25 21:57:40 -05:00
Ryan
e023c4e789 Fixed Discord URL 2020-04-09 11:45:35 -04:00
aBooDyy
784d7dd273 Fixes ecloud placeholders command (#201)
* fix parsing placeholders on ecloud placeholders command

* try catch on registering expansions

Co-authored-by: aBo0oDyy <35378106+aBo0oDyy@users.noreply.github.com>
2020-04-09 11:43:21 -04:00
Andre_601
d26561eaeb Add issue template config for custom template selection (#272)
* Fix typos

* Update change_request_placeholderapi.md

* Slighty better grammar

* Create config.yml

* Add about part

* Make wiki point to PAPI wiki
2020-04-09 11:38:14 -04:00
WCKDAWE
0666ac7b01 Minor spelling mistakes (#284)
Not a grammar nazi, just noticed them and though to commit dem changes.
2020-04-09 11:37:48 -04:00
Andre_601
2caf5f0232 Add missing setPlaceholder methods (#234)
* Add missing setPlaceholder methods
Also includes setBracketPlaceholders and setRelationPlaceholders

* Update PlaceholderAPI.java
2020-04-09 11:37:06 -04:00
Glare
d706469ed8 Ahem. Let's flex. 2020-04-03 10:44:12 -05:00
darbyjack
5d4decafbe Bump to 2.10.6 dev 2020-03-25 23:28:48 -05:00
darbyjack
bb639328a3 Push to 2.10.5 for release pt2 2020-03-25 23:27:56 -05:00
darbyjack
ca0791f3af Push to 2.10.5 for release 2020-03-25 23:05:12 -05:00
darbyjack
449c927c6c Add user-friendly message when host can't connect to ecloud 2020-03-25 23:04:00 -05:00
darbyjack
e95f1b4850 Removed extra semi 2020-03-25 22:54:26 -05:00
Glare
06513c89bc Merge pull request #268 from PiggyPiglet/master
covered up string's size insecurities with a fat bufferedreader
2020-03-25 21:42:43 -06:00
PiggyPiglet
38d9185232 made it compile 2020-03-26 11:25:02 +08:00
PiggyPiglet
35738f59d9 covered up string's size insecurities with a fat bufferedreader 2020-03-26 11:15:16 +08:00
darbyjack
66758b1992 Compile under 1.15.2 2020-02-03 12:18:57 -06:00
extendedclip
c1cff8ca74 javadoc 2020-01-06 14:29:07 -05:00
extendedclip
2dbf69a74e Allows the setPlaceholders method to specify if color codes should be translated in the output string 2020-01-06 14:27:39 -05:00
darbyjack
6c964baba7 Added support for 1.15.1 2019-12-21 13:56:07 -06:00
darbyjack
4b77eb5d00 Added support for 1.15 2019-12-10 17:49:49 -06:00
darbyjack
6e68929a5c Updated gitignore to ignore IDEA files. 2019-12-10 17:16:28 -06:00
darbyjack
fc263d9ce7 Updated bStats repo version. 2019-12-10 17:15:39 -06:00
Max Berkelmans
ab9716489b Merge pull request #131 from Draycia/master
Formatting, spacing, final modifiers, and a few code fixes
2019-10-16 22:29:38 +02:00
Max Berkelmans
5c6202a8ee Merge branch 'master' into master 2019-10-16 22:28:19 +02:00
extendedclip
38c1eca590 Bump version to 2.10.5 development 2019-09-19 14:38:33 -04:00
extendedclip
a1a1b1afd7 Bump version to 2.10.4 for release 2019-09-19 14:26:35 -04:00
extendedclip
51599c4044 Allow cancelling expansion registration 2019-09-19 14:22:08 -04:00
extendedclip
9871efbadb Allow cancelling expansion registration 2019-09-19 14:16:35 -04:00
Evan Lindsay
6b9f22c7ec Fix case check in PlaceholderExpansion.isRegistered (#161) 2019-08-04 18:03:25 -04:00
aBooDyy
7c54e58ab7 Merge pull request #151 from Andre601/patch-1
Fixing broken link
2019-07-23 19:49:13 +03:00
Andre_601
024d9b281a Fixing broken link 2019-07-23 17:19:20 +02:00
Leomixer17
6c5cd0ed1f Update plugin.yml (#142)
1.13 set as api version won’t cause issues. I reverted adding 1.14 but we can merge this as it won’t have any conflicts. Thanks for the contribution.
2019-07-12 18:33:35 -04:00
Josh (Vicarious)
719172c185 Merge branch 'master' into master 2019-06-30 21:40:51 -07:00
darbyjack
763bb52d06 Changed some logic to suggest the right command. 2019-06-28 12:14:30 -05:00
darbyjack
d0d0c99505 Added message saying to reload papi to enable downloaded expansion. 2019-06-28 12:14:07 -05:00
darbyjack
16726215bb Updated to dev, fixed spigot version. 2019-06-28 12:13:34 -05:00
Ryan
454b1f19f4 Update README.md
Updated stats
2019-06-25 15:01:08 -04:00
darbyjack
6286451991 Push to 1.14.3-SNAPSHOT. 2019-06-25 05:39:52 -05:00
extendedclip
b9881eb70b Fix page indexes when on pages greater than 1 2019-06-21 12:49:45 -04:00
extendedclip
93f586a216 Update to 2.10.3 2019-06-21 12:36:59 -04:00
extendedclip
a0ac08b838 Start at 1 2019-06-21 12:36:03 -04:00
extendedclip
2c0b768774 ITS 2019 2019-06-21 12:30:32 -04:00
Glare
21048f83d5 Issue templates update (#128)
Issue templates update
2019-06-11 11:12:32 -05:00
Draycia
5b92dd5553 Shorten line in FileUtil 2019-06-10 11:22:05 -07:00
Draycia
4851655110 Make various things final 2019-06-10 11:10:39 -07:00
Draycia
64a6389ebf Better use of StringBuilder 2019-06-10 11:10:14 -07:00
Draycia
4860e3f8bf Remove unused casts 2019-06-10 11:04:01 -07:00
Draycia
dfbf1b95f6 Cleanup formatting / spacing 2019-06-10 11:03:48 -07:00
Andre_601
9af9a3570d Update CONTRIBUTING.md 2019-06-02 20:07:40 +02:00
Andre_601
16c237ce51 Update CONTRIBUTING.md 2019-06-02 20:06:56 +02:00
Andre_601
b44cb13d7a Create CONTRIBUTING.md 2019-06-02 19:56:33 +02:00
Andre_601
8c509b47d1 Create PULL_REQUEST_TEMPLATE.md 2019-06-02 19:54:17 +02:00
Andre_601
c4cba9c6a7 Update bug_report.md 2019-06-02 19:37:57 +02:00
Andre_601
0809897303 Update and rename feature_request.md to change_request_placeholderapi.md 2019-06-02 19:30:12 +02:00
Andre_601
82181ed74d Update and rename change_request.md to change_request_wiki.md 2019-06-02 19:20:27 +02:00
Andre_601
85328c473b Improve the feature_request 2019-06-02 19:01:11 +02:00
darbyjack
c9abc4ae00 Updated to 1.14.1 2019-05-13 21:36:33 -05:00
extendedclip
5f23db98a8 Set version to dev builds 2019-05-10 20:37:49 -04:00
extendedclip
f367abbdfa Check if config values aren't null before attempting to set them. 2019-05-10 20:36:43 -04:00
95 changed files with 13113 additions and 3317 deletions

64
.github/CONTRIBUTING.md vendored Normal file
View File

@@ -0,0 +1,64 @@
[issue]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request_placeholderapi.md
[Discord]: https://helpch.at/discord
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
# 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.
Please note we have a code of conduct, please follow it in all your interactions with the project.
## Pull Request Process
1. Update the README.md with details of changes if it is affected by those changes.
2. Try to prevent any breaking changes affecting the end-user (Developers using the API).
Mention any breaking changes that could affect the end-user.
3. Document any public methods that the end-user might use.
## Code of Conduct
### Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
### Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
### Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
### Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
### Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at our [Discord]. All
complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
### Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

View File

@@ -1,38 +1,48 @@
---
name: Bug Report
about: Found a bug with PlaceholderAPI? Report it through this form!
about: Report bugs of PlaceholderAPI with this template
---
[New placeholders/plugin]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=feature_request.md
[Request change]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request.md
[Spigot page]: https://www.spigotmc.org/resources/6245/
[Jenkins page]: http://ci.extendedclip.com/job/PlaceholderAPI/
[issue]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues
## 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.
### Notes
This template is for **reporting a bug** and not for requesting changes to the wiki!
If you want your placeholders added or updated, use the [New placeholders/plugin] or [Request change] 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.
Also make sure, that you use the latest version of PlaceholderAPI from either the [Spigot page] or the [Jenkins page] and that your
issue isn't already listed in the [issue] 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 type below this like -->
<!-- Please write below this line to prevent formatting issues -->
### Expected behaviour
> What should PlaceholderAPI do?
<!-- Please type below this like -->
<!-- Please write below this line to prevent formatting issues -->
### Actual behaviour
> What does PlaceholderAPI actually do?
<!-- Please type below this like -->
<!-- Please write below this line to prevent formatting issues -->
### How to reproduce
> What steps did you made, to get this bug?
<!-- Please type below this like -->
<!-- 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

View File

@@ -1,36 +0,0 @@
---
name: Request change
about: Request a update/change of a wiki-page
---
[New placeholders/plugin]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=feature_request.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
### Notes
This template is for **requesting changes to the wiki** and not for reporting bugs or requesting additions for the wiki!
If you want your placeholders added, use the [New placeholders/plugin] template.
For bug reports, use the [Bug report] template.
Also make sure, that your requested change isn't already made in the [wiki] or listed in the [issues] page.
### Type
> What kind of change is it? (Multiple selections possible)
<!-- Please select the right one, by changing the [ ] to [x] -->
- [ ] Placeholder(s) changed.
- [ ] New placeholder(s).
- [ ] Plugin no longer supports PlaceholderAPI and/or was deleted.
### Plugin
> What is the name of the plugin?
<!-- Please type below this line -->
### What is the new value?
> **Placeholder(s) changed**: Type what the old and the new placeholder(s) is/are.
> **New Placeholder(s)**: Type the new placeholder(s).
> **Plugin no longer supports PlaceholderAPI**: Leave this blank.
<!-- Please type below this line -->

View File

@@ -0,0 +1,42 @@
---
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

View File

@@ -0,0 +1,38 @@
---
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

11
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: HelpChat Discord
url: https://discordapp.com/invite/0utOOIYX82aImw7h
about: Please join our Discord for faster support.
- name: Wiki
url: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
about: The Wiki of PlaceholderAPI.
- name: Hastebin
url: https://paste.helpch.at
about: Use our Hastebin-site for sharing errors and configuration files.

View File

@@ -1,35 +0,0 @@
---
name: New placeholders/plugin
about: Do you have a plugin that supports and/or adds placeholders from/to PlaceholderAPI and that isn't on the wiki? Use this template!
---
[Request change]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request.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
### Notes
This template is for **requesting additions for the wiki** and not for reporting bugs or requesting changes for the wiki!
If you want changes to be made to the wiki, use the [Request change] template.
For bug reports, use the [Bug report] template.
Also make sure, that your requested placeholders/plugin isn't already added in the [wiki] or listed in the [issues] page.
### Type
> What kind of request is this? (Multiple selections possible)
<!-- Select the right option by replacing [ ] with [x] -->
<!-- For an update of an already listed plugin, use the "Request change" template -->
- [ ] New expansion providing placeholders.
- [ ] New plugin providing placeholders.
- [ ] New plugin supporting PlaceholderAPI.
### Plugin
> What is the name of the plugin/expansion?
> Provide also a link to it.
<!-- Please type below this line -->
### Placeholders/others
> What are the new placeholders/Any additional info?
<!-- Please type below this line -->

25
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,25 @@
## Please read
Please make sure you checked the following:
- You checked the [Pull requests] page for any upcoming changes.
- You documented any public code that the end-user might use.
- You followed the [contributing file]
### Type
<!--
Please select the right one, by changing the [ ] to [x]
-->
- [ ] Internal change (Doesn't affect end-user).
- [ ] External change (Does affect end-user).
- [ ] Wiki (Changes towards the [Wiki]).
- [ ] Other: __________ <!-- Use this if none of the above matches your request -->
### Description
> Provide additional information if needed.
<!-- Please type 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

49
.github/workflows/wiki.yml vendored Normal file
View File

@@ -0,0 +1,49 @@
#
# This is a GitHub Action that allows us to auto-update the wiki
# when a Pull request changes specific files in a folder.
#
name: Update Wiki
on:
push:
#
# Only trigger when the push changes any files in the wiki-folder.
#
paths:
- 'wiki/**'
branches:
- 'master'
#
# Releases cause this action to also fire.
# Using this prevents this problem.
#
tags-ignore:
- '**'
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Code'
uses: actions/Checkout@v2
- name: 'Update Wiki'
uses: docker://decathlon/wiki-page-creator-action:latest
env:
#
# We can use the E-Mail and Name of the GitHub Actions account
# for our convenience.
#
ACTION_MAIL: 'actions@github.com'
ACTION_NAME: 'github-actions[bot]'
GH_PAT: '${{ secrets.WORKFLOWPAT }}'
OWNER: 'PlaceholderAPI'
REPO_NAME: 'PlaceholderAPI'
#
# We only want to target files in the wiki folder
#
MD_FOLDER: 'wiki'
WIKI_PUSH_MESSAGE: 'Updating wiki from commit ${{ github.event.after }}'
#
# We skip/ignore the README.md file in the Wiki folder
#
SKIP_MD: README.md

150
.gitignore vendored
View File

@@ -1,146 +1,6 @@
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Eclipse Patch ###
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Ruby plugin and RubyMine
/.rakeTasks
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
*.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
### NetBeans ###
nbproject/private/
.idea/
.gradle/
server/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
nbactions.xml
out/
*.iml

View File

@@ -25,9 +25,9 @@
# Information
[PlaceholderAPI][spigot] is a plugin for Spigot servers that allows server owners to display information from various plugins with a uniform format.
Support for specific plugins are provided either by the plugin itself or through expansions. The expansions may be downloaded in-game through the PAPI Expansion Cloud. There are currently over 100 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 100,000 times and has been used concurrently on over 10,000 servers, which makes it a must-have for a server of any type or scale.
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.
<!-- TODO: Add contributing section -->
<!-- TODO: Add expansion creation section (possibly add to a wiki?) -->

106
build.gradle Normal file
View File

@@ -0,0 +1,106 @@
plugins {
id "java"
id "maven-publish"
id "net.minecrell.licenser" version "0.4.1"
id "com.github.johnrengelman.shadow" version "6.0.0"
}
group "me.clip"
version "2.10.7"
description "An awesome placeholder provider!"
repositories {
mavenCentral()
maven({ url = "https://rayzr.dev/repo/" })
maven({ url = "https://repo.codemc.org/repository/maven-public" })
maven({ url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" })
}
dependencies {
implementation "com.google.code.gson:gson:2.8.6"
implementation "org.bstats:bstats-bukkit:1.5"
implementation "me.rayzr522:jsonmessage:1.2.1"
compileOnly "org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT"
compileOnly "org.jetbrains:annotations:19.0.0"
testImplementation "org.openjdk.jmh:jmh-core:1.23"
testImplementation "org.openjdk.jmh:jmh-generator-annprocess:1.23"
testCompile "org.junit.jupiter:junit-jupiter-engine:5.6.2"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.6.2"
}
import org.apache.tools.ant.filters.ReplaceTokens
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [
name: rootProject.name,
version: project.version.toString(),
description: project.description
]
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
shadowJar {
archiveClassifier.set("")
relocate "org.bstats", "me.clip.placeholderapi.metrics"
relocate "com.google.gson", "me.clip.placeholderapi.libs.gson"
relocate "me.rayzr522.jsonmessage", "me.clip.placeholderapi.libs.jsonmessage"
}
license {
header = file("headers/header.txt")
ext {
year = 2020
}
include "**/*.java"
}
test {
useJUnitPlatform()
}
sourceSets {
test.compileClasspath += configurations.compileOnly
test.runtimeClasspath += configurations.compileOnly
}
publishing {
repositories {
maven {
if (version.contains("-DEV-")) {
url = uri("https://repo.extendedclip.com/content/repositories/dev/")
} else {
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}
credentials {
username = System.getenv("JENKINS_USER")
password = System.getenv("JENKINS_PASS")
}
}
}
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
publish.dependsOn clean, test, jar

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,6 @@
#Tue Jul 14 23:27:02 AWST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

185
gradlew vendored Normal file
View File

@@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

104
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,104 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

17
headers/header.txt Normal file
View File

@@ -0,0 +1,17 @@
This file is part of PlaceholderAPI
PlaceholderAPI
Copyright (c) 2015 - ${year} PlaceholderAPI Team
PlaceholderAPI free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PlaceholderAPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

119
pom.xml
View File

@@ -1,119 +0,0 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.2</version>
<name>PlaceholderAPI</name>
<description>An awesome placeholder provider!</description>
<url>http://extendedclip.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>bstats-repo</id>
<url>http://repo.bstats.org/content/repositories/releases/</url>
</repository>
<repository>
<id>rayzr-repo</id>
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.rayzr522</groupId>
<artifactId>jsonmessage</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<finalName>${project.name}-${project.version}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>me.clip.placeholderapi.metrics</shadedPattern>
</relocation>
<relocation>
<pattern>me.rayzr522</pattern>
<shadedPattern>me.clip.placeholderapi.util</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.code.gson</pattern>
<shadedPattern>me.clip.placeholderapi.libs.gson</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>

1
settings.gradle Normal file
View File

@@ -0,0 +1 @@
rootProject.name = 'PlaceholderAPI'

View File

@@ -1,30 +1,38 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package me.clip.placeholderapi;
import static me.clip.placeholderapi.util.Msg.color;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.HashMap;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.Relational;
import me.clip.placeholderapi.replacer.CharsReplacer;
import me.clip.placeholderapi.replacer.Replacer;
import me.clip.placeholderapi.replacer.Replacer.Closure;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -32,215 +40,364 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import me.clip.placeholderapi.events.ExpansionRegisterEvent;
import me.clip.placeholderapi.events.ExpansionUnregisterEvent;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.Relational;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class PlaceholderAPI {
public final class PlaceholderAPI
{
private static final Replacer REPLACER_PERCENT = new CharsReplacer(Closure.PERCENT);
private static final Replacer REPLACER_BRACKET = new CharsReplacer(Closure.BRACKET);
@Deprecated
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
@Deprecated
private static final Pattern BRACKET_PLACEHOLDER_PATTERN = Pattern.compile("[{]([^{}]+)[}]");
@Deprecated
private static final Pattern RELATIONAL_PLACEHOLDER_PATTERN = Pattern.compile("[%](rel_)([^%]+)[%]");
private static final Map<String, PlaceholderHook> placeholders = new HashMap<>();
private PlaceholderAPI() {
private PlaceholderAPI()
{
}
// === Current API ===
/**
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
*
* @param player Player to parse the placeholders against
* @param text Text to set the placeholder values in
* @return String containing all translated placeholders
*/
@NotNull
public static String setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text)
{
return REPLACER_PERCENT.apply(text, player, PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()::getExpansion);
}
/**
* check if a specific placeholder identifier is currently registered
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
*
* @param identifier to check
* @param player Player to parse the placeholders against
* @param text List of Strings to set the placeholder values in
* @return String containing all translated placeholders
*/
@NotNull
public static List<String> setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<@NotNull String> text)
{
return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList());
}
/**
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
*
* @param player Player to parse the placeholders against
* @param text Text to set the placeholder values in
* @return String containing all translated placeholders
*/
@NotNull
public static String setBracketPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text)
{
return REPLACER_BRACKET.apply(text, player, PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()::getExpansion);
}
/**
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
*
* @param player Player to parse the placeholders against
* @param text List of Strings to set the placeholder values in
* @return String containing all translated placeholders
*/
@NotNull
public static List<String> setBracketPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<@NotNull String> text)
{
return text.stream().map(line -> setBracketPlaceholders(player, line)).collect(Collectors.toList());
}
/**
* Check if a specific placeholder identifier is currently registered
*
* @param identifier The identifier to check
* @return true if identifier is already registered
*/
public static boolean isRegistered(String identifier) {
return getRegisteredIdentifiers().stream().filter(id -> id.equalsIgnoreCase(identifier))
.findFirst().orElse(null) != null;
public static boolean isRegistered(@NotNull final String identifier)
{
return PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByIdentifier(identifier).isPresent();
}
/**
* Register a new placeholder hook
*
* @param identifier Identifier of the placeholder -> "%(identifier)_(args...)%
* @param placeholderHook implementing class that contains the onPlaceholderRequest method which
* is called when a value is needed for the specific placeholder
* @return true if the hook was successfully registered, false if there is already a hook
* registered for the specified identifier
*/
public static boolean registerPlaceholderHook(String identifier,
PlaceholderHook placeholderHook) {
Validate.notNull(identifier, "Identifier can not be null");
Validate.notNull(placeholderHook, "Placeholderhook can not be null");
if (isRegistered(identifier)) {
return false;
}
placeholders.put(identifier.toLowerCase(), placeholderHook);
return true;
}
/**
* unregister a placeholder hook by identifier
*
* @param identifier the identifier for the placeholder hook to unregister
* @return true if the placeholder hook was successfully unregistered, false if there was no
* placeholder hook registered for the identifier specified
*/
public static boolean unregisterPlaceholderHook(String identifier) {
Validate.notNull(identifier, "Identifier can not be null");
return placeholders.remove(identifier.toLowerCase()) != null;
}
/**
* Get all registered placeholder identifiers
*
* @return all registered placeholder identifiers
* @return All registered placeholder identifiers
*/
public static Set<String> getRegisteredIdentifiers() {
return ImmutableSet.copyOf(placeholders.keySet());
@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
* @return Copy of the internal placeholder map
*/
public static Map<String, PlaceholderHook> getPlaceholders() {
return ImmutableMap.copyOf(placeholders);
@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)");
}
public static Set<PlaceholderExpansion> getExpansions() {
/**
* 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
* 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.
*/
public static boolean containsPlaceholders(String text) {
@Deprecated
public static boolean containsPlaceholders(String text)
{
return text != null && PLACEHOLDER_PATTERN.matcher(text).find();
}
/**
* check if a String contains any PlaceholderAPI bracket placeholders
* 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.
*/
public static boolean containsBracketPlaceholders(String text) {
@Deprecated
public static boolean containsBracketPlaceholders(String text)
{
return text != null && BRACKET_PLACEHOLDER_PATTERN.matcher(text).find();
}
/**
* set placeholders in the list<String> text provided placeholders are matched with the pattern
* {<placeholder>} when set with this method
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
*
* @param p Player to parse the placeholders for
* @param text text to set the placeholder values in
* @return modified list with all placeholders set to the corresponding values
* @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.
*/
public static List<String> setBracketPlaceholders(OfflinePlayer p, List<String> text) {
return setPlaceholders(p, text, BRACKET_PLACEHOLDER_PATTERN);
@Deprecated
public static List<String> setBracketPlaceholders(OfflinePlayer player, List<String> text, boolean colorize)
{
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
}
/**
* set placeholders in the list<String> text provided placeholders are matched with the pattern
* %(identifier)_(params)>% when set with this method
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
*
* @param p Player to parse the placeholders for
* @param text text to parse the placeholder values in
* @return modified list with all placeholders set to the corresponding values
* @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.
*/
public static List<String> setPlaceholders(OfflinePlayer p, List<String> text) {
return setPlaceholders(p, text, PLACEHOLDER_PATTERN);
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text, boolean colorize)
{
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
}
/**
* Translates all placeholders into their corresponding values.
* <br>You set the pattern yourself through this method.
*
* @param player Player to parse the placeholders against
* @param text List of Strings to set the placeholder values in
* @param pattern The pattern to match placeholders to. Capture group 1 must contain an underscore separating the
* identifier from the params
* @return String containing all translated placeholders
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text, Pattern pattern)
{
return setPlaceholders(player, text, pattern, true);
}
/**
* set placeholders in the list<String> text provided placeholders are matched with the pattern
* %(identifier)_(params)>% when set with this method
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}
*
* @param p Player to parse the placeholders for
* @param text text to parse the placeholder values in
* @return modified list with all placeholders set to the corresponding values
* @param player Player to parse the placeholders against
* @param text Text to set the placeholder values in
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
* @return String containing all translated placeholders
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
*/
public static List<String> setPlaceholders(OfflinePlayer p, List<String> text, Pattern pattern) {
if (text == null) {
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setBracketPlaceholders(OfflinePlayer player, String text, boolean colorize)
{
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
}
/**
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal %<identifier>_<params>%}.
*
* @param player Player to parse the placeholder against
* @param text Text to parse the placeholders in
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
* @return The text containing the parsed placeholders
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setPlaceholders(OfflinePlayer player, String text, boolean colorize)
{
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
}
/**
* Translates all placeholders into their corresponding values.
* <br>You set the pattern yourself through this method.
*
* @param player Player to parse the placeholders against
* @param text Text to set the placeholder values in
* @param pattern The pattern to match placeholders to. Capture group 1 must contain an underscore separating the
* identifier from the params
* @return The text containing the parsed placeholders
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setPlaceholders(OfflinePlayer player, String text, Pattern pattern)
{
return setPlaceholders(player, text, pattern, true);
}
/**
* Translate placeholders in the provided List based on the relation of the two provided players.
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<param>%}.
*
* @param one Player to compare
* @param two Player to compare
* @param text text to parse the placeholder values to
* @return The text containing the parsed relational placeholders
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text)
{
return setRelationalPlaceholders(one, two, text, true);
}
/**
* Translate placeholders in the provided list based on the relation of the two provided players.
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<params>%}.
*
* @param one First player to compare
* @param two Second player to compare
* @param text Text to parse the placeholders in
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
* @return The text containing the parsed relational placeholders
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text, boolean colorize)
{
if (text == null)
{
return null;
}
return text.stream().map(line -> setPlaceholders(p, line, pattern))
return text.stream()
.map(line -> setRelationalPlaceholders(one, two, line, colorize))
.collect(Collectors.toList());
}
/**
* set placeholders in the text specified placeholders are matched with the pattern
* {<placeholder>} when set with this method
* set relational placeholders in the text specified placeholders are matched with the pattern
* %<rel_(identifier)_(params)>% when set with this method
*
* @param player Player to parse the placeholders for
* @param text text to parse the placeholder values to
* @return modified text with all placeholders set to the corresponding values
* @param one First player to compare
* @param two Second player to compare
* @param text Text to parse the placeholders in
* @return The text containing the parsed relational placeholders
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
*/
public static String setBracketPlaceholders(OfflinePlayer player, String text) {
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN);
}
/**
* set placeholders in the text specified placeholders are matched with the pattern
* %<(identifier)_(params)>% when set with this method
*
* @param player Player to parse the placeholders for
* @param text text to parse the placeholder values to
* @return text with all placeholders set to the corresponding values
*/
public static String setPlaceholders(OfflinePlayer player, String text) {
return setPlaceholders(player, text, PLACEHOLDER_PATTERN);
}
/**
* set placeholders in the text specified placeholders are matched with the pattern
* %<(identifier)_(params)>% when set with this method
*
* @param player Player to parse the placeholders for
* @param text text to parse the placeholder values to
* @param placeholderPattern the pattern to match placeholders to. Capture group 1 must contain an
* underscore separating the identifier from the params
* @return text with all placeholders set to the corresponding values
*/
public static String setPlaceholders(OfflinePlayer player, String text,
Pattern placeholderPattern) {
if (text == null) {
return null;
}
if (placeholders.isEmpty()) {
return color(text);
}
Matcher m = placeholderPattern.matcher(text);
Map<String, PlaceholderHook> hooks = getPlaceholders();
while (m.find()) {
String format = m.group(1);
int index = format.indexOf("_");
if (index <= 0 || index >= format.length()) {
continue;
}
String identifier = format.substring(0, index).toLowerCase();
String params = format.substring(index + 1);
if (hooks.containsKey(identifier)) {
String value = hooks.get(identifier).onRequest(player, params);
if (value != null) {
text = text.replaceAll(Pattern.quote(m.group()), Matcher.quoteReplacement(value));
}
}
}
return color(text);
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setRelationalPlaceholders(Player one, Player two, String text)
{
return setRelationalPlaceholders(one, two, text, true);
}
/**
@@ -249,143 +406,196 @@ public class PlaceholderAPI {
*
* @param one Player to compare
* @param two Player to compare
* @param text text to parse the placeholder values to
* @return text with all relational placeholders set to the corresponding values
* @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.
*/
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text) {
if (text == null) {
@Deprecated
@SuppressWarnings("DuplicatedCode")
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setRelationalPlaceholders(Player one, Player two, String text, boolean colorize)
{
if (text == null)
{
return null;
}
return text.stream().map(line -> setRelationalPlaceholders(one, two, line))
.collect(Collectors.toList());
}
/**
* set relational placeholders in the text specified placeholders are matched with the pattern
* %<rel_(identifier)_(params)>% when set with this method
*
* @param one Player to compare
* @param two Player to compare
* @param text text to parse the placeholder values to
* @return text with all relational placeholders set to the corresponding values
*/
public static String setRelationalPlaceholders(Player one, Player two, String text) {
if (text == null) {
return null;
if (PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().getExpansionsCount() == 0)
{
return colorize ? Msg.color(text) : text;
}
if (placeholders.isEmpty()) {
return color(text);
}
Matcher m = RELATIONAL_PLACEHOLDER_PATTERN.matcher(text);
Map<String, PlaceholderHook> hooks = getPlaceholders();
while (m.find()) {
String format = m.group(2);
int index = format.indexOf("_");
if (index <= 0 || index >= format.length()) {
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);
if (hooks.containsKey(identifier)) {
if (!(hooks.get(identifier) instanceof Relational)) {
final PlaceholderHook hook = hooks.get(identifier);
if (!(hook instanceof Relational))
{
continue;
}
Relational rel = (Relational) hooks.get(identifier);
String value = rel.onPlaceholderRequest(one, two, params);
if (value != null) {
text = text.replaceAll(Pattern.quote(m.group()), Matcher.quoteReplacement(value));
final String value = ((Relational) hook).onPlaceholderRequest(one, two, params);
if (value != null)
{
text = text.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement(value));
}
}
}
return color(text);
return colorize ? Msg.color(text) : text;
}
/**
* unregister ALL placeholder hooks that are currently registered
* Gets the placeholder pattern for the default placeholders.
*
* @return The pattern for {@literal %<identifier>_<params>%}
* @deprecated Will be removed in a future release.
*/
protected static void unregisterAll() {
unregisterAllProvidedExpansions();
placeholders.clear();
}
/**
* unregister all expansions provided by PlaceholderAPI
*/
public static void unregisterAllProvidedExpansions() {
if (placeholders.isEmpty()) {
return;
}
getPlaceholders().forEach((key, value) -> {
if (value instanceof PlaceholderExpansion) {
PlaceholderExpansion ex = (PlaceholderExpansion) value;
if (!ex.persist()) {
unregisterExpansion(ex);
}
}
});
}
public static boolean registerExpansion(PlaceholderExpansion ex) {
if (registerPlaceholderHook(ex.getIdentifier(), ex)) {
Bukkit.getPluginManager().callEvent(new ExpansionRegisterEvent(ex));
return true;
}
return false;
}
public static boolean unregisterExpansion(PlaceholderExpansion ex) {
if (unregisterPlaceholderHook(ex.getIdentifier())) {
Bukkit.getPluginManager().callEvent(new ExpansionUnregisterEvent(ex));
return true;
}
return false;
}
public static Pattern getPlaceholderPattern() {
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Pattern getPlaceholderPattern()
{
return PLACEHOLDER_PATTERN;
}
public static Pattern getBracketPlaceholderPattern() {
/**
* Gets the placeholder pattern for the bracket placeholders.
*
* @return The pattern for {@literal {<identifier>_<params>}}
* @deprecated Will be removed in a future release.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Pattern getBracketPlaceholderPattern()
{
return BRACKET_PLACEHOLDER_PATTERN;
}
public static Pattern getRelationalPlaceholderPattern() {
/**
* Gets the placeholder pattern for the relational placeholders.
*
* @return The pattern for {@literal %rel_<identifier>_<params>%}
* @deprecated Will be removed in a future release.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Pattern getRelationalPlaceholderPattern()
{
return RELATIONAL_PLACEHOLDER_PATTERN;
}
/**
* @deprecated Will be removed in a future release.
*/
@Deprecated
public static Set<String> getRegisteredPlaceholderPlugins() {
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Set<String> getRegisteredPlaceholderPlugins()
{
return getRegisteredIdentifiers();
}
/**
* @deprecated Will be removed in a future release.
*/
@Deprecated
public static Set<String> getExternalPlaceholderPlugins() {
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Set<String> getExternalPlaceholderPlugins()
{
return null;
}
/**
* @deprecated Will be removed in a future release.
*/
@Deprecated
public static boolean registerPlaceholderHook(Plugin plugin, PlaceholderHook placeholderHook) {
return plugin != null && registerPlaceholderHook(plugin.getName(), placeholderHook);
@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
public static boolean unregisterPlaceholderHook(Plugin plugin) {
return plugin != null && unregisterPlaceholderHook(plugin.getName());
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setPlaceholders(Player player, String text, boolean colorize)
{
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
}
public static String setPlaceholders(Player p, String text) {
return setPlaceholders((OfflinePlayer) p, text, PLACEHOLDER_PATTERN);
/**
* @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);
}
public static List<String> setPlaceholders(Player p, List<String> text) {
return setPlaceholders((OfflinePlayer) p, text, PLACEHOLDER_PATTERN);
/**
* @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);
}
public static String setBracketPlaceholders(Player p, String text) {
return setPlaceholders((OfflinePlayer) p, text, BRACKET_PLACEHOLDER_PATTERN);
/**
* @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);
}
public static List<String> setBracketPlaceholders(Player p, List<String> text) {
return setPlaceholders((OfflinePlayer) p, text, BRACKET_PLACEHOLDER_PATTERN);
/**
* @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);
}
}

View File

@@ -1,78 +1,217 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package me.clip.placeholderapi;
import me.clip.placeholderapi.commands.PlaceholderCommandRouter;
import me.clip.placeholderapi.configuration.PlaceholderAPIConfig;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.Version;
import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
import me.clip.placeholderapi.updatechecker.UpdateChecker;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import me.clip.placeholderapi.commands.PlaceholderAPICommands;
import me.clip.placeholderapi.configuration.PlaceholderAPIConfig;
import me.clip.placeholderapi.expansion.ExpansionManager;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.Version;
import me.clip.placeholderapi.expansion.cloud.ExpansionCloudManager;
import me.clip.placeholderapi.external.EZPlaceholderHook;
import me.clip.placeholderapi.updatechecker.UpdateChecker;
import me.clip.placeholderapi.util.TimeUtil;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Level;
/**
* Yes I have a shit load of work to do...
*
* @author Ryan McCarthy
*/
public class PlaceholderAPIPlugin extends JavaPlugin {
public final class PlaceholderAPIPlugin extends JavaPlugin
{
@NotNull
private static final Version VERSION;
static
{
final String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
boolean isSpigot;
try
{
Class.forName("org.spigotmc.SpigotConfig");
isSpigot = true;
}
catch (final ExceptionInInitializerError | ClassNotFoundException ignored)
{
isSpigot = false;
}
VERSION = new Version(version, isSpigot);
}
private static PlaceholderAPIPlugin instance;
private static SimpleDateFormat dateFormat;
private static String booleanTrue;
private static String booleanFalse;
private static Version serverVersion;
private PlaceholderAPIConfig config;
private ExpansionManager expansionManager;
private ExpansionCloudManager expansionCloud;
private long startTime;
private static Version getVersion() {
String v = "unknown";
boolean spigot = false;
try {
v = Bukkit.getServer().getClass().getPackage().getName()
.split("\\.")[3];
} catch (ArrayIndexOutOfBoundsException ex) {
@NotNull
private final PlaceholderAPIConfig config = new PlaceholderAPIConfig(this);
@NotNull
private final LocalExpansionManager localExpansionManager = new LocalExpansionManager(this);
@NotNull
private final CloudExpansionManager cloudExpansionManager = new CloudExpansionManager(this);
@Override
public void onLoad()
{
instance = this;
saveDefaultConfig();
}
try {
Class.forName("org.spigotmc.SpigotConfig");
Class.forName("net.md_5.bungee.api.chat.BaseComponent");
spigot = true;
} catch (ExceptionInInitializerError | ClassNotFoundException exception) {
@Override
public void onEnable()
{
setupCommand();
setupMetrics();
setupExpansions();
if (config.isCloudEnabled())
{
getCloudExpansionManager().load();
}
return new Version(v, spigot);
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
@@ -81,210 +220,59 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
*
* @return PlaceholderAPIPlugin instance
*/
public static PlaceholderAPIPlugin getInstance() {
@NotNull
public static PlaceholderAPIPlugin getInstance()
{
return instance;
}
/**
* Get the configurable {@linkplain String} value that should be returned when a boolean is true
*
* @return string value of true
*/
@NotNull
public static String booleanTrue()
{
return getInstance().getPlaceholderAPIConfig().booleanTrue();
}
/**
* Get the configurable {@linkplain String} value that should be returned when a boolean is false
*
* @return string value of false
*/
@NotNull
public static String booleanFalse()
{
return getInstance().getPlaceholderAPIConfig().booleanFalse();
}
/**
* Get the configurable {@linkplain SimpleDateFormat} object that is used to parse time for
* generic time based placeholders
*
* @return date format
*/
public static SimpleDateFormat getDateFormat() {
return dateFormat != null ? dateFormat : new SimpleDateFormat(
"MM/dd/yy HH:mm:ss");
@NotNull
public static SimpleDateFormat getDateFormat()
{
try
{
return new SimpleDateFormat(getInstance().getPlaceholderAPIConfig().dateFormat());
}
/**
* Get the configurable {@linkplain String} value that should be returned when a boolean is true
*
* @return string value of true
*/
public static String booleanTrue() {
return booleanTrue != null ? booleanTrue : "true";
}
/**
* Get the configurable {@linkplain String} value that should be returned when a boolean is false
*
* @return string value of false
*/
public static String booleanFalse() {
return booleanFalse != null ? booleanFalse : "false";
}
public static Version getServerVersion() {
return serverVersion != null ? serverVersion : getVersion();
}
@Override
public void onLoad() {
startTime = System.currentTimeMillis();
instance = this;
serverVersion = getVersion();
config = new PlaceholderAPIConfig(this);
expansionManager = new ExpansionManager(this);
}
@Override
public void onEnable() {
config.loadDefConfig();
setupOptions();
getCommand("placeholderapi").setExecutor(new PlaceholderAPICommands(this));
new PlaceholderListener(this);
try {
Class.forName("org.bukkit.event.server.ServerLoadEvent");
new ServerLoadEventListener(this);
} catch (ExceptionInInitializerError | ClassNotFoundException exception) {
Bukkit.getScheduler().runTaskLater(this, () -> {
getLogger().info("Placeholder expansion registration initializing...");
//fetch any hooks that may have registered externally onEnable first otherwise they will be lost
final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders();
getExpansionManager().registerAllExpansions();
if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) {
alreadyRegistered.forEach(PlaceholderAPI::registerPlaceholderHook);
}
}, 1);
}
if (config.checkUpdates()) {
new UpdateChecker(this).fetch();
}
if (config.isCloudEnabled()) {
enableCloud();
}
setupMetrics();
getServer().getScheduler().runTaskLater(this, this::checkHook, 40);
}
@Override
public void onDisable() {
disableCloud();
PlaceholderAPI.unregisterAll();
expansionManager = null;
Bukkit.getScheduler().cancelTasks(this);
serverVersion = null;
instance = null;
}
public void reloadConf(CommandSender s) {
boolean cloudEnabled = this.expansionCloud != null;
PlaceholderAPI.unregisterAllProvidedExpansions();
reloadConfig();
setupOptions();
expansionManager.registerAllExpansions();
if (!config.isCloudEnabled()) {
disableCloud();
} else if (!cloudEnabled) {
enableCloud();
}
s.sendMessage(ChatColor.translateAlternateColorCodes('&',
PlaceholderAPI.getRegisteredIdentifiers().size()
+ " &aplaceholder hooks successfully registered!"));
}
private void checkHook() {
Map<String, PlaceholderHook> loaded = PlaceholderAPI.getPlaceholders();
loaded.values().forEach(h -> {
if (h instanceof EZPlaceholderHook) {
String author;
try {
author = Bukkit.getPluginManager().getPlugin(((EZPlaceholderHook) h).getPluginName()).getDescription().getAuthors().toString();
} catch (Exception ex) {
author = "the author of the hook's plugin";
}
getLogger().severe(((EZPlaceholderHook) h).getPluginName() + " is currently using a deprecated method to hook into PlaceholderAPI. Placeholders for that plugin no longer work. " +
"Please consult {author} and urge them to update it ASAP.".replace("{author}", author));
// disable the hook on startup
PlaceholderAPI.unregisterPlaceholderHook(((EZPlaceholderHook) h).getPlaceholderName());
}
});
}
private void setupOptions() {
booleanTrue = config.booleanTrue();
if (booleanTrue == null) {
booleanTrue = "true";
}
booleanFalse = config.booleanFalse();
if (booleanFalse == null) {
booleanFalse = "false";
}
try {
dateFormat = new SimpleDateFormat(config.dateFormat());
} catch (Exception e) {
dateFormat = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
catch (final IllegalArgumentException ex)
{
getInstance().getLogger().log(Level.WARNING, "configured date format is invalid", ex);
return new SimpleDateFormat("MM/dd/yy HH:mm:ss");
}
}
private void setupMetrics() {
Metrics m = new Metrics(this);
m.addCustomChart(new Metrics.SimplePie("using_expansion_cloud",
() -> getExpansionCloud() != null ? "yes" : "no"));
m.addCustomChart(
new Metrics.SimplePie("using_spigot", () -> getServerVersion().isSpigot() ? "yes" : "no"));
m.addCustomChart(new Metrics.AdvancedPie("expansions_used", () -> {
Map<String, Integer> map = new HashMap<>();
Map<String, PlaceholderHook> p = PlaceholderAPI.getPlaceholders();
if (!p.isEmpty()) {
for (PlaceholderHook hook : p.values()) {
if (hook instanceof PlaceholderExpansion) {
PlaceholderExpansion ex = (PlaceholderExpansion) hook;
map.put(ex.getRequiredPlugin() == null ? ex.getIdentifier()
: ex.getRequiredPlugin(), 1);
}
}
}
return map;
}));
public static Version getServerVersion()
{
return VERSION;
}
public void enableCloud() {
if (expansionCloud == null) {
expansionCloud = new ExpansionCloudManager(this);
expansionCloud.fetch(config.cloudAllowUnverifiedExpansions());
} else {
expansionCloud.clean();
expansionCloud.fetch(config.cloudAllowUnverifiedExpansions());
}
}
public void disableCloud() {
if (expansionCloud != null) {
expansionCloud.clean();
expansionCloud = null;
}
}
/**
* Obtain the configuration class for PlaceholderAPI.
*
* @return PlaceholderAPIConfig instance
*/
public PlaceholderAPIConfig getPlaceholderAPIConfig() {
return config;
}
public ExpansionManager getExpansionManager() {
return expansionManager;
}
public ExpansionCloudManager getExpansionCloud() {
return expansionCloud;
}
public String getUptime() {
return TimeUtil
.getTime((int) TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime));
}
public long getUptimeMillis() {
return (System.currentTimeMillis() - startTime);
}
}

View File

@@ -1,53 +1,76 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package me.clip.placeholderapi;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
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 p {@link OfflinePlayer} to request the placeholder value for, null if not needed for a
* @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)}
*/
public String onRequest(OfflinePlayer p, String params) {
if (p != null && p.isOnline()) {
return onPlaceholderRequest((Player) p, params);
@Nullable
@Deprecated
public String onRequest(@Nullable final OfflinePlayer player, @NotNull final String params)
{
if (player != null && player.isOnline())
{
return onPlaceholderRequest((Player) player, params);
}
return onPlaceholderRequest(null, params);
}
/**
* called when a placeholder is requested from this hook
*
* @param p {@link Player} to request the placeholder value for, null if not needed for a player
* @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)}
*/
public String onPlaceholderRequest(Player p, String params) {
@Nullable
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public String onPlaceholderRequest(@Nullable final Player player, @NotNull final String params)
{
return null;
}
}

View File

@@ -1,128 +0,0 @@
/*
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
*
* This program 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package me.clip.placeholderapi;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import me.clip.placeholderapi.events.ExpansionUnregisterEvent;
import me.clip.placeholderapi.expansion.Cacheable;
import me.clip.placeholderapi.expansion.Cleanable;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.Taskable;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.PluginDisableEvent;
public class PlaceholderListener implements Listener {
private PlaceholderAPIPlugin plugin;
public PlaceholderListener(PlaceholderAPIPlugin instance) {
plugin = instance;
Bukkit.getPluginManager().registerEvents(this, instance);
}
@EventHandler
public void onExpansionUnregister(ExpansionUnregisterEvent event) {
if (event.getExpansion() instanceof Listener) {
HandlerList.unregisterAll((Listener) event.getExpansion());
}
if (event.getExpansion() instanceof Taskable) {
((Taskable) event.getExpansion()).stop();
}
if (event.getExpansion() instanceof Cacheable) {
((Cacheable) event.getExpansion()).clear();
}
if (plugin.getExpansionCloud() != null) {
CloudExpansion ex = plugin.getExpansionCloud()
.getCloudExpansion(event.getExpansion().getName());
if (ex != null) {
ex.setHasExpansion(false);
ex.setShouldUpdate(false);
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPluginUnload(PluginDisableEvent e) {
String n = e.getPlugin().getName();
if (n == null) {
return;
}
if (n.equals(plugin.getName())) {
return;
}
Map<String, PlaceholderHook> hooks = PlaceholderAPI.getPlaceholders();
for (Entry<String, PlaceholderHook> hook : hooks.entrySet()) {
PlaceholderHook i = hook.getValue();
if (i instanceof PlaceholderExpansion) {
PlaceholderExpansion ex = (PlaceholderExpansion) i;
if (ex.getRequiredPlugin() == null) {
continue;
}
if (ex.getRequiredPlugin().equalsIgnoreCase(n)) {
if (PlaceholderAPI.unregisterExpansion(ex)) {
plugin.getLogger().info("Unregistered placeholder expansion: " + ex.getIdentifier());
}
}
}
}
}
@EventHandler
public void onQuit(PlayerQuitEvent e) {
Set<PlaceholderExpansion> expansions = PlaceholderAPI.getExpansions();
if (expansions.isEmpty()) {
return;
}
for (PlaceholderExpansion ex : expansions) {
if (ex instanceof Cleanable) {
((Cleanable) ex).cleanup(e.getPlayer());
}
}
}
}

View File

@@ -1,37 +0,0 @@
package me.clip.placeholderapi;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerLoadEvent;
public class ServerLoadEventListener implements Listener {
private PlaceholderAPIPlugin plugin;
public ServerLoadEventListener(PlaceholderAPIPlugin instance) {
plugin = instance;
Bukkit.getPluginManager().registerEvents(this, instance);
}
/**
* This method will be called when the server is first loaded
*
* The goal of the method is to register all the expansions as soon as possible
* especially before players can join
*
* This will ensure no issues with expanions and hooks.
* @param e the server load event
*/
@EventHandler
public void onServerLoad(ServerLoadEvent e) {
plugin.getLogger().info("Placeholder expansion registration initializing...");
final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders();
plugin.getExpansionManager().registerAllExpansions();
if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) {
alreadyRegistered.forEach(PlaceholderAPI::registerPlaceholderHook);
}
}
}

View File

@@ -1,444 +0,0 @@
/*
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
*
* This program 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package me.clip.placeholderapi.commands;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.rayzr522.jsonmessage.JSONMessage;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static me.clip.placeholderapi.util.Msg.color;
import static me.clip.placeholderapi.util.Msg.msg;
public class ExpansionCloudCommands implements CommandExecutor {
private PlaceholderAPIPlugin plugin;
public ExpansionCloudCommands(PlaceholderAPIPlugin instance) {
plugin = instance;
}
@Override
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 1) {
msg(s, "&bExpansion cloud commands",
" ",
"&b/papi ecloud status",
"&fView status of the ecloud",
"&b/papi ecloud list <all/author> (page)",
"&fList all/author specific available expansions",
"&b/papi ecloud info <expansion name>",
"&fView information about a specific expansion available on the cloud",
"&b/papi ecloud versioninfo <expansion name> <version>",
"&fView information about a specific version of an expansion",
"&b/papi ecloud placeholders <expansion name>",
"&fView placeholders for an expansion",
"&b/papi ecloud download <expansion name> (version)",
"&fDownload an expansion from the ecloud",
"&b/papi ecloud refresh",
"&fFetch the most up to date list of expansions available.",
"&b/papi ecloud clear",
"&fClear the expansion cloud cache.");
return true;
}
if (args[1].equalsIgnoreCase("refresh") || args[1].equalsIgnoreCase("update") || args[1]
.equalsIgnoreCase("fetch")) {
msg(s, "&aRefresh task started. Use &f/papi ecloud list all &ain a few!!");
plugin.getExpansionCloud().clean();
plugin.getExpansionCloud().fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
return true;
}
if (plugin.getExpansionCloud().getCloudExpansions().isEmpty()) {
msg(s, "&7No cloud expansions are available at this time.");
return true;
}
if (args[1].equalsIgnoreCase("clear")) {
plugin.getExpansionCloud().clean();
msg(s, "&aThe cache has been cleared!!");
return true;
}
if (args[1].equalsIgnoreCase("status")) {
msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size()
+ " &bexpansions available on the cloud.",
"&7A total of &f" + plugin.getExpansionCloud().getCloudAuthorCount()
+ " &7authors have contributed to the expansion cloud.");
if (plugin.getExpansionCloud().getToUpdateCount() > 0) {
msg(s, "&eYou have &f" + plugin.getExpansionCloud().getToUpdateCount()
+ " &eexpansions installed that have updates available.");
}
return true;
}
if (args[1].equalsIgnoreCase("info")) {
if (args.length < 3) {
msg(s, "&cAn expansion name must be specified!");
return true;
}
CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]);
if (expansion == null) {
msg(s, "&cNo expansion found by the name: &f" + args[2]);
return true;
}
if (!(s instanceof Player)) {
msg(s,
(expansion.shouldUpdate() ? "&e" : "") + expansion.getName() + " &8&m-- &r" + expansion
.getVersion().getUrl());
return true;
}
Player p = (Player) s;
msg(s, "&bExpansion&7: &f" + expansion.getName(),
"&bAuthor: &f" + expansion.getAuthor(),
"&bVerified: &f" + expansion.isVerified()
);
// latest version
JSONMessage latestVersion = JSONMessage
.create(color("&bLatest version: &f" + expansion.getLatestVersion()));
latestVersion.tooltip(color("&bReleased: &f" + expansion.getTimeSinceLastUpdate()
+ "\n&bUpdate information: &f" + expansion.getVersion().getReleaseNotes()
));
latestVersion.send(p);
// versions
JSONMessage versions = JSONMessage
.create(color("&bVersions available: &f" + expansion.getVersions().size()));
versions.tooltip(color(String.join("&b, &f", expansion.getAvailableVersions())));
versions.suggestCommand(
"/papi ecloud versioninfo " + expansion.getName() + " " + expansion.getLatestVersion());
versions.send(p);
// placeholders
if (expansion.getPlaceholders() != null) {
JSONMessage placeholders = JSONMessage
.create(color("&bPlaceholders: &f" + expansion.getPlaceholders().size()));
placeholders.tooltip(color(String.join("&b, &f", expansion.getPlaceholders())));
placeholders.suggestCommand("/papi ecloud placeholders " + expansion.getName());
placeholders.send(p);
}
return true;
}
if (args[1].equalsIgnoreCase("versioninfo")) {
if (args.length < 4) {
msg(s, "&cAn expansion name and version must be specified!");
return true;
}
CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]);
if (expansion == null) {
msg(s, "&cNo expansion found by the name: &f" + args[2]);
return true;
}
CloudExpansion.Version version = expansion.getVersion(args[3]);
if (version == null) {
msg(s, "&cThe version specified does not exist for expansion: &f" + expansion.getName());
return true;
}
msg(s, "&bExpansion: " + (expansion.shouldUpdate() ? "&e" : "&f") + expansion.getName(),
"&bVersion: &f" + version.getVersion(),
"&bVersion info: &f" + version.getReleaseNotes());
if (!(s instanceof Player)) {
msg(s, "&bDownload url: " + version.getUrl());
return true;
}
Player p = (Player) s;
JSONMessage download = JSONMessage.create(color("&7Click to download this version"));
download.suggestCommand(
"/papi ecloud download " + expansion.getName() + " " + version.getVersion());
download.send(p);
return true;
}
if (args[1].equalsIgnoreCase("placeholders")) {
if (args.length < 3) {
msg(s, "&cAn expansion name must be specified!");
return true;
}
CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]);
if (expansion == null) {
msg(s, "&cNo expansion found by the name: &f" + args[2]);
return true;
}
List<String> placeholders = expansion.getPlaceholders();
if (placeholders == null) {
msg(s, "&cThe expansion: &f" + expansion.getName()
+ " &cdoes not have any placeholders listed.",
"&7You should contact &f" + expansion.getAuthor() + " &7and ask for them to be added.");
return true;
}
if (!(s instanceof Player)
|| plugin.getExpansionManager().getRegisteredExpansion(expansion.getName()) == null) {
msg(s, "&bPlaceholders: &f" + placeholders.size(),
String.join("&a, &f", placeholders));
return true;
}
Player p = (Player) s;
JSONMessage message = JSONMessage.create(color("&bPlaceholders: &f" + placeholders.size()));
message.then("\n");
for (int i = 0; i < placeholders.size(); i++) {
if (i == placeholders.size() - 1) {
message.then(placeholders.get(i));
} else {
message.then(color(placeholders.get(i) + "&b, &f"));
}
message.tooltip(PlaceholderAPI.setPlaceholders(p, placeholders.get(i)));
}
message.send(p);
return true;
}
if (args[1].equalsIgnoreCase("list")) {
int page = 1;
String author;
boolean installed = false;
if (args.length < 3) {
msg(s, "&cIncorrect usage! &7/papi ecloud list <all/author/installed> (page)");
return true;
}
author = args[2];
if (author.equalsIgnoreCase("all")) {
author = null;
} else if (author.equalsIgnoreCase("installed")) {
author = null;
installed = true;
}
if (args.length >= 4) {
try {
page = Integer.parseInt(args[3]);
} catch (NumberFormatException ex) {
msg(s, "&cPage number must be an integer!");
return true;
}
}
if (page < 1) {
msg(s, "&cPage must be greater than or equal to 1!");
return true;
}
int avail;
Map<Integer, CloudExpansion> ex;
if (installed) {
ex = plugin.getExpansionCloud().getAllInstalled();
} else if (author == null) {
ex = plugin.getExpansionCloud().getCloudExpansions();
} else {
ex = plugin.getExpansionCloud().getAllByAuthor(author);
}
if (ex == null || ex.isEmpty()) {
msg(s, "&cNo expansions available" + (author != null ? " for author &f" + author : ""));
return true;
}
avail = plugin.getExpansionCloud().getPagesAvailable(ex, 10);
if (page > avail) {
msg(s, "&cThere " + ((avail == 1) ? " is only &f" + avail + " &cpage available!"
: "are only &f" + avail + " &cpages available!"));
return true;
}
msg(s, "&bShowing expansions for&7: &f" + (author != null ? author
: (installed ? "all installed" : "all available")) + " &8&m--&r &bamount&7: &f" + ex
.size() + " &bpage&7: &f" + page + "&7/&f" + avail);
ex = plugin.getExpansionCloud().getPage(ex, page, 10);
if (ex == null) {
msg(s, "&cThere was a problem getting the requested page...");
return true;
}
msg(s, "&aGreen = Expansions you have");
msg(s, "&6Gold = Expansions which need updated");
if (!(s instanceof Player)) {
Map<String, CloudExpansion> expansions = new HashMap<>();
for (CloudExpansion exp : ex.values()) {
if (exp == null || exp.getName() == null) {
continue;
}
expansions.put(exp.getName(), exp);
}
List<String> ce = expansions.keySet().stream().sorted().collect(Collectors.toList());
int i = (int) ex.keySet().toArray()[0]+1;
for (String name : ce) {
if (expansions.get(name) == null) {
continue;
}
CloudExpansion expansion = expansions.get(name);
msg(s,
"&b" + i + "&7: " + (expansion.shouldUpdate() ? "&6"
: (expansion.hasExpansion() ? "&a" : "&7")) + expansion
.getName() + " &8&m-- &r" + expansion.getVersion().getUrl());
i++;
}
return true;
}
Player p = (Player) s;
Map<String, CloudExpansion> expansions = new HashMap<>();
for (CloudExpansion exp : ex.values()) {
if (exp == null || exp.getName() == null) {
continue;
}
expansions.put(exp.getName(), exp);
}
List<String> ce = expansions.keySet().stream().sorted().collect(Collectors.toList());
int i = 1;
for (String name : ce) {
if (expansions.get(name) == null) {
continue;
}
CloudExpansion expansion = expansions.get(name);
StringBuilder sb = new StringBuilder();
if (expansion.shouldUpdate()) {
sb.append("&6Click to update to the latest version of this expansion\n\n");
} else if (!expansion.hasExpansion()) {
sb.append("&bClick to download this expansion\n\n");
} else {
sb.append("&aYou have the latest version of this expansion\n\n");
}
sb.append("&bAuthor&7: &f" + expansion.getAuthor() + "\n");
sb.append("&bVerified&7: &f" + expansion.isVerified() + "\n");
sb.append("&bLatest version&7: &f" + expansion.getVersion().getVersion() + "\n");
sb.append(
"&bLast updated&7: &f" + expansion.getTimeSinceLastUpdate() + " ago\n");
sb.append("\n" + expansion.getDescription());
String msg = color(
"&b" + (i + 1) + "&7: " + (expansion.shouldUpdate() ? "&6"
: (expansion.hasExpansion() ? "&a" : "")) + expansion.getName());
String hover = color(sb.toString());
JSONMessage line = JSONMessage.create(msg);
line.tooltip(hover);
if (expansion.shouldUpdate()) {
line.suggestCommand("/papi ecloud download " + expansion.getName());
}
else {
line.suggestCommand("/papi ecloud info " + expansion.getName());
}
line.send(p);
i++;
}
return true;
}
if (args[1].equalsIgnoreCase("download")) {
if (args.length < 3) {
msg(s, "&cAn expansion name must be specified!");
return true;
}
CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]);
if (expansion == null) {
msg(s, "&cNo expansion found with the name: &f" + args[2]);
return true;
}
PlaceholderExpansion loaded = plugin.getExpansionManager().getRegisteredExpansion(args[2]);
if (loaded != null && loaded.isRegistered()) {
PlaceholderAPI.unregisterPlaceholderHook(loaded.getIdentifier());
}
String version = expansion.getLatestVersion();
if (args.length == 4) {
version = args[3];
if (expansion.getVersion(version) == null) {
msg(s, "&cThe version you specified does not exist for &f" + expansion.getName());
msg(s, "&7Available versions: &f" + expansion.getVersions().size());
msg(s, String.join("&a, &f", expansion.getAvailableVersions()));
return true;
}
}
msg(s, "&aDownload starting for expansion: &f" + expansion.getName() + " &aversion: &f"
+ version);
String player = ((s instanceof Player) ? s.getName() : null);
plugin.getExpansionCloud().downloadExpansion(player, expansion, version);
plugin.getExpansionCloud().clean();
plugin.getExpansionCloud().fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
return true;
}
msg(s, "&cIncorrect usage! &b/papi ecloud");
return true;
}
}

View File

@@ -1,289 +0,0 @@
/*
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
*
* This program 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package me.clip.placeholderapi.commands;
import java.util.Set;
import java.util.stream.Collectors;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PlaceholderAPICommands implements CommandExecutor {
private PlaceholderAPIPlugin plugin;
private CommandExecutor eCloud;
public PlaceholderAPICommands(PlaceholderAPIPlugin i) {
plugin = i;
eCloud = new ExpansionCloudCommands(i);
}
@Override
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 0) {
Msg.msg(s, "PlaceholderAPI &7version &b&o" + plugin.getDescription().getVersion(),
"&fCreated by&7: &b" + plugin.getDescription().getAuthors(),
"&fPapi commands: &b/papi help",
"&fEcloud commands: &b/papi ecloud");
return true;
} else {
if (args[0].equalsIgnoreCase("help")) {
Msg.msg(s, "PlaceholderAPI &aHelp &e(&f" + plugin.getDescription().getVersion() + "&e)",
"&b/papi",
"&fView plugin info/version info",
"&b/papi list",
"&fList all placeholder expansions that are currently active",
"&b/papi info <placeholder name>",
"&fView information for a specific expansion",
"&b/papi parse <(playername)/me> <...args>",
"&fParse a String with placeholders",
"&b/papi bcparse <(playername)/me> <...args>",
"&fParse a String with placeholders and broadcast the message",
"&b/papi parserel <player one> <player two> <...args>",
"&fParse a String with relational placeholders",
"&b/papi register <fileName>",
"&fRegister an expansion by the name of the file",
"&b/papi unregister <Expansion name>",
"&fUnregister an expansion by name",
"&b/papi reload",
"&fReload the config settings");
if (s.hasPermission("placeholderapi.ecloud")) {
if (plugin.getExpansionCloud() == null) {
Msg.msg(s, "&b/papi enablecloud",
"&fEnable the expansion cloud");
} else {
Msg.msg(s, "&b/papi disablecloud",
"&fDisable the expansion cloud",
"&b/papi ecloud",
"&fView ecloud command usage");
}
}
return true;
} else if (args[0].equalsIgnoreCase("ecloud")) {
if (!s.hasPermission("placeholderapi.ecloud")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
if (plugin.getExpansionCloud() == null) {
Msg.msg(s, "&7The expansion cloud is not enabled!");
return true;
}
return eCloud.onCommand(s, c, label, args);
} else if (args[0].equalsIgnoreCase("enablecloud")) {
if (!s.hasPermission("placeholderapi.ecloud")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
if (plugin.getExpansionCloud() != null) {
Msg.msg(s, "&7The cloud is already enabled!");
return true;
}
plugin.enableCloud();
plugin.getPlaceholderAPIConfig().setCloudEnabled(true);
Msg.msg(s, "&aThe cloud has been enabled!");
return true;
} else if (args[0].equalsIgnoreCase("disablecloud")) {
if (!s.hasPermission("placeholderapi.ecloud")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
if (plugin.getExpansionCloud() == null) {
Msg.msg(s, "&7The cloud is already disabled!");
return true;
}
plugin.disableCloud();
plugin.getPlaceholderAPIConfig().setCloudEnabled(false);
Msg.msg(s, "&aThe cloud has been disabled!");
return true;
} else if (args.length > 1 && args[0].equalsIgnoreCase("info")) {
if (!s.hasPermission("placeholderapi.info")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
PlaceholderExpansion ex = plugin.getExpansionManager().getRegisteredExpansion(args[1]);
if (ex == null) {
Msg.msg(s, "&cThere is no expansion loaded with the identifier: &f" + args[1]);
return true;
}
Msg.msg(s, "&7Placeholder expansion info for: &f" + ex.getName());
Msg.msg(s, "&7Status: " + (ex.isRegistered() ? "&aRegistered" : "&cNot registered"));
if (ex.getAuthor() != null) {
Msg.msg(s, "&7Created by: &f" + ex.getAuthor());
}
if (ex.getVersion() != null) {
Msg.msg(s, "&7Version: &f" + ex.getVersion());
}
if (ex.getRequiredPlugin() != null) {
Msg.msg(s, "&7Requires plugin: &f" + ex.getRequiredPlugin());
}
if (ex.getPlaceholders() != null) {
Msg.msg(s, "&8&m-- &r&7Placeholders &8&m--");
for (String placeholder : ex.getPlaceholders()) {
Msg.msg(s, placeholder);
}
}
return true;
} else if (args.length > 2 && args[0].equalsIgnoreCase("parse")
|| args.length > 2 && args[0].equalsIgnoreCase("bcparse")) {
if (!s.hasPermission("placeholderapi.parse")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
OfflinePlayer pl = null;
if (args[1].equalsIgnoreCase("me")) {
if (s instanceof Player) {
pl = (Player) s;
} else {
Msg.msg(s, "&cThis command must target a player when used by console");
return true;
}
} else {
if (Bukkit.getPlayer(args[1]) != null) {
pl = Bukkit.getPlayer(args[1]);
} else {
pl = Bukkit.getOfflinePlayer(args[1]);
}
}
if (pl == null || !pl.hasPlayedBefore()) {
Msg.msg(s, "&cFailed to find player: &f" + args[1]);
return true;
}
String parse = StringUtils.join(args, " ", 2, args.length);
if (args[0].equalsIgnoreCase("bcparse")) {
Msg.broadcast("&r" + PlaceholderAPI.setPlaceholders(pl, parse));
} else {
Msg.msg(s, "&r" + PlaceholderAPI.setPlaceholders(pl, parse));
}
return true;
} else if (args.length > 3 && args[0].equalsIgnoreCase("parserel")) {
if (!(s instanceof Player)) {
Msg.msg(s, "&cThis command can only be used in game!");
return true;
} else {
if (!s.hasPermission("placeholderapi.parse")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Player one = Bukkit.getPlayer(args[1]);
if (one == null) {
Msg.msg(s, args[1] + " &cis not online!");
return true;
}
Player two = Bukkit.getPlayer(args[2]);
if (two == null) {
Msg.msg(s, args[2] + " &cis not online!");
return true;
}
String parse = StringUtils.join(args, " ", 3, args.length);
Msg.msg(s, "&r" + PlaceholderAPI.setRelationalPlaceholders(one, two, parse));
return true;
} else if (args[0].equalsIgnoreCase("reload")) {
if (s instanceof Player) {
if (!s.hasPermission("placeholderapi.reload")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Msg.msg(s, "&fPlaceholder&7API &bconfiguration reloaded!");
plugin.reloadConf(s);
} else if (args[0].equalsIgnoreCase("list")) {
if (s instanceof Player) {
if (!s.hasPermission("placeholderapi.list")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Set<String> registered = PlaceholderAPI.getRegisteredIdentifiers();
if (registered.isEmpty()) {
Msg.msg(s, "&7There are no placeholder hooks currently registered!");
return true;
}
Msg.msg(s, registered.size() + " &7Placeholder hooks registered:");
Msg.msg(s, registered.stream().sorted().collect(Collectors.joining(", ")));
} else if (args.length > 1 && args[0].equalsIgnoreCase("register")) {
if (s instanceof Player) {
if (!s.hasPermission("placeholderapi.register")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
String fileName = args[1].replace(".jar", "");
PlaceholderExpansion ex = plugin.getExpansionManager().registerExpansion(fileName);
if (ex == null) {
Msg.msg(s, "&cFailed to register expansion from " + fileName);
return true;
}
Msg.msg(s, "&aSuccessfully registered expansion: &f" + ex.getName());
} else if (args.length > 1 && args[0].equalsIgnoreCase("unregister")) {
if (s instanceof Player) {
if (!s.hasPermission("placeholderapi.register")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
PlaceholderExpansion ex = plugin.getExpansionManager().getRegisteredExpansion(args[1]);
if (ex == null) {
Msg.msg(s, "&cFailed to find expansion: &f" + args[1]);
return true;
}
if (PlaceholderAPI.unregisterExpansion(ex)) {
Msg.msg(s, "&aSuccessfully unregistered expansion: &f" + ex.getName());
} else {
Msg.msg(s, "&cFailed to unregister expansion: &f" + ex.getName());
}
} else {
Msg.msg(s, "&cIncorrect usage! &7/papi help");
}
}
return true;
}
}

View File

@@ -0,0 +1,118 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
public abstract class PlaceholderCommand
{
@NotNull
private final String label;
@NotNull
private final Set<String> alias;
@Nullable
private String permission;
protected PlaceholderCommand(@NotNull final String label, @NotNull final String... alias)
{
this.label = label;
this.alias = Sets.newHashSet(alias);
setPermission("placeholderapi." + label);
}
@NotNull
public final String getLabel()
{
return label;
}
@NotNull
@Unmodifiable
public final Set<String> getAlias()
{
return ImmutableSet.copyOf(alias);
}
@NotNull
@Unmodifiable
public final Set<String> getLabels()
{
return ImmutableSet.<String>builder().add(label).addAll(alias).build();
}
@Nullable
public final String getPermission()
{
return permission;
}
public void setPermission(@NotNull final String permission)
{
this.permission = permission;
}
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
}
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
}
@NotNull
public static Stream<PlaceholderCommand> filterByPermission(@NotNull final CommandSender sender, @NotNull final Stream<PlaceholderCommand> commands)
{
return commands.filter(target -> target.getPermission() == null || sender.hasPermission(target.getPermission()));
}
public static void suggestByParameter(@NotNull final Stream<String> possible, @NotNull final List<String> suggestions, @Nullable final String parameter)
{
if (parameter == null)
{
possible.forEach(suggestions::add);
}
else
{
possible.filter(suggestion -> suggestion.toLowerCase().startsWith(parameter.toLowerCase())).forEach(suggestions::add);
}
}
}

View File

@@ -0,0 +1,143 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.impl.cloud.CommandECloud;
import me.clip.placeholderapi.commands.impl.local.CommandDump;
import me.clip.placeholderapi.commands.impl.local.CommandExpansionRegister;
import me.clip.placeholderapi.commands.impl.local.CommandExpansionUnregister;
import me.clip.placeholderapi.commands.impl.local.CommandHelp;
import me.clip.placeholderapi.commands.impl.local.CommandInfo;
import me.clip.placeholderapi.commands.impl.local.CommandList;
import me.clip.placeholderapi.commands.impl.local.CommandParse;
import me.clip.placeholderapi.commands.impl.local.CommandReload;
import me.clip.placeholderapi.commands.impl.local.CommandVersion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.*;
import java.util.stream.Stream;
public final class PlaceholderCommandRouter implements CommandExecutor, TabCompleter
{
@Unmodifiable
private static final List<PlaceholderCommand> COMMANDS = ImmutableList.of(new CommandHelp(),
new CommandInfo(),
new CommandList(),
new CommandDump(),
new CommandECloud(),
new CommandParse(),
new CommandReload(),
new CommandVersion(),
new CommandExpansionRegister(),
new CommandExpansionUnregister());
@NotNull
private final PlaceholderAPIPlugin plugin;
@NotNull
@Unmodifiable
private final Map<String, PlaceholderCommand> commands;
public PlaceholderCommandRouter(@NotNull final PlaceholderAPIPlugin plugin)
{
this.plugin = plugin;
final ImmutableMap.Builder<String, PlaceholderCommand> commands = ImmutableMap.builder();
for (final PlaceholderCommand command : COMMANDS)
{
command.getLabels().forEach(label -> commands.put(label, command));
}
this.commands = commands.build();
}
@Override
public boolean onCommand(@NotNull final CommandSender sender, @NotNull final Command command, @NotNull final String alias, @NotNull final String[] args)
{
if (args.length == 0)
{
final PlaceholderCommand fallback = commands.get("version");
if (fallback != null)
{
fallback.evaluate(plugin, sender, "", Collections.emptyList());
}
return true;
}
final String search = args[0].toLowerCase();
final PlaceholderCommand target = commands.get(search);
if (target == null)
{
Msg.msg(sender, "&cUnknown command &7" + search);
return true;
}
final String permission = target.getPermission();
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission))
{
Msg.msg(sender, "&cYou do not have permission to do this!");
return true;
}
target.evaluate(plugin, sender, search, Arrays.asList(Arrays.copyOfRange(args, 1, args.length)));
return true;
}
@Override
public List<String> onTabComplete(@NotNull final CommandSender sender, @NotNull final Command command, @NotNull final String alias, @NotNull final String[] args)
{
final List<String> suggestions = new ArrayList<>();
if (args.length > 1)
{
final PlaceholderCommand target = this.commands.get(args[0].toLowerCase());
if (target != null)
{
target.complete(plugin, sender, args[0].toLowerCase(), Arrays.asList(Arrays.copyOfRange(args, 1, args.length)), suggestions);
}
return suggestions;
}
final Stream<String> targets = PlaceholderCommand.filterByPermission(sender, commands.values().stream()).map(PlaceholderCommand::getLabels).flatMap(Collection::stream);
PlaceholderCommand.suggestByParameter(targets, suggestions, args.length == 0 ? null : args[0]);
return suggestions;
}
}

View File

@@ -0,0 +1,150 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
public final class CommandECloud extends PlaceholderCommand
{
@Unmodifiable
private static final List<PlaceholderCommand> COMMANDS = ImmutableList.of(new CommandECloudClear(),
new CommandECloudToggle(),
new CommandECloudStatus(),
new CommandECloudUpdate(),
new CommandECloudRefresh(),
new CommandECloudDownload(),
new CommandECloudExpansionInfo(),
new CommandECloudExpansionList(),
new CommandECloudExpansionPlaceholders());
static
{
COMMANDS.forEach(command -> command.setPermission("placeholderapi.ecloud." + command.getLabel()));
}
@NotNull
@Unmodifiable
private final Map<String, PlaceholderCommand> commands;
public CommandECloud()
{
super("ecloud");
final ImmutableMap.Builder<String, PlaceholderCommand> commands = ImmutableMap.builder();
for (final PlaceholderCommand command : COMMANDS)
{
command.getLabels().forEach(label -> commands.put(label, command));
}
this.commands = commands.build();
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
if (params.isEmpty())
{
Msg.msg(sender,
"&b&lPlaceholderAPI &8- &7eCloud Help Menu &8- ",
" ",
"&b/papi &fecloud status",
" &7&oView status of the eCloud",
"&b/papi &fecloud list <all/{author}/installed> {page}",
" &7&oList all/author specific available expansions",
"&b/papi &fecloud info <expansion name> {version}",
" &7&oView information about a specific expansion available on the eCloud",
"&b/papi &fecloud placeholders <expansion name>",
" &7&oView placeholders for an expansion",
"&b/papi &fecloud download <expansion name> {version}",
" &7&oDownload an expansion from the eCloud",
"&b/papi &fecloud refresh",
" &7&oFetch the most up to date list of expansions available.",
"&b/papi &fecloud clear",
" &7&oClear the expansion cloud cache.");
return;
}
final String search = params.get(0).toLowerCase();
final PlaceholderCommand target = commands.get(search);
if (target == null)
{
Msg.msg(sender, "&cUnknown command &7ecloud " + search);
return;
}
final String permission = target.getPermission();
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission))
{
Msg.msg(sender, "&cYou do not have permission to do this!");
return;
}
if (!(target instanceof CommandECloudToggle) && !plugin.getPlaceholderAPIConfig().isCloudEnabled())
{
Msg.msg(sender,
"&cThe eCloud Manager is not enabled!");
return;
}
target.evaluate(plugin, sender, search, params.subList(1, params.size()));
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() <= 1)
{
final Stream<String> targets = filterByPermission(sender, commands.values().stream()).map(PlaceholderCommand::getLabels).flatMap(Collection::stream);
suggestByParameter(targets, suggestions, params.isEmpty() ? null : params.get(0));
return; // send sub commands
}
final String search = params.get(0).toLowerCase();
final PlaceholderCommand target = commands.get(search);
if (target == null)
{
return;
}
target.complete(plugin, sender, search, params.subList(1, params.size()), suggestions);
}
}

View File

@@ -0,0 +1,48 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
public final class CommandECloudClear extends PlaceholderCommand
{
public CommandECloudClear()
{
super("clear");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
plugin.getCloudExpansionManager().clean();
Msg.msg(sender,
"&aThe eCloud cache has been cleared!");
}
}

View File

@@ -0,0 +1,124 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
public final class CommandECloudDownload extends PlaceholderCommand
{
public CommandECloudDownload()
{
super("download");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
if (params.isEmpty())
{
Msg.msg(sender,
"&cYou must supply the name of an eCloud expansion.");
return;
}
final CloudExpansion expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).orElse(null);
if (expansion == null)
{
Msg.msg(sender,
"&cCould not find expansion named: &f" + params.get(0));
return;
}
final CloudExpansion.Version version;
if (params.size() < 2)
{
version = expansion.getVersion(expansion.getLatestVersion());
if (version == null)
{
Msg.msg(sender,
"&cCould not find latest version for expansion.");
return;
}
}
else
{
version = expansion.getVersion(params.get(1));
if (version == null)
{
Msg.msg(sender,
"&cCould not find specified version: &f" + params.get(1),
"&7Versions: &a" + expansion.getAvailableVersions());
return;
}
}
plugin.getCloudExpansionManager().downloadExpansion(expansion, version).whenComplete((file, exception) -> {
if (exception != null)
{
Msg.msg(sender,
"&cFailed to download expansion: &e" + exception.getMessage());
return;
}
Msg.msg(sender,
"&aSuccessfully downloaded expansion to file: &e" + file.getName());
plugin.getCloudExpansionManager().clean();
plugin.getCloudExpansionManager().fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
});
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() > 2)
{
return;
}
if (params.size() <= 1)
{
final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values().stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
return;
}
final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0));
if (!expansion.isPresent())
{
return;
}
suggestByParameter(expansion.get().getAvailableVersions().stream(), suggestions, params.get(1));
}
}

View File

@@ -0,0 +1,136 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
public final class CommandECloudExpansionInfo extends PlaceholderCommand
{
public CommandECloudExpansionInfo()
{
super("info");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
if (params.isEmpty())
{
Msg.msg(sender,
"&cYou must specify the name of the expansion.");
return;
}
final CloudExpansion expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).orElse(null);
if (expansion == null)
{
Msg.msg(sender,
"&cThere is no expansion with the name: &f" + params.get(0));
return;
}
final StringBuilder builder = new StringBuilder();
builder.append("&bExpansion: &f")
.append(expansion.shouldUpdate() ? "&e" : "&a")
.append(expansion.getName())
.append('\n')
.append("&bAuthor: &f")
.append(expansion.getAuthor())
.append('\n')
.append("&bVerified: ")
.append(expansion.isVerified() ? "&a&l✔" : "&c&l❌")
.append('\n');
if (params.size() < 2)
{
builder.append("&bLatest Version: &f")
.append(expansion.getLatestVersion())
.append('\n')
.append("&bReleased: &f")
.append(expansion.getTimeSinceLastUpdate())
.append(" ago")
.append('\n')
.append("&bRelease Notes: &f")
.append(expansion.getVersion().getReleaseNotes())
.append('\n');
}
else
{
final CloudExpansion.Version version = expansion.getVersion(params.get(1));
if (version == null)
{
Msg.msg(sender,
"&cCould not find specified version: &f" + params.get(1),
"&7Versions: &a" + expansion.getAvailableVersions());
return;
}
builder.append("&bVersion: &f")
.append(version.getVersion())
.append('\n')
.append("&bRelease Notes: &f")
.append(version.getReleaseNotes())
.append('\n')
.append("&bDownload URL: &f")
.append(version.getUrl())
.append('\n');
}
Msg.msg(sender, builder.toString());
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() > 2)
{
return;
}
if (params.size() <= 1)
{
final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values().stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
return;
}
final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0));
if (!expansion.isPresent())
{
return;
}
suggestByParameter(expansion.get().getAvailableVersions().stream(), suggestions, params.get(1));
}
}

View File

@@ -0,0 +1,360 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.primitives.Ints;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.configuration.ExpansionSort;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.Format;
import me.clip.placeholderapi.util.Msg;
import me.rayzr522.jsonmessage.JSONMessage;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public final class CommandECloudExpansionList extends PlaceholderCommand
{
private static final int PAGE_SIZE = 10;
@NotNull
private static final Function<CloudExpansion, Object> EXPANSION_NAME =
expansion -> (expansion.shouldUpdate() ? "&6" : expansion.hasExpansion() ? "&a" : "&7") + expansion.getName();
@NotNull
private static final Function<CloudExpansion, Object> EXPANSION_AUTHOR =
expansion -> "&f" + expansion.getAuthor();
@NotNull
private static final Function<CloudExpansion, Object> EXPANSION_VERIFIED =
expansion -> expansion.isVerified() ? "&aY" : "&cN";
@NotNull
private static final Function<CloudExpansion, Object> EXPANSION_LATEST_VERSION =
expansion -> "&f" + expansion.getLatestVersion();
@NotNull
private static final Function<CloudExpansion, Object> EXPANSION_CURRENT_VERSION =
expansion -> "&f" + PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByName(expansion.getName()).map(PlaceholderExpansion::getVersion).orElse("Unknown");
@Unmodifiable
private static final Set<String> OPTIONS = ImmutableSet.of("all", "installed");
public CommandECloudExpansionList()
{
super("list");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
if (params.isEmpty())
{
Msg.msg(sender,
"&cYou must specify an option. [all, {author}, installed]");
return;
}
final boolean installed = params.get(0).equalsIgnoreCase("installed");
final List<CloudExpansion> expansions = Lists.newArrayList(getExpansions(params.get(0), plugin));
if (expansions.isEmpty())
{
Msg.msg(sender,
"&cNo expansions available to list.");
return;
}
expansions.sort(plugin.getPlaceholderAPIConfig().getExpansionSort().orElse(ExpansionSort.LATEST));
if (!(sender instanceof Player) && params.size() < 2)
{
final StringBuilder builder = new StringBuilder();
addExpansionTitle(builder, params.get(0), -1);
addExpansionTable(expansions,
builder,
1,
installed ? "&9Version" : "&9Latest Version",
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION);
Msg.msg(sender, builder.toString());
return;
}
final int page;
if (params.size() < 2)
{
page = 1;
}
else
{
//noinspection UnstableApiUsage
final Integer parsed = Ints.tryParse(params.get(1));
if (parsed == null)
{
Msg.msg(sender,
"&cPage number must be an integer.");
return;
}
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
if (parsed < 1 || parsed > limit)
{
Msg.msg(sender,
"&cPage number must be in the range &8[&a1&7..&a" + limit + "&8]");
return;
}
page = parsed;
}
final StringBuilder builder = new StringBuilder();
final List<CloudExpansion> values = getPage(expansions, page - 1);
addExpansionTitle(builder, params.get(0), page);
if (!(sender instanceof Player))
{
addExpansionTable(values,
builder,
((page - 1) * PAGE_SIZE) + 1,
installed ? "&9Version" : "&9Latest Version",
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION);
Msg.msg(sender, builder.toString());
return;
}
Msg.msg(sender, builder.toString());
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
final JSONMessage message = getMessage(values, page, limit, params.get(0));
message.send(((Player) sender));
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() > 2)
{
return;
}
if (params.size() <= 1)
{
suggestByParameter(Sets.union(OPTIONS, plugin.getCloudExpansionManager().getCloudExpansionAuthors()).stream(), suggestions, params.isEmpty() ? null : params.get(0));
return;
}
suggestByParameter(IntStream.rangeClosed(1, (int) Math.ceil((double) getExpansions(params.get(0), plugin).size() / PAGE_SIZE)).mapToObj(Objects::toString), suggestions, params.get(1));
}
@NotNull
private static Collection<CloudExpansion> getExpansions(@NotNull final String target, @NotNull final PlaceholderAPIPlugin plugin)
{
switch (target.toLowerCase())
{
case "all":
return plugin.getCloudExpansionManager().getCloudExpansions().values();
case "installed":
return plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values();
default:
return plugin.getCloudExpansionManager().getCloudExpansionsByAuthor(target).values();
}
}
@NotNull
private static List<CloudExpansion> getPage(@NotNull final List<CloudExpansion> expansions, final int page)
{
final int head = (page * PAGE_SIZE);
final int tail = Math.min(expansions.size(), head + PAGE_SIZE);
if (expansions.size() < head)
{
return Collections.emptyList();
}
return expansions.subList(head, tail);
}
public static void addExpansionTitle(@NotNull final StringBuilder builder, @NotNull final String target, final int page)
{
switch (target.toLowerCase())
{
case "all":
builder.append("&bAll Expansions");
break;
case "installed":
builder.append("&bInstalled Expansions");
break;
default:
builder.append("&bExpansions by &6")
.append(target);
break;
}
if (page == -1)
{
builder.append('\n');
return;
}
builder.append(" &bPage&7: &a")
.append(page)
.append("&r")
.append('\n');
}
@NotNull
private static JSONMessage getMessage(@NotNull final List<CloudExpansion> expansions, final int page, final int limit, @NotNull final String target)
{
final SimpleDateFormat format = PlaceholderAPIPlugin.getDateFormat();
final StringBuilder tooltip = new StringBuilder();
final JSONMessage message = JSONMessage.create();
for (int index = 0; index < expansions.size(); index++)
{
final CloudExpansion expansion = expansions.get(index);
tooltip.append("&bClick to download this expansion!")
.append('\n')
.append('\n')
.append("&bAuthor: &f")
.append(expansion.getAuthor())
.append('\n')
.append("&bVerified: ")
.append(expansion.isVerified() ? "&a&l✔&r" : "&c&l❌&r")
.append('\n')
.append("&bLatest Version: &f")
.append(expansion.getLatestVersion())
.append('\n')
.append("&bReleased: &f")
.append(format.format(expansion.getLastUpdate()));
final String description = expansion.getDescription();
if (description != null && !description.isEmpty())
{
tooltip.append('\n')
.append('\n')
.append("&f")
.append(description.replace("\r", "").trim());
}
message.then(Msg.color("&8" + (index + ((page - 1) * PAGE_SIZE) + 1) + ".&r " + (expansion.shouldUpdate() ? "&6" : expansion.hasExpansion() ? "&a" : "&7") + expansion.getName()));
message.tooltip(Msg.color(tooltip.toString()));
message.suggestCommand("/papi ecloud download " + expansion.getName());
if (index < expansions.size() - 1)
{
message.newline();
}
tooltip.setLength(0);
}
if (limit > 1)
{
message.newline();
message.then("â—€")
.color(page > 1 ? ChatColor.GRAY : ChatColor.DARK_GRAY);
if (page > 1)
{
message.runCommand("/papi ecloud list " + target + " " + (page - 1));
}
message.then(" " + page + " ").color(ChatColor.GREEN);
message.then("â–¶")
.color(page < limit ? ChatColor.GRAY : ChatColor.DARK_GRAY);
if (page < limit)
{
message.runCommand("/papi ecloud list " + target + " " + (page + 1));
}
}
return message;
}
private static void addExpansionTable(@NotNull final List<CloudExpansion> expansions, @NotNull final StringBuilder message, final int startIndex, @NotNull final String versionTitle, @NotNull final Function<CloudExpansion, Object> versionFunction)
{
final Map<String, Function<CloudExpansion, Object>> functions = new LinkedHashMap<>();
final AtomicInteger counter = new AtomicInteger(startIndex);
functions.put("&f", expansion -> "&8" + counter.getAndIncrement() + ".");
functions.put("&9Name", EXPANSION_NAME);
functions.put("&9Author", EXPANSION_AUTHOR);
functions.put("&9Verified", EXPANSION_VERIFIED);
functions.put(versionTitle, versionFunction);
final List<List<String>> rows = new ArrayList<>();
rows.add(0, new ArrayList<>(functions.keySet()));
for (final CloudExpansion expansion : expansions)
{
rows.add(functions.values().stream().map(function -> function.apply(expansion)).map(Objects::toString).collect(Collectors.toList()));
}
final List<String> table = Format.tablify(Format.Align.LEFT, rows).orElse(Collections.emptyList());
if (table.isEmpty())
{
return;
}
table.add(1, "&8" + Strings.repeat("-", table.get(0).length() - (rows.get(0).size() * 2)));
message.append(String.join("\n", table));
}
}

View File

@@ -0,0 +1,96 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import com.google.common.collect.Lists;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public final class CommandECloudExpansionPlaceholders extends PlaceholderCommand
{
public CommandECloudExpansionPlaceholders()
{
super("placeholders");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
if (params.isEmpty())
{
Msg.msg(sender,
"&cYou must specify the name of the expansion.");
return;
}
final CloudExpansion expansion = plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).orElse(null);
if (expansion == null)
{
Msg.msg(sender,
"&cThere is no expansion with the name: &f" + params.get(0));
return;
}
final List<String> placeholders = expansion.getPlaceholders();
if (placeholders == null || placeholders.isEmpty())
{
Msg.msg(sender,
"&cThat expansion does not have placeholders listed.");
return;
}
final List<List<String>> partitions = Lists.partition(placeholders.stream().sorted().collect(Collectors.toList()), 10);
Msg.msg(sender,
"&6" + placeholders.size() + "&7 placeholders: &a",
partitions.stream().map(partition -> " " + String.join(", ", partition)).collect(Collectors.joining("\n")));
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() > 1)
{
return;
}
final Stream<String> names = plugin.getCloudExpansionManager()
.getCloudExpansions()
.values()
.stream()
.map(CloudExpansion::getName)
.map(name -> name.replace(' ', '_'));
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
}
}

View File

@@ -0,0 +1,50 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
public final class CommandECloudRefresh extends PlaceholderCommand
{
public CommandECloudRefresh()
{
super("refresh");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
plugin.getCloudExpansionManager().clean();
plugin.getCloudExpansionManager().fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
Msg.msg(sender,
"&aThe eCloud Manager has been refreshed!");
}
}

View File

@@ -0,0 +1,63 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
public final class CommandECloudStatus extends PlaceholderCommand
{
public CommandECloudStatus()
{
super("status");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
final CloudExpansionManager manager = plugin.getCloudExpansionManager();
final int updateCount = manager.getCloudUpdateCount();
final int authorCount = manager.getCloudExpansionAuthorCount();
final int expansionCount = manager.getCloudExpansions().size();
final StringBuilder builder = new StringBuilder();
builder.append("&bThere are &a").append(expansionCount).append("&b expansions available on the eCloud.").append('\n');
builder.append("&7A total of &f").append(authorCount).append("&7 authors have contributed to the eCloud.").append('\n');
if (updateCount > 0)
{
builder.append("&eYou have &a").append(updateCount).append("&e expansions installed that have updates available.");
}
Msg.msg(sender,builder.toString());
}
}

View File

@@ -0,0 +1,79 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
public final class CommandECloudToggle extends PlaceholderCommand
{
public CommandECloudToggle()
{
super("toggle", "enable", "disable");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
final boolean desiredState;
final boolean currentState = plugin.getPlaceholderAPIConfig().isCloudEnabled();
switch (alias.toLowerCase())
{
case "enable":
desiredState = true;
break;
case "disable":
desiredState = false;
break;
default:
desiredState = !currentState;
break;
}
if (desiredState == currentState)
{
Msg.msg(sender, "&7The eCloud Manager is already " + (desiredState ? "enabled" : "disabled"));
return;
}
plugin.getPlaceholderAPIConfig().setCloudEnabled(desiredState);
if (desiredState)
{
plugin.getCloudExpansionManager().load();
}
else
{
plugin.getCloudExpansionManager().kill();
}
Msg.msg(sender, "&aThe eCloud Manager has been " + (desiredState ? "enabled" : "disabled"));
}
}

View File

@@ -0,0 +1,145 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.cloud;
import com.google.common.collect.Lists;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.Futures;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
* please don't flame me for this code, I will fix this shit later.
*/
public final class CommandECloudUpdate extends PlaceholderCommand
{
public CommandECloudUpdate()
{
super("update");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
if (params.isEmpty())
{
Msg.msg(sender,
"&cYou must define 'all' or the name of an expansion to update.");
return;
}
final boolean multiple = params.get(0).equalsIgnoreCase("all");
final List<CloudExpansion> expansions = new ArrayList<>();
// gather target expansions
if (multiple)
{
expansions.addAll(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
}
else
{
plugin.getCloudExpansionManager().findCloudExpansionByName(params.get(0)).ifPresent(expansions::add);
}
// remove the ones that are the latest version
expansions.removeIf(expansion -> !expansion.shouldUpdate());
if (expansions.isEmpty())
{
Msg.msg(sender,
"&cNo updates available for " + (!multiple ? "this expansion." : "your active expansions."));
return;
}
Msg.msg(sender,
"&aUpdating expansions: " + expansions.stream().map(CloudExpansion::getName).collect(Collectors.joining("&7, &6", "&8[&6", "&8]&r")));
Futures.onMainThread(plugin, downloadAndDiscover(expansions, plugin), (classes, exception) -> {
if (exception != null)
{
Msg.msg(sender,
"&cFailed to update expansions: &e" + exception.getMessage());
return;
}
Msg.msg(sender,
"&aSuccessfully downloaded updates, registering new versions.");
final String message = classes.stream()
.filter(Objects::nonNull)
.map(plugin.getLocalExpansionManager()::register)
.filter(Optional::isPresent)
.map(Optional::get)
.map(expansion -> " &a" + expansion.getName() + " &f" + expansion.getVersion())
.collect(Collectors.joining("\n"));
Msg.msg(sender,
"&7Registered expansions:", message);
});
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() > 1)
{
return;
}
final List<CloudExpansion> installed = Lists.newArrayList(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
installed.removeIf(expansion -> !expansion.shouldUpdate());
if (!installed.isEmpty() && (params.isEmpty() || "all".startsWith(params.get(0).toLowerCase())))
{
suggestions.add("all");
}
suggestByParameter(installed.stream().map(CloudExpansion::getName).map(name -> name.replace(" ", "_")), suggestions, params.isEmpty() ? null : params.get(0));
}
private static CompletableFuture<List<@Nullable Class<? extends PlaceholderExpansion>>> downloadAndDiscover(@NotNull final List<CloudExpansion> expansions, @NotNull final PlaceholderAPIPlugin plugin)
{
return expansions.stream()
.map(expansion -> plugin.getCloudExpansionManager().downloadExpansion(expansion, expansion.getVersion()))
.map(future -> future.thenCompose(plugin.getLocalExpansionManager()::findExpansionInFile))
.collect(Futures.collector());
}
}

View File

@@ -0,0 +1,179 @@
package me.clip.placeholderapi.commands.impl.local;
import com.google.common.io.CharStreams;
import com.google.gson.JsonParser;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.logging.Level;
import java.util.stream.Collectors;
public final class CommandDump extends PlaceholderCommand
{
@NotNull
private static final String URL = "https://paste.helpch.at/";
@NotNull
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG)
.withLocale(Locale.US)
.withZone(ZoneId.of("UTC"));
public CommandDump()
{
super("dump");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
postDump(makeDump(plugin)).whenComplete((key, exception) -> {
if (exception != null)
{
plugin.getLogger().log(Level.WARNING, "failed to post dump details", exception);
Msg.msg(sender,
"&cFailed to post dump details, check console.");
return;
}
Msg.msg(sender,
"&aSuccessfully posted dump: " + URL + key);
});
}
@NotNull
private CompletableFuture<String> postDump(@NotNull final String dump)
{
return CompletableFuture.supplyAsync(() -> {
try
{
final HttpURLConnection connection = ((HttpURLConnection) new URL(URL + "documents").openConnection());
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
connection.setDoOutput(true);
connection.connect();
try (final OutputStream stream = connection.getOutputStream())
{
stream.write(dump.getBytes(StandardCharsets.UTF_8));
}
try (final InputStream stream = connection.getInputStream())
{
//noinspection UnstableApiUsage
final String json = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
return JsonParser.parseString(json).getAsJsonObject().get("key").getAsString();
}
}
catch (final IOException ex)
{
throw new CompletionException(ex);
}
});
}
@NotNull
private String makeDump(@NotNull final PlaceholderAPIPlugin plugin)
{
final StringBuilder builder = new StringBuilder();
builder.append("Generated: ")
.append(DATE_FORMAT.format(Instant.now()))
.append("\n\n");
builder.append("PlaceholderAPI: ")
.append(plugin.getDescription().getVersion())
.append("\n\n");
builder.append("Expansions Registered:")
.append('\n');
final Map<String, List<PlaceholderExpansion>> expansions = plugin.getLocalExpansionManager()
.getExpansions()
.stream()
.collect(Collectors.groupingBy(PlaceholderExpansion::getAuthor));
for (final Map.Entry<String, List<PlaceholderExpansion>> expansionsByAuthor : expansions.entrySet())
{
builder.append(" ")
.append(expansionsByAuthor.getKey())
.append(": ")
.append('\n');
for (final PlaceholderExpansion expansion : expansionsByAuthor.getValue())
{
builder.append(" ")
.append(expansion.getName())
.append(':')
.append(expansion.getVersion())
.append('\n');
}
}
builder.append('\n');
builder.append("Expansions Directory:")
.append('\n');
final String[] jars = plugin.getLocalExpansionManager()
.getExpansionsFolder()
.list((dir, name) -> name.toLowerCase().endsWith(".jar"));
for (final String jar : jars)
{
builder.append(" ")
.append(jar)
.append('\n');
}
builder.append('\n');
builder.append("Server Info: ")
.append(plugin.getServer().getBukkitVersion())
.append('/')
.append(plugin.getServer().getVersion())
.append("\n\n");
builder.append("Plugin Info:")
.append('\n');
for (final Plugin other : plugin.getServer().getPluginManager().getPlugins())
{
builder.append(" ")
.append(other.getName())
.append(": ")
.append(other.getDescription().getVersion())
.append('\n');
}
return builder.toString();
}
}

View File

@@ -0,0 +1,117 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.local;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
import me.clip.placeholderapi.util.Futures;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.logging.Level;
public final class CommandExpansionRegister extends PlaceholderCommand
{
public CommandExpansionRegister()
{
super("register");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
if (params.size() < 1)
{
Msg.msg(sender,
"&cYou must specify the name of an expansion file.");
return;
}
final LocalExpansionManager manager = plugin.getLocalExpansionManager();
final File file = new File(manager.getExpansionsFolder(), params.get(0));
if (!file.exists())
{
Msg.msg(sender,
"&cThe file &f" + file.getName() + "&c doesn't exist!");
return;
}
Futures.onMainThread(plugin, manager.findExpansionInFile(file), (clazz, exception) -> {
if (exception != null)
{
Msg.msg(sender,
"&cFailed to find expansion in file: &f" + file);
plugin.getLogger().log(Level.WARNING, "failed to find expansion in file: " + file, exception);
return;
}
if (clazz == null)
{
Msg.msg(sender,
"&cNo expansion class found in file: &f" + file);
return;
}
final Optional<PlaceholderExpansion> expansion = manager.register(clazz);
if (!expansion.isPresent())
{
Msg.msg(sender,
"&cFailed to register expansion from &f" + params.get(0));
return;
}
Msg.msg(sender,
"&aSuccessfully registered expansion: &f" + expansion.get().getName());
});
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() > 1)
{
return;
}
final String[] fileNames = plugin.getLocalExpansionManager().getExpansionsFolder().list((dir, name) -> name.endsWith(".jar"));
if (fileNames == null || fileNames.length == 0)
{
return;
}
suggestByParameter(Arrays.stream(fileNames), suggestions, params.isEmpty() ? null : params.get(0));
}
}

View File

@@ -0,0 +1,80 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.local;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
import java.util.Optional;
public final class CommandExpansionUnregister extends PlaceholderCommand
{
public CommandExpansionUnregister()
{
super("unregister");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
if (params.isEmpty())
{
Msg.msg(sender,
"&cYou must specify the name of the expansion.");
return;
}
final Optional<PlaceholderExpansion> expansion = plugin.getLocalExpansionManager().findExpansionByName(params.get(0));
if (!expansion.isPresent())
{
Msg.msg(sender,
"&cThere is no expansion loaded with the identifier: &f" + params.get(0));
return;
}
final String message = !expansion.get().unregister() ?
"&cFailed to unregister expansion: &f" :
"&aSuccessfully unregistered expansion: &f";
Msg.msg(sender, message + expansion.get().getName());
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() > 1)
{
return;
}
suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions, params.isEmpty() ? null : params.get(0));
}
}

View File

@@ -0,0 +1,70 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.local;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginDescriptionFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
public final class CommandHelp extends PlaceholderCommand
{
public CommandHelp()
{
super("help");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
final PluginDescriptionFile description = plugin.getDescription();
Msg.msg(sender,
"&b&lPlaceholderAPI &8- &7Help Menu &8- &7(&f" + description.getVersion() + "&7)",
" ",
"&b/papi",
" &7&oView plugin info/version",
"&b/papi &freload",
" &7&oReload the config of PAPI",
"&b/papi &flist",
" &7&oList active expansions",
"&b/papi &finfo &9<placeholder name>",
" &7&oView information for a specific expansion",
"&b/papi &fparse &9<me/player name> <message>",
" &7&oParse a message with placeholders",
"&b/papi &fbcparse &9<me/player name> <message>",
" &7&oParse a message with placeholders and broadcast it",
"&b/papi &fparserel &9<player one> <player two> <message>",
" &7&oParse a message with relational placeholders",
"&b/papi &fregister &9<file name>",
" &7&oRegister an expansion by the name of the file",
"&b/papi &funregister &9<expansion name>",
" &7&oUnregister an expansion by name");
}
}

View File

@@ -0,0 +1,120 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.local;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
public final class CommandInfo extends PlaceholderCommand
{
public CommandInfo()
{
super("info");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
if (params.isEmpty())
{
Msg.msg(sender,
"&cYou must specify the name of the expansion.");
return;
}
final PlaceholderExpansion expansion = plugin.getLocalExpansionManager().findExpansionByName(params.get(0)).orElse(null);
if (expansion == null)
{
Msg.msg(sender,
"&cThere is no expansion loaded with the identifier: &f" + params.get(0));
return;
}
final StringBuilder builder = new StringBuilder();
builder.append("&7Placeholder expansion info for: &r")
.append(expansion.getName())
.append('\n')
.append("&7Status: &r")
.append(expansion.isRegistered() ? "&aRegistered" : "7cNotRegistered")
.append('\n');
final String author = expansion.getAuthor();
if (author != null)
{
builder.append("&7Author: &r")
.append(author)
.append('\n');
}
final String version = expansion.getVersion();
if (version != null)
{
builder.append("&7Version: &r")
.append(version)
.append('\n');
}
final String requiredPlugin = expansion.getRequiredPlugin();
if (requiredPlugin != null)
{
builder.append("&7Requires plugin: &r")
.append(requiredPlugin)
.append('\n');
}
final List<String> placeholders = expansion.getPlaceholders();
if (placeholders != null && !placeholders.isEmpty())
{
builder.append("&8&m-- &7Placeholders &8&m--&r")
.append('\n');
for (final String placeholder : placeholders)
{
builder.append(placeholder)
.append('\n');
}
}
Msg.msg(sender, builder.toString());
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() > 1)
{
return;
}
suggestByParameter(PlaceholderAPI.getRegisteredIdentifiers().stream(), suggestions, params.isEmpty() ? null : params.get(0));
}
}

View File

@@ -0,0 +1,62 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.local;
import com.google.common.collect.Lists;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public final class CommandList extends PlaceholderCommand
{
public CommandList()
{
super("list");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
final Set<String> identifiers = PlaceholderAPI.getRegisteredIdentifiers();
if (identifiers.isEmpty())
{
Msg.msg(sender, "&6There are no placeholder hooks active!");
return;
}
final List<List<String>> partitions = Lists.partition(identifiers.stream().sorted().collect(Collectors.toList()), 10);
Msg.msg(sender,
"&6" + identifiers.size() + "&7 placeholder hook(s) active: &a",
partitions.stream().map(partition -> " " + String.join(", ", partition)).collect(Collectors.joining("\n")));
}
}

View File

@@ -0,0 +1,243 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.local;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
public final class CommandParse extends PlaceholderCommand
{
public CommandParse()
{
super("parse", "bcparse", "parserel", "cmdparse");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
switch (alias.toLowerCase())
{
case "parserel":
evaluateParseRelation(sender, params);
break;
case "parse":
evaluateParseSingular(sender, params, false, false);
break;
case "bcparse":
evaluateParseSingular(sender, params, true, false);
break;
case "cmdparse":
evaluateParseSingular(sender, params, false, true);
break;
}
}
@Override
public void complete(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
switch (alias.toLowerCase())
{
case "parserel":
completeParseRelation(params, suggestions);
break;
case "parse":
case "bcparse":
case "cmdparse":
completeParseSingular(sender, params, suggestions);
break;
}
}
private void evaluateParseSingular(@NotNull final CommandSender sender, @NotNull @Unmodifiable final List<String> params, final boolean broadcast, final boolean command)
{
if (params.size() < 2)
{
Msg.msg(sender, "&cYou must supply a target, and a message: &b/papi " + (broadcast ? "bcparse" : "parse") + " &7{target} &a{message}");
return;
}
@NotNull final OfflinePlayer player;
if ("me".equalsIgnoreCase(params.get(0)))
{
if (!(sender instanceof Player))
{
Msg.msg(sender, "&cYou must be a player to use &7me&c as a target!");
return;
}
player = ((Player) sender);
}
else
{
final OfflinePlayer target = resolvePlayer(params.get(0));
if (target == null)
{
Msg.msg(sender, "&cFailed to find player: &7" + params.get(0));
return;
}
player = target;
}
final String message = PlaceholderAPI.setPlaceholders(player, String.join(" ", params.subList(1, params.size())));
if (command)
{
Bukkit.dispatchCommand(sender, message);
return;
}
if (broadcast)
{
Msg.broadcast(message);
}
else
{
if (!(sender instanceof Player))
{
Msg.msg(sender, message);
}
else
{
sender.spigot().sendMessage(TextComponent.fromLegacyText(message));
}
}
}
private void evaluateParseRelation(@NotNull final CommandSender sender, @NotNull @Unmodifiable final List<String> params)
{
if (params.size() < 3)
{
Msg.msg(sender, "&cYou must supply two targets, and a message: &b/papi parserel &7{target one} {target two} &a{message}");
return;
}
final OfflinePlayer targetOne = resolvePlayer(params.get(0));
if (targetOne == null || !targetOne.isOnline())
{
Msg.msg(sender, "&cFailed to find player: &7" + params.get(0));
return;
}
final OfflinePlayer targetTwo = resolvePlayer(params.get(1));
if (targetTwo == null || !targetTwo.isOnline())
{
Msg.msg(sender, "&cFailed to find player: &7" + params.get(1));
return;
}
final String message = PlaceholderAPI.setRelationalPlaceholders(((Player) targetOne), ((Player) targetTwo), String.join(" ", params.subList(2, params.size())));
Msg.msg(sender, message);
}
private void completeParseSingular(@NotNull final CommandSender sender, @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() <= 1)
{
if (sender instanceof Player && (params.isEmpty() || "me".startsWith(params.get(0).toLowerCase())))
{
suggestions.add("me");
}
final Stream<String> names = Bukkit.getOnlinePlayers().stream().map(Player::getName);
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
return;
}
final String name = params.get(params.size() - 1);
if (!name.startsWith("%") || name.endsWith("%"))
{
return;
}
final int index = name.indexOf('_');
if (index == -1)
{
return; // no arguments supplied yet
}
final PlaceholderExpansion expansion = PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByIdentifier(name.substring(1, index)).orElse(null);
if (expansion == null)
{
return;
}
final Set<String> possible = new HashSet<>(expansion.getPlaceholders());
PlaceholderAPIPlugin.getInstance()
.getCloudExpansionManager()
.findCloudExpansionByName(expansion.getName())
.ifPresent(cloud -> possible.addAll(cloud.getPlaceholders()));
suggestByParameter(possible.stream(), suggestions, params.get(params.size() - 1));
}
private void completeParseRelation(@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions)
{
if (params.size() > 2)
{
return;
}
final Stream<String> names = Bukkit.getOnlinePlayers().stream().map(Player::getName);
suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(params.size() - 1));
}
@Nullable
private OfflinePlayer resolvePlayer(@NotNull final String name)
{
OfflinePlayer target = Bukkit.getPlayer(name);
if (target == null)
{
target = Bukkit.getOfflinePlayer(name); // this is probably not a great idea.
}
return target.hasPlayedBefore() ? target : null;
}
}

View File

@@ -0,0 +1,45 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.local;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
public final class CommandReload extends PlaceholderCommand
{
public CommandReload()
{
super("reload");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
plugin.reloadConf(sender);
}
}

View File

@@ -0,0 +1,54 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.commands.impl.local;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginDescriptionFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
public final class CommandVersion extends PlaceholderCommand
{
public CommandVersion()
{
super("version");
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
final PluginDescriptionFile description = plugin.getDescription();
Msg.msg(sender,
"&b&lPlaceholderAPI &e(&f" + description.getVersion() + "&e)",
"&fAuthors&8: &6" + description.getAuthors(),
"&fPAPI Commands&8: &b/papi &7help",
"&feCloud Commands&8: &b/papi &7ecloud");
}
}

View File

@@ -0,0 +1,31 @@
package me.clip.placeholderapi.configuration;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import org.jetbrains.annotations.NotNull;
import java.util.Comparator;
public enum ExpansionSort implements Comparator<CloudExpansion>
{
NAME(Comparator.comparing(CloudExpansion::getName)),
AUTHOR(Comparator.comparing(CloudExpansion::getAuthor)),
LATEST(Comparator.comparing(CloudExpansion::getLastUpdate).reversed());
@NotNull
private final Comparator<CloudExpansion> comparator;
ExpansionSort(@NotNull final Comparator<CloudExpansion> comparator)
{
this.comparator = comparator;
}
@Override
public final int compare(final CloudExpansion expansion1, final CloudExpansion expansion2)
{
return comparator.compare(expansion1, expansion2);
}
}

View File

@@ -1,66 +1,107 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import org.jetbrains.annotations.NotNull;
public class PlaceholderAPIConfig {
import java.util.Optional;
private PlaceholderAPIPlugin plugin;
public final class PlaceholderAPIConfig
{
public PlaceholderAPIConfig(PlaceholderAPIPlugin i) {
plugin = i;
@NotNull
private final PlaceholderAPIPlugin plugin;
public PlaceholderAPIConfig(@NotNull final PlaceholderAPIPlugin plugin)
{
this.plugin = plugin;
}
public void loadDefConfig() {
plugin.saveDefaultConfig();
plugin.reloadConfig();
}
public boolean checkUpdates() {
public boolean checkUpdates()
{
return plugin.getConfig().getBoolean("check_updates");
}
public boolean cloudAllowUnverifiedExpansions() {
public boolean cloudAllowUnverifiedExpansions()
{
return plugin.getConfig().getBoolean("cloud_allow_unverified_expansions");
}
public boolean isCloudEnabled() {
public boolean isCloudEnabled()
{
return plugin.getConfig().getBoolean("cloud_enabled");
}
public void setCloudEnabled(boolean b) {
plugin.getConfig().set("cloud_enabled", b);
plugin.reloadConfig();
public void setCloudEnabled(boolean state)
{
plugin.getConfig().set("cloud_enabled", state);
plugin.saveConfig();
}
public String booleanTrue() {
return plugin.getConfig().getString("boolean.true");
public boolean isDebugMode()
{
return plugin.getConfig().getBoolean("debug", false);
}
public String booleanFalse() {
return plugin.getConfig().getString("boolean.false");
public Optional<ExpansionSort> getExpansionSort()
{
final String option = plugin.getConfig().getString("cloud_sorting", ExpansionSort.LATEST.name());
try
{
//noinspection ConstantConditions (bad spigot annotation)
return Optional.of(ExpansionSort.valueOf(option.toUpperCase()));
}
catch (final IllegalArgumentException ignored)
{
return Optional.empty();
}
}
public String dateFormat() {
return plugin.getConfig().getString("date_format");
@NotNull
public String dateFormat()
{
//noinspection ConstantConditions (bad spigot annotation)
return plugin.getConfig().getString("date_format", "MM/dd/yy HH:mm:ss");
}
@NotNull
public String booleanTrue()
{
//noinspection ConstantConditions (bad spigot annotation)
return plugin.getConfig().getString("boolean.true", "true");
}
@NotNull
public String booleanFalse()
{
//noinspection ConstantConditions (bad spigot annotation)
return plugin.getConfig().getString("boolean.false", "false");
}
}

View File

@@ -1,48 +1,80 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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 me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class ExpansionRegisterEvent extends Event {
public final class ExpansionRegisterEvent extends Event implements Cancellable
{
@NotNull
private static final HandlerList HANDLERS = new HandlerList();
private PlaceholderExpansion expansion;
public ExpansionRegisterEvent(PlaceholderExpansion expansion) {
private boolean cancelled;
@NotNull
private final PlaceholderExpansion expansion;
public ExpansionRegisterEvent(@NotNull final PlaceholderExpansion expansion)
{
this.expansion = expansion;
}
public static HandlerList getHandlerList() {
return HANDLERS;
@NotNull
public PlaceholderExpansion getExpansion()
{
return expansion;
}
@Override
public boolean isCancelled()
{
return cancelled;
}
@Override
public HandlerList getHandlers() {
public void setCancelled(boolean cancelled)
{
this.cancelled = cancelled;
}
@NotNull
@Override
public HandlerList getHandlers()
{
return HANDLERS;
}
public PlaceholderExpansion getExpansion() {
return expansion;
@NotNull
public static HandlerList getHandlerList()
{
return HANDLERS;
}
}

View File

@@ -1,48 +1,65 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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 me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class ExpansionUnregisterEvent extends Event {
public final class ExpansionUnregisterEvent extends Event
{
@NotNull
private static final HandlerList HANDLERS = new HandlerList();
private PlaceholderExpansion expansion;
public ExpansionUnregisterEvent(PlaceholderExpansion expansion) {
@NotNull
private final PlaceholderExpansion expansion;
public ExpansionUnregisterEvent(@NotNull final PlaceholderExpansion expansion)
{
this.expansion = expansion;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
public PlaceholderExpansion getExpansion() {
@NotNull
public PlaceholderExpansion getExpansion()
{
return expansion;
}
@NotNull
@Override
public HandlerList getHandlers()
{
return HANDLERS;
}
@NotNull
public static HandlerList getHandlerList()
{
return HANDLERS;
}
}

View File

@@ -1,55 +1,77 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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 me.clip.placeholderapi.PlaceholderHook;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* @deprecated This event is no longer used.
*/
@Deprecated
public class PlaceholderHookUnloadEvent extends Event {
public final class PlaceholderHookUnloadEvent extends Event
{
@NotNull
private static final HandlerList HANDLERS = new HandlerList();
private String plugin;
private PlaceholderHook hook;
public PlaceholderHookUnloadEvent(String plugin, PlaceholderHook placeholderHook) {
@NotNull
private final String plugin;
@NotNull
private final PlaceholderHook placeholderHook;
public PlaceholderHookUnloadEvent(@NotNull final String plugin, @NotNull final PlaceholderHook placeholderHook)
{
this.plugin = plugin;
this.hook = placeholderHook;
this.placeholderHook = placeholderHook;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
public String getHookName() {
@NotNull
public String getHookName()
{
return plugin;
}
public PlaceholderHook getHook() {
return hook;
@NotNull
public PlaceholderHook getHook()
{
return placeholderHook;
}
@NotNull
@Override
public HandlerList getHandlers()
{
return HANDLERS;
}
@NotNull
public static HandlerList getHandlerList()
{
return HANDLERS;
}
}

View File

@@ -0,0 +1,28 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.exceptions;
public final class NoDefaultCommandException extends RuntimeException {
public NoDefaultCommandException(final String message) {
super(message);
}
}

View File

@@ -1,23 +1,23 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion;
/**

View File

@@ -1,23 +1,23 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion;
import org.bukkit.entity.Player;

View File

@@ -1,23 +1,23 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion;
import java.util.Map;

View File

@@ -1,183 +0,0 @@
/*
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
*
* This program 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.
*
* This program 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.expansion;
import java.io.File;
import java.lang.reflect.Constructor;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.PlaceholderHook;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.FileUtil;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.Listener;
public final class ExpansionManager {
private PlaceholderAPIPlugin plugin;
public ExpansionManager(PlaceholderAPIPlugin instance) {
plugin = instance;
File f = new File(PlaceholderAPIPlugin.getInstance().getDataFolder(), "expansions");
if (!f.exists()) {
f.mkdirs();
}
}
public PlaceholderExpansion getRegisteredExpansion(String name) {
for (Entry<String, PlaceholderHook> hook : PlaceholderAPI.getPlaceholders().entrySet()) {
if (hook.getValue() instanceof PlaceholderExpansion) {
if (name.equalsIgnoreCase(hook.getKey())) {
return (PlaceholderExpansion) hook.getValue();
}
}
}
return null;
}
public boolean registerExpansion(PlaceholderExpansion expansion) {
if (expansion == null || expansion.getIdentifier() == null) {
return false;
}
if (expansion instanceof Configurable) {
Map<String, Object> defaults = ((Configurable) expansion).getDefaults();
String pre = "expansions." + expansion.getIdentifier() + ".";
FileConfiguration cfg = plugin.getConfig();
boolean save = false;
for (Entry<String, Object> entries : defaults.entrySet()) {
if (entries.getKey() == null || entries.getKey().isEmpty()) {
continue;
}
if (entries.getValue() == null) {
if (cfg.contains(pre + entries.getKey())) {
save = true;
cfg.set(pre + entries.getKey(), null);
}
} else {
if (!cfg.contains(pre + entries.getKey())) {
save = true;
cfg.set(pre + entries.getKey(), entries.getValue());
}
}
}
if (save) {
plugin.saveConfig();
plugin.reloadConfig();
}
}
if (expansion instanceof VersionSpecific) {
VersionSpecific nms = (VersionSpecific) expansion;
if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion())) {
plugin.getLogger()
.info(
"Your server version is not compatible with expansion: " + expansion.getIdentifier()
+ " version: " + expansion.getVersion());
return false;
}
}
if (!expansion.canRegister()) {
return false;
}
if (!expansion.register()) {
return false;
}
if (expansion instanceof Listener) {
Listener l = (Listener) expansion;
Bukkit.getPluginManager().registerEvents(l, plugin);
}
plugin.getLogger().info("Successfully registered expansion: " + expansion.getIdentifier());
if (expansion instanceof Taskable) {
((Taskable) expansion).start();
}
if (plugin.getExpansionCloud() != null) {
CloudExpansion ce = plugin.getExpansionCloud().getCloudExpansion(expansion.getIdentifier());
if (ce != null) {
ce.setHasExpansion(true);
if (!ce.getLatestVersion().equals(expansion.getVersion())) {
ce.setShouldUpdate(true);
}
}
}
return true;
}
public PlaceholderExpansion registerExpansion(String fileName) {
List<Class<?>> subs = FileUtil.getClasses("expansions", fileName, PlaceholderExpansion.class);
if (subs == null || subs.isEmpty()) {
return null;
}
// only register the first instance found as an expansion jar should only have 1 class
// extending PlaceholderExpansion
PlaceholderExpansion ex = createInstance(subs.get(0));
if (registerExpansion(ex)) {
return ex;
}
return null;
}
public void registerAllExpansions() {
if (plugin == null) {
return;
}
List<Class<?>> subs = FileUtil.getClasses("expansions", null, PlaceholderExpansion.class);
if (subs == null || subs.isEmpty()) {
return;
}
for (Class<?> klass : subs) {
PlaceholderExpansion ex = createInstance(klass);
if (ex != null) {
registerExpansion(ex);
}
}
}
private PlaceholderExpansion createInstance(Class<?> klass) {
if (klass == null) {
return null;
}
PlaceholderExpansion ex = null;
if (!PlaceholderExpansion.class.isAssignableFrom(klass)) {
return null;
}
try {
Constructor<?>[] c = klass.getConstructors();
if (c.length == 0) {
ex = (PlaceholderExpansion) klass.newInstance();
} else {
for (Constructor<?> con : c) {
if (con.getParameterTypes().length == 0) {
ex = (PlaceholderExpansion) klass.newInstance();
break;
}
}
}
} catch (Throwable t) {
plugin.getLogger()
.severe("Failed to init placeholder expansion from class: " + klass.getName());
plugin.getLogger().severe(t.getMessage());
}
return ex;
}
}

View File

@@ -1,23 +1,23 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion;
public enum NMSVersion {
@@ -37,9 +37,11 @@ public enum NMSVersion {
SPIGOT_1_12_R1("v1_12_R1"),
SPIGOT_1_13_R1("v1_13_R1"),
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_16_R1("v1_16_R1");
private String version;
private final String version;
NMSVersion(String version) {
this.version = version;
@@ -51,6 +53,7 @@ public enum NMSVersion {
return v;
}
}
return NMSVersion.UNKNOWN;
}

View File

@@ -1,49 +1,48 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion;
import java.util.List;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.PlaceholderHook;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class PlaceholderExpansion extends PlaceholderHook {
import java.util.Collections;
import java.util.List;
import java.util.Objects;
public abstract class PlaceholderExpansion extends PlaceholderHook
{
/**
* The name of this expansion
*
* @return {@link #getIdentifier()} by default, name of this expansion if specified
*/
public String getName() {
return getIdentifier();
}
/**
* The placeholder identifier of this expanion
* The placeholder identifier of this expansion
*
* @return placeholder identifier that is associated with this expansion
*/
@NotNull
public abstract String getIdentifier();
/**
@@ -51,6 +50,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
*
* @return name of the author for this expansion
*/
@NotNull
public abstract String getAuthor();
/**
@@ -58,15 +58,36 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
*
* @return current version of this expansion
*/
@NotNull
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 the plugin that this expansion hooks into. by default will return the deprecated
* {@link #getPlugin()} method
* The name of this expansion
*
* @return {@link #getIdentifier()} by default, name of this expansion if specified
*/
@NotNull
public String getName()
{
return getIdentifier();
}
/**
* The name of the plugin that this expansion hooks into. by default will null
*
* @return plugin name that this expansion requires to function
*/
public String getRequiredPlugin() {
@Nullable
public String getRequiredPlugin()
{
return getPlugin();
}
@@ -75,10 +96,13 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
*
* @return placeholder list that this expansion provides
*/
public List<String> getPlaceholders() {
return null;
@NotNull
public List<String> getPlaceholders()
{
return Collections.emptyList();
}
/**
* Expansions that do not use the ecloud and instead register from the dependency should set this
* to true to ensure that your placeholder expansion is not unregistered when the papi reload
@@ -86,98 +110,171 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
*
* @return if this expansion should persist through placeholder reloads
*/
public boolean persist() {
public boolean persist()
{
return false;
}
/**
* Check if this placeholder identfier has already been registered
* Check if this placeholder identifier has already been registered
*
* @return true if the identifier for this expansion is already registered
*/
public boolean isRegistered() {
Validate.notNull(getIdentifier(), "Placeholder identifier can not be null!");
return PlaceholderAPI.getRegisteredIdentifiers().contains(getIdentifier());
public final boolean isRegistered()
{
return getPlaceholderAPI().getLocalExpansionManager().findExpansionByIdentifier(getIdentifier()).map(it -> it.equals(this)).orElse(false);
}
/**
* If any requirements need to be checked before this expansion should register, you can check
* them here
*
* @return true if this hook meets all the requirements to register
*/
public boolean canRegister() {
return getRequiredPlugin() == null
|| Bukkit.getPluginManager().getPlugin(getRequiredPlugin()) != null;
public boolean canRegister()
{
return getRequiredPlugin() == null || Bukkit.getPluginManager().getPlugin(getRequiredPlugin()) != null;
}
/**
* Attempt to register this PlaceholderExpansion
*
* @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.
*/
public boolean register() {
Validate.notNull(getIdentifier(), "Placeholder identifier can not be null!");
return PlaceholderAPI.registerExpansion(this);
@Deprecated
public boolean register()
{
return canRegister() && getPlaceholderAPI().getLocalExpansionManager().register(this);
}
/**
* Attempt to unregister this PlaceholderExpansion
*
* @return true if this expansion is now unregistered with PlaceholderAPI
*/
public final boolean unregister()
{
return getPlaceholderAPI().getLocalExpansionManager().unregister(this);
}
/**
* Quick getter for the {@link PlaceholderAPIPlugin} instance
*
* @return {@link PlaceholderAPIPlugin} instance
*/
public PlaceholderAPIPlugin getPlaceholderAPI() {
@NotNull
public final PlaceholderAPIPlugin getPlaceholderAPI()
{
return PlaceholderAPIPlugin.getInstance();
}
public String getString(String path, String def) {
return getPlaceholderAPI().getConfig()
.getString("expansions." + getIdentifier() + "." + path, def);
}
public int getInt(String path, int def) {
return getPlaceholderAPI().getConfig()
.getInt("expansions." + getIdentifier() + "." + path, def);
}
// === Configuration ===
public long getLong(String path, long def) {
return getPlaceholderAPI().getConfig()
.getLong("expansions." + getIdentifier() + "." + path, def);
}
public double getDouble(String path, double def) {
return getPlaceholderAPI().getConfig()
.getDouble("expansions." + getIdentifier() + "." + path, def);
}
public List<String> getStringList(String path) {
return getPlaceholderAPI().getConfig()
.getStringList("expansions." + getIdentifier() + "." + path);
}
public Object get(String path, Object def) {
return getPlaceholderAPI().getConfig().get("expansions." + getIdentifier() + "." + path, def);
}
public ConfigurationSection getConfigSection(String path) {
return getPlaceholderAPI().getConfig()
.getConfigurationSection("expansions." + getIdentifier() + "." + path);
}
public ConfigurationSection getConfigSection() {
@Nullable
public final ConfigurationSection getConfigSection()
{
return getPlaceholderAPI().getConfig().getConfigurationSection("expansions." + getIdentifier());
}
public boolean configurationContains(String path) {
return getPlaceholderAPI().getConfig().contains("expansions." + getIdentifier() + "." + path);
@Nullable
public final ConfigurationSection getConfigSection(@NotNull final String path)
{
final ConfigurationSection section = getConfigSection();
return section == null ? null : section.getConfigurationSection(path);
}
@Nullable
@Contract("_, !null -> !null")
public final Object get(@NotNull final String path, final Object def)
{
final ConfigurationSection section = getConfigSection();
return section == null ? def : section.get(path, def);
}
public final int getInt(@NotNull final String path, final int def)
{
final ConfigurationSection section = getConfigSection();
return section == null ? def : section.getInt(path, def);
}
public final long getLong(@NotNull final String path, final long def)
{
final ConfigurationSection section = getConfigSection();
return section == null ? def : section.getLong(path, def);
}
public final double getDouble(@NotNull final String path, final double def)
{
final ConfigurationSection section = getConfigSection();
return section == null ? def : section.getDouble(path, def);
}
@Nullable
@Contract("_, !null -> !null")
public final String getString(@NotNull final String path, @Nullable final String def)
{
final ConfigurationSection section = getConfigSection();
return section == null ? def : section.getString(path, def);
}
@NotNull
public final List<String> getStringList(@NotNull final String path)
{
final ConfigurationSection section = getConfigSection();
return section == null ? Collections.emptyList() : section.getStringList(path);
}
public final boolean configurationContains(@NotNull final String path)
{
final ConfigurationSection section = getConfigSection();
return section != null && section.contains(path);
}
@Override
public final boolean equals(final Object o)
{
if (this == o)
{
return true;
}
if (!(o instanceof PlaceholderExpansion))
{
return false;
}
final PlaceholderExpansion expansion = (PlaceholderExpansion) o;
return getIdentifier().equals(expansion.getIdentifier()) &&
getAuthor().equals(expansion.getAuthor()) &&
getVersion().equals(expansion.getVersion());
}
@Override
public final int hashCode()
{
return Objects.hash(getIdentifier(), 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
public String getPlugin() {
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public String getPlugin()
{
return null;
}
@@ -185,7 +282,9 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to show a description
*/
@Deprecated
public String getDescription() {
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public String getDescription()
{
return null;
}
@@ -193,7 +292,10 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to display a link
*/
@Deprecated
public String getLink() {
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public String getLink()
{
return null;
}
}

View File

@@ -1,23 +1,23 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion;
import org.bukkit.entity.Player;

View File

@@ -1,23 +1,23 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion;

View File

@@ -1,30 +1,29 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion;
public final class Version {
private boolean isSpigot;
private String version;
private final boolean isSpigot;
private final String version;
public Version(String version, boolean isSpigot) {
this.version = version;

View File

@@ -1,23 +1,23 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion;
/**

View File

@@ -1,29 +1,30 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.expansion.cloud;
import me.clip.placeholderapi.util.TimeUtil;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import me.clip.placeholderapi.util.TimeUtil;
public class CloudExpansion {
@@ -172,7 +173,6 @@ public class CloudExpansion {
}
public class Version {
private String url, version, release_notes;
public String getUrl() {

View File

@@ -1,345 +0,0 @@
/*
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
*
* This program 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.
*
* This program 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.expansion.cloud;
import com.google.gson.Gson;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.google.gson.reflect.TypeToken;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class ExpansionCloudManager {
private static final String API_URL = "http://api.extendedclip.com/v2/";
private static final Gson GSON = new Gson();
private final PlaceholderAPIPlugin plugin;
private final File expansionsDir;
private final List<String> downloading = new ArrayList<>();
private final Map<Integer, CloudExpansion> remote = new TreeMap<>();
public ExpansionCloudManager(PlaceholderAPIPlugin plugin) {
this.plugin = plugin;
expansionsDir = new File(plugin.getDataFolder(), "expansions");
final boolean result = expansionsDir.mkdirs();
if (result) {
plugin.getLogger().info("Created Expansions Directory");
}
}
public void clean() {
remote.clear();
downloading.clear();
}
public Map<Integer, CloudExpansion> getCloudExpansions() {
return remote;
}
public CloudExpansion getCloudExpansion(String name) {
return remote.values()
.stream()
.filter(ex -> ex.getName().equalsIgnoreCase(name))
.findFirst()
.orElse(null);
}
public int getCloudAuthorCount() {
return remote.values()
.stream()
.collect(Collectors.groupingBy(CloudExpansion::getAuthor, Collectors.counting()))
.size();
}
public int getToUpdateCount() {
return ((int) PlaceholderAPI.getExpansions()
.stream()
.filter(ex -> getCloudExpansion(ex.getName()) != null && getCloudExpansion(ex.getName()).shouldUpdate())
.count());
}
public Map<Integer, CloudExpansion> getAllByAuthor(String author) {
if (remote.isEmpty()) return new HashMap<>();
Map<Integer, CloudExpansion> byAuthor = new TreeMap<>();
for (CloudExpansion ex : remote.values()) {
if (!ex.getAuthor().equalsIgnoreCase(author)) continue;
byAuthor.put(byAuthor.size(), ex);
}
return byAuthor;
}
public Map<Integer, CloudExpansion> getAllInstalled() {
if (remote.isEmpty()) return new HashMap<>();
Map<Integer, CloudExpansion> has = new TreeMap<>();
for (CloudExpansion ex : remote.values()) {
if (!ex.hasExpansion()) continue;
has.put(has.size(), ex);
}
return has;
}
public int getPagesAvailable(Map<Integer, CloudExpansion> map, int amount) {
if (map == null) {
return 0;
}
int pages = map.size() > 0 ? 1 : 0;
if (pages == 0) {
return pages;
}
if (map.size() > amount) {
pages = map.size() / amount;
if (map.size() % amount > 0) {
pages++;
}
}
return pages;
}
public Map<Integer, CloudExpansion> getPage(Map<Integer, CloudExpansion> map, int page, int size) {
if (map == null || map.size() == 0 || page > getPagesAvailable(map, size)) {
return new HashMap<>();
}
int end = size * page;
int start = end - size;
Map<Integer, CloudExpansion> ex = new TreeMap<>();
IntStream.range(start, end).forEach(n -> ex.put(n, map.get(n)));
return ex;
}
public void fetch(boolean allowUnverified) {
plugin.getLogger().info("Fetching available expansion information...");
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
final String readJson = URLReader.read(API_URL);
final Map<String, CloudExpansion> data = GSON.fromJson(readJson, new TypeToken<Map<String, CloudExpansion>>() {
}.getType());
final List<CloudExpansion> unsorted = new ArrayList<>();
data.forEach((name, cexp) -> {
if ((allowUnverified || cexp.isVerified()) && cexp.getLatestVersion() != null && cexp.getVersion(cexp.getLatestVersion()) != null) {
cexp.setName(name);
PlaceholderExpansion ex = plugin.getExpansionManager().getRegisteredExpansion(cexp.getName());
if (ex != null && ex.isRegistered()) {
cexp.setHasExpansion(true);
if (!ex.getVersion().equals(cexp.getLatestVersion())) {
cexp.setShouldUpdate(true);
}
}
unsorted.add(cexp);
}
});
unsorted.sort(Comparator.comparing(CloudExpansion::getLastUpdate).reversed());
int count = 0;
for (CloudExpansion e : unsorted) {
remote.put(count++, e);
}
plugin.getLogger().info(count + " placeholder expansions are available on the cloud.");
long updates = getToUpdateCount();
if (updates > 0) {
plugin.getLogger().info(updates + " installed expansions have updates available.");
}
});
}
public boolean isDownloading(String expansion) {
return downloading.contains(expansion);
}
private void download(URL url, String name) throws IOException {
InputStream is = null;
FileOutputStream fos = null;
try {
URLConnection urlConn = url.openConnection();
is = urlConn.getInputStream();
fos = new FileOutputStream(
expansionsDir.getAbsolutePath() + File.separator + "Expansion-" + name + ".jar");
byte[] buffer = new byte[is.available()];
int l;
while ((l = is.read(buffer)) > 0) {
fos.write(buffer, 0, l);
}
} finally {
try {
if (is != null) {
is.close();
}
} finally {
if (fos != null) {
fos.close();
}
}
}
}
public void downloadExpansion(final String player, final CloudExpansion ex) {
downloadExpansion(player, ex, ex.getLatestVersion());
}
public void downloadExpansion(final String player, final CloudExpansion ex, final String version) {
if (downloading.contains(ex.getName())) {
return;
}
final CloudExpansion.Version ver = ex.getVersions()
.stream()
.filter(v -> v.getVersion().equals(version))
.findFirst()
.orElse(null);
if (ver == null) {
return;
}
downloading.add(ex.getName());
plugin.getLogger().info("Attempting download of expansion: " + ex.getName() + (player != null ? " by user: " + player : "") + " from url: " + ver.getUrl());
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
download(new URL(ver.getUrl()), ex.getName());
plugin.getLogger().info("Download of expansion: " + ex.getName() + " complete!");
} catch (Exception e) {
plugin.getLogger()
.warning("Failed to download expansion: " + ex.getName() + " from: " + ver.getUrl());
Bukkit.getScheduler().runTask(plugin, () -> {
downloading.remove(ex.getName());
if (player != null) {
Player p = Bukkit.getPlayer(player);
if (p != null) {
Msg.msg(p, "&cThere was a problem downloading expansion: &f" + ex.getName());
}
}
});
return;
}
Bukkit.getScheduler().runTask(plugin, () -> {
downloading.remove(ex.getName());
if (player != null) {
Player p = Bukkit.getPlayer(player);
if (p != null) {
Msg.msg(p, "&aExpansion &f" + ex.getName() + " &adownload complete!");
}
}
});
});
}
private static class URLReader {
static String read(String url) {
StringBuilder builder = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(url).openStream()))) {
String inputLine;
while ((inputLine = reader.readLine()) != null) {
builder.append(inputLine);
}
} catch (Exception ex) {
builder.setLength(0);
}
return builder.toString();
}
}
}

View File

@@ -0,0 +1,288 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.expansion.manager;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Resources;
import com.google.gson.Gson;
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.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Type;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.stream.Collector;
import java.util.stream.Collectors;
public final class CloudExpansionManager
{
@NotNull
private static final String API_URL = "http://api.extendedclip.com/v2/";
@NotNull
private static final Gson GSON = new Gson();
@NotNull
private static final Type TYPE = new TypeToken<Map<String, CloudExpansion>>() {}.getType();
@NotNull
private final Collector<CloudExpansion, ?, Map<String, CloudExpansion>> INDEXED_NAME_COLLECTOR = Collectors.toMap(CloudExpansionManager::toIndexName, Function.identity());
@NotNull
private final PlaceholderAPIPlugin plugin;
@NotNull
private final Map<String, CloudExpansion> cache = new HashMap<>();
@NotNull
private final Map<String, CompletableFuture<File>> await = new ConcurrentHashMap<>();
public CloudExpansionManager(@NotNull final PlaceholderAPIPlugin plugin)
{
this.plugin = plugin;
}
public void load()
{
clean();
fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
}
public void kill()
{
clean();
}
@NotNull
@Unmodifiable
public Map<String, CloudExpansion> getCloudExpansions()
{
return ImmutableMap.copyOf(cache);
}
@NotNull
@Unmodifiable
public Map<String, CloudExpansion> getCloudExpansionsInstalled()
{
if (cache.isEmpty())
{
return Collections.emptyMap();
}
return cache.values()
.stream()
.filter(CloudExpansion::hasExpansion)
.collect(INDEXED_NAME_COLLECTOR);
}
@NotNull
@Unmodifiable
public Map<String, CloudExpansion> getCloudExpansionsByAuthor(@NotNull final String author)
{
if (cache.isEmpty())
{
return Collections.emptyMap();
}
return cache.values()
.stream()
.filter(expansion -> author.equalsIgnoreCase(expansion.getAuthor()))
.collect(INDEXED_NAME_COLLECTOR);
}
@NotNull
@Unmodifiable
public Set<String> getCloudExpansionAuthors()
{
return cache.values().stream().map(CloudExpansion::getAuthor).collect(Collectors.toSet());
}
public int getCloudExpansionAuthorCount()
{
return getCloudExpansionAuthors().size();
}
public int getCloudUpdateCount()
{
return ((int) plugin.getLocalExpansionManager()
.getExpansions()
.stream()
.filter(expansion -> findCloudExpansionByName(expansion.getName()).map(CloudExpansion::shouldUpdate).orElse(false))
.count());
}
@NotNull
public Optional<CloudExpansion> findCloudExpansionByName(@NotNull final String name)
{
return Optional.ofNullable(cache.get(toIndexName(name)));
}
public void clean()
{
cache.clear();
await.values().forEach(future -> future.cancel(true));
await.clear();
}
public void fetch(final boolean allowUnverified)
{
plugin.getLogger().info("Fetching available expansion information...");
CompletableFuture<Map<String, CloudExpansion>> future = CompletableFuture.supplyAsync(() -> {
final Map<String, CloudExpansion> values = new HashMap<>();
try
{
//noinspection UnstableApiUsage
final String json = Resources.toString(new URL(API_URL), StandardCharsets.UTF_8);
values.putAll(GSON.fromJson(json, TYPE));
}
catch (final IOException ex)
{
throw new CompletionException(ex);
}
values.values().removeIf(value -> value.getLatestVersion() == null || value.getVersion(value.getLatestVersion()) == null);
return values;
});
if (!allowUnverified)
{
future = future.thenApplyAsync((values) -> {
values.values().removeIf(expansion -> !expansion.isVerified());
return values;
});
}
future = future.thenApplyAsync((values) -> {
values.forEach((name, expansion) -> {
expansion.setName(name);
final Optional<PlaceholderExpansion> local = plugin.getLocalExpansionManager().findExpansionByName(name);
if (local.isPresent() && local.get().isRegistered())
{
expansion.setHasExpansion(true);
expansion.setShouldUpdate(!local.get().getVersion().equals(expansion.getLatestVersion()));
}
});
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)
{
return await.containsKey(toIndexName(expansion));
}
@NotNull
public CompletableFuture<File> downloadExpansion(@NotNull final CloudExpansion expansion, @NotNull final CloudExpansion.Version version)
{
final CompletableFuture<File> previous = await.get(toIndexName(expansion));
if (previous != null)
{
return previous;
}
final File file = new File(plugin.getLocalExpansionManager().getExpansionsFolder(), "Expansion-" + toIndexName(expansion) + ".jar");
final CompletableFuture<File> download = CompletableFuture.supplyAsync(() -> {
try (final ReadableByteChannel source = Channels.newChannel(new URL(version.getUrl()).openStream()); final FileOutputStream target = new FileOutputStream(file))
{
target.getChannel().transferFrom(source, 0, Long.MAX_VALUE);
}
catch (final IOException ex)
{
throw new CompletionException(ex);
}
return file;
});
download.whenCompleteAsync((value, exception) -> {
await.remove(toIndexName(expansion));
if (exception != null)
{
plugin.getLogger().log(Level.SEVERE, "failed to download " + expansion.getName() + ":" + version.getVersion(), exception);
}
});
await.put(toIndexName(expansion), 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());
}
}

View File

@@ -0,0 +1,424 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.expansion.manager;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.events.ExpansionRegisterEvent;
import me.clip.placeholderapi.events.ExpansionUnregisterEvent;
import me.clip.placeholderapi.expansion.*;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.FileUtil;
import me.clip.placeholderapi.util.Futures;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.PluginDisableEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
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.CompletionException;
import java.util.logging.Level;
public final class LocalExpansionManager implements Listener
{
@NotNull
private static final String EXPANSIONS_FOLDER_NAME = "expansions";
@NotNull
private final File folder;
@NotNull
private final PlaceholderAPIPlugin plugin;
@NotNull
private final Map<String, PlaceholderExpansion> expansions = new HashMap<>();
public LocalExpansionManager(@NotNull final PlaceholderAPIPlugin plugin)
{
this.plugin = plugin;
this.folder = new File(plugin.getDataFolder(), EXPANSIONS_FOLDER_NAME);
if (!this.folder.exists() && !folder.mkdirs())
{
plugin.getLogger().log(Level.WARNING, "failed to create expansions folder!");
}
}
public void load(@NotNull final CommandSender sender)
{
registerAll(sender);
}
public void kill()
{
unregisterAll();
}
@NotNull
public File getExpansionsFolder()
{
return folder;
}
public int getExpansionsCount()
{
return expansions.size();
}
@NotNull
@Unmodifiable
public Collection<String> getIdentifiers()
{
return ImmutableSet.copyOf(expansions.keySet());
}
@NotNull
@Unmodifiable
public Collection<PlaceholderExpansion> getExpansions()
{
return ImmutableSet.copyOf(expansions.values());
}
@Nullable
public PlaceholderExpansion getExpansion(@NotNull final String identifier)
{
return expansions.get(identifier.toLowerCase());
}
@NotNull
public Optional<PlaceholderExpansion> findExpansionByName(@NotNull final String name)
{
return expansions.values().stream().filter(expansion -> name.equalsIgnoreCase(expansion.getName())).findFirst();
}
@NotNull
public Optional<PlaceholderExpansion> findExpansionByIdentifier(@NotNull final String identifier)
{
return Optional.ofNullable(getExpansion(identifier));
}
public Optional<PlaceholderExpansion> register(@NotNull final Class<? extends PlaceholderExpansion> clazz)
{
try
{
final PlaceholderExpansion expansion = createExpansionInstance(clazz);
if (expansion == null || !expansion.register())
{
return Optional.empty();
}
return Optional.of(expansion);
}
catch (final LinkageError ex)
{
plugin.getLogger().severe("expansion class " + clazz.getSimpleName() + " is outdated: \n" +
"Failed to load due to a [" + ex.getClass().getSimpleName() + "], attempted to use " + ex.getMessage());
}
return Optional.empty();
}
/**
* Do not call this method yourself, use {@link PlaceholderExpansion#register()}
*/
@ApiStatus.Internal
public boolean register(@NotNull final PlaceholderExpansion expansion)
{
final String identifier = expansion.getIdentifier();
if (expansion instanceof Configurable)
{
Map<String, Object> defaults = ((Configurable) expansion).getDefaults();
String pre = "expansions." + expansion.getIdentifier() + ".";
FileConfiguration cfg = plugin.getConfig();
boolean save = false;
if (defaults != null)
{
for (Map.Entry<String, Object> entries : defaults.entrySet())
{
if (entries.getKey() == null || entries.getKey().isEmpty())
{
continue;
}
if (entries.getValue() == null)
{
if (cfg.contains(pre + entries.getKey()))
{
save = true;
cfg.set(pre + entries.getKey(), null);
}
}
else
{
if (!cfg.contains(pre + entries.getKey()))
{
save = true;
cfg.set(pre + entries.getKey(), entries.getValue());
}
}
}
}
if (save)
{
plugin.saveConfig();
plugin.reloadConfig();
}
}
if (expansion instanceof VersionSpecific)
{
VersionSpecific nms = (VersionSpecific) expansion;
if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion()))
{
plugin.getLogger().info("Your server version is not compatible with expansion: " + expansion.getIdentifier() + " version: " + expansion.getVersion());
return false;
}
}
final PlaceholderExpansion removed = expansions.get(expansion.getIdentifier());
if (removed != null && !removed.unregister())
{
return false;
}
final ExpansionRegisterEvent event = new ExpansionRegisterEvent(expansion);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
{
return false;
}
expansions.put(expansion.getIdentifier(), expansion);
if (expansion instanceof Listener)
{
Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);
}
plugin.getLogger().info("Successfully registered expansion: " + expansion.getIdentifier());
if (expansion instanceof Taskable)
{
((Taskable) expansion).start();
}
if (plugin.getPlaceholderAPIConfig().isCloudEnabled())
{
final Optional<CloudExpansion> cloudExpansion = plugin.getCloudExpansionManager().findCloudExpansionByName(identifier);
if (cloudExpansion.isPresent())
{
cloudExpansion.get().setHasExpansion(true);
cloudExpansion.get().setShouldUpdate(!cloudExpansion.get().getLatestVersion().equals(expansion.getVersion()));
}
}
return true;
}
/**
* Do not call this method yourself, use {@link PlaceholderExpansion#unregister()}
*/
@ApiStatus.Internal
public boolean unregister(@NotNull final PlaceholderExpansion expansion)
{
if (expansions.remove(expansion.getIdentifier()) == null)
{
return false;
}
Bukkit.getPluginManager().callEvent(new ExpansionUnregisterEvent(expansion));
if (expansion instanceof Listener)
{
HandlerList.unregisterAll((Listener) expansion);
}
if (expansion instanceof Taskable)
{
((Taskable) expansion).stop();
}
if (expansion instanceof Cacheable)
{
((Cacheable) expansion).clear();
}
if (plugin.getPlaceholderAPIConfig().isCloudEnabled())
{
plugin.getCloudExpansionManager().findCloudExpansionByName(expansion.getName()).ifPresent(cloud -> {
cloud.setHasExpansion(false);
cloud.setShouldUpdate(false);
});
}
return true;
}
private void registerAll(@NotNull final CommandSender sender)
{
plugin.getLogger().info("Placeholder expansion registration initializing...");
Futures.onMainThread(plugin, findExpansionsOnDisk(), (classes, exception) -> {
if (exception != null)
{
plugin.getLogger().log(Level.SEVERE, "failed to load class files of expansions", exception);
return;
}
final long registered = classes.stream().map(this::register).filter(Optional::isPresent).count();
Msg.msg(sender,
registered == 0 ? "&6No expansions were registered!" : registered + "&a placeholder hooks successfully registered!");
});
}
private void unregisterAll()
{
for (final PlaceholderExpansion expansion : Sets.newHashSet(expansions.values()))
{
if (expansion.persist())
{
continue;
}
expansion.unregister();
}
}
@NotNull
public CompletableFuture<@NotNull List<@NotNull Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk()
{
return Arrays.stream(folder.listFiles((dir, name) -> name.endsWith(".jar")))
.map(this::findExpansionInFile)
.collect(Futures.collector());
}
@NotNull
public CompletableFuture<@Nullable Class<? extends PlaceholderExpansion>> findExpansionInFile(@NotNull final File file)
{
return CompletableFuture.supplyAsync(() -> {
try
{
return FileUtil.findClass(file, PlaceholderExpansion.class);
}
catch (final VerifyError ex)
{
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;
}
catch (final Exception ex)
{
throw new CompletionException(ex);
}
});
}
@Nullable
public PlaceholderExpansion createExpansionInstance(@NotNull final Class<? extends PlaceholderExpansion> clazz) throws LinkageError
{
try
{
return clazz.getDeclaredConstructor().newInstance();
}
catch (final Exception ex)
{
if (ex.getCause() instanceof LinkageError)
{
throw ((LinkageError) ex.getCause());
}
plugin.getLogger().log(Level.SEVERE, "Failed to load placeholder expansion from class: " + clazz.getName(), ex);
return null;
}
}
@EventHandler
public void onQuit(@NotNull final PlayerQuitEvent event)
{
for (final PlaceholderExpansion expansion : getExpansions())
{
if (!(expansion instanceof Cleanable))
{
continue;
}
((Cleanable) expansion).cleanup(event.getPlayer());
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPluginDisable(@NotNull final PluginDisableEvent event)
{
final String name = event.getPlugin().getName();
if (name.equals(plugin.getName()))
{
return;
}
for (final PlaceholderExpansion expansion : getExpansions())
{
if (!name.equalsIgnoreCase(expansion.getRequiredPlugin()))
{
continue;
}
expansion.unregister();
plugin.getLogger().info("Unregistered placeholder expansion: " + expansion.getName());
}
}
}

View File

@@ -1,57 +0,0 @@
/*
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
*
* This program 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.
*
* This program 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.external;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderHook;
import org.apache.commons.lang.Validate;
import org.bukkit.plugin.Plugin;
@Deprecated
public abstract class EZPlaceholderHook extends PlaceholderHook {
private String identifier;
private String plugin;
public EZPlaceholderHook(Plugin plugin, String identifier) {
Validate.notNull(plugin, "Plugin can not be null!");
Validate.notNull(identifier, "Placeholder name can not be null!");
this.identifier = identifier;
this.plugin = plugin.getName();
}
public boolean isHooked() {
return PlaceholderAPI.getRegisteredPlaceholderPlugins().contains(identifier);
}
public boolean hook() {
return PlaceholderAPI.registerPlaceholderHook(identifier, this);
}
public String getPlaceholderName() {
return identifier;
}
public String getPluginName() {
return plugin;
}
}

View File

@@ -0,0 +1,61 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.listeners;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerLoadEvent;
import org.jetbrains.annotations.NotNull;
public final class ServerLoadEventListener implements Listener
{
@NotNull
private final PlaceholderAPIPlugin plugin;
public ServerLoadEventListener(@NotNull final PlaceholderAPIPlugin plugin)
{
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
}
/**
* This method will be called when the server is first loaded
* <p>
* The goal of the method is to register all the expansions as soon as possible
* especially before players can join
* <p>
* This will ensure no issues with expansions and hooks.
*
* @param event the server load event
*/
@EventHandler
public void onServerLoad(@NotNull final ServerLoadEvent event)
{
HandlerList.unregisterAll(this);
plugin.getLocalExpansionManager().load(Bukkit.getConsoleSender());
}
}

View File

@@ -0,0 +1,200 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.replacer;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.Function;
public final class CharsReplacer implements Replacer
{
@NotNull
private final Closure closure;
public CharsReplacer(@NotNull final Closure closure)
{
this.closure = closure;
}
@NotNull
@Override
public String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup)
{
final char[] chars = text.toCharArray();
final StringBuilder builder = new StringBuilder(text.length());
final StringBuilder identifier = new StringBuilder();
final StringBuilder parameters = new StringBuilder();
for (int i = 0; i < chars.length; i++)
{
final char l = chars[i];
if (l == '&' && ++i < chars.length)
{
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')
{
builder.append(l).append(chars[i]);
}
else
{
builder.append(ChatColor.COLOR_CHAR);
if (c != 'x')
{
builder.append(chars[i]);
continue;
}
if ((i > 1 && chars[i - 2] == '\\') /*allow escaping &x*/)
{
builder.setLength(builder.length() - 2);
builder.append('&').append(chars[i]);
continue;
}
builder.append(c);
int j = 0;
while (++j <= 6)
{
if (i + j >= chars.length)
{
break;
}
final char x = chars[i + j];
builder.append(ChatColor.COLOR_CHAR).append(x);
}
if (j == 7)
{
i += 6;
}
else
{
builder.setLength(builder.length() - (j * 2)); // undo &x parsing
}
}
continue;
}
if (l != closure.head || i + 1 >= chars.length)
{
builder.append(l);
continue;
}
boolean identified = false;
boolean oopsitsbad = true;
while (++i < chars.length)
{
final char p = chars[i];
if (p == ' ' && !identified)
{
break;
}
if (p == closure.tail)
{
oopsitsbad = false;
break;
}
if (p == '_' && !identified)
{
identified = true;
continue;
}
if (identified)
{
parameters.append(p);
}
else
{
identifier.append(p);
}
}
final String identifierString = identifier.toString();
final String parametersString = parameters.toString();
identifier.setLength(0);
parameters.setLength(0);
if (oopsitsbad)
{
builder.append(closure.head).append(identifierString);
if (identified)
{
builder.append('_').append(parametersString);
}
builder.append(' ');
continue;
}
final PlaceholderExpansion placeholder = lookup.apply(identifierString);
if (placeholder == null)
{
builder.append(closure.head).append(identifierString);
if (identified)
{
builder.append('_');
}
builder.append(parametersString).append(closure.tail);
continue;
}
final String replacement = placeholder.onRequest(player, parametersString);
if (replacement == null)
{
builder.append(closure.head).append(identifierString);
if (identified)
{
builder.append('_');
}
builder.append(parametersString).append(closure.tail);
continue;
}
builder.append(replacement);
}
return builder.toString();
}
}

View File

@@ -0,0 +1,76 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.replacer;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class RegexReplacer implements Replacer
{
@NotNull
private final Pattern pattern;
public RegexReplacer(@NotNull final Closure closure)
{
this.pattern = Pattern.compile(String.format("\\%s((?<identifier>[a-zA-Z0-9]+)_)(?<parameters>[^%s%s]+)\\%s", closure.head, closure.head, closure.tail, closure.tail));
}
@NotNull
@Override
public String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup)
{
final Matcher matcher = pattern.matcher(text);
if (!matcher.find())
{
return text;
}
final StringBuffer builder = new StringBuffer();
do
{
final String identifier = matcher.group("identifier");
final String parameters = matcher.group("parameters");
final PlaceholderExpansion expansion = lookup.apply(identifier);
if (expansion == null)
{
continue;
}
final String requested = expansion.onRequest(player, parameters);
matcher.appendReplacement(builder, requested != null ? requested : matcher.group(0));
}
while (matcher.find());
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(builder).toString());
}
}

View File

@@ -0,0 +1,52 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.replacer;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.Function;
public interface Replacer
{
@NotNull
String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup);
enum Closure
{
BRACKET('{', '}'),
PERCENT('%', '%');
public final char head, tail;
Closure(final char head, final char tail)
{
this.head = head;
this.tail = tail;
}
}
}

View File

@@ -1,9 +1,25 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.updatechecker;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.Bukkit;
@@ -12,11 +28,17 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
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 {
private final int RESOURCE_ID = 6245;
private PlaceholderAPIPlugin plugin;
private String spigotVersion, pluginVersion;
private final PlaceholderAPIPlugin plugin;
private final String pluginVersion;
private String spigotVersion;
private boolean updateAvailable;
public UpdateChecker(PlaceholderAPIPlugin i) {
@@ -68,6 +90,7 @@ public class UpdateChecker implements Listener {
if (spigotVersion == null || spigotVersion.isEmpty()) {
return false;
}
String plV = toReadable(pluginVersion);
String spV = toReadable(spigotVersion);
return plV.compareTo(spV) < 0;
@@ -77,6 +100,7 @@ public class UpdateChecker implements Listener {
if (version.contains("-DEV-")) {
version = version.split("-DEV-")[0];
}
return version.replaceAll("\\.", "");
}

View File

@@ -1,93 +1,84 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.util;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
public class FileUtil {
public class FileUtil
{
public static List<Class<?>> getClasses(String folder, Class<?> type) {
return getClasses(folder, null, type);
}
public static List<Class<?>> getClasses(String folder, String fileName, Class<?> type) {
List<Class<?>> list = new ArrayList<>();
try {
File f = new File(PlaceholderAPIPlugin.getInstance().getDataFolder(), folder);
if (!f.exists()) {
return list;
}
FilenameFilter fileNameFilter = (dir, name) -> {
if (fileName != null) {
return name.endsWith(".jar") && name.replace(".jar", "")
.equalsIgnoreCase(fileName.replace(".jar", ""));
}
return name.endsWith(".jar");
};
File[] jars = f.listFiles(fileNameFilter);
if (jars == null) {
return list;
}
for (File file : jars) {
list = gather(file.toURI().toURL(), list, type);
}
return list;
} catch (Throwable t) {
}
@Nullable
public static <T> Class<? extends T> findClass(@NotNull final File file, @NotNull final Class<T> clazz) throws IOException, ClassNotFoundException
{
if (!file.exists())
{
return null;
}
private static List<Class<?>> gather(URL jar, List<Class<?>> list, Class<?> clazz) {
if (list == null) {
list = new ArrayList<>();
}
try (URLClassLoader cl = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader()); JarInputStream jis = new JarInputStream(jar.openStream())) {
while (true) {
JarEntry j = jis.getNextJarEntry();
if (j == null) {
break;
}
String name = j.getName();
if (name == null || name.isEmpty()) {
final URL jar = file.toURI().toURL();
final List<String> matches = new ArrayList<>();
final List<Class<? extends T>> classes = new ArrayList<>();
try (final JarInputStream stream = new JarInputStream(jar.openStream()); final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader()))
{
JarEntry entry;
while ((entry = stream.getNextJarEntry()) != null)
{
final String name = entry.getName();
if (name == null || name.isEmpty() || !name.endsWith(".class"))
{
continue;
}
if (name.endsWith(".class")) {
name = name.replace("/", ".");
String cname = name.substring(0, name.lastIndexOf(".class"));
Class<?> c = cl.loadClass(cname);
if (clazz.isAssignableFrom(c)) {
list.add(c);
matches.add(name.substring(0, name.lastIndexOf('.')).replace('/', '.'));
}
for (final String match : matches)
{
try
{
final Class<?> loaded = loader.loadClass(match);
if (clazz.isAssignableFrom(loaded))
{
classes.add(loaded.asSubclass(clazz));
}
}
catch (final NoClassDefFoundError ignored)
{ }
}
} catch (Throwable t) {
}
return list;
return classes.isEmpty() ? null : classes.get(0);
}
}

View File

@@ -0,0 +1,78 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.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.min;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import static java.util.stream.IntStream.range;
/**
* For the record, I am not sorry.
*/
public final class Format
{
private Format()
{}
public enum Align
{
LEFT, RIGHT
}
@NotNull
public static Optional<List<String>> tablify(@NotNull final Align align, @NotNull final List<List<String>> rows)
{
return findSpacing(rows)
.map(spacing -> buildFormat(align, spacing))
.map(format -> rows.stream()
.map(row -> String.format(format, row.toArray()).substring(align == Align.RIGHT ? 2 : 0))
.collect(toList()));
}
@NotNull
private static String buildFormat(@NotNull final Align align, @NotNull final int[] spacing)
{
return stream(spacing)
.mapToObj(space -> "%" + (align == Align.LEFT ? "-" : "") + (space + 2) + "s")
.collect(joining());
}
@NotNull
private static Optional<int[]> findSpacing(@NotNull final List<List<String>> rows)
{
return rows.stream()
.map(row -> row.stream().mapToInt(String::length).toArray())
.reduce((l, r) -> range(0, min(l.length, r.length)).map(i -> max(l[i], r[i])).toArray());
}
}

View File

@@ -0,0 +1,63 @@
package me.clip.placeholderapi.util;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public final class Futures
{
private Futures()
{}
public static <T> void onMainThread(@NotNull final Plugin plugin, @NotNull final CompletableFuture<T> future, @NotNull final BiConsumer<T, Throwable> consumer)
{
future.whenComplete((value, exception) -> {
if (Bukkit.isPrimaryThread())
{
consumer.accept(value, exception);
}
else
{
Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(value, exception));
}
});
}
@NotNull
public static <T> Collector<CompletableFuture<T>, ?, CompletableFuture<List<T>>> collector()
{
return Collectors.collectingAndThen(Collectors.toList(), Futures::of);
}
@NotNull
public static <T> CompletableFuture<List<T>> of(@NotNull final Stream<CompletableFuture<T>> futures)
{
return of(futures.collect(Collectors.toList()));
}
@NotNull
public static <T> CompletableFuture<List<T>> of(@NotNull final Collection<CompletableFuture<T>> futures)
{
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
.thenApplyAsync($ -> awaitCompletion(futures));
}
@NotNull
private static <T> List<T> awaitCompletion(@NotNull final Collection<CompletableFuture<T>> futures)
{
return futures.stream().map(CompletableFuture::join).collect(Collectors.toList());
}
}

View File

@@ -1,41 +1,59 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.util;
import java.util.Arrays;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class Msg {
import java.util.Arrays;
import java.util.stream.Collectors;
public static void msg(CommandSender s, String... msg) {
Arrays.stream(msg).map(Msg::color).forEach(s::sendMessage);
public final class Msg
{
public static void msg(@NotNull final CommandSender sender, @NotNull final String... messages)
{
if (messages.length == 0)
{
return;
}
public static void broadcast(String... msg) {
Arrays.stream(msg).map(Msg::color).forEach(Bukkit::broadcastMessage);
sender.sendMessage(Arrays.stream(messages).map(Msg::color).collect(Collectors.joining("\n")));
}
public static String color(String text) {
public static void broadcast(@NotNull final String... messages)
{
if (messages.length == 0)
{
return;
}
Bukkit.broadcastMessage(Arrays.stream(messages).map(Msg::color).collect(Collectors.joining("\n")));
}
public static String color(@NotNull final String text)
{
return ChatColor.translateAlternateColorCodes('&', text);
}
}

View File

@@ -1,27 +1,26 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.util;
public enum TimeFormat {
DAYS,
HOURS,
MINUTES,

View File

@@ -1,29 +1,31 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (C) 2018 Ryan McCarthy
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* This program is 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.util;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
public class TimeUtil {
public static String getRemaining(int seconds, TimeFormat type) {
if (seconds < 60) {
switch (type) {
case DAYS:
@@ -33,12 +35,14 @@ public class TimeUtil {
case SECONDS:
return String.valueOf(seconds);
}
return String.valueOf(seconds);
}
int minutes = seconds / 60;
int s = 60 * minutes;
int secondsLeft = seconds - s;
if (minutes < 60) {
switch (type) {
case DAYS:
@@ -49,6 +53,7 @@ public class TimeUtil {
case SECONDS:
return String.valueOf(secondsLeft);
}
return String.valueOf(seconds);
}
@@ -56,6 +61,7 @@ public class TimeUtil {
int hours = minutes / 60;
int inMins = 60 * hours;
int leftOver = minutes - inMins;
switch (type) {
case DAYS:
return "0";
@@ -66,6 +72,7 @@ public class TimeUtil {
case SECONDS:
return String.valueOf(secondsLeft);
}
return String.valueOf(seconds);
}
@@ -84,12 +91,14 @@ public class TimeUtil {
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);
@@ -100,60 +109,62 @@ public class TimeUtil {
case SECONDS:
return String.valueOf(secondsLeft);
}
return String.valueOf(seconds);
}
}
public static String getTime(int seconds) {
if (seconds < 60) {
return seconds + "s";
return getTime(Duration.ofSeconds(seconds));
}
int minutes = seconds / 60;
int s = 60 * minutes;
int secondsLeft = seconds - s;
if (minutes < 60) {
if (secondsLeft > 0) {
return minutes + "m " + secondsLeft + "s";
} else {
return minutes + "m";
}
}
if (minutes < 1440) {
String time;
int hours = minutes / 60;
time = hours + "h";
int inMins = 60 * hours;
int leftOver = minutes - inMins;
if (leftOver >= 1) {
time = time + " " + leftOver + "m";
}
if (secondsLeft > 0) {
time = time + " " + secondsLeft + "s";
}
return time;
/**
* Format the given value with s, m, h and d (seconds, minutes, hours and days)
*
* @param duration {@link Duration} (eg, Duration.of(20, {@link ChronoUnit#SECONDS}) for 20 seconds)
* @return formatted time
*/
public static String getTime(final Duration duration) {
final StringBuilder builder = new StringBuilder();
long seconds = duration.getSeconds();
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;
seconds %= 60;
minutes %= 60;
hours %= 60;
days %= 24;
if (seconds > 0) {
builder.insert(0, seconds + "s");
}
String time;
int days = minutes / 1440;
time = days + "d";
int inMins = 1440 * days;
int leftOver = minutes - inMins;
if (leftOver >= 1) {
if (leftOver < 60) {
time = time + " " + leftOver + "m";
} else {
int hours = leftOver / 60;
time = time + " " + hours + "h";
int hoursInMins = 60 * hours;
int minsLeft = leftOver - hoursInMins;
time = time + " " + minsLeft + "m";
if (minutes > 0) {
if (builder.length() > 0) {
builder.insert(0, ' ');
}
builder.insert(0, minutes + "m");
}
if (secondsLeft > 0) {
time = time + " " + secondsLeft + "s";
if (hours > 0) {
if (builder.length() > 0) {
builder.insert(0, ' ');
}
return time;
builder.insert(0, hours + "h");
}
if (days > 0) {
if (builder.length() > 0) {
builder.insert(0, ' ');
}
builder.insert(0, days + "d");
}
return builder.toString();
}
}

View File

@@ -1,5 +1,5 @@
# PlaceholderAPI
# Version: ${project.version}
# Version: @version@
# Created by: extended_clip
# Contributors: https://github.com/PlaceholderAPI/PlaceholderAPI/graphs/contributors
# Issues: https://github.com/PlaceholderAPI/PlaceholderAPI/issues
@@ -10,8 +10,10 @@
# Download placeholders: /papi ecloud
check_updates: true
cloud_enabled: true
cloud_sorting: "name"
cloud_allow_unverified_expansions: false
boolean:
'true': 'yes'
'false': 'no'
date_format: MM/dd/yy HH:mm:ss
debug: false

View File

@@ -1,41 +1,102 @@
name: ${project.name}
main: me.clip.placeholderapi.PlaceholderAPIPlugin
version: ${project.version}
authors: [extended_clip, Glare]
description: ${project.description}
permissions:
placeholderapi.*:
description: ability to use all commands
children:
placeholderapi.admin: true
placeholderapi.admin:
description: ability to use all commands
children:
placeholderapi.list: true
placeholderapi.reload: true
placeholderapi.ecloud: true
placeholderapi.parse: true
placeholderapi.register: true
placeholderapi.updatenotify: true
placeholderapi.list:
description: ability to use the list command
default: op
placeholderapi.reload:
description: ability to use the reload command
default: op
placeholderapi.parse:
description: ability to use parse command
default: op
placeholderapi.register:
description: ability to register or unregister placeholder expansions
default: op
placeholderapi.ecloud:
description: allows the usage of ecloud commands
default: op
placeholderapi.updatenotify:
description: notifies you when there is a PAPI update
default: op
name: "@name@"
main: "me.clip.placeholderapi.PlaceholderAPIPlugin"
version: "@version@"
author: HelpChat
api-version: "1.13"
description: "@description@"
commands:
placeholderapi:
description: PlaceholderAPI command
aliases: [papi]
description: "PlaceholderAPI Command"
aliases: ["papi"]
permissions:
placeholderapi.*:
description: "Ability to use all PAPI commands"
children:
placeholderapi.admin: true
placeholderapi.ecloud.*: true
placeholderapi.admin:
description: "Ability to use all PAPI commands"
children:
placeholderapi.help: true
placeholderapi.info: true
placeholderapi.list: true
placeholderapi.parse: true
placeholderapi.reload: true
placeholderapi.version: true
placeholderapi.register: true
placeholderapi.unregister: true
placeholderapi.updatenotify: true
placeholderapi.ecloud.*:
description: "Ability to use all PAPI ecloud commands"
children:
placeholderapi.ecloud: true
placeholderapi.ecloud.info: true
placeholderapi.ecloud.list: true
placeholderapi.ecloud.clear: true
placeholderapi.ecloud.toggle: true
placeholderapi.ecloud.status: true
placeholderapi.ecloud.update: true
placeholderapi.ecloud.refresh: true
placeholderapi.ecloud.download: true
placeholderapi.ecloud.placeholders: true
placeholderapi.help:
default: "op"
description: "Allows you to view the list of PAPI commands"
placeholderapi.info:
default: "op"
description: "Allows you to view expansion information"
placeholderapi.list:
default: "op"
description: "Allows you to list active expansions"
placeholderapi.ecloud:
default: "op"
description: "Allows you to access PAPI eCloud"
placeholderapi.parse:
default: "op"
description: "Allows you to parse placeholders"
placeholderapi.reload:
default: "op"
description: "Allows you to reload PAPI and its configuration"
placeholderapi.version:
default: "op"
description: "Allows you to view the version of PAPI installed"
placeholderapi.register:
default: "op"
description: "Allows you to register expansions"
placeholderapi.unregister:
default: "op"
description: "Allows you to unregister expansions"
placeholderapi.updatenotify:
default: "op"
description: "Notifies you when there is a PAPI update"
placeholderapi.ecloud.info:
default: "op"
description: "Allows you to view cloud expansion information"
placeholderapi.ecloud.list:
default: "op"
description: "Allows you to list eCloud expansions"
placeholderapi.ecloud.clear:
default: "op"
description: "Allows you to clear the local eCloud expansion cache"
placeholderapi.ecloud.toggle:
default: "op"
description: "Allows you to toggle/enable/disable the eCloud manager"
placeholderapi.ecloud.status:
default: "op"
description: "Allows you to view the status of eCloud expansions"
placeholderapi.ecloud.update:
default: "op"
description: "Allows you to update registered eCloud expansions"
placeholderapi.ecloud.refresh:
default: "op"
description: "Allows you to refresh the local eCloud expansion cache"
placeholderapi.ecloud.download:
default: "op"
description: "Allows you to download an expansion from the eCloud"
placeholderapi.ecloud.placeholders:
default: "op"
description: "Allows you to view the placeholders of a eCloud expansion"

View File

@@ -0,0 +1,103 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi;
import com.google.common.collect.ImmutableMap;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.replacer.CharsReplacer;
import me.clip.placeholderapi.replacer.RegexReplacer;
import me.clip.placeholderapi.replacer.Replacer;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface Values
{
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%";
ImmutableMap<String, PlaceholderExpansion> PLACEHOLDERS = ImmutableMap.<String, PlaceholderExpansion>builder()
.put("player", new MockPlayerPlaceholderExpansion())
.build();
Replacer CHARS_REPLACER = new CharsReplacer(Replacer.Closure.PERCENT);
Replacer REGEX_REPLACER = new RegexReplacer(Replacer.Closure.PERCENT);
final class MockPlayerPlaceholderExpansion extends PlaceholderExpansion
{
public static final String PLAYER_X = "10";
public static final String PLAYER_Y = "20";
public static final String PLAYER_Z = "30";
public static final String PLAYER_NAME = "Sxtanna";
@NotNull
@Override
public String getIdentifier()
{
return "player";
}
@NotNull
@Override
public String getAuthor()
{
return "Sxtanna";
}
@NotNull
@Override
public String getVersion()
{
return "1.0";
}
@Override
public String onRequest(@Nullable final OfflinePlayer player, @NotNull final String params)
{
final String[] parts = params.split("_");
if (parts.length == 0)
{
return null;
}
switch (parts[0])
{
case "name":
return PLAYER_NAME;
case "x":
return PLAYER_X;
case "y":
return PLAYER_Y;
case "z":
return PLAYER_Z;
}
return null;
}
}
}

View File

@@ -0,0 +1,53 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.replacer;
import me.clip.placeholderapi.Values;
import org.openjdk.jmh.annotations.Benchmark;
public class ReplacerBenchmarks
{
@Benchmark
public void measureCharsReplacerSmallText()
{
Values.CHARS_REPLACER.apply(Values.SMALL_TEXT, null, Values.PLACEHOLDERS::get);
}
@Benchmark
public void measureRegexReplacerSmallText()
{
Values.REGEX_REPLACER.apply(Values.SMALL_TEXT, null, Values.PLACEHOLDERS::get);
}
@Benchmark
public void measureCharsReplacerLargeText()
{
Values.CHARS_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get);
}
@Benchmark
public void measureRegexReplacerLargeText()
{
Values.REGEX_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get);
}
}

View File

@@ -0,0 +1,95 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team
*
* PlaceholderAPI free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi.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_X;
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_Y;
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_Z;
import static org.junit.jupiter.api.Assertions.assertEquals;
public final class ReplacerUnitTester
{
@Test
void testCharsReplacerProducesExpectedSingleValue()
{
assertEquals(PLAYER_NAME, Values.CHARS_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
}
@Test
void testRegexReplacerProducesExpectedSingleValue()
{
assertEquals(PLAYER_NAME, Values.REGEX_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
}
@Test
void testCharsReplacerProducesExpectedSentence()
{
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));
}
@Test
void testRegexReplacerProducesExpectedSentence()
{
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));
}
@Test
void testResultsAreTheSameAsReplacement()
{
final String resultChars = Values.CHARS_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(PLAYER_NAME, resultChars);
}
@Test
void testResultsAreTheSameNoReplacement()
{
final String resultChars = Values.CHARS_REPLACER.apply("%player_location%", null, Values.PLACEHOLDERS::get);
final String resultRegex = Values.REGEX_REPLACER.apply("%player_location%", null, Values.PLACEHOLDERS::get);
assertEquals(resultChars, resultRegex);
}
@Test
void testCharsReplacerIgnoresMalformed()
{
final String text = "10% and %hello world 15%";
assertEquals(text, Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
}
@Test
void testCharsReplacerHandlesEscapedHex()
{
final String text = "\\&xFFFFFFThis should not change.";
assertEquals(text.substring(1), Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
}
}

239
wiki/Commands.md Normal file
View File

@@ -0,0 +1,239 @@
This page shows all commands, including with a detailed description of what every command does.
## Overview
- **[Parse Commands](#parse-commands)**
- [`/papi bcparse <player|me> <string>`](#papi-bcparse)
- [`/papi cmdparse <player|me> <string>`](#papi-cmdparse)
- [`/papi parse <player|me> <string>`](#papi-parse)
- [`/papi parserel <player> <player> <string>`](#papi-parserel)
- **[eCloud Commands](#ecloud-commands)**
- [`/papi ecloud clear`](#papi-ecloud-clear)
- [`/papi ecloud disable`](#papi-ecloud-disable)
- [`/papi ecloud download <expansion> [version]`](#papi-ecloud-download)
- [`/papi ecloud enable`](#papi-ecloud-enable)
- [`/papi ecloud info <expansion> [version]`](#papi-ecloud-info)
- [`/papi ecloud list <all|<author>|installed>`](#papi-ecloud-list)
- [`/papi ecloud placeholders <expansion>`](#papi-ecloud-placeholders)
- [`/papi ecloud refresh`](#papi-ecloud-refresh)
- [`/papi ecloud status`](#papi-ecloud-status)
- **[Expansion Commands](#expansion-commands)**
- [`/papi info <expansion>`](#papi-info)
- [`/papi list`](#papi-list)
- [`/papi register <jar file>`](#papi-register)
- [`/papi unregister <jar file>`](#papi-unregister)
- **[Other Commands](#other-commands)**
- [`/papi dump`](#papi-dump)
- [`/papi reload`](#papi-reload)
----
### Parse Commands
These commands are used to parse placeholders into their respective values. Useful for debugging.
#### `/papi bcparse`
**Description**:
Parses placeholders of a String and broadcasts the result to all players.
**Arguments**:
* `<player|me>` - The Player to parse values of the placeholder (Use `me` for yourself).
* `<Text with placeholders>` - The text to parse.
**Example**:
```
/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%
```
----
### eCloud Commands
These commands all start with `/papi ecloud` and are used for things related about the [[Expansion Cloud]].
#### `/papi ecloud clear`
**Description**:
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.
----
### Expansion Commands
These commands can be used to manage the expansions that you have currently installed.
#### `/papi info`
**Description**:
Gives you information about the specified Expansion.
**Argument(s)**:
- `<expansion>` - The Expansion to get info from (Needs to be registered and active).
**Example**:
```
/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
```
----
### Other Commands
These are other commands of PlaceholderAPI that don't fit any of the above categories.
#### `/papi dump`
**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.
#### `/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.

67
wiki/Expansion-cloud.md Normal file
View File

@@ -0,0 +1,67 @@
## About
PlaceholderAPI uses an expansion-cloud (A website that has all kinds of expansions stored), to download jar-files, that contain the placeholders for it to use.
The expansion-cloud can be seen under https://api.extendedclip.com/home
## How it works
PlaceholderAPI connects to the ecloud on startup of your server, to check if the cloud is available and how many expansions are available on it.
If you run `/papi ecloud download <expansion>` PlaceholderAPI will connect to the site to first check if the specified expansion exists and then downloads it if it does.
Note that not all listed expansions are on the ecloud. Some are in the corresponding plugin itself and are registered on the startup of the server.
You can disable the connection to the cloud by setting `cloud_enabled` in the config.yml to false.
## Adding your own expansion
You can add your own expansion to the expansion-cloud for others to use.
In order to do that, you have to follow those steps:
1. Make sure you have created a seperate jar-file like explained on the page [[PlaceholderExpansion]].
2. Create an account on the site, or log in, if you already have one.
3. Click on `Expansions` and then on [`Upload New`](https://api.extendedclip.com/manage/add/).
4. Fill out the required information. `Source URL` and `Dependency URL` are optional.
5. Click on the button that says `Choose an file...` and select the jar of your expansion.
* **Important**! Make sure, that the name of the jar-file contains the same version like you set in the version-field!
6. Click on `Submit Expansion`
Your expansion is now uploaded and will be reviewed by a moderator.
If everything is ok will your expansion be approved and will be available on the ecloud for PlaceholderAPI*.
> *You can only download verified Expansions through PlaceholderAPIs command, unless you enable the option `cloud_allow_unverified_expansions` in the config.yml
> Unverified expansions can be downloaded manually by going to the site and download it yourself.
## Updating your expansion
Before you update, please note the following:
If you aren't a verified dev and you upload an update, your expansion will become **unverified** until a moderator reviews the update and approves it!
It is recommended to only update the expansion, if it contains huge changes or bug fixes.
To update your expansion, you first have to go to the list of [your expansions](https://api.extendedclip.com/manage/).
For that click on `Expansions` and select `Your Expansions`.
After that, follow those steps:
1. Click the name of the expansion, that you want to update.
2. Click on the button that says `Version`
3. Click on `Add Version`
4. Fill out the fields and upload the new jar.
* **Important**! Make sure, that the name of the jar-file contains the same version like you set in the version-field!
5. Click on `Save Changes`
If you're a verified dev, your version will be approved and is available directly.
If you aren't a verified dev, you have to wait until a moderator approves the update.
## Downloading a specific expansion version
In some cases, you may want to use a specific, older version of expansion. Such a case could be for example, when you run an old server version and the newest version of an expansion uses methods that aren't available on that particular server version.
For that case is there a way, to download a specific version of expansion. You can download the expansion either manually, or through PlaceholderAPI itself.
Here is how you can do it for each.
### Download with PlaceholderAPI
This is the easiest of both methods since it requires the least amount of effort.
Run the following command in-game or in your console to download a specific version:
`/papi ecloud download <expansion> [version]`
To find out, what versions are available for the expansion, run `/papi ecloud info <expansion>`
You can then run `/papi ecloud versioninfo <expansion> <version>` to receive more infor about a specific version.
After you downloaded the specific version, run `/papi reload` to refresh the installed expansions.
### Download manually
To download an expansion manually, you first have to connect to the website and go to the expansion of your choice.
There, you click on the button that says `Version` and click on the download-icon of the version you want to download.
Finally, stop your server, upload the jar to the folder in `/plugins/PlaceholderAPI/expansions` (Make sure to delete the old jar, if there's already one) and start the server again.

22
wiki/FAQ.md Normal file
View File

@@ -0,0 +1,22 @@
Here are frequently asked questions about stuff related to PlaceholderAPI.
## It only shows %placeholder% and not the variable
Make sure, that you've tried the following steps:
- PlaceholderAPI is installed and running (Shows green in `/pl` and responds to the `/papi` command)
- You downloaded the expansion with `/papi ecloud download [expansion]`
A list of available expansions and their placeholders can be found [[here|Placeholders]]!
Also note that not all placeholders are in a seperate expansion. Some are "hardcoded" into a plugin.
- You reloaded PlaceholderAPI with `/papi reload` after downloading an expansion.
- Any possible dependency for the expansion (Plugin) is installed and running.
- The placeholder doesn't contain any typos.
- The plugin that should use the placeholder actually supports PlaceholderAPI.
For a list of plugins supporting PlaceholderAPI go [[here|Plugins-using-PlaceholderAPI]].
## 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.
Next step would be to check if the expansion actually exists on the cloud. Not all plugins provide their placeholders through a separate jar on the cloud. Some have them build in and register them on startup.
If both checks failed, go to the cloud-page and download the jar manually. Put it then in the `expansions` folder of PlaceholderAPI (`/plugins/PlaceholderAPI/expansions`)
## How can other plugins use my placeholders with PlaceholderAPI?
A tutorial can be found [[here|Hook into PlaceholderAPI]]!

78
wiki/Home.md Normal file
View File

@@ -0,0 +1,78 @@
<p align="center">
<img src="https://i.imgur.com/puadJ8Z.png" alt="PlaceholderAPI">
</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.
It also has a list with all available placeholders (Work in progress).
### Setup
**[[Hook into PlaceholderAPI]]**
- [[First steps|Hook-into-PlaceholderAPI#first-steps]]
- [[Adding placeholders to PlaceholderAPI|Hook-into-PlaceholderAPI#adding-placeholders-to-placeholderapi]]
- [[PlaceholderExpansion]]
- [[Without an external plugin|PlaceholderExpansion#without-an-external-plugin]]
- [[With external plugin|PlaceholderExpansion#with-external-plugin]]
- [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]]
### Other
**[[Commands]]**
**[[Expansion cloud]]**
**[[FAQ]]**
**[[Plugins using PlaceholderAPI]]**
**[[Placeholders]]**
- [[PAPI-placeholders|Placeholders#papi-placeholders-1]]
- [[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]]
- [[B|Placeholders#b]]
- [[C|Placeholders#c]]
- [[D|Placeholders#d]]
- [[E|Placeholders#e]]
- [[F|Placeholders#f]]
- [[G|Placeholders#g]]
- [[H|Placeholders#h]]
- [[I|Placeholders#i]]
- [[J|Placeholders#j]]
- [[K|Placeholders#k]]
- [[L|Placeholders#l]]
- [[M|Placeholders#m]]
- [[N|Placeholders#n]]
- [[O|Placeholders#o]]
- [[P|Placeholders#p]]
- [[Q|Placeholders#q]]
- [[R|Placeholders#r]]
- [[S|Placeholders#s]]
- [[T|Placeholders#t]]
- [[U|Placeholders#u]]
- [[V|Placeholders#v]]
- [[W|Placeholders#w]]
- [[Z|Placeholders#z]]

View File

@@ -0,0 +1,137 @@
[APIBadge]: https://img.shields.io/nexus/r/http/repo.extendedclip.com/me.clip/placeholderapi.svg?label=API-Version
[SpigotBadge]: https://img.shields.io/spiget/version/6245?label=Spigot
[Spigot]: https://spigotmc.org/resources/6245
[GitHubBadge]: https://img.shields.io/github/v/release/PlaceholderAPI/PlaceholderAPI?label=GitHub%20Release
[GitHub]: /PlaceholderAPI/PlaceholderAPI/releases/latest
> [![SpigotBadge]][Spigot] [![GitHubBadge]][GitHub]
>
> ![APIBadge]
>
> *The GitHub release may be different from the spigot release*
This page is about using PlaceholderAPI in your own plugin, to either let other plugins use your plugin, or just use placeholders from other plugins in your own.
Please note, that the examples in this page are only available for **PlaceholderAPI 2.10.0 or higher**!
## First steps
Before you can actually make use of PlaceholderAPI, you first have to import it into your project.
### Import with Maven
To import PlaceholderAPI, simply add the following code to your **pom.xml**
Replace `{VERSION}` with the version listed at the top of this page.
```xml
<repositories>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>{VERSION}</version>
<scope>provided</scope>
</dependency>
</dependencies>
```
### Import with Gradle
Here is how you can import PlaceholderAPI through gradle.
Put this into your **Gradle.build**.
Replace `{VERSION}` with the version listed at the top of this page.
```gradle
repositories {
maven {
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}
}
dependencies {
compileOnly 'me.clip:placeholderapi:{VERSION}'
}
```
### Set PlaceholderAPI as (soft)depend
Next step is to go to your plugin.yml and add PlaceholderAPI as a depend or softdepend, depending (no pun intended) on if it is optional or not.
**Example Softdepend**:
```yaml
name: ExamplePlugin
version: 1.0
author: author
main: your.main.path.here
softdepend: [PlaceholderAPI] # This is used, if your plugin works without PlaceholderAPI.
```
**Example Depend**:
```yaml
name: ExamplePlugin
version: 1.0
author: author
main: your.main.path.here
depend: [PlaceholderAPI] # If your plugin requires PlaceholderAPI, to work, use this.
```
## Adding placeholders to PlaceholderAPI
A full guide on how to create expansions can be found on the [[PlaceholderExpansion]] page of this wiki.
## Setting placeholders in your plugin
PlaceholderAPI offers the ability, to automatically parse placeholders from other plugins within your own plugin, giving the ability for your plugin to support thousands of other placeholders without depending on each plugin individually.
To use placeholders from other plugins in our own plugin, we simply have to [(soft)depend on PlaceholderAPI](#set-placeholderapi-as-softdepend) and use the `setPlaceholders` method.
It is also important to point out, that any required plugin/dependency for an expansion has to be on the server and enabled, or the `setPlaceholders` method will just return the placeholder itself (do nothing).
**Example**:
Let's assume we want to send an own join message that shows the group a player has.
To achieve that, we can do the following:
```java
package at.helpch.placeholderapi;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import me.clip.placeholderapi.PlaceholderAPI;
public class JoinExample extends JavaPlugin implements Listener {
@Override
public void onEnable() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
/*
* We register the EventListener here, when PlaceholderAPI is installed.
* Since all events are in the main class (this class), we simply use "this"
*/
Bukkit.getPluginManager().registerEvents(this, this);
} else {
throw new RuntimeException("Could not find PlaceholderAPI!! Plugin can not work without it!");
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent event) {
String joinText = "%player_name% &ajoined the server! He/she is rank &f%vault_rank%";
/*
* We parse the placeholders using "setPlaceholders"
* This would turn %vault_rank% into the name of the Group, that the
* joining player has.
*/
joinText = PlaceholderAPI.setPlaceholders(event.getPlayer(), joinText);
event.setJoinMessage(withPlaceholdersSet);
}
}
```

View File

@@ -0,0 +1,411 @@
## Overview
This page covers how you can use the `PlaceholderExpansion` to add own placeholders to PlaceholderAPI, which then can be used by other plugins.
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.
## Note
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
There are multiple methods and ways you can use the PlaceholderExpansion.
Those depend on what you want to display through the placeholders in the end.
* [Without external plugin](#without-external-plugin)
* [With external plugin](#with-external-plugin)
* [Separate jar](#separate-jar)
* [Internal class](#internal-class)
### Without an external plugin
This part here covers how you create an expansion that doesn't require any external/additional plugins to function.
Examples of such expansions are:
- [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.
To begin, first make the class extend the `PlaceholderExpansion` and add the required methods:
```java
package at.helpch.placeholderapi.example.expansions;
import org.bukkit.OfflinePlayer;
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 {
/**
* 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
public boolean canRegister(){
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";
}
/**
* 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
public String getIdentifier(){
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
public String getVersion(){
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;
}
}
```
----
### With external plugin
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.
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.
#### Separate jar
In our separate jar do we have to make some checks, to be sure, that the required plugin is installed and running.
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
package at.helpch.placeholderapi.example.expansions;
import org.bukkit.OfflinePlayer;
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 {
// 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
public boolean canRegister(){
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";
}
/**
* 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
public String getIdentifier(){
return "someplugin";
}
/**
* 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
public String getRequiredPlugin(){
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";
}
/**
* 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
public String onPlaceholderRequest(Player player, String identifier){
if(p == null){
return "";
}
// %someplugin_placeholder1%
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;
}
}
```
----
#### Internal class
You can have the class inside your plugin.
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
otherwise, if PlaceholderAPI is reloaded, your expansion will be unregistered and lost forever.
```java
package at.helpch.placeholderapi.example.expansions;
import org.bukkit.OfflinePlayer;
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 {
private 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;
}
/**
* 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
public boolean persist(){
return true;
}
/**
* 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
public boolean canRegister(){
return true;
}
/**
* 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
public String getAuthor(){
return plugin.getDescription().getAuthors().toString();
}
/**
* 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
public String getIdentifier(){
return "someplugin";
}
/**
* 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
public String getVersion(){
return plugin.getDescription().getVersion();
}
/**
* 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
public String onPlaceholderRequest(Player player, String identifier){
if(player == null){
return "";
}
// %someplugin_placeholder1%
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.
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
package at.helpch.placeholderapi.example
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class SomePlugin extends JavaPlugin{
@Override
public void onEnable(){
// Small check to make sure that PlaceholderAPI is installed
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null){
new SomeExpansion(this).register();
}
}
}
```

4300
wiki/Placeholders.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,944 @@
This here is a list of all plugins supporting PlaceholderAPI by either having their own placeholders added, or just allowing other placeholders to be used.
If your plugin isn't shown here and you want it to be added, [open an issue](/PlaceholderAPI/PlaceholderAPI/issues/new?template=change_request_wiki.md) and we will add it!
## Plugins
* **[A](#a)**
* **[B](#b)**
* **[C](#c)**
* **[D](#d)**
* **[E](#e)**
* **[F](#f)**
* **[G](#g)**
* **[H](#h)**
* **[I](#i)**
* **[J](#j)**
* **[K](#k)**
* **[L](#l)**
* **[M](#m)**
* **[N](#n)**
* **[O](#o)**
* **[P](#p)**
* **[Q](#q)**
* **[R](#r)**
* **[S](#s)**
* **[T](#t)**
* **[U](#u)**
* **[V](#v)**
* **[W](#w)**
* **[X](#X)**
----
## A
- **[AAC - AdvancedAntiCheat](https://www.spigotmc.org/resources/6442/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#aac]]**]
- **[AbstractMenus](https://www.spigotmc.org/resources/75107/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#abstractmenus]]**]
- **[AcidIsland](https://www.spigotmc.org/resources/581/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#acidisland]]**]
- **[Advanced Abilities](https://www.spigotmc.org/resources/21983/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#advanced-abilities]]**]
- **[Advanced Achievements](https://www.spigotmc.org/resources/6239/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[AdvancedAFK](https://www.spigotmc.org/resources/60761/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#advancedafk]]**]
- **[AdvancedCustomMenu+](https://www.spigotmc.org/resources/47945/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#advancedcustommenu]]**]
- **[AdvancedLottery](https://www.spigotmc.org/resources/43668/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#advancedlottery]]**]
- **[AdvancedModReq](https://www.spigotmc.org/resources/40528/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#advancedmodreq]]**]
- **[Advance Tab](https://www.spigotmc.org/resources/21958/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[ajParkour](https://www.spigotmc.org/resources/60909/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ajparkour]]**]
- **[AnimatedBoard](https://www.spigotmc.org/resources/13632/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[AnimatedScoreboard](https://www.spigotmc.org/resources/20848/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Animated Menu](https://www.spigotmc.org/resources/4690/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#amimated-menu]]**]
- **[AnimatedSpecialBar](https://www.spigotmc.org/resources/24654/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[AnnouncementsEverywhere](https://www.spigotmc.org/resources/59510/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[AParkour](https://www.spigotmc.org/resources/30923/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#aparkour]]**]
- **[ASkyBlock](https://www.spigotmc.org/resources/1220/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#askyblock]]**]
- **[AsyncKeepAlive](https://www.spigotmc.org/resources/64676/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#asynckeepalive]]**]
- **[AutoCommandsPlus](https://www.spigotmc.org/resources/11083/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[AutoRank](https://www.spigotmc.org/resources/3239/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#autorank]]**]
- **[AutoSell](https://www.spigotmc.org/resources/2157/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#autosell]]**]
----
## B
- **[BankSystem](https://www.spigotmc.org/resources/61580/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#banksystem]]**]
- **[BannerBoard](https://www.spigotmc.org/resources/20435/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[BattleLevels](https://www.spigotmc.org/resources/2218/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#battlelevels]]**]
- **[BeautyQuests](https://www.spigotmc.org/resources/39255/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#beautyquests]]**]
- **[BedWars1058](https://www.spigotmc.org/resources/50942/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#bedwars1058]]**]
- **[BentoBox](https://github.com/BentoBoxWorld/BentoBox)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#bentobox]]**]
- **[Big Doors Opener](https://www.spigotmc.org/resources/80805/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[BlockParty](https://www.spigotmc.org/resources/7264/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#blockparty]]**]
- **[BlockQuests](https://www.spigotmc.org/resources/32729/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#blockquests]]**]
- **[BookStats](https://www.spigotmc.org/resources/4313/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[BossBarSet](https://www.spigotmc.org/resources/26963/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[BossVote](https://www.spigotmc.org/resources/16497/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Broadcaster Plugin](https://dev.bukkit.org/projects/broadcaster-plugin)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[BuildBattlePro](https://www.spigotmc.org/resources/49587/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#buildbattlepro]]**]
- **[BungeePerms](https://www.spigotmc.org/resources/25/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#bungeeperms]]**]
----
## C
- **[CarlTheCreeper](https://www.spigotmc.org/resources/18008/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#carlthecreeper]]**]
- **[Characters Premium](https://www.spigotmc.org/resources/45142/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[ChatBot](https://www.spigotmc.org/resources/55642/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[ChatColor+](https://www.spigotmc.org/resources/1546/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#chatcolor]]**]
- **[ChatColor+ Premium](https://www.spigotmc.org/resources/54093/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#chatcolor-premium]]**]
- **[ChatControl Pro](https://www.spigotmc.org/resources/10258/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Chat Format](https://www.spigotmc.org/resources/11780/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [**[[Link|Placeholders#chat-format]]**]
- **[ChatManager](https://www.spigotmc.org/resources/52245/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[ChatReaction](https://www.spigotmc.org/resources/3748/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#chatreaction]]**]
- **[CheckNameHistory](https://www.spigotmc.org/resources/3768/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#checknamehistory]]**]
- **[ChestCommands](https://dev.bukkit.org/projects/chest-commands)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[CitizensBooks](https://www.spigotmc.org/resources/37465/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [**[[Link|Placeholders#citizensbooks]]**]
- **[Clans-API for Spigot/Clan tag in chat](https://www.spigotmc.org/resources/31547/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#clans-api-for-spigotclan-tag-in-chat]]**]
- **[Clans](https://www.spigotmc.org/resources/34696/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#clans]]**]
- **[Clans](https://www.spigotmc.org/resources/78415/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#clans-1]]**]
- **[ClicksPerSecond](https://www.spigotmc.org/resources/57214/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[CMI](https://www.spigotmc.org/resources/3742/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[CombatLogX](https://www.spigotmc.org/resources/31689/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#combatlogx]]**]
- **[CommandConditions](https://www.spigotmc.org/resources/41736/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Compassance](https://www.spigotmc.org/resources/18327/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#compassance]]**]
- **[Country on Join](https://www.spigotmc.org/resources/34275/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#country-on-join]]**]
- **[CraftConomy](https://www.spigotmc.org/resources/2395/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#craftconomy]]**]
- **[CraftingStore.net](https://www.spigotmc.org/resources/31331/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#craftingstorenet]]**]
- **[CTSNC](https://www.spigotmc.org/resources/10714/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[CursedVIP](https://www.spigotmc.org/resources/67068/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#cursedvip]]**]
- **[CustomCommands](https://www.spigotmc.org/resources/14363/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[CustomGUI (Free)](https://www.spigotmc.org/resources/58440/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[CustomGUI (Paid)](https://www.spigotmc.org/resources/7386/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[CustomHelp](https://www.spigotmc.org/resources/20606/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[CustomSigns](https://www.spigotmc.org/resources/63569/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
----
## D
- **[Daily Rewards](https://www.spigotmc.org/resources/16708)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#daily-rewards]]**]
- **[DeliveryMan](https://www.spigotmc.org/resources/14131/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#deliveryman]]**]
- **[DeluxeChat](https://www.spigotmc.org/resources/1277/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#deluxechat]]**]
- **[DeluxeCombat](https://www.spigotmc.org/resources/63970/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#deluxecombat]]**]
- **[DeluxeCommands](https://www.spigotmc.org/resources/8033/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[DeluxeMenus](https://www.spigotmc.org/resources/11734/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[DeluxeTags](https://www.spigotmc.org/resources/4390/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#deluxetags]]**]
- **[Depinezen](/DenizenScript/Depenizen-For-Bukkit/blob/master/README.md) (For [Denizen](https://www.spigotmc.org/resources/21039/))**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#denizen]]**]
- **[DiscordSRV](https://www.spigotmc.org/resources/18494/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#discordsrv]]**]
- **[Disease](https://www.spigotmc.org/resources/3911/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#disease]]**]
- **DonationParty**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#donationparty]]**]
- **[Donations Holograms](https://www.spigotmc.org/resources/1956/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#donations-holograms]]**]
- **[DragonSlayer](https://www.spigotmc.org/resources/36250/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#dragonslayer]]**]
- **[DungeonsXL](https://www.spigotmc.org/resources/9488/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#dungeonsxl]]**]
----
## E
- **[Economy Bank](https://www.spigotmc.org/resources/7674/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#economy-bank]]**]
- **[Enjin & DonationCraft 2.x](https://dev.bukkit.org/projects/emp)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#enjin--donationcraft-2x]]**]
- **[Enhanced BalTop](https://www.spigotmc.org/resources/20168/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Envoys](https://www.spigotmc.org/resources/20357/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#envoys]]**]
- **[EpicCraftingsPlus](https://www.spigotmc.org/resources/39967/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[EpicFriends](https://www.spigotmc.org/resources/11294/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#epicfriends]]**]
- **[EpicLevels](https://songoda.com/marketplace/product/44)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#epiclevels]]**]
- **[Ersatz](https://www.spigotmc.org/resources/49433/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[essCore](https://www.spigotmc.org/resources/37766/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#esscore]]**]
- **[Essentials](https://ci.ender.zone/job/EssentialsX/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#essentials]]**]
- **[EZBlocks](https://www.spigotmc.org/resources/1499/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ezblocks]]**]
- **[EzChat](https://www.spigotmc.org/resources/75048/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders.
- **[EZPrestige](https://www.spigotmc.org/resources/1794/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ezprestige]]**]
- **[EZRanksPro](https://www.spigotmc.org/resources/10731/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ezrankspro]]**]
----
## F
- **[FactionMapScoreboard](https://www.spigotmc.org/resources/23071/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Factions MCore](https://www.spigotmc.org/resources/1900/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#factions-mcore]]**]
- **[FactionsUUID](https://www.spigotmc.org/resources/1035/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#factionsuuid]]**]
- **[FunnyGuilds](https://github.com/FunnyGuilds/FunnyGuilds)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#funnyguilds]]**]
- **[FriendReferral](https://www.spigotmc.org/resources/21626/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
----
## G
- **[GangsPlus](https://www.spigotmc.org/resources/2604/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#gangsplus]]**]
- **[GemsEconomy](https://www.spigotmc.org/resources/19655/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#gemseconomy]]**]
- **[GriefDefender](https://www.spigotmc.org/resources/68900/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#griefdefender]]**]
- **[GriefPrevention](https://www.spigotmc.org/resources/1884/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#griefprevention]]**]
- **[Guilds](https://www.spigotmc.org/resources/48920/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#guilds]]**]
- **[GUIPlus](https://www.spigotmc.org/resources/38664/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders.
----
## H
- **[Hawn - Hub/Lobby Management](https://www.spigotmc.org/resources/66907/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Head Database](https://www.spigotmc.org/resources/14280/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#head-database]]**]
- **[HelpGUI](https://www.spigotmc.org/resources/33245/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[HeroChat Premium]()**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [**[[Link|Placeholders#herochat-premium]]**]
- **[Heroes](https://www.spigotmc.org/resources/305/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#heroes]]**]
- **[HoloBlock](https://www.spigotmc.org/resources/43192/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#holoblock]]**]
- **[HPWizard](https://www.spigotmc.org/resources/26821/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#hpwizard]]**]
- **[Hugs](https://www.spigotmc.org/resources/hugs.39722/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#hugs]]**]
----
## I
- **[InteractionVisualizer](https://www.spigotmc.org/resources/77050/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#interactionvisualizer]]**]
- **[IslandRate (ASkyBlock Addon)](https://www.spigotmc.org/resources/53519/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#islandrate-askyblock-addon]]**]
- **[IslandRate (AcidIsland Addon)](https://www.spigotmc.org/resources/54913/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#islandrate-acidisland-addon]]**]
- **[ItemJoin](https://www.spigotmc.org/resources/12661/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
----
## J
- **[Jobs Reborn](https://www.spigotmc.org/resources/4216/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#jobs-reborn]]**]
- **[JSONChat](https://www.spigotmc.org/resources/17744/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
----
## K
- **[Karma](https://www.spigotmc.org/resources/71156/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#karma]]**]
- **[KillStats](http://dev.bukkit.org/bukkit-plugins/killstats-v1-0/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#killstats]]**]
- **[KitPvP](https://www.spigotmc.org/resources/27107/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#kitpvp]]**]
- **[Kingdoms+](https://www.spigotmc.org/resources/11833/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#kingdoms]]**]
- **[KP-PVP](https://www.spigotmc.org/resources/50969/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#kp-pvp]]**]
----
## L
- **[LastLoginAPI](https://www.spigotmc.org/resources/66348/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#lastloginapi]]**]
- **[LeaderHeads](https://www.spigotmc.org/resources/2079/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#leaderheads]]**]
- **[Leak Parkour](https://www.spigotmc.org/resources/12852/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders.
- **[LegendQuest](https://www.spigotmc.org/resources/2120/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#legendquest]]**]
- **[LemonMobCoins](https://www.spigotmc.org/resources/59402/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#lemonmobcoins]]**]
- **[LuckPerms](https://www.spigotmc.org/resources/28140/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#luckperms]]**]
- **[LWC (Modern LWC)](https://www.spigotmc.org/resources/2162/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#lwc]]**]
----
## M
- **[Marcely's Bedwars](https://www.spigotmc.org/resources/13622/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#marcelys-bedwars]]**]
- **[Marriage](https://www.spigotmc.org/resources/81807/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#marriage]]**]
- **[Marriage (reloaded)](https://www.spigotmc.org/resources/18998/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#marriage-reloaded]]**]
- **[MarriageMaster](http://dev.bukkit.org/bukkit-plugins/marriage-master/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#marriagemaster]]**]
- **[MCInfected](https://www.spigotmc.org/resources/2133/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#mcinfected]]**]
- **[MCInfected-Ranks](https://www.spigotmc.org/resources/2826/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#mcinfected-ranks]]**]
- **[McJobs](https://dev.bukkit.org/projects/mcjobs/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#mcjobs]]**]
- **[McMMO](https://www.spigotmc.org/resources/2445/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#mcmmo]]**]
- **[Menu](https://www.spigotmc.org/resources/50658/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[MineChess](https://www.spigotmc.org/resources/74178/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#minechess]]**]
- **[Minecord](https://www.spigotmc.org/resources/44055/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#minecord]]**]
- **[MineCrates](https://www.spigotmc.org/resources/4685/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#minecrates]]**]
- **[MinetopiaSDB](https://www.spigotmc.org/resources/28830/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[MixStepManager](https://www.spigotmc.org/resources/23531/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[MobHunting](https://www.spigotmc.org/resources/3582/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#mobhunting]]**]
- **[MultiChat](https://www.spigotmc.org/resources/26204/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[MultiClan 2.0](https://www.spigotmc.org/resources/23927/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Multiverse-Core](https://www.spigotmc.org/resources/390/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#multiverse-core]]**]
- **[MurderMystery 2](https://www.spigotmc.org/resources/36894/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[MyCommand](http://dev.bukkit.org/bukkit-plugins/mycommand/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#mycommand]]**]
- **[MyPet](https://www.spigotmc.org/resources/12725/) [[Premium](https://www.spigotmc.org/resources/17566/)]**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#mypet-premium]]**]
- **[MyPrefixSystem](https://www.spigotmc.org/resources/46244/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#myprefixsystem]]**]
----
## N
- **[Nameless Plugin](https://www.spigotmc.org/resources/59032/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#nameless-plugin]]**]
- **[Nicknamer](https://www.spigotmc.org/resources/5341/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#nicknamer]]**]
- **[NickReloaded](https://www.spigotmc.org/resources/46335/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#nickreloaded]]**]
- **[Nicky](https://www.spigotmc.org/resources/590/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#nicky]]**]
----
## O
- **[OnePlayerSleep](https://www.spigotmc.org/resources/76534/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#oneplayersleep]]**]
- **[OneTimeUse](https://www.spigotmc.org/resources/13907/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[OnTime](http://dev.bukkit.org/bukkit-plugins/ontime/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ontime]]**]
- **[OreAnnouncer](https://www.spigotmc.org/resources/33464/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#oreannouncer]]**]
- **[Outpost](https://www.spigotmc.org/resources/38657/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#outpost]]**]
----
## P
- **[Paintball Battle](https://www.spigotmc.org/resources/76676/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#paintball-battle]]**]
- **[Parkour](https://www.spigotmc.org/resources/23685/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#parkour]]**]
- **[Parties](https://www.spigotmc.org/resources/3709/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#parties]]**]
- **[Party and Friends](https://www.spigotmc.org/resources/11633/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#party-and-friends]]**]
- **[PingTest](https://www.spigotmc.org/resources/69580/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders.
- **[PixelVip](https://www.spigotmc.org/resources/30438/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#pixelvip]]**]
- **[Plan](https://www.spigotmc.org/resources/32536/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#plan]]**]
- **[PlayerBalancerAddon](https://www.spigotmc.org/resources/51220/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[PlayTime](https://www.spigotmc.org/resources/26016/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#playtime]]**]
- **[PlayerPoints](http://dev.bukkit.org/bukkit-plugins/playerpoints/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#playerpoints]]**]
- **[PlotSquared](https://www.spigotmc.org/resources/1177/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#plotsquared]]**]
- **[PointsAPI](https://www.spigotmc.org/resources/13957/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#pointsapi]]**]
- **[Potatoes](https://www.spigotmc.org/resources/12353/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[PowerRanks](https://www.spigotmc.org/resources/64696/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#powerranks]]**]
- **[PremiumVanish](https://www.spigotmc.org/resources/14404/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#premiumvanish]]**]
- **[PrisonMines](https://www.spigotmc.org/resources/4046/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#prisonmines]]**]
- **[PrisonRanksX](https://www.spigotmc.org/resources/55899/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#prisonranksx]]**]
- **[ProCosmetics](https://www.spigotmc.org/resources/49106/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#procosmetics]]**]
- **[ProdigyGadget](https://www.spigotmc.org/resources/1335/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[ProfessionalBans](https://www.spigotmc.org/resources/63657/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#professionalbans]]**]
- **[ProQuest](https://www.spigotmc.org/resources/18249/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#proquest]]**]
- **[ProtectionStones](https://www.spigotmc.org/resources/61797/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#protectionstones]]**]
- **[PurpleIRC](https://www.spigotmc.org/resources/2836/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[PvPLevels](https://www.spigotmc.org/resources/20807/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#pvplevels]]**]
- **[PvP Stats](http://dev.bukkit.org/bukkit-plugins/pvp-stats/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#pvp-stats]]**]
- **[PvPStats Plugin](https://www.spigotmc.org/resources/69984/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#pvpstats-plugin]]**]
- **[PyrCore](https://www.spigotmc.org/resources/24180/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
----
## Q
- **[Quests](https://www.spigotmc.org/resources/3711/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#quests]]**]
- **[QuestCreator](https://www.spigotmc.org/resources/38734/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#questcreator]]**]
- **[QuickBoard](https://www.spigotmc.org/resources/15057/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[QuickSell](https://www.spigotmc.org/resources/6107/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#quicksell]]**]
----
## R
- **[RabbitsVSPenguins](https://www.spigotmc.org/resources/65277/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#rabbitsvspenguins]]**]
- **[RageMode](https://www.spigotmc.org/resources/69169/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ragemode]]**]
- **[RankedHelp](https://www.spigotmc.org/resources/61919/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Rankup](https://www.spigotmc.org/resources/17933/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#rankup]]**]
- **[RawMSG](https://www.spigotmc.org/resources/35864/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders.
- **[RecentFind (Treasures Add-on)](https://www.spigotmc.org/resources/33366/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#recentfind]]**]
- **[RedProtect](http://spigotmc.org/resources/15841/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#redprotect]]**]
- **[ReporterGUI](https://www.spigotmc.org/resources/8596/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[RestrictedDimensions](http://spigotmc.org/resources/80574/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#restricteddimensions]]**]
- **[RogueParkour](https://www.spigotmc.org/resources/26563/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#rogueparkour]]**]
- **[RoyalCommands](https://www.spigotmc.org/resources/4113/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#royalcommands]]**]
- **[ReferralSystem](https://www.spigotmc.org/resources/29709/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#referralsystem]]**]
- **[Residence](https://www.spigotmc.org/resources/11480/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[RPGInventory](https://www.spigotmc.org/resources/12498/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#rpginventory]]**]
----
## S
- **[Scoreboard Sidebar API](https://www.spigotmc.org/resources/21042/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[ScrollBoard](https://www.spigotmc.org/resources/24697/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Skellett (Skript Add-on)](https://forums.skunity.com/resources/24/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[SellAll](https://www.spigotmc.org/resources/1221/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#sellall]]**]
- **[Server List/Staff List](https://www.spigotmc.org/resources/15119/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[ServerSelectorX](https://www.spigotmc.org/resources/32853/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[SignLink](https://www.spigotmc.org/resources/39593/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#signlink]]**]
- **[SimpleBoard](https://www.spigotmc.org/resources/39597/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[SimpleClans](https://www.spigotmc.org/resources/5269/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#simpleclans]]**]
- **[SimpleCoinsAPI](https://www.spigotmc.org/resources/1432/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#simplecoinsapi]]**]
- **[SimpleKillTracker](https://www.spigotmc.org/resources/17651/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#simplekilltracker]]**]
- **[SimplePrefix](http://dev.bukkit.org/bukkit-plugins/simple-prefix/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#simpleprefix]]**]
- **[Simple Suffix](http://dev.bukkit.org/bukkit-plugins/simple-suffix/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#simple-suffix]]**]
- **[SkillAPI](https://www.spigotmc.org/resources/4824/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#skillapi]]**]
- **[Skript](https://github.com/bensku/Skript)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#skript]]**]
- **[SkyWars](https://www.spigotmc.org/resources/6525/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[SkyWarsReloaded](https://www.spigotmc.org/resources/3796/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#skywarsreloaded]]**]
- **[Spark](https://github.com/lucko/spark)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#spark]]**]
- **[SpigotBoard](https://www.spigotmc.org/resources/47497/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[SpigotLib](https://www.spigotmc.org/resources/5925/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[SpigotLobby](https://www.spigotmc.org/resources/58797/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[SQLPerms](https://www.spigotmc.org/resources/1462/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#sqlperms]]**]
- **[SQLTokens](https://www.spigotmc.org/resources/3482/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#sqltokens]]**]
- **[sTablist](https://www.spigotmc.org/resources/12234/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Staff Facilities](https://www.spigotmc.org/resources/13097/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#staff-facilities]]**]
- **[Statz](https://www.spigotmc.org/resources/25969/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#statz]]**]
- **[StrikePractice 2](https://www.spigotmc.org/resources/46906/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#strikepractice-2]]**]
- **[stTitles](https://www.spigotmc.org/resources/8310/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#sttitles]]**]
- **[SubServers](https://github.com/ME1312/SubServers-2)**
- [ ] Supports Placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#subservers]]**]
- **[SuperbVote](https://www.spigotmc.org/resources/11626/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#superbvote]]**]
- **[SuperCredits](https://www.spigotmc.org/resources/31074/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#supercredits]]**]
- **[SuperScratch](https://www.spigotmc.org/resources/12250/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[SuperVanish](https://www.spigotmc.org/resources/1331/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#supervanish]]**]
----
## T
- **[TakaAntiCheat](https://www.spigotmc.org/resources/45167/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[The Time](https://www.spigotmc.org/resources/25146/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#the-time]]**]
- **[ThemePark](https://www.spigotmc.org/resources/48648/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#themepark]]**]
- **[Thirst](https://www.spigotmc.org/resources/3316/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#thirst]]**]
- **[Timed Rewards](https://www.spigotmc.org/resources/34008/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#timed-rewards]]**]
- **[Time Tokens](https://www.spigotmc.org/resources/75441/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#time-tokens]]**]
- **[TNTRun_Reloaded](https://www.spigotmc.org/resources/53359/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#tntrun_reloaded]]**]
- **[TokenEnchant](https://www.spigotmc.org/resources/2287/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#tokenenchant]]**]
- **[TokenManager](https://www.spigotmc.org/resources/8610/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#tokenmanager]]**]
- **[Tokens](https://www.spigotmc.org/resources/71941/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#tokens]]**]
- **[Towny](https://github.com/TownyAdvanced/Towny)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#towny]]**]
- **[TownyChat](https://github.com/TownyAdvanced/TownyChat)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#townychat]]**]
- **[TransmuteIt](https://www.spigotmc.org/resources/76287/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#transmuteIt]]**]
- **[Treasures](https://www.spigotmc.org/resources/14178/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#treasures]]**]
- **[Trey's Double Jump](https://www.spigotmc.org/resources/19630/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#treys-double-jump]]**]
- **[TrickOrTreat](https://www.spigotmc.org/resources/61370/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#trickortreat]]**]
----
## U
- **[UChat](https://www.spigotmc.org/resources/23767/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[UltimateAnnounce+](https://www.spigotmc.org/resources/7459/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[UltimateBossBar](https://www.spigotmc.org/resources/19303/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders.
- **[UltimateSigns](https://www.spigotmc.org/resources/72462/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders.
- **[UltraChatFormat](https://www.spigotmc.org/resources/57929/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[UltraMenu](https://www.spigotmc.org/resources/27856/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Ultra Permissions](https://www.spigotmc.org/resources/42678/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Ultra Simple Staff Chat](https://www.spigotmc.org/resources/22064/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[USkyBlock](https://www.spigotmc.org/resources/2280/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#uskyblock]]**]
- **[UltimateChat](https://www.spigotmc.org/resources/uchat.23767/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ultimatechat]]**]
- **[UltimateVotes](https://www.spigotmc.org/resources/516)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#ultimatevote]]**]
- **[UnityGen](https://www.spigotmc.org/resources/26218/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#unitygen]]**]
----
## V
- **[VariableTriggers](https://dev.bukkit.org/projects/variabletriggers)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[Vault](http://dev.bukkit.org/bukkit-plugins/vault/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#vault]]**]
- **[VentureChat](https://www.spigotmc.org/resources/771/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[ViaVersion](https://www.spigotmc.org/resources/19254/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#viaversion]]**]
- **[VoteParty](https://www.spigotmc.org/resources/987/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#voteparty]]**]
- **[VoteRoulette](http://dev.bukkit.org/bukkit-plugins/voteroulette/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#voteroulette]]**]
- **[VotingPlugin](https://www.spigotmc.org/resources/15358/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#votingplugin]]**]
----
## W
- **[WickedSkyWars](https://www.spigotmc.org/resources/556/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#wickedskywars]]**]
- **[WonderHUD](https://www.spigotmc.org/resources/12220/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders. [Link]
- **[WorldGuard](https://dev.bukkit.org/bukkit-plugins/worldguard/)**
- [ ] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#worldguard]]**]
- **[WorldJoin](https://www.spigotmc.org/resources/63892/)**
- [x] Supports placeholders.
- [ ] Provides own placeholders.
----
## X
- **[XLTournaments](https://www.spigotmc.org/resources/70630/)**
- [x] Supports placeholders.
- [x] Provides own placeholders. [**[[Link|Placeholders#xltournaments]]**]

82
wiki/README.md Normal file
View File

@@ -0,0 +1,82 @@
[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
# Wiki
This is the wiki folder. It contains all pages that you can find in our [Wiki].
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.
## Adding your resource(s)
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.
### [Plugins using PlaceholderAPI]
You should always add your resource to this page, no matter if it only supports placeholders or also provides its own.
The format of a plugin is always as follows:
```md
- **[:name](:url)**
- [?] Supports placeholders.
- [?] Provides own placeholders. [:link]
```
A quick summary over the different parts:
- `: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.
- `: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.
- `?` 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]
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.
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.
The overall structure of an entry is always the same:
````md
- ### **[:name](:url)**
> :command
```
: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.
- `: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.
If your extension is at the very bottom of the page can you ommit the `----`.
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.
## Other Wiki pages
Please follow these general guidelines when editing any other pages.
### Linking
Linking should always be done through either the reference option or through the Wiki link option.
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).
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.
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.
This system allows us to easly maintain the links without the need to update a URL on several places within the page.
### Lists
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.

16
wiki/_Footer.md Normal file
View File

@@ -0,0 +1,16 @@
[discordImg]: https://img.shields.io/discord/164280494874165248.svg?logo=discord&label=Discord&colorB=7289DA
[discord]: https://helpch.at/discord
[jenkinsImg]: https://img.shields.io/badge/Download%20from-Jenkins-brightgreen.svg
[jenkins]: http://ci.extendedclip.com/job/PlaceholderAPI/
[licenseImg]: https://img.shields.io/github/license/PlaceholderAPI/PlaceholderAPI.svg
[license]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/LICENSE
[issuesImg]: https://img.shields.io/github/issues-raw/PlaceholderAPI/PlaceholderAPI.svg?logo=github&logoColor=white
[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
[plugin-page]: https://spigotmc.org/resources/6245
> Thanks for using PlaceholderAPI.
>
> **[Plugin-page]** | **[[Placeholders]]** | **[[Plugins using PlaceholderAPI]]** | **[[Hook into PlaceholderAPI]]**
![versionImg] [![jenkinsImg]][jenkins] [![licenseImg]][license] [![issuesImg]][issues] [![discordImg]][discord]

78
wiki/_Sidebar.md Normal file
View File

@@ -0,0 +1,78 @@
<p align="center">
<img src="https://i.imgur.com/Adp7xdh.png" alt="PlaceholderAPI">
</p>
**[[Main page|Home]]**
### Setup
**[[Hook into PlaceholderAPI]]**
- [[First steps|Hook-into-PlaceholderAPI#first-steps]]
- [[Adding placeholders to PlaceholderAPI|Hook-into-PlaceholderAPI#adding-placeholders-to-placeholderapi]]
- [[PlaceholderExpansion]]
- [[Without an external plugin|PlaceholderExpansion#without-an-external-plugin]]
- [[With external plugin|PlaceholderExpansion#with-external-plugin]]
- [[Setting placeholders in your plugin|Hook-into-PlaceholderAPI#setting-placeholders-in-your-plugin]]
### Other
**[[Commands]]**
**[[Expansion cloud]]**
**[[FAQ]]**
**[[Plugins using PlaceholderAPI]]**
**[[Placeholders]]**
- [[PAPI-placeholders|Placeholders#papi-placeholders-1]]
- [[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]]
- [[B|Placeholders#b]]
- [[C|Placeholders#c]]
- [[D|Placeholders#d]]
- [[E|Placeholders#e]]
- [[F|Placeholders#f]]
- [[G|Placeholders#g]]
- [[H|Placeholders#h]]
- [[I|Placeholders#i]]
- [[J|Placeholders#j]]
- [[K|Placeholders#k]]
- [[L|Placeholders#l]]
- [[M|Placeholders#m]]
- [[N|Placeholders#n]]
- [[O|Placeholders#o]]
- [[P|Placeholders#p]]
- [[Q|Placeholders#q]]
- [[R|Placeholders#r]]
- [[S|Placeholders#s]]
- [[T|Placeholders#t]]
- [[U|Placeholders#u]]
- [[V|Placeholders#v]]
- [[W|Placeholders#w]]
- [[Z|Placeholders#z]]