Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a guard to /autosort to check if an argument was given. #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down