private void endLeap(Player player, AnniPlayer p) { if (p.getData("Cur") != null) { Object obj = p.getData("Arm"); if (obj != null && player != null) player.getInventory().setArmorContents((ItemStack[]) obj); p.setData("Arm", null); if (player != null) { player.removePotionEffect(PotionEffectType.INVISIBILITY); player.removePotionEffect(PotionEffectType.SPEED); player.removePotionEffect(PotionEffectType.FAST_DIGGING); } p.setData("Cur", null); } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void damageHandler(EntityDamageByEntityEvent event) { if (event.getDamager().getType() == EntityType.PLAYER) { Player player = (Player) event.getDamager(); AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if (p != null && p.getKit().equals(this) && p.getData("Cur") != null) endLeap(player, p); } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void damageHandler(EntityDamageEvent event) { if (event.getEntityType() == EntityType.PLAYER) { AnniPlayer p = AnniPlayer.getPlayer(event.getEntity().getUniqueId()); if (p != null && p.getKit().equals(this) && p.getData("Cur") != null) { if (event.getCause() == DamageCause.FALL) event.setCancelled(true); else endLeap((Player) event.getEntity(), p); } } }