Search in sources :

Example 16 with Monster

use of org.bukkit.entity.Monster in project RedProtect by FabioZumbi12.

the class RPGlobalListener method MonsterBlockBreak.

@EventHandler
public void MonsterBlockBreak(EntityChangeBlockEvent event) {
    Entity e = event.getEntity();
    Block b = event.getBlock();
    Region r = RedProtect.get().rm.getTopRegion(event.getBlock().getLocation());
    if (r != null) {
        return;
    }
    if (b != null) {
        RedProtect.get().logger.debug("RPGlobalListener - Is EntityChangeBlockEvent event. Block: " + b.getType().name());
    }
    if (e instanceof Monster) {
        if (!RPConfig.getGlobalFlagBool(e.getWorld().getName() + ".entity-block-damage")) {
            event.setCancelled(true);
        }
    }
    if (e instanceof Player) {
        Player p = (Player) e;
        if (!bypassBuild(p, b, 2)) {
            event.setCancelled(true);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) Monster(org.bukkit.entity.Monster) Block(org.bukkit.block.Block) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 17 with Monster

use of org.bukkit.entity.Monster in project RedProtect by FabioZumbi12.

the class RPGlobalListener method onCreatureSpawn.

@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    RedProtect.get().logger.debug("RPGlobalListener - Is CreatureSpawnEvent event! Cancelled? " + event.isCancelled());
    if (event.isCancelled()) {
        return;
    }
    Entity e = event.getEntity();
    if (e == null) {
        return;
    }
    Location l = event.getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    if (r != null) {
        return;
    }
    if (e instanceof Wither && event.getSpawnReason().equals(SpawnReason.BUILD_WITHER) && !RPConfig.getGlobalFlagBool(e.getWorld().getName() + ".spawn-wither")) {
        event.setCancelled(true);
        return;
    }
    if (e instanceof Monster && !RPConfig.getGlobalFlagBool(e.getWorld().getName() + ".spawn-monsters")) {
        if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL) || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER) || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN) || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
            event.setCancelled(true);
            return;
        }
    }
    if ((e instanceof Animals || e instanceof Villager || e instanceof Golem) && !RPConfig.getGlobalFlagBool(e.getWorld().getName() + ".spawn-passives")) {
        if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL) || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER) || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN) || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
            event.setCancelled(true);
        }
    }
}
Also used : Wither(org.bukkit.entity.Wither) Golem(org.bukkit.entity.Golem) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Animals(org.bukkit.entity.Animals) Monster(org.bukkit.entity.Monster) Villager(org.bukkit.entity.Villager) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 18 with Monster

use of org.bukkit.entity.Monster in project RedProtect by FabioZumbi12.

the class RPGlobalListener method onEntityDamage.

@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamage(EntityDamageEvent e) {
    Region r = RedProtect.get().rm.getTopRegion(e.getEntity().getLocation());
    if (r != null) {
        return;
    }
    Entity ent = e.getEntity();
    if (ent instanceof LivingEntity && !(ent instanceof Monster)) {
        if (RPConfig.getGlobalFlagBool(ent.getWorld().getName() + ".invincible")) {
            if (ent instanceof Animals) {
                ((Animals) ent).setTarget(null);
            }
            e.setCancelled(true);
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Animals(org.bukkit.entity.Animals) Monster(org.bukkit.entity.Monster) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 19 with Monster

use of org.bukkit.entity.Monster in project RedProtect by FabioZumbi12.

the class RPPlayerListener method onHangingDamaged.

@EventHandler
public void onHangingDamaged(HangingBreakByEntityEvent e) {
    if (e.isCancelled()) {
        return;
    }
    RedProtect.get().logger.debug("Is RPPlayerListener - HangingBreakByEntityEvent event");
    Entity ent = e.getRemover();
    Location loc = e.getEntity().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(loc);
    if (ent instanceof Player) {
        Player player = (Player) ent;
        if (r != null && !r.canBuild(player) && !r.canBreak(e.getEntity().getType())) {
            RPLang.sendMessage(player, "blocklistener.region.cantbuild");
            e.setCancelled(true);
        }
    }
    if (ent instanceof Monster) {
        if (r != null && !r.canMobLoot()) {
            e.setCancelled(true);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) MyPetBukkitEntity(de.Keyle.MyPet.api.entity.MyPetBukkitEntity) Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Monster(org.bukkit.entity.Monster) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 20 with Monster

use of org.bukkit.entity.Monster in project Spirits by xNuminousx.

the class Rejuvenate method healEntities.

public void healEntities(Entity entity) {
    if (new Random().nextInt(effectInt) == 0) {
        if (entity instanceof Player && damageDarkSpirits) {
            Player ePlayer = (Player) entity;
            BendingPlayer bEntity = BendingPlayer.getBendingPlayer(ePlayer);
            if (bEntity.hasElement(Element.getElement("DarkSpirit"))) {
                DamageHandler.damageEntity(ePlayer, damage, this);
            }
        } else if (entity instanceof Monster && damageMonsters) {
            DamageHandler.damageEntity(entity, damage, this);
        } else {
            LivingEntity le = (LivingEntity) entity;
            le.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 120, 1));
            ParticleEffect.HEART.display(entity.getLocation().add(0, 2, 0), 0, 0, 0, 0, 1);
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) BendingPlayer(com.projectkorra.projectkorra.BendingPlayer) BendingPlayer(com.projectkorra.projectkorra.BendingPlayer) Player(org.bukkit.entity.Player) Random(java.util.Random) PotionEffect(org.bukkit.potion.PotionEffect) Monster(org.bukkit.entity.Monster)

Aggregations

Monster (org.bukkit.entity.Monster)27 EventHandler (org.bukkit.event.EventHandler)22 Player (org.bukkit.entity.Player)18 LivingEntity (org.bukkit.entity.LivingEntity)16 Animals (org.bukkit.entity.Animals)15 Entity (org.bukkit.entity.Entity)14 Villager (org.bukkit.entity.Villager)11 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)10 Projectile (org.bukkit.entity.Projectile)9 Location (org.bukkit.Location)8 Slime (org.bukkit.entity.Slime)8 Squid (org.bukkit.entity.Squid)8 IronGolem (org.bukkit.entity.IronGolem)6 Snowman (org.bukkit.entity.Snowman)6 Island (com.wasteofplastic.acidisland.Island)4 Island (com.wasteofplastic.askyblock.Island)4 Golem (org.bukkit.entity.Golem)4 Hanging (org.bukkit.entity.Hanging)4 UUID (java.util.UUID)3 ArmorStand (org.bukkit.entity.ArmorStand)3