org.bukkit.event.entity.EntityDamageEvent Java Examples

The following examples show how to use org.bukkit.event.entity.EntityDamageEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArmorListener.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
private void expCalculation(boolean isBlocking, ItemStack tool, EntityDamageEvent event, Player player) {
	//Armor should not get Exp when successfully blocking
	if(isBlocking && !ToolType.SHIELD.contains(tool.getType()) && ToolType.ARMOR.contains(tool.getType())) return;
	//Shield should not get Exp when not successfully blocking when getting attacked
	if(!isBlocking && player.equals(event.getEntity()) && ToolType.SHIELD.contains(tool.getType())) return;
	FileConfiguration config = MineTinker.getPlugin().getConfig();
	int amount = config.getInt("ExpPerEntityHit");

	if (config.getBoolean("EnableDamageExp")) {
		amount = (int) Math.round(event.getDamage());
	}

	if (config.getBoolean("DisableExpFromFalldamage", false)
			&& event.getCause() == EntityDamageEvent.DamageCause.FALL) {
		return;
	}

	modManager.addExp(player, tool, amount);
}
 
Example #2
Source File: EntityDamageByEntityListener.java    From IridiumSkyblock with GNU General Public License v2.0 6 votes vote down vote up
@EventHandler
public void onEntityDamageEvent(EntityDamageEvent event) {
    final Entity damagee = event.getEntity();
    if (!(damagee instanceof Player)) return;
    final Player player = (Player) damagee;
    final User user = User.getUser(player);
    final Location damageeLocation = damagee.getLocation();
    final IslandManager islandManager = IridiumSkyblock.getIslandManager();
    final Island island = islandManager.getIslandViaLocation(damageeLocation);
    if (island == null) return;

    //The user is visiting this island, so disable damage
    if (user.islandID != island.getId() && IridiumSkyblock.getConfiguration().disablePvPOnIslands) {
        event.setCancelled(true);
    }

}
 
Example #3
Source File: EntityDamage.java    From AdditionsAPI with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamage(EntityDamageEvent event) {
	if (event.isCancelled())
		return;

	DamageCause cause = event.getCause();
	Entity damagee = event.getEntity();
	EntityType damageeType = damagee.getType();
	// PlayerCustomArmorDamageEvent
	if (damageeType == EntityType.PLAYER) {
		Player player = (Player) damagee;
		PlayerInventory inv = player.getInventory();
		for (ItemStack armor : inv.getArmorContents())
			// TODO: Speed up
			if (armor != null && armor.getType() != Material.AIR && AdditionsAPI.isCustomItem(armor)
					&& new CustomItemStack(armor).getCustomItem() instanceof CustomArmor
					&& new CustomItemStack(armor).getCustomItem()
							.getDurabilityMechanics() instanceof ArmorDurability) {
				CustomArmor cArmor = (CustomArmor) new CustomItemStack(armor).getCustomItem();
				Bukkit.getServer().getPluginManager().callEvent(new PlayerCustomArmorDamageEvent(player, armor,
						cArmor, cause, (float) event.getDamage(), armor.containsEnchantment(Enchantment.THORNS)));
			}
	}
}
 
Example #4
Source File: SpawnMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
public void teleportObservers(final EntityDamageEvent event) {
  // when an observer begins to take fall damage, teleport them to their spawn
  if (event.getEntity() instanceof Player
      && event.getCause() == EntityDamageEvent.DamageCause.VOID) {
    MatchPlayer player = match.getPlayer(event.getEntity());
    if (player != null && player.isObserving()) {
      Spawn spawn = chooseSpawn(player);
      if (spawn != null) {
        Location location = spawn.getSpawn(player);
        if (location != null) {
          player.getBukkit().teleport(location);
        }
      }
    }
  }
}
 
Example #5
Source File: MagnetShoesListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onDamage(EntityDamageEvent event) {
    if (event.isCancelled() || !(event.getEntity() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getEntity();
    if (Main.isPlayerInGame(player)) {
        ItemStack boots = player.getInventory().getBoots();
        if (boots != null) {
            String magnetShoes = APIUtils.unhashFromInvisibleStringStartsWith(boots, MAGNET_SHOES_PREFIX);
            if (magnetShoes != null) {
                int probability = Integer.parseInt(magnetShoes.split(":")[2]);
                int randInt = MiscUtils.randInt(0, 100);
                if (randInt <= probability) {
                    event.setCancelled(true);
                    player.damage(event.getDamage());
                }
            }
        }
    }
}
 
Example #6
Source File: SentinelTrait.java    From Sentinel with MIT License 6 votes vote down vote up
/**
 * Called when this sentinel gets attacked, to correct the armor handling.
 */
public void whenAttacksAreHappeningToMe(EntityDamageByEntityEvent event) {
    if (event.isCancelled()) {
        return;
    }
    if (!getNPC().isSpawned()) {
        return;
    }
    double armorLevel = getArmor(getLivingEntity());
    if (hitIsBlocked(event.getDamager())) {
        armorLevel = (1.0 - armorLevel) * 0.5 + armorLevel;
    }
    if (!event.isApplicable(EntityDamageEvent.DamageModifier.ARMOR)) {
        event.setDamage(EntityDamageEvent.DamageModifier.BASE, (1.0 - armorLevel) * event.getDamage(EntityDamageEvent.DamageModifier.BASE));
    }
    else {
        event.setDamage(EntityDamageEvent.DamageModifier.ARMOR, -armorLevel * event.getDamage(EntityDamageEvent.DamageModifier.BASE));
    }
    for (EntityDamageEvent.DamageModifier modifier : modifiersToZero) {
        if (event.isApplicable(modifier)) {
            event.setDamage(modifier, 0);
        }
    }
}
 
Example #7
Source File: WarpPowderListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onDamage(EntityDamageEvent event) {
    if (event.isCancelled() || !(event.getEntity() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getEntity();

    if (!Main.isPlayerInGame(player)) {
        return;
    }

    GamePlayer gPlayer = Main.getPlayerGameProfile(player);
    Game game = gPlayer.getGame();

    if (gPlayer.isSpectator) {
        return;
    }

    WarpPowder warpPowder = (WarpPowder) game.getFirstActivedSpecialItemOfPlayer(player, WarpPowder.class);
    if (warpPowder != null) {
        warpPowder.cancelTeleport(true, true);
    }
}
 
Example #8
Source File: SentinelTrait.java    From Sentinel with MIT License 6 votes vote down vote up
/**
 * Called when this sentinel gets hurt.
 */
public void whenImHurt(EntityDamageEvent event) {
    if (SentinelPlugin.debugMe) {
        debug("I'm hurt! By " + event.getCause().name() + " for " + event.getFinalDamage() + " hp");
    }
    switch (event.getCause()) {
        case FIRE:
        case FIRE_TICK:
        case LAVA:
        case MELTING:
            if (ticksSinceLastBurn <= 20) {
                event.setDamage(0);
                event.setCancelled(true);
                return;
            }
            ticksSinceLastBurn = 0;
            break;
    }
}
 
Example #9
Source File: ArrowBlockerListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH)
public void onDamage(EntityDamageEvent event) {
    Entity entity = event.getEntity();
    if (!(entity instanceof Player)) {
        return;
    }

    Player player = ((Player) entity).getPlayer();

    if (!Main.isPlayerInGame(player)) {
        return;
    }

    GamePlayer gPlayer = Main.getPlayerGameProfile(player);
    Game game = gPlayer.getGame();

    if (gPlayer.isSpectator) {
        return;
    }

    ArrowBlocker arrowBlocker = (ArrowBlocker) game.getFirstActivedSpecialItemOfPlayer(player, ArrowBlocker.class);
    if (arrowBlocker != null && event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
        event.setCancelled(true);
    }
}
 
Example #10
Source File: InvulnerabilityKnockback.java    From EliteMobs with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void invulnerabilityKnockback(EntityDamageEvent event) {

    if (EntityTracker.hasPower(this, event.getEntity())) {

        event.getEntity().setVelocity(new Vector(0, 0, 0));

        new BukkitRunnable() {
            @Override
            public void run() {
                event.getEntity().setVelocity(new Vector(0, 0, 0));
            }
        }.runTaskLater(MetadataHandler.PLUGIN, 1);

    }

}
 
Example #11
Source File: ExprAttacked.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
	if (!ScriptLoader.isCurrentEvent(EntityDamageEvent.class, EntityDeathEvent.class, VehicleDamageEvent.class, VehicleDestroyEvent.class)) {
		Skript.error("The expression 'victim' can only be used in a damage or death event", ErrorQuality.SEMANTIC_ERROR);
		return false;
	}
	final String type = parser.regexes.size() == 0 ? null : parser.regexes.get(0).group();
	if (type == null) {
		this.type = EntityData.fromClass(Entity.class);
	} else {
		final EntityData<?> t = EntityData.parse(type);
		if (t == null) {
			Skript.error("'" + type + "' is not an entity type", ErrorQuality.NOT_AN_EXPRESSION);
			return false;
		}
		this.type = t;
	}
	return true;
}
 
Example #12
Source File: WarpPowderListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onDamage(EntityDamageEvent event) {
    if (event.isCancelled() || !(event.getEntity() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getEntity();

    if (!Main.isPlayerInGame(player)) {
        return;
    }

    GamePlayer gPlayer = Main.getPlayerGameProfile(player);
    Game game = gPlayer.getGame();

    if (gPlayer.isSpectator) {
        return;
    }

    WarpPowder warpPowder = (WarpPowder) game.getFirstActivedSpecialItemOfPlayer(player, WarpPowder.class);
    if (warpPowder != null) {
        warpPowder.cancelTeleport(true, true);
    }
}
 
Example #13
Source File: EvtDamage.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("null")
	private static boolean checkDamage(final EntityDamageEvent e) {
		if (!(e.getEntity() instanceof LivingEntity))
			return true;
		final LivingEntity en = (LivingEntity) e.getEntity();
		if (HealthUtils.getHealth(en) <= 0)
			return false;
//		if (en.getNoDamageTicks() <= en.getMaximumNoDamageTicks() / 2) {
//			lastDamages.put(en, e.getDamage());
//			return true;
//		}
//		final Integer lastDamage = lastDamages.get(en);
//		if (lastDamage != null && lastDamage >= e.getDamage())
//			return false;
//		lastDamages.put(en, e.getDamage());
		return true;
	}
 
Example #14
Source File: FeatureEmulation.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {
	if (((event.getCause() == DamageCause.FIRE_TICK) || (event.getCause() == DamageCause.FIRE) || (event.getCause() == DamageCause.DROWNING))) {
		for (Player player : ServerPlatform.get().getMiscUtils().getNearbyPlayers(event.getEntity().getLocation(), 48, 128, 48)) {
			if (player != null) {
				Connection connection = ProtocolSupportAPI.getConnection(player);
				if (
					(connection != null) &&
					(connection.getVersion().getProtocolType() == ProtocolType.PC) &&
					connection.getVersion().isBefore(ProtocolVersion.MINECRAFT_1_12)
				) {
					connection.sendPacket(ServerPlatform.get().getPacketFactory().createEntityStatusPacket(event.getEntity(), 2));
				}
			}
		}
	}
}
 
Example #15
Source File: ReceivedDamageEvent.java    From StackMob-3 with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onDamageReceived(EntityDamageEvent event) {
    if(event.getEntity() instanceof LivingEntity){
        if(StackTools.hasValidStackData(event.getEntity())){
            LivingEntity entity = (LivingEntity) event.getEntity();
            if(sm.getCustomConfig().getBoolean("kill-step-damage.enabled")){
                double healthAfter = entity.getHealth() - event.getFinalDamage();
                if(healthAfter <= 0){
                    entity.setMetadata(GlobalValues.LEFTOVER_DAMAGE, new FixedMetadataValue(sm, Math.abs(healthAfter)));
                }
            }

            if(!sm.getCustomConfig().getStringList("multiply-damage-received.cause-blacklist")
                    .contains(event.getCause().toString())) {
                if(event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK){
                    return;
                }
                int stackSize = StackTools.getSize(entity);
                double extraDamage = event.getDamage() + ((event.getDamage() * (stackSize - 1) * 0.25));
                event.setDamage(extraDamage);
            }
        }
    }
}
 
Example #16
Source File: DamageMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onTarget(EntityTargetEvent event) {
    if(!(event.getEntity() instanceof ExperienceOrb)) {
        ParticipantState victimState = null;
        if(event.getTarget() instanceof Player) {
            // Don't target allies
            MatchPlayer victim = getVictim(event.getTarget());
            if(victim == null) return;
            victimState = victim.getParticipantState();
        } else if(event.getTarget() != null) {
            // Don't target other mobs owned by allies
            victimState = entityResolver.getOwner(event.getTarget());
        }
        if(victimState == null) return;
        DamageInfo damageInfo = damageResolver.resolveDamage(EntityDamageEvent.DamageCause.ENTITY_ATTACK, event.getTarget(), event.getEntity());
        if(queryHostile(event, victimState, damageInfo).isDenied()) {
            event.setCancelled(true);
        }
    }
}
 
Example #17
Source File: Poisonous.java    From MineTinker with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onDamage(EntityDamageEvent event) {
	if (event.getCause() != EntityDamageEvent.DamageCause.POISON) return;
	if (!(event.getEntity() instanceof Player)) return;
	if (!this.effectHealsPlayer) return;

	Player player = (Player) event.getEntity();
	if (!player.hasPermission("minetinker.modifiers.poisonous.use")) {
		return;
	}

	boolean hasPoisonous = false;
	ItemStack armor = null;
	for (ItemStack stack : player.getInventory().getArmorContents()) {
		if (stack == null) continue;
		if (modManager.hasMod(stack, this)) {
			hasPoisonous = true;
			armor = stack;
			break;
		}
	}

	if (!hasPoisonous) return;

	double damage = event.getDamage();
	if (damage > 0) {
		event.setDamage(0);
		double health = player.getHealth();
		player.setHealth(Math.min(health + damage, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
		ChatWriter.logModifier(player, event, this, armor, String.format("Health(%.2f -> %.2f)", health, player.getHealth()));
	}
}
 
Example #18
Source File: DamageMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onIgnition(EntityCombustByEntityEvent event) {
    MatchPlayer victim = getVictim(event.getEntity());
    if(victim == null) return;
    processDamageEvent(event, victim.getParticipantState(),
                       damageResolver.resolveDamage(EntityDamageEvent.DamageCause.FIRE, event.getEntity(), event.getCombuster()));
}
 
Example #19
Source File: KnockbackPlayerFacet.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@TargetedEventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMelee(EntityDamageByEntityEvent event) {
    if(knockback.isPresent() &&
       victim.equals(event.getEntity()) &&
       event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK &&
       event.getDamager() instanceof LivingEntity &&
       victim.getNoDamageTicks() <= 0) {

        applyImpulses((LivingEntity) event.getDamager());
    }
}
 
Example #20
Source File: DamageMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onDamageVehicle(VehicleDamageEvent event) {
    MatchPlayer victim = getVictim(event.getVehicle());
    if(victim == null) return;
    processDamageEvent(event, victim.getParticipantState(),
                       damageResolver.resolveDamage(EntityDamageEvent.DamageCause.CUSTOM, event.getVehicle(), event.getAttacker()));
}
 
Example #21
Source File: InvulnerabilityFire.java    From EliteMobs with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void invulnerabilityFire(EntityDamageEvent event) {

    if ((event.getCause().equals(EntityDamageEvent.DamageCause.FIRE) ||
            event.getCause().equals(EntityDamageEvent.DamageCause.FIRE_TICK)) &&
            EntityTracker.hasPower(this, event.getEntity()))
        event.setCancelled(true);

}
 
Example #22
Source File: ExprLastDamageCause.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected DamageCause[] get(final Event e, final LivingEntity[] source) {
	return get(source, new Getter<DamageCause, LivingEntity>() {
		@SuppressWarnings("null")
		@Override
		public DamageCause get(final LivingEntity entity) {
			EntityDamageEvent dmgEvt = entity.getLastDamageCause();
			if (dmgEvt == null) return DamageCause.CUSTOM;
			return dmgEvt.getCause();
		}
	});
}
 
Example #23
Source File: DeathTracker.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
/** Must run after {@link tc.oc.pgm.spawns.SpawnMatchModule#onVanillaDeath} */
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDeath(PlayerDeathEvent event) {
  logger.fine("Wrapping " + event);
  MatchPlayer victim = match.getParticipant(event.getEntity());
  if (victim == null || victim.isDead()) return;

  DamageInfo info = getLastDamage(victim);
  if (info == null) info = new GenericDamageInfo(EntityDamageEvent.DamageCause.CUSTOM);

  match.callEvent(
      new MatchPlayerDeathEvent(event, victim, info, CombatLogTracker.isCombatLog(event)));
}
 
Example #24
Source File: TitleRespawn.java    From CardinalPGM with MIT License 5 votes vote down vote up
private void killPlayer(final Player player, Player killer, EntityDamageEvent.DamageCause cause) {
    if (deadPlayers.containsKey(player.getUniqueId())) return;
    this.deadPlayers.put(player.getUniqueId(), System.currentTimeMillis());

    CardinalDeathEvent cardinalDeathEvent = new CardinalDeathEvent(player, killer, cause);
    Bukkit.getServer().getPluginManager().callEvent(cardinalDeathEvent);

    dropInventory(player, true);

    PlayerDeathEvent deathEvent = new PlayerDeathEvent(player, new ArrayList<ItemStack>(), player.getExpToLevel(), 0, 0, 0, null);
    deathEvent.setDeathMessage(null);
    Bukkit.getServer().getPluginManager().callEvent(deathEvent);

    if (!isDeadUUID(player.getUniqueId())) return;

    Players.setObserver(player);

    PlayerNameUpdateEvent nameUpdateEvent = new PlayerNameUpdateEvent(player);
    Bukkit.getServer().getPluginManager().callEvent(nameUpdateEvent);

    sendTitle(player);

    player.setGameMode(GameMode.CREATIVE);

    setBlood(player, true);
    playDeathAnimation(player);

    if (!this.spectate) sendArmorStandPacket(player);

    player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 100, 0, true, false), false);
    player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, this.blackout ? Integer.MAX_VALUE : 20, 0, true, false), false);

    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Cardinal.getInstance(), new Runnable() {
        public void run() {
            GameHandler.getGameHandler().getMatch().getModules().getModule(Visibility.class).showOrHide(player);
        }
    }, 15L);
    if (this.auto) hasLeftClicked.add(player.getUniqueId());
}
 
Example #25
Source File: RescuePlatformListener.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onFallDamage(EntityDamageEvent event) {
    Entity entity = event.getEntity();
    if (event.isCancelled() || !(entity instanceof Player)) {
        return;
    }

    Player player = ((Player) entity).getPlayer();
    if (!Main.isPlayerInGame(player)) {
        return;
    }

    GamePlayer gPlayer = Main.getPlayerGameProfile(player);
    Game game = gPlayer.getGame();
    if (gPlayer.isSpectator) {
        return;
    }

    RescuePlatform rescuePlatform = (RescuePlatform) game.getFirstActivedSpecialItemOfPlayer(player, RescuePlatform.class);
    if (rescuePlatform != null && event.getCause() == EntityDamageEvent.DamageCause.FALL) {
        Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
        if (block != null) {
            if (block.getType() == rescuePlatform.getMaterial()) {
                event.setCancelled(true);
            }
        }
    }
}
 
Example #26
Source File: SpawnMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPlayerDamage(final EntityDamageEvent event) {
  MatchPlayer player = getMatch().getPlayer(event.getEntity());
  if (player != null) {
    State state = states.get(player);
    if (state != null) state.onEvent(event);
  }
}
 
Example #27
Source File: MobListener.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDamage(EntityDamageEvent event) {
	if (!(event.getEntity() instanceof LivingEntity)) {
		return;
	}
	
	if (!MobLib.isMobLibEntity((LivingEntity) event.getEntity())) {
		return;
	}
	
	switch (event.getCause()) {
	case SUFFOCATION:
		Location loc = event.getEntity().getLocation();
		int y = loc.getWorld().getHighestBlockAt(loc.getBlockX(), loc.getBlockZ()).getY()+4;
		loc.setY(y);
		event.getEntity().teleport(loc);
	case CONTACT:
	case FALL:
	case FIRE:
	case FIRE_TICK:
	case LAVA:
	case MELTING:
	case DROWNING:
	case FALLING_BLOCK:
	case BLOCK_EXPLOSION:
	case ENTITY_EXPLOSION:
	case LIGHTNING:
	case MAGIC:
		event.setCancelled(true);
		break;
	default:
		break;
	}
}
 
Example #28
Source File: CombatLogTracker.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
private ImminentDeath(
    EntityDamageEvent.DamageCause cause,
    Location deathLocation,
    @Nullable Block blockDamager,
    boolean damaged) {
  this.cause = cause;
  this.deathLocation = deathLocation;
  this.blockDamager = blockDamager;
  this.alreadyDamaged = damaged;
}
 
Example #29
Source File: Scout.java    From AnnihilationPro with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void fallDamage(EntityDamageEvent event)
{
	if(event.getEntity().getType() == EntityType.PLAYER && event.getCause() == DamageCause.FALL)
	{
		Player p = (Player)event.getEntity();
		AnniPlayer pl = AnniPlayer.getPlayer(p.getUniqueId());
		if(pl != null && pl.getKit().equals(this))
		{
			event.setDamage(event.getDamage()/2);
		}
	}
}
 
Example #30
Source File: MainListener.java    From ArmorStandTools with MIT License 5 votes vote down vote up
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if(event.getEntity() instanceof ArmorStand) {
        ArmorStand as = (ArmorStand) event.getEntity();
        if(ArmorStandGUI.isInUse(as) || as.isInvulnerable()) {
            event.setCancelled(true);
        }
    }
}