本文整理汇总了Java中org.bukkit.Bukkit.createWorld方法的典型用法代码示例。如果您正苦于以下问题:Java Bukkit.createWorld方法的具体用法?Java Bukkit.createWorld怎么用?Java Bukkit.createWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Bukkit
的用法示例。
在下文中一共展示了Bukkit.createWorld方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEnable
import org.bukkit.Bukkit; //导入方法依赖的package包/类
@Override
public void onEnable() {
world = Bukkit.createWorld(new WorldCreator(OpenUHC.WORLD_DIR_PREFIX + "lobby"));
// Read lobby yml if it exists
File lobbyFile = new File(OpenUHC.WORLD_DIR_PREFIX + "lobby/lobby.yml");
if (lobbyFile.exists()) {
FileConfiguration lobbyConfig = YamlConfiguration.loadConfiguration(lobbyFile);
ConfigurationSection spawn = lobbyConfig.getConfigurationSection("spawn");
if (spawn != null) {
double x = spawn.getDouble("x", 0);
double y = spawn.getDouble("y", 64);
double z = spawn.getDouble("z", 0);
double r = spawn.getDouble("r", 1);
this.spawn = new Vector(x, y, z);
radius = (float) r;
}
}
OpenUHC.registerEvents(this);
}
示例2: onCommand
import org.bukkit.Bukkit; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player) sender;
if (args.length != 1) {
Chat.player(sender, "&4[SG] &cPlease include the world name");
return true;
}
String name = args[0];
World w = Bukkit.getWorld(name);
if (w == null)
Bukkit.createWorld(new WorldCreator(name));
w = Bukkit.getWorld(name);
p.teleport(w.getSpawnLocation());
Chat.player(sender, "&2[SG] &aTeleported to " + w.getName() + " spawn point");
return true;
}
示例3: generate
import org.bukkit.Bukkit; //导入方法依赖的package包/类
/**
* Generates the chunks in the game world with a given radius.
*/
public void generate() throws BusyGameStateException, InvalidGameStateException {
if (busy) {
throw new BusyGameStateException();
} else if (state != GameState.NEW) {
throw new InvalidGameStateException(state, GameState.NEW);
}
busy = true;
world = Bukkit.createWorld(new WorldCreator(
OpenUHC.WORLD_DIR_PREFIX + String.valueOf(System.currentTimeMillis())));
world.setGameRuleValue("naturalRegeneration", "false");
final int chunkRadius = (worldRadius / 16) + 4;
chunkX = -1 * chunkRadius;
chunkY = -1 * chunkRadius;
final CompletableFuture<BukkitTask> task = new CompletableFuture<>();
task.complete(Bukkit.getScheduler().runTaskTimer(OpenUHC.getInstance(), () -> {
for (int i = 0; i < 25; ++i) {
world.loadChunk(chunkX, chunkY);
if (chunkX == chunkRadius && chunkY == chunkRadius) {
try {
// Task completed!
busy = false;
state = GameState.GENERATED;
OpenUHC.getPluginLogger().info("World generation compete!");
task.get().cancel();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
} else if (chunkX == chunkRadius) {
chunkX = -1 * chunkRadius;
++chunkY;
OpenUHC.getPluginLogger().info(chunkY + chunkRadius + "/" + chunkRadius * 2);
} else {
++chunkX;
}
}
}, 0, 1));
}