From 47f0804fc9023db5bc868551f05e89804a950e25 Mon Sep 17 00:00:00 2001 From: levischnorr Date: Tue, 6 Feb 2024 11:27:26 +0100 Subject: [PATCH] Fix Exception --- .../java/mavenmcserver/command/CommandTicTacToe.java | 12 +++++++++++- .../main/java/mavenmcserver/game/CubicBlockArea.java | 10 ---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mavenmcserver/src/main/java/mavenmcserver/command/CommandTicTacToe.java b/mavenmcserver/src/main/java/mavenmcserver/command/CommandTicTacToe.java index 04e4439..bd413aa 100644 --- a/mavenmcserver/src/main/java/mavenmcserver/command/CommandTicTacToe.java +++ b/mavenmcserver/src/main/java/mavenmcserver/command/CommandTicTacToe.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -40,6 +41,15 @@ public CommandTicTacToe(Plugin plugin) { this.plugin.getCommand(CommandTicTacToe.COMMAND_NAME).setTabCompleter(this); } + public CubicBlockArea(Location startBlock, Location endBlock) { + if(startBlock.getWorld() != endBlock.getWorld()) { + throw new IllegalArgumentException("Attempted to create a CubicBlockArea with two Locations in different worlds. Have '" + startBlock.getWorld().getName() + "' and '" + endBlock.getWorld().getName() + "'!"); + } + + this.startBlock = startBlock; + this.endBlock = endBlock; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -177,7 +187,7 @@ public List onTabComplete(CommandSender sender, Command command, String } ArrayList filteredCompletions = new ArrayList(); - StringUtil.copyPartialMatches(argList.get(argList.size() - 1), completions, filteredCompletions); + StringUtil.copyPartialMatches(argList.size() > 0 ? argList.get(argList.size() - 1) : "", completions, filteredCompletions); return filteredCompletions; } diff --git a/mavenmcserver/src/main/java/mavenmcserver/game/CubicBlockArea.java b/mavenmcserver/src/main/java/mavenmcserver/game/CubicBlockArea.java index 59b77a7..4dfa3a4 100644 --- a/mavenmcserver/src/main/java/mavenmcserver/game/CubicBlockArea.java +++ b/mavenmcserver/src/main/java/mavenmcserver/game/CubicBlockArea.java @@ -11,16 +11,6 @@ public class CubicBlockArea { public Location startBlock; public Location endBlock; - public CubicBlockArea(Location startBlock, Location endBlock) { - if(startBlock.getWorld() != endBlock.getWorld()) { - throw new IllegalArgumentException("Attempted to create a CubicBlockArea with two Locations in different worlds. Have '" + startBlock.getWorld().getName() + "' and '" + endBlock.getWorld().getName() + "'!"); - } - - this.startBlock = startBlock; - this.endBlock = endBlock; - } - - public boolean contains(Location block) { if(block.getWorld() != this.startBlock.getWorld()) { throw new IllegalArgumentException("Attempted to execute contains() on a CubicBlockArea in world '" + this.startBlock.getWorld().getName() + "' using a location in world '" + block.getWorld().getName() + "'");