本文整理汇总了Java中org.bukkit.WorldCreator.name方法的典型用法代码示例。如果您正苦于以下问题:Java WorldCreator.name方法的具体用法?Java WorldCreator.name怎么用?Java WorldCreator.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.WorldCreator
的用法示例。
在下文中一共展示了WorldCreator.name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createWorld
import org.bukkit.WorldCreator; //导入方法依赖的package包/类
@Override
public World createWorld(WorldCreator creator) {
World alreadyLoaded = this.getWorld(creator.name());
if (alreadyLoaded != null) {
return alreadyLoaded;
}
if (nukkit.isLevelGenerated(creator.name())) {
nukkit.loadLevel(creator.name());
World alreadyGenerated = this.getWorld(creator.name());
return alreadyGenerated;
}
if (creator.environment() != Environment.NORMAL) {
throw new IllegalArgumentException("No Nether or End support yet");
}
if (creator.generator() != null) {
throw new IllegalArgumentException("Custom generators are not yet supported");
}
Map<String, Object> options = new HashMap<>();
options.put("preset", creator.generatorSettings());
if (!nukkit.generateLevel(creator.name(), creator.seed(), PokkitWorldType.toNukkit(creator.type()), options)) {
throw new RuntimeException("Failed to create world " + creator.name());
}
World world = this.getWorld(creator.name());
Pokkit.assertion(world != null, "World was still null");
return world;
}
示例2: createWorld
import org.bukkit.WorldCreator; //导入方法依赖的package包/类
@Override
public World createWorld(WorldCreator creator) {
Validate.notNull(creator, "Creator may not be null");
String name = creator.name();
ChunkGenerator generator = creator.generator();
File folder = new File(getWorldContainer(), name);
World world = getWorld(name);
net.minecraft.world.WorldType type = net.minecraft.world.WorldType.parseWorldType(creator.type().getName());
boolean generateStructures = creator.generateStructures();
if ((folder.exists()) && (!folder.isDirectory())) {
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
}
if (world != null) {
return world;
}
boolean hardcore = false;
WorldSettings worldSettings = new WorldSettings(creator.seed(), net.minecraft.world.WorldSettings.GameType.getByID(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
net.minecraft.world.WorldServer worldserver = DimensionManager.initDimension(creator, worldSettings);
pluginManager.callEvent(new WorldInitEvent(worldserver.getWorld()));
net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = true;
System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Dimension: " + worldserver.provider.dimensionId + ", Seed: " + worldserver.getSeed() + ")"); // Cauldron - log dimension
if (worldserver.getWorld().getKeepSpawnInMemory()) {
short short1 = 196;
long i = System.currentTimeMillis();
for (int j = -short1; j <= short1; j += 16) {
for (int k = -short1; k <= short1; k += 16) {
long l = System.currentTimeMillis();
if (l < i) {
i = l;
}
if (l > i + 1000L) {
int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;
System.out.println("Preparing spawn area for " + worldserver.getWorld().getName() + ", " + (j1 * 100 / i1) + "%");
i = l;
}
net.minecraft.util.ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + j >> 4, chunkcoordinates.posZ + k >> 4);
}
}
}
pluginManager.callEvent(new WorldLoadEvent(worldserver.getWorld()));
net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = false;
return worldserver.getWorld();
}
示例3: initDimension
import org.bukkit.WorldCreator; //导入方法依赖的package包/类
public static WorldServer initDimension(WorldCreator creator, WorldSettings worldSettings) {
WorldServer overworld = getWorld(0);
if (overworld == null) {
throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!");
}
MinecraftServer mcServer = overworld.func_73046_m();
String worldType;
String name;
int providerId = 0;
if (creator.environment() != null)
providerId = creator.environment().getId();
try {
providerId = getProviderType(providerId);
}
catch (IllegalArgumentException e)
{
// do nothing
}
Environment env = creator.environment();
worldType = env.name().toLowerCase();
name = creator.name();
int dim = 0;
// Use saved dimension from level.dat if it exists. This guarantees that after a world is created, the same dimension will be used. Fixes issues with MultiVerse
AnvilSaveHandler saveHandler = new AnvilSaveHandler(mcServer.server.getWorldContainer(), name, true);
if (saveHandler.loadWorldInfo() != null)
{
int savedDim = saveHandler.loadWorldInfo().getDimension();
if (savedDim != 0 && savedDim != -1 && savedDim != 1)
{
dim = savedDim;
}
}
if (dim == 0)
{
dim = getNextFreeDimId();
}
if (!isDimensionRegistered(dim)) // handle reloads properly
{
registerDimension(dim, providerId);
addBukkitDimension(dim);
}
ChunkGenerator gen = creator.generator();
if (mcServer instanceof DedicatedServer) {
worldSettings.func_82750_a(((DedicatedServer) mcServer).getStringProperty("generator-settings", ""));
}
WorldServer world = new WorldServerMulti(mcServer, saveHandler, name, dim, worldSettings, overworld, mcServer.theProfiler, env, gen);
if (gen != null)
{
world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld()));
}
world.provider.dimensionId = dim; // Fix for TerrainControl injecting their own WorldProvider
mcServer.getConfigurationManager().setPlayerManager(mcServer.worlds.toArray(new WorldServer[mcServer.worlds.size()]));
world.addWorldAccess(new WorldManager(mcServer, world));
MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
if (!mcServer.isSinglePlayer())
{
world.getWorldInfo().setGameType(mcServer.getGameType());
}
mcServer.func_147139_a(mcServer.func_147135_j());
return world;
}