Skip to content

Commit

Permalink
Fix Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
lscgh committed Feb 6, 2024
1 parent 5bfd4ec commit 47f0804
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -177,7 +187,7 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
}

ArrayList<String> filteredCompletions = new ArrayList<String>();
StringUtil.copyPartialMatches(argList.get(argList.size() - 1), completions, filteredCompletions);
StringUtil.copyPartialMatches(argList.size() > 0 ? argList.get(argList.size() - 1) : "", completions, filteredCompletions);

return filteredCompletions;
}
Expand Down
10 changes: 0 additions & 10 deletions mavenmcserver/src/main/java/mavenmcserver/game/CubicBlockArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() + "'");
Expand Down

0 comments on commit 47f0804

Please sign in to comment.