Skip to content

Commit

Permalink
fix: remove crafting items in non-input slots
Browse files Browse the repository at this point in the history
  • Loading branch information
AsoDesu committed Apr 20, 2024
1 parent 245be43 commit 8b30a9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public static CraftingMenuType craftingMenuType(Component component) {

private static TextColor timeLeftColor = ChatUtils.parseColor("#FF5556");
public static void analyseCraftingItem(CraftingMenuType type, ItemStack item, int slot) {
if (!isInputSlot(slot)) return;
if (!isInputSlot(slot)) {
CraftingItems.removeSlot(type, slot);
return;
}

List<Component> lores = Utils.getLores(item);
if (lores != null && isActive(lores)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public static void addItem(CraftingItem item) {
* @param slot The slot you wish to remove
*/
public static void removeSlot(CraftingMenuType type, int slot) {
items.removeIf(i -> i.getCraftingMenuType() == type && i.getSlot() == slot);
save();
boolean wasRemoved = items.removeIf(i -> i.getCraftingMenuType() == type && i.getSlot() == slot);
if (wasRemoved) save();
}

public static <T> void submit(Runnable task) {
Expand Down Expand Up @@ -84,7 +84,7 @@ public static void saveSync() {
try {
array.add(item.toJson());
} catch (Exception e) {
logger.error("Failed to save item: " + item, e);
logger.error("Failed to save item: {}", item, e);
}
}

Expand Down

0 comments on commit 8b30a9f

Please sign in to comment.