/*
  * Read and write functions used internally
  */
 public void writeTo(DataOutputStream stream) throws IOException {
   stream.writeInt(members.length);
   for (OfflineMember member : members) {
     member.writeTo(stream);
   }
   stream.writeUTF(this.name);
 }
 public boolean isMoving() {
   for (OfflineMember member : members) {
     if (member.isMoving()) {
       return true;
     }
   }
   return false;
 }
 public OfflineGroup(MinecartGroup group) {
   this(group.size());
   for (int i = 0; i < members.length; i++) {
     this.members[i] = new OfflineMember(this, group.get(i));
   }
   this.name = group.getProperties().getTrainName();
   this.worldUUID = group.getWorld().getUID();
   if (group.getActions().getCurrentAction() instanceof MemberActionLaunch) {
     double vel = ((MemberActionLaunch) group.getActions().getCurrentAction()).getTargetVelocity();
     for (OfflineMember member : this.members) {
       member.setVelocity(vel);
     }
   }
   this.genChunks();
 }
 public static OfflineGroup readFrom(DataInputStream stream) throws IOException {
   OfflineGroup wg = new OfflineGroup(stream.readInt());
   for (int i = 0; i < wg.members.length; i++) {
     wg.members[i] = OfflineMember.readFrom(stream);
   }
   wg.name = stream.readUTF();
   wg.genChunks();
   return wg;
 }
 /**
  * Tries to find all Minecarts based on their UID and creates a new group
  *
  * @param world to find the Minecarts in
  * @return An array of Minecarts
  */
 public MinecartGroup create(World world) {
   ArrayList<MinecartMember<?>> rval = new ArrayList<>(this.members.length);
   int missingNo = 0;
   for (OfflineMember member : this.members) {
     MinecartMember<?> mm = member.create(world);
     if (mm != null) {
       rval.add(mm);
     } else {
       missingNo++;
     }
   }
   if (missingNo > 0) {
     TrainCarts.plugin.log(
         Level.WARNING,
         missingNo + " carts of group '" + this.name + "' are missing! (externally edited?)");
   }
   if (rval.isEmpty()) {
     TrainPropertiesStore.remove(this.name);
     return null;
   }
   // Is a new group needed?
   return MinecartGroup.create(this.name, rval.toArray(new MinecartMember[0]));
 }