当前位置: 首页>>代码示例>>Java>>正文


Java SpawnReason.SPAWNER属性代码示例

本文整理汇总了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);
  }
 }
}
 
开发者ID:AnonymousDr,项目名称:ADR,代码行数:21,代码来源:mobs.java

示例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);
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:18,代码来源:FlagDef_NoMonsterSpawns.java

示例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);
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:20,代码来源:FlagDef_NoMobSpawns.java

示例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));
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:12,代码来源:MoreExpListener.java

示例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));
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:14,代码来源:MoreDropsListener.java

示例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);
                }
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:15,代码来源:ZombieArmorListener.java

示例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);
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:15,代码来源:ZombieArmorListener.java

示例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);
                }
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:15,代码来源:ZombieWeaponListener.java

示例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);
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:15,代码来源:ZombieWeaponListener.java

示例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));
}
 
开发者ID:sabersamus,项目名称:Bytecraft,代码行数:15,代码来源:RareDropListener.java

示例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));
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:11,代码来源:RareDropListener.java

示例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());
	}
}
 
开发者ID:vxnick,项目名称:mobrewards,代码行数:11,代码来源:MobRewards.java

示例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;
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:47,代码来源:MobLimtier.java

示例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));
}
 
开发者ID:Explodncheez,项目名称:MysteryBags,代码行数:5,代码来源:MysteryBagsListener.java

示例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);
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:59,代码来源:EntityLimits.java


注:本文中的org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。