Add use-control-panel option to config

This commit is contained in:
tastybento 2020-04-18 14:46:06 -07:00
parent a3d4b0e381
commit 111875f09c
3 changed files with 25 additions and 1 deletions

View File

@ -50,7 +50,11 @@ public class AISettings implements WorldSettings {
@ConfigComment("The island admin command.")
@ConfigEntry(path = "acid.command.admin")
private String adminCommand = "acid";
@ConfigComment("Use control panel if it exists (ControlPanel addon must be in addons)")
@ConfigEntry(path = "acid.use-control-panel", since = "1.13.0")
private boolean useControlPanel = false;
// Damage
@ConfigComment("Damage that a player will experience in acid. 10 is half their health typically. 5 would be easier.")
@ -1693,4 +1697,16 @@ public class AISettings implements WorldSettings {
public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) {
this.ticksPerMonsterSpawns = ticksPerMonsterSpawns;
}
/**
* @return the useControlPanel
*/
public boolean isUseControlPanel() {
return useControlPanel;
}
/**
* @param useControlPanel the useControlPanel to set
*/
public void setUseControlPanel(boolean useControlPanel) {
this.useControlPanel = useControlPanel;
}
}

View File

@ -3,6 +3,7 @@ package world.bentobox.acidisland.commands;
import java.util.ArrayList;
import java.util.List;
import world.bentobox.acidisland.AcidIsland;
import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.commands.island.IslandBanCommand;
@ -71,8 +72,13 @@ public class AiCommand extends CompositeCommand {
if (args.isEmpty()) {
// If in world, go
if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) != null) {
return getSubCommand("go").map(goCmd -> goCmd.call(user, label, new ArrayList<>())).orElse(false);
if (((AcidIsland)getAddon()).getSettings().isUseControlPanel()
&& getSubCommand("controlpanel").isPresent()) {
return getSubCommand("controlpanel").get().call(user, label, new ArrayList<>());
}
return getSubCommand("go").map(goCmd -> goCmd.call(user, goCmd.getLabel(), new ArrayList<>())).orElse(false);
}
// No islands currently
return getSubCommand("create").map(createCmd -> createCmd.call(user, label, new ArrayList<>())).orElse(false);
}

View File

@ -9,6 +9,8 @@ acid:
island: ai
# The island admin command.
admin: acid
# Use control panel if it exists (ControlPanel addon must be in addons)
use-control-panel: false
damage:
acid:
# Damage that a player will experience in acid. 10 is half their health typically. 5 would be easier.