mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-23 18:45:17 +01:00
Added level placeholder
This requires BentoBox 1.3.0 This needs testing with plugins that use placeholders.
This commit is contained in:
parent
05ebb4c283
commit
8eaca607d8
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>world.bentobox</groupId>
|
||||
<artifactId>level</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
|
||||
<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>
|
||||
|
@ -18,6 +18,7 @@ import world.bentobox.level.config.Settings;
|
||||
import world.bentobox.level.listeners.JoinLeaveListener;
|
||||
import world.bentobox.level.listeners.NewIslandListener;
|
||||
import world.bentobox.level.objects.LevelsData;
|
||||
import world.bentobox.level.placeholders.LevelPlaceholder;
|
||||
import world.bentobox.level.requests.LevelRequestHandler;
|
||||
|
||||
/**
|
||||
@ -125,6 +126,11 @@ public class Level extends Addon {
|
||||
new IslandLevelCommand(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
|
||||
@ -134,6 +140,8 @@ public class Level extends Addon {
|
||||
// Register request handlers
|
||||
registerRequestHandler(new LevelRequestHandler(this));
|
||||
|
||||
|
||||
|
||||
// Done
|
||||
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user