public void execute() { this.removeArg(0); this.genWorldname(0); if (this.handleWorld()) { WorldConfig wc = WorldConfig.get(worldname); wc.pvp = !wc.pvp; wc.updatePVP(wc.getWorld()); if (wc.pvp) { message(ChatColor.GREEN + "PvP on World: '" + worldname + "' enabled!"); } else { message(ChatColor.YELLOW + "PvP on World: '" + worldname + "' disabled!"); } if (!WorldManager.isLoaded(worldname)) { message(ChatColor.YELLOW + "Please note that this world is not loaded!"); } } }
public void execute() { boolean lock = false; boolean useWorld = false; long time = -1; for (String command : args) { // Time reading if (command.equalsIgnoreCase("lock")) { lock = true; } else if (command.equalsIgnoreCase("locked")) { lock = true; } else if (command.equalsIgnoreCase("always")) { lock = true; } else if (command.equalsIgnoreCase("endless")) { lock = true; } else if (command.equalsIgnoreCase("l")) { lock = true; } else if (command.equalsIgnoreCase("-l")) { lock = true; } else if (command.equalsIgnoreCase("stop")) { lock = true; } else if (command.equalsIgnoreCase("freeze")) { lock = true; } else { long newtime = TimeUtil.getTime(command); if (newtime != -1) { time = newtime; } else { // Used the last argument as command? if (command == args[args.length - 1]) useWorld = true; } } } worldname = WorldManager.getWorldName(sender, args, useWorld); if (this.handleWorld()) { WorldConfig wc = WorldConfig.get(worldname); if (time == -1) { World w = WorldManager.getWorld(worldname); if (w == null) { WorldInfo i = wc.getInfo(); if (i == null) { time = 0; } else { time = i.time; } } else { time = w.getFullTime(); } } if (args.length == 0) { message( ChatColor.YELLOW + "The current time of world '" + worldname + "' is " + TimeUtil.getTimeString(time)); } else { TimeControl tc = wc.timeControl; boolean wasLocked = tc.isLocked(); tc.setLocking(lock); tc.setTime(time); if (lock) { if (wc.isLoaded()) { message( ChatColor.GREEN + "Time of world '" + worldname + "' locked to " + TimeUtil.getTimeString(time) + "!"); } else { Localization.WORLD_NOTLOADED.message(sender, worldname); message( ChatColor.YELLOW + "Time will be locked to " + TimeUtil.getTimeString(time) + " as soon it is loaded!"); } } else { World w = wc.getWorld(); if (w != null) { if (wasLocked) { message( ChatColor.GREEN + "Time of world '" + worldname + "' unlocked and set to " + TimeUtil.getTimeString(time) + "!"); } else { message( ChatColor.GREEN + "Time of world '" + worldname + "' set to " + TimeUtil.getTimeString(time) + "!"); } } else { Localization.WORLD_NOTLOADED.message(sender, worldname); message(ChatColor.YELLOW + "Time has not been changed!"); } } } } }
public static World createWorld(String worldname, long seed) { String gen = getGeneratorPlugin(worldname); if (gen == null) { MyWorlds.log(Level.INFO, "Loading or creating world: '" + worldname + "' using seed " + seed); } else { MyWorlds.log( Level.INFO, "Loading or creating world: '" + worldname + "' using seed " + seed + " and chunk generator: '" + gen + "'"); } final int retrycount = 3; World w = null; int i = 0; ChunkGenerator cgen = null; try { if (gen != null) { cgen = getGenerator(worldname, gen); } } catch (Exception ex) { } if (gen != null && cgen == null) { MyWorlds.log( Level.SEVERE, "World '" + worldname + "' could not be loaded because the chunk generator '" + gen + "' was not found!"); return null; } WorldConfig wc = WorldConfig.get(worldname); wc.chunkGeneratorName = gen; for (i = 0; i < retrycount + 1; i++) { try { WorldCreator c = new WorldCreator(worldname); c.environment(wc.environment); c.seed(seed); c.generator(cgen); w = c.createWorld(); } catch (Exception ex) { MyWorlds.log(Level.WARNING, "World load issue: " + ex.getMessage()); } if (w != null) break; } if (w != null) { wc.updatePVP(w); // Data file is made? if (!worldExists(worldname)) { w.save(); } } if (w == null) { MyWorlds.log(Level.WARNING, "Operation failed after " + i + " retries!"); } else if (i == 1) { MyWorlds.log(Level.INFO, "Operation succeeded after 1 retry!"); } else if (i > 0) { MyWorlds.log(Level.INFO, "Operation succeeded after " + i + " retries!"); } return w; }
public static void setGenerator(String worldname, String name) { WorldConfig.get(worldname).chunkGeneratorName = name; }
public static String getGeneratorPlugin(String forWorld) { return WorldConfig.get(forWorld).chunkGeneratorName; }
public static Position getRespawn(String ofWorld) { return WorldConfig.get(ofWorld).spawnPoint; }
public static void setSpawn(String forWorld, Position destination) { WorldConfig.get(forWorld).spawnPoint = destination; }