/** * Gets the location at which the creature is spawning. * * @return The location at which the creature is spawning */ public Location getLocation() { return getEntity().getLocation(); }
/** * This handles end dragon spawning prevention * * @param e - event * @return true if dragon can spawn, false if not */ @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public boolean onDragonSpawn(CreatureSpawnEvent e) { if (!e.getEntityType().equals(EntityType.ENDER_DRAGON) || plugin.getIWM().isDragonSpawn(e.getEntity().getWorld())) { return true; } e.getEntity().setHealth(0); e.getEntity().remove(); e.setCancelled(true); return false; }
@Override public MCLivingEntity getEntity() { return (MCLivingEntity) BukkitConvertor.BukkitGetCorrectEntity(e.getEntity()); }
/** * Track where the mob was created. This will determine its allowable movement zone. * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onMobSpawn(CreatureSpawnEvent e) { if (getIWM().inWorld(e.getLocation()) && getIWM().getGeoLimitSettings(e.getLocation().getWorld()).contains(e.getEntityType().name())) { getIslands().getIslandAt(e.getLocation()).ifPresent(i -> mobSpawnTracker.put(e.getEntity(), i)); } }
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = false) public void onCreatureSpawn(CreatureSpawnEvent event) { if (nmsManager.isNMSEntityBase(event.getEntity())) { if (event.isCancelled()) { event.setCancelled(false); } } }
public void onCreatureSpawn(CreatureSpawnEvent event) { if (!arena.getRegion().contains(event.getLocation())) { return; } if (arena.inEditMode() && event.getEntityType() == EntityType.ARMOR_STAND) { return; } if (event.getSpawnReason() != SpawnReason.CUSTOM) { if (event.getSpawnReason() == SpawnReason.BUILD_IRONGOLEM || event.getSpawnReason() == SpawnReason.BUILD_SNOWMAN) { monsters.addGolem(event.getEntity()); } else { event.setCancelled(true); return; } } LivingEntity entity = event.getEntity(); if (arena.isRunning() && entity instanceof Slime) monsters.addMonster(entity); // If running == true, setCancelled(false), and vice versa. event.setCancelled(!arena.isRunning()); }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSilurianSpawn(CreatureSpawnEvent event) { if (!event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)) { return; } if (!event.getLocation().getWorld().getName().equals("Siluria")) { return; } if (!event.getEntity().getType().equals(EntityType.SKELETON)) { return; } LivingEntity le = event.getEntity(); // it's a Silurian - disguise it! twaAPI.setSilurianEquipment(le, false); } }
/** * Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit. * @param event The event. */ @EventHandler public void creatureSpawn(CreatureSpawnEvent event) { // Check to see if the Creature is spawned by a plugin, we don't want to prevent this behaviour. // TODO: Allow the egg thing to be a config param. Doubt this will be per world; seems silly. if (event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.SPAWNER_EGG || event.getSpawnReason() == SpawnReason.BREEDING) { return; } World world = event.getEntity().getWorld(); if (event.isCancelled()) return; // Check if it's a world which we are meant to be managing. if (!(this.worldManager.isMVWorld(world.getName()))) return; EntityType type = event.getEntityType(); /** * Handle people with non-standard animals: ie a patched craftbukkit. */ if (type == null || type.getName() == null) { this.plugin.log(Level.FINER, "Found a null typed creature."); return; } MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName()); event.setCancelled(this.plugin.getMVWorldManager().getTheWorldPurger().shouldWeKillThisCreature(mvworld, event.getEntity())); }
public boolean onNaturalMobSpawn(CreatureSpawnEvent e) { if (e.getEntity() == null || !getIWM().inWorld(e.getEntity().getLocation())) { return false; if ((e.getEntity() instanceof Monster || e.getEntity() instanceof Slime)) { boolean cancel = island.map(i -> !i.isAllowed(Flags.MONSTER_SPAWN)).orElse(!Flags.MONSTER_SPAWN.isSetForWorld(e.getEntity().getWorld())); e.setCancelled(cancel); return cancel; } else if (e.getEntity() instanceof Animals) { boolean cancel = island.map(i -> !i.isAllowed(Flags.ANIMAL_SPAWN)).orElse(!Flags.ANIMAL_SPAWN.isSetForWorld(e.getEntity().getWorld())); e.setCancelled(cancel); return cancel;
@EventHandler(ignoreCancelled = true) private void mobSpawnEvent(CreatureSpawnEvent event){ if(hasRegenArea() && minigame.hasPlayers() && blockInRegenArea(event.getLocation())){ addEntity(event.getEntity(), null, true); } }
/** * Monitor CreatureSpawn events. * * @param event * The event to watch */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; LivingEntity entity = event.getEntity(); switch (event.getSpawnReason()) { case NETHER_PORTAL: case SPAWNER: case SPAWNER_EGG: entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); Entity passenger = entity.getPassenger(); if (passenger != null) { passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); } return; case BREEDING: entity.setMetadata(mcMMO.bredMetadataKey, mcMMO.metadataValue); return; default: return; } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInteract(CreatureSpawnEvent event) { Entity ent = event.getEntity(); if (!(ent instanceof Ageable)) { return; } if (!event.getSpawnReason().equals(SpawnReason.BREEDING)) { return; } Location l = ent.getLocation(); String w = l.getWorld().getName(); if (!plugin.getTrackerKeeper().getSiegeBreedingAreas().containsKey(w)) { return; } plugin.getTrackerKeeper().getSiegeBreedingAreas().get(w).forEach((area) -> { if (area.isInSiegeArea(l) && random.nextInt(100) < chance) { // make them twins plugin.setTardisSpawn(true); Ageable twin = (Ageable) l.getWorld().spawnEntity(l, ent.getType()); twin.setBaby(); } }); } }
final Entity entity = event.getEntity(); SpawnReason reason = event.getSpawnReason(); if (reason != SpawnReason.SPAWNER
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onDalekSpawn(CreatureSpawnEvent event) { if (!event.getSpawnReason().equals(SpawnReason.SPAWNER)) { return; } if (!event.getLocation().getWorld().getName().equals("Skaro")) { return; } if (!event.getEntity().getType().equals(EntityType.SKELETON)) { return; } LivingEntity le = event.getEntity(); // it's a Dalek - disguise it! twaAPI.setDalekEquipment(le); if (plugin.getPlanetsConfig().getBoolean("planets.Skaro.flying_daleks") && r.nextInt(100) < 10) { // make the Dalek fly EntityEquipment ee = le.getEquipment(); ee.setChestplate(new ItemStack(Material.ELYTRA, 1)); // teleport them straight up le.teleport(le.getLocation().add(0.0d, 20.0d, 0.0d)); plugin.getTardisHelper().setFallFlyingTag(le); } } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { Location loc = event.getEntity().getLocation(); if (loc == null) return; World world = loc.getWorld(); if (world == null) return; BorderData border = Config.Border(world.getName()); if (border == null) return; if (!border.insideBorder(loc.getX(), loc.getZ(), Config.ShapeRound())) { event.setCancelled(true); } }
final Entity spawned = event.getEntity(); if (spawned instanceof EnderDragon)
LivingEntity creature = e.getEntity(); if (creature.getCustomName() != null) { return;