Search in sources :

Example 1 with EntityTransformEvent

use of org.bukkit.event.entity.EntityTransformEvent in project Essentials by EssentialsX.

the class EssentialsProtectEntityListener_1_13_2_R1 method onEntityTransform.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTransform(final EntityTransformEvent event) {
    final Entity entity = event.getEntity();
    final EntityTransformEvent.TransformReason reason = event.getTransformReason();
    if (reason == EntityTransformEvent.TransformReason.INFECTION && prot.getSettingBool(ProtectConfig.prevent_villager_infection)) {
        event.setCancelled(true);
    } else if (reason == EntityTransformEvent.TransformReason.CURED && prot.getSettingBool(ProtectConfig.prevent_villager_cure)) {
        event.setCancelled(true);
    } else if (reason == EntityTransformEvent.TransformReason.LIGHTNING) {
        if (entity instanceof Villager && prot.getSettingBool(ProtectConfig.prevent_villager_to_witch)) {
            event.setCancelled(true);
        } else if (entity instanceof Pig && prot.getSettingBool(ProtectConfig.prevent_pig_transformation)) {
            event.setCancelled(true);
        } else if (entity instanceof Creeper && prot.getSettingBool(ProtectConfig.prevent_creeper_charge)) {
            event.setCancelled(true);
        } else if (entity instanceof MushroomCow && prot.getSettingBool(ProtectConfig.prevent_mooshroom_switching)) {
            event.setCancelled(true);
        }
    } else if (reason == EntityTransformEvent.TransformReason.DROWNED && prot.getSettingBool(ProtectConfig.prevent_zombie_drowning)) {
        event.setCancelled(true);
    }
}
Also used : Entity(org.bukkit.entity.Entity) MushroomCow(org.bukkit.entity.MushroomCow) Creeper(org.bukkit.entity.Creeper) Villager(org.bukkit.entity.Villager) EntityTransformEvent(org.bukkit.event.entity.EntityTransformEvent) Pig(org.bukkit.entity.Pig) EventHandler(org.bukkit.event.EventHandler)

Example 2 with EntityTransformEvent

use of org.bukkit.event.entity.EntityTransformEvent in project Essentials by drtshock.

the class EssentialsProtectEntityListener_1_13_2_R1 method onEntityTransform.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTransform(final EntityTransformEvent event) {
    final Entity entity = event.getEntity();
    final EntityTransformEvent.TransformReason reason = event.getTransformReason();
    if (reason == EntityTransformEvent.TransformReason.INFECTION && prot.getSettingBool(ProtectConfig.prevent_villager_infection)) {
        event.setCancelled(true);
    } else if (reason == EntityTransformEvent.TransformReason.CURED && prot.getSettingBool(ProtectConfig.prevent_villager_cure)) {
        event.setCancelled(true);
    } else if (reason == EntityTransformEvent.TransformReason.LIGHTNING) {
        if (entity instanceof Villager && prot.getSettingBool(ProtectConfig.prevent_villager_to_witch)) {
            event.setCancelled(true);
        } else if (entity instanceof Pig && prot.getSettingBool(ProtectConfig.prevent_pig_transformation)) {
            event.setCancelled(true);
        } else if (entity instanceof Creeper && prot.getSettingBool(ProtectConfig.prevent_creeper_charge)) {
            event.setCancelled(true);
        } else if (entity instanceof MushroomCow && prot.getSettingBool(ProtectConfig.prevent_mooshroom_switching)) {
            event.setCancelled(true);
        }
    } else if (reason == EntityTransformEvent.TransformReason.DROWNED && prot.getSettingBool(ProtectConfig.prevent_zombie_drowning)) {
        event.setCancelled(true);
    }
}
Also used : Entity(org.bukkit.entity.Entity) MushroomCow(org.bukkit.entity.MushroomCow) Creeper(org.bukkit.entity.Creeper) Villager(org.bukkit.entity.Villager) EntityTransformEvent(org.bukkit.event.entity.EntityTransformEvent) Pig(org.bukkit.entity.Pig) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Creeper (org.bukkit.entity.Creeper)2 Entity (org.bukkit.entity.Entity)2 MushroomCow (org.bukkit.entity.MushroomCow)2 Pig (org.bukkit.entity.Pig)2 Villager (org.bukkit.entity.Villager)2 EventHandler (org.bukkit.event.EventHandler)2 EntityTransformEvent (org.bukkit.event.entity.EntityTransformEvent)2