make sure chests are in the same world

fixes #14
This commit is contained in:
hyperdefined
2022-06-18 17:09:12 -04:00
parent 63d508fded
commit 5eebcb9ff4

View File

@@ -65,11 +65,13 @@ public class GenerateLoot implements Listener {
// if the distance is less than 1, it's the same chest // if the distance is less than 1, it's the same chest
for (Block chest : toolStats.playerInteract.openedChests.keySet()) { for (Block chest : toolStats.playerInteract.openedChests.keySet()) {
Location chestLocation = chest.getLocation(); Location chestLocation = chest.getLocation();
if (chest.getWorld() == lootLocation.getWorld()) {
double distance = lootLocation.distance(chestLocation); double distance = lootLocation.distance(chestLocation);
if (distance <= 1.0) { if (distance <= 1.0) {
openedChest = chest; openedChest = chest;
} }
} }
}
// ignore if the chest is not in the same location // ignore if the chest is not in the same location
if (openedChest == null) { if (openedChest == null) {
return; return;