From 5eebcb9ff42a9be12c422fb69060c2ee5078d8d8 Mon Sep 17 00:00:00 2001 From: hyperdefined Date: Sat, 18 Jun 2022 17:09:12 -0400 Subject: [PATCH] make sure chests are in the same world fixes #14 --- .../java/lol/hyper/toolstats/events/GenerateLoot.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/lol/hyper/toolstats/events/GenerateLoot.java b/src/main/java/lol/hyper/toolstats/events/GenerateLoot.java index 217fe11..82bea0a 100644 --- a/src/main/java/lol/hyper/toolstats/events/GenerateLoot.java +++ b/src/main/java/lol/hyper/toolstats/events/GenerateLoot.java @@ -65,9 +65,11 @@ public class GenerateLoot implements Listener { // if the distance is less than 1, it's the same chest for (Block chest : toolStats.playerInteract.openedChests.keySet()) { Location chestLocation = chest.getLocation(); - double distance = lootLocation.distance(chestLocation); - if (distance <= 1.0) { - openedChest = chest; + if (chest.getWorld() == lootLocation.getWorld()) { + double distance = lootLocation.distance(chestLocation); + if (distance <= 1.0) { + openedChest = chest; + } } } // ignore if the chest is not in the same location