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


Java World.setDifficulty方法代码示例

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


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

示例1: createWorld

import org.bukkit.World; //导入方法依赖的package包/类
@Override
public World createWorld(String worldName) throws ModuleLoadException, IOException {
    if(server.getWorlds().isEmpty()) {
        throw new IllegalStateException("Can't create a world because there is no default world to derive it from");
    }

    try {
        importDestructive(terrainOptions.worldFolder().toFile(), worldName);
    } catch(FileNotFoundException e) {
        // If files are missing, just inform the mapmaker.
        // Other IOExceptions are considered internal errors.
        throw new ModuleLoadException(e.getMessage()); // Don't set the cause, it's redundant
    }

    final WorldCreator creator = worldCreator(worldName);
    worldConfigurators.forEach(wc -> wc.configureWorld(creator));

    final World world = server.createWorld(creator);
    if(world == null) {
        throw new IllegalStateException("Failed to create world (Server.createWorld returned null)");
    }

    world.setAutoSave(false);
    world.setKeepSpawnInMemory(false);
    world.setDifficulty(Optional.ofNullable(mapInfo.difficulty)
                                .orElseGet(() -> server.getWorlds().get(0).getDifficulty()));

    return world;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:30,代码来源:WorldManagerImpl.java

示例2: loadMap

import org.bukkit.World; //导入方法依赖的package包/类
public boolean loadMap(int gNumber) {
	WorldController wc = SkyWarsReloaded.getWC();
	String mapName = name + "_" + gNumber;
	boolean mapExists = false;
	File target = new File(rootDirectory, mapName);
	if(target.isDirectory()) {			 
		if(target.list().length > 0) {
 			mapExists = true;
		}	 
	}
	if (mapExists) {
		SkyWarsReloaded.getWC().deleteWorld(mapName);
	}
	
	wc.copyWorld(source, target);
	
	boolean loaded = SkyWarsReloaded.getWC().loadWorld(mapName);
	if (loaded) {
		World world = SkyWarsReloaded.get().getServer().getWorld(mapName);
	    world.setAutoSave(false);
	    world.setThundering(false);
	    world.setStorm(false);
	    world.setDifficulty(Difficulty.NORMAL);
	    world.setSpawnLocation(2000, 0, 2000);
	    world.setTicksPerAnimalSpawns(1);
	    world.setTicksPerMonsterSpawns(1);
        world.setGameRuleValue("doMobSpawning", "false");
        world.setGameRuleValue("mobGriefing", "false");
        world.setGameRuleValue("doFireTick", "false");
        world.setGameRuleValue("showDeathMessages", "false");
	}
	return loaded;
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:34,代码来源:GameMap.java

示例3: prepareWorld

import org.bukkit.World; //导入方法依赖的package包/类
public void prepareWorld(World w) {
    w.setPVP(true);
    w.setGameRuleValue("doDaylightCycle", "false");
    w.setStorm(false);
    w.setDifficulty(Difficulty.PEACEFUL);
    w.setTime(14000);
    w.getLivingEntities().stream().filter(e -> !e.getType().equals(EntityType.PLAYER)).forEach(Entity::remove);
    initArena();
    w.setAutoSave(false);
}
 
开发者ID:cadox8,项目名称:PA,代码行数:11,代码来源:ArenaManager.java


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