本文整理汇总了Java中org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER属性的典型用法代码示例。如果您正苦于以下问题:Java SpawnReason.SPAWNER属性的具体用法?Java SpawnReason.SPAWNER怎么用?Java SpawnReason.SPAWNER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason
的用法示例。
在下文中一共展示了SpawnReason.SPAWNER属性的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: onEntitySpawn
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event)
{
LivingEntity entity = event.getEntity();
if(!this.isMonster(entity)) return;
SpawnReason reason = event.getSpawnReason();
if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG)
{
entity.setMetadata(this.ALLOW_TARGET_TAG, new FixedMetadataValue(GPFlags.instance, new Boolean(true)));
return;
}
Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
if(flag == null) return;
event.setCancelled(true);
}
示例3: onEntitySpawn
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event)
{
if(!(event.getEntity() instanceof LivingEntity)) return;
if(event.getLocation() == null) return;
EntityType type = event.getEntityType();
if(type == EntityType.PLAYER) return;
if(type == EntityType.ARMOR_STAND) return;
SpawnReason reason = event.getSpawnReason();
if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) return;
Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
if(flag == null) return;
event.setCancelled(true);
}
示例4: onEntityDeath
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) {
LivingEntity entity = event.getEntity();
World world = entity.getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (entity instanceof Creature && plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_EXP)) {
if (!worldConfig.getBoolean(Config.FEATURE_MORE_EXP_IGNORE_SPAWNERS) || plugin.getSpawnReason(entity) != SpawnReason.SPAWNER) {
event.setDroppedExp(event.getDroppedExp() * Math.max(worldConfig.getInt(Config.FEATURE_MORE_EXP_MULTIPLIER), 0));
}
}
}
示例5: onEntityDeath
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
LivingEntity entity = event.getEntity();
World world = entity.getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (entity instanceof Creature && plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_DROPS)) {
if (!worldConfig.getBoolean(Config.FEATURE_MORE_DROPS_IGNORE_SPAWNERS) || plugin.getSpawnReason(entity) != SpawnReason.SPAWNER) {
for (ItemStack drop : event.getDrops()) {
drop.setAmount(drop.getAmount() * Math.max(worldConfig.getInt(Config.FEATURE_MORE_DROPS_MULTIPLIER), 0));
}
}
}
}
示例6: onStart
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onStart(BloodMoonStartEvent event) {
World world = event.getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (plugin.isFeatureEnabled(world, Feature.ZOMBIE_ARMOR)) {
for (LivingEntity entity : event.getWorld().getLivingEntities()) {
if (!worldConfig.getBoolean(Config.FEATURE_ZOMBIE_ARMOR_IGNORE_SPAWNERS) || plugin.getSpawnReason(entity) != SpawnReason.SPAWNER) {
if (entity.getType() == EntityType.ZOMBIE && this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_ZOMBIE_WEAPON_CHANCE)) {
this.giveArmor(entity, worldConfig);
}
}
}
}
}
示例7: onCreatureSpawn
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
World world = event.getLocation().getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.ZOMBIE_ARMOR)) {
LivingEntity entity = event.getEntity();
if (!worldConfig.getBoolean(Config.FEATURE_ZOMBIE_ARMOR_IGNORE_SPAWNERS) || event.getSpawnReason() != SpawnReason.SPAWNER) {
if (entity.getType() == EntityType.ZOMBIE && this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_ZOMBIE_WEAPON_CHANCE)) {
this.giveArmor(entity, worldConfig);
}
}
}
}
示例8: onStart
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onStart(BloodMoonStartEvent event) {
World world = event.getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (plugin.isFeatureEnabled(world, Feature.ZOMBIE_WEAPON)) {
for (LivingEntity entity : event.getWorld().getLivingEntities()) {
if (!worldConfig.getBoolean(Config.FEATURE_ZOMBIE_WEAPON_IGNORE_SPAWNERS) || plugin.getSpawnReason(entity) != SpawnReason.SPAWNER) {
if (entity.getType() == EntityType.ZOMBIE && this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_ZOMBIE_WEAPON_CHANCE)) {
this.giveWeapon(entity, worldConfig);
}
}
}
}
}
示例9: onCreatureSpawn
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
World world = event.getLocation().getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.ZOMBIE_WEAPON)) {
LivingEntity entity = event.getEntity();
if (!worldConfig.getBoolean(Config.FEATURE_ZOMBIE_WEAPON_IGNORE_SPAWNERS) || event.getSpawnReason() != SpawnReason.SPAWNER) {
if (entity.getType() == EntityType.ZOMBIE && this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_ZOMBIE_WEAPON_CHANCE)) {
this.giveWeapon(entity, worldConfig);
}
}
}
}
示例10: onSpawn
@EventHandler
public void onSpawn(CreatureSpawnEvent event)
{
if(event.getSpawnReason() != SpawnReason.SPAWNER
&& event.getSpawnReason() != SpawnReason.SPAWNER_EGG){
return;
}
if(!this.entityTypes.contains(event.getEntityType())){
return;
}
LivingEntity ent = event.getEntity();
ent.setMetadata("spawned", new FixedMetadataValue(plugin, true));
}
示例11: onSpawn
@EventHandler
public void onSpawn(CreatureSpawnEvent event)
{
if(!mobs.contains(event.getEntityType()))
return;
if(event.getSpawnReason() != SpawnReason.SPAWNER)
return;
LivingEntity ent = event.getEntity();
ent.setMetadata("spawned", new FixedMetadataValue(plugin, true));
}
示例12: onMobSpawn
@EventHandler(priority = EventPriority.LOWEST)
public void onMobSpawn(CreatureSpawnEvent event) {
// Only log spawned mobs if we want to disable earnings
if (getConfig().getBoolean("global.spawner_earnings", true)) {
return;
}
if (event.getSpawnReason() == SpawnReason.SPAWNER) {
spawnedMobs.add(event.getEntity().getUniqueId());
}
}
示例13: 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;
}
}
}
}
示例14: onEntitySpawn
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent e) {
if (e.getSpawnReason() == SpawnReason.SPAWNER)
e.getEntity().setMetadata("isSpawnerMob", new FixedMetadataValue(instance, true));
}
示例15: onVillagerSpawn
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onVillagerSpawn(final CreatureSpawnEvent e) {
// If not an villager
if (!(e.getEntity() instanceof Villager)) {
return;
}
if (DEBUG3) {
plugin.getLogger().info("Villager spawn event! " + e.getEventName());
plugin.getLogger().info("Reason:" + e.getSpawnReason().toString());
plugin.getLogger().info("Entity:" + e.getEntityType().toString());
}
// Only cover overworld
if (!e.getEntity().getWorld().equals(ASkyBlock.getIslandWorld())) {
return;
}
// If there's no limit - leave it
if (Settings.villagerLimit <= 0) {
return;
}
// We only care about villagers breeding, being cured or coming from a spawn egg, etc.
if (e.getSpawnReason() != SpawnReason.SPAWNER && e.getSpawnReason() != SpawnReason.BREEDING
&& e.getSpawnReason() != SpawnReason.DISPENSE_EGG && e.getSpawnReason() != SpawnReason.SPAWNER_EGG
&& e.getSpawnReason() != SpawnReason.CURED) {
return;
}
Island island = plugin.getGrid().getProtectedIslandAt(e.getLocation());
if (island == null || island.getOwner() == null || island.isSpawn()) {
// No island, no limit
return;
}
int limit = Settings.villagerLimit * Math.max(1,plugin.getPlayers().getMembers(island.getOwner()).size());
//plugin.getLogger().info("DEBUG: villager limit = " + limit);
//long time = System.nanoTime();
int pop = island.getPopulation();
//plugin.getLogger().info("DEBUG: time = " + ((System.nanoTime() - time)*0.000000001));
if (pop >= limit) {
plugin.getLogger().warning(
"Island at " + island.getCenter().getBlockX() + "," + island.getCenter().getBlockZ() + " hit the island villager limit of "
+ limit);
//plugin.getLogger().info("Stopped villager spawning on island " + island.getCenter());
// Get all players in the area
List<Entity> players = e.getEntity().getNearbyEntities(10,10,10);
for (Entity player: players) {
if (player instanceof Player) {
Player p = (Player) player;
Util.sendMessage(p, ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit)));
}
}
plugin.getMessages().tellTeam(island.getOwner(), ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit)));
if (e.getSpawnReason().equals(SpawnReason.CURED)) {
// Easter Egg. Or should I say Easter Apple?
ItemStack goldenApple = new ItemStack(Material.GOLDEN_APPLE);
// Nerfed
//goldenApple.setDurability((short)1);
e.getLocation().getWorld().dropItemNaturally(e.getLocation(), goldenApple);
}
e.setCancelled(true);
}
}