Пример #1
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());
     }
   }
 }
Пример #2
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();
       }
     }
   }
 }