/** * Gets the location at which the creature is spawning. * * @return The location at which the creature is spawning */ public Location getLocation() { return getEntity().getLocation(); }
/** * Gets the type of creature being spawned. * * @return A CreatureType value detailing the type of creature being * spawned * @deprecated In favour of {@link #getEntityType()}. */ @Deprecated public CreatureType getCreatureType() { return CreatureType.fromEntityType(getEntityType()); }
@EventHandler(priority = EventPriority.LOWEST) public void onEntitySpawn(CreatureSpawnEvent event) { //these rules apply only to creative worlds if(!GriefPrevention.instance.creativeRulesApply(event.getLocation())) return; //chicken eggs and breeding could potentially make a mess in the wilderness, once griefers get involved SpawnReason reason = event.getSpawnReason(); if(reason != SpawnReason.SPAWNER_EGG && reason != SpawnReason.BUILD_IRONGOLEM && reason != SpawnReason.BUILD_SNOWMAN && event.getEntityType() != EntityType.ARMOR_STAND) { event.setCancelled(true); return; } //otherwise, just apply the limit on total entities per claim (and no spawning in the wilderness!) Claim claim = this.dataStore.getClaimAt(event.getLocation(), false, null); if(claim == null || claim.allowMoreEntities(true) != null) { event.setCancelled(true); return; } }
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { if (event.getLocation() == null) { return; } if (Conf.safeZoneNerfedCreatureTypes.contains(event.getEntityType()) && Board.getInstance().getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory()) { event.setCancelled(true); } }
/** * 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())); }
@EventHandler public void onMobSpawn(CreatureSpawnEvent evt) { switch (evt.getSpawnReason()) { case NATURAL: case JOCKEY: case CHUNK_GEN: case SPAWNER: case BUILD_WITHER: case VILLAGE_DEFENSE: case VILLAGE_INVASION: case REINFORCEMENTS: case NETHER_PORTAL: if (Statics.ARENA_WORLD_NAME.equals(evt.getLocation().getWorld().getName())) { evt.setCancelled(true); } break; default: break; } } }
@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); } }
if (event.isCancelled()) { return; Entity entity = event.getEntity(); Location loc = event.getLocation(); Field field = plugin.getForceFieldManager().getEnabledSourceField(loc, FieldFlag.PREVENT_MOB_SPAWN); if (field != null) { event.setCancelled(true); Field field = plugin.getForceFieldManager().getEnabledSourceField(loc, FieldFlag.PREVENT_ANIMAL_SPAWN); if (field != null) { event.setCancelled(true); if (field != null) { List<String> types = field.getSettings().getPotionTargets(); plugin.getPotionManager().addEffectToEntity(field, event.getEntity(), types);
final Entity spawned = event.getEntity(); if (spawned instanceof EnderDragon) event.setCancelled(true); return; event.setCancelled(true); return; event.setCancelled(true); return; event.setCancelled(true); return; event.setCancelled(true); return; for (Entity entity : event.getLocation().getWorld().getLivingEntities()) event.setCancelled(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 public void onCreatureSpawn(CreatureSpawnEvent e) { if (e.getSpawnReason() == CreatureSpawnEvent.SpawnReason.EGG) { e.setCancelled(true); } }
/** * 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; }
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = false) public void onCreatureSpawn(CreatureSpawnEvent event) { if (nmsManager.isNMSEntityBase(event.getEntity())) { if (event.isCancelled()) { event.setCancelled(false); } } }
/** * 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)); } }
@Override public void setType(MCEntityType type) { e.setCancelled(true); e.getLocation().getWorld().spawnEntity(e.getLocation(), EntityType.valueOf(type.name())); } }
@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); } }
@EventHandler(ignoreCancelled = true) private void mobSpawnEvent(CreatureSpawnEvent event){ if(hasRegenArea() && minigame.hasPlayers() && blockInRegenArea(event.getLocation())){ addEntity(event.getEntity(), null, true); } }
@EventHandler(ignoreCancelled = false, priority = EventPriority.HIGHEST) public void onCreatureSpawn(CreatureSpawnEvent event) { if (forceSpawn) { event.setCancelled(false); } }
@Override public MCLocation getLocation() { return new BukkitMCLocation(e.getLocation()); }
@Override public MCSpawnReason getSpawnReason() { return BukkitMCSpawnReason.getConvertor().getAbstractedEnum(e.getSpawnReason()); }