Adds some missing command argument checks

This commit is contained in:
Kristian Knarvik 2023-03-26 15:52:54 +02:00
parent 0c58860026
commit 49eb0ac82c
3 changed files with 22 additions and 2 deletions

View File

@ -21,6 +21,10 @@ public class EditArenaCommand implements CommandExecutor {
return false;
}
if (arguments.length < 2) {
return false;
}
DropperArena specifiedArena = Dropper.getInstance().getArenaHandler().getArena(arguments[0]);
if (specifiedArena == null) {
commandSender.sendMessage("Unable to find the specified dropper arena.");

View File

@ -3,15 +3,19 @@ package net.knarcraft.dropper.command;
import net.knarcraft.dropper.Dropper;
import net.knarcraft.dropper.arena.DropperArenaSession;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* The command used to leave the current dropper arena
*/
public class LeaveArenaCommand implements CommandExecutor {
public class LeaveArenaCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
@ -32,4 +36,11 @@ public class LeaveArenaCommand implements CommandExecutor {
return true;
}
@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
@NotNull String[] arguments) {
return new ArrayList<>();
}
}

View File

@ -15,6 +15,11 @@ public class RemoveArenaCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
@NotNull String[] arguments) {
// Abort if no name was specified
if (arguments.length < 1) {
return false;
}
// Get the specified arena
DropperArena targetArena = Dropper.getInstance().getArenaHandler().getArena(arguments[0]);
if (targetArena == null) {