コード例 #1
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onEntityDamageEvent(EntityDamageEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (!(event.getEntity() instanceof Player)) {
     return;
   }
   Player p = (Player) event.getEntity();
   ItemStack iimh = p.getEquipment().getItemInMainHand();
   Tier t = iimh != null ? TierUtil.getTierFromItemStack(iimh) : null;
   if (t != null && t.isInfiniteDurability()) {
     p.getEquipment().getItemInMainHand().setDurability((short) 0);
   }
   for (ItemStack is : p.getEquipment().getArmorContents()) {
     if (is == null || is.getType() == Material.AIR) {
       continue;
     }
     t = TierUtil.getTierFromItemStack(is);
     if (t == null) {
       continue;
     }
     if (t.isInfiniteDurability()) {
       is.setDurability((short) 0);
     }
   }
 }
コード例 #2
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onEntityShootBowEvent(EntityShootBowEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (!(event.getEntity() instanceof Player)) {
     return;
   }
   Player p = (Player) event.getEntity();
   ItemStack iimh = p.getEquipment().getItemInMainHand();
   Tier t = iimh != null ? TierUtil.getTierFromItemStack(iimh) : null;
   if (t != null && t.isInfiniteDurability()) {
     iimh.setDurability((short) 0);
   }
 }
コード例 #3
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onBlockBreakEvent(BlockBreakEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (event.getPlayer() == null) {
     return;
   }
   if (event.getPlayer().getEquipment().getItemInMainHand() == null) {
     return;
   }
   ItemStack iimh = event.getPlayer().getEquipment().getItemInMainHand();
   Tier t = iimh != null ? TierUtil.getTierFromItemStack(iimh) : null;
   if (t == null) {
     return;
   }
   if (t.isInfiniteDurability()) {
     iimh.setDurability((short) 0);
   }
 }