mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Prevent potion effects for protected NPCs
This commit is contained in:
parent
e3f339b80d
commit
d7237dff4e
@ -13,6 +13,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.AbstractHorse;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -28,6 +29,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.PlayerLeashEntityEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
@ -473,6 +475,18 @@ public class EventListen implements Listener {
|
||||
skinUpdateTracker.updatePlayer(event.getPlayer(), 15, true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPotionSplashEvent(PotionSplashEvent event) {
|
||||
for (LivingEntity entity : event.getAffectedEntities()) {
|
||||
NPC npc = npcRegistry.getNPC(entity);
|
||||
if (npc == null)
|
||||
continue;
|
||||
if (npc.isProtected()) {
|
||||
event.setIntensity(entity, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (!(event.getEntity() instanceof FishHook))
|
||||
|
@ -38,4 +38,4 @@ public class Gravity extends Trait implements Toggleable {
|
||||
public boolean toggle() {
|
||||
return enabled = !enabled;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user