本文整理匯總了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));
}