Fixed NPE in BaseWindow#redrawItem

This commit is contained in:
NichtStudioCode 2021-12-21 11:47:25 +01:00
parent d35355f64b
commit dbad076ce1

@ -64,9 +64,11 @@ public abstract class BaseWindow implements Window {
itemStack = element.getItemStack(viewerUUID); itemStack = element.getItemStack(viewerUUID);
// This makes every item unique to prevent Shift-DoubleClick "clicking" multiple items at the same time. // This makes every item unique to prevent Shift-DoubleClick "clicking" multiple items at the same time.
ItemMeta itemMeta = itemStack.getItemMeta(); if (itemStack.hasItemMeta()) {
itemMeta.getPersistentDataContainer().set(SLOT_KEY, PersistentDataType.BYTE, (byte) index); ItemMeta itemMeta = itemStack.getItemMeta();
itemStack.setItemMeta(itemMeta); itemMeta.getPersistentDataContainer().set(SLOT_KEY, PersistentDataType.BYTE, (byte) index);
itemStack.setItemMeta(itemMeta);
}
} else if (element == null || (element instanceof VISlotElement && element.getItemStack(viewerUUID) == null)) { } else if (element == null || (element instanceof VISlotElement && element.getItemStack(viewerUUID) == null)) {
ItemProvider background = getGuiAt(index).getFirst().getBackground(); ItemProvider background = getGuiAt(index).getFirst().getBackground();
itemStack = background == null ? null : background.getFor(viewerUUID); itemStack = background == null ? null : background.getFor(viewerUUID);