Added level placeholder

This requires BentoBox 1.3.0

This needs testing with plugins that use placeholders.
This commit is contained in:
tastybento 2019-02-02 12:31:14 -08:00
parent 05ebb4c283
commit 8eaca607d8
3 changed files with 46 additions and 1 deletions

View File

@ -6,7 +6,7 @@
<groupId>world.bentobox</groupId> <groupId>world.bentobox</groupId>
<artifactId>level</artifactId> <artifactId>level</artifactId>
<version>1.1-SNAPSHOT</version> <version>1.2-SNAPSHOT</version>
<name>Level</name> <name>Level</name>
<description>Level is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock or AcidIsland.</description> <description>Level is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock or AcidIsland.</description>

View File

@ -18,6 +18,7 @@ import world.bentobox.level.config.Settings;
import world.bentobox.level.listeners.JoinLeaveListener; import world.bentobox.level.listeners.JoinLeaveListener;
import world.bentobox.level.listeners.NewIslandListener; import world.bentobox.level.listeners.NewIslandListener;
import world.bentobox.level.objects.LevelsData; import world.bentobox.level.objects.LevelsData;
import world.bentobox.level.placeholders.LevelPlaceholder;
import world.bentobox.level.requests.LevelRequestHandler; import world.bentobox.level.requests.LevelRequestHandler;
/** /**
@ -125,6 +126,11 @@ public class Level extends Addon {
new IslandLevelCommand(this, playerCmd); new IslandLevelCommand(this, playerCmd);
new IslandTopCommand(this, playerCmd); new IslandTopCommand(this, playerCmd);
}); });
// Register placeholders
getPlugin().logDebug(getPlugin().getPlaceholdersManager());
if (getPlugin().getPlaceholdersManager() != null) {
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "island-level", new LevelPlaceholder(this, gm));
}
}); });
// Register new island listener // Register new island listener
@ -134,6 +140,8 @@ public class Level extends Addon {
// Register request handlers // Register request handlers
registerRequestHandler(new LevelRequestHandler(this)); registerRequestHandler(new LevelRequestHandler(this));
// Done // Done
} }

View File

@ -0,0 +1,37 @@
/**
*
*/
package world.bentobox.level.placeholders;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.placeholders.PlaceholderReplacer;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.level.Level;
/**
* @author tastybento
*
*/
public class LevelPlaceholder implements PlaceholderReplacer {
private Level addon;
private GameModeAddon gm;
/**
* Provides placeholder support
* @param gm
*/
public LevelPlaceholder(Level addon, GameModeAddon gm) {
this.addon = addon;
this.gm = gm;
}
/* (non-Javadoc)
* @see world.bentobox.bentobox.api.placeholders.PlaceholderReplacer#onReplace(world.bentobox.bentobox.api.user.User)
*/
@Override
public String onReplace(User user) {
return String.valueOf(addon.getIslandLevel(gm.getOverWorld(), user.getUniqueId()));
}
}