本文整理汇总了Java中org.bukkit.event.entity.EntitySpawnEvent类的典型用法代码示例。如果您正苦于以下问题:Java EntitySpawnEvent类的具体用法?Java EntitySpawnEvent怎么用?Java EntitySpawnEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntitySpawnEvent类属于org.bukkit.event.entity包,在下文中一共展示了EntitySpawnEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadArmorStand
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
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");
}
示例2: onDragonSpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
/**
* 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);
}
}
示例3: checkAndRemoveTooManyEntities
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
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++;
}
}
}
}
}
}
示例4: onEntitySpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
/**
* 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);
}
}
示例5: onEntitySpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
/**
* 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);
}
示例6: onEntitySpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
@EventHandler
public void onEntitySpawn(EntitySpawnEvent ev)
{
switch (ev.getEntityType())
{
case ARMOR_STAND:
case PLAYER:
case SLIME:
case MAGMA_CUBE:
return ;
default:
ev.setCancelled(true);
}
}
示例7: onSpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
@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);
}
}
}
示例8: onSpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
@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);
}
示例9: onEntitySpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
/**
* 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();
}
}
示例10: creatureSpawnEvent
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
@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()));
}
}
}
示例11: spawnListener
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
@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); }
}
示例12: onSpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
@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);
}
}
}
示例13: onSpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
@EventHandler
public void onSpawn(EntitySpawnEvent e) {
if (e.getEntity() instanceof Animals) e.setCancelled(true);
}
示例14: check
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
@Override
public boolean check(Event event) {
return event instanceof EntitySpawnEvent && ((EntitySpawnEvent) event).getEntity() instanceof ArmorStand;
}
示例15: armorStandStop
import org.bukkit.event.entity.EntitySpawnEvent; //导入依赖的package包/类
@EventHandler
public void armorStandStop(EntitySpawnEvent event)
{
if(event.getEntityType() == EntityType.ARMOR_STAND)
event.setCancelled(true);
}