Exemple #1
0
 public WorldConfig(String worldname) {
   this.worldname = worldname;
   if (worldname == null) {
     return;
   }
   worldname = worldname.toLowerCase();
   worldConfigs.put(worldname, this);
   World world = this.getWorld();
   if (world != null) {
     // Read from the loaded world directly
     this.keepSpawnInMemory = world.getKeepSpawnInMemory();
     this.worldmode = WorldMode.get(world);
     this.difficulty = world.getDifficulty();
     this.spawnPoint = new Position(world.getSpawnLocation());
     this.pvp = world.getPVP();
     this.autosave = world.isAutoSave();
     this.getChunkGeneratorName();
   } else {
     this.worldmode = WorldMode.get(worldname);
     this.spawnPoint = new Position(worldname, 0, 128, 0);
     if (WorldManager.worldExists(this.worldname)) {
       // Open up the level.dat of the World and read the settings from it
       CommonTagCompound data = WorldManager.getData(this.worldname);
       if (data != null) {
         // Read the settings from it
         this.spawnPoint.setX(data.getValue("SpawnX", this.spawnPoint.getBlockX()));
         this.spawnPoint.setY(data.getValue("SpawnY", this.spawnPoint.getBlockY()));
         this.spawnPoint.setZ(data.getValue("SpawnZ", this.spawnPoint.getBlockZ()));
       }
       // Figure out the world mode by inspecting the region files in the world
       // On failure, it will resort to using the world name to figure it out
       File regions = Common.SERVER.getWorldRegionFolder(this.worldname);
       if (regions != null && regions.isDirectory()) {
         // Skip the 'region' folder found in the dimension folder
         regions = regions.getParentFile();
         // Find out what name the current folder is
         // If this is DIM1 or DIM-1 then it is the_end/nether
         // Otherwise we will resort to using the world name
         String dimName = regions.getName();
         if (dimName.equals("DIM1")) {
           this.worldmode = WorldMode.THE_END;
         } else if (dimName.equals("DIM-1")) {
           this.worldmode = WorldMode.NETHER;
         }
       }
     }
   }
   if (MyWorlds.useWorldOperators) {
     for (OfflinePlayer op : Bukkit.getServer().getOperators()) {
       this.OPlist.add(op.getName());
     }
   }
   this.inventory = new WorldInventory(this.worldname).add(worldname);
 }
Exemple #2
0
 public void load(ConfigurationNode node) {
   this.keepSpawnInMemory = node.get("keepSpawnLoaded", this.keepSpawnInMemory);
   this.worldmode = WorldMode.get(node.get("environment", this.worldmode.getName()));
   this.chunkGeneratorName = node.get("chunkGenerator", String.class, this.chunkGeneratorName);
   if (LogicUtil.nullOrEmpty(this.chunkGeneratorName)) {
     this.chunkGeneratorName = null;
   }
   this.difficulty = node.get("difficulty", Difficulty.class, this.difficulty);
   this.gameMode = node.get("gamemode", GameMode.class, this.gameMode);
   this.clearInventory = node.get("clearInventory", this.clearInventory);
   String worldspawn = node.get("spawn.world", String.class);
   if (worldspawn != null) {
     double x = node.get("spawn.x", 0.0);
     double y = node.get("spawn.y", 64.0);
     double z = node.get("spawn.z", 0.0);
     double yaw = node.get("spawn.yaw", 0.0);
     double pitch = node.get("spawn.pitch", 0.0);
     this.spawnPoint = new Position(worldspawn, x, y, z, (float) yaw, (float) pitch);
   }
   this.holdWeather = node.get("holdWeather", this.holdWeather);
   this.formIce = node.get("formIce", this.formIce);
   this.formSnow = node.get("formSnow", this.formSnow);
   this.showRain = node.get("showRain", this.showRain);
   this.showSnow = node.get("showSnow", this.showSnow);
   this.pvp = node.get("pvp", this.pvp);
   this.forcedRespawn = node.get("forcedRespawn", this.forcedRespawn);
   this.allowHunger = node.get("hunger", this.allowHunger);
   this.rememberLastPlayerPosition =
       node.get("rememberlastplayerpos", this.rememberLastPlayerPosition);
   this.reloadWhenEmpty = node.get("reloadWhenEmpty", this.reloadWhenEmpty);
   for (String type : node.getList("deniedCreatures", String.class)) {
     type = type.toUpperCase();
     if (type.equals("ANIMALS")) {
       this.spawnControl.setAnimals(true);
     } else if (type.equals("MONSTERS")) {
       this.spawnControl.setMonsters(true);
     } else {
       EntityType t = ParseUtil.parseEnum(EntityType.class, type, null);
       if (t != null) {
         this.spawnControl.deniedCreatures.add(t);
       }
     }
   }
   long time = node.get("lockedtime", Integer.MIN_VALUE);
   if (time != Integer.MIN_VALUE) {
     this.timeControl.setTime(time);
     this.timeControl.setLocking(true);
   }
   this.defaultNetherPortal =
       node.get("defaultNetherPortal", String.class, this.defaultNetherPortal);
   this.defaultEnderPortal = node.get("defaultEndPortal", String.class, this.defaultEnderPortal);
   if (node.contains("defaultPortal")) {
     // Compatibility mode
     this.defaultNetherPortal = node.get("defaultPortal", String.class, this.defaultNetherPortal);
     node.set("defaultPortal", null);
   }
   this.OPlist = node.getList("operators", String.class, this.OPlist);
 }