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);
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
Aggregations