/** * Tries to create a portal link with another world currently available. * * @see #tryCreatePortalLink(WorldConfig, WorldConfig) */ public void tryCreatePortalLink() { // Try to detect a possible portal link between worlds for (WorldConfig otherConfig : WorldConfig.all()) { if (otherConfig != this) { WorldConfig.tryCreatePortalLink(this, otherConfig); } } }
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 static Position[] getSpawnPoints() { Collection<WorldConfig> all = WorldConfig.all(); Position[] pos = new Position[all.size()]; int i = 0; for (WorldConfig wc : all) { pos[i] = wc.spawnPoint; i++; } return pos; }
/** * Tries to create a default portal link if none is currently set between two worlds Only if the * worlds match names and no portal is set will this create a link. * * @param world1 * @param world1 */ public static void tryCreatePortalLink(WorldConfig world1, WorldConfig world2) { // Name compatibility check if (!world1.getRawWorldName().equals(world2.getRawWorldName())) { return; } // If same environment, directly stop it here if (world1.worldmode == world2.worldmode) { return; } // Default nether portal check and detection if (world1.defaultNetherPortal == null && world2.defaultEnderPortal == null) { // Try to create a link with the nether portals if ((world1.worldmode == WorldMode.NETHER && world2.worldmode == WorldMode.NORMAL) || (world2.worldmode == WorldMode.NETHER && world1.worldmode == WorldMode.NORMAL)) { // Nether link detected! world1.defaultNetherPortal = world2.worldname; world2.defaultNetherPortal = world1.worldname; MyWorlds.plugin.log( Level.INFO, "Created nether portal link between worlds '" + world1.worldname + "' and '" + world2.worldname + "'!"); } } // Default ender portal check and detection if (world1.defaultEnderPortal == null && world2.defaultEnderPortal == null) { // Try to create a link with the nether portals if ((world1.worldmode == WorldMode.THE_END && world2.worldmode == WorldMode.NORMAL) || (world2.worldmode == WorldMode.THE_END && world1.worldmode == WorldMode.NORMAL)) { // Nether link detected! world1.defaultEnderPortal = world2.worldname; world2.defaultEnderPortal = world1.worldname; MyWorlds.plugin.log( Level.INFO, "Created ender portal link between worlds '" + world1.worldname + "' and '" + world2.worldname + "'!"); } } }
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; }