diff --git a/src/main/java/world/bentobox/level/Level.java b/src/main/java/world/bentobox/level/Level.java index 6a09f06..9083a39 100644 --- a/src/main/java/world/bentobox/level/Level.java +++ b/src/main/java/world/bentobox/level/Level.java @@ -118,8 +118,9 @@ public class Level extends Addon { registerListener(topTen); // Register commands for AcidIsland and BSkyBlock getPlugin().getAddonsManager().getGameModeAddons().stream() - .filter(gm -> gm.getDescription().getName().equals("AcidIsland") || gm.getDescription().getName().equals("BSkyBlock")) + .filter(gm -> settings.getGameModes().contains(gm.getDescription().getName())) .forEach(gm -> { + log("Level hooking into " + gm.getDescription().getName()); gm.getAdminCommand().ifPresent(adminCommand -> { new AdminLevelCommand(this, adminCommand); new AdminTopCommand(this, adminCommand); @@ -130,11 +131,11 @@ public class Level extends Addon { }); // Register placeholders if (getPlugin().getPlaceholdersManager() != null) { - getPlugin().getPlaceholdersManager().registerPlaceholder(this, "island-level", new LevelPlaceholder(this, gm)); + getPlugin().getPlaceholdersManager().registerPlaceholder(this, gm.getDescription().getName().toLowerCase() + "-island-level", new LevelPlaceholder(this, gm)); // Top Ten for (int i = 1; i < 11; i++) { - getPlugin().getPlaceholdersManager().registerPlaceholder(this, "island-level-top-value-" + i, new TopTenPlaceholder(this, gm, i)); - getPlugin().getPlaceholdersManager().registerPlaceholder(this, "island-level-top-name-" + i, new TopTenNamePlaceholder(this, gm, i)); + getPlugin().getPlaceholdersManager().registerPlaceholder(this, gm.getDescription().getName().toLowerCase() + "-island-level-top-value-" + i, new TopTenPlaceholder(this, gm, i)); + getPlugin().getPlaceholdersManager().registerPlaceholder(this, gm.getDescription().getName().toLowerCase() + "-island-level-top-name-" + i, new TopTenNamePlaceholder(this, gm, i)); } } }); diff --git a/src/main/java/world/bentobox/level/config/Settings.java b/src/main/java/world/bentobox/level/config/Settings.java index d0d7952..e0f49dd 100644 --- a/src/main/java/world/bentobox/level/config/Settings.java +++ b/src/main/java/world/bentobox/level/config/Settings.java @@ -1,6 +1,8 @@ package world.bentobox.level.config; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.bukkit.Bukkit; @@ -23,11 +25,15 @@ public class Settings { private int maxDeaths; private boolean islandResetDeathReset; private boolean teamJoinDeathReset; + private List gameModes = new ArrayList<>(); public Settings(Level level) { level.saveDefaultConfig(); + // GameModes + gameModes = level.getConfig().getStringList("game-modes"); + setLevelWait(level.getConfig().getInt("levelwait", 60)); if (getLevelWait() < 0) { setLevelWait(0); @@ -221,4 +227,11 @@ public class Settings { return worldBlockValues; } + /** + * @return the gameModes + */ + public List getGameModes() { + return gameModes; + } + } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 842ada4..2f8e1e1 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,14 +1,13 @@ # Config file for Level add-on for BSkyBlock or AcidIsland -# Command hook-in configuration. -# Level will try to hook into these commands when it starts -# If you have changed the default AcidIsland or BSkyBlock commands, change them here -acidisland: - admin-command: acid - user-command: ai -bskyblock: - admin-command: bsbadmin - user-command: island +# GameModes +# Level will hook into these game modes. Don't forget to set any world-specific +# block values below! +game-modes: +- AcidIsland +- BSkyBlock +- CaveBlock +#- SkyGrid # This file lists the values for various blocks that are used to calculate the # island level. Level = total of all blocks in island boundary / 100.