diff --git a/pom.xml b/pom.xml index bd5a8ef..5ba8a64 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.masterbro TesterUtils - 1.0 + 1.1 jar TesterUtils diff --git a/src/main/java/me/masterbro/testerutils/commands/DestroyEntityCommand.java b/src/main/java/me/masterbro/testerutils/commands/DestroyEntityCommand.java index 66874c2..a2650af 100644 --- a/src/main/java/me/masterbro/testerutils/commands/DestroyEntityCommand.java +++ b/src/main/java/me/masterbro/testerutils/commands/DestroyEntityCommand.java @@ -13,13 +13,17 @@ import java.util.List; public class DestroyEntityCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) { - sender.sendMessage("This command can only be used in-game."); + private boolean entityTypeExists(String string) { + try { + EntityType.valueOf(string); return true; + } catch(IllegalArgumentException exception) { + return false; } + } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = (Player) sender; if(args.length == 0) { @@ -27,6 +31,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St player.sendMessage("Correct usage: /destroyentity "); } else { + if(!entityTypeExists(args[1])) { + player.sendMessage("Error: The entity type that was specified doesn't exist."); + player.sendMessage("Please check the spelling and try again."); + return true; + } + EntityType entityType = EntityType.valueOf(args[1]); String worldName = args[0];