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


Java SpawnReason.NATURAL属性代码示例

本文整理汇总了Java中org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL属性的典型用法代码示例。如果您正苦于以下问题:Java SpawnReason.NATURAL属性的具体用法?Java SpawnReason.NATURAL怎么用?Java SpawnReason.NATURAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason的用法示例。


在下文中一共展示了SpawnReason.NATURAL属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreatureSpawn

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() != SpawnReason.NATURAL) { //TODO: Should check for Custom instead of checking against natural?
        return;
    }

    EntityType type = event.getEntityType();
    World world = event.getLocation().getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_SPAWNING) && worldConfig.getStringList(Config.FEATURE_MORE_SPAWNING_MOBS).contains(type.getName().toUpperCase())) {
        for (int i = 0; i < Math.max(worldConfig.getInt(Config.FEATURE_MORE_SPAWNING_MULTIPLIER), 1); ++i) {
            for (BloodMoonEntityType bloodMoonEntity : BloodMoonEntityType.values()) {
                if (type == bloodMoonEntity.getEntityType()) {
                    bloodMoonEntity.spawnEntity(event.getLocation().add((random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5));
                    return;
                }
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:21,代码来源:MoreSpawningListener.java

示例2: onCreatureSpawn

@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event)
{
    Entity entity = event.getEntity();

    Location location = event.getLocation();
    Point pos = new Point(location.getBlockX(), location.getBlockZ());

    ZoneWorld world = plugin.getWorld(entity.getWorld());
    Zone zone = world.findZone(pos);

    if (zone == null || zone.hasHostiles()) {
        return;
    }

    if (!allowedMobs.contains(event.getEntityType()) &&
        event.getSpawnReason() == SpawnReason.NATURAL) {

        event.setCancelled(true);
    }
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:21,代码来源:ZoneEntityListener.java

示例3: onCreatureSpawn

@EventHandler(priority = EventPriority.MONITOR)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if(this.module.getConfig().getBoolean("mob-money.enabled", true) && event.getSpawnReason() == SpawnReason.NATURAL) {
        event.getEntity().setMetadata("natural", new MetadataValueAdapter(Bukkit.getServer().getPluginManager().getPlugin(this.module.getManager().getImplementationName())) {
            @Override
            public void invalidate() {
            }

            @Override
            public Object value() {
                return true;
            }
        });
    }
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:15,代码来源:EconomyListener.java

示例4: onSpawn

@EventHandler(priority = EventPriority.HIGH)
public void onSpawn(CreatureSpawnEvent event) {
	for (int i = 0; i < SGApi.getMultiWorldManager().getWorlds().size(); i++) {
		if (SGApi.getMultiWorldManager().getWorlds().get(i).getWorld() == event.getLocation().getWorld()) {
			if (event.getSpawnReason() == SpawnReason.NATURAL)
				event.setCancelled(true);
		}
	}
}
 
开发者ID:SurvivalGamesDevTeam,项目名称:TheSurvivalGames,代码行数:9,代码来源:MobSpawnListener.java

示例5: onNaturalSpawn

@EventHandler(priority= EventPriority.HIGHEST, ignoreCancelled = true)
private void onNaturalSpawn(CreatureSpawnEvent event) {

    if (event.getSpawnReason() != SpawnReason.NATURAL)
        return;

    IArena arena = PVStarAPI.getArenaManager().getArena(event.getLocation());
    if (arena == null)
        return;

    if (!arena.getSettings().isMobSpawnEnabled())
        event.setCancelled(true);
}
 
开发者ID:JCThePants,项目名称:PV-Star,代码行数:13,代码来源:MobEventListener.java

示例6: onCreatureSpawn

/**
 * Handles mob spawning.<br>
 * Checks if an arena allows mob spawning before letting a mob spawn inside it.
 * @param event The {@link org.bukkit.event.entity.CreatureSpawnEvent} event.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() == SpawnReason.NATURAL) {
        Arena arena = ultimateGames.getArenaManager().getLocationArena(event.getLocation());
        if (arena != null && !arena.allowMobSpawning()) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:UltimateGames,项目名称:UltimateGames,代码行数:14,代码来源:ArenaListener.java

示例7: onEntitySpawn

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event) {
    //do nothing for non-natural spawns
    if (event.getSpawnReason() != SpawnReason.NATURAL)
        return;

    if (ConfigData.managedWorld == null || event.getLocation().getWorld() != ConfigData.managedWorld)
        return;

    //when an animal naturally spawns, grow grass around it
    Entity entity = event.getEntity();
    if (entity instanceof Animals && ConfigData.regrowGrass)
        this.regrow(entity.getLocation().getBlock(), 4);

    //when a monster spawns, sometimes spawn animals too
    if (entity instanceof Monster && ConfigData.respawnAnimals) {
        //only do this if the spawn is in the newest region
        if (!Region.getOpenRegion().equals(Region.fromLocation(entity.getLocation())))
            return;

        //if it's on grass, there's a 1/100 chance it will also spawn a group of animals
        Block underBlock = event.getLocation().getBlock().getRelative(BlockFace.DOWN);
        if (underBlock.getType() == Material.GRASS && --this.respawnAnimalCounter == 0) {
            this.respawnAnimalCounter = 100;

            //check the chunk for other animals
            Chunk chunk = entity.getLocation().getChunk();
            Entity[] entities = chunk.getEntities();
            for (int i = 0; i < entities.length; i++) {
                if (entity instanceof Animals)
                    return;
            }

            EntityType animalType = null;

            //decide what to spawn based on the type of monster
            if (entity instanceof Creeper)
                animalType = EntityType.COW;
            else if (entity instanceof Zombie)
                animalType = EntityType.CHICKEN;
            else if (entity instanceof Spider)
                animalType = EntityType.PIG;
            else if (entity instanceof Enderman)
                animalType = EntityType.SHEEP;

            //spawn an animal at the entity's location and regrow some grass
            if (animalType != null) {
                entity.getWorld().spawnEntity(entity.getLocation(), animalType);
                entity.getWorld().spawnEntity(entity.getLocation(), animalType);
                this.regrow(entity.getLocation().getBlock(), 4);
            }
        }
    }
}
 
开发者ID:RoyalDev,项目名称:PopulationDensity,代码行数:54,代码来源:EntityEventHandler.java


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