From 111875f09ce54aaccd813c82fca5442f08004acb Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 18 Apr 2020 14:46:06 -0700 Subject: [PATCH] Add use-control-panel option to config --- .../world/bentobox/acidisland/AISettings.java | 16 ++++++++++++++++ .../bentobox/acidisland/commands/AiCommand.java | 8 +++++++- src/main/resources/config.yml | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/acidisland/AISettings.java b/src/main/java/world/bentobox/acidisland/AISettings.java index 0ee7275..33260d2 100644 --- a/src/main/java/world/bentobox/acidisland/AISettings.java +++ b/src/main/java/world/bentobox/acidisland/AISettings.java @@ -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; + } } diff --git a/src/main/java/world/bentobox/acidisland/commands/AiCommand.java b/src/main/java/world/bentobox/acidisland/commands/AiCommand.java index b4e228e..df12325 100644 --- a/src/main/java/world/bentobox/acidisland/commands/AiCommand.java +++ b/src/main/java/world/bentobox/acidisland/commands/AiCommand.java @@ -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); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 19d7885..04798d8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -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.