Java 类org.bukkit.event.entity.EntitySpawnEvent 实例源码

项目:MundoSK    文件:MiscMundo.java   
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");
}
项目:askygrid    文件:BlockEndDragon.java   
/**
    * 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);
}
   }
项目:StarQuestCode    文件:EntityListener.java   
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++;
                    }
                }
            }
        }
    }
}
项目:OpenUHC    文件:LobbyModule.java   
/**
 * 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);
  }
}
项目:SurvivalAPI    文件:GameListener.java   
/**
 * 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);
}
项目:AgarMC    文件:WorldListener.java   
@EventHandler
public void onEntitySpawn(EntitySpawnEvent ev)
{
    switch (ev.getEntityType())
    {
    case ARMOR_STAND:
    case PLAYER:
    case SLIME:
    case MAGMA_CUBE:
        return ;
    default:
        ev.setCancelled(true);
    }
}
项目:SkywarsSeries    文件:EntitySpawn.java   
@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);
        }
    }
}
项目:Pokkit    文件:EntityEvents.java   
@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);
}
项目:buildinggame    文件:EntitySpawn.java   
/**
    * 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();
    }
}
项目:PlotSquared    文件:EntitySpawnListener.java   
@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()));
            }
    }
}
项目:CraftoPlugin    文件:EntitySpawnListener.java   
@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); }
}
项目:Equestrian-Dash    文件:EntitySpawnListener.java   
@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);
        }
    }
}
项目:PA    文件:GameEvents.java   
@EventHandler
public void onSpawn(EntitySpawnEvent e) {
    if (e.getEntity() instanceof Animals) e.setCancelled(true);
}
项目:MundoSK    文件:EvtArmorStandPlace.java   
@Override
public boolean check(Event event) {
    return event instanceof EntitySpawnEvent && ((EntitySpawnEvent) event).getEntity() instanceof ArmorStand;
}
项目:AnnihilationPro    文件:ArmorStandListener.java   
@EventHandler
public void armorStandStop(EntitySpawnEvent event)
{
    if(event.getEntityType() == EntityType.ARMOR_STAND)
        event.setCancelled(true);
}
项目:NPCs    文件:NPCManager.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntitySpawn(EntitySpawnEvent event) {
  if (spawning) {
    event.setCancelled(false);
  }
}