Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Loading