当前位置: 首页>>代码示例>>Java>>正文


Java PlayerItemBreakEvent类代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerItemBreakEvent的典型用法代码示例。如果您正苦于以下问题:Java PlayerItemBreakEvent类的具体用法?Java PlayerItemBreakEvent怎么用?Java PlayerItemBreakEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PlayerItemBreakEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerItemBreakEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: itemBreakEvent

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@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);
			}
		}
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:24,代码来源:ArmorEquipListener.java

示例2: itemBreakEvent

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@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);
			}
		}
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:24,代码来源:ArmorunEquipListener.java

示例3: onToolBreak

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@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()));

}
 
开发者ID:Staartvin,项目名称:Statz,代码行数:21,代码来源:ToolsBrokenListener.java

示例4: onToolBreak

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:BigScary,项目名称:AutomaticInventory,代码行数:10,代码来源:AIEventHandler.java

示例5: onPlayerItemBreak

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:11,代码来源:AchieveItemBreakListener.java

示例6: onItemBreak

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:15,代码来源:QuestItemHandler.java

示例7: PlayerItemBreakEvent

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@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);

}
 
开发者ID:Taiterio,项目名称:ce,代码行数:10,代码来源:CEListener.java

示例8: onItemBreak

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@EventHandler
public void onItemBreak(PlayerItemBreakEvent e) {
	if (Talisman.checkFor(e, SlimefunItem.getByID("ANVIL_TALISMAN"))) e.getBrokenItem().setAmount(1);
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:5,代码来源:TalismanListener.java

示例9: onBreakItem

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@EventHandler
public void onBreakItem(PlayerItemBreakEvent event) {
    this.onItemDisappeared(event, event.getBrokenItem());
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:5,代码来源:InventoryListener.java

示例10: onItemBreak

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@EventHandler
public void onItemBreak(PlayerItemBreakEvent event){
    event.getBrokenItem().setDurability(event.getBrokenItem().getType().getMaxDurability());
}
 
开发者ID:GaryQian,项目名称:League,代码行数:5,代码来源:GeneralListeners.java

示例11: onBreak

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@EventHandler
public void onBreak(final PlayerItemBreakEvent event) {
    final PlayerEquips equips = Enchantments.getEquipmentData(event.getPlayer());
    Tasks.schedule(() -> equips.updateWeapon(event.getPlayer().getInventory()));
}
 
开发者ID:Eniripsa96,项目名称:EnchantmentAPI,代码行数:6,代码来源:ItemListener.java

示例12: onPlayerItemBreak

import org.bukkit.event.player.PlayerItemBreakEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerItemBreak(PlayerItemBreakEvent event) {
    refreshView(event.getPlayer().getUniqueId());
}
 
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:5,代码来源:ObserverModule.java


注:本文中的org.bukkit.event.player.PlayerItemBreakEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。