@Override public MinecartGroup getHolder() { MinecartGroup group = this.group.get(); if (group == null || group.isRemoved()) { return this.group.set(MinecartGroup.get(this)); } else { return group; } }
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(); }
/** * 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])); }
public void tryUpdate() { MinecartGroup g = this.getHolder(); if (g != null) g.onPropertiesChanged(); }