本文整理匯總了Java中org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CUSTOM屬性的典型用法代碼示例。如果您正苦於以下問題:Java SpawnReason.CUSTOM屬性的具體用法?Java SpawnReason.CUSTOM怎麽用?Java SpawnReason.CUSTOM使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason
的用法示例。
在下文中一共展示了SpawnReason.CUSTOM屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSpawn
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawnerEggs") == true) {
if (event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
}
}
if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawners") == true) {
if (event.getSpawnReason() == SpawnReason.SPAWNER) {
this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
}
}
if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySummonCommand") == true) {
if (event.getSpawnReason() == SpawnReason.DEFAULT) {
this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
}
if (event.getSpawnReason() == SpawnReason.CUSTOM) {
this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
}
}
}
示例2: onEnderDragonSpawn
/**
* - Prevents natural spawn of EnderDragon
* - Prevents too many Dragons in the End world
* - Handle custom health and take care of this new Dragon
*
* @param event a CreatureSpawnEvent
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEnderDragonSpawn(final CreatureSpawnEvent event) {
if (event.getEntityType() == EntityType.ENDER_DRAGON) {
final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getLocation().getWorld().getName()));
if (handler != null) {
if (handler.getNumberOfAliveEnderDragons() >= handler.getConfig().getRespawnNumber()) {
event.setCancelled(true);
} else {
if (event.getSpawnReason() != SpawnReason.CUSTOM && event.getSpawnReason() != SpawnReason.SPAWNER_EGG) {
event.setCancelled(true);
} else {
if (!handler.getDragons().containsKey(event.getEntity().getUniqueId())) {
handler.getDragons().put(event.getEntity().getUniqueId(), new HashMap<String, Double>());
event.getEntity().setMaxHealth(handler.getConfig().getEdHealth());
event.getEntity().setHealth(event.getEntity().getMaxHealth());
}
handler.getLoadedDragons().add(event.getEntity().getUniqueId());
}
}
}
}
}
示例3: onCreatureSpawn
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getSpawnReason() != SpawnReason.CUSTOM) {
event.getEntity().setHealth(0);
event.getEntity().remove();
}
}
示例4: onEntitySpawn
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent event) {
if (event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.EGG)
return;
event.setCancelled(true);
}
示例5: onMonsterSpawn
@EventHandler(priority = EventPriority.NORMAL)
public void onMonsterSpawn(CreatureSpawnEvent event) {
if (event.getSpawnReason() != SpawnReason.CUSTOM && _activated && event.getEntity() instanceof Monster) {
double modifier = calculateGlobalModifier(event.getLocation());
if (modifier > 0.0) {
// boost le health
Damageable entityDamage = event.getEntity();
double maxHealth = entityDamage.getMaxHealth() + (int)(modifier * entityDamage.getMaxHealth());
try {
EntityReflection.setEntityPropertyValue(event.getEntity(), EntityReflection.HEALTH, maxHealth);
ScenarioService.getInstance().updateDamageModifier(event.getEntity(), modifier);
}
catch (Exception ex) {
_logger.info("exception on Frontier!");
}
// ajuste les rare drops, rien en diamant dans le premier palier
if (LocationUtil.getDistanceBetween(event.getLocation(), event.getLocation().getWorld().getSpawnLocation()) <= _divider) {
RareDropsMultiplierData.getInstance().addEntityRareDropsMultiplier(event.getEntity().getEntityId(), new RareDropsMultipliers(0.25, 0.25, 0.00));
}
else {
RareDropsMultiplierData.getInstance().addEntityRareDropsMultiplier(event.getEntity().getEntityId(), new RareDropsMultipliers(modifier, modifier, modifier));
}
}
}
}
示例6: onMobSpawn
@EventHandler
public void onMobSpawn(CreatureSpawnEvent e){
if(e.getSpawnReason() == SpawnReason.CUSTOM)
return;
e.setCancelled(true);
}
示例7: onEntitySpawn
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event) {
if (!enabled || event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.DEFAULT) return;
MagicWorld magicWorld = controller.getWorld(event.getLocation().getWorld().getName());
if (magicWorld == null) return;
LivingEntity entity = event.getEntity();
Plugin plugin = controller.getPlugin();
LivingEntity replace = magicWorld.processEntitySpawn(plugin, entity);
if (replace != null && replace != entity) {
entity.setHealth(0);
event.setCancelled(true);
}
}
示例8: EntitySnapshot
public EntitySnapshot(World pWorld,Entity pEntity,SpawnReason pReason){
this.mWorld=pWorld;
this.mEntity=pEntity;
this.mReason=pReason==null?SpawnReason.CUSTOM:pReason;
}
示例9: onEntitySpawn
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent event) {
event.setCancelled(false);
if (event.getSpawnReason() != SpawnReason.EGG && event.getSpawnReason() != SpawnReason.CUSTOM)
event.setCancelled(true);
}
示例10: onCreatureSpawn
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent e) {
if (!cm.spawnLimitEnabled) {
return;
}
// 如果開啟了TPS閥值,當TPS大於閥值,就不限製
if (cm.spawnLimitTpsThreshold > 0 && cm.spawnLimitTpsThreshold <= 20 &&
NeverLag.getTpsWatcher().getAverageTPS() >= cm.spawnLimitTpsThreshold) {
return;
}
// 實體有自定義名字的不限製,兼容MM怪物等插件
LivingEntity creature = e.getEntity();
if (creature.getCustomName() != null) {
return;
}
// 不限製插件、刷怪蛋、刷怪籠刷出的實體和凋零、鐵傀儡、雪人
if (creature.getType() != EntityType.IRON_GOLEM && creature.getType() != EntityType.SNOWMAN && creature.getType() != EntityType.WITHER
&& e.getSpawnReason() != SpawnReason.SPAWNER_EGG && e.getSpawnReason() != SpawnReason.SPAWNER
&& e.getSpawnReason() != SpawnReason.CUSTOM) {
if (creature instanceof Animals) {
if (this.getMobCount() >= cm.spawnLimitAnimalThreshold) {
e.setCancelled(true);
}
} else if (creature instanceof Monster) {
if (this.getMobCount() >= cm.spawnLimitMonsterThreshold) {
e.setCancelled(true);
}
}
}
// 刷怪籠不按照總數量限製,而是按照區塊內實體數量
if (SpawnReason.SPAWNER == e.getSpawnReason()) {
int count = 0;
for (Entity entity : e.getLocation().getChunk().getEntities()) {
if (creature instanceof Monster && entity instanceof Monster) {
count++;
} else if (creature instanceof Animals && entity instanceof Animals) {
count++;
} else if (entity instanceof Monster) {
count++;
}
if (count > cm.maxSpawnEntityPerChunk) {
e.setCancelled(true);
break;
}
}
}
}
示例11: addEntity
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
if (entity == null) return false;
// CraftBukkit end
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
boolean flag = entity.attachedToPlayer;
if (entity instanceof EntityHuman) {
flag = true;
}
// CraftBukkit start
org.bukkit.event.Cancellable event = null;
if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;
if (spawnReason != SpawnReason.CUSTOM) {
if (isAnimal && !allowAnimals || isMonster && !allowMonsters) {
entity.dead = true;
return false;
}
}
event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
} else if (entity instanceof EntityItem) {
event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
event = CraftEventFactory.callProjectileLaunchEvent(entity);
}
if (event != null && (event.isCancelled() || entity.dead)) {
entity.dead = true;
return false;
}
// CraftBukkit end
if (!flag && !this.isChunkLoaded(i, j)) {
entity.dead = true; // CraftBukkit
return false;
} else {
if (entity instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) entity;
this.players.add(entityhuman);
this.everyoneSleeping();
this.b(entity);
}
this.getChunkAt(i, j).a(entity);
this.entityList.add(entity);
this.a(entity);
return true;
}
}
示例12: addEntity
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity add!"); // Spigot
if (entity == null) return false;
// CraftBukkit end
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
boolean flag = entity.p;
if (entity instanceof EntityHuman) {
flag = true;
}
// CraftBukkit start
org.bukkit.event.Cancellable event = null;
if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;
if (spawnReason != SpawnReason.CUSTOM) {
if (isAnimal && !allowAnimals || isMonster && !allowMonsters) {
entity.dead = true;
return false;
}
}
event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
} else if (entity instanceof EntityItem) {
event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
event = CraftEventFactory.callProjectileLaunchEvent(entity);
}
// Spigot start
else if (entity instanceof EntityExperienceOrb) {
EntityExperienceOrb xp = (EntityExperienceOrb) entity;
double radius = spigotConfig.expMerge;
if (radius > 0) {
List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
for (Entity e : entities) {
if (e instanceof EntityExperienceOrb) {
EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
if (!loopItem.dead) {
xp.value += loopItem.value;
loopItem.die();
}
}
}
}
} // Spigot end
if (event != null && (event.isCancelled() || entity.dead)) {
entity.dead = true;
return false;
}
// CraftBukkit end
if (!flag && !this.isChunkLoaded(i, j)) {
entity.dead = true; // CraftBukkit
return false;
} else {
if (entity instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) entity;
this.players.add(entityhuman);
this.everyoneSleeping();
}
this.getChunkAt(i, j).a(entity);
this.entityList.add(entity);
this.a(entity);
return true;
}
}
示例13: addEntity
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
org.spigotmc.AsyncCatcher.catchOp( "entity add"); // Spigot
if (entity == null) return false;
// CraftBukkit end
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
boolean flag = entity.attachedToPlayer;
if (entity instanceof EntityHuman) {
flag = true;
}
// CraftBukkit start
org.bukkit.event.Cancellable event = null;
if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;
if (spawnReason != SpawnReason.CUSTOM) {
if (isAnimal && !allowAnimals || isMonster && !allowMonsters) {
entity.dead = true;
return false;
}
}
event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
} else if (entity instanceof EntityItem) {
event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
event = CraftEventFactory.callProjectileLaunchEvent(entity);
}
// Spigot start
else if (entity instanceof EntityExperienceOrb) {
EntityExperienceOrb xp = (EntityExperienceOrb) entity;
double radius = spigotConfig.expMerge;
if (radius > 0) {
List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
for (Entity e : entities) {
if (e instanceof EntityExperienceOrb) {
EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
if (!loopItem.dead) {
xp.value += loopItem.value;
loopItem.die();
}
}
}
}
} // Spigot end
if (event != null && (event.isCancelled() || entity.dead)) {
entity.dead = true;
return false;
}
// CraftBukkit end
if (!flag && !this.isChunkLoaded(i, j)) {
entity.dead = true; // CraftBukkit
return false;
} else {
if (entity instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) entity;
this.players.add(entityhuman);
this.everyoneSleeping();
this.b(entity);
}
this.getChunkAt(i, j).a(entity);
this.entityList.add(entity);
this.a(entity);
return true;
}
}
示例14: onEntitySpawn
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent event) {
if (event.isCancelled())
return;
// Don't mess with other Plugins or Spawn Eggs
// REMEMBER: Our own Mod throws CUSTOM spawn events when we cancel the old spawn
// and schedule a new one in this handler
if ((SpawnReason.CUSTOM == event.getSpawnReason()) ||
(SpawnReason.DISPENSE_EGG == event.getSpawnReason()))
return;
if (SpawnReason.BREEDING == event.getSpawnReason()) {
event.getEntity().setMetadata("domesticated", new FixedMetadataValue(p, "true"));
// BetterPassives used to assign a CustomName here on passives
// TODO: Do over-crowding checks
}
// If a hostile tried to spawn, change it to a locally acceptable hostile
if (event.getEntity() instanceof Monster) {
// If this is not one of the Monsters(Hostile) that is allowed here, change it to one that is
}
if (PlanetSettings.getInstance().isAllowed(event)) {
PlanetSettings.getInstance().applyPlanetChanges(event.getEntity());
} else {
event.setCancelled(true);
}
// } else if (event.getSpawnReason() != SpawnReason.CUSTOM) {
// if (!event.isCancelled()) {
// List<EntityType> types = p.getAcceptableHostileTypes(event.getEntity().getWorld());
// if (types == null) {
// event.setCancelled(true);
// return;
// }
// if (types.size() == 0) {
// event.setCancelled(true);
// return;
// }
// if (types.contains(event.getEntity().getType()) && !event.getEntity().getWorld().getName().equalsIgnoreCase("Ceharram")){
// hostileQueue.add(event.getEntity());
// if(hostileQueue.size() > MAX_HOSTILES){
// hostileQueue.remove().remove();
// }
// return;
// }
//
//
// Collections.shuffle(types);
// EntityType type = types.get(0);
// Entity e = event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), type);
// String n = e.getWorld().getName().toLowerCase();
// if (e.getType() == EntityType.SKELETON && n.equals("inaris")) {
// Skeleton s = (Skeleton) e;
// s.setSkeletonType(SkeletonType.WITHER);
// } else if (e.getType() == EntityType.CREEPER && n.equals("acualis")) {
// Creeper c = (Creeper) e;
// c.setPowered(true);
// permaVanish(c);
// } else if (e.getType() == EntityType.SKELETON && n.equals("krystallos")) {
// createRobot((Skeleton) e);
// } else if (e.getType() == EntityType.ZOMBIE && n.equals("emera")) {
// createSpiritBlock((Zombie) e);
// }
// event.setCancelled(true);
// hostileQueue.add(e);
// if(hostileQueue.size() > MAX_HOSTILES){
// hostileQueue.remove().remove();
// }
// }
// }
}
示例15: addEntity
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
org.spigotmc.AsyncCatcher.catchOp( "entity add"); // Spigot
if (entity == null) return false;
// CraftBukkit end
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
boolean flag = entity.attachedToPlayer;
if (entity instanceof EntityHuman) {
flag = true;
}
// CraftBukkit start
org.bukkit.event.Cancellable event = null;
if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;
if (spawnReason != SpawnReason.CUSTOM) {
if (isAnimal && !allowAnimals || isMonster && !allowMonsters) {
entity.dead = true;
return false;
}
}
event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
} else if (entity instanceof EntityItem) {
event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
event = CraftEventFactory.callProjectileLaunchEvent(entity);
}
// Spigot start
else if (entity instanceof EntityExperienceOrb) {
EntityExperienceOrb xp = (EntityExperienceOrb) entity;
double radius = spigotConfig.expMerge;
if (radius > 0) {
List<Entity> entities = this.getEntities(entity, entity.getBoundingBox().grow(radius, radius, radius));
for (Entity e : entities) {
if (e instanceof EntityExperienceOrb) {
EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
if (!loopItem.dead) {
xp.value += loopItem.value;
loopItem.die();
}
}
}
}
} // Spigot end
if (event != null && (event.isCancelled() || entity.dead)) {
entity.dead = true;
return false;
}
// CraftBukkit end
if (!flag && !this.isChunkLoaded(i, j, false)) {
return false;
} else {
if (entity instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) entity;
this.players.add(entityhuman);
this.everyoneSleeping();
}
this.getChunkAt(i, j).a(entity);
this.entityList.add(entity);
this.b(entity);
return true;
}
}