예제 #1
0
 public void saveDefault(ConfigurationNode node) {
   save(node);
   // Remove nodes we rather not see
   node.remove("environment");
   node.remove("name");
   node.remove("chunkGenerator");
   node.remove("spawn");
   node.remove("loaded");
 }
예제 #2
0
 @Override
 public void save(ConfigurationNode node) {
   node.set("displayName", this.displayName.equals(this.trainname) ? null : this.displayName);
   node.set("soundEnabled", this.soundEnabled ? null : false);
   node.set("allowPlayerTake", this.allowPlayerTake ? null : false);
   node.set("requirePoweredMinecart", this.requirePoweredMinecart ? true : null);
   node.set("trainCollision", this.collision ? null : false);
   node.set("keepChunksLoaded", this.keepChunksLoaded ? true : null);
   node.set("speedLimit", this.speedLimit != 0.4 ? this.speedLimit : null);
   node.set("slowDown", this.slowDown ? null : false);
   node.set("allowManualMovement", allowManualMovement ? true : null);
   if (this.mobCollision != CollisionMode.DEFAULT) {
     node.set("collision.mobs", this.mobCollision);
   }
   if (this.playerCollision != CollisionMode.DEFAULT) {
     node.set("collision.players", this.playerCollision);
   }
   if (this.miscCollision != CollisionMode.DEFAULT) {
     node.set("collision.misc", this.miscCollision);
   }
   if (this.trainCollision != CollisionMode.LINK) {
     node.set("collision.train", this.trainCollision);
   }
   if (!this.isEmpty()) {
     ConfigurationNode carts = node.getNode("carts");
     for (CartProperties prop : this) {
       ConfigurationNode cart = carts.getNode(prop.getUUID().toString());
       prop.save(cart);
       if (cart.getKeys().isEmpty()) carts.remove(cart.getName());
     }
   }
 }
예제 #3
0
 @Override
 public void saveAsDefault(ConfigurationNode node) {
   node.set("soundEnabled", this.soundEnabled);
   node.set("displayName", this.displayName);
   node.set("allowPlayerTake", this.allowPlayerTake);
   node.set("requirePoweredMinecart", this.requirePoweredMinecart);
   node.set("trainCollision", this.collision);
   node.set("keepChunksLoaded", this.keepChunksLoaded);
   node.set("speedLimit", this.speedLimit);
   node.set("slowDown", this.slowDown);
   node.set("allowManualMovement", this.allowManualMovement);
   node.set("collision.mobs", this.mobCollision);
   node.set("collision.players", this.playerCollision);
   node.set("collision.misc", this.miscCollision);
   node.set("collision.train", this.trainCollision);
   for (CartProperties prop : this) {
     prop.saveAsDefault(node);
     break;
   }
 }
예제 #4
0
 @Override
 public void load(ConfigurationNode node) {
   this.setDisplayName(node.get("displayName", this.displayName));
   this.allowPlayerTake = node.get("allowPlayerTake", this.allowPlayerTake);
   this.collision = node.get("trainCollision", this.collision);
   this.soundEnabled = node.get("soundEnabled", this.soundEnabled);
   this.slowDown = node.get("slowDown", this.slowDown);
   if (node.contains("collision")) {
     this.mobCollision = node.get("collision.mobs", this.mobCollision);
     this.playerCollision = node.get("collision.players", this.playerCollision);
     this.miscCollision = node.get("collision.misc", this.miscCollision);
     this.trainCollision = node.get("collision.train", this.trainCollision);
   }
   this.speedLimit = MathUtil.clamp(node.get("speedLimit", this.speedLimit), 0, 20);
   this.requirePoweredMinecart = node.get("requirePoweredMinecart", this.requirePoweredMinecart);
   this.keepChunksLoaded = node.get("keepChunksLoaded", this.keepChunksLoaded);
   this.allowManualMovement = node.get("allowManualMovement", this.allowManualMovement);
   if (node.isNode("carts")) {
     for (ConfigurationNode cart : node.getNode("carts").getNodes()) {
       try {
         CartProperties prop = CartProperties.get(UUID.fromString(cart.getName()), this);
         this.add(prop);
         prop.load(cart);
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     }
   }
 }
예제 #5
0
  public void save(ConfigurationNode node) {
    // Set if the world can be directly accessed
    World w = this.getWorld();
    if (w != null) {
      this.difficulty = w.getDifficulty();
      this.keepSpawnInMemory = w.getKeepSpawnInMemory();
      this.autosave = w.isAutoSave();
    }
    if (this.worldname == null || this.worldname.equals(this.getConfigName())) {
      node.remove("name");
    } else {
      node.set("name", this.worldname);
    }
    node.set("loaded", w != null);
    node.set("keepSpawnLoaded", this.keepSpawnInMemory);
    node.set("environment", this.worldmode.getName());
    node.set("chunkGenerator", LogicUtil.fixNull(this.getChunkGeneratorName(), ""));
    node.set("clearInventory", this.clearInventory ? true : null);
    node.set("gamemode", this.gameMode == null ? "NONE" : this.gameMode.toString());

    if (this.timeControl.isLocked()) {
      node.set("lockedtime", this.timeControl.getTime());
    } else {
      node.remove("lockedtime");
    }

    ArrayList<String> creatures = new ArrayList<String>();
    for (EntityType type : this.spawnControl.deniedCreatures) {
      creatures.add(type.name());
    }
    node.set("forcedRespawn", this.forcedRespawn);
    node.set("rememberlastplayerpos", this.rememberLastPlayerPosition);
    node.set("pvp", this.pvp);
    node.set("defaultNetherPortal", this.defaultNetherPortal);
    node.set("defaultEndPortal", this.defaultEnderPortal);
    node.set("operators", this.OPlist);
    node.set("deniedCreatures", creatures);
    node.set("holdWeather", this.holdWeather);
    node.set("hunger", this.allowHunger);
    node.set("formIce", this.formIce);
    node.set("formSnow", this.formSnow);
    node.set("showRain", this.showRain);
    node.set("showSnow", this.showSnow);
    node.set("difficulty", this.difficulty == null ? "NONE" : this.difficulty.toString());
    node.set("reloadWhenEmpty", this.reloadWhenEmpty);
    if (this.spawnPoint == null) {
      node.remove("spawn");
    } else {
      node.set("spawn.world", this.spawnPoint.getWorldName());
      node.set("spawn.x", this.spawnPoint.getX());
      node.set("spawn.y", this.spawnPoint.getY());
      node.set("spawn.z", this.spawnPoint.getZ());
      node.set("spawn.yaw", (double) this.spawnPoint.getYaw());
      node.set("spawn.pitch", (double) this.spawnPoint.getPitch());
    }
  }
예제 #6
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);
 }