diff --git a/src/main/java/net/xevianlight/aphelion/client/AphelionDebugOverlay.java b/src/main/java/net/xevianlight/aphelion/client/AphelionDebugOverlay.java index 8530c51..d816e2e 100644 --- a/src/main/java/net/xevianlight/aphelion/client/AphelionDebugOverlay.java +++ b/src/main/java/net/xevianlight/aphelion/client/AphelionDebugOverlay.java @@ -54,6 +54,7 @@ public class AphelionDebugOverlay { // event.getLeft().add(" Sky: " + rendererSummary); event.getLeft().add(" Station: " + x + " " + z + " ID: " + SpacePartitionSavedData.pack(x,z)); event.getLeft().add(" Station Destination:" + PartitionClientState.lastData().getDestination()); + event.getLeft().add(" Station Owner:" + PartitionClientState.lastData().getOwner()); var server = mc.getSingleplayerServer(); ServerLevel singlePlayerLevel; if (server != null) { diff --git a/src/main/java/net/xevianlight/aphelion/commands/AphelionCommand.java b/src/main/java/net/xevianlight/aphelion/commands/AphelionCommand.java index d4bf5d1..6930bcf 100644 --- a/src/main/java/net/xevianlight/aphelion/commands/AphelionCommand.java +++ b/src/main/java/net/xevianlight/aphelion/commands/AphelionCommand.java @@ -1,5 +1,6 @@ package net.xevianlight.aphelion.commands; +import com.mojang.authlib.GameProfile; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.LongArgumentType; @@ -10,6 +11,7 @@ import net.minecraft.commands.arguments.*; import net.minecraft.commands.arguments.coordinates.BlockPosArgument; import net.minecraft.commands.arguments.coordinates.ColumnPosArgument; import net.minecraft.core.BlockPos; +import net.minecraft.core.UUIDUtil; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.*; @@ -22,6 +24,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.xevianlight.aphelion.Aphelion; import net.xevianlight.aphelion.core.saveddata.SpacePartitionSavedData; +import net.xevianlight.aphelion.core.saveddata.types.PartitionData; import net.xevianlight.aphelion.entites.vehicles.RocketEntity; import net.xevianlight.aphelion.planet.Planet; import net.xevianlight.aphelion.util.RocketStructure; @@ -29,7 +32,9 @@ import net.xevianlight.aphelion.util.SpacePartitionHelper; import net.xevianlight.aphelion.util.registries.ModRegistries; import org.jetbrains.annotations.NotNull; +import java.util.Collection; import java.util.EnumSet; +import java.util.UUID; public class AphelionCommand { @@ -246,20 +251,86 @@ public class AphelionCommand { ) ) .then(Commands.literal("destination") - .then(Commands.literal("set").then( - Commands.argument("pos", ColumnPosArgument.columnPos()) - .then(Commands.argument("id", ResourceLocationArgument.id()) - .executes(context -> { - int x = SpacePartitionHelper.get(ColumnPosArgument.getColumnPos(context, "pos").x()); - int z = SpacePartitionHelper.get(ColumnPosArgument.getColumnPos(context, "pos").z()); - ResourceLocation orbit = ResourceLocationArgument.getId(context, "id"); + .then(Commands.literal("set") + .then(Commands.argument("pos", ColumnPosArgument.columnPos()) + .then(Commands.argument("id", ResourceLocationArgument.id()) + .executes(context -> { + int px = SpacePartitionHelper.get(ColumnPosArgument.getColumnPos(context, "pos").x()); + int pz = SpacePartitionHelper.get(ColumnPosArgument.getColumnPos(context, "pos").z()); + ResourceLocation orbit = ResourceLocationArgument.getId(context, "id"); - ServerLevel level = context.getSource().getLevel(); - SpacePartitionSavedData.get(level).getData(x,z).setDestination(orbit); + ServerLevel level = context.getSource().getLevel(); + PartitionData data = SpacePartitionSavedData.get(level).getData(px, pz); + if (data == null) { + context.getSource().sendFailure(Component.translatable("command.aphelion.station.invalid")); + return 1; + } + data.setDestination(orbit); + return 1; + }) + ) + ) + ) + ) + .then(Commands.literal("owner") + .then(Commands.literal("get") + .then(Commands.argument("pos", ColumnPosArgument.columnPos()) + .executes(context -> { + int px = SpacePartitionHelper.get(ColumnPosArgument.getColumnPos(context, "pos").x()); + int pz = SpacePartitionHelper.get(ColumnPosArgument.getColumnPos(context, "pos").z()); + + ServerLevel level = context.getSource().getLevel(); + PartitionData data = SpacePartitionSavedData.get(level).getData(px, pz); + var cache = level.getServer().getProfileCache(); + if (data == null) { + context.getSource().sendFailure(Component.translatable("command.aphelion.station.invalid")); return 1; - }) - ) + } + if (cache == null) { + return 0; + } + UUID uuid = data.getOwner(); + if (uuid == null) { + context.getSource().sendSuccess(() -> Component.translatable("command.aphelion.station.owner.unset"), true); + return 1; + } + + String name = cache.get(uuid).map(GameProfile::getName).orElse(null); + context.getSource().sendSuccess(() -> Component.translatable("command.aphelion.station.owner.get", px, pz, name), true); + return 1; + }) + ) + ) + .then(Commands.literal("set") + .then(Commands.argument("pos", ColumnPosArgument.columnPos()) + .then(Commands.argument("player", GameProfileArgument.gameProfile()) + .executes(context -> { + int px = SpacePartitionHelper.get(ColumnPosArgument.getColumnPos(context, "pos").x()); + int pz = SpacePartitionHelper.get(ColumnPosArgument.getColumnPos(context, "pos").z()); + + ServerLevel level = context.getSource().getLevel(); + PartitionData data = SpacePartitionSavedData.get(level).getData(px, pz); + if (data == null) { + context.getSource().sendFailure(Component.translatable("command.aphelion.station.invalid")); + return 1; + } + Collection profiles = + GameProfileArgument.getGameProfiles(context, "player"); + + if (profiles.size() != 1) { + context.getSource().sendFailure(Component.translatable("command.aphelion.player.invalid")); + return 0; + } + + GameProfile profile = profiles.iterator().next(); + UUID uuid = profile.getId(); + + data.setOwner(uuid); + context.getSource().sendSuccess(() -> Component.translatable("command.aphelion.station.owner.set.success", px, pz, profile.getName()), true); + return 1; + }) + ) ) ) ) diff --git a/src/main/java/net/xevianlight/aphelion/core/saveddata/SpacePartitionSavedData.java b/src/main/java/net/xevianlight/aphelion/core/saveddata/SpacePartitionSavedData.java index b10a717..b0300dc 100644 --- a/src/main/java/net/xevianlight/aphelion/core/saveddata/SpacePartitionSavedData.java +++ b/src/main/java/net/xevianlight/aphelion/core/saveddata/SpacePartitionSavedData.java @@ -60,6 +60,18 @@ public class SpacePartitionSavedData extends SavedData { pd.setDistanceToDest(e.getDouble("DistanceToDest")); } + if (e.hasUUID("Owner")) { + pd.setOwner(e.getUUID("Owner")); + } + + if (e.contains("Generated", CompoundTag.TAG_BYTE)) { + pd.setGenerated(e.getBoolean("Generated")); + } + + if (e.contains("LandingPads", CompoundTag.TAG_LONG_ARRAY)) { + pd.setLandingPadContollersFromArray(e.getLongArray("LandingPads")); + } + data.map.put(key, pd); } @@ -93,6 +105,14 @@ public class SpacePartitionSavedData extends SavedData { e.putDouble("DistanceTraveled", pd.getDistanceTraveled()); e.putDouble("DistanceToDest", pd.getDistanceToDest()); + if (pd.getOwner() != null) { + e.putUUID("Owner", pd.getOwner()); + } + + e.putBoolean("Generated", pd.isGenerated()); + + e.putLongArray("LandingPads", pd.getLandingPadContollersAsArray()); + entries.add(e); }); @@ -137,6 +157,12 @@ public class SpacePartitionSavedData extends SavedData { } } + /** + * Gets the mutable PartitionData object stored at px, pz + * @param px + * @param pz + * @return + */ public @Nullable PartitionData getData(int px, int pz) { long key = pack(px, pz); PartitionData data = map.get(key); @@ -154,7 +180,7 @@ public class SpacePartitionSavedData extends SavedData { boolean changed = false; for (var entry : map.long2ObjectEntrySet()) { - if(!orbit.equals(entry.getValue())) { + if(!orbit.equals(entry.getValue().getOrbit())) { entry.getValue().setOrbit(orbit); changed = true; } diff --git a/src/main/java/net/xevianlight/aphelion/core/saveddata/types/PartitionData.java b/src/main/java/net/xevianlight/aphelion/core/saveddata/types/PartitionData.java index 25b2feb..ee3ea8b 100644 --- a/src/main/java/net/xevianlight/aphelion/core/saveddata/types/PartitionData.java +++ b/src/main/java/net/xevianlight/aphelion/core/saveddata/types/PartitionData.java @@ -1,20 +1,32 @@ package net.xevianlight.aphelion.core.saveddata.types; import io.netty.buffer.ByteBuf; +import net.minecraft.core.BlockPos; +import net.minecraft.core.UUIDUtil; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; +import net.xevianlight.aphelion.util.BigCodec; import org.jetbrains.annotations.Nullable; +import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.UUID; public class PartitionData { + public static final int MAX_PADS = 64; + private static final StreamCodec> BLOCKPOS_LIST_CODEC = BlockPos.STREAM_CODEC.apply(ByteBufCodecs.list(MAX_PADS)); + @Nullable private ResourceLocation orbit; @Nullable private ResourceLocation destination; private boolean traveling; private double distanceTraveled; private double distanceToDest; + private boolean generated; + private UUID owner; + private List landingPadControllers; public PartitionData(@Nullable ResourceLocation orbit) { this.orbit = orbit; @@ -22,6 +34,9 @@ public class PartitionData { this.traveling = false; this.distanceTraveled = 0; this.distanceToDest = 0; + this.generated = false; + this.owner = null; + this.landingPadControllers = List.of(); } public PartitionData(PartitionData other) { @@ -30,10 +45,13 @@ public class PartitionData { this.traveling = other.traveling; this.distanceTraveled = other.distanceTraveled; this.distanceToDest = other.distanceToDest; + this.generated = other.generated; + this.owner = other.owner; + this.landingPadControllers = other.landingPadControllers; } public static final StreamCodec STREAM_CODEC = - StreamCodec.composite( + BigCodec.composite( // orbit is nullable -> optional codec ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC), d -> Optional.ofNullable(d.getOrbit()), @@ -51,12 +69,24 @@ public class PartitionData { ByteBufCodecs.DOUBLE, PartitionData::getDistanceToDest, - (orbitOpt, destOpt, traveling, distTraveled, distToDest) -> { + ByteBufCodecs.optional(UUIDUtil.STREAM_CODEC), + d -> Optional.ofNullable(d.getOwner()), + + ByteBufCodecs.BOOL, + PartitionData::isGenerated, + + BLOCKPOS_LIST_CODEC, + PartitionData::getLandingPadControllers, + + (orbitOpt, destOpt, traveling, distTraveled, distToDest, ownerOpt, generated, controllers) -> { PartitionData data = new PartitionData(orbitOpt.orElse(null)); data.destination = destOpt.orElse(null); data.traveling = traveling; data.distanceTraveled = distTraveled; data.distanceToDest = distToDest; + data.owner = ownerOpt.orElse(null); + data.generated = generated; + data.landingPadControllers = controllers; return data; } ); @@ -65,7 +95,7 @@ public class PartitionData { return this.orbit; } - public void setOrbit(ResourceLocation orbit) { + public void setOrbit(@Nullable ResourceLocation orbit) { this.orbit = orbit; } @@ -105,6 +135,42 @@ public class PartitionData { distanceTraveled = Math.min( distanceTraveled + distance, distanceToDest); } + public boolean isGenerated() { + return generated; + } + + public void setGenerated(boolean generated) { + this.generated = generated; + } + + public @Nullable UUID getOwner() { + return owner; + } + + public void setOwner(@Nullable UUID owner) { + this.owner = owner; + } + + public List getLandingPadControllers() { + return landingPadControllers; + } + + public void setLandingPadControllers(List landingPadControllers) { + this.landingPadControllers = landingPadControllers; + } + + public boolean addLandingPadController(BlockPos pos) { + if (!landingPadControllers.contains(pos)) { + landingPadControllers.add(pos); + return true; + } + return false; + } + + public boolean removeLandingPadController(BlockPos pos) { + return landingPadControllers.remove(pos); + } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -116,6 +182,28 @@ public class PartitionData { && Objects.equals(this.destination, that.destination) && this.traveling == that.traveling && Double.compare(this.distanceTraveled, that.distanceTraveled) == 0 - && Double.compare(this.distanceToDest, that.distanceToDest) == 0; + && Double.compare(this.distanceToDest, that.distanceToDest) == 0 + && this.generated == that.generated + && Objects.equals(this.owner, that.owner); + } + + public long[] getLandingPadContollersAsArray() { + long[] out = new long[landingPadControllers.size()]; + int i = 0; + for (BlockPos pos : landingPadControllers) { + out[i] = pos.asLong(); + i++; + } + return out; + } + + public void setLandingPadContollersFromArray(long[] in) { + List newList = new java.util.ArrayList<>(List.of()); + int i = 0; + for (Long packedPos : in) { + newList.add(BlockPos.of(packedPos)); + i++; + } + setLandingPadControllers(newList); } } diff --git a/src/main/java/net/xevianlight/aphelion/network/packet/PartitionPayload.java b/src/main/java/net/xevianlight/aphelion/network/packet/PartitionPayload.java index 0062170..c275f0c 100644 --- a/src/main/java/net/xevianlight/aphelion/network/packet/PartitionPayload.java +++ b/src/main/java/net/xevianlight/aphelion/network/packet/PartitionPayload.java @@ -6,6 +6,7 @@ import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; import net.xevianlight.aphelion.Aphelion; import net.xevianlight.aphelion.core.saveddata.types.PartitionData; +import org.jetbrains.annotations.NotNull; import java.util.Objects; @@ -21,7 +22,7 @@ public record PartitionPayload(PartitionData partitionData) implements CustomPac ); @Override - public Type type() { + public @NotNull Type type() { return TYPE; } diff --git a/src/main/java/net/xevianlight/aphelion/util/BigCodec.java b/src/main/java/net/xevianlight/aphelion/util/BigCodec.java new file mode 100644 index 0000000..94b51a9 --- /dev/null +++ b/src/main/java/net/xevianlight/aphelion/util/BigCodec.java @@ -0,0 +1,500 @@ +package net.xevianlight.aphelion.util; + +import com.mojang.datafixers.util.*; +import net.minecraft.network.codec.StreamCodec; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Function; + +/** + * Since mojang only wanted to implement codecs up to 6 types, here's all the codecs 7-16. You're welcome. + * @param + * @param + */ +public interface BigCodec extends StreamCodec { + + // ---------- 7 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final Function7 factory + ) { + return new StreamCodec() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + } + }; + } + + // ---------- 8 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final StreamCodec c8, final Function g8, + final Function8 factory + ) { + return new StreamCodec() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + T8 t8 = (T8)c8.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7, t8); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + c8.encode(b, g8.apply(v)); + } + }; + } + + // ---------- 9 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final StreamCodec c8, final Function g8, + final StreamCodec c9, final Function g9, + Function9 factory + ) { + return new StreamCodec<>() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + T8 t8 = (T8)c8.decode(b); + T9 t9 = (T9)c9.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + c8.encode(b, g8.apply(v)); + c9.encode(b, g9.apply(v)); + } + }; + } + + // ---------- 10 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final StreamCodec c8, final Function g8, + final StreamCodec c9, final Function g9, + final StreamCodec c10, final Function g10, + Function10 factory + ) { + return new StreamCodec<>() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + T8 t8 = (T8)c8.decode(b); + T9 t9 = (T9)c9.decode(b); + T10 t10 = (T10)c10.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + c8.encode(b, g8.apply(v)); + c9.encode(b, g9.apply(v)); + c10.encode(b, g10.apply(v)); + } + }; + } + + // ---------- 11 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final StreamCodec c8, final Function g8, + final StreamCodec c9, final Function g9, + final StreamCodec c10, final Function g10, + final StreamCodec c11, final Function g11, + Function11 factory + ) { + return new StreamCodec<>() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + T8 t8 = (T8)c8.decode(b); + T9 t9 = (T9)c9.decode(b); + T10 t10 = (T10)c10.decode(b); + T11 t11 = (T11)c11.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + c8.encode(b, g8.apply(v)); + c9.encode(b, g9.apply(v)); + c10.encode(b, g10.apply(v)); + c11.encode(b, g11.apply(v)); + } + }; + } + + // ---------- 12 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final StreamCodec c8, final Function g8, + final StreamCodec c9, final Function g9, + final StreamCodec c10, final Function g10, + final StreamCodec c11, final Function g11, + final StreamCodec c12, final Function g12, + Function12 factory + ) { + return new StreamCodec<>() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + T8 t8 = (T8)c8.decode(b); + T9 t9 = (T9)c9.decode(b); + T10 t10 = (T10)c10.decode(b); + T11 t11 = (T11)c11.decode(b); + T12 t12 = (T12)c12.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + c8.encode(b, g8.apply(v)); + c9.encode(b, g9.apply(v)); + c10.encode(b, g10.apply(v)); + c11.encode(b, g11.apply(v)); + c12.encode(b, g12.apply(v)); + } + }; + } + + // ---------- 13 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final StreamCodec c8, final Function g8, + final StreamCodec c9, final Function g9, + final StreamCodec c10, final Function g10, + final StreamCodec c11, final Function g11, + final StreamCodec c12, final Function g12, + final StreamCodec c13, final Function g13, + Function13 factory + ) { + return new StreamCodec<>() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + T8 t8 = (T8)c8.decode(b); + T9 t9 = (T9)c9.decode(b); + T10 t10 = (T10)c10.decode(b); + T11 t11 = (T11)c11.decode(b); + T12 t12 = (T12)c12.decode(b); + T13 t13 = (T13)c13.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + c8.encode(b, g8.apply(v)); + c9.encode(b, g9.apply(v)); + c10.encode(b, g10.apply(v)); + c11.encode(b, g11.apply(v)); + c12.encode(b, g12.apply(v)); + c13.encode(b, g13.apply(v)); + } + }; + } + + // ---------- 14 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final StreamCodec c8, final Function g8, + final StreamCodec c9, final Function g9, + final StreamCodec c10, final Function g10, + final StreamCodec c11, final Function g11, + final StreamCodec c12, final Function g12, + final StreamCodec c13, final Function g13, + final StreamCodec c14, final Function g14, + Function14 factory + ) { + return new StreamCodec<>() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + T8 t8 = (T8)c8.decode(b); + T9 t9 = (T9)c9.decode(b); + T10 t10 = (T10)c10.decode(b); + T11 t11 = (T11)c11.decode(b); + T12 t12 = (T12)c12.decode(b); + T13 t13 = (T13)c13.decode(b); + T14 t14 = (T14)c14.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + c8.encode(b, g8.apply(v)); + c9.encode(b, g9.apply(v)); + c10.encode(b, g10.apply(v)); + c11.encode(b, g11.apply(v)); + c12.encode(b, g12.apply(v)); + c13.encode(b, g13.apply(v)); + c14.encode(b, g14.apply(v)); + } + }; + } + + // ---------- 15 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final StreamCodec c8, final Function g8, + final StreamCodec c9, final Function g9, + final StreamCodec c10, final Function g10, + final StreamCodec c11, final Function g11, + final StreamCodec c12, final Function g12, + final StreamCodec c13, final Function g13, + final StreamCodec c14, final Function g14, + final StreamCodec c15, final Function g15, + Function15 factory + ) { + return new StreamCodec<>() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + T8 t8 = (T8)c8.decode(b); + T9 t9 = (T9)c9.decode(b); + T10 t10 = (T10)c10.decode(b); + T11 t11 = (T11)c11.decode(b); + T12 t12 = (T12)c12.decode(b); + T13 t13 = (T13)c13.decode(b); + T14 t14 = (T14)c14.decode(b); + T15 t15 = (T15)c15.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + c8.encode(b, g8.apply(v)); + c9.encode(b, g9.apply(v)); + c10.encode(b, g10.apply(v)); + c11.encode(b, g11.apply(v)); + c12.encode(b, g12.apply(v)); + c13.encode(b, g13.apply(v)); + c14.encode(b, g14.apply(v)); + c15.encode(b, g15.apply(v)); + } + }; + } + + // ---------- 16 ---------- + static StreamCodec composite( + final StreamCodec c1, final Function g1, + final StreamCodec c2, final Function g2, + final StreamCodec c3, final Function g3, + final StreamCodec c4, final Function g4, + final StreamCodec c5, final Function g5, + final StreamCodec c6, final Function g6, + final StreamCodec c7, final Function g7, + final StreamCodec c8, final Function g8, + final StreamCodec c9, final Function g9, + final StreamCodec c10, final Function g10, + final StreamCodec c11, final Function g11, + final StreamCodec c12, final Function g12, + final StreamCodec c13, final Function g13, + final StreamCodec c14, final Function g14, + final StreamCodec c15, final Function g15, + final StreamCodec c16, final Function g16, + Function16 factory + ) { + return new StreamCodec<>() { + public @NotNull C decode(@NotNull B b) { + T1 t1 = (T1)c1.decode(b); + T2 t2 = (T2)c2.decode(b); + T3 t3 = (T3)c3.decode(b); + T4 t4 = (T4)c4.decode(b); + T5 t5 = (T5)c5.decode(b); + T6 t6 = (T6)c6.decode(b); + T7 t7 = (T7)c7.decode(b); + T8 t8 = (T8)c8.decode(b); + T9 t9 = (T9)c9.decode(b); + T10 t10 = (T10)c10.decode(b); + T11 t11 = (T11)c11.decode(b); + T12 t12 = (T12)c12.decode(b); + T13 t13 = (T13)c13.decode(b); + T14 t14 = (T14)c14.decode(b); + T15 t15 = (T15)c15.decode(b); + T16 t16 = (T16)c16.decode(b); + return (C)factory.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16); + } + + public void encode(@NotNull B b, @NotNull C v) { + c1.encode(b, g1.apply(v)); + c2.encode(b, g2.apply(v)); + c3.encode(b, g3.apply(v)); + c4.encode(b, g4.apply(v)); + c5.encode(b, g5.apply(v)); + c6.encode(b, g6.apply(v)); + c7.encode(b, g7.apply(v)); + c8.encode(b, g8.apply(v)); + c9.encode(b, g9.apply(v)); + c10.encode(b, g10.apply(v)); + c11.encode(b, g11.apply(v)); + c12.encode(b, g12.apply(v)); + c13.encode(b, g13.apply(v)); + c14.encode(b, g14.apply(v)); + c15.encode(b, g15.apply(v)); + c16.encode(b, g16.apply(v)); + } + }; + } +} diff --git a/src/main/resources/assets/aphelion/lang/en_us.json b/src/main/resources/assets/aphelion/lang/en_us.json index 8b4936d..9095b43 100644 --- a/src/main/resources/assets/aphelion/lang/en_us.json +++ b/src/main/resources/assets/aphelion/lang/en_us.json @@ -54,5 +54,10 @@ "command.aphelion.rocket.get_pos.success": "Target position of rocket is %s", "command.aphelion.rocket.get_pos.success.null": "Target position of rocket is not set", "command.aphelion.rocket.disassemble.success": "Rocket disassembled", - "command.aphelion.rocket.disassemble.failure": "Could not disassemble rocket" + "command.aphelion.rocket.disassemble.failure": "Could not disassemble rocket", + "command.aphelion.station.invalid": "Station is invalid!", + "command.aphelion.station.owner.unset": "Station has no owner", + "command.aphelion.station.owner.get": "Station (%s %s) belongs to %s", + "command.aphelion.station.owner.set.success": "Set station (%s %s)'s owner to %s", + "command.aphelion.player.invalid": "Player is invalid" }