From 27a6c1bd549f4e06e5eeeb3d683b147aec10432a Mon Sep 17 00:00:00 2001 From: Logan Date: Mon, 18 Aug 2025 20:44:16 -0500 Subject: [PATCH] feat: better handling of invalid cosmetics for dye subcommand --- .../hmccosmetics/command/CosmeticCommand.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java index 0a76002e..ad3bc237 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java @@ -310,13 +310,17 @@ public class CosmeticCommand implements CommandExecutor { return true; } - String rawSlot = args[1]; + final String rawSlot = args[1]; if (!CosmeticSlot.contains(rawSlot)) { if (!silent) MessagesUtil.sendMessage(player, "invalid-slot"); return true; } - CosmeticSlot slot = CosmeticSlot.valueOf(rawSlot); - Cosmetic cosmetic = user.getCosmetic(slot); + final CosmeticSlot slot = CosmeticSlot.valueOf(rawSlot); // This is checked above. While IDEs may say the slot might be null, it will not be. + final Cosmetic cosmetic = user.getCosmetic(slot); + if (cosmetic == null) { + if (!silent) MessagesUtil.sendMessage(player, "invalid-slot"); + return true; + } if (args.length >= 3) { if (args[2].isEmpty()) {