Commits

Hex authored 1526726b579
SPIGOT-4031: Improve bounds checking in CraftInventoryView.
No tags

src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java

Modified
43 43 InventoryType type = viewing.getType();
44 44 if (type == InventoryType.CRAFTING && player.getGameMode() == GameMode.CREATIVE) {
45 45 return InventoryType.CREATIVE;
46 46 }
47 47 return type;
48 48 }
49 49
50 50 @Override
51 51 public void setItem(int slot, ItemStack item) {
52 52 net.minecraft.server.ItemStack stack = CraftItemStack.asNMSCopy(item);
53 - if (slot != -999) {
53 + if (slot >= 0) {
54 54 container.getSlot(slot).set(stack);
55 55 } else {
56 56 player.getHandle().drop(stack, false);
57 57 }
58 58 }
59 59
60 60 @Override
61 61 public ItemStack getItem(int slot) {
62 - if (slot == -999) {
62 + if (slot < 0) {
63 63 return null;
64 64 }
65 65 return CraftItemStack.asCraftMirror(container.getSlot(slot).getItem());
66 66 }
67 67
68 68 public boolean isInTop(int rawSlot) {
69 69 return rawSlot < viewing.getSize();
70 70 }
71 71
72 72 public Container getHandle() {
118 118 if (slot == 2) {
119 119 type = SlotType.RESULT;
120 120 } else {
121 121 type = SlotType.CRAFTING;
122 122 }
123 123 break;
124 124 default:
125 125 // Nothing to do, it's a CONTAINER slot
126 126 }
127 127 } else {
128 - if (slot == -999 || slot == -1) {
128 + if (slot < 0) {
129 129 type = SlotType.OUTSIDE;
130 130 } else if (inventory.getType() == InventoryType.CRAFTING) { // Also includes creative inventory
131 131 if (slot < 9) {
132 132 type = SlotType.ARMOR;
133 133 } else if (slot > 35) {
134 134 type = SlotType.QUICKBAR;
135 135 }
136 136 } else if (slot >= (inventory.countSlots() - (9 + 4 + 1))) { // Quickbar, Armor, Offhand
137 137 type = SlotType.QUICKBAR;
138 138 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut