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


Java Bukkit.createWorld方法代码示例

本文整理汇总了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);
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:20,代码来源:LobbyModule.java

示例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;
  }
 
开发者ID:thekeenant,项目名称:mczone,代码行数:22,代码来源:WorldCmd.java

示例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));
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:44,代码来源:Game.java


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