Ignore spurious slot IDs sent by client, e.g. in enchanting tables

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2018-12-30 22:27:16 +11:00
parent 022955b377
commit 1c116bb13c

View File

@ -210,7 +210,9 @@ public abstract class InventoryView {
* @return corresponding inventory, or null
*/
public final Inventory getInventory(int rawSlot) {
if (rawSlot == OUTSIDE) {
// Slot may be -1 if not properly detected due to client bug
// e.g. dropping an item into part of the enchantment list section of an enchanting table
if (rawSlot == OUTSIDE || rawSlot == -1) {
return null;
}
Preconditions.checkArgument(rawSlot >= 0, "Negative, non outside slot %s", rawSlot);