private static void loadArmorStand() { Registration.registerEvent("Armor Stand Interact Event", SimpleEvent.class, PlayerArmorStandManipulateEvent.class, "armor stand (manipulate|interact)") .document("Armor Stand Interact", "1.6.9", "Called when a player right clicks an armor stand to put something on it / take something off of it. " + "The event is called before the interaction fully happens, meaning, for example, player's tool is what was in the player's hand before interacting, " + "and (if it isn't air) represents what the player is putting on the armor stand. " + "Note: If you are using Umbaska, make sure to use manipulate instead of interact, as interact conflicts with an Umbaska event.") .eventValue(Player.class, "1.6.9", "The player.") .eventValue(Entity.class, "1.6.9", "The armor stand.") .eventValue(ItemStack.class, "1.6.9", "The item being taken off.") .eventValue(Slot.class, "1.6.9", "The equipment slot, use this to set the item in that particular event."); Registration.registerEventValue(PlayerArmorStandManipulateEvent.class, ItemStack.class, PlayerArmorStandManipulateEvent::getArmorStandItem); Registration.registerEventValue(PlayerArmorStandManipulateEvent.class, Slot.class, e -> new ArmorStandEquipmentSlot(e.getRightClicked(), ArmorStandEquipmentSlot.EquipSlot.getByEquipmentSlot(e.getSlot()))); Registration.registerEvent("Armor Stand Place Event", EvtArmorStandPlace.class, EntitySpawnEvent.class, "armor stand place") .document("Armor Stand Place", "1.6.9", "Called when an armor stand is placed") .eventValue(Entity.class, "1.6.9", "The armor stand that was placed"); }
/** * This handles end dragon spawning * * @param event */ @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onDragonSpawn(EntitySpawnEvent event) { if (!Settings.createEnd) { return; } if (!event.getLocation().getWorld().equals(ASkyGrid.getEndWorld())) { return; } if (event.getEntityType().equals(EntityType.ENDER_DRAGON)) { //plugin.getLogger().info("DEBUG: removing ender dragon"); LivingEntity dragon = (LivingEntity)event.getEntity(); dragon.setHealth(0); event.getEntity().remove(); event.setCancelled(true); } }
private void checkAndRemoveTooManyEntities(EntitySpawnEvent event, List<EntityType> passives) { Entity[] cents = event.getEntity().getLocation().getChunk().getEntities(); int count = 0; for (Entity e : cents) { if (e instanceof LivingEntity) { LivingEntity le = (LivingEntity) e; if (passives.contains(e.getType())) { if ((le.getCustomName() != null) || le.isCustomNameVisible()) { if (count > Settings.getTamedPerChunk()) { e.remove(); } else { count++; } } } } } }
/** * Prevents lobby players from interacting in the world. * * @param event The event */ @EventHandler public void onEntitySpawn(final EntitySpawnEvent event) { if (event.getLocation().getWorld().equals(world)) { event.setCancelled(true); } }
/** * Disable Guardian spawn (Mining Fatique effect) * * @param event Event */ @EventHandler public void onEntitySpawn(EntitySpawnEvent event) { if (event.getEntityType() == EntityType.GUARDIAN || event.getEntityType() == EntityType.WITCH) event.setCancelled(true); }
@EventHandler public void onEntitySpawn(EntitySpawnEvent ev) { switch (ev.getEntityType()) { case ARMOR_STAND: case PLAYER: case SLIME: case MAGMA_CUBE: return ; default: ev.setCancelled(true); } }
@EventHandler public void onSpawn(EntitySpawnEvent event) { if (Skywars.getInstance().isSingleServerMode()) { if (event.getEntityType() != EntityType.PLAYER && event.getEntityType() != EntityType.DROPPED_ITEM && event.getEntityType() != EntityType.PRIMED_TNT) { event.setCancelled(true); } } }
@EventHandler(ignoreCancelled = false) public void onSpawn(cn.nukkit.event.entity.EntitySpawnEvent event) { if (canIgnore(EntitySpawnEvent.getHandlerList())) { return; } EntitySpawnEvent bukkitEvent = new EntitySpawnEvent(PokkitEntity.toBukkit(event.getEntity())); callUncancellable(bukkitEvent); }
/** * Handles entity spawning * * @param e an event representing a spawned entity * @see EntitySpawnEvent * @since 2.1.0 */ @EventHandler(ignoreCancelled = true) public void onEntitySpawn(EntitySpawnEvent e) { Entity entity = e.getEntity(); Plot plot; if ((plot = Plot.getPlot(entity.getLocation())) != null) { if (!plot.addEntity(entity)) entity.remove(); } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void creatureSpawnEvent(EntitySpawnEvent event) { Entity entity = event.getEntity(); Location location = BukkitUtil.getLocation(entity.getLocation()); PlotArea area = location.getPlotArea(); if (area == null) { return; } Plot plot = area.getOwnedPlotAbs(location); if (plot == null) { if (!area.MOB_SPAWNING) { if (event.getEntityType().isAlive() || !area.MISC_SPAWN_UNOWNED) { event.setCancelled(true); } } return; } if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) { event.setCancelled(true); } switch (entity.getType()) { case ENDER_CRYSTAL: if (PlayerEvents.checkEntity(entity, plot)) { event.setCancelled(true); } case SHULKER: if(!entity.hasMetadata("plot")) { entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot.getId())); } } }
@EventHandler public void spawnListener(final EntitySpawnEvent event) { if (!this.spawnListener) { return; } try { @SuppressWarnings("unused") final StoredEntity entity = this.module.getOrCreateEntity(event.getEntity()); this.spawnListenerInserts++; } catch (final Exception e) { CraftoMessenger.report(this.getClass(), "Failed to store entity: " + event.getEntity().getType() + " (" + event.getEntity().getUniqueId() + ")", e); } }
@EventHandler public void onSpawn(EntitySpawnEvent event) { //plugin.getLogger().info("SPAWN EVENT!"); if(event.getEntity() instanceof EnderCrystal) { ItemBox itemBox = plugin.getItemBoxRegistry().getByLocation(event.getLocation().getBlock().getLocation()); if(itemBox != null && !itemBox.getEnderCrystal().equals(event.getEntity())) { event.setCancelled(true); } } }
@EventHandler public void onSpawn(EntitySpawnEvent e) { if (e.getEntity() instanceof Animals) e.setCancelled(true); }
@Override public boolean check(Event event) { return event instanceof EntitySpawnEvent && ((EntitySpawnEvent) event).getEntity() instanceof ArmorStand; }
@EventHandler public void armorStandStop(EntitySpawnEvent event) { if(event.getEntityType() == EntityType.ARMOR_STAND) event.setCancelled(true); }
@EventHandler(priority = EventPriority.HIGHEST) public void onEntitySpawn(EntitySpawnEvent event) { if (spawning) { event.setCancelled(false); } }