diff --git a/internal/paper26_2/src/main/java/com/lishid/openinv/internal/paper26_2/container/menu/OpenChestMenu.java b/internal/paper26_2/src/main/java/com/lishid/openinv/internal/paper26_2/container/menu/OpenChestMenu.java index 93dc5a58..137eb264 100644 --- a/internal/paper26_2/src/main/java/com/lishid/openinv/internal/paper26_2/container/menu/OpenChestMenu.java +++ b/internal/paper26_2/src/main/java/com/lishid/openinv/internal/paper26_2/container/menu/OpenChestMenu.java @@ -163,17 +163,17 @@ public InventoryType.SlotType getSlotType(int slot) { private int getTopSize(ServerPlayer viewer) { MenuType menuType = getType(); - if (menuType == MenuType.GENERIC_9x1) { + if (MenuType.GENERIC_9x1.equals(menuType)) { return 9; - } else if (menuType == MenuType.GENERIC_9x2) { + } else if (MenuType.GENERIC_9x2.equals(menuType)) { return 18; - } else if (menuType == MenuType.GENERIC_9x3) { + } else if (MenuType.GENERIC_9x3.equals(menuType)) { return 27; - } else if (menuType == MenuType.GENERIC_9x4) { + } else if (MenuType.GENERIC_9x4.equals(menuType)) { return 36; - } else if (menuType == MenuType.GENERIC_9x5) { + } else if (MenuType.GENERIC_9x5.equals(menuType)) { return 45; - } else if (menuType == MenuType.GENERIC_9x6) { + } else if (MenuType.GENERIC_9x6.equals(menuType)) { return 54; } // This is a bit gross, but allows us a safe fallthrough. diff --git a/internal/paper26_2/src/main/java/com/lishid/openinv/internal/paper26_2/container/slot/ContentOffHand.java b/internal/paper26_2/src/main/java/com/lishid/openinv/internal/paper26_2/container/slot/ContentOffHand.java index 2e15656b..0f1fe12c 100644 --- a/internal/paper26_2/src/main/java/com/lishid/openinv/internal/paper26_2/container/slot/ContentOffHand.java +++ b/internal/paper26_2/src/main/java/com/lishid/openinv/internal/paper26_2/container/slot/ContentOffHand.java @@ -10,6 +10,8 @@ import org.bukkit.event.inventory.InventoryType; import org.jetbrains.annotations.NotNull; +import java.util.Objects; + /** * A slot for equipment that updates held items if necessary. */ @@ -37,7 +39,7 @@ public Slot asSlot(Container container, int slot, int x, int y) { return new SlotEquipment(container, slot, x, y) { @Override public void setChanged() { - if (OpenPlayer.isConnected(holder.connection) && holder.containerMenu != holder.inventoryMenu) { + if (OpenPlayer.isConnected(holder.connection) && !Objects.equals(holder.containerMenu, holder.inventoryMenu)) { holder.connection.send( new ClientboundContainerSetSlotPacket( holder.inventoryMenu.containerId, diff --git a/internal/spigot26_2/src/main/java/com/github/jikoo/openinv/internal/spigot26_2/container/menu/OpenChestMenu.java b/internal/spigot26_2/src/main/java/com/github/jikoo/openinv/internal/spigot26_2/container/menu/OpenChestMenu.java index 00b5322d..7810cb07 100644 --- a/internal/spigot26_2/src/main/java/com/github/jikoo/openinv/internal/spigot26_2/container/menu/OpenChestMenu.java +++ b/internal/spigot26_2/src/main/java/com/github/jikoo/openinv/internal/spigot26_2/container/menu/OpenChestMenu.java @@ -164,17 +164,17 @@ public int convertSlot(int rawSlot) { private int getTopSize(ServerPlayer viewer) { MenuType menuType = getType(); - if (menuType == MenuType.GENERIC_9x1) { + if (MenuType.GENERIC_9x1.equals(menuType)) { return 9; - } else if (menuType == MenuType.GENERIC_9x2) { + } else if (MenuType.GENERIC_9x2.equals(menuType)) { return 18; - } else if (menuType == MenuType.GENERIC_9x3) { + } else if (MenuType.GENERIC_9x3.equals(menuType)) { return 27; - } else if (menuType == MenuType.GENERIC_9x4) { + } else if (MenuType.GENERIC_9x4.equals(menuType)) { return 36; - } else if (menuType == MenuType.GENERIC_9x5) { + } else if (MenuType.GENERIC_9x5.equals(menuType)) { return 45; - } else if (menuType == MenuType.GENERIC_9x6) { + } else if (MenuType.GENERIC_9x6.equals(menuType)) { return 54; } // This is a bit gross, but allows us a safe fallthrough. diff --git a/internal/spigot26_2/src/main/java/com/github/jikoo/openinv/internal/spigot26_2/container/slot/ContentOffHand.java b/internal/spigot26_2/src/main/java/com/github/jikoo/openinv/internal/spigot26_2/container/slot/ContentOffHand.java index 0b9c9121..dd4c0752 100644 --- a/internal/spigot26_2/src/main/java/com/github/jikoo/openinv/internal/spigot26_2/container/slot/ContentOffHand.java +++ b/internal/spigot26_2/src/main/java/com/github/jikoo/openinv/internal/spigot26_2/container/slot/ContentOffHand.java @@ -10,6 +10,8 @@ import org.bukkit.event.inventory.InventoryType; import org.jetbrains.annotations.NotNull; +import java.util.Objects; + public class ContentOffHand extends ContentEquipment { private ServerPlayer holder; @@ -34,7 +36,7 @@ public Slot asSlot(Container container, int slot, int x, int y) { return new SlotEquipment(container, slot, x, y) { @Override public void setChanged() { - if (OpenPlayer.isConnected(holder.connection) && holder.containerMenu != holder.inventoryMenu) { + if (OpenPlayer.isConnected(holder.connection) && !Objects.equals(holder.containerMenu, holder.inventoryMenu)) { holder.connection.send( new ClientboundContainerSetSlotPacket( holder.inventoryMenu.containerId, diff --git a/plugin/src/main/java/com/lishid/openinv/util/InventoryManager.java b/plugin/src/main/java/com/lishid/openinv/util/InventoryManager.java index 40076679..974cc8b6 100644 --- a/plugin/src/main/java/com/lishid/openinv/util/InventoryManager.java +++ b/plugin/src/main/java/com/lishid/openinv/util/InventoryManager.java @@ -133,6 +133,7 @@ private void onWorldChanged(@NotNull PlayerChangedWorldEvent event) { @Keep @EventHandler + @SuppressWarnings("ReferenceEquality") // We do really want to check that we have the same ref here. private void onInventoryClose(@NotNull InventoryCloseEvent event) { ISpecialInventory inventory = InventoryAccess.getInventory(event.getInventory());