From 4fc2c3b786b10feff6c02cee3b1f1cfd35f7d44e Mon Sep 17 00:00:00 2001 From: Calcilore Date: Sun, 23 Jun 2024 01:37:10 +1000 Subject: [PATCH] Update 4.3.1: Fixed plugin not starting on 1.7 and below, and disabled /setmaxhealth on 1.3 because it does not work. --- pom.xml | 2 +- .../net/serble/estools/Commands/GameModeCommand.java | 9 ++++++--- src/main/java/net/serble/estools/Main.java | 11 +++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 84e9508..6764ab7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.serble.EsTools EsTools - 4.3.1 + 4.3.2 jar EsTools diff --git a/src/main/java/net/serble/estools/Commands/GameModeCommand.java b/src/main/java/net/serble/estools/Commands/GameModeCommand.java index 0e91a4a..a2c591e 100644 --- a/src/main/java/net/serble/estools/Commands/GameModeCommand.java +++ b/src/main/java/net/serble/estools/Commands/GameModeCommand.java @@ -9,10 +9,13 @@ import java.util.ArrayList; public class GameModeCommand extends MultiPlayerCommand { - private final GameMode gameMode; + private GameMode gameMode; - public GameModeCommand(GameMode gameMode) { - this.gameMode = gameMode; + public GameModeCommand(String gameMode) { + // If it's an old version it will throw when trying to get Enum Value, so we ignore it. + try { + this.gameMode = GameMode.valueOf(gameMode); + } catch (IllegalArgumentException ignored) {} } @Override diff --git a/src/main/java/net/serble/estools/Main.java b/src/main/java/net/serble/estools/Main.java index a301b6e..473265b 100644 --- a/src/main/java/net/serble/estools/Main.java +++ b/src/main/java/net/serble/estools/Main.java @@ -12,7 +12,6 @@ import org.bstats.bukkit.Metrics; import org.bstats.charts.SimplePie; import org.bukkit.Bukkit; -import org.bukkit.GameMode; import org.bukkit.command.PluginCommand; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.java.JavaPlugin; @@ -75,10 +74,10 @@ public void onEnable() { } // Commands - sc("gms", "gamemode.survival", new GameModeCommand(GameMode.SURVIVAL)); - sc("gmc", "gamemode.creative", new GameModeCommand(GameMode.CREATIVE)); - sc("gma", "gamemode.adventure", new GameModeCommand(GameMode.ADVENTURE), 3); - sc("gmsp", "gamemode.spectator", new GameModeCommand(GameMode.SPECTATOR), 8); + sc("gms", "gamemode.survival", new GameModeCommand("SURVIVAL")); + sc("gmc", "gamemode.creative", new GameModeCommand("CREATIVE")); + sc("gma", "gamemode.adventure", new GameModeCommand("ADVENTURE"), 3); + sc("gmsp", "gamemode.spectator", new GameModeCommand("SPECTATOR"), 8); sc("tphere", "tp", new TpHere()); sc("tpall", "tp", new TpAll()); sc("feed", "feed", new Feed()); @@ -124,7 +123,7 @@ public void onEnable() { sc("heal", "heal", new Heal()); sc("suicide", "suicide", new Suicide()); sc("sethealth", "sethealth", new SetHealth()); - sc("setmaxhealth", "setmaxhealth", new SetMaxHealth(), 3); + sc("setmaxhealth", "setmaxhealth", new SetMaxHealth(), 4); sc("getinfo", "getinfo", new GetInfo()); sc("editsign", "editsign", new EditSign());