mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-09-25 13:22:52 +02:00
Added defensive code to handle island adding to grid.
When an island cannot be added to the grid, it should show some helpful console error. Related to https://github.com/BentoBoxWorld/bentobox/issues/326
This commit is contained in:
parent
161975adde
commit
68873e033f
@ -3,6 +3,7 @@ package world.bentobox.bentobox.managers.island;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,6 +23,9 @@ class IslandGrid {
|
|||||||
if (grid.containsKey(island.getMinX())) {
|
if (grid.containsKey(island.getMinX())) {
|
||||||
TreeMap<Integer, Island> zEntry = grid.get(island.getMinX());
|
TreeMap<Integer, Island> zEntry = grid.get(island.getMinX());
|
||||||
if (zEntry.containsKey(island.getMinZ())) {
|
if (zEntry.containsKey(island.getMinZ())) {
|
||||||
|
BentoBox.getInstance().logError("Cannot add island to grid because there is an overlapping");
|
||||||
|
BentoBox.getInstance().logError("island already registered at this location:" + island.getCenter());
|
||||||
|
BentoBox.getInstance().logError("This is most likely caused by island distances changing mid-game, or an old database file");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// Add island
|
// Add island
|
||||||
|
@ -118,7 +118,11 @@ public class NewIsland {
|
|||||||
}
|
}
|
||||||
// Add to the grid
|
// Add to the grid
|
||||||
island = plugin.getIslands().createIsland(next, user.getUniqueId());
|
island = plugin.getIslands().createIsland(next, user.getUniqueId());
|
||||||
// Save the player so that if the server is reset weird things won't happen
|
if (island == null) {
|
||||||
|
plugin.logError("Failed to make island! Island could not be added to the grid.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: Save the player so that if the server is reset weird things won't happen?
|
||||||
|
|
||||||
// Clear any old home locations (they should be clear, but just in case)
|
// Clear any old home locations (they should be clear, but just in case)
|
||||||
plugin.getPlayers().clearHomeLocations(world, user.getUniqueId());
|
plugin.getPlayers().clearHomeLocations(world, user.getUniqueId());
|
||||||
|
@ -21,7 +21,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemFactory;
|
import org.bukkit.inventory.ItemFactory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
Loading…
Reference in New Issue
Block a user