diff --git a/src/main/java/dev/chaws/automaticinventory/commands/AutoSortCommand.java b/src/main/java/dev/chaws/automaticinventory/commands/AutoSortCommand.java index 17747e1..52c11c2 100644 --- a/src/main/java/dev/chaws/automaticinventory/commands/AutoSortCommand.java +++ b/src/main/java/dev/chaws/automaticinventory/commands/AutoSortCommand.java @@ -6,6 +6,7 @@ import dev.chaws.automaticinventory.messaging.Messages; import dev.chaws.automaticinventory.utilities.Chat; import dev.chaws.automaticinventory.utilities.Level; +import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -25,6 +26,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command var playerConfig = PlayerConfig.fromPlayer(player); + // Guard to prevent out of index error + if (args.length < 1) { + Chat.sendMessage(player, ChatColor.GOLD, "Usage: /autosort [chest|inv]"); + return false; + } + var optionName = args[0].toLowerCase(); if (optionName.startsWith("chest")) { if (!AutomaticInventory.hasPermission(Features.SortChests, player)) {