From 9cb58d885da56c28bc12dee7b3be4fcc64f07581 Mon Sep 17 00:00:00 2001 From: Pim van der Loos Date: Tue, 24 Nov 2020 12:30:23 +0100 Subject: [PATCH] Simplify clearing anvil inventory --- .../armoredElytra/handlers/AnvilHandler.java | 6 +----- .../armoredElytra/handlers/ArmoredElytraHandler.java | 11 ----------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/main/java/nl/pim16aap2/armoredElytra/handlers/AnvilHandler.java b/src/main/java/nl/pim16aap2/armoredElytra/handlers/AnvilHandler.java index f8e93ca..759f31f 100644 --- a/src/main/java/nl/pim16aap2/armoredElytra/handlers/AnvilHandler.java +++ b/src/main/java/nl/pim16aap2/armoredElytra/handlers/AnvilHandler.java @@ -205,8 +205,6 @@ public class AnvilHandler extends ArmoredElytraHandler implements Listener return; } - int slot = e.getRawSlot(); - if (anvilInventory.getItem(0) != null && anvilInventory.getItem(1) != null && anvilInventory.getItem(2) != null && anvilInventory.getItem(2).getType() == Material.ELYTRA) { @@ -228,9 +226,7 @@ public class AnvilHandler extends ArmoredElytraHandler implements Listener return; // Clean the anvil's inventory after transferring the items. - cleanAnvilInventory(anvilInventory); - player.updateInventory(); - return; + anvilInventory.clear(); } } } diff --git a/src/main/java/nl/pim16aap2/armoredElytra/handlers/ArmoredElytraHandler.java b/src/main/java/nl/pim16aap2/armoredElytra/handlers/ArmoredElytraHandler.java index dbffb3e..8fc4fb5 100644 --- a/src/main/java/nl/pim16aap2/armoredElytra/handlers/ArmoredElytraHandler.java +++ b/src/main/java/nl/pim16aap2/armoredElytra/handlers/ArmoredElytraHandler.java @@ -4,7 +4,6 @@ import nl.pim16aap2.armoredElytra.ArmoredElytra; import nl.pim16aap2.armoredElytra.util.XMaterial; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.ItemStack; /** @@ -24,16 +23,6 @@ abstract class ArmoredElytraHandler this.creationEnabled = creationEnabled; } - protected void cleanAnvilInventory(AnvilInventory anvilInventory) - { - if (anvilInventory.getItem(0) != null) - anvilInventory.getItem(0).setAmount(0); - if (anvilInventory.getItem(1) != null) - anvilInventory.getItem(1).setAmount(anvilInventory.getItem(1).getAmount() - 1); - if (anvilInventory.getItem(2) != null) - anvilInventory.getItem(2).setAmount(0); - } - // Repair an Armored Elytra protected short repairItem(short curDur, ItemStack repairItem) {