Skip to content

Commit

Permalink
Merge pull request #70
Browse files Browse the repository at this point in the history
Fixed ItemCreator crashes when placing missing custom item
  • Loading branch information
WolfyScript authored Feb 9, 2022
2 parents 8ce7b52 + a332197 commit 2a56d0b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import me.wolfyscript.customcrafting.utils.NamespacedKeyUtils;
import me.wolfyscript.customcrafting.utils.PlayerUtil;
import me.wolfyscript.utilities.api.inventory.custom_items.CustomItem;
import me.wolfyscript.utilities.api.inventory.custom_items.references.APIReference;
import me.wolfyscript.utilities.api.inventory.custom_items.references.WolfyUtilitiesRef;
import me.wolfyscript.utilities.api.inventory.gui.GuiCluster;
import me.wolfyscript.utilities.api.inventory.gui.GuiHandler;
Expand Down Expand Up @@ -93,7 +94,11 @@ public void onInit() {
})));
registerButton(new ItemInputButton<>(ITEM_INPUT, new ButtonState<>("", Material.AIR, (cache, guiHandler, player, inventory, slot, event) -> false, (cache, guiHandler, player, inventory, item, slot, event) -> {
var items = cache.getItems();
items.setItem(CustomItem.getReferenceByItemStack(item != null ? item : ItemUtils.AIR));
CustomItem reference = CustomItem.getReferenceByItemStack(item != null ? item : ItemUtils.AIR);
if (ItemUtils.isAirOrNull(reference.getItemStack())) {
reference = new CustomItem(item != null ? item : ItemUtils.AIR);
}
items.setItem(reference);
}, null, (hashMap, cache, guiHandler, player, guiInventory, itemStack, i, b) -> guiHandler.getCustomCache().getItems().getItem().getItemStack())));

registerButton(new ActionButton<>(SAVE_ITEM, Material.WRITABLE_BOOK, (cache, guiHandler, player, guiInventory, i, inventoryInteractEvent) -> {
Expand Down

0 comments on commit 2a56d0b

Please sign in to comment.