diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/NpcCommand.java b/common/src/main/java/org/samo_lego/taterzens/commands/NpcCommand.java index 2f3f959c1..c0c0c13a0 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/NpcCommand.java +++ b/common/src/main/java/org/samo_lego/taterzens/commands/NpcCommand.java @@ -252,18 +252,19 @@ private static int selectTaterzenByName(CommandContext conte if (npcIt.getName().getString().equals(name)) { taterzen = npcIt; count++; + + if (count > 1) { + source.sendFailure(errorText("taterzens.error.multiple.name", name)); + return 0; + } } } if (count == 0) { // equivalent to taterzen == null source.sendFailure(errorText("taterzens.error.404.name", name)); - return -1; - } - else if (count > 1) { - source.sendFailure(errorText("taterzens.error.multiple.name", name)); - return -1; + return 0; } - else if (count == 1) { + else { // if count == 1 ServerPlayer player = source.getPlayerOrException(); TaterzenNPC npc = ((ITaterzenEditor) player).getNpc(); @@ -281,16 +282,9 @@ else if (count == 1) { source.sendFailure( errorText("taterzens.command.error.locked", taterzen.getName().getString()) ); - return -1; + return 0; } } - else { - // in theory there could be more than 2^32-1 NPCs. - // More than that will result in an overflow, i.e. a negative int. - // In practise, this is highly improbable. - - return -1; - } } private static String[] getAvailableTaterzenUUIDs() { @@ -309,8 +303,8 @@ private static int selectTaterzenByUUID(CommandContext conte try { uuid = UUID.fromString(StringArgumentType.getString(context, "uuid")); } catch (IllegalArgumentException ex) { - source.sendFailure(errorText("taterzens.error.invalid.uuid")); - return -1; + source.sendFailure(errorText("argument.uuid.invalid")); + return 0; } TaterzenNPC taterzen = null; @@ -324,7 +318,7 @@ private static int selectTaterzenByUUID(CommandContext conte } if (taterzen == null) { source.sendFailure(errorText("taterzens.error.404.uuid", uuid.toString())); - return -1; + return 0; } else { ServerPlayer player = source.getPlayerOrException(); TaterzenNPC npc = ((ITaterzenEditor) player).getNpc(); @@ -342,7 +336,7 @@ private static int selectTaterzenByUUID(CommandContext conte source.sendFailure( errorText("taterzens.command.error.locked", taterzen.getName().getString()) ); - return -1; + return 0; } } } diff --git a/common/src/main/resources/data/taterzens/lang/en_us.json b/common/src/main/resources/data/taterzens/lang/en_us.json index 533d1fc24..92052621b 100644 --- a/common/src/main/resources/data/taterzens/lang/en_us.json +++ b/common/src/main/resources/data/taterzens/lang/en_us.json @@ -116,7 +116,6 @@ "taterzens.tooltip.exit": "Exit", "taterzens.error.invalid.url": "URL %s is malformed.", "taterzens.error.invalid.text": "The text nbt you entered is invalid.", - "taterzens.error.invalid.uuid": "The uuid you entered is invalid.", "taterzens.error.404.detected": "No Taterzen was detected in front of you.", "taterzens.error.404.id": "No Taterzen with id %s was found.", "taterzens.error.404.name": "No Taterzen with name %s was found.",