Skip to content

Commit

Permalink
Fix duplication bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fantahund committed Nov 8, 2023
1 parent 3e68ee8 commit 85aefdb
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;

Expand Down Expand Up @@ -163,6 +164,27 @@ public void onItemClick(InventoryClickEvent e) {
}
}

@EventHandler
public void onEquip(PlayerInteractEvent e) {
ItemStack handStack = e.getItem();
if (handStack == null || e.getHand() == null) {
return;
}
final EquipmentSlot armorItemSlot = handStack.getType().getEquipmentSlot();
if (armorItemSlot != EquipmentSlot.HEAD) {
return;
}

final PlayerInventory inventory = e.getPlayer().getInventory();
final ItemStack headStack = inventory.getItem(armorItemSlot);
AbstractFireWork fireWork = plugin.getRegistry().getByItemStack(headStack);
if (fireWork instanceof BlockFireWork blockFireWork) {
if (blockFireWork.hasActiveTask(e.getPlayer())) {
e.setCancelled(true);
}
}
}

@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
ItemStack stack = event.getPlayer().getInventory().getHelmet();
Expand Down

0 comments on commit 85aefdb

Please sign in to comment.