Skip to content

Commit

Permalink
Changes config.yml to enable hooking into any gamemode
Browse files Browse the repository at this point in the history
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%

#39
BentoBoxWorld/BentoBox#322
#27
  • Loading branch information
tastybento committed Feb 4, 2019
1 parent 8fa3f51 commit bf96527
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/main/java/world/bentobox/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ public void onEnable() {
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);
Expand All @@ -130,11 +131,11 @@ public void onEnable() {
});
// 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));
}
}
});
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/world/bentobox/level/config/Settings.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -221,4 +227,11 @@ public Map<World, Map<Material, Integer>> getWorldBlockValues() {
return worldBlockValues;
}

/**
* @return the gameModes
*/
public List<String> getGameModes() {
return gameModes;
}

}
17 changes: 8 additions & 9 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit bf96527

Please sign in to comment.