@EventHandler public void onDamageItem(PlayerItemDamageEvent e) { Player p = e.getPlayer(); if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Damage-Item.Disable")) { if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Damage-Item.World.All_World")) { if (WorldUtils.getWItemDamage().contains(p.getWorld().getName())) { if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Damage-Item.Bypass")) { if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.damageitem")) { e.setCancelled(true); } } else { e.setCancelled(true); } } } else { if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Damage-Item.Bypass")) { if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.damageitem")) { e.setCancelled(true); } } else { e.setCancelled(true); } } } }
@SuppressWarnings("deprecation") @Override public void onDurabilityChange(PlayerItemDamageEvent event) { event.setDamage(0); event.getPlayer().updateInventory(); // LinkedList<ItemDurabilityEntry> entries = CustomItemManager.itemDuraMap.get(player.getName()); // // if (entries == null) { // entries = new LinkedList<ItemDurabilityEntry>(); // } // // ItemDurabilityEntry entry = new ItemDurabilityEntry(); // entry.stack = stack; // entry.oldValue = stack.getDurability(); // // entries.add(entry); // CustomItemManager.itemDuraMap.put(player.getName(), entries); // // if (!CustomItemManager.duraTaskScheduled) { // TaskMaster.syncTask(new ItemDuraSyncTask()); // } }
@EventHandler public void onItemDamage(PlayerItemDamageEvent event) { ItemStack stack = event.getItem(); if ((stack != null) && (ALLOWED.contains(stack.getType())) && (ThreadLocalRandom.current().nextInt(3) != 0)) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerItemDamageEvent(PlayerItemDamageEvent event) { Player player = event.getPlayer(); ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()); if (regions.queryState(WorldGuardUtils.wrapPlayer(player), FlagUtils.ITEM_DURABILITY) == State.DENY) //Not sure should we add bypass for this { event.setCancelled(true); } }
@EventHandler public void onItemDamage(PlayerItemDamageEvent event) { if(event.getItem().getDurability() == event.getItem().getType().getMaxDurability() - 1) { event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ITEM_SHIELD_BREAK, 1.0F, 1.0F); event.getPlayer().getInventory().setItem(event.getPlayer().getInventory().getHeldItemSlot(), null); } }
@EventHandler(priority = EventPriority.LOW) public void onItemDurabilityChange(PlayerItemDamageEvent event) { ItemStack stack = event.getItem(); LoreCraftableMaterial craftMat = LoreCraftableMaterial.getCraftMaterial(stack); if (craftMat == null) { return; } craftMat.onItemDurabilityChange(event); }
@EventHandler public void onDamage(PlayerItemDamageEvent e) { Item es = Item.get(e.getItem()); if (es.hasEnchantment(UNBREAKING)) { int r = (int) Math.random() * 100; switch (es.getEnchantmentLevel(UNBREAKING)) { case 1: if (r <= 12) { e.setDamage(0); } break; case 2: if (r <= 25) { e.setDamage(0); } break; case 3: if (r <= 37) { e.setDamage(0); } break; case 4: if (r <= 50) { e.setDamage(0); } break; case 5: if (r <= 63) { e.setDamage(0); } break; case 6: if (r <= 75) { e.setDamage(0); } break; case 7: if (r <= 87) { e.setDamage(0); } break; case 8: e.setDamage(0); break; } } }
public void onItemDurabilityChange(PlayerItemDamageEvent event) { for (ItemComponent comp : this.components.values()) { comp.onDurabilityChange(event); } }
public void onDurabilityChange(PlayerItemDamageEvent event) {}