Java 类org.bukkit.event.player.PlayerItemDamageEvent 实例源码

项目:UltimateSpawn    文件:BasicFeatures.java   
@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);
            }
        }
    }
}
项目:civcraft    文件:NoVanillaDurability.java   
@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());
//      }
    }
项目:HCFCore    文件:ArmorFixListener.java   
@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);
  }
}
项目:WorldGuardExtraFlagsPlugin    文件:PlayerListener.java   
@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);
    }
}
项目:Enhanced-Items    文件:EnhancedItemsEvents.java   
@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);
    }
}
项目:civcraft    文件:CustomItemManager.java   
@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);
}
项目:NationZ    文件:EnchantmentZ_Unbreaking.java   
@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;
        }
    }
}
项目:civcraft    文件:LoreCraftableMaterial.java   
public void onItemDurabilityChange(PlayerItemDamageEvent event) {
    for (ItemComponent comp : this.components.values()) {
        comp.onDurabilityChange(event);
    }
}
项目:civcraft    文件:ItemComponent.java   
public void onDurabilityChange(PlayerItemDamageEvent event) {}