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

项目:SharpSK    文件:ArmorEquipListener.java   
@EventHandler
public void itemBreakEvent(PlayerItemBreakEvent e) {
    ArmorType type = ArmorType.matchType(e.getBrokenItem());
    if (type != null) {
        Player p = e.getPlayer();
        ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p, EquipMethod.BROKE, type, e.getBrokenItem());
        Bukkit.getServer().getPluginManager().callEvent(armorEquipEvent);
        if (armorEquipEvent.isCancelled()) {
            ItemStack i = e.getBrokenItem().clone();
            i.setAmount(1);
            i.setDurability((short) (i.getDurability() - 1));
            if (type.equals(ArmorType.HELMET)) {
                p.getInventory().setHelmet(i);
            } else if (type.equals(ArmorType.CHESTPLATE)) {
                p.getInventory().setChestplate(i);
            } else if (type.equals(ArmorType.LEGGINGS)) {
                p.getInventory().setLeggings(i);
            } else if (type.equals(ArmorType.BOOTS)) {
                p.getInventory().setBoots(i);
            }
        }
    }
}
项目:SharpSK    文件:ArmorunEquipListener.java   
@EventHandler
public void itemBreakEvent(PlayerItemBreakEvent e) {
    ArmorType type = ArmorType.matchType(e.getBrokenItem());
    if (type != null) {
        Player p = e.getPlayer();
        ArmorunEquipEvent ArmorunEquipEvent = new ArmorunEquipEvent(p, EquipMethod.BROKE, type, e.getBrokenItem());
        Bukkit.getServer().getPluginManager().callEvent(ArmorunEquipEvent);
        if (ArmorunEquipEvent.isCancelled()) {
            ItemStack i = e.getBrokenItem().clone();
            i.setAmount(1);
            i.setDurability((short) (i.getDurability() - 1));
            if (type.equals(ArmorType.HELMET)) {
                p.getInventory().setHelmet(i);
            } else if (type.equals(ArmorType.CHESTPLATE)) {
                p.getInventory().setChestplate(i);
            } else if (type.equals(ArmorType.LEGGINGS)) {
                p.getInventory().setLeggings(i);
            } else if (type.equals(ArmorType.BOOTS)) {
                p.getInventory().setBoots(i);
            }
        }
    }
}
项目:Statz    文件:ToolsBrokenListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onToolBreak(final PlayerItemBreakEvent event) {

    final PlayerStat stat = PlayerStat.TOOLS_BROKEN;

    // Get player
    final Player player = event.getPlayer();

    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;

    ItemStack item = event.getBrokenItem();

    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat,
            StatzUtil.makeQuery("uuid", player.getUniqueId(), "value", 1, "world", player.getWorld().getName(),
                    "item", item.getType().toString()));

}
项目:AutomaticInventory    文件:AIEventHandler.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
   public void onToolBreak(PlayerItemBreakEvent event)
{
    Player player = event.getPlayer();
    PlayerInventory inventory = player.getInventory();
    EquipmentSlot slot = this.getSlotWithItemStack(inventory, event.getBrokenItem());

    tryRefillStackInHand(player, slot, false);
}
项目:AdvancedAchievements    文件:AchieveItemBreakListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerItemBreak(PlayerItemBreakEvent event) {
    Player player = event.getPlayer();
    NormalAchievements category = NormalAchievements.ITEMBREAKS;
    if (!shouldIncreaseBeTakenIntoAccount(player, category)) {
        return;
    }

    updateStatisticAndAwardAchievementsIfAvailable(player, category, 1);
}
项目:BetonQuest    文件:QuestItemHandler.java   
@EventHandler
public void onItemBreak(PlayerItemBreakEvent event) {
    if (BetonQuest.getInstance().getConfig().getString("quest_items_unbreakable").equalsIgnoreCase("false")) {
        return;
    }
    // prevent quest items from breaking
    if (Utils.isQuestItem(event.getBrokenItem())) {
        ItemStack original = event.getBrokenItem();
        original.setDurability((short) 0);
        ItemStack copy = original.clone();
        event.getPlayer().getInventory().removeItem(original);
        event.getPlayer().getInventory().addItem(copy);
    }
}
项目:ce    文件:CEListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void PlayerItemBreakEvent(PlayerItemBreakEvent e) {

    for (ItemStack i : e.getPlayer().getInventory().getArmorContents())
        if (i != null && i.getType() != Material.AIR)
            if (i.getAmount() == 0)
                CEventHandler.handleArmor(e.getPlayer(), e.getBrokenItem(), true, e);

}
项目:Slimefun4-Chinese-Version    文件:TalismanListener.java   
@EventHandler
public void onItemBreak(PlayerItemBreakEvent e) {
    if (Talisman.checkFor(e, SlimefunItem.getByID("ANVIL_TALISMAN"))) e.getBrokenItem().setAmount(1);
}
项目:RPGInventory    文件:InventoryListener.java   
@EventHandler
public void onBreakItem(PlayerItemBreakEvent event) {
    this.onItemDisappeared(event, event.getBrokenItem());
}
项目:Slimefun4    文件:TalismanListener.java   
@EventHandler
public void onItemBreak(PlayerItemBreakEvent e) {
    if (Talisman.checkFor(e, SlimefunItem.getByID("ANVIL_TALISMAN"))) e.getBrokenItem().setAmount(1);
}
项目:League    文件:GeneralListeners.java   
@EventHandler
public void onItemBreak(PlayerItemBreakEvent event){
    event.getBrokenItem().setDurability(event.getBrokenItem().getType().getMaxDurability());
}
项目:EnchantmentAPI    文件:ItemListener.java   
@EventHandler
public void onBreak(final PlayerItemBreakEvent event) {
    final PlayerEquips equips = Enchantments.getEquipmentData(event.getPlayer());
    Tasks.schedule(() -> equips.updateWeapon(event.getPlayer().getInventory()));
}
项目:CardinalPGM    文件:ObserverModule.java   
@EventHandler
public void onPlayerItemBreak(PlayerItemBreakEvent event) {
    refreshView(event.getPlayer().getUniqueId());
}