diff --git a/Scenamatica/ScenamaticaScenarioFile/src/main/java/org/kunlab/scenamatica/scenariofile/StructureSerializerImpl.java b/Scenamatica/ScenamaticaScenarioFile/src/main/java/org/kunlab/scenamatica/scenariofile/StructureSerializerImpl.java index b3cc03eeb..823c8bd0e 100644 --- a/Scenamatica/ScenamaticaScenarioFile/src/main/java/org/kunlab/scenamatica/scenariofile/StructureSerializerImpl.java +++ b/Scenamatica/ScenamaticaScenarioFile/src/main/java/org/kunlab/scenamatica/scenariofile/StructureSerializerImpl.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Entity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.kunlab.scenamatica.enums.MinecraftVersion; import org.kunlab.scenamatica.interfaces.scenariofile.Mapped; import org.kunlab.scenamatica.interfaces.scenariofile.ScenarioFileStructure; import org.kunlab.scenamatica.interfaces.scenariofile.Structure; @@ -48,6 +49,7 @@ import org.kunlab.scenamatica.scenariofile.structures.trigger.TriggerStructureImpl; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; @@ -167,140 +169,6 @@ public & Structure> T toStructure(@NotNull V value) return PlayerSpecifierImpl.tryDeserializePlayer(obj, this); } - // void registerStructure(@NotNull Class clazz, - @NotNull BiFunction> serializer, - @NotNull BiFunction, StructureSerializer, T> deserializer, - @NotNull BiConsumer, StructureSerializer> validator) - { - this.structureEntries.add(new StructureEntry<>(clazz, serializer, deserializer, validator)); - } - - @SuppressWarnings("SameParameterValue") - private void registerStructure(@NotNull Class clazz, - @NotNull BiFunction> serializer, - @NotNull BiFunction, StructureSerializer, T> deserializer, - @NotNull Consumer> validator) - { - this.structureEntries.add(new StructureEntry<>(clazz, serializer, deserializer, (v, t) -> validator.accept(v))); - } - - private void registerStructure(@NotNull Class clazz, - @NotNull Function> serializer, - @NotNull BiFunction, StructureSerializer, T> deserializer, - @NotNull BiConsumer, StructureSerializer> validator) - { - this.structureEntries.add(new StructureEntry<>(clazz, (v, t) -> serializer.apply(v), deserializer, validator)); - } - - private void registerStructure(@NotNull Class clazz, - @NotNull Function> serializer, - @NotNull BiFunction, StructureSerializer, T> deserializer, - @NotNull Consumer> validator) - { - this.structureEntries.add(new StructureEntry<>(clazz, (v, t) -> serializer.apply(v), deserializer, (v, t) -> validator.accept(v))); - } - - private void registerStructure(@NotNull Class clazz, - @NotNull Function> serializer, - @NotNull Function, ? extends T> deserializer, - @NotNull BiConsumer, StructureSerializer> validator) - { - this.structureEntries.add(new StructureEntry<>(clazz, (v, t) -> serializer.apply(v), (v, t) -> deserializer.apply(v), validator)); - } - - private void registerStructure(@NotNull Class clazz, - @NotNull Function> serializer, - @NotNull Function, ? extends T> deserializer, - @NotNull Consumer> validator) - { - this.structureEntries.add(new StructureEntry<>(clazz, (v, t) -> serializer.apply(v), (v, t) -> deserializer.apply(v), (v, t) -> validator.accept(v))); - } - - @SuppressWarnings("SameParameterValue") - private void registerStructure(@NotNull Class clazz, - @NotNull BiFunction> serializer, - @NotNull Function, ? extends T> deserializer, - @NotNull Consumer> validator) - { - this.structureEntries.add(new StructureEntry<>(clazz, serializer, (v, t) -> deserializer.apply(v), (v, t) -> validator.accept(v))); - } - - /* ------------------------------------ */ - - private & Structure> void registerStructure(@NotNull Class clazz, - @NotNull BiFunction> serializer, - @NotNull BiFunction, StructureSerializer, T> deserializer, - @NotNull BiConsumer, StructureSerializer> validator, - @NotNull Function constructor, - @NotNull Predicate applicator) - { - this.structureEntries.add(new MappedStructureEntry<>(clazz, serializer, deserializer, validator, constructor, applicator)); - } - - private & Structure> void registerStructure(@NotNull Class clazz, - @NotNull BiFunction> serializer, - @NotNull BiFunction, StructureSerializer, T> deserializer, - @NotNull Consumer> validator, - @NotNull Function constructor, - @NotNull Predicate applicator) - { - this.structureEntries.add(new MappedStructureEntry<>(clazz, serializer, deserializer, (v, t) -> validator.accept(v), constructor, applicator)); - } - - private & Structure> void registerStructure(@NotNull Class clazz, - @NotNull Function> serializer, - @NotNull BiFunction, StructureSerializer, T> deserializer, - @NotNull BiConsumer, StructureSerializer> validator, - @NotNull Function constructor, - @NotNull Predicate applicator) - { - this.structureEntries.add(new MappedStructureEntry<>(clazz, (v, t) -> serializer.apply(v), deserializer, validator, constructor, applicator)); - } - - private & Structure> void registerStructure(@NotNull Class clazz, - @NotNull Function> serializer, - @NotNull BiFunction, StructureSerializer, T> deserializer, - @NotNull Consumer> validator, - @NotNull Function constructor, - @NotNull Predicate applicator) - { - this.structureEntries.add(new MappedStructureEntry<>(clazz, (v, t) -> serializer.apply(v), deserializer, (v, t) -> validator.accept(v), constructor, applicator)); - } - - private & Structure> void registerStructure(@NotNull Class clazz, - @NotNull Function> serializer, - @NotNull Function, ? extends T> deserializer, - @NotNull BiConsumer, StructureSerializer> validator, - @NotNull Function constructor, - @NotNull Predicate applicator) - { - this.structureEntries.add(new MappedStructureEntry<>(clazz, (v, t) -> serializer.apply(v), (v, t) -> deserializer.apply(v), validator, constructor, applicator)); - } - - private & Structure> void registerStructure(@NotNull Class clazz, - @NotNull Function> serializer, - @NotNull Function, ? extends T> deserializer, - @NotNull Consumer> validator, - @NotNull Function constructor, - @NotNull Predicate applicator) - { - this.structureEntries.add(new MappedStructureEntry<>(clazz, (v, t) -> serializer.apply(v), (v, t) -> deserializer.apply(v), (v, t) -> validator.accept(v), constructor, applicator)); - } - - private & Structure> void registerStructure(@NotNull Class clazz, - @NotNull BiFunction> serializer, - @NotNull Function, ? extends T> deserializer, - @NotNull Consumer> validator, - @NotNull Function constructor, - @NotNull Predicate applicator) - { - this.structureEntries.add(new MappedStructureEntry<>(clazz, serializer, (v, t) -> deserializer.apply(v), (v, t) -> validator.accept(v), constructor, applicator)); - } - - // - private StructureEntry selectEntry(@NotNull T value, @Nullable Class clazz) { if (clazz != null) @@ -509,6 +377,509 @@ private void registerHelpers() // + + // void registerStructure(@NotNull Class clazz, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator) + { + this.structureEntries.add(new StructureEntry<>(clazz, serializer, deserializer, validator)); + } + + @SuppressWarnings("SameParameterValue") + private void registerStructure(@NotNull Class clazz, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator) + { + this.structureEntries.add(new StructureEntry<>(clazz, serializer, deserializer, (v, t) -> validator.accept(v))); + } + + private void registerStructure(@NotNull Class clazz, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator) + { + this.structureEntries.add(new StructureEntry<>(clazz, (v, t) -> serializer.apply(v), deserializer, validator)); + } + + private void registerStructure(@NotNull Class clazz, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator) + { + this.structureEntries.add(new StructureEntry<>(clazz, (v, t) -> serializer.apply(v), deserializer, (v, t) -> validator.accept(v))); + } + + private void registerStructure(@NotNull Class clazz, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator) + { + this.structureEntries.add(new StructureEntry<>(clazz, (v, t) -> serializer.apply(v), (v, t) -> deserializer.apply(v), validator)); + } + + private void registerStructure(@NotNull Class clazz, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator) + { + this.structureEntries.add(new StructureEntry<>(clazz, (v, t) -> serializer.apply(v), (v, t) -> deserializer.apply(v), (v, t) -> validator.accept(v))); + } + + @SuppressWarnings("SameParameterValue") + private void registerStructure(@NotNull Class clazz, + @NotNull BiFunction> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator) + { + this.structureEntries.add(new StructureEntry<>(clazz, serializer, (v, t) -> deserializer.apply(v), (v, t) -> validator.accept(v))); + } + + /* ------------------------------------ */ + + private & Structure> void registerStructure(@NotNull Class clazz, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.structureEntries.add(new MappedStructureEntry<>(clazz, serializer, deserializer, validator, constructor, applicator)); + } + + private & Structure> void registerStructure(@NotNull Class clazz, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.structureEntries.add(new MappedStructureEntry<>(clazz, serializer, deserializer, (v, t) -> validator.accept(v), constructor, applicator)); + } + + private & Structure> void registerStructure(@NotNull Class clazz, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.structureEntries.add(new MappedStructureEntry<>(clazz, (v, t) -> serializer.apply(v), deserializer, validator, constructor, applicator)); + } + + private & Structure> void registerStructure(@NotNull Class clazz, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.structureEntries.add(new MappedStructureEntry<>(clazz, (v, t) -> serializer.apply(v), deserializer, (v, t) -> validator.accept(v), constructor, applicator)); + } + + private & Structure> void registerStructure(@NotNull Class clazz, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.structureEntries.add(new MappedStructureEntry<>(clazz, (v, t) -> serializer.apply(v), (v, t) -> deserializer.apply(v), validator, constructor, applicator)); + } + + private & Structure> void registerStructure(@NotNull Class clazz, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.structureEntries.add(new MappedStructureEntry<>(clazz, (v, t) -> serializer.apply(v), (v, t) -> deserializer.apply(v), (v, t) -> validator.accept(v), constructor, applicator)); + } + + private & Structure> void registerStructure(@NotNull Class clazz, + @NotNull BiFunction> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.structureEntries.add(new MappedStructureEntry<>(clazz, serializer, (v, t) -> deserializer.apply(v), (v, t) -> validator.accept(v), constructor, applicator)); + } + + /* ------------------------------------ */ + + private static boolean canExtend(@Nullable MinecraftVersion targetVersionSince, @Nullable MinecraftVersion targetVersionUntil) + { + return MinecraftVersion.current().isInRange(targetVersionSince, targetVersionUntil); + } + + private static boolean canExtend(@Nullable MinecraftVersion targetVersionSince) + { + return canExtend(targetVersionSince, null); + } + + private void removeStructureFor(@NotNull Class structureClazz) + { + Iterator> iterator = this.structureEntries.iterator(); + while (iterator.hasNext()) + { + StructureEntry entry = iterator.next(); + if (entry.getClazz() == structureClazz) // Class は VM で一意なので == で比較する + { + iterator.remove(); + return; + } + } + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator); + } + + @SuppressWarnings("SameParameterValue") + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull BiFunction> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator); + } + + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull MinecraftVersion mcVersionUntil, + @NotNull BiFunction> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + if (!canExtend(mcVersionSince, mcVersionUntil)) + return; + + this.removeStructureFor(clazz); + this.registerStructure(clazz, serializer, deserializer, validator, constructor, applicator); + } + + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator); + } + + private void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull BiFunction> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull BiFunction> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull Function> serializer, + @NotNull BiFunction, StructureSerializer, T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull BiConsumer, StructureSerializer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator, constructor, applicator); + } + + private & Structure> void extendStructure(@NotNull Class clazz, + @NotNull MinecraftVersion mcVersionSince, + @NotNull Function> serializer, + @NotNull Function, ? extends T> deserializer, + @NotNull Consumer> validator, + @NotNull Function constructor, + @NotNull Predicate applicator) + { + this.extendStructure(clazz, mcVersionSince, null, serializer, deserializer, validator, constructor, applicator); + } + + // + @Data @NotNull @AllArgsConstructor diff --git a/Scenamatica/ScenamaticaStructures/StructureBase/src/main/java/org/kunlab/scenamatica/structures/minecraft/entity/PlayerStructureImpl.java b/Scenamatica/ScenamaticaStructures/StructureBase/src/main/java/org/kunlab/scenamatica/structures/minecraft/entity/PlayerStructureImpl.java index bd7f7a037..3546d143f 100644 --- a/Scenamatica/ScenamaticaStructures/StructureBase/src/main/java/org/kunlab/scenamatica/structures/minecraft/entity/PlayerStructureImpl.java +++ b/Scenamatica/ScenamaticaStructures/StructureBase/src/main/java/org/kunlab/scenamatica/structures/minecraft/entity/PlayerStructureImpl.java @@ -1,5 +1,7 @@ package org.kunlab.scenamatica.structures.minecraft.entity; +import lombok.AllArgsConstructor; +import lombok.Getter; import lombok.Value; import org.kunlab.scenamatica.structures.minecraft.entity.entities.HumanEntityStructureImpl; import org.kunlab.scenamatica.structures.minecraft.misc.LocationStructureImpl; @@ -22,32 +24,33 @@ import java.util.Objects; import java.util.stream.Collectors; -@Value +@Getter +@AllArgsConstructor public class PlayerStructureImpl extends HumanEntityStructureImpl implements PlayerStructure { private static final float SPEED_DEFAULT = 0.2f; - String name; - Boolean online; - InetAddress remoteAddress; - Integer port; - String hostName; - String displayName; - String playerListName; - String playerListHeader; - String playerListFooter; - LocationStructure compassTarget; - LocationStructure bedSpawnLocation; - Integer exp; - Integer level; - Integer totalExperience; - Boolean allowFlight; - Boolean flying; - Float walkSpeed; - Float flySpeed; - - Integer opLevel; - List activePermissions; + protected final String name; + protected final Boolean online; + protected final InetAddress remoteAddress; + protected final Integer port; + protected final String hostName; + protected final String displayName; + protected final String playerListName; + protected final String playerListHeader; + protected final String playerListFooter; + protected final LocationStructure compassTarget; + protected final LocationStructure bedSpawnLocation; + protected final Integer exp; + protected final Integer level; + protected final Integer totalExperience; + protected final Boolean allowFlight; + protected final Boolean flying; + protected final Float walkSpeed; + protected final Float flySpeed; + + protected final Integer opLevel; + protected final List activePermissions; public PlayerStructureImpl(@NotNull HumanEntityStructure human, @Nullable String name, Boolean online, InetAddress remoteAddress, Integer port, String hostName, String displayName,