本文整理汇总了Java中org.bukkit.event.player.PlayerItemBreakEvent.getPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerItemBreakEvent.getPlayer方法的具体用法?Java PlayerItemBreakEvent.getPlayer怎么用?Java PlayerItemBreakEvent.getPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerItemBreakEvent
的用法示例。
在下文中一共展示了PlayerItemBreakEvent.getPlayer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
}
示例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);
}
}
}
}
示例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()));
}
示例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);
}
示例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);
}