BentoBoxWorld / BentoBox

Expandable Minecraft server plugin for island-type games like SkyBlock or AcidIsland.
https://bentobox.world
Eclipse Public License 2.0
334 stars 136 forks source link

PlaceholderAPI Placeholders automatically registered to each GameModeAddon #322

Closed BiGUNMAN closed 5 years ago

BiGUNMAN commented 5 years ago

Description Placeholders that hook into PlaceholderAPI.

Placeholders %island_owner% - Owner of current island, returns empty if no owner. %island_team_size% - Returns number of island members %island_teammember[#] - Returns name of island member (# represents a particular member) %island_level_topvalue[1-10] - Displays the level of the top islands (1 being #1 island, 10 being #10 island) %island_level_topname[1-10] - Displays island owner of the top islands %island_protection_size% - Returns protection size of the player's island (not the island they are standing in, but their own island). %islandflag(flag-name)% - Return the value that the island flag is set to - this will probably be used the least. %island_has_island% - true/false if player has an island - Should probably include a 3rd option that says if they are part of a team.

I've probably not thought of everything yet, but this is a start. I think the ones above will be used the most.

More Placeholders PlaceholderAPI: https://www.spigotmc.org/wiki/placeholderapi-plugin-placeholders-page-1/#askyblock - has 4 more nice placeholders that would also probably be nice to have (island z, x, world, coop).

MVDW has a ton of placeholders, not sure how necessary they are. The more the merrier though: https://www.spigotmc.org/wiki/mvdw-placeholders/

Poslovitch commented 5 years ago

reminder: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Hooking-into-PlaceholderAPI

Poslovitch commented 5 years ago

PlaceholderAPI integration is done. Let's add the placeholders now!

tastybento commented 5 years ago

There's a bug that occurs on startup with 0.13.0-SNAPSHOT because the plugin doesn't check if PlaceholderAPI plugin exists or not.

[01:31:27 WARN]: [BentoBox] Task #8 for BentoBox v0.13.0-SNAPSHOT generated an exception
java.lang.NoClassDefFoundError: me/clip/placeholderapi/expansion/PlaceholderExpansion
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_181]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[?:1.8.0_181]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_181]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:150) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at org.bukkit.plugin.java.JavaPluginLoader.getClassByName(JavaPluginLoader.java:193) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:111) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:100) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_181]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_181]
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_181]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[?:1.8.0_181]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_181]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:150) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at org.bukkit.plugin.java.JavaPluginLoader.getClassByName(JavaPluginLoader.java:193) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:111) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:100) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_181]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_181]
    at world.bentobox.bentobox.hooks.PlaceholderAPIHook.<init>(PlaceholderAPIHook.java:27) ~[?:?]
    at world.bentobox.bentobox.BentoBox.lambda$onEnable$1(BentoBox.java:150) ~[?:?]
    at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftTask.run(CraftTask.java:76) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:361) [spigot.jar:git-Spigot-2474d93-e693496]
    at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:893) [spigot.jar:git-Spigot-2474d93-e693496]
    at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:417) [spigot.jar:git-Spigot-2474d93-e693496]
    at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:835) [spigot.jar:git-Spigot-2474d93-e693496]
    at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:733) [spigot.jar:git-Spigot-2474d93-e693496]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
Caused by: java.lang.ClassNotFoundException: me.clip.placeholderapi.expansion.PlaceholderExpansion
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_181]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:154) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:100) ~[spigot.jar:git-Spigot-2474d93-e693496]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_181]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_181]
    ... 27 more

I'll try and fix it.

tastybento commented 5 years ago

@Poslovitch I added a check for the Placeholder API's mentioned in the soft depend of plugin.yml. I am not familiar with MVdWPlaceholderAPI. I included it in the check but I don't think it's a drop-in replacement so I think the check should just be for PlaceholderAPI right now. Can you check it?

Poslovitch commented 5 years ago

Oh, I see what's wrong on this one!

Poslovitch commented 5 years ago

MVdWPlaceholderAPI is not supported yet though. Maybe I'll work on this today.

Poslovitch commented 5 years ago

Fixed the bug once and for all in the commit above

Poslovitch commented 5 years ago

Here are some other placeholders I thought may be interesting:

%sb_island_protection_range%
%sb_island_center%
%sb_island_owner%
%sb_island_creation_date%
%sb_island_distance%
%sb_island_spawnpoint%
Kryniowesegryderiusz commented 5 years ago

Where can i find list of actually implemented placeholders?

Poslovitch commented 5 years ago

@Kryniowesegryderiusz None is implemented yet.

TheWranger commented 5 years ago

@Poslovitch PlaceholderAPI already has a placeholder that allows you to use any placeholder from MVdWPlaceholderAPI

AbelMG commented 5 years ago

How can I add addons to BSkyblock?

Poslovitch commented 5 years ago

@AbelMG Off-topic.

Poslovitch commented 5 years ago

Unlocking and removed the "bug" label. It's been added when there was an issue with the placeholderapi hook, but that's not relevant to this issue.

TheWranger commented 5 years ago

Should %island_has_island% respond with true if the user has an island but isn't the owner of it? Also, I think %island_owner% should be split into two placeholders: %island_owner% displays the owner of the island that YOU are a part of %island_locowner% displays the owner of the island that you are standing on (pretty much the thing that was suggested in the main issue)

Other placeholders that I think would be cool to see: %island_level% (Level Addon) -Displays the current island level, good for scoreboards %island_rank% - Displays what rank you have on your island %island_name% - Displays the name of the island you are a part of

tastybento commented 5 years ago

Added these placeholders (BSkyBlock examples):

Level Placeholder %Level_bskyblock-island-level% - the player's level

Top Ten Placeholders %Level_bskyblock-island-level-top-value-x% where x is a number between 1 and 10 %Level_bskyblock-island-level-top-name-x% where x is a number between 1 and 10

If the top ten is less than 10 players then the placeholder will return an empty string.

To get the the values for other game modes, for example AcidIsland or CaveBlock, use the same format but with the Addon name in lower case, e.g. %Level_acidisland-island-level%

PizzaMC commented 5 years ago

These don't work. No placeholders on mentioned here work..

Poslovitch commented 5 years ago

@PizzaMC ...Maybe because this is a feature request...?

Poslovitch commented 5 years ago

Anyway, I'm gonna work on placeholders that'll be automatically registered by every GameModeAddon. That's going to be easier.

tastybento commented 5 years ago

@PizzaMC The Level add-on ones are done and work. It does require PAPI plugin to be installed. The BentoBox ones though still need to be done.

Deathinflames commented 5 years ago

Hiya Poslovitch and tastybento! :D

May i request that the next placeholder to be implemented be one that returns true/false if the player is the island owner? It would be super beneficial to have this placeholder so that it could be used as an important requirement to check for island upgrades.

I know there are more important things to work on but i thought i'd just throw this out there due to how useful it actually is.

Thanks!

BONNe commented 5 years ago

If you plan to use placeholders just to find out, if user has or has not owner of island, then you are doing something wrong.

I know, that "hype" about placeholders is their simplicity. But using them to get information is just the same, as using JAVA to open any browser. Yes, you can do it, but it is just wrong.

Poslovitch commented 5 years ago

@Deathinflames @BONNe Placeholders are not designed to get data that will later be used in a programmatic manner. They're used to display things.

And @Deathinflames: such placeholder has already been suggested.

BONNe commented 5 years ago

@Poslovitch No there is not a placeholder, that returns TRUE/FALSE and @Deathinflames was asking for it.

Poslovitch commented 5 years ago

@BONNe I think you misunderstood what I was saying: image

Placeholders are not methods to get data like Island#getOwner() would. They are used to display things. true, false, 45, 798.13 €, Pikachu, N/A...

Deathinflames commented 5 years ago

@BONNe While i understand that placeholders might not be designed to be used in a programmatic manner as @Poslovitch has pointed out, and they should only be used to display stats and such, there are more than quite a few people that use them in conjunction with say DeluxeMenus for example as conditional requirements for other things that IMO do not justify the need to have a whole separate addon/plugin be created for if it can just be as simple as checking the output of certain placeholders.

Yes, i agree this might be wrong and not a very logical way of doing things from a developers point of view but for the sake of functionality it's another valid way of doing things and it works quite well, otherwise why would clip have created such a thing?

Also @Poslovitch i understand it's already been suggested, my post was simply to request that this particular placeholder be expedited, but i think that's probably out the window now with this disagreement in functionality.

Poslovitch commented 5 years ago

Placeholders are planned and will be implemented in 1.4.0. Don't worry about that @Deathinflames.

TheWranger commented 5 years ago

Would also be cool to see a placeholder that returns how many island resets the player has left. %island_resets_remaining%

Poslovitch commented 5 years ago

Closing this, as the PR has been merged. Please create feature requests if you want us to add some specific placeholders that we didn't add there.