Changes config.yml to enable hooking into any gamemode

When upgrading, must delete config.yml to get new version.

Also changes placeholder names to be prefixed with GameModeAddon name in
lower case. e.g, %bskyblock-island-level%

https://github.com/BentoBoxWorld/Level/issues/39
https://github.com/BentoBoxWorld/BentoBox/issues/322
https://github.com/BentoBoxWorld/Level/issues/27
This commit is contained in:
tastybento 2019-02-03 22:30:27 -08:00
parent 8fa3f51666
commit bf965277c3
3 changed files with 26 additions and 13 deletions

View File

@ -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));
}
}
});

View File

@ -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<String> 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<String> getGameModes() {
return gameModes;
}
}

View File

@ -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.