From eff2ae6cf7c32b10b6dd13ab6ac816d814f08c89 Mon Sep 17 00:00:00 2001
From: MasterBro Network <60338675+MasterBroNetwork@users.noreply.github.com>
Date: Thu, 15 Sep 2022 05:44:20 +0100
Subject: [PATCH] Update source code to match v1.1
---
pom.xml | 2 +-
.../commands/DestroyEntityCommand.java | 18 ++++++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
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];