diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 45bb9f6ab..d824dd39c 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -34,8 +34,8 @@ jobs: if: "!contains(github.event.head_commit.message, '--skip') && !contains(github.event.head_commit.commit.message, '--skip')" uses: softprops/action-gh-release@v1 with: - name: Latest v1.2.1 dev - tag_name: mc1.21/0-v1.2.1 + name: Latest v1.2.2 dev + tag_name: mc1.21/0-v1.2.2 body: \"changes\"=${{ github.event.head_commit.message }} token: ${{ secrets.GIT_TOKEN }} files: build/libs/*.jar diff --git a/API-DOCS.md b/API-DOCS.md index a34ab919c..8639f0a1a 100644 --- a/API-DOCS.md +++ b/API-DOCS.md @@ -20,7 +20,7 @@ repositories { } dependencies { - implementation("io.github.Dueris:OriginsPaper:mc1.21~0-v1.2.1") + implementation("io.github.Dueris:OriginsPaper:mc1.21~0-v1.2.2") } ``` diff --git a/build.gradle.kts b/build.gradle.kts index ce63a4249..470349c8b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ val paperweightVersion: String = "1.21-R0.1-SNAPSHOT" extra["mcMajorVer"] = "21" extra["mcMinorVer"] = "1" -extra["pluginVer"] = "v1.2.1" +extra["pluginVer"] = "v1.2.2" val mcMajorVer = extra["mcMajorVer"] as String val mcMinorVer = extra["mcMinorVer"] as String @@ -66,7 +66,8 @@ allprojects { "pluginVer" to pluginVer, "fullVer" to "mc$mcVer-$pluginVer", "apiVer" to "1.$mcMajorVer", - "supportedVersions" to listOf("1.21", "1.21.1") + "supported" to listOf("1.21", "1.21.1"), + "apoli" to "2.12.0-alpha.10+mc.1.21.x" ) inputs.properties(props) filesMatching("paper-plugin.yml") { diff --git a/calio/src/main/java/io/github/dueris/calio/CalioParserBuilder.java b/calio/src/main/java/io/github/dueris/calio/CalioParserBuilder.java index 78d51f03d..bf70db1ce 100644 --- a/calio/src/main/java/io/github/dueris/calio/CalioParserBuilder.java +++ b/calio/src/main/java/io/github/dueris/calio/CalioParserBuilder.java @@ -1,29 +1,19 @@ package io.github.dueris.calio; -import io.github.dueris.calio.data.AccessorKey; -import io.github.dueris.calio.parser.ParsingStrategy; -import io.github.dueris.calio.registry.RegistryKey; -import io.github.dueris.calio.test.ModMeta; +import io.github.dueris.calio.data.DataBuildDirective; import it.unimi.dsi.fastutil.objects.AbstractObjectSet; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import net.minecraft.resources.ResourceLocation; - -import java.util.List; public class CalioParserBuilder { - protected static final AbstractObjectSet> accessorKeys = new ObjectOpenHashSet<>(); + protected static final AbstractObjectSet> DATA_BUILD_DIRECTIVES = new ObjectOpenHashSet<>(); private final CraftCalio calio; public CalioParserBuilder(CraftCalio calio) { this.calio = calio; - accessorKeys.add( - new AccessorKey<>(List.of("calio"), "test", ModMeta.class, 0, ParsingStrategy.DEFAULT, - new RegistryKey<>(ModMeta.class, ResourceLocation.fromNamespaceAndPath("calio", "test"))) - ); } - public CalioParserBuilder withAccessor(AccessorKey key) { - accessorKeys.add(key); + public CalioParserBuilder withAccessor(DataBuildDirective key) { + DATA_BUILD_DIRECTIVES.add(key); return this; } diff --git a/calio/src/main/java/io/github/dueris/calio/CraftCalio.java b/calio/src/main/java/io/github/dueris/calio/CraftCalio.java index cfb6bb4ba..edd9a61f2 100644 --- a/calio/src/main/java/io/github/dueris/calio/CraftCalio.java +++ b/calio/src/main/java/io/github/dueris/calio/CraftCalio.java @@ -1,33 +1,22 @@ package io.github.dueris.calio; -import io.github.dueris.calio.data.AccessorKey; +import io.github.dueris.calio.data.DataBuildDirective; import io.github.dueris.calio.parser.CalioParser; import io.github.dueris.calio.parser.reader.system.FileSystemReader; import io.github.dueris.calio.util.Util; import io.github.dueris.calio.util.thread.ParserFactory; import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tags.TagKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; -import net.minecraft.world.level.storage.LevelResource; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.bukkit.Bukkit; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import java.io.File; +import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.*; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executors; import java.util.function.BiConsumer; @@ -44,37 +33,15 @@ public record CraftCalio(boolean threaded, int threadCount) { * Creates the calio parser instance and allows for providing * arguments like {@code async} to make it run threaded parsing. */ - @Contract("_ -> new") - public static @NotNull CraftCalio buildInstance(String[] args) { - OptionParser parser = new OptionParser(); - - parser.accepts("async").withOptionalArg().ofType(Boolean.class).defaultsTo(false); - - OptionSet options = parser.parse(args); - - boolean threaded = (Boolean) options.valueOf("async"); + public static @NotNull CraftCalio buildInstance() { int threadCount = 4; - if (threaded) { - CalioParser.threadedParser = Executors.newFixedThreadPool(threadCount, new ParserFactory(threadCount)); - CalioParser.threaded = true; - } - return new CraftCalio(threaded, threadCount); - } - - public static boolean areTagsEqual(ResourceKey> registryKey, TagKey tag1, TagKey tag2) { - return areTagsEqual(tag1, tag2); - } - - public static boolean areTagsEqual(TagKey tag1, TagKey tag2) { - return tag1 == tag2 - || tag1 != null - && tag2 != null - && tag1.registry().equals(tag2.registry()) - && tag1.location().equals(tag2.location()); + CalioParser.threadedParser = Executors.newFixedThreadPool(threadCount, new ParserFactory(threadCount)); + CalioParser.threaded = true; + return new CraftCalio(true, threadCount); } /** - * Creates a new builder for calio parsing to add {@link AccessorKey}s + * Creates a new builder for calio parsing to add {@link DataBuildDirective}s */ @Contract(value = " -> new", pure = true) public @NotNull CalioParserBuilder startBuilder() { @@ -82,69 +49,47 @@ public static boolean areTagsEqual(TagKey tag1, TagKey tag2) { } /** - * Begins parsing instances defined by the {@link AccessorKey}s in the - * CalioParserBuilder in both the plugins directory(and sub-dirs), and the - * datapacks directory defined by the {@code server.properties} file. + * Parses the datapack path provided to build registries + * Example: {@code /world/datapacks/example/} * - * @throws Throwable + * @param pathToParse The datapack path to parse */ - public boolean parse() throws Throwable { - MinecraftServer server = MinecraftServer.getServer(); - if (server == null) { - throw new IllegalAccessException("Server instance not created yet! Please wait until MinecraftServer is spun!"); - } else { - Bukkit.getLogger().info("Starting CraftCalio parsing with mod implementation version '{}'".replace("{}", "1.14.0-alpha.5+mc.1.21.x")); - Path datapackDirPath = server.getWorldPath(LevelResource.DATAPACK_DIR); - if (!datapackDirPath.toFile().exists()) { - datapackDirPath.toFile().mkdirs(); + @SuppressWarnings("unchecked") + public boolean parse(@NotNull Path pathToParse) { + Object2ObjectLinkedOpenHashMap, List>> priorityParsingQueue = new Object2ObjectLinkedOpenHashMap<>(); + CalioParserBuilder.DATA_BUILD_DIRECTIVES.forEach((key) -> { + priorityParsingQueue.put((DataBuildDirective) key, new CopyOnWriteArrayList<>()); + }); + BiConsumer jsonVerificationFilter = (path, jsonContents) -> { + + for (DataBuildDirective key : CalioParserBuilder.DATA_BUILD_DIRECTIVES) { + if (jsonContents != null && path != null && Util.pathMatchesAccessor(path, key)) { + priorityParsingQueue.get(key).add(new Tuple<>(Objects.requireNonNull(Util.buildResourceLocationFromPath(path, key)), jsonContents)); + } } - File datapackDirectory = datapackDirPath.toFile(); - if (!datapackDirectory.isDirectory()) { - throw new IllegalStateException("'datapacks' directory is not a directory! Corrupted?"); - } else { - for (Path pathToParse : new Path[]{Paths.get("plugins"), datapackDirPath}) { - Object2ObjectLinkedOpenHashMap, ConcurrentLinkedQueue>> priorityParsingQueue = new Object2ObjectLinkedOpenHashMap<>(); - CalioParserBuilder.accessorKeys.forEach((key) -> { - priorityParsingQueue.put(key, new ConcurrentLinkedQueue<>()); - }); - if (pathToParse.toFile().listFiles() != null) { - BiConsumer jsonVerificationFilter = (path, jsonContents) -> { - - for (AccessorKey key : CalioParserBuilder.accessorKeys) { - if (jsonContents != null && path != null && Util.pathMatchesAccessor(path, key)) { - priorityParsingQueue.get(key).add(new Tuple<>(path, jsonContents)); - } - } - - }; - FileSystemReader.processDatapacks(pathToParse, jsonVerificationFilter); - } - - List, ConcurrentLinkedQueue>>> entries = new ArrayList<>(priorityParsingQueue.object2ObjectEntrySet()); - entries.sort(Comparator.comparingInt((ent) -> { - return ent.getKey().priority(); - })); - for (Map.Entry, ConcurrentLinkedQueue>> entry : entries) { - try { - CalioParser.fromJsonFile(entry).forEach((out) -> { - if (out.getA() == null || out.getB() == null) { - throw new RuntimeException("Output instance or output ResourceLocation was null!"); - } - }); - } catch (Throwable throwable) { - throwable.printStackTrace(); - } - } - - } + }; + try { + FileSystemReader.processDatapacks(pathToParse, jsonVerificationFilter); + } catch (IOException e) { + throw new RuntimeException("Unable to process datapacks to parse", e); + } - if (CalioParser.threadedParser != null) { - CalioParser.threadedParser.shutdown(); - } - return true; + for (Map.Entry, List>> entry : new LinkedList<>(priorityParsingQueue.object2ObjectEntrySet()).stream().sorted(Comparator.comparingInt((ent) -> ent.getKey().priority())).toList()) { + try { + CalioParser.parseFiles(entry); + } catch (Throwable throwable) { + log.info("An unexpected exception occurred when building instances of {}, {}", entry.getKey().builder().type().getSimpleName(), throwable); + throwable.printStackTrace(); } } + return true; + } + + public void shutdown() { + if (CalioParser.threadedParser != null) { + CalioParser.threadedParser.shutdown(); + } } @Override diff --git a/calio/src/main/java/io/github/dueris/calio/SerializableDataTypes.java b/calio/src/main/java/io/github/dueris/calio/SerializableDataTypes.java index 03b0f841e..07f7e226c 100644 --- a/calio/src/main/java/io/github/dueris/calio/SerializableDataTypes.java +++ b/calio/src/main/java/io/github/dueris/calio/SerializableDataTypes.java @@ -13,9 +13,9 @@ import com.mojang.serialization.DynamicOps; import com.mojang.serialization.codecs.PrimitiveCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; import io.github.dueris.calio.data.exceptions.DataException; -import io.github.dueris.calio.parser.SerializableData; import io.github.dueris.calio.registry.RegistryKey; import io.github.dueris.calio.registry.impl.CalioRegistry; import io.github.dueris.calio.util.ArgumentWrapper; @@ -268,7 +268,7 @@ public T write(DynamicOps ops, Number value) { } } }; - List entries = new ArrayList<>(); + List entries = new LinkedList<>(); if (jsonElement.isJsonObject()) { initValues.accept(jsonElement.getAsJsonObject(), entries); } else if (jsonElement.isJsonArray()) { @@ -376,7 +376,7 @@ public T write(DynamicOps ops, Number value) { jo, FoodProperties.class ); - List effects = new ArrayList<>(); + List effects = new LinkedList<>(); data.ifPresent("effect", effects::add); data.>ifPresent("effects", effects::addAll); diff --git a/calio/src/main/java/io/github/dueris/calio/data/AccessorKey.java b/calio/src/main/java/io/github/dueris/calio/data/AccessorKey.java deleted file mode 100644 index f8eb032c4..000000000 --- a/calio/src/main/java/io/github/dueris/calio/data/AccessorKey.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.github.dueris.calio.data; - -import io.github.dueris.calio.parser.ParsingStrategy; -import io.github.dueris.calio.registry.RegistryKey; - -import java.util.List; - -public record AccessorKey(List modid, String folder, Class toBuild, int priority, - ParsingStrategy strategy, - RegistryKey registryKey) { -} diff --git a/calio/src/main/java/io/github/dueris/calio/data/DataBuildDirective.java b/calio/src/main/java/io/github/dueris/calio/data/DataBuildDirective.java new file mode 100644 index 000000000..968036bea --- /dev/null +++ b/calio/src/main/java/io/github/dueris/calio/data/DataBuildDirective.java @@ -0,0 +1,10 @@ +package io.github.dueris.calio.data; + +import io.github.dueris.calio.parser.RootResult; +import io.github.dueris.calio.registry.RegistryKey; + +import java.util.List; + +public record DataBuildDirective(List modids, String folder, SerializableDataBuilder> builder, + int priority, RegistryKey registryKey) { +} diff --git a/calio/src/main/java/io/github/dueris/calio/parser/SerializableData.java b/calio/src/main/java/io/github/dueris/calio/data/SerializableData.java similarity index 66% rename from calio/src/main/java/io/github/dueris/calio/parser/SerializableData.java rename to calio/src/main/java/io/github/dueris/calio/data/SerializableData.java index 63c95c68f..d1fbe1618 100644 --- a/calio/src/main/java/io/github/dueris/calio/parser/SerializableData.java +++ b/calio/src/main/java/io/github/dueris/calio/data/SerializableData.java @@ -1,29 +1,34 @@ -package io.github.dueris.calio.parser; +package io.github.dueris.calio.data; -import com.google.gson.JsonObject; import com.mojang.serialization.Codec; -import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.calio.parser.SerializableType; import io.github.dueris.calio.util.holder.ObjectTiedEnumState; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.function.Consumer; import java.util.function.Supplier; -import java.util.stream.Collectors; public class SerializableData { - protected final Map defaultMap = new HashMap<>(); - private final HashMap>> dataMap = new HashMap<>(); - private final Object2IntOpenHashMap keyPriorities = new Object2IntOpenHashMap<>(); public Consumer postProcessor; - @Nullable - protected ResourceLocation typedInstance; - private int priorityCounter = 0; + public ResourceLocation typedInstance; + Map defaultMap = new LinkedHashMap<>(); + HashMap>> dataMap = new LinkedHashMap<>(); + + public SerializableData(@NotNull SerializableData serializableData) { + this.defaultMap = serializableData.defaultMap; + this.dataMap = serializableData.dataMap; + this.postProcessor = serializableData.postProcessor; + this.typedInstance = serializableData.typedInstance; + } + + public SerializableData() { + } public static @NotNull SerializableData serializableData() { return new SerializableData(); @@ -35,7 +40,6 @@ public synchronized SerializableData add(String key, @NotNull Tuple public synchronized SerializableData add(String key, SerializableDataBuilder data) { dataMap.put(key, new ObjectTiedEnumState<>(data, SerializableType.REQUIRED)); - keyPriorities.put(key, priorityCounter++); return this; } @@ -46,7 +50,6 @@ public synchronized SerializableData add(String key, @NotNull Tuple public synchronized SerializableData add(String key, SerializableDataBuilder data, T defaultValue) { dataMap.put(key, new ObjectTiedEnumState<>(data, SerializableType.DEFAULT)); defaultMap.put(key, defaultValue); - keyPriorities.put(key, priorityCounter++); return this; } @@ -57,7 +60,6 @@ public synchronized SerializableData add(String key, @NotNull Tuple public synchronized SerializableData addSupplied(String key, SerializableDataBuilder data, @NotNull Supplier supplier) { dataMap.put(key, new ObjectTiedEnumState<>(data, SerializableType.DEFAULT)); defaultMap.put(key, supplier.get()); - keyPriorities.put(key, priorityCounter++); return this; } @@ -75,30 +77,9 @@ public HashMap>> dataMap( return dataMap; } - public List sortByPriorities(@NotNull List> Tuples) { - return Tuples.stream() - .sorted(Comparator.comparingInt(Tuple -> keyPriorities.getInt(Tuple.getA()))) - .map(Tuple::getB) - .collect(Collectors.toList()); - } - @SuppressWarnings("unchecked") public record Instance(Map data) { - public static @NotNull Instance decompileJsonObject(JsonObject jsonObject, SerializableData definer, String instanceType, String key, Optional> classType) { - Optional>, List>>> compiledInstance = CalioParser.compileFromInstanceDefinition( - definer, jsonObject, Optional.of(key + "=|=" + instanceType), classType - ); - if (compiledInstance.isEmpty()) return new Instance(new HashMap<>()); - List> compiledArguments = compiledInstance.get().getB(); - HashMap deserialized = new HashMap<>(); - for (Tuple compiledArgument : compiledArguments) { - deserialized.put(compiledArgument.getA(), compiledArgument.getB()); - } - - return new Instance(deserialized); - } - public boolean isPresent(String name) { return data.containsKey(name) && data.get(name) != null; } @@ -131,6 +112,10 @@ public T getOrDefault(String name, T def) { return def; } + public T getOrElse(String name, T object) { + return getOrDefault(name, object); + } + public int getInt(String name) { return get(name); } diff --git a/calio/src/main/java/io/github/dueris/calio/data/SerializableDataBuilder.java b/calio/src/main/java/io/github/dueris/calio/data/SerializableDataBuilder.java index 3688cf4bb..f720a3c1c 100644 --- a/calio/src/main/java/io/github/dueris/calio/data/SerializableDataBuilder.java +++ b/calio/src/main/java/io/github/dueris/calio/data/SerializableDataBuilder.java @@ -2,26 +2,40 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.*; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.parser.SerializableType; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; -import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; +import static io.github.dueris.calio.parser.CalioParser.LOGGER; + +/** + * The builder for parsing JsonElements -> Java objects + * Upon deserializing, if a null value is provided, it will not parse. It WILL return null. + */ public interface SerializableDataBuilder extends Codec { DynamicOps JSON_OPS = JsonOps.INSTANCE; + Logger log = LogManager.getLogger("SerializableDataBuilder"); static @NotNull SerializableDataBuilder> of(Codec> listCodec) { return of(listCodec, List.class); } static @NotNull SerializableDataBuilder of(Codec codec, Class type) { - return new AbstractSerializableDataBuilder(type) { + return new AbstractSerializableDataBuilder<>(type) { @Override public T deserialize(JsonElement object) { + if (object == null) return null; return decode(JSON_OPS, object).getOrThrow().getFirst(); } @@ -33,10 +47,23 @@ public DataResult> decode(DynamicOps ops, T1 input) { } static @NotNull SerializableDataBuilder of(Function deserialize, Class type) { - return new AbstractSerializableDataBuilder(type) { + return of(deserialize, type, true); + } + + static @NotNull SerializableDataBuilder of(Function deserialize, Class type, boolean printJson) { + return new AbstractSerializableDataBuilder<>(type) { @Override - public T deserialize(JsonElement object) { - return deserialize.apply(object); + public T deserialize(@Nullable JsonElement object) { + if (object == null) return null; + try { + return deserialize.apply(object); + } catch (Throwable throwable) { + log.error("Unable to build datatype '{}' because: [ {} ]", type.getSimpleName(), throwable.getClass().getSimpleName() + " :: " + throwable.getMessage()); + if (printJson) { + log.error("JsonElement : {}", object.toString()); + } + return null; + } } @Override @@ -49,9 +76,10 @@ public DataResult> decode(DynamicOps ops, T1 input) { } static @NotNull Codec of(final Encoder encoder, final Decoder decoder, final String name, Class type) { - return new AbstractSerializableDataBuilder(type) { + return new AbstractSerializableDataBuilder<>(type) { @Override public A deserialize(JsonElement object) { + if (object == null) return null; return decoder.decode(JSON_OPS, object).getOrThrow().getFirst(); } @@ -72,9 +100,56 @@ public String toString() { }; } - static @NotNull SerializableData.Instance compound(SerializableData definer, JsonObject object, @NotNull Class classType) { - return SerializableData.Instance - .decompileJsonObject(object, definer, "null", classType.getSimpleName(), Optional.of(classType)); + static @Nullable SerializableData.Instance compound(@NotNull SerializableData definer, JsonObject object, @NotNull Class classType) { + HashMap backend = new LinkedHashMap<>(); + AtomicBoolean failed = new AtomicBoolean(false); + + definer.dataMap().forEach((key, tiedState) -> { + if (failed.get()) return; + SerializableType state = (SerializableType) tiedState.state(); + switch (state) { + case DEFAULT -> { + if (object.has(key)) { + JsonElement element = object.get(key); + backend.put(key, tiedState.object().deserialize(element)); + } else { + backend.put(key, definer.defaultMap.get(key)); + } + } + case REQUIRED -> { + if (!object.has(key)) { + LOGGER.error("JsonObject for type [{}] is missing required key '{}'", classType.getSimpleName(), key); + failed.set(true); + return; + } + + JsonElement element = object.get(key); + backend.put(key, tiedState.object().deserialize(element)); + } + case null, default -> { + } + } + }); + + if (failed.get()) { + return null; + } + + SerializableData.Instance instance = new SerializableData.Instance(backend); + if (definer.postProcessor != null) { + definer.postProcessor.accept(instance); + } + return instance; + } + + static @NotNull SerializableDataBuilder compound(SerializableData definer, Function fromData, Class classType) { + return SerializableDataBuilder.of( + (jsonElement) -> { + if (!(jsonElement instanceof JsonObject jo)) throw new JsonSyntaxException("Expected JsonObject"); + SerializableData.Instance compound = compound(definer, jo, classType); + return fromData.apply(compound); + }, classType + ); } T deserialize(JsonElement object); diff --git a/calio/src/main/java/io/github/dueris/calio/parser/CalioParser.java b/calio/src/main/java/io/github/dueris/calio/parser/CalioParser.java index 579159a4b..7212f17fa 100644 --- a/calio/src/main/java/io/github/dueris/calio/parser/CalioParser.java +++ b/calio/src/main/java/io/github/dueris/calio/parser/CalioParser.java @@ -2,34 +2,22 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; -import io.github.dueris.calio.data.AccessorKey; -import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.calio.data.DataBuildDirective; import io.github.dueris.calio.registry.RegistryKey; import io.github.dueris.calio.registry.impl.CalioRegistry; import io.github.dueris.calio.util.ReflectionUtils; -import io.github.dueris.calio.util.Util; -import io.github.dueris.calio.util.annotations.DontRegister; -import io.github.dueris.calio.util.annotations.RequiresPlugin; import io.github.dueris.calio.util.annotations.SourceProvider; -import io.github.dueris.calio.util.holder.ObjectProvider; -import io.github.dueris.calio.util.holder.ObjectTiedEnumState; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.bukkit.Bukkit; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.Unmodifiable; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.atomic.AtomicBoolean; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicReference; public class CalioParser { @@ -39,169 +27,48 @@ public class CalioParser { public static ExecutorService threadedParser; public static boolean threaded = false; - @SuppressWarnings("unchecked") - public static @NotNull ConcurrentLinkedQueue> fromJsonFile(Map.@NotNull Entry, ConcurrentLinkedQueue>> entry) { - AccessorKey accessorKey = entry.getKey(); - // We return the same result, but implement a check that it's valid to ensure it's ready for parsing. - ConcurrentLinkedQueue>> typedTempInstance = new ConcurrentLinkedQueue<>(); - final Class[] defaultType = new Class[]{null}; - Class clz = accessorKey.strategy().equals(ParsingStrategy.DEFAULT) ? (Class) accessorKey.toBuild() : - ((ObjectProvider>) () -> { - try { - ConcurrentLinkedQueue> instanceTypes = (ConcurrentLinkedQueue>) ReflectionUtils.getStaticFieldValue(accessorKey.toBuild(), "INSTANCE_TYPES"); - for (Class instanceType : instanceTypes) { - if (ReflectionUtils.hasMethod(instanceType, "buildFactory", true)) { - typedTempInstance.add(new Tuple<>(ReflectionUtils.invokeStaticMethod(instanceType, "buildFactory"), instanceType)); - } - } - if (ReflectionUtils.hasField(accessorKey.toBuild(), "DEFAULT_TYPE", true)) { - defaultType[0] = (Class) ReflectionUtils.getStaticFieldValue(accessorKey.toBuild(), "DEFAULT_TYPE"); - } - } catch (Throwable throwable) { - throw new RuntimeException("Unable to parse INSTANCE_TYPES field for class '" + accessorKey.toBuild().getSimpleName() + "'"); - } - return (Class) accessorKey.toBuild(); - }).get(); - ConcurrentLinkedQueue> concurrentLinkedQueue = new ConcurrentLinkedQueue<>(); - if (ReflectionUtils.hasAnnotation(clz, DontRegister.class)) { - return concurrentLinkedQueue; - } - if (ReflectionUtils.hasAnnotation(clz, RequiresPlugin.class)) { - String pluginInstance = ReflectionUtils.getAnnotation(clz, RequiresPlugin.class).get().pluginName(); - if (!Bukkit.getPluginManager().isPluginEnabled(pluginInstance)) { - return concurrentLinkedQueue; - } - } - if (ReflectionUtils.hasMethod(clz, "buildFactory", true)) { - List> parsingTasks = new ArrayList<>(); - for (Tuple Tuple : entry.getValue()) { - Optional> future = submitParseTask(() -> { - parseFile(new Tuple<>(Util.buildResourceLocationFromPath(Tuple.getA()), Tuple.getB()), clz, accessorKey, defaultType, typedTempInstance); - }); - - Objects.requireNonNull(parsingTasks); - future.ifPresent(parsingTasks::add); - } - - CompletableFuture allOf = CompletableFuture.allOf(parsingTasks.toArray(new CompletableFuture[0])); - try { - allOf.get(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - } else { - LOGGER.error("Provided class, {} has no static method 'buildFactory'", clz.getSimpleName()); + /** + * Parses the files inside the list provided based on the {@link DataBuildDirective}. + * The list provided needs to be instances of a {@link Tuple} of the location and the json contents + * to be parsed. After 1 1/2 minutes, the parser will kill the process since realistically it shouldn't + * take that long... + */ + public static void parseFiles(Map.@NotNull Entry, List>> toParse) { + DataBuildDirective dataBuildDirective = toParse.getKey(); + + List> parseTasks = new CopyOnWriteArrayList<>(); + for (Tuple parseData : toParse.getValue()) { + Optional> future = submitParseTask(() -> { + parseFile(parseData, dataBuildDirective); + }); + + future.ifPresent(parseTasks::add); } - return concurrentLinkedQueue; - } - - public static @Nullable T parseFile(@NotNull Tuple Tuple, Class clz, AccessorKey accessorKey, Class[] defaultType, ConcurrentLinkedQueue>> typedTempInstance) { - final AtomicBoolean[] kill = {new AtomicBoolean(false)}; - ResourceLocation location = Tuple.getA(); - String jsonContents = Tuple.getB(); - if (location == null) - throw new RuntimeException("Unable to compile ResourceLocation for CalioParser!"); - SerializableData definer; - Class toBuild = clz; - - JsonObject jsonSource = REMAPPER.get().remap(GSON.fromJson(jsonContents, JsonObject.class), location).getAsJsonObject(); - switch (accessorKey.strategy()) { - case TYPED -> { - Class typedInst; - if (!jsonSource.has("type")) { - if (defaultType[0] != null) { - typedInst = defaultType[0]; - } else { - LOGGER.error("Error when parsing {} : 'type' field is required for {} instances", location.toString(), clz.getSimpleName()); - kill[0].set(true); - return null; - } - } else { - try { - typedInst = typedTempInstance.stream().filter(stringClassTuple -> { - return stringClassTuple.getA().typedInstance != null && stringClassTuple.getA().typedInstance.toString().equalsIgnoreCase(jsonSource.get("type").getAsString()); - }).findFirst().get().getB(); - } catch (NoSuchElementException e) { - kill[0].set(true); - LOGGER.error("Unable to retrieve type instance of '{}'", jsonSource.get("type").getAsString()); - return null; - } - } - if (typedInst != null) { - toBuild = typedInst; - } - } - } - if (toBuild == null) - throw new RuntimeException("Unable to parse type for class '" + clz.getSimpleName() + "' and type value of '" + jsonSource.get("type").getAsString() + "'"); + CompletableFuture allTasks = CompletableFuture.allOf(parseTasks.toArray(new CompletableFuture[0])); try { - if (!ReflectionUtils.hasMethod(toBuild, "buildFactory", true)) - throw new IllegalArgumentException("Class '" + toBuild.getSimpleName() + "' must have the method 'buildFactory' but one was not found!"); - definer = ReflectionUtils.invokeStaticMethod(toBuild, "buildFactory"); - } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { + allTasks.get(90, TimeUnit.SECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException(e); } - Optional>, List>>> compiledInstance = compileFromInstanceDefinition(definer, jsonSource, Optional.of(location.toString()), Optional.of(clz)); - if (compiledInstance.isEmpty()) return null; - List> compiledArguments = compiledInstance.get().getB(); - List> compiledParams = compiledInstance.get().getA(); - if (kill[0].get()) return null; - - List> parameterTypes = (List>) definer.sortByPriorities(compiledParams); - parameterTypes.addFirst(ResourceLocation.class); - - Constructor constructor; - try { - constructor = toBuild.getConstructor(parameterTypes.toArray(new Class[0])); - } catch (NoSuchMethodException e) { - LOGGER.error("No such constructor with the given parameter types: {}", e.getMessage()); - e.printStackTrace(); - return null; - } - - List arguments = definer.sortByPriorities(compiledArguments); - arguments.addFirst(location); - - Object[] argsArray = new Object[parameterTypes.size()]; - for (int i = 0; i < parameterTypes.size(); i++) { - Class paramType = parameterTypes.get(i); - Object arg = (i < arguments.size()) ? arguments.get(i) : null; - - if (arg != null && !paramType.isInstance(arg)) { - try { - arg = convertArgument(arg, paramType); - } catch (Exception e) { - LOGGER.error("Error converting argument {} to type {}: {}", arg, paramType, e.getMessage()); - continue; - } - } + } - argsArray[i] = arg; - } - // Post-processing start - if (definer.postProcessor != null) { - SerializableData.Instance factoryJson = SerializableData.Instance.decompileJsonObject( - jsonSource, definer, toBuild.getSimpleName(), location.toString(), Optional.of(toBuild) - ); - definer.postProcessor.accept(factoryJson); - } + public static @Nullable T parseFile(@NotNull Tuple jsonData, @NotNull DataBuildDirective dataBuildDirective) { + ResourceLocation location = jsonData.getA(); + JsonObject jsonSource = REMAPPER.get().remap(GSON.fromJson(jsonData.getB(), JsonObject.class), location).getAsJsonObject(); - try { - return finalizeInstance((T) constructor.newInstance(argsArray), jsonSource, accessorKey, location); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | - InvocationTargetException e) { - LOGGER.error("Error compiling instanceof {} : {}", toBuild.getSimpleName(), e.getMessage()); - } - return null; + RootResult instance = dataBuildDirective.builder().deserialize(jsonSource); + if (instance == null) return null; + return finalizeInstance(instance.apply(location), jsonSource, dataBuildDirective, location); } - public static @NotNull T finalizeInstance(@NotNull T instance, JsonObject jsonSource, AccessorKey accessorKey, ResourceLocation location) { + @SuppressWarnings("unchecked") + public static @NotNull T finalizeInstance(@NotNull T instance, JsonObject jsonSource, DataBuildDirective dataBuildDirective, ResourceLocation location) { if (ReflectionUtils.hasFieldWithAnnotation(instance.getClass(), JsonObject.class, SourceProvider.class)) { ReflectionUtils.setFieldWithAnnotation(instance, SourceProvider.class, jsonSource); } - RegistryKey registryKey = (RegistryKey) accessorKey.registryKey(); + RegistryKey registryKey = (RegistryKey) dataBuildDirective.registryKey(); if (ReflectionUtils.invokeBooleanMethod(instance, "canRegister")) { CalioRegistry.INSTANCE.retrieve(registryKey).register(instance, location); } @@ -218,85 +85,4 @@ private static Optional> submitParseTask(Runnable runnab return Optional.of(voidCompletableFuture); } - public static Optional>, List>>> compileFromInstanceDefinition(@NotNull SerializableData definer, JsonObject jsonSource, Optional location, Optional> clz) { - List> compiledParams = new ArrayList<>(); - List> compiledArguments = new ArrayList<>(); - for (Map.Entry>> entry : definer.dataMap().entrySet()) { - String key = entry.getKey(); - ObjectTiedEnumState> serializableTiedBoolean = entry.getValue(); - SerializableType type = (SerializableType) serializableTiedBoolean.state(); - try { - switch (type) { - case DEFAULT: - compiledParams.add(new Tuple<>(key, serializableTiedBoolean.object().type())); - if (jsonSource.has(key)) { - compiledArguments.add(new Tuple<>(key, serializableTiedBoolean.object().deserialize(jsonSource.get(key)))); - } else { - if (!definer.defaultMap.containsKey(key)) { - throw new UnsupportedOperationException("A default value was provided but it wasn't fetch-able by the calio compiler!"); - } - - compiledArguments.add(new Tuple<>(key, definer.defaultMap.get(key))); - } - break; - case REQUIRED: - compiledParams.add(new Tuple<>(key, serializableTiedBoolean.object().type())); - if (jsonSource.has(key)) { - compiledArguments.add(new Tuple<>(key, serializableTiedBoolean.object().deserialize(jsonSource.get(key)))); - } else { - LOGGER.error("Required instance not found, skipping instance compiling for '{}' : KEY ['{}'] | ClassName [{}]", location.orElse("Unknown Key"), key, clz.isPresent() ? clz.get() : "Unknown Class"); - LOGGER.error("JSON: {}", jsonSource.get(key).toString()); - return Optional.empty(); - } - } - } catch (Throwable throwable) { - LOGGER.error("Unable to compile '{}' from InstanceDefinition: '{}'", serializableTiedBoolean.object() == null ? "NULL" : serializableTiedBoolean.object().asString(), location.orElse("no_location_found")); - LOGGER.error("JSON-ELEMENT: {}", jsonSource.get(key).toString()); - throwable.printStackTrace(); - } - } - if (!compiledParams.isEmpty() && !compiledArguments.isEmpty()) { - return Optional.of(new Tuple<>(compiledParams, compiledArguments)); - } - return Optional.empty(); - } - - private static Object convertArgument(Object arg, @NotNull Class paramType) { - if (paramType.isPrimitive()) { - return convertToPrimitive(arg, paramType); - } else if (isWrapperType(paramType)) { - return convertToWrapper(arg, paramType); - } - throw new IllegalArgumentException("Unsupported type conversion for: " + paramType.getName()); - } - - private static boolean isWrapperType(Class type) { - return type == Integer.class || type == Boolean.class || type == Double.class || type == Float.class || - type == Long.class || type == Short.class || type == Byte.class || type == Character.class; - } - - private static Object convertToPrimitive(Object arg, Class primitiveType) { - if (primitiveType == int.class) return ((Number) arg).intValue(); - if (primitiveType == boolean.class) return arg; - if (primitiveType == double.class) return ((Number) arg).doubleValue(); - if (primitiveType == float.class) return ((Number) arg).floatValue(); - if (primitiveType == long.class) return ((Number) arg).longValue(); - if (primitiveType == short.class) return ((Number) arg).shortValue(); - if (primitiveType == byte.class) return ((Number) arg).byteValue(); - if (primitiveType == char.class) return arg.toString().charAt(0); - throw new IllegalArgumentException("Unsupported primitive type: " + primitiveType.getName()); - } - - private static @Unmodifiable Object convertToWrapper(Object arg, Class wrapperType) { - if (wrapperType == Integer.class) return Integer.valueOf(((Number) arg).intValue()); - if (wrapperType == Boolean.class) return arg; - if (wrapperType == Double.class) return Double.valueOf(((Number) arg).doubleValue()); - if (wrapperType == Float.class) return Float.valueOf(((Number) arg).floatValue()); - if (wrapperType == Long.class) return Long.valueOf(((Number) arg).longValue()); - if (wrapperType == Short.class) return Short.valueOf(((Number) arg).shortValue()); - if (wrapperType == Byte.class) return Byte.valueOf(((Number) arg).byteValue()); - if (wrapperType == Character.class) return Character.valueOf(arg.toString().charAt(0)); - throw new IllegalArgumentException("Unsupported wrapper type: " + wrapperType.getName()); - } - } diff --git a/calio/src/main/java/io/github/dueris/calio/parser/JsonObjectRemapper.java b/calio/src/main/java/io/github/dueris/calio/parser/JsonObjectRemapper.java index a2e88dab3..a890b9aea 100644 --- a/calio/src/main/java/io/github/dueris/calio/parser/JsonObjectRemapper.java +++ b/calio/src/main/java/io/github/dueris/calio/parser/JsonObjectRemapper.java @@ -7,7 +7,7 @@ import net.minecraft.util.Tuple; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.function.Consumer; @@ -17,7 +17,7 @@ public class JsonObjectRemapper { * For hooking into where type aliases get checked and then returned * The Tuple provided will be */ - public static List>>> PRE_REMAP_HOOK = new ArrayList<>(); + public static List>>> PRE_REMAP_HOOK = new LinkedList<>(); private final List> namespaceRemappings; private final List> typeAliases; private final List aliasKeys; diff --git a/calio/src/main/java/io/github/dueris/calio/parser/ParsingStrategy.java b/calio/src/main/java/io/github/dueris/calio/parser/ParsingStrategy.java deleted file mode 100644 index ebb61acae..000000000 --- a/calio/src/main/java/io/github/dueris/calio/parser/ParsingStrategy.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.dueris.calio.parser; - -public enum ParsingStrategy { - TYPED, DEFAULT -} diff --git a/calio/src/main/java/io/github/dueris/calio/parser/RootResult.java b/calio/src/main/java/io/github/dueris/calio/parser/RootResult.java new file mode 100644 index 000000000..747119708 --- /dev/null +++ b/calio/src/main/java/io/github/dueris/calio/parser/RootResult.java @@ -0,0 +1,26 @@ +package io.github.dueris.calio.parser; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.util.Util; +import net.minecraft.resources.ResourceLocation; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +public class RootResult { + private final Constructor constructor; + private final SerializableData.Instance instance; + + public RootResult(Constructor constructor, SerializableData.Instance instance) { + this.constructor = constructor; + this.instance = instance; + } + + public T apply(ResourceLocation key) { + try { + return Util.instantiate(constructor, key, instance); + } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } +} diff --git a/calio/src/main/java/io/github/dueris/calio/registry/Registrar.java b/calio/src/main/java/io/github/dueris/calio/registry/Registrar.java index e9c4f50a2..6f1fd8402 100644 --- a/calio/src/main/java/io/github/dueris/calio/registry/Registrar.java +++ b/calio/src/main/java/io/github/dueris/calio/registry/Registrar.java @@ -8,7 +8,10 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.*; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import java.util.function.Predicate; import java.util.stream.Stream; public class Registrar { @@ -16,7 +19,7 @@ public class Registrar { private final ConcurrentHashMap rawRegistry = new ConcurrentHashMap<>(); private final ConcurrentHashMap reverseLookup = new ConcurrentHashMap<>(); private final Map defaultValues = new ConcurrentHashMap<>(); - private final List>> eventListeners = Collections.synchronizedList(new ArrayList<>()); + private final List>> eventListeners = Collections.synchronizedList(new LinkedList<>()); private volatile boolean frozen = false; private BiFunction serializer; private BiFunction deserializer; diff --git a/calio/src/main/java/io/github/dueris/calio/registry/impl/CalioRegistry.java b/calio/src/main/java/io/github/dueris/calio/registry/impl/CalioRegistry.java index d6f6463f6..955dd8ddc 100644 --- a/calio/src/main/java/io/github/dueris/calio/registry/impl/CalioRegistry.java +++ b/calio/src/main/java/io/github/dueris/calio/registry/impl/CalioRegistry.java @@ -7,11 +7,12 @@ import io.github.dueris.calio.registry.exceptions.AlreadyRegisteredException; import java.util.HashMap; +import java.util.LinkedHashMap; @SuppressWarnings("unchecked") public class CalioRegistry implements IRegistry { public static final CalioRegistry INSTANCE = new CalioRegistry(); - private final HashMap, Registrar> registry = new HashMap<>(); + private final HashMap, Registrar> registry = new LinkedHashMap<>(); public void freezeAll() { this.registry.values().forEach(Registrar::freeze); diff --git a/calio/src/main/java/io/github/dueris/calio/test/ModMeta.java b/calio/src/main/java/io/github/dueris/calio/test/ModMeta.java deleted file mode 100644 index ed666ba3d..000000000 --- a/calio/src/main/java/io/github/dueris/calio/test/ModMeta.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.dueris.calio.test; - -import com.google.gson.JsonObject; -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.calio.util.annotations.SourceProvider; -import net.minecraft.resources.ResourceLocation; - -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; - -public class ModMeta { - public static ConcurrentLinkedQueue> INSTANCE_TYPES = new ConcurrentLinkedQueue<>(List.of()); - private final int priority; - @SourceProvider - private JsonObject sourceProvider; - - public ModMeta(ResourceLocation key, int priority) { - this.priority = priority; - } - - public static SerializableData buildFactory() { - return SerializableData.serializableData() - .add("priority", SerializableDataTypes.boundNumber(SerializableDataTypes.INT, 0, Integer.MAX_VALUE)); - } -} diff --git a/calio/src/main/java/io/github/dueris/calio/util/ReflectionUtils.java b/calio/src/main/java/io/github/dueris/calio/util/ReflectionUtils.java index 907b3d435..55ed10e28 100644 --- a/calio/src/main/java/io/github/dueris/calio/util/ReflectionUtils.java +++ b/calio/src/main/java/io/github/dueris/calio/util/ReflectionUtils.java @@ -62,7 +62,6 @@ public static void invokeMethod(Object instance, @NotNull String methodName) { method.setAccessible(true); method.invoke(instance); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) { - ignored.printStackTrace(); } } diff --git a/calio/src/main/java/io/github/dueris/calio/util/Util.java b/calio/src/main/java/io/github/dueris/calio/util/Util.java index 134273d25..0fe3688af 100644 --- a/calio/src/main/java/io/github/dueris/calio/util/Util.java +++ b/calio/src/main/java/io/github/dueris/calio/util/Util.java @@ -1,39 +1,77 @@ package io.github.dueris.calio.util; -import io.github.dueris.calio.data.AccessorKey; +import io.github.dueris.calio.data.DataBuildDirective; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.calio.util.holder.ObjectTiedEnumState; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + public class Util { - public static boolean pathMatchesAccessor(@NotNull String path, AccessorKey accessorKey) { + public static boolean pathMatchesAccessor(@NotNull String path, DataBuildDirective dataBuildDirective) { if (!path.contains("data/")) return false; - try { - String[] parts = path.split("/"); - if (parts.length < 4) return false; - String modid = parts[2]; - String typeFolder = parts[3]; - return accessorKey.folder().equalsIgnoreCase(typeFolder) && accessorKey.modid().contains(modid); - } catch (ArrayIndexOutOfBoundsException e) { - return false; + if (!dataBuildDirective.modids().isEmpty()) { + try { + String[] parts = path.split("/"); + if (parts.length < 4) return false; + String modid = parts[2]; + String typeFolder = parts[3]; + return dataBuildDirective.folder().equalsIgnoreCase(typeFolder) && dataBuildDirective.modids().contains(modid); + } catch (ArrayIndexOutOfBoundsException e) { + return false; + } + } else { + try { + String[] parts = path.split("/"); + if (parts.length < 3) return false; + String typeFolder = parts[2]; + return dataBuildDirective.folder().equalsIgnoreCase(typeFolder); + } catch (ArrayIndexOutOfBoundsException e) { + return false; + } } } - public static @Nullable ResourceLocation buildResourceLocationFromPath(@NotNull String path) { + public static @Nullable ResourceLocation buildResourceLocationFromPath(@NotNull String path, DataBuildDirective dataBuildDirective) { if (!path.contains("data/")) return null; - try { - String[] parts = path.split("/"); - if (parts.length < 4) return null; + if (!dataBuildDirective.modids().isEmpty()) { + try { + String[] parts = path.split("/"); + if (parts.length < 4) return null; - StringBuilder nameBuilder = new StringBuilder(parts[4].replace(".json", "")); - for (int i = 5; i < parts.length; i++) { - nameBuilder.append('/').append(parts[i].replace(".json", "")); + StringBuilder nameBuilder = new StringBuilder(parts[4].replace(".json", "")); + for (int i = 5; i < parts.length; i++) { + nameBuilder.append('/').append(parts[i].replace(".json", "")); + } + String name = nameBuilder.toString(); + String resourceString = parts[1] + ":" + name; + return ResourceLocation.read(resourceString).getOrThrow(); + } catch (Exception e) { + return null; + } + } else { + try { + String[] parts = path.split("/"); + if (parts.length < 3) return null; + + StringBuilder nameBuilder = new StringBuilder(parts[3].replace(".json", "")); + for (int i = 5; i < parts.length; i++) { + nameBuilder.append('/').append(parts[i].replace(".json", "")); + } + String name = nameBuilder.toString(); + String resourceString = parts[1] + ":" + name; + return ResourceLocation.read(resourceString).getOrThrow(); + } catch (Exception e) { + return null; } - String name = nameBuilder.toString(); - String resourceString = parts[1] + ":" + name; - return ResourceLocation.read(resourceString).getOrThrow(); - } catch (Exception e) { - return null; } } @@ -41,4 +79,68 @@ public static boolean pathMatchesAccessor(@NotNull String path, AccessorKey a public static Class castClass(Class aClass) { return (Class) aClass; } + + public static @NotNull Constructor generateConstructor(Class targetClass, @NotNull SerializableData serializableData) throws NoSuchMethodException, IllegalAccessException { + List> paramTypes = new LinkedList<>(); + paramTypes.add(ResourceLocation.class); + + for (Map.Entry>> entry : serializableData.dataMap().entrySet()) { + Class paramType = entry.getValue().object().type(); + paramTypes.add(getPrimitiveType(paramType)); + } + + Class[] paramArray = paramTypes.toArray(new Class[0]); + Constructor constructor = targetClass.getConstructor(paramArray); + + if (Modifier.isPrivate(constructor.getModifiers())) { + throw new IllegalAccessException("Cannot access private constructor"); + } + + return constructor; + } + + public static @NotNull T instantiate(@NotNull Constructor constructor, ResourceLocation resourceLocation, SerializableData.@NotNull Instance instance) throws InstantiationException, IllegalAccessException, InvocationTargetException { + Object[] params = new Object[constructor.getParameterCount()]; + params[0] = resourceLocation; + + int i = 1; + for (String key : instance.data().keySet()) { + Object value = instance.get(key); + Class paramType = constructor.getParameterTypes()[i]; + + if (value == null) { + if (paramType.isPrimitive()) { + value = getDefaultValue(paramType); + } + } + + params[i++] = value; + } + + return constructor.newInstance(params); + } + + private static Object getDefaultValue(Class type) { + if (type == boolean.class) return false; + if (type == char.class) return '\u0000'; + if (type == byte.class) return (byte) 0; + if (type == short.class) return (short) 0; + if (type == int.class) return 0; + if (type == long.class) return 0L; + if (type == float.class) return 0f; + if (type == double.class) return 0d; + throw new IllegalArgumentException("Type " + type + " is not a supported primitive type."); + } + + private static Class getPrimitiveType(Class clazz) { + if (clazz == Integer.class) return int.class; + if (clazz == Boolean.class) return boolean.class; + if (clazz == Float.class) return float.class; + if (clazz == Double.class) return double.class; + if (clazz == Long.class) return long.class; + if (clazz == Byte.class) return byte.class; + if (clazz == Short.class) return short.class; + if (clazz == Character.class) return char.class; + return clazz; + } } diff --git a/calio/src/main/java/io/github/dueris/calio/util/annotations/DontRegister.java b/calio/src/main/java/io/github/dueris/calio/util/annotations/DontRegister.java deleted file mode 100644 index 770a6d2ea..000000000 --- a/calio/src/main/java/io/github/dueris/calio/util/annotations/DontRegister.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.dueris.calio.util.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface DontRegister { -} diff --git a/calio/src/main/java/io/github/dueris/calio/util/annotations/RequiresPlugin.java b/calio/src/main/java/io/github/dueris/calio/util/annotations/RequiresPlugin.java deleted file mode 100644 index f25c37801..000000000 --- a/calio/src/main/java/io/github/dueris/calio/util/annotations/RequiresPlugin.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.github.dueris.calio.util.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface RequiresPlugin { - String pluginName(); -} diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/MixBukkit.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/MixBukkit.java index 90cda7786..8dd7223dd 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/MixBukkit.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/MixBukkit.java @@ -1,19 +1,17 @@ package com.dragoncommissions.mixbukkit; -import com.dragoncommissions.mixbukkit.addons.AutoMapper; import com.dragoncommissions.mixbukkit.agent.ClassesManager; import com.dragoncommissions.mixbukkit.agent.JVMAttacher; import com.dragoncommissions.mixbukkit.api.MixinPlugin; import com.dragoncommissions.mixbukkit.api.ObfMap; import com.dragoncommissions.mixbukkit.utils.io.BukkitErrorOutputStream; -import lombok.AllArgsConstructor; +import io.papermc.paper.plugin.entrypoint.classloader.PaperPluginClassLoader; import lombok.Getter; import lombok.SneakyThrows; import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.slf4j.LoggerFactory; @@ -21,31 +19,40 @@ import java.io.IOException; import java.io.InputStream; import java.lang.instrument.Instrumentation; -import java.lang.reflect.Method; -import java.net.URLClassLoader; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; import java.util.jar.JarFile; public class MixBukkit { public final static String VERSION = "0.1"; - public final static BuildType BUILD_TYPE = BuildType.SNAPSHOT; @Getter private static final Map plugins = new HashMap<>(); private static final org.slf4j.Logger log = LoggerFactory.getLogger(MixBukkit.class); - public static boolean DEBUG = BUILD_TYPE.isDevBuild(); - public static boolean WRITE_TRANSFORMED_CLASS = false; + public static MixBukkit INSTANCE; + public static boolean DEBUG = true; + public static boolean WRITE_TRANSFORMED_CLASS = true; public static boolean SAFE_MODE = true; public static Instrumentation INSTRUMENTATION = null; public static boolean PREPARED = false; public static BukkitErrorOutputStream ERROR_OUTPUT_STREAM = new BukkitErrorOutputStream(); public static ClassesManager classesManager; + @ApiStatus.Internal + public static AtomicReference CLASSLOADER = new AtomicReference<>(); @Getter private static JVMAttacher jvmAttacher; @Getter private File pluginFile; + public MixBukkit(PaperPluginClassLoader classLoader) { + CLASSLOADER.set(classLoader); + } + + public static PaperPluginClassLoader getClassLoader() { + return CLASSLOADER.get(); + } + @SneakyThrows public static void addLibrary(File file) { try { @@ -60,20 +67,10 @@ public static void addLibrary(File file) { } @SneakyThrows - public void onEnable(Logger logger, File pluginFile, URLClassLoader parent) { - // ((URLClassLoader) plugin.getClassLoader().getParent()); - this.pluginFile = pluginFile; // plugin.getFile() - - loadConfig(); - - logger.info("=-=-=-=-= MIXIN LOADER =-=-=-=-="); - logger.info(" Starting MIXIN loader on server:"); - logger.info(" - Version: " + VERSION); - logger.info(" - Build Type: " + BUILD_TYPE); - logger.info(" - MC Version: " + AutoMapper.getMCVersion()); - logger.info(""); + public void onEnable(Logger logger, File pluginFile) { + this.pluginFile = pluginFile; + INSTANCE = this; - logger.info("Attaching to JVM..."); jvmAttacher = new JVMAttacher(this); jvmAttacher.attach(); if (INSTRUMENTATION == null) { @@ -85,6 +82,7 @@ public void onEnable(Logger logger, File pluginFile, URLClassLoader parent) { logger.warn("1. Do you have -XX:+DisableAttachMechanism? If yes, remove it from server start command."); logger.warn("2. Does the server have permission to spawn a process? If no, give it. Normally yes unless you are using a server panel that limits the privilege"); logger.warn(""); + logger.warn("============================================="); throw new NullPointerException("Instrumentation is null"); } catch (Exception e) { @@ -92,63 +90,20 @@ public void onEnable(Logger logger, File pluginFile, URLClassLoader parent) { } } - logger.info("- Finished Attaching!"); - logger.info("- Preparing class transformers..."); - ClassesManager.init(); - - logger.info("- Finished preparing class transformers!"); - logger.info(""); - logger.info("Finished loading MIXIN!"); - logger.info("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); PREPARED = true; } - private void loadConfig() { - try { - SAFE_MODE = true; - DEBUG = true; - WRITE_TRANSFORMED_CLASS = false; - } catch (Exception e) { - e.printStackTrace(); - } - } - - public @NotNull MixinPlugin registerMixinPlugin(@NotNull Plugin plugin, InputStream membersMapStream) { - MixinPlugin mixinPlugin = plugins.get(plugin.getName()); + public @NotNull MixinPlugin registerMixinPlugin(@NotNull MixinPluginInstance plugin, InputStream membersMapStream) { + MixinPlugin mixinPlugin = plugins.get(plugin.name()); if (mixinPlugin != null) { return mixinPlugin; } mixinPlugin = new MixinPlugin(plugin, new ObfMap(membersMapStream)); - plugins.put(plugin.getName(), mixinPlugin); - try { - Method getFile = JavaPlugin.class.getDeclaredMethod("getFile"); - getFile.setAccessible(true); - File pluginFile = ((File) getFile.invoke(plugin)); - pluginFile = pluginFile.getAbsoluteFile(); - } catch (Exception e) { - e.printStackTrace(); - } + plugins.put(plugin.name(), mixinPlugin); return mixinPlugin; } - @AllArgsConstructor - @Getter - public enum BuildType { - SNAPSHOT(true), - BETA(false), - RELEASE(false); - - private final boolean devBuild; - - BuildType(boolean devBuild) { - this.devBuild = devBuild; - } - - public boolean isDevBuild() { - return devBuild; - } - } } diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/MixinPluginInstance.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/MixinPluginInstance.java new file mode 100644 index 000000000..c6136ac21 --- /dev/null +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/MixinPluginInstance.java @@ -0,0 +1,4 @@ +package com.dragoncommissions.mixbukkit; + +public record MixinPluginInstance(String name) { +} diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/addons/AutoMapper.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/addons/AutoMapper.java index 8429256e4..d5c90a638 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/addons/AutoMapper.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/addons/AutoMapper.java @@ -8,6 +8,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.SneakyThrows; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.eclipse.jgit.api.Git; @@ -27,6 +29,7 @@ public class AutoMapper { + private static final Logger log = LogManager.getLogger("AutoMapper"); private static boolean prepared = false; private static File mappingFile; @@ -39,9 +42,9 @@ public static InputStream getMappingAsStream() { if (MixBukkit.DEBUG) { e.printStackTrace(); } - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Error loading mapping! Have you connected to the internet?"); + log.error("[!] Error loading mapping! Have you connected to the internet?"); if (MixBukkit.SAFE_MODE) { - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Server shutdown because safe mode is on, not loading mapping correctly may cause critical bugs/saves corruption."); + log.error("[!] Server shutdown because safe mode is on, not loading mapping correctly may cause critical bugs/saves corruption."); Bukkit.getServer().shutdown(); throw e; } @@ -59,19 +62,19 @@ public static InputStream getMappingAsStream() { @SneakyThrows private static void prepareMapping() { if (!shouldLoadMapping()) { - Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[!] You don't need any mapping for this build!"); + log.info("[!] You don't need any mapping for this build!"); return; } mappingFile = new File("mappings.csrg"); if (mappingFile.exists()) { if (!mappingFile.isDirectory()) { - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Pre-downloaded mapping detected! Using it. If anything went wrong, please try deleting " + ChatColor.DARK_GRAY + mappingFile.getAbsolutePath() + ChatColor.YELLOW + " and try again"); + log.info("[!] Pre-downloaded mapping detected! Using it. If anything went wrong, please try deleting {}{}{} and try again", ChatColor.DARK_GRAY, mappingFile.getAbsolutePath(), ChatColor.YELLOW); return; } mappingFile.delete(); } File buildDataDir = new File(Paths.get("cache/mixins/").toFile(), "BuildData"); - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Fetching BuildData version from Spigot API..."); + log.info("[!] Fetching BuildData version from Spigot API..."); Gson gson = new Gson(); URLConnection connection = null; try { @@ -87,19 +90,19 @@ private static void prepareMapping() { } String buildDataVersion = object.get("refs").getAsJsonObject().get("BuildData").getAsString(); Git buildData = null; - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Fetched BuildData Version: " + buildDataVersion + "!"); + log.info("[!] Fetched BuildData Version: {}!", buildDataVersion); if (buildDataDir.exists()) { - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Found Spigot's BuildData cache at " + buildDataDir.getAbsolutePath() + "! Doing some simple verification..."); + log.info("[!] Found Spigot's BuildData cache at {}! Doing some simple verification...", buildDataDir.getAbsolutePath()); try { buildData = Git.open(buildDataDir); - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Verified! Updating BuildData..."); + log.info("[!] Verified! Updating BuildData..."); buildData.pull().call(); } catch (Exception e) { buildDataDir.delete(); } } if (!buildDataDir.exists()) { - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Cloning Spigot's BuildData repository to " + buildDataDir.getAbsolutePath() + " . It should take a while (Usually around 35 MB), but it's a one time process (across every server)"); + log.info("[!] Cloning Spigot's BuildData repository to {} . It should take a while (Usually around 35 MB), but it's a one time process (across every server)", buildDataDir.getAbsolutePath()); try { buildData = Git.cloneRepository().setURI("https://hub.spigotmc.org/stash/scm/spigot/builddata.git").setDirectory(buildDataDir).call(); } catch (GitAPIException e) { @@ -107,30 +110,30 @@ private static void prepareMapping() { } } - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Successfully fetched BuildData! Switching to " + buildDataVersion); + log.info("[!] Successfully fetched BuildData! Switching to {}", buildDataVersion); try { buildData.checkout().setName(buildDataVersion).call(); } catch (GitAPIException e) { throw new RuntimeException(e); } - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Checking version info..."); + log.info("[!] Checking version info..."); VersionInfo versionInfo = null; try { versionInfo = gson.fromJson(new FileReader(new File(buildDataDir, "info.json")), VersionInfo.class); } catch (FileNotFoundException e) { throw new RuntimeException(e); } - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Scanning for members mapping..."); + log.info("[!] Scanning for members mapping..."); File classMappings = new File(buildDataDir, "mappings/" + versionInfo.classMappings); if (versionInfo.memberMappings == null) { - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Didn't find a members mapping! Building one..."); + log.info("[!] Didn't find a members mapping! Building one..."); MapUtil mapUtil = new MapUtil(); try { mapUtil.loadBuk(classMappings); } catch (IOException e) { throw new RuntimeException(e); } - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Downloading Minecraft's Mappings & Building Members Mappings..."); + log.info("[!] Downloading Minecraft's Mappings & Building Members Mappings..."); InputStream inputStream = null; try { inputStream = new URL(versionInfo.mappingsUrl).openConnection().getInputStream(); @@ -154,7 +157,7 @@ private static void prepareMapping() { throw new RuntimeException(e); } } else { - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Found a pre-built members mapping! Extracting..."); + log.info("[!] Found a pre-built members mapping! Extracting..."); try { mappingFile.createNewFile(); } catch (IOException e) { @@ -166,7 +169,7 @@ private static void prepareMapping() { throw new RuntimeException(e); } } - Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[!] Finished loading mappings!"); + log.info("[!] Finished loading mappings!"); } diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/MixinPlugin.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/MixinPlugin.java index cbd7e6b75..b308dfdee 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/MixinPlugin.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/MixinPlugin.java @@ -1,6 +1,7 @@ package com.dragoncommissions.mixbukkit.api; import com.dragoncommissions.mixbukkit.MixBukkit; +import com.dragoncommissions.mixbukkit.MixinPluginInstance; import com.dragoncommissions.mixbukkit.agent.ClassesManager; import com.dragoncommissions.mixbukkit.api.action.MixinAction; import com.dragoncommissions.mixbukkit.utils.ASMUtils; @@ -9,7 +10,6 @@ import lombok.SneakyThrows; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.plugin.Plugin; import org.objectweb.asm.ClassReader; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; @@ -35,11 +35,11 @@ public class MixinPlugin { @Getter private final ObfMap obfMap; @Getter - private final Plugin plugin; + private final MixinPluginInstance plugin; private final List registeredMixins = new ArrayList<>(); - public MixinPlugin(Plugin plugin, ObfMap obfMap) { + public MixinPlugin(MixinPluginInstance plugin, ObfMap obfMap) { this.plugin = plugin; this.obfMap = obfMap; } @@ -102,7 +102,7 @@ public boolean registerMixin(String namespace, MixinAction mixinAction, Class ClassNode classNode = ClassesManager.getClassNode(owner.getName()); if (classNode == null) { - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Failed to load mixin: " + plugin.getName() + ":" + namespace + ", Reason: Could not find the target class: " + owner.getName()); + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Failed to load mixin: " + plugin.name() + ":" + namespace + ", Reason: Could not find the target class: " + owner.getName()); return false; } PrintWriter printWriter = new PrintWriter(MixBukkit.ERROR_OUTPUT_STREAM, true); @@ -134,10 +134,10 @@ public void write(int b) throws IOException { CheckClassAdapter.verify(classReader, getClass().getClassLoader().getParent(), false, printWriter); } if (MixBukkit.SAFE_MODE) { - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Failed to load mixin: " + plugin.getName() + ":" + namespace + ", Reason: Invalid Bytecode, and safe-mode is on"); + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Failed to load mixin: " + plugin.name() + ":" + namespace + ", Reason: Invalid Bytecode, and safe-mode is on"); return false; } else { - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[?] Mixin: " + plugin.getName() + ":" + namespace + " has failed the verification, and it might crash your server! Be careful."); + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[?] Mixin: " + plugin.name() + ":" + namespace + " has failed the verification, and it might crash your server! Be careful."); } } @@ -147,13 +147,13 @@ public void write(int b) throws IOException { ClassesManager.classes.put(owner.getName(), data); } catch (Exception e) { e.printStackTrace(); - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Failed to load mixin: " + plugin.getName() + ":" + namespace + ", Reason: Could not redefine class: " + owner.getSimpleName()); + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Failed to load mixin: " + plugin.name() + ":" + namespace + ", Reason: Could not redefine class: " + owner.getSimpleName()); } registeredMixins.add(namespace); return true; } } - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Failed to load mixin: " + plugin.getName() + ":" + namespace + ", Reason: Could not find the target method"); + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Failed to load mixin: " + plugin.name() + ":" + namespace + ", Reason: Could not find the target method"); return false; } diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionCallSuper.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionCallSuper.java index 5c4cc3919..778ae4066 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionCallSuper.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionCallSuper.java @@ -5,22 +5,18 @@ import com.dragoncommissions.mixbukkit.api.shellcode.impl.inner.IShellCodeMethodInvoke; import com.dragoncommissions.mixbukkit.utils.ASMUtils; import javassist.bytecode.Opcode; +import org.jetbrains.annotations.NotNull; import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.VarInsnNode; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -public class MActionCallSuper implements MixinAction { +public record MActionCallSuper(MixinPlugin plugin) implements MixinAction { - private final MixinPlugin plugin; - - public MActionCallSuper(MixinPlugin plugin) { - this.plugin = plugin; - } @Override - public void action(Class owner, MethodNode method) { + public void action(@NotNull Class owner, MethodNode method) { Method m = null; Method superMethod = null; for (Method declaredMethod : owner.getDeclaredMethods()) { diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionInsertShellCode.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionInsertShellCode.java index a27fc1094..269cdf181 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionInsertShellCode.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionInsertShellCode.java @@ -4,8 +4,6 @@ import com.dragoncommissions.mixbukkit.api.locator.HookLocator; import com.dragoncommissions.mixbukkit.api.shellcode.LocalVarManager; import com.dragoncommissions.mixbukkit.api.shellcode.ShellCode; -import lombok.AllArgsConstructor; -import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.objectweb.asm.tree.InsnList; @@ -13,17 +11,7 @@ import java.util.List; -@AllArgsConstructor -@Getter -public class MActionInsertShellCode implements MixinAction { - - private final ShellCode shellCode; - private final HookLocator hookLocator; - - public MActionInsertShellCode(ShellCode shellCode, HookLocator hookLocator) { - this.shellCode = shellCode; - this.hookLocator = hookLocator; - } +public record MActionInsertShellCode(ShellCode shellCode, HookLocator hookLocator) implements MixinAction { @Override public void action(Class owner, MethodNode method) { @@ -42,8 +30,8 @@ public void action(Class owner, MethodNode method) { newInstructions.add(instructions); newInstructions.add(shellCode.popExtraStack()); } catch (Exception e) { - e.printStackTrace(); Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Shell Code \"" + ChatColor.YELLOW + shellCode.getShellCodeInfo().name() + ChatColor.RED + "\" has failed generating instructions: Exception Thrown"); + e.printStackTrace(); } } else { Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Shell Code \"" + ChatColor.YELLOW + shellCode.getShellCodeInfo().name() + ChatColor.RED + "\" shouldn't be called directly (calledDirectly = false)"); diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionMethodCallSpoofer.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionMethodCallSpoofer.java index 70e81e074..486bcbef9 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionMethodCallSpoofer.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionMethodCallSpoofer.java @@ -5,6 +5,7 @@ import com.dragoncommissions.mixbukkit.utils.ASMUtils; import javassist.bytecode.Opcode; import lombok.SneakyThrows; +import org.jetbrains.annotations.NotNull; import org.objectweb.asm.tree.*; import java.lang.reflect.Method; @@ -21,7 +22,7 @@ public class MActionMethodCallSpoofer implements MixinAction { private final String key; private Predicate filter; - private MActionMethodCallSpoofer(Method method, ReturnValueGetter returnValueGetter, Predicate filter) { + private MActionMethodCallSpoofer(@NotNull Method method, ReturnValueGetter returnValueGetter, Predicate filter) { this.method = method; if (method.getReturnType() == void.class) throw new IllegalArgumentException("Method: " + method.getName() + " is not returning anything. Nothing to spoof"); diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionMethodReplacer.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionMethodReplacer.java index de557cc77..365c2cb86 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionMethodReplacer.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionMethodReplacer.java @@ -6,23 +6,18 @@ import com.dragoncommissions.mixbukkit.utils.ASMUtils; import javassist.bytecode.Opcode; import lombok.SneakyThrows; +import org.jetbrains.annotations.NotNull; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.InsnNode; import org.objectweb.asm.tree.MethodNode; import java.lang.reflect.Method; -public class MActionMethodReplacer implements MixinAction { - - private final Method handler; - - public MActionMethodReplacer(Method handler) { - this.handler = handler; - } +public record MActionMethodReplacer(Method handler) implements MixinAction { @Override @SneakyThrows - public void action(Class owner, MethodNode methodNode) { + public void action(Class owner, @NotNull MethodNode methodNode) { methodNode.tryCatchBlocks.clear(); methodNode.localVariables.clear(); methodNode.instructions.clear(); diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionPipeline.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionPipeline.java index a92ca5258..b617f0fd0 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionPipeline.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionPipeline.java @@ -3,13 +3,7 @@ import com.dragoncommissions.mixbukkit.api.action.MixinAction; import org.objectweb.asm.tree.MethodNode; -public class MActionPipeline implements MixinAction { - - private final MixinAction[] actions; - - public MActionPipeline(MixinAction... actions) { - this.actions = actions; - } +public record MActionPipeline(MixinAction... actions) implements MixinAction { @Override public void action(Class owner, MethodNode method) { @@ -17,4 +11,5 @@ public void action(Class owner, MethodNode method) { action.action(owner, method); } } + } diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldAccess.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldAccess.java index dfb2d73cb..0239ffe6a 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldAccess.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldAccess.java @@ -13,7 +13,6 @@ import java.util.List; import java.util.function.Predicate; -@AllArgsConstructor public class HLocatorFieldAccess implements HookLocator { private final Field field; diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldRead.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldRead.java index 9be2a153d..c4b981215 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldRead.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldRead.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.function.Predicate; -@AllArgsConstructor public class HLocatorFieldRead implements HookLocator { private final Field field; diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldWrite.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldWrite.java index 76e938b5a..2873cb5c4 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldWrite.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/locator/impl/HLocatorFieldWrite.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.function.Predicate; -@AllArgsConstructor public class HLocatorFieldWrite implements HookLocator { private final Field field; diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/shellcode/impl/inner/IShellCodeLoadClassFromPCL.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/shellcode/impl/inner/IShellCodeLoadClassFromPCL.java index b6fbe3b8f..1f20db7a6 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/shellcode/impl/inner/IShellCodeLoadClassFromPCL.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/api/shellcode/impl/inner/IShellCodeLoadClassFromPCL.java @@ -3,14 +3,23 @@ import com.dragoncommissions.mixbukkit.api.shellcode.LocalVarManager; import com.dragoncommissions.mixbukkit.api.shellcode.ShellCode; import com.dragoncommissions.mixbukkit.api.shellcode.ShellCodeInfo; -import javassist.bytecode.Opcode; +import com.dragoncommissions.mixbukkit.utils.ASMUtils; +import io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler; +import io.papermc.paper.plugin.provider.PluginProvider; +import io.papermc.paper.plugin.provider.type.paper.PaperPluginParent; +import io.papermc.paper.plugin.storage.SimpleProviderStorage; import lombok.SneakyThrows; -import org.bukkit.Bukkit; -import org.bukkit.plugin.PluginManager; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.InsnNode; -import org.objectweb.asm.tree.LdcInsnNode; -import org.objectweb.asm.tree.MethodNode; +import org.jetbrains.annotations.NotNull; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.*; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; @ShellCodeInfo( name = "Load Class From Plugin Class Loader", @@ -21,12 +30,13 @@ public class IShellCodeLoadClassFromPCL extends ShellCode { private final String name; + private boolean isLast = false; - public IShellCodeLoadClassFromPCL(String className) { + public IShellCodeLoadClassFromPCL(@NotNull String className) { this.name = className.replace("/", "."); } - public IShellCodeLoadClassFromPCL(Class clazz) { + public IShellCodeLoadClassFromPCL(@NotNull Class clazz) { this.name = clazz.getName(); } @@ -36,33 +46,76 @@ public InsnList generate(MethodNode methodNode, LocalVarManager varManager) { InsnList out = new InsnList(); out.add(new LdcInsnNode(name)); out.add(new IShellCodePushInt(1).generate()); // true + try { - out.add(new IShellCodeMethodInvoke(Bukkit.class.getDeclaredMethod("getPluginManager")).generate()); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - try { - out.add(new IShellCodeMethodInvoke(PluginManager.class.getDeclaredMethod("getPlugins")).generate()); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - out.add(new IShellCodePushInt(0).generate()); - out.add(new InsnNode(Opcode.AALOAD)); - try { - out.add(new IShellCodeMethodInvoke(Object.class.getDeclaredMethod("getClass")).generate()); - } catch (NoSuchMethodException e) { + isLast = ((ArrayList) ((SimpleProviderStorage) LaunchEntryPointHandler.INSTANCE.getStorage().values().stream().toList().getLast()).getRegisteredProviders()).getLast() instanceof PaperPluginParent.PaperBootstrapProvider; + // ((PluginProvider)((ArrayList)LaunchEntryPointHandler.INSTANCE.getStorage().values().stream().toList().getFirst().getRegisteredProviders()).getFirst()).createInstance(); + out.add(new IShellCodeFieldAccess(LaunchEntryPointHandler.class.getField("INSTANCE"), false).generate()); + out.add(new IShellCodeMethodInvoke(LaunchEntryPointHandler.class.getMethod("getStorage")).generate()); + out.add(new IShellCodeMethodInvoke(Map.class.getMethod("values")).generate()); + out.add(new IShellCodeMethodInvoke(Collection.class.getMethod("stream")).generate()); + out.add(new IShellCodeMethodInvoke(Stream.class.getMethod("toList")).generate()); + out.add(new IShellCodeMethodInvoke( + List.class.getMethod(isLast ? "getLast" : "getFirst") + ).generate()); + out.add(new TypeInsnNode(Opcodes.CHECKCAST, "io/papermc/paper/plugin/storage/SimpleProviderStorage")); + out.add(new IShellCodeMethodInvoke(SimpleProviderStorage.class.getMethod("getRegisteredProviders")).generate()); + out.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/util/ArrayList")); + out.add(new IShellCodeMethodInvoke(ArrayList.class.getMethod("getLast")).generate()); + out.add(new IShellCodeMethodInvoke(PluginProvider.class.getMethod("createInstance")).generate()); + out.add(new IShellCodeMethodInvoke( + Object.class.getDeclaredMethod("getClass") + ).generate()); + out.add(new IShellCodeMethodInvoke( + Class.class.getDeclaredMethod("getClassLoader") + ).generate()); + out.add(new IShellCodeMethodInvoke( + Class.class.getDeclaredMethod("forName", String.class, boolean.class, ClassLoader.class) + ).generate()); + + } catch (NoSuchMethodException | NoSuchFieldException e) { throw new RuntimeException(e); } - try { - out.add(new IShellCodeMethodInvoke(Class.class.getDeclaredMethod("getClassLoader")).generate()); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); + + return out; + } + + @ShellCodeInfo( + name = "Field Invoke", + description = "Call fields programmatically", + stacksContent = {"Return value of invoked field"}, + requiredStacksContent = {"Object that calls the field", "Arguments (in order)"} + ) + public static class IShellCodeFieldAccess extends ShellCode { + + private final Field field; + private final boolean isSetOperation; + + public IShellCodeFieldAccess(Field field, boolean isSetOperation) { + this.field = field; + this.isSetOperation = isSetOperation; } - try { - out.add(new IShellCodeMethodInvoke(Class.class.getDeclaredMethod("forName", String.class, boolean.class, ClassLoader.class)).generate()); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); + + @Override + public InsnList generate(MethodNode methodNode, LocalVarManager varManager) { + InsnList list = new InsnList(); + + int opcode; + if (Modifier.isStatic(field.getModifiers())) { + opcode = isSetOperation ? Opcodes.PUTSTATIC : Opcodes.GETSTATIC; + } else { + opcode = isSetOperation ? Opcodes.PUTFIELD : Opcodes.GETFIELD; + } + + ASMUtils.getDescriptor(field.getType()); + list.add(new FieldInsnNode( + opcode, + field.getDeclaringClass().getName().replace(".", "/"), + field.getName(), + ASMUtils.getFieldDescriptor(field.getType()) + )); + + return list; } - return out; } } diff --git a/mixin/src/main/java/com/dragoncommissions/mixbukkit/utils/ASMUtils.java b/mixin/src/main/java/com/dragoncommissions/mixbukkit/utils/ASMUtils.java index 50b27e9f4..456056e46 100644 --- a/mixin/src/main/java/com/dragoncommissions/mixbukkit/utils/ASMUtils.java +++ b/mixin/src/main/java/com/dragoncommissions/mixbukkit/utils/ASMUtils.java @@ -62,6 +62,35 @@ public static String getDescriptor(Class returnType, Class... arguments) { return out.toString(); } + public static String getFieldDescriptor(Class fieldType) { + return toDescriptorTypeName(fieldType); + } + + private static String toDescriptorTypeName(Class type) { + if (type.isArray()) { + return '[' + toDescriptorTypeName(type.getComponentType()); + } else if (type == void.class) { + return "V"; + } else if (type == boolean.class) { + return "Z"; + } else if (type == byte.class) { + return "B"; + } else if (type == char.class) { + return "C"; + } else if (type == double.class) { + return "D"; + } else if (type == float.class) { + return "F"; + } else if (type == int.class) { + return "I"; + } else if (type == long.class) { + return "J"; + } else if (type == short.class) { + return "S"; + } else { + return 'L' + type.getName().replace('.', '/') + ';'; + } + } @SneakyThrows public static AbstractInsnNode loadVar(Class type, int varNumber) { @@ -140,7 +169,7 @@ public static byte[] fromClassNode(ClassNode node) { if (MixBukkit.WRITE_TRANSFORMED_CLASS) { try { - Path mixinOut = Paths.get("cache/mixin/output"); + Path mixinOut = Paths.get("cache/mixins/output"); if (!mixinOut.toFile().exists()) { mixinOut.toFile().mkdirs(); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/Bootstrap.java b/origins/src/main/java/io/github/dueris/originspaper/Bootstrap.java index c585b6ef3..64dc5d182 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/Bootstrap.java +++ b/origins/src/main/java/io/github/dueris/originspaper/Bootstrap.java @@ -1,198 +1,29 @@ package io.github.dueris.originspaper; -import com.dragoncommissions.mixbukkit.MixBukkit; -import com.mojang.brigadier.CommandDispatcher; -import io.github.dueris.calio.parser.CalioParser; -import io.github.dueris.calio.parser.JsonObjectRemapper; -import io.github.dueris.originspaper.command.Commands; -import io.github.dueris.originspaper.content.NMSBootstrap; -import io.github.dueris.originspaper.power.FireProjectilePower; -import io.github.dueris.originspaper.registry.Registries; +import io.github.dueris.originspaper.registry.nms.OriginLootCondition; +import io.github.dueris.originspaper.registry.nms.PowerLootCondition; import io.github.dueris.originspaper.util.WrappedBootstrapContext; -import io.papermc.paper.command.brigadier.ApiMirrorRootNode; -import io.papermc.paper.command.brigadier.CommandSourceStack; -import io.papermc.paper.command.brigadier.PaperCommands; import io.papermc.paper.plugin.bootstrap.BootstrapContext; import io.papermc.paper.plugin.bootstrap.PluginBootstrap; -import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager; -import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; -import net.minecraft.util.Tuple; -import org.bukkit.configuration.file.YamlConfiguration; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.Nullable; -import java.io.*; -import java.net.URLClassLoader; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.security.ProtectionDomain; -import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - public class Bootstrap implements PluginBootstrap { - public static ArrayList> apiCalls = new ArrayList<>(); - public static AtomicBoolean BOOTSTRAPPED = new AtomicBoolean(false); - public static AtomicReference MIXIN_LOADER = new AtomicReference<>(); - - public static void copyOriginDatapack(Path datapackPath) { - String jarPath = getJarPath(); - if (jarPath == null) { - System.err.println("Could not determine JAR file path."); - return; - } - String outputDir = datapackPath.toAbsolutePath().toString(); - String resourceDir = "minecraft/"; - try { - extractResources(jarPath, outputDir, resourceDir); - } catch (IOException e) { - throw new RuntimeException(e); - } - System.out.println("Resources extracted successfully."); - } - - public static void extractResources(String jarPath, String outputDir, String resourceDir) throws IOException { - try (JarFile jar = new JarFile(jarPath)) { - Enumeration entries = jar.entries(); - while (entries.hasMoreElements()) { - JarEntry entry = entries.nextElement(); - if (entry.getName().startsWith(resourceDir) && !entry.isDirectory()) { - File file = new File(outputDir, entry.getName().substring(resourceDir.length())); - File parent = file.getParentFile(); - if (parent != null && !parent.exists()) { - parent.mkdirs(); - } - try (InputStream is = jar.getInputStream(entry); - OutputStream os = Files.newOutputStream(file.toPath())) { - byte[] buffer = new byte[1024]; - int bytesRead; - while ((bytesRead = is.read(buffer)) != -1) { - os.write(buffer, 0, bytesRead); - } - } - } - } - } - } - - public static @Nullable String getJarPath() { - ProtectionDomain protectionDomain = Bootstrap.class.getProtectionDomain(); - File jarFile = null; - try { - jarFile = new File(protectionDomain.getCodeSource().getLocation().toURI()); - } catch (Exception e) { - e.printStackTrace(); - } - return jarFile != null ? jarFile.getAbsolutePath() : null; - } - - public static String levelNameProp() { - Path propPath = Paths.get("server.properties"); - if (propPath.toFile().exists()) { - Properties properties = new Properties(); - - try (FileInputStream input = new FileInputStream(propPath.toFile())) { - properties.load(input); - } catch (IOException e) { - e.printStackTrace(); - } - - System.out.println(properties.keySet()); - return properties.getProperty("level-name", "world"); - } else { - return "world"; - } - } @Override + @SuppressWarnings("unchecked") public void bootstrap(@Nullable BootstrapContext bootContext) { WrappedBootstrapContext context = new WrappedBootstrapContext(bootContext); - if (bootContext != null) { - NMSBootstrap.bootstrap(context); - - for (Consumer apiCall : apiCalls) { - apiCall.accept(context); - } - - File packDir = null; + context.registerBuiltin(BuiltInRegistries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath("apoli", "power"), PowerLootCondition.TYPE); + context.registerBuiltin(BuiltInRegistries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath("origins", "origin"), OriginLootCondition.TYPE); - try { - packDir = new File(this.parseDatapackPath()); - copyOriginDatapack(packDir.toPath()); - } catch (Exception ignored) { - } finally { - if (packDir != null) { - context.initRegistries(packDir.toPath()); - } - } + try { +// ((PluginProvider)((LinkedList)LaunchEntryPointHandler.INSTANCE.get(Entrypoint.BOOTSTRAPPER).getRegisteredProviders()).getFirst()).createInstance(); + OriginsPaper.init(context); + } catch (Throwable e) { + throw new RuntimeException("An error occurred when loading OriginsPaper!", e); } - - LifecycleEventManager lifecycleManager = context.context().getLifecycleManager(); - lifecycleManager.registerEventHandler((LifecycleEvents.COMMANDS.newHandler(event -> { - CommandDispatcher commands = PaperCommands.INSTANCE.getDispatcher(); - Commands.bootstrap(((ApiMirrorRootNode) commands.getRoot()).getDispatcher()); - })).priority(10)); - - io.github.dueris.calio.parser.JsonObjectRemapper remapper = new io.github.dueris.calio.parser.JsonObjectRemapper( - List.of( - new Tuple<>("origins", "apoli") - ), - List.of( - new Tuple<>("apoli:restrict_armor", "apoli:conditioned_restrict_armor"), - new Tuple<>("apoli:has_tag", "apoli:has_command_tag"), - new Tuple<>("apoli:custom_data", "apoli:nbt"), - new Tuple<>("apoli:is_equippable", "apoli:equippable"), - new Tuple<>("apoli:fireproof", "apoli:fire_resistant"), - new Tuple<>("apoli:merge_nbt", "apoli:merge_custom_data"), - new Tuple<>("apoli:revoke_power", "apoli:remove_power"), - new Tuple<>("apoli:water_protection", "origins:water_protection"), // fix water protection in namespace aliases - new Tuple<>("apoli:enderian_pearl", "minecraft:ender_pearl") - ), - List.of( - "power_type", "type", "entity_type" - ) - ); - JsonObjectRemapper.PRE_REMAP_HOOK.add(new Tuple<>( - "apoli:enderian_pearl", - (tuple) -> { - FireProjectilePower.IS_ENDERIAN_PEARL.add(tuple.getB()); - } - )); - CalioParser.REMAPPER.set(remapper); - context.createRegistries( - Registries.ORIGIN, - Registries.LAYER, - Registries.CRAFT_POWER, - Registries.FLUID_CONDITION, - Registries.ENTITY_CONDITION, - Registries.BIOME_CONDITION, - Registries.BIENTITY_CONDITION, - Registries.BLOCK_CONDITION, - Registries.ITEM_CONDITION, - Registries.DAMAGE_CONDITION, - Registries.ENTITY_ACTION, - Registries.ITEM_ACTION, - Registries.BLOCK_ACTION, - Registries.BIENTITY_ACTION, - Registries.LANG, - Registries.CHOOSING_PAGE - ); - - MixBukkit bukkit = new MixBukkit(); - bukkit.onEnable(context.LOGGER, bootContext.getPluginSource().toFile(), (URLClassLoader) this.getClass().getClassLoader()); - - MIXIN_LOADER.set(bukkit); - BOOTSTRAPPED.set(true); } - public String parseDatapackPath() { - YamlConfiguration bukkitConfiguration = YamlConfiguration.loadConfiguration(Paths.get("bukkit.yml").toFile()); - File container = new File(bukkitConfiguration.getString("settings.world-container", ".")); - String s = Optional.ofNullable(levelNameProp()).orElse("world"); - Path datapackFolder = Paths.get(container.getAbsolutePath() + File.separator + s + File.separator + "datapacks"); - return datapackFolder.toString(); - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/Factory.java b/origins/src/main/java/io/github/dueris/originspaper/Factory.java index 49954a140..d8ea60d98 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/Factory.java +++ b/origins/src/main/java/io/github/dueris/originspaper/Factory.java @@ -1,6 +1,6 @@ package io.github.dueris.originspaper; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import net.minecraft.resources.ResourceLocation; public interface Factory { diff --git a/origins/src/main/java/io/github/dueris/originspaper/OriginScheduler.java b/origins/src/main/java/io/github/dueris/originspaper/OriginScheduler.java deleted file mode 100644 index 52b7ec145..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/OriginScheduler.java +++ /dev/null @@ -1,89 +0,0 @@ -package io.github.dueris.originspaper; - -import io.github.dueris.originspaper.power.CreativeFlightPower; -import io.github.dueris.originspaper.power.PowerType; -import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.storage.PowerHolderComponent; -import net.minecraft.world.entity.player.Player; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.Arrays; -import java.util.concurrent.ConcurrentLinkedQueue; - -public class OriginScheduler { - final Plugin plugin; - private final ConcurrentLinkedQueue mainThreadCalls = new ConcurrentLinkedQueue<>(); - - public OriginScheduler(Plugin plugin) { - this.plugin = plugin; - } - - public void scheduleMainThreadCall(Runnable run) { - this.mainThreadCalls.add(run); - } - - public static class MainTickerThread extends BukkitRunnable implements Listener { - public OriginScheduler parent = new OriginScheduler(OriginsPaper.getPlugin()); - - public String toString() { - return "OriginSchedulerTree$run()"; - } - - public void run() { - this.parent.mainThreadCalls.forEach(Runnable::run); - this.parent.mainThreadCalls.clear(); - - for (PowerType power : OriginsPaper.getPlugin().registry.retrieve(Registries.CRAFT_POWER).values()) { - power.tick(); - if (power.hasPlayers()) { - for (Player p : power.getPlayers()) { - if (Bukkit.getServer().getCurrentTick() % 20 == 0) { - PowerHolderComponent.checkForDuplicates((CraftPlayer) p.getBukkitEntity()); - } - - try { - if (power.shouldTick()) { - power.tick(p); - } - } catch (Throwable var8) { - String[] stacktrace = new String[]{"\n"}; - Arrays.stream(var8.getStackTrace()) - .map(StackTraceElement::toString) - .forEach(string -> stacktrace[0] = stacktrace[0] + "\tat " + string + "\n"); - OriginsPaper.getPlugin() - .getLog4JLogger() - .error("An unhandled exception occurred when ticking a Power! [{}]", var8.getClass().getSimpleName()); - String t = power.getType(); - if (t == null) { - t = power.key().toString(); - } - - OriginsPaper.getPlugin() - .getLog4JLogger() - .error("Player: {} | Power: {} | CraftPower: {} | Throwable: {} {}", p.getName(), power.getTag(), t, var8.getMessage() == null ? var8.getClass().getSimpleName() : var8.getMessage(), stacktrace[0]); - } - } - } - } - } - - public void tickAsyncScheduler() { - for (org.bukkit.entity.Player p : Bukkit.getOnlinePlayers()) { - for (PowerType c : PowerHolderComponent.getPowersApplied(p)) { - c.tickAsync(((CraftPlayer) p).getHandle()); - } - } - - for (org.bukkit.entity.Player p : Bukkit.getOnlinePlayers()) { - CreativeFlightPower.tickPlayer(((CraftPlayer) p).getHandle(), null); -// if (!PowerHolderComponent.hasPowerType(p, GravityPower.class) && !PowerHolderComponent.hasPower(p, "origins:like_water")) { -// p.setGravity(true); -// } - } - } - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/OriginsPaper.java b/origins/src/main/java/io/github/dueris/originspaper/OriginsPaper.java index e9cc7bcc8..fb6315c54 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/OriginsPaper.java +++ b/origins/src/main/java/io/github/dueris/originspaper/OriginsPaper.java @@ -1,107 +1,60 @@ package io.github.dueris.originspaper; -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.tree.CommandNode; -import io.github.dueris.calio.data.AccessorKey; -import io.github.dueris.calio.parser.ParsingStrategy; +import com.dragoncommissions.mixbukkit.MixBukkit; +import io.github.dueris.calio.parser.CalioParser; +import io.github.dueris.calio.parser.JsonObjectRemapper; import io.github.dueris.calio.registry.IRegistry; import io.github.dueris.calio.registry.impl.CalioRegistry; -import io.github.dueris.originspaper.action.ActionTypes; -import io.github.dueris.originspaper.command.Commands; +import io.github.dueris.originspaper.action.factory.BiEntityActions; +import io.github.dueris.originspaper.action.factory.BlockActions; +import io.github.dueris.originspaper.action.factory.EntityActions; +import io.github.dueris.originspaper.action.factory.ItemActions; import io.github.dueris.originspaper.command.OriginCommand; -import io.github.dueris.originspaper.condition.ConditionTypes; -import io.github.dueris.originspaper.condition.types.BiEntityConditions; -import io.github.dueris.originspaper.content.OrbOfOrigins; +import io.github.dueris.originspaper.command.PowerCommand; +import io.github.dueris.originspaper.command.ResourceCommand; +import io.github.dueris.originspaper.condition.factory.*; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.OriginsDataTypes; import io.github.dueris.originspaper.data.types.modifier.ModifierOperations; -import io.github.dueris.originspaper.integration.CraftPehuki; import io.github.dueris.originspaper.mixin.OriginsMixins; import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; -import io.github.dueris.originspaper.power.PowerType; -import io.github.dueris.originspaper.power.RecipePower; -import io.github.dueris.originspaper.registry.BuiltinRegistry; +import io.github.dueris.originspaper.plugin.OriginsPlugin; +import io.github.dueris.originspaper.power.type.FireProjectilePower; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.screen.ChoosingPage; -import io.github.dueris.originspaper.screen.GuiTicker; -import io.github.dueris.originspaper.screen.RandomOriginPage; -import io.github.dueris.originspaper.screen.ScreenNavigator; import io.github.dueris.originspaper.storage.OriginConfiguration; -import io.github.dueris.originspaper.storage.PlayerPowerRepository; -import io.github.dueris.originspaper.storage.PowerHolderComponent; -import io.github.dueris.originspaper.util.*; -import io.github.dueris.originspaper.util.entity.GlowingEntitiesUtils; -import io.github.dueris.originspaper.util.entity.PlayerManager; -import io.papermc.paper.event.player.PlayerFailMoveEvent; -import io.papermc.paper.plugin.configuration.PluginMeta; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.TextColor; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.nbt.CompoundTag; +import io.github.dueris.originspaper.util.LangFile; +import io.github.dueris.originspaper.util.Renderer; +import io.github.dueris.originspaper.util.Util; +import io.github.dueris.originspaper.util.WrappedBootstrapContext; +import io.papermc.paper.ServerBuildInfo; +import io.papermc.paper.plugin.bootstrap.BootstrapContext; +import io.papermc.paper.plugin.entrypoint.classloader.PaperPluginClassLoader; +import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager; +import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; -import org.bukkit.Bukkit; -import org.bukkit.NamespacedKey; -import org.bukkit.configuration.InvalidConfigurationException; +import net.minecraft.util.Tuple; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.server.ServerLoadEvent; -import org.bukkit.persistence.PersistentDataType; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; +import java.io.StringReader; +import java.nio.file.Path; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Consumer; -public final class OriginsPaper extends JavaPlugin implements Listener { - public static final boolean isFolia = classExists("io.papermc.paper.threadedregions.RegionizedServer"); - public static final boolean isExpandedScheduler = classExists("io.papermc.paper.threadedregions.scheduler.ScheduledTask"); - public static List preShutdownTasks = new ArrayList<>(); - public static GlowingEntitiesUtils glowingEntitiesUtils; - public static BstatsMetrics metrics; - public static String apoliVersion = "2.12.0-alpha.9+mc.1.21.x"; +public class OriginsPaper { + public static final Logger LOGGER = LogManager.getLogger("OriginsPaper"); public static String LANGUAGE = "en_us"; public static boolean showCommandOutput = false; - public static File playerDataFolder; - public static boolean forceUseCurrentVersion = false; - public static OriginScheduler.MainTickerThread scheduler = null; - public static String version = Bukkit.getVersion().split("\\(MC: ")[1].replace(")", ""); - public static boolean isCompatible = false; - public static String pluginVersion; - public static String world_container; - public static ArrayList versions = new ArrayList<>(); public static MinecraftServer server; - public static Origin EMPTY_ORIGIN; - private static OriginsPaper plugin; - public IRegistry registry; - - public OriginsPaper() { - if (!Bootstrap.BOOTSTRAPPED.get()) { - Bootstrap bootstrap = new Bootstrap(); - bootstrap.bootstrap(null); - } - - Bootstrap.BOOTSTRAPPED.set(false); - - plugin = this; - OriginsMixins.init(Bootstrap.MIXIN_LOADER.get()); - } - - public static OriginScheduler.MainTickerThread getScheduler() { - return scheduler; - } + public static PluginData pluginData; + public static Path jarFile; + private static WrappedBootstrapContext context; public static @NotNull ResourceLocation identifier(String path) { return ResourceLocation.fromNamespaceAndPath("originspaper", path); @@ -116,260 +69,157 @@ public static OriginScheduler.MainTickerThread getScheduler() { } public static OriginLayer getLayer(ResourceLocation location) { - return OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).get(location); + return getRegistry().retrieve(Registries.LAYER).get(location); } public static PowerType getPower(ResourceLocation location) { - return OriginsPaper.getPlugin().registry.retrieve(Registries.CRAFT_POWER).get(location); + return getRegistry().retrieve(Registries.POWER).get(location); } public static Origin getOrigin(ResourceLocation location) { - return OriginsPaper.getPlugin().registry.retrieve(Registries.ORIGIN).get(location); - } - - private static void patchPowers() { - for (Player p : Bukkit.getOnlinePlayers()) { - PowerHolderComponent.loadPowers(p); - } + return getRegistry().retrieve(Registries.ORIGIN).get(location); } - public static OriginsPaper getPlugin() { - return plugin; + public static IRegistry getRegistry() { + return CalioRegistry.INSTANCE; } - public static boolean classExists(String className) { - try { - Class.forName(className); - return true; - } catch (ClassNotFoundException var2) { - return false; - } + public static OriginsPlugin getPlugin() { + return OriginsPlugin.plugin; } - public void finalizePreboot() { - PluginMeta meta = this.getPluginMeta(); - if (meta == null) { - throw new RuntimeException("PluginMeta was null?"); - } else { - pluginVersion = meta.getVersion().split("-")[1]; + public static void init(@NotNull WrappedBootstrapContext context) throws Throwable { + pluginData = new PluginData(YamlConfiguration.loadConfiguration(new StringReader(Util.readResource("/paper-plugin.yml")))); + jarFile = context.context().getPluginSource(); + OriginsPaper.context = context; - try (InputStream stream = this.getClass().getClassLoader().getResourceAsStream("paper-plugin.yml")) { - byte[] bytes = stream.readAllBytes(); - String contents = new String(bytes, StandardCharsets.UTF_8); - YamlConfiguration yamlConfiguration = new YamlConfiguration(); - yamlConfiguration.loadFromString(contents); - if (!yamlConfiguration.contains("supportedVersions")) - throw new RuntimeException("Supported Versions list not found in plugin yaml!"); - versions.addAll(yamlConfiguration.getStringList("supportedVersions")); - LANGUAGE = yamlConfiguration.getString("default-language"); - } catch (InvalidConfigurationException | IOException var8) { - throw new RuntimeException(var8); - } - - metrics = new BstatsMetrics(this, 18536); + String runningVersion = ServerBuildInfo.buildInfo().minecraftVersionId(); + if (!pluginData.getSupportedVersions().contains(runningVersion)) { + throw new IllegalStateException("This version of OriginsPaper does not support this version! Please use {}".replace("{}", pluginData.getSupportedVersions().toString())); + } + MixBukkit bukkit = new MixBukkit((PaperPluginClassLoader) OriginsPaper.class.getClassLoader()); + bukkit.onEnable(context.LOGGER, context.context().getPluginSource().toFile()); + + OriginsMixins.init(bukkit); + + ApiCall.call(ApiCall.INIT, context); + + LifecycleEventManager lifecycleManager = context.context().getLifecycleManager(); + lifecycleManager.registerEventHandler((LifecycleEvents.COMMANDS.newHandler(event -> { + PowerCommand.register(event.registrar()); + OriginCommand.register(event.registrar()); + ResourceCommand.register(event.registrar()); + })).priority(4)); + + io.github.dueris.calio.parser.JsonObjectRemapper remapper = new io.github.dueris.calio.parser.JsonObjectRemapper( + List.of(new Tuple<>("origins", "apoli")), + List.of( + new Tuple<>("apoli:restrict_armor", "apoli:conditioned_restrict_armor"), + new Tuple<>("apoli:has_tag", "apoli:has_command_tag"), + new Tuple<>("apoli:custom_data", "apoli:nbt"), + new Tuple<>("apoli:is_equippable", "apoli:equippable"), + new Tuple<>("apoli:fireproof", "apoli:fire_resistant"), + new Tuple<>("apoli:merge_nbt", "apoli:merge_custom_data"), + new Tuple<>("apoli:revoke_power", "apoli:remove_power"), + new Tuple<>("apoli:water_protection", "origins:water_protection"), + new Tuple<>("apoli:enderian_pearl", "minecraft:ender_pearl") + ), + List.of("power_type", "type", "entity_type") + ); + JsonObjectRemapper.PRE_REMAP_HOOK.add(new Tuple<>( + "apoli:enderian_pearl", + (tuple) -> FireProjectilePower.IS_ENDERIAN_PEARL.add(tuple.getB()) + )); + CalioParser.REMAPPER.set(remapper); + context.createRegistries( + Registries.ORIGIN, + Registries.LAYER, + Registries.POWER, + Registries.FLUID_CONDITION, + Registries.ENTITY_CONDITION, + Registries.BIOME_CONDITION, + Registries.BIENTITY_CONDITION, + Registries.BLOCK_CONDITION, + Registries.ITEM_CONDITION, + Registries.DAMAGE_CONDITION, + Registries.ENTITY_ACTION, + Registries.ITEM_ACTION, + Registries.BLOCK_ACTION, + Registries.BIENTITY_ACTION, + Registries.LANG, + Registries.CHOOSING_PAGE + ); + + OriginConfiguration.load(); + showCommandOutput = OriginConfiguration.getConfiguration().getBoolean("show-command-output", false); + LANGUAGE = OriginConfiguration.getConfiguration().getString("language", LANGUAGE); + LangFile.init(); + Renderer.init(); + + OriginsDataTypes.init(); + ApoliDataTypes.init(); + + ModifierOperations.registerAll(); + PowerType.registerAll(); + EntityConditions.register(); + BiEntityConditions.register(); + ItemConditions.register(); + BlockConditions.register(); + DamageConditions.register(); + FluidConditions.register(); + BiomeConditions.register(); + EntityActions.register(); + ItemActions.register(); + BlockActions.register(); + BiEntityActions.register(); + + ApiCall.call(ApiCall.PRE_PARSE, context); + } + + public enum ApiCall { + INIT, PRE_PARSE; + private static final List>> REGISTERED = new CopyOnWriteArrayList<>(); + + public static void registerCall(ApiCall call, Consumer consumer) { + REGISTERED.add(new Tuple<>( + call, consumer + )); } - } - - @Override - public void onEnable() { - Getter startup = () -> { - this.finalizePreboot(); - this.registry = CalioRegistry.INSTANCE; - Bukkit.getLogger().info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - System.out.println(); - this.printComponent( - Component.text( - "* Loading Version OriginsPaper-{minecraftVersion-versionNumber} // CraftApoli-{apoliVersion}" - .replace("minecraftVersion", "mc" + version) - .replace("versionNumber", pluginVersion) - .replace("apoliVersion", apoliVersion) - ) - .color(TextColor.fromHexString("#4fec4f")) - ); - System.out.println(); - server = ((CraftServer) Bukkit.getServer()).getServer(); - world_container = server.options.asMap().toString().split(", \\[W, universe, world-container, world-dir]=\\[")[1].split("], ")[0]; - playerDataFolder = server.playerDataStorage.getPlayerDir(); - glowingEntitiesUtils = new GlowingEntitiesUtils(this); - - try { - OriginConfiguration.load(); - showCommandOutput = OriginConfiguration.getConfiguration().getBoolean("show-command-output", false); - LANGUAGE = OriginConfiguration.getConfiguration().getString("language", LANGUAGE); - LangFile.init(); - } catch (IOException var7) { - throw new RuntimeException(var7); - } - - isCompatible = !isFolia && isExpandedScheduler; - boolean isCorrectVersion = false; - - for (String vers : versions) { - if (vers.equalsIgnoreCase(String.valueOf(version))) { - isCorrectVersion = true; - break; - } - } - - if ((!isCompatible || !isCorrectVersion) && !forceUseCurrentVersion) { - if (isCorrectVersion) { - this.getLog4JLogger().error("Unable to start OriginsPaper due to it not being compatible with this server type"); - } else { - this.getLog4JLogger().error("Unable to start OriginsPaper due to it not being compatible with this server version, {}", version); - } - - Bukkit.getLogger().info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - Bukkit.getServer().getPluginManager().disablePlugin(this); - } - try { - io.github.dueris.calio.CraftCalio craftCalio = io.github.dueris.calio.CraftCalio.buildInstance( - new String[]{"--async=true"} - ); - ApoliDataTypes.init(); - OriginsDataTypes.init(); - ModifierOperations.registerAll(); - ConditionTypes.registerAll(); - ActionTypes.registerAll(); - PowerType.registerAll(); - craftCalio.startBuilder() - .withAccessor(new AccessorKey<>(List.of("apoli", "origins"), "power", PowerType.class, 0, ParsingStrategy.TYPED, Registries.CRAFT_POWER)) - .withAccessor(new AccessorKey<>(List.of("origins"), "origin", Origin.class, 1, ParsingStrategy.DEFAULT, Registries.ORIGIN)) - .withAccessor(new AccessorKey<>(List.of("origins"), "origin_layer", OriginLayer.class, 2, ParsingStrategy.DEFAULT, Registries.LAYER)) - .build().parse(); - BuiltinRegistry.bootstrap(); - return true; - } catch (Throwable throwable) { - this.getLog4JLogger().error("An unhandled exception occurred when starting OriginsPaper!"); - this.throwable(throwable, true); - return false; - } - }; - if (startup.get()) { - this.debug(Component.text(" - Loaded @1 powers".replace("@1", String.valueOf(this.registry.retrieve(Registries.CRAFT_POWER).registrySize())))); - this.debug(Component.text(" - Loaded @2 layers".replace("@2", String.valueOf(this.registry.retrieve(Registries.LAYER).registrySize())))); - this.debug(Component.text(" - Loaded @3 origins".replace("@3", String.valueOf(this.registry.retrieve(Registries.ORIGIN).registrySize())))); - this.debug(Component.text(" - Loaded @4 actions".replace("@4", String.valueOf(((Getter) () -> { - int bientity = this.registry.retrieve(Registries.BIENTITY_ACTION).registrySize(); - int block = this.registry.retrieve(Registries.BLOCK_ACTION).registrySize(); - int entity = this.registry.retrieve(Registries.ENTITY_ACTION).registrySize(); - int item = this.registry.retrieve(Registries.ITEM_ACTION).registrySize(); - return item + entity + block + bientity; - }).get())))); - this.debug(Component.text(" - Loaded @5 conditions".replace("@5", String.valueOf(((Getter) () -> { - int bientity = this.registry.retrieve(Registries.BIENTITY_CONDITION).registrySize(); - int biome = this.registry.retrieve(Registries.BIOME_CONDITION).registrySize(); - int block = this.registry.retrieve(Registries.BLOCK_CONDITION).registrySize(); - int damage = this.registry.retrieve(Registries.DAMAGE_CONDITION).registrySize(); - int entity = this.registry.retrieve(Registries.ENTITY_CONDITION).registrySize(); - int fluid = this.registry.retrieve(Registries.FLUID_CONDITION).registrySize(); - int item = this.registry.retrieve(Registries.ITEM_CONDITION).registrySize(); - return item + fluid + entity + damage + block + biome + bientity; - }).get())))); - scheduler = new OriginScheduler.MainTickerThread(); - scheduler.runTaskTimer(this, 0L, 1L); - new BukkitRunnable() { - @Override - public void run() { - OriginsPaper.scheduler.tickAsyncScheduler(); + private static void call(ApiCall call, WrappedBootstrapContext context) { + for (Tuple> apiCall : REGISTERED) { + if (apiCall.getA().equals(call)) { + apiCall.getB().accept(context); + REGISTERED.remove(apiCall); } - }.runTaskTimerAsynchronously(getPlugin(), 0L, 1L); - this.start(); - patchPowers(); - this.debug(Component.text(" - Power thread starting with {originScheduler}".replace("originScheduler", scheduler.toString()))); - CommandDispatcher commandDispatcher = server.getCommands().getDispatcher(); - if (commandDispatcher.getRoot().getChildren().stream().map(CommandNode::getName).toList().contains("origin")) { - Commands.unload(commandDispatcher); } - - Commands.bootstrap(commandDispatcher); - Bukkit.updateRecipes(); - CraftPehuki.onLoad(); } - Bukkit.getLogger().info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } - public void throwable(@NotNull Throwable throwable, boolean kill) { - String[] stacktrace = new String[]{"\n"}; - Arrays.stream(throwable.getStackTrace()).map(StackTraceElement::toString).forEach(string -> stacktrace[0] = stacktrace[0] + "\tat " + string + "\n"); - this.getLog4JLogger().error("{}{}", throwable.getMessage(), stacktrace[0]); - if (kill) { - Bukkit.getPluginManager().disablePlugin(this); + /** + * A parser for the plugin data found in `paper-plugin.yml` + * This is needed because that information is not directly stored + * in the plugin source, and is provided on build. + */ + public record PluginData(YamlConfiguration configuration) { + public @NotNull List getSupportedVersions() { + return configuration.getStringList("supported"); } - } - - public void printComponent(Component component) { - Bukkit.getServer().getConsoleSender().sendMessage(component); - } - - public void debug(Component component) { - this.printComponent(component); - } - - private void start() { - this.getServer().getPluginManager().registerEvents(this, this); - this.getServer().getPluginManager().registerEvents(new PlayerManager(), this); - this.getServer().getPluginManager().registerEvents(new ScreenNavigator(), this); - this.getServer().getPluginManager().registerEvents(new OriginCommand(), this); - this.getServer().getPluginManager().registerEvents(new LogoutBugWorkaround(), this); - this.getServer().getPluginManager().registerEvents(new BiEntityConditions(), this); - this.getServer().getPluginManager().registerEvents(new OriginScheduler.MainTickerThread(), this); - this.getServer().getPluginManager().registerEvents(new KeybindUtil(), this); - this.getServer().getPluginManager().registerEvents(new AsyncUpgradeTracker(), this); - this.getServer().getPluginManager().registerEvents(new PowerHolderComponent(), this); - this.getServer().getPluginManager().registerEvents(new CraftPehuki(), this); - this.getServer().getPluginManager().registerEvents(EntityLinkedItemStack.getInstance(), this); - this.getServer().getPluginManager().registerEvents(new ApoliScheduler(), this); - this.registry.retrieve(Registries.CRAFT_POWER).values().forEach(powerType -> { - if (powerType != null) { - this.getServer().getPluginManager().registerEvents(powerType, this); - } - }); - BukkitRunnable[] independentTickers = new BukkitRunnable[]{new GuiTicker(), new OriginCommand()}; - for (BukkitRunnable runnable : independentTickers) { - runnable.runTaskTimerAsynchronously(getPlugin(), 0L, 1L); + public String getRecommendedVersion() { + return configuration.getString("minecraft"); } - } - - @Override - public void onDisable() { - try { - for (Player player : Bukkit.getOnlinePlayers()) { - player.closeInventory(); - player.getPersistentDataContainer() - .set(new NamespacedKey(this, "powers"), PersistentDataType.STRING, PlayerPowerRepository.getOrCreateRepo(((CraftPlayer) player).getHandle()).serializePowers(new CompoundTag()).toString()); - PowerHolderComponent.unloadPowers(player); - } - preShutdownTasks.forEach(Runnable::run); - glowingEntitiesUtils.disable(); - RecipePower.recipeMapping.clear(); - RecipePower.tags.clear(); - this.registry.clearRegistries(); - if (scheduler != null) { - scheduler.cancel(); - } - } catch (Throwable var3) { - this.getLog4JLogger().error("An unhandled exception occurred when disabling OriginsPaper!"); - this.throwable(var3, false); + public String getPluginVersion() { + return configuration.getString("plugin"); } - } - @EventHandler(priority = EventPriority.HIGHEST) - public void lagBackPatch(@NotNull PlayerFailMoveEvent e) { - e.setAllowed(true); - e.setLogWarning(false); - } - - @EventHandler - public void loadEvent(ServerLoadEvent e) { - ChoosingPage.registerInstances(); - ScreenNavigator.layerPages.values().forEach(pages -> pages.add(pages.size(), new RandomOriginPage())); - OrbOfOrigins.init(); - } + public String getFullVersion() { + return configuration.getString("version"); + } - private interface Getter { - T get(); + public String getApoliVersion() { + return configuration.getString("apoli"); + } } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/ActionTypes.java b/origins/src/main/java/io/github/dueris/originspaper/action/ActionTypes.java deleted file mode 100644 index 951c4ffb6..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/ActionTypes.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.github.dueris.originspaper.action; - -import io.github.classgraph.ClassGraph; -import io.github.classgraph.ScanResult; -import io.github.dueris.calio.util.ReflectionUtils; -import io.github.dueris.originspaper.action.types.BiEntityActions; -import io.github.dueris.originspaper.action.types.BlockActions; -import io.github.dueris.originspaper.action.types.EntityActions; -import io.github.dueris.originspaper.action.types.ItemActions; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.InvocationTargetException; -import java.util.function.Consumer; - -public class ActionTypes { - - public static void registerAll() { - BiEntityActions.registerAll(); - BlockActions.registerAll(); - EntityActions.registerAll(); - ItemActions.registerAll(); - } - - public static void registerPackage(@NotNull Consumer> factoryConsumer, String directory) { - try { - ScanResult result = new ClassGraph().whitelistPackages(directory).enableClassInfo().scan(); - - try { - result.getAllClasses().loadClasses() - .stream() - .filter(clz -> !clz.isAnnotation() && !clz.isInterface() && !clz.isEnum()) - .forEach( - clz -> { - try { - ActionTypeFactory factory = ReflectionUtils.invokeStaticMethod(clz, "getFactory"); - factoryConsumer.accept(factory); - } catch (InvocationTargetException | IllegalAccessException | - NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - ); - } catch (Throwable var5) { - if (result != null) { - try { - result.close(); - } catch (Throwable var4) { - var5.addSuppressed(var4); - } - } - - throw var5; - } - - result.close(); - } catch (Exception var6) { - System.out.println("This would've been a zip error :P. Please tell us on discord if you see this ^-^"); - var6.printStackTrace(); - } - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/ActionTypeFactory.java b/origins/src/main/java/io/github/dueris/originspaper/action/factory/ActionTypeFactory.java similarity index 83% rename from origins/src/main/java/io/github/dueris/originspaper/action/ActionTypeFactory.java rename to origins/src/main/java/io/github/dueris/originspaper/action/factory/ActionTypeFactory.java index 39be36932..c1563b35e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/ActionTypeFactory.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/factory/ActionTypeFactory.java @@ -1,12 +1,12 @@ -package io.github.dueris.originspaper.action; +package io.github.dueris.originspaper.action.factory; import com.google.gson.JsonObject; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; import io.github.dueris.originspaper.Factory; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; -import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -44,7 +44,7 @@ public ActionTypeFactory copy() { } public ActionTypeFactory decompile(JsonObject object) { - this.deserializedFactory = SerializableData.Instance.decompileJsonObject(object, data, "Action Factory", location.toString(), Optional.of(this.getClass())); + this.deserializedFactory = SerializableDataBuilder.compound(data, object, this.getClass()); if (data.postProcessor != null) { data.postProcessor.accept(deserializedFactory); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/factory/BiEntityActions.java b/origins/src/main/java/io/github/dueris/originspaper/action/factory/BiEntityActions.java new file mode 100644 index 000000000..d118ceeba --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/factory/BiEntityActions.java @@ -0,0 +1,43 @@ +package io.github.dueris.originspaper.action.factory; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.type.bientity.*; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; + +import java.util.function.BiConsumer; +import java.util.function.Function; + +public class BiEntityActions { + + public static void register() { + + MetaActions.register(ApoliDataTypes.BIENTITY_ACTION, ApoliDataTypes.BIENTITY_CONDITION, Function.identity(), BiEntityActions::register); + + register(InvertActionType.getFactory()); + register(ActorActionType.getFactory()); + register(TargetActionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("mount"), MountActionType::action)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("set_in_love"), SetInLoveActionType::action)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("tame"), TameActionType::action)); + register(AddVelocityActionType.getFactory()); + register(DamageActionType.getFactory()); + register(AddToEntitySetActionType.getFactory()); + register(RemoveFromEntitySetActionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("leash"), LeashActionType::action)); + + } + + public static ActionTypeFactory> createSimpleFactory(ResourceLocation id, BiConsumer action) { + return new ActionTypeFactory<>(id, new SerializableData(), (data, actorAndTarget) -> action.accept(actorAndTarget.getA(), actorAndTarget.getB())); + } + + public static ActionTypeFactory> register(ActionTypeFactory> actionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.BIENTITY_ACTION).register(actionFactory, actionFactory.getSerializerId()); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/factory/BlockActions.java b/origins/src/main/java/io/github/dueris/originspaper/action/factory/BlockActions.java new file mode 100644 index 000000000..9141b5d82 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/factory/BlockActions.java @@ -0,0 +1,34 @@ +package io.github.dueris.originspaper.action.factory; + +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.type.block.*; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.apache.commons.lang3.tuple.Triple; + +public class BlockActions { + + public static void register() { + + MetaActions.register(ApoliDataTypes.BLOCK_ACTION, ApoliDataTypes.BLOCK_CONDITION, block -> new BlockInWorld(block.getLeft(), block.getMiddle(), true), BlockActions::register); + + register(OffsetActionType.getFactory()); + register(SetBlockActionType.getFactory()); + register(AddBlockActionType.getFactory()); + register(ExecuteCommandActionType.getFactory()); + register(BoneMealActionType.getFactory()); + register(ModifyBlockStateActionType.getFactory()); + register(ExplodeActionType.getFactory()); + register(AreaOfEffectActionType.getFactory()); + register(SpawnEntityActionType.getFactory()); + } + + public static ActionTypeFactory> register(ActionTypeFactory> actionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.BLOCK_ACTION).register(actionFactory, actionFactory.getSerializerId()); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/factory/EntityActions.java b/origins/src/main/java/io/github/dueris/originspaper/action/factory/EntityActions.java new file mode 100644 index 000000000..a0f3c1d00 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/factory/EntityActions.java @@ -0,0 +1,81 @@ +package io.github.dueris.originspaper.action.factory; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.type.entity.*; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; + +import java.util.function.Consumer; +import java.util.function.Function; + +public class EntityActions { + + public static void register() { + + MetaActions.register(ApoliDataTypes.ENTITY_ACTION, ApoliDataTypes.ENTITY_CONDITION, Function.identity(), EntityActions::register); + + register(DamageActionType.getFactory()); + register(HealActionType.getFactory()); + register(PlaySoundActionType.getFactory()); + register(ExhaustActionType.getFactory()); + register(ApplyEffectActionType.getFactory()); + register(ClearEffectActionType.getFactory()); + register(SetOnFireActionType.getFactory()); + register(AddVelocityActionType.getFactory()); + register(SpawnEntityActionType.getFactory()); + register(GainAirActionType.getFactory()); + register(BlockActionAtActionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("extinguish"), Entity::clearFire)); + register(ExecuteCommandActionType.getFactory()); + register(ChangeResourceActionType.getFactory()); + register(FeedActionType.getFactory()); + register(AddXpActionType.getFactory()); + register(SetFallDistanceActionType.getFactory()); + register(GiveActionType.getFactory()); + register(EquippedItemActionType.getFactory()); + register(TriggerCooldownActionType.getFactory()); + register(ToggleActionType.getFactory()); + register(EmitGameEventActionType.getFactory()); + register(SetResourceActionType.getFactory()); + register(GrantPowerActionType.getFactory()); + register(RevokePowerActionType.getFactory()); + register(RevokeAllPowersActionType.getFactory()); + register(RemovePowerActionType.getFactory()); + register(ExplodeActionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("dismount"), Entity::stopRiding)); + register(PassengerActionType.getFactory()); + register(RidingActionType.getFactory()); + register(AreaOfEffectActionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("crafting_table"), CraftingTableActionType::action)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("ender_chest"), EnderChestActionType::action)); + register(SwingHandActionType.getFactory()); + register(RaycastActionType.getFactory()); + register(SpawnParticlesActionType.getFactory()); + register(ModifyInventoryActionType.getFactory()); + register(ReplaceInventoryActionType.getFactory()); + register(DropInventoryActionType.getFactory()); + register(ModifyDeathTicksActionType.getFactory()); + register(ModifyResourceActionType.getFactory()); + register(ModifyStatActionType.getFactory()); + register(FireProjectileActionType.getFactory()); + register(SelectorActionType.getFactory()); + register(GrantAdvancementActionType.getFactory()); + register(RevokeAdvancementActionType.getFactory()); + register(ActionOnEntitySetActionType.getFactory()); + register(RandomTeleportActionType.getFactory()); + register(SpawnEffectCloudActionType.getFactory()); + + } + + public static ActionTypeFactory createSimpleFactory(ResourceLocation id, Consumer action) { + return new ActionTypeFactory<>(id, new SerializableData(), (data, entity) -> action.accept(entity)); + } + + public static ActionTypeFactory register(ActionTypeFactory actionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.ENTITY_ACTION).register(actionFactory, actionFactory.getSerializerId()); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/ItemActionTypeFactory.java b/origins/src/main/java/io/github/dueris/originspaper/action/factory/ItemActionTypeFactory.java similarity index 92% rename from origins/src/main/java/io/github/dueris/originspaper/action/ItemActionTypeFactory.java rename to origins/src/main/java/io/github/dueris/originspaper/action/factory/ItemActionTypeFactory.java index 6ca6da80c..e408bd4a4 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/ItemActionTypeFactory.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/factory/ItemActionTypeFactory.java @@ -1,6 +1,6 @@ -package io.github.dueris.originspaper.action; +package io.github.dueris.originspaper.action.factory; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraft.world.entity.SlotAccess; diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/factory/ItemActions.java b/origins/src/main/java/io/github/dueris/originspaper/action/factory/ItemActions.java new file mode 100644 index 000000000..3e3c8f6cb --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/factory/ItemActions.java @@ -0,0 +1,29 @@ +package io.github.dueris.originspaper.action.factory; + +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.type.item.*; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.SlotAccess; +import net.minecraft.world.level.Level; + +public class ItemActions { + + public static void register() { + + MetaActions.register(ApoliDataTypes.ITEM_ACTION, ApoliDataTypes.ITEM_CONDITION, worldAndStackRef -> new Tuple<>(worldAndStackRef.getA(), worldAndStackRef.getB().get()), ItemActions::register); + + register(ConsumeActionType.getFactory()); + register(ModifyActionType.getFactory()); + register(DamageActionType.getFactory()); + register(MergeCustomDataActionType.getFactory()); + register(RemoveEnchantmentActionType.getFactory()); + + } + + public static ActionTypeFactory> register(ActionTypeFactory> actionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.ITEM_ACTION).register(actionFactory, actionFactory.getSerializerId()); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/factory/MetaActions.java b/origins/src/main/java/io/github/dueris/originspaper/action/factory/MetaActions.java new file mode 100644 index 000000000..ed684bb59 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/factory/MetaActions.java @@ -0,0 +1,23 @@ +package io.github.dueris.originspaper.action.factory; + +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.action.type.meta.*; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; + +import java.util.function.Consumer; +import java.util.function.Function; + +public class MetaActions { + + public static void register(SerializableDataBuilder> actionDataType, SerializableDataBuilder> conditionDataType, Function actionToCondition, Consumer> registrant) { + registrant.accept(AndActionType.getFactory(SerializableDataBuilder.of(actionDataType.listOf()))); + registrant.accept(ChanceActionType.getFactory(actionDataType)); + registrant.accept(IfElseActionType.getFactory(actionDataType, conditionDataType, actionToCondition)); + registrant.accept(ChoiceActionType.getFactory(actionDataType)); + registrant.accept(IfElseListActionType.getFactory(actionDataType, conditionDataType, actionToCondition)); + registrant.accept(DelayActionType.getFactory(actionDataType)); + registrant.accept(SideActionType.getFactory(actionDataType)); + registrant.accept(NothingActionType.getFactory()); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/meta/AndAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/meta/AndAction.java deleted file mode 100644 index a2bafde03..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/meta/AndAction.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.dueris.originspaper.action.meta; - -import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class AndAction { - - public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder>> listDataType) { - return new ActionTypeFactory(OriginsPaper.apoliIdentifier("and"), - SerializableData.serializableData() - .add("actions", listDataType), - (data, t) -> { - List> actions = data.get("actions"); - actions.forEach(a -> a.accept(t)); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/meta/ChanceAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/meta/ChanceAction.java deleted file mode 100644 index fe37b5849..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/meta/ChanceAction.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.github.dueris.originspaper.action.meta; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import org.jetbrains.annotations.NotNull; - -import java.util.Random; - -public class ChanceAction { - - public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> dataType) { - return new ActionTypeFactory(OriginsPaper.apoliIdentifier("chance"), - SerializableData.serializableData() - .add("action", dataType) - .add("chance", SerializableDataTypes.FLOAT) - .add("fail_action", dataType, null), - (data, t) -> { - ActionTypeFactory action = data.get("action"); - if (new Random().nextFloat() < data.getFloat("chance")) { - action.accept(t); - } else if (data.isPresent("fail_action")) { - ActionTypeFactory fail = data.get("fail_action"); - fail.accept(t); - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/meta/ChoiceAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/meta/ChoiceAction.java deleted file mode 100644 index 2bf749164..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/meta/ChoiceAction.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.dueris.originspaper.action.meta; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.calio.util.FilterableWeightedList; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import org.jetbrains.annotations.NotNull; - -import java.util.Random; - -public class ChoiceAction { - - public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> dataType) { - return new ActionTypeFactory(OriginsPaper.apoliIdentifier("choice"), - SerializableData.serializableData() - .add("actions", SerializableDataTypes.weightedList(dataType)), - (data, t) -> { - FilterableWeightedList> actionList = data.get("actions"); - ActionTypeFactory action = actionList.pickRandom(new Random()); - action.accept(t); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/meta/DelayAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/meta/DelayAction.java deleted file mode 100644 index 141b3e4d0..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/meta/DelayAction.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.dueris.originspaper.action.meta; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.util.ApoliScheduler; -import org.jetbrains.annotations.NotNull; - -public class DelayAction { - private static final ApoliScheduler SCHEDULER = new ApoliScheduler(); - - public static void action(@NotNull SerializableData.Instance data, T t) { - ActionTypeFactory action = data.get("action"); - SCHEDULER.queue(s -> action.accept(t), data.getInt("ticks")); - } - - public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> dataType) { - return new ActionTypeFactory(OriginsPaper.apoliIdentifier("delay"), - SerializableData.serializableData() - .add("ticks", SerializableDataTypes.INT) - .add("action", dataType), - DelayAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/meta/IfElseAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/meta/IfElseAction.java deleted file mode 100644 index 9cf489867..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/meta/IfElseAction.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.github.dueris.originspaper.action.meta; - -import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -public class IfElseAction { - - public static @NotNull ActionTypeFactory getFactory( - SerializableDataBuilder> actionDataType, - SerializableDataBuilder> conditionDataType, - Function actionToConditionTypeFunction) { - return new ActionTypeFactory(OriginsPaper.apoliIdentifier("if_else"), - SerializableData.serializableData() - .add("condition", conditionDataType) - .add("if_action", actionDataType) - .add("else_action", actionDataType, null), - (data, t) -> { - ConditionTypeFactory condition = data.get("condition"); - ActionTypeFactory ifAction = data.get("if_action"); - U u = actionToConditionTypeFunction.apply(t); - if (condition.test(u)) { - ifAction.accept(t); - } else if (data.isPresent("else_action")) { - ActionTypeFactory elseAction = data.get("else_action"); - elseAction.accept(t); - } - } - ); - } - - public static @NotNull ActionTypeFactory getFactory( - SerializableDataBuilder> actionDataType, - SerializableDataBuilder> conditionDataType) { - return getFactory(actionDataType, conditionDataType, t -> t); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/meta/IfElseListAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/meta/IfElseListAction.java deleted file mode 100644 index f72569ff1..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/meta/IfElseListAction.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.github.dueris.originspaper.action.meta; - -import com.google.gson.JsonObject; -import com.google.gson.JsonSyntaxException; -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.function.Function; - -public class IfElseListAction { - - public static void action(@NotNull SerializableData.Instance data, T t, @NotNull Function actionToConditionTypeFunction) { - List, ActionTypeFactory>> actions = - data.get("actions"); - U u = actionToConditionTypeFunction.apply(t); - for (Tuple, ActionTypeFactory> action : actions) { - if (action.getA().test(u)) { - action.getB().accept(t); - break; - } - } - } - - public static @NotNull ActionTypeFactory getFactory( - SerializableDataBuilder> actionDataType, - SerializableDataBuilder> conditionDataType, - Function actionToConditionTypeFunction) { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("if_else_list"), SerializableData.serializableData() - .add("actions", SerializableDataTypes.list(SerializableDataBuilder.of( - (jsonElement) -> { - if (jsonElement.isJsonObject()) { - JsonObject jo = jsonElement.getAsJsonObject(); - return new Tuple<>( - conditionDataType.deserialize(jo.get("condition")), actionDataType.deserialize(jo.get("action")) - ); - } - throw new JsonSyntaxException("Unable to parse actions for the if_else_list action!"); - }, Tuple.class - ))), - (inst, t) -> action(inst, t, actionToConditionTypeFunction)); - } - - public static @NotNull ActionTypeFactory getFactory( - SerializableDataBuilder> actionDataType, - SerializableDataBuilder> conditionDataType) { - return getFactory(actionDataType, conditionDataType, t -> t); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/meta/NothingAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/meta/NothingAction.java deleted file mode 100644 index 4181c4000..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/meta/NothingAction.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.dueris.originspaper.action.meta; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import org.jetbrains.annotations.NotNull; - -public class NothingAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory(OriginsPaper.apoliIdentifier("nothing"), - SerializableData.serializableData(), - (inst, t) -> { - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/meta/SideAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/meta/SideAction.java deleted file mode 100644 index 5a2ead153..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/meta/SideAction.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.dueris.originspaper.action.meta; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -public class SideAction { - - public static void action(@NotNull SerializableData.Instance data, T t, @NotNull Function serverCheck) { - ActionTypeFactory action = data.get("action"); - Side side = data.get("side"); - boolean isServer = serverCheck.apply(t); - if ((side == Side.CLIENT) != isServer) { - action.accept(t); - } - } - - public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> dataType, Function serverCheck) { - return new ActionTypeFactory(OriginsPaper.apoliIdentifier("side"), - SerializableData.serializableData() - .add("side", SerializableDataTypes.enumValue(Side.class)) - .add("action", dataType), - (data, t) -> SideAction.action(data, t, serverCheck) - ); - } - - public enum Side { - CLIENT, SERVER - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/ActorAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/ActorActionType.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/ActorAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/ActorActionType.java index 9f43c89c3..25f56e4f2 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/ActorAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/ActorActionType.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.action.types.bientity; +package io.github.dueris.originspaper.action.type.bientity; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; @@ -10,14 +10,12 @@ import java.util.function.Consumer; -public class ActorAction { +public class ActorActionType { - public static void action(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); + public static void action(Entity actor, Consumer action) { if (actor != null) { - data.>get("action").accept(actor); + action.accept(actor); } } @@ -25,9 +23,12 @@ public static void action(SerializableData.Instance data, @NotNull Tuple> getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("actor_action"), - SerializableData.serializableData() + new SerializableData() .add("action", ApoliDataTypes.ENTITY_ACTION), - ActorAction::action + (data, actorAndTarget) -> action(actorAndTarget.getA(), + data.get("action") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/AddToEntitySetActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/AddToEntitySetActionType.java new file mode 100644 index 000000000..6bc09147b --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/AddToEntitySetActionType.java @@ -0,0 +1,33 @@ +package io.github.dueris.originspaper.action.type.bientity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +// TODO - EntitySets - Dueris +public class AddToEntitySetActionType { + + public static void action(Entity actor, Entity target, PowerReference power, @Nullable Integer timeLimit) { + } + + public static @NotNull ActionTypeFactory> getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("add_to_entity_set"), + new SerializableData() + .add("set", ApoliDataTypes.POWER_REFERENCE) + .add("time_limit", SerializableDataTypes.POSITIVE_INT, null), + (data, actorAndTarget) -> action(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("set"), + data.get("time_limit") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/AddVelocityAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/AddVelocityActionType.java similarity index 55% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/AddVelocityAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/AddVelocityActionType.java index dbcaa0925..b410ac456 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/AddVelocityAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/AddVelocityActionType.java @@ -1,14 +1,13 @@ -package io.github.dueris.originspaper.action.types.bientity; +package io.github.dueris.originspaper.action.type.bientity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.types.Space; import net.minecraft.util.Mth; import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.Vec3; import org.apache.logging.log4j.util.TriConsumer; import org.jetbrains.annotations.NotNull; @@ -16,26 +15,18 @@ import java.util.function.BiFunction; -public class AddVelocityAction { +public class AddVelocityActionType { - public static void action(SerializableData.Instance data, @NotNull Tuple entities) { + public static void action(Entity actor, Entity target, @NotNull Reference reference, Vector3f velocity, boolean set) { - Entity actor = entities.getA(); - Entity target = entities.getB(); + TriConsumer method = set + ? target::setDeltaMovement + : target::push; - if ((actor == null || target == null) || (target instanceof Player && (target.level().isClientSide ? !data.getBoolean("client") : !data.getBoolean("server")))) { - return; - } - - Vector3f vec = new Vector3f(data.getFloat("x"), data.getFloat("y"), data.getFloat("z")); - TriConsumer method = data.getBoolean("set") ? target::setDeltaMovement : target::push; - - Reference reference = data.get("reference"); Vec3 refVec = reference.apply(actor, target); + Space.transformVectorToBase(refVec, velocity, actor.getYRot(), true); // vector normalized by method - Space.transformVectorToBase(refVec, vec, actor.getYRot(), true); // vector normalized by method - method.accept(vec.x, vec.y, vec.z); - + method.accept(velocity.x, velocity.y, velocity.z); target.hurtMarked = true; } @@ -43,15 +34,17 @@ public static void action(SerializableData.Instance data, @NotNull Tuple> getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("add_velocity"), - SerializableData.serializableData() + new SerializableData() + .add("reference", SerializableDataTypes.enumValue(Reference.class), Reference.POSITION) .add("x", SerializableDataTypes.FLOAT, 0F) .add("y", SerializableDataTypes.FLOAT, 0F) .add("z", SerializableDataTypes.FLOAT, 0F) - .add("client", SerializableDataTypes.BOOLEAN, true) - .add("server", SerializableDataTypes.BOOLEAN, true) - .add("set", SerializableDataTypes.BOOLEAN, false) - .add("reference", SerializableDataTypes.enumValue(Reference.class), Reference.POSITION), - AddVelocityAction::action + .add("set", SerializableDataTypes.BOOLEAN, false), + (data, actorAndTarget) -> action(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("reference"), + new Vector3f(data.get("x"), data.get("y"), data.get("z")), + data.get("set") + ) ); } @@ -84,4 +77,5 @@ public Vec3 apply(Entity actor, Entity target) { } } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/DamageActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/DamageActionType.java new file mode 100644 index 000000000..6537c3055 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/DamageActionType.java @@ -0,0 +1,78 @@ +package io.github.dueris.originspaper.action.type.bientity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.types.modifier.Modifier; +import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; +import io.github.dueris.originspaper.util.Util; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.Tuple; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageType; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.bukkit.craftbukkit.CraftRegistry; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.LinkedList; + +public class DamageActionType { + + public static void action(Entity actor, Entity target, ResourceKey damageTypeKey, @Nullable Float amount, Collection modifiers) { + + if (actor == null || target == null) { + return; + } + + if (!modifiers.isEmpty() && target instanceof LivingEntity livingTarget) { + amount = (float) ModifierUtil.applyModifiers(actor, modifiers.stream().toList(), livingTarget.getMaxHealth()); + } + + if (amount != null) { + target.hurt(source(damageTypeKey, actor), amount); + } + + } + + private static @NotNull DamageSource source(ResourceKey key, @javax.annotation.Nullable Entity attacker) { + return new DamageSource(CraftRegistry.getMinecraftRegistry().registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(key), attacker); + } + + public static @NotNull ActionTypeFactory> getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("damage"), + new SerializableData() + .add("damage_type", SerializableDataTypes.DAMAGE_TYPE) + .add("amount", SerializableDataTypes.FLOAT, null) + .add("modifier", Modifier.DATA_TYPE, null) + .add("modifiers", Modifier.LIST_TYPE, null) + .postProcessor(data -> { + + if (!data.isPresent("amount") && !Util.anyPresent(data, "modifier", "modifiers")) { + throw new IllegalStateException("Any of 'amount', 'modifier', or 'modifiers' fields must be defined!"); + } + + }), + (data, actorAndTarget) -> { + + Collection modifiers = new LinkedList<>(); + + data.ifPresent("modifier", modifiers::add); + data.ifPresent("modifiers", modifiers::addAll); + + action(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("damage_type"), + data.get("amount"), + modifiers + ); + + } + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/InvertActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/InvertActionType.java new file mode 100644 index 000000000..a754c29b5 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/InvertActionType.java @@ -0,0 +1,30 @@ +package io.github.dueris.originspaper.action.type.bientity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; + +public class InvertActionType { + + public static void action(Entity actor, Entity target, @NotNull Consumer> biEntityAction) { + biEntityAction.accept(new Tuple<>(target, actor)); + } + + public static @NotNull ActionTypeFactory> getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("invert"), + new SerializableData() + .add("action", ApoliDataTypes.BIENTITY_ACTION), + (data, actorAndTarget) -> action(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("action") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/LeashActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/LeashActionType.java new file mode 100644 index 000000000..bb09f4968 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/LeashActionType.java @@ -0,0 +1,20 @@ +package io.github.dueris.originspaper.action.type.bientity; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Leashable; + +public class LeashActionType { + + public static void action(Entity actor, Entity target) { + + if (actor == null || !(target instanceof Leashable leashable)) { + return; + } + + if (leashable.isLeashed()) { + leashable.setLeashedTo(actor, true); + } + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/MountActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/MountActionType.java new file mode 100644 index 000000000..8c40cb339 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/MountActionType.java @@ -0,0 +1,21 @@ +package io.github.dueris.originspaper.action.type.bientity; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; + +public class MountActionType { + + public static void action(Entity actor, Entity target) { + + if (actor == null || target == null) { + return; + } + + actor.startRiding(target, true); + if (!actor.level().isClientSide && target instanceof ServerPlayer targetPlayer) { + target.getBukkitEntity().setPassenger(targetPlayer.getBukkitEntity()); + } + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/RemoveFromEntitySetActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/RemoveFromEntitySetActionType.java new file mode 100644 index 000000000..bac0c03a8 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/RemoveFromEntitySetActionType.java @@ -0,0 +1,28 @@ +package io.github.dueris.originspaper.action.type.bientity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; + +// TODO - EntitySets - Dueris +public class RemoveFromEntitySetActionType { + + public static void action(Entity actor, Entity target, PowerReference power) { + } + + public static ActionTypeFactory> getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("remove_from_entity_set"), + new SerializableData() + .add("set", ApoliDataTypes.POWER_REFERENCE), + (data, actorAndTarget) -> action(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("set") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/SetInLoveActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/SetInLoveActionType.java new file mode 100644 index 000000000..fedf23495 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/SetInLoveActionType.java @@ -0,0 +1,17 @@ +package io.github.dueris.originspaper.action.type.bientity; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.player.Player; + +public class SetInLoveActionType { + + public static void action(Entity actor, Entity target) { + + if (target instanceof Animal targetAnimal && actor instanceof Player actorPlayer) { + targetAnimal.setInLove(actorPlayer); + } + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/TameActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/TameActionType.java new file mode 100644 index 000000000..0318ea6c8 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/TameActionType.java @@ -0,0 +1,24 @@ +package io.github.dueris.originspaper.action.type.bientity; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.animal.horse.AbstractHorse; +import net.minecraft.world.entity.player.Player; + +public class TameActionType { + + public static void action(Entity actor, Entity target) { + + if (!(actor instanceof Player actorPlayer)) { + return; + } + + if (target instanceof TamableAnimal tameableTarget && !tameableTarget.isTame()) { + tameableTarget.tame(actorPlayer); + } else if (target instanceof AbstractHorse targetHorseLike && !targetHorseLike.isTamed()) { + targetHorseLike.tameWithName(actorPlayer); + } + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/TargetAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/TargetActionType.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/TargetAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/TargetActionType.java index 13d13e601..20781859e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/TargetAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/bientity/TargetActionType.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.action.types.bientity; +package io.github.dueris.originspaper.action.type.bientity; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; @@ -10,14 +10,12 @@ import java.util.function.Consumer; -public class TargetAction { +public class TargetActionType { - public static void action(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity target = actorAndTarget.getB(); + public static void action(Entity target, Consumer action) { if (target != null) { - data.>get("action").accept(target); + action.accept(target); } } @@ -25,9 +23,12 @@ public static void action(SerializableData.Instance data, @NotNull Tuple> getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("target_action"), - SerializableData.serializableData() + new SerializableData() .add("action", ApoliDataTypes.ENTITY_ACTION), - TargetAction::action + (data, actorAndTarget) -> action(actorAndTarget.getB(), + data.get("action") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/AddBlockAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/AddBlockActionType.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/block/AddBlockAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/block/AddBlockActionType.java index 9be0862fe..d3cf200bf 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/AddBlockAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/AddBlockActionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.action.types.block; +package io.github.dueris.originspaper.action.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.Level; @@ -11,18 +11,25 @@ import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; -public class AddBlockAction { +public class AddBlockActionType { + + public static void action(Level world, BlockPos pos, Direction direction, BlockState blockState) { + + if (direction != null) { + world.setBlockAndUpdate(pos.relative(direction), blockState); + } + + } public static @NotNull ActionTypeFactory> getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("add_block"), - SerializableData.serializableData() + new SerializableData() .add("block", SerializableDataTypes.BLOCK_STATE), - (data, block) -> { - BlockState actualState = data.get("block"); - BlockPos pos = block.getMiddle().relative(block.getRight()); - block.getLeft().setBlockAndUpdate(pos, actualState); - } + (data, block) -> action(block.getLeft(), block.getMiddle(), block.getRight(), + data.get("block") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/block/AreaOfEffectActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/AreaOfEffectActionType.java new file mode 100644 index 000000000..2f053feb5 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/AreaOfEffectActionType.java @@ -0,0 +1,50 @@ +package io.github.dueris.originspaper.action.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Shape; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; +import java.util.function.Predicate; + +public class AreaOfEffectActionType { + + public static void action(Level world, BlockPos pos, Direction direction, Consumer> blockAction, Predicate blockCondition, Shape shape, int radius) { + + for (BlockPos collectedPos : Shape.getPositions(pos, shape, radius)) { + + if (blockCondition.test(new BlockInWorld(world, collectedPos, true))) { + blockAction.accept(Triple.of(world, collectedPos, direction)); + } + + } + + } + + public static @NotNull ActionTypeFactory> getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("area_of_effect"), + new SerializableData() + .add("block_action", ApoliDataTypes.BLOCK_ACTION) + .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) + .add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE) + .add("radius", SerializableDataTypes.INT, 16), + (data, block) -> action(block.getLeft(), block.getMiddle(), block.getRight(), + data.get("block_action"), + data.getOrElse("block_condition", cachedBlock -> true), + data.get("shape"), + data.get("radius") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/block/BoneMealActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/BoneMealActionType.java new file mode 100644 index 000000000..b5aab79d1 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/BoneMealActionType.java @@ -0,0 +1,57 @@ +package io.github.dueris.originspaper.action.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.item.BoneMealItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.LevelEvent; +import net.minecraft.world.level.block.state.BlockState; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.NotNull; + +public class BoneMealActionType { + + public static void action(Level world, BlockPos pos, Direction direction, boolean showEffects) { + + if (BoneMealItem.growCrop(ItemStack.EMPTY, world, pos)) { + + if (showEffects && !world.isClientSide) { + world.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, pos, 0); + } + + } else { + + BlockState blockState = world.getBlockState(pos); + BlockPos offsetPos = pos.relative(direction); + + boolean solidSide = blockState.isFaceSturdy(world, pos, direction); + + if (solidSide && BoneMealItem.growWaterPlant(ItemStack.EMPTY, world, offsetPos, direction)) { + + if (showEffects && !world.isClientSide) { + world.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, offsetPos, 0); + } + + } + + } + + } + + public static @NotNull ActionTypeFactory> getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("bonemeal"), + new SerializableData() + .add("effects", SerializableDataTypes.BOOLEAN, true), + (data, block) -> action(block.getLeft(), block.getMiddle(), block.getRight(), + data.get("effects") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/block/ExecuteCommandActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/ExecuteCommandActionType.java new file mode 100644 index 000000000..a2da24aab --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/ExecuteCommandActionType.java @@ -0,0 +1,45 @@ +package io.github.dueris.originspaper.action.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.commands.CommandSource; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.level.Level; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.NotNull; + +public class ExecuteCommandActionType { + + public static void action(Level world, BlockPos pos, String command) { + + MinecraftServer server = world.getServer(); + if (server == null) { + return; + } + + CommandSourceStack source = server.createCommandSourceStack() + .withSource(OriginsPaper.showCommandOutput ? server : CommandSource.NULL) + .withPosition(pos.getCenter()) + .withPermission(4); + + server.getCommands().performPrefixedCommand(source, command); + + } + + public static @NotNull ActionTypeFactory> getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("execute_command"), + new SerializableData() + .add("command", SerializableDataTypes.STRING), + (data, block) -> action(block.getLeft(), block.getMiddle(), + data.get("command") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/block/ExplodeActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/ExplodeActionType.java new file mode 100644 index 000000000..0240ca463 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/ExplodeActionType.java @@ -0,0 +1,64 @@ +package io.github.dueris.originspaper.action.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.util.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Predicate; + +public class ExplodeActionType { + + public static void action(@NotNull Level world, BlockPos pos, float power, Explosion.BlockInteraction destructionType, @Nullable Predicate indestructibleCondition, float indestructibleResistance, @Nullable Predicate destructibleCondition, boolean createFire) { + + if (world.isClientSide) { + return; + } + + if (destructibleCondition != null) { + indestructibleCondition = Util.combineOr(destructibleCondition.negate(), indestructibleCondition); + } + + Util.createExplosion( + world, + pos.getCenter(), + power, + createFire, + destructionType, + Util.getExplosionBehavior(world, indestructibleResistance, indestructibleCondition) + ); + + } + + public static @NotNull ActionTypeFactory> getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("explode"), + new SerializableData() + .add("power", SerializableDataTypes.FLOAT) + .add("destruction_type", ApoliDataTypes.DESTRUCTION_TYPE, Explosion.BlockInteraction.DESTROY) + .add("indestructible", ApoliDataTypes.BLOCK_CONDITION, null) + .add("indestructible_resistance", SerializableDataTypes.FLOAT, 10.0f) + .add("destructible", ApoliDataTypes.BLOCK_CONDITION, null) + .add("create_fire", SerializableDataTypes.BOOLEAN, false), + (data, block) -> action(block.getLeft(), block.getMiddle(), + data.get("power"), + data.get("destruction_type"), + data.get("indestructible"), + data.get("indestructible_resistance"), + data.get("destructible"), + data.get("create_fire") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/block/ModifyBlockStateActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/ModifyBlockStateActionType.java new file mode 100644 index 000000000..4f6255d95 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/ModifyBlockStateActionType.java @@ -0,0 +1,95 @@ +package io.github.dueris.originspaper.action.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.ResourceOperation; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.Property; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; + +public class ModifyBlockStateActionType { + + public static void action(@NotNull Level world, BlockPos pos, String propertyName, ResourceOperation operation, @Nullable Integer change, @Nullable Boolean value, @Nullable String enumName, boolean cycle) { + + BlockState blockState = world.getBlockState(pos); + Property property = blockState.getProperties() + .stream() + .filter(prop -> prop.getName().equals(propertyName)) + .findFirst() + .orElse(null); + + if (property == null) { + return; + } + + if (cycle) { + world.setBlockAndUpdate(pos, blockState.cycle(property)); + return; + } + + switch (property) { + case EnumProperty enumProp when enumName != null && !enumName.isEmpty() -> + setEnumProperty(enumProp, enumName, world, pos, blockState); + case BooleanProperty boolProp when value != null -> + world.setBlockAndUpdate(pos, blockState.setValue(boolProp, value)); + case IntegerProperty intProp when change != null -> { + + int newValue = switch (operation) { + case ADD -> Optional.of(blockState.getValue(intProp)).orElse(0) + change; + case SET -> change; + }; + + if (intProp.getPossibleValues().contains(newValue)) { + world.setBlockAndUpdate(pos, blockState.setValue(intProp, newValue)); + } + + } + default -> { + + } + } + + } + + private static & StringRepresentable> void setEnumProperty(@NotNull EnumProperty property, String name, Level world, BlockPos pos, BlockState originalState) { + property.getValue(name).ifPresentOrElse( + propValue -> world.setBlockAndUpdate(pos, originalState.setValue(property, propValue)), + () -> OriginsPaper.LOGGER.warn("Couldn't set enum property \"{}\" of block at {} to \"{}\"! Expected value to be any of {}", property.getName(), pos.toShortString(), name, String.join(", ", property.getPossibleValues().stream().map(StringRepresentable::getSerializedName).toList())) + ); + } + + public static @NotNull ActionTypeFactory> getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("modify_block_state"), + new SerializableData() + .add("property", SerializableDataTypes.STRING) + .add("operation", ApoliDataTypes.RESOURCE_OPERATION, ResourceOperation.ADD) + .add("change", SerializableDataTypes.INT, null) + .add("value", SerializableDataTypes.BOOLEAN, null) + .add("enum", SerializableDataTypes.STRING, null) + .add("cycle", SerializableDataTypes.BOOLEAN, false), + (data, block) -> action(block.getLeft(), block.getMiddle(), + data.get("property"), + data.get("operation"), + data.get("change"), + data.get("value"), + data.get("enum"), + data.get("cycle") + ) + ); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/OffsetCondition.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/OffsetActionType.java similarity index 50% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/block/OffsetCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/block/OffsetActionType.java index 97009e77e..ce94b50e5 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/OffsetCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/OffsetActionType.java @@ -1,31 +1,38 @@ -package io.github.dueris.originspaper.action.types.block; +package io.github.dueris.originspaper.action.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; import net.minecraft.world.level.Level; import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; -public class OffsetCondition { +import java.util.function.Consumer; + +public class OffsetActionType { + + public static void action(Level world, @NotNull BlockPos pos, Direction direction, @NotNull Consumer> action, Vec3i offset) { + action.accept(Triple.of(world, pos.offset(offset), direction)); + } public static @NotNull ActionTypeFactory> getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("offset"), - SerializableData.serializableData() + new SerializableData() .add("action", ApoliDataTypes.BLOCK_ACTION) .add("x", SerializableDataTypes.INT, 0) .add("y", SerializableDataTypes.INT, 0) .add("z", SerializableDataTypes.INT, 0), - (data, block) -> ((ActionTypeFactory>) data.get("action")).accept(Triple.of( - block.getLeft(), - block.getMiddle().offset(data.getInt("x"), data.getInt("y"), data.getInt("z")), - block.getRight()) + (data, block) -> action(block.getLeft(), block.getMiddle(), block.getRight(), + data.get("action"), + new Vec3i(data.get("x"), data.get("y"), data.get("z")) ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/SetBlockAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/SetBlockActionType.java similarity index 56% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/block/SetBlockAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/block/SetBlockActionType.java index 04f15dc7f..41e2c0bd5 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/SetBlockAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/SetBlockActionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.action.types.block; +package io.github.dueris.originspaper.action.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.Level; @@ -11,17 +11,21 @@ import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; -public class SetBlockAction { +public class SetBlockActionType { + + public static void action(@NotNull Level world, BlockPos pos, BlockState blockState) { + world.setBlockAndUpdate(pos, blockState); + } public static @NotNull ActionTypeFactory> getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("set_block"), - SerializableData.serializableData() + new SerializableData() .add("block", SerializableDataTypes.BLOCK_STATE), - (data, block) -> { - BlockState actualState = data.get("block"); - block.getLeft().setBlockAndUpdate(block.getMiddle(), actualState); - } + (data, block) -> action(block.getLeft(), block.getMiddle(), + data.get("block") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/SpawnEntityAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/SpawnEntityActionType.java similarity index 63% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/block/SpawnEntityAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/block/SpawnEntityActionType.java index 8b15ad3dc..12fc75dee 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/SpawnEntityAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/block/SpawnEntityActionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.action.types.block; +package io.github.dueris.originspaper.action.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.util.Util; import net.minecraft.core.BlockPos; @@ -19,20 +19,14 @@ import java.util.Optional; import java.util.function.Consumer; -public class SpawnEntityAction { +public class SpawnEntityActionType { - public static void action(SerializableData.Instance data, @NotNull Triple worldPosAndDirection) { - - Level world = worldPosAndDirection.getLeft(); - BlockPos pos = worldPosAndDirection.getMiddle(); + public static void action(Level world, BlockPos pos, EntityType entityType, Consumer entityAction, CompoundTag entityNbt) { if (!(world instanceof ServerLevel serverWorld)) { return; } - EntityType entityType = data.get("entity_type"); - CompoundTag entityNbt = data.get("tag"); - Entity entityToSpawn = Util.getEntityWithPassengers( serverWorld, entityType, @@ -47,18 +41,24 @@ public static void action(SerializableData.Instance data, @NotNull Triple>ifPresent("entity_action", entityAction -> entityAction.accept(entityToSpawn)); + entityAction.accept(entityToSpawn); } public static @NotNull ActionTypeFactory> getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("spawn_entity"), - SerializableData.serializableData() + new SerializableData() .add("entity_type", SerializableDataTypes.ENTITY_TYPE) - .add("tag", SerializableDataTypes.NBT_COMPOUND, new CompoundTag()) - .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null), - SpawnEntityAction::action + .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) + .add("tag", SerializableDataTypes.NBT_COMPOUND, new CompoundTag()), + (data, block) -> action(block.getLeft(), block.getMiddle(), + data.get("entity_type"), + data.getOrElse("entity_action", e -> { + }), + data.get("tag") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ActionOnEntitySetActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ActionOnEntitySetActionType.java new file mode 100644 index 000000000..507b9e14f --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ActionOnEntitySetActionType.java @@ -0,0 +1,41 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; +import java.util.function.Predicate; + +// TODO - EntitySets - Dueris +public class ActionOnEntitySetActionType { + + public static void action(Entity entity, PowerReference power, Consumer> biEntityAction, Predicate> biEntityCondition, boolean reverse, int limit) { + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("action_on_entity_set"), + new SerializableData() + .add("set", ApoliDataTypes.POWER_REFERENCE) + .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION) + .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) + .add("reverse", SerializableDataTypes.BOOLEAN, false) + .add("limit", SerializableDataTypes.INT, 0), + (data, entity) -> action(entity, + data.get("set"), + data.get("bientity_action"), + data.getOrElse("bientity_condition", actorAndTarget -> true), + data.get("reverse"), + data.get("limit") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/AddVelocityActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/AddVelocityActionType.java new file mode 100644 index 000000000..96b7fe0b7 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/AddVelocityActionType.java @@ -0,0 +1,46 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Space; +import net.minecraft.world.entity.Entity; +import org.apache.commons.lang3.function.TriConsumer; +import org.jetbrains.annotations.NotNull; +import org.joml.Vector3f; + +public class AddVelocityActionType { + + public static void action(Entity entity, Vector3f velocity, @NotNull Space space, boolean set) { + + TriConsumer method = set + ? entity::setDeltaMovement + : entity::push; + + space.toGlobal(velocity, entity); + method.accept(velocity.x(), velocity.y(), velocity.z()); + + entity.hurtMarked = true; + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("add_velocity"), + new SerializableData() + .add("x", SerializableDataTypes.FLOAT, 0.0F) + .add("y", SerializableDataTypes.FLOAT, 0.0F) + .add("z", SerializableDataTypes.FLOAT, 0.0F) + .add("space", ApoliDataTypes.SPACE, Space.WORLD) + .add("set", SerializableDataTypes.BOOLEAN, false), + (data, entity) -> action(entity, + new Vector3f(data.get("x"), data.get("y"), data.get("z")), + data.get("space"), + data.get("set") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/AddXpActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/AddXpActionType.java new file mode 100644 index 000000000..83c4796ce --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/AddXpActionType.java @@ -0,0 +1,37 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.NotNull; + +public class AddXpActionType { + + public static void action(Entity entity, int points, int levels) { + + if (!(entity instanceof Player player)) { + return; + } + + player.giveExperiencePoints(points); + player.giveExperienceLevels(levels); + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("add_xp"), + new SerializableData() + .add("points", SerializableDataTypes.INT, 0) + .add("levels", SerializableDataTypes.INT, 0), + (data, entity) -> action(entity, + data.get("points"), + data.get("levels") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ApplyEffectActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ApplyEffectActionType.java new file mode 100644 index 000000000..b1070778e --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ApplyEffectActionType.java @@ -0,0 +1,45 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.LinkedList; + +public class ApplyEffectActionType { + + public static void action(@NotNull Entity entity, Collection effects) { + + if (!entity.level().isClientSide && entity instanceof LivingEntity living) { + effects.forEach(living::addEffect); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("apply_effect"), + new SerializableData() + .add("effect", SerializableDataTypes.STATUS_EFFECT_INSTANCE, null) + .add("effects", SerializableDataBuilder.of(SerializableDataTypes.STATUS_EFFECT_INSTANCE.listOf()), null), + (data, entity) -> { + + Collection effects = new LinkedList<>(); + + data.ifPresent("effect", effects::add); + data.ifPresent("effects", effects::addAll); + + action(entity, effects); + + } + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/AreaOfEffectAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/AreaOfEffectActionType.java similarity index 57% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/AreaOfEffectAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/AreaOfEffectActionType.java index bdee5a378..b54b8a30e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/AreaOfEffectAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/AreaOfEffectActionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Shape; import net.minecraft.util.Tuple; @@ -13,25 +13,19 @@ import java.util.function.Consumer; import java.util.function.Predicate; -public class AreaOfEffectAction { +public class AreaOfEffectActionType { - public static void action(@NotNull SerializableData.Instance data, @NotNull Entity entity) { - - Consumer> biEntityAction = data.get("bientity_action"); - Predicate> biEntityCondition = data.get("bientity_condition"); - Shape shape = data.get("shape"); - - boolean includeActor = data.get("include_actor"); - double radius = data.get("radius"); + public static void action(@NotNull Entity entity, Consumer> biEntityAction, Predicate> biEntityCondition, Shape shape, double radius, boolean includeActor) { for (Entity target : Shape.getEntities(shape, entity.level(), entity.getPosition(1.0f), radius)) { - if (target == entity && !includeActor) { + if (entity.equals(target) && !includeActor) { continue; } Tuple actorAndTarget = new Tuple<>(entity, target); - if (biEntityCondition == null || biEntityCondition.test(actorAndTarget)) { + + if (biEntityCondition.test(actorAndTarget)) { biEntityAction.accept(actorAndTarget); } @@ -42,14 +36,22 @@ public static void action(@NotNull SerializableData.Instance data, @NotNull Enti public static @NotNull ActionTypeFactory getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("area_of_effect"), - SerializableData.serializableData() - .add("radius", SerializableDataTypes.DOUBLE, 16D) - .add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE) + new SerializableData() .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) - .add("include_target", SerializableDataTypes.BOOLEAN, false) + .add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE) + .add("radius", SerializableDataTypes.DOUBLE, 16D) .add("include_actor", SerializableDataTypes.BOOLEAN, false), - AreaOfEffectAction::action + (data, entity) -> action(entity, + data.getOrElse("bientity_action", actorAndTarget -> { + }), + data.getOrElse("bientity_condition", actorAndTarget -> true), + data.get("shape"), + data.get("radius"), + data.get("include_actor") + ) ); } + } + diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/BlockActionAtActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/BlockActionAtActionType.java new file mode 100644 index 000000000..b27d48aee --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/BlockActionAtActionType.java @@ -0,0 +1,33 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; + +public class BlockActionAtActionType { + + public static void action(@NotNull Entity entity, @NotNull Consumer> blockAction) { + blockAction.accept(Triple.of(entity.level(), entity.blockPosition(), Direction.UP)); + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("block_action_at"), + new SerializableData() + .add("block_action", ApoliDataTypes.BLOCK_ACTION), + (data, entity) -> action(entity, + data.get("block_action") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ChangeResourceActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ChangeResourceActionType.java new file mode 100644 index 000000000..5f80cd936 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ChangeResourceActionType.java @@ -0,0 +1,68 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.ResourceOperation; +import io.github.dueris.originspaper.power.type.CooldownPower; +import io.github.dueris.originspaper.power.type.ResourcePower; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class ChangeResourceActionType { + + public static void action(Entity entity, PowerReference power, ResourceOperation operation, int change) { + + int oldValue; + int newValue; + + switch (power.getType()) { + case ResourcePower varInt -> { + + oldValue = varInt.getValue(entity); + newValue = processValue(operation, oldValue, change); + + varInt.setValue(entity, newValue); + + } + case CooldownPower cooldown -> { + + oldValue = cooldown.getRemainingTicks(entity); + newValue = processValue(operation, oldValue, change); + + cooldown.setCooldown(entity, newValue); + + } + case null, default -> { + + } + } + + } + + private static int processValue(@NotNull ResourceOperation operation, int oldValue, int newValue) { + return switch (operation) { + case ADD -> oldValue + newValue; + case SET -> newValue; + }; + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("change_resource"), + new SerializableData() + .add("resource", ApoliDataTypes.POWER_REFERENCE) + .add("operation", ApoliDataTypes.RESOURCE_OPERATION, ResourceOperation.ADD) + .add("change", SerializableDataTypes.INT), + (data, entity) -> action(entity, + data.get("resource"), + data.get("operation"), + data.get("change") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ClearEffectActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ClearEffectActionType.java new file mode 100644 index 000000000..9665ac999 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ClearEffectActionType.java @@ -0,0 +1,52 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.core.Holder; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.LinkedList; + +public class ClearEffectActionType { + + public static void action(Entity entity, Collection> effects) { + + if (entity instanceof LivingEntity living) { + + if (!effects.isEmpty()) { + effects.forEach(living::removeEffect); + } else { + living.removeAllEffects(); + } + + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("clear_effect"), + new SerializableData() + .add("effect", SerializableDataTypes.STATUS_EFFECT_ENTRY, null) + .add("effects", SerializableDataBuilder.of(SerializableDataTypes.STATUS_EFFECT_ENTRY.listOf()), null), + (data, entity) -> { + + Collection> effects = new LinkedList<>(); + + data.ifPresent("effect", effects::add); + data.ifPresent("effects", effects::addAll); + + action(entity, effects); + + } + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/CraftingTableActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/CraftingTableActionType.java new file mode 100644 index 000000000..285f2ca96 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/CraftingTableActionType.java @@ -0,0 +1,19 @@ +package io.github.dueris.originspaper.action.type.entity; + +import net.minecraft.stats.Stats; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; + +public class CraftingTableActionType { + + public static void action(Entity entity) { + + if (!(entity instanceof Player player)) { + return; + } + + player.getBukkitEntity().openWorkbench(null, true); + player.awardStat(Stats.INTERACT_WITH_CRAFTING_TABLE); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/DamageActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/DamageActionType.java new file mode 100644 index 000000000..63163bb4c --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/DamageActionType.java @@ -0,0 +1,73 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.types.modifier.Modifier; +import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; +import io.github.dueris.originspaper.util.Util; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageType; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.bukkit.craftbukkit.CraftRegistry; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.LinkedList; + +public class DamageActionType { + + public static void action(Entity entity, ResourceKey damageTypeKey, @Nullable Float amount, @NotNull Collection modifiers) { + + if (!modifiers.isEmpty() && entity instanceof LivingEntity living) { + amount = (float) ModifierUtil.applyModifiers(entity, modifiers.stream().toList(), living.getMaxHealth()); + } + + if (amount != null) { + entity.hurt(source(damageTypeKey), amount); + } + + } + + private static @NotNull DamageSource source(ResourceKey key) { + return new DamageSource(CraftRegistry.getMinecraftRegistry().registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(key)); + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("damage"), + new SerializableData() + .add("damage_type", SerializableDataTypes.DAMAGE_TYPE) + .add("amount", SerializableDataTypes.FLOAT, null) + .add("modifier", Modifier.DATA_TYPE, null) + .add("modifiers", Modifier.LIST_TYPE, null) + .postProcessor(data -> { + + if (!data.isPresent("amount") && !Util.anyPresent(data, "modifier", "modifiers")) { + throw new IllegalStateException("Any of 'amount', 'modifier', or 'modifiers' fields must be defined!"); + } + + }), + (data, entity) -> { + + Collection modifiers = new LinkedList<>(); + + data.ifPresent("modifier", modifiers::add); + data.ifPresent("modifiers", modifiers::addAll); + + action(entity, + data.get("damage_type"), + data.get("amount"), + modifiers + ); + + } + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/DropInventoryAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/DropInventoryActionType.java similarity index 57% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/DropInventoryAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/DropInventoryActionType.java index c17e67308..821d7ae86 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/DropInventoryAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/DropInventoryActionType.java @@ -1,41 +1,45 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.InventoryType; import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; + +import java.util.Objects; import static io.github.dueris.originspaper.util.Util.dropInventory; -public class DropInventoryAction { +public class DropInventoryActionType { - public static void action(@NotNull SerializableData.Instance data, Entity entity) { + public static void action(SerializableData.Instance data, Entity entity) { InventoryType inventoryType = data.get("inventory_type"); - switch (inventoryType) { - case INVENTORY -> dropInventory(data, entity); + if (Objects.requireNonNull(inventoryType) == InventoryType.INVENTORY) { + dropInventory(data, entity); } } - public static @NotNull ActionTypeFactory getFactory() { + public static ActionTypeFactory getFactory() { return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("drop_inventory"), - SerializableData.serializableData() + new SerializableData() .add("inventory_type", ApoliDataTypes.INVENTORY_TYPE, InventoryType.INVENTORY) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("item_action", ApoliDataTypes.ITEM_ACTION, null) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) - .add("slots", SerializableDataTypes.list(ApoliDataTypes.ITEM_SLOT), null) + .add("slots", SerializableDataBuilder.of(ApoliDataTypes.ITEM_SLOT.listOf()), null) .add("slot", ApoliDataTypes.ITEM_SLOT, null) + .add("power", ApoliDataTypes.POWER_REFERENCE, null) .add("throw_randomly", SerializableDataTypes.BOOLEAN, false) .add("retain_ownership", SerializableDataTypes.BOOLEAN, true) .add("amount", SerializableDataTypes.INT, 0), - DropInventoryAction::action + DropInventoryActionType::action ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/EmitGameEventActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/EmitGameEventActionType.java new file mode 100644 index 000000000..fd866cf93 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/EmitGameEventActionType.java @@ -0,0 +1,29 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.core.Holder; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.gameevent.GameEvent; +import org.jetbrains.annotations.NotNull; + +public class EmitGameEventActionType { + + public static void action(@NotNull Entity entity, Holder gameEvent) { + entity.gameEvent(gameEvent); + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("emit_game_event"), + new SerializableData() + .add("event", SerializableDataTypes.GAME_EVENT_ENTRY), + (data, entity) -> action(entity, + data.get("event") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/EnderChestActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/EnderChestActionType.java new file mode 100644 index 000000000..e8690b563 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/EnderChestActionType.java @@ -0,0 +1,29 @@ +package io.github.dueris.originspaper.action.type.entity; + +import net.minecraft.network.chat.Component; +import net.minecraft.stats.Stats; +import net.minecraft.world.SimpleMenuProvider; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.ChestMenu; +import net.minecraft.world.inventory.MenuConstructor; +import net.minecraft.world.inventory.PlayerEnderChestContainer; + +public class EnderChestActionType { + + public static void action(Entity entity) { + + if (!(entity instanceof Player player)) { + return; + } + + PlayerEnderChestContainer enderChestContainer = player.getEnderChestInventory(); + MenuConstructor handlerFactory = (syncId, playerInventory, _player) -> ChestMenu.threeRows(syncId, playerInventory, enderChestContainer); + + player.openMenu(new SimpleMenuProvider(handlerFactory, Component.translatable("container.enderchest"))); + player.awardStat(Stats.OPEN_ENDERCHEST); + + } + +} + diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/EquippedItemAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/EquippedItemActionType.java similarity index 67% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/EquippedItemAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/EquippedItemActionType.java index 7b8b3b80b..dec4b1714 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/EquippedItemAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/EquippedItemActionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; @@ -15,17 +15,14 @@ import java.util.function.Consumer; -public class EquippedItemAction { +public class EquippedItemActionType { - public static void action(SerializableData.Instance data, Entity entity) { + public static void action(Entity entity, EquipmentSlot slot, Consumer> itemAction) { if (!(entity instanceof LivingEntity livingEntity)) { return; } - EquipmentSlot slot = data.get("equipment_slot"); - Consumer> itemAction = data.get("action"); - SlotAccess stackReference = SlotAccess.forEquipmentSlot(livingEntity, slot); itemAction.accept(new Tuple<>(entity.level(), stackReference)); @@ -34,10 +31,14 @@ public static void action(SerializableData.Instance data, Entity entity) { public static @NotNull ActionTypeFactory getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("equipped_item_action"), - SerializableData.serializableData() + new SerializableData() .add("equipment_slot", SerializableDataTypes.EQUIPMENT_SLOT) .add("action", ApoliDataTypes.ITEM_ACTION), - EquippedItemAction::action + (data, entity) -> action(entity, + data.get("equipment_slot"), + data.get("action") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ExecuteCommandActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ExecuteCommandActionType.java new file mode 100644 index 000000000..02a9d85ad --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ExecuteCommandActionType.java @@ -0,0 +1,41 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.commands.CommandSource; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class ExecuteCommandActionType { + + public static void action(@NotNull Entity entity, String command) { + + MinecraftServer server = entity.getServer(); + if (server == null) { + return; + } + + CommandSourceStack source = entity.createCommandSourceStack() + .withSource(OriginsPaper.showCommandOutput ? entity : CommandSource.NULL) + .withPermission(4); + + server.getCommands().performPrefixedCommand(source, command); + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("execute_command"), + new SerializableData() + .add("command", SerializableDataTypes.STRING), + (data, entity) -> action(entity, + data.get("command") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ExhaustActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ExhaustActionType.java new file mode 100644 index 000000000..06033a8fd --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ExhaustActionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.NotNull; + +public class ExhaustActionType { + + public static void action(Entity entity, float amount) { + + if (entity instanceof Player player) { + player.causeFoodExhaustion(amount); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("exhaust"), + new SerializableData() + .add("amount", SerializableDataTypes.FLOAT), + (data, entity) -> action(entity, + data.get("amount") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ExplodeActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ExplodeActionType.java new file mode 100644 index 000000000..20e8d049a --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ExplodeActionType.java @@ -0,0 +1,70 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.util.Util; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Predicate; + +public class ExplodeActionType { + + public static void action(@NotNull Entity entity, float power, Explosion.BlockInteraction destructionType, @Nullable Predicate indestructibleCondition, float indestructibleResistance, @Nullable Predicate destructibleCondition, boolean damageSelf, boolean createFire) { + + Level world = entity.level(); + if (world.isClientSide) { + return; + } + + if (destructibleCondition != null) { + indestructibleCondition = Util.combineOr(destructibleCondition.negate(), indestructibleCondition); + } + + Vec3 pos = entity.position(); + Util.createExplosion( + world, + damageSelf ? null : entity, + Explosion.getDefaultDamageSource(world, entity), + pos.x(), + pos.y(), + pos.z(), + power, + createFire, + destructionType, + Util.getExplosionBehavior(world, indestructibleResistance, indestructibleCondition) + ); + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("explode"), + new SerializableData() + .add("power", SerializableDataTypes.FLOAT) + .add("destruction_type", ApoliDataTypes.DESTRUCTION_TYPE, Explosion.BlockInteraction.DESTROY) + .add("indestructible", ApoliDataTypes.BLOCK_CONDITION, null) + .add("indestructible_resistance", SerializableDataTypes.FLOAT, 10.0f) + .add("destructible", ApoliDataTypes.BLOCK_CONDITION, null) + .add("damage_self", SerializableDataTypes.BOOLEAN, true) + .add("create_fire", SerializableDataTypes.BOOLEAN, false), + (data, entity) -> action(entity, + data.get("power"), + data.get("destruction_type"), + data.get("indestructible"), + data.get("indestructible_resistance"), + data.get("destructible"), + data.get("damage_self"), + data.get("create_fire") + ) + ); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/FeedActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/FeedActionType.java new file mode 100644 index 000000000..112ef10f8 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/FeedActionType.java @@ -0,0 +1,34 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.NotNull; + +public class FeedActionType { + + public static void action(Entity entity, int nutrition, float saturation) { + + if (entity instanceof Player player) { + player.getFoodData().eat(nutrition, saturation); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("feed"), + new SerializableData() + .add("nutrition", SerializableDataTypes.INT) + .add("saturation", SerializableDataTypes.FLOAT), + (data, entity) -> action(entity, + data.get("nutrition"), + data.get("saturation") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/FireProjectileAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/FireProjectileActionType.java similarity index 85% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/FireProjectileAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/FireProjectileActionType.java index 4c8ab6c3e..2fd9cb5ca 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/FireProjectileAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/FireProjectileActionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.util.Util; import net.minecraft.nbt.CompoundTag; @@ -19,7 +19,7 @@ import java.util.function.Consumer; -public class FireProjectileAction { +public class FireProjectileActionType { public static void action(Entity entity, EntityType entityType, Consumer projectileAction, CompoundTag entityNbt, float divergence, float speed, int count) { @@ -92,24 +92,23 @@ public static void action(Entity entity, EntityType entityType, Consumer getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("fire_projectile"), - SerializableData.serializableData() + new SerializableData() .add("entity_type", SerializableDataTypes.ENTITY_TYPE) + .add("projectile_action", ApoliDataTypes.ENTITY_ACTION, null) + .add("tag", SerializableDataTypes.NBT_COMPOUND, new CompoundTag()) .add("divergence", SerializableDataTypes.FLOAT, 1F) .add("speed", SerializableDataTypes.FLOAT, 1.5F) - .add("count", SerializableDataTypes.INT, 1) - .add("tag", SerializableDataTypes.NBT_COMPOUND, new CompoundTag()) - .add("projectile_action", ApoliDataTypes.ENTITY_ACTION, null), - (data, entity) -> { - action(entity, - data.get("entity_type"), - data.getOrDefault("projectile_action", e -> { - }), - data.get("tag"), - data.get("divergence"), - data.get("speed"), - data.get("count") - ); - } + .add("count", SerializableDataTypes.INT, 1), + (data, entity) -> action(entity, + data.get("entity_type"), + data.getOrElse("projectile_action", e -> { + }), + data.get("tag"), + data.get("divergence"), + data.get("speed"), + data.get("count") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GainAirActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GainAirActionType.java new file mode 100644 index 000000000..853c77f2d --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GainAirActionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +public class GainAirActionType { + + public static void action(Entity entity, int value) { + + if (entity instanceof LivingEntity living) { + living.setAirSupply(Math.min(living.getAirSupply() + value, living.getMaxAirSupply())); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("gain_air"), + new SerializableData() + .add("value", SerializableDataTypes.INT), + (data, entity) -> action(entity, + data.get("value") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GiveActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GiveActionType.java new file mode 100644 index 000000000..0785161af --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GiveActionType.java @@ -0,0 +1,83 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.util.Util; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.SlotAccess; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Consumer; + +public class GiveActionType { + + public static void action(@NotNull Entity entity, ItemStack newStack, Consumer> itemAction, @Nullable EquipmentSlot preferredSlot) { + + if (entity.level().isClientSide || newStack.isEmpty()) { + return; + } + + SlotAccess stackReference = Util.createStackReference(newStack); + itemAction.accept(new Tuple<>(entity.level(), stackReference)); + + ItemStack stackToGive = stackReference.get(); + + tryPreferredSlot: + if (preferredSlot != null && entity instanceof LivingEntity living) { + + ItemStack stackInSlot = living.getItemBySlot(preferredSlot); + if (stackInSlot.isEmpty()) { + living.setItemSlot(preferredSlot, stackToGive); + return; + } + + if (!ItemStack.matches(stackInSlot, stackToGive) || stackInSlot.getCount() >= stackInSlot.getMaxStackSize()) { + break tryPreferredSlot; + } + + int itemsToGive = Math.min(stackInSlot.getMaxStackSize() - stackInSlot.getCount(), stackToGive.getCount()); + + stackInSlot.grow(itemsToGive); + stackToGive.shrink(itemsToGive); + + if (stackToGive.isEmpty()) { + return; + } + + } + + if (entity instanceof Player player) { + player.getInventory().placeItemBackInInventory(stackToGive); + } else { + Util.throwItem(entity, stackToGive, false, false); + } + + } + + public static ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("give"), + new SerializableData() + .add("stack", SerializableDataTypes.ITEM_STACK) + .add("item_action", ApoliDataTypes.ITEM_ACTION, null) + .add("preferred_slot", SerializableDataTypes.EQUIPMENT_SLOT, null), + (data, entity) -> action(entity, + data.get("stack").copy(), + data.getOrElse("item_action", wsr -> { + }), + data.get("preferred_slot") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GrantAdvancementActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GrantAdvancementActionType.java new file mode 100644 index 000000000..917b1d3d7 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GrantAdvancementActionType.java @@ -0,0 +1,60 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.advancements.AdvancementProgress; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.advancement.CraftAdvancement; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.HashSet; + +public class GrantAdvancementActionType { + + public static void action(@NotNull Entity entity, @Nullable ResourceLocation advancementId, Collection criteria) { + + MinecraftServer server = entity.getServer(); + if (server == null || !(entity instanceof ServerPlayer serverPlayerEntity)) { + return; + } + + AdvancementHolder holder = ((CraftAdvancement) Bukkit.getAdvancement(CraftNamespacedKey.fromMinecraft(advancementId))).getHandle(); + AdvancementProgress progress = serverPlayerEntity.getAdvancements().getOrStartProgress(holder); + + for (String remainingCriterion : criteria.isEmpty() ? progress.getRemainingCriteria() : criteria) { + progress.grantProgress(remainingCriterion); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("grant_advancement"), + new SerializableData() + .add("advancement", SerializableDataTypes.IDENTIFIER, null) + .add("criterion", SerializableDataTypes.STRING, null) + .add("criteria", SerializableDataTypes.STRINGS, null), + (data, entity) -> { + + Collection criteria = new HashSet<>(); + + data.ifPresent("criterion", criteria::add); + data.ifPresent("criteria", criteria::addAll); + + action(entity, data.get("advancement"), criteria); + + } + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GrantPowerActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GrantPowerActionType.java new file mode 100644 index 000000000..0814047d5 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/GrantPowerActionType.java @@ -0,0 +1,36 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerReference; +import io.github.dueris.originspaper.util.entity.PowerUtils; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class GrantPowerActionType { + + public static void action(@NotNull Entity entity, PowerReference power, ResourceLocation source) { + if (entity.getBukkitEntity() instanceof Player) { + PowerUtils.grantPower(entity.getBukkitEntity(), power.getType(), (Player) entity.getBukkitEntity(), OriginsPaper.getLayer(source), true); + } + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("grant_power"), + new SerializableData() + .add("power", ApoliDataTypes.POWER_REFERENCE) + .add("source", SerializableDataTypes.IDENTIFIER), + (data, entity) -> action(entity, + data.get("power"), + data.get("source") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/HealActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/HealActionType.java new file mode 100644 index 000000000..83df7e1e9 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/HealActionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +public class HealActionType { + + public static void action(Entity entity, float amount) { + + if (entity instanceof LivingEntity living) { + living.heal(amount); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("heal"), + new SerializableData() + .add("amount", SerializableDataTypes.FLOAT), + (data, entity) -> action(entity, + data.get("amount") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyDeathTicksAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyDeathTicksActionType.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyDeathTicksAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyDeathTicksActionType.java index c6c7ed6c0..3bbb64520 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyDeathTicksAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyDeathTicksActionType.java @@ -1,26 +1,31 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import org.jetbrains.annotations.NotNull; -public class ModifyDeathTicksAction { +public class ModifyDeathTicksActionType { + + public static void action(Entity entity, Modifier modifier) { - public static void action(SerializableData.Instance data, Entity entity) { if (entity instanceof LivingEntity living) { - living.deathTime = (int) data.get("modifier").apply(entity, living.deathTime); + living.deathTime = (int) modifier.apply(entity, living.deathTime); } + } public static @NotNull ActionTypeFactory getFactory() { return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("modify_death_ticks"), - SerializableData.serializableData() + new SerializableData() .add("modifier", Modifier.DATA_TYPE), - ModifyDeathTicksAction::action + (data, entity) -> action(entity, + data.get("modifier") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyInventoryAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyInventoryActionType.java similarity index 57% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyInventoryAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyInventoryActionType.java index b9f99dc94..8e1a86900 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyInventoryAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyInventoryActionType.java @@ -1,44 +1,46 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.InventoryType; import io.github.dueris.originspaper.util.Util; import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; + +import java.util.Objects; import static io.github.dueris.originspaper.util.Util.modifyInventory; -public class ModifyInventoryAction { +public class ModifyInventoryActionType { - public static void action(@NotNull SerializableData.Instance data, Entity entity) { + public static void action(SerializableData.Instance data, Entity entity) { InventoryType inventoryType = data.get("inventory_type"); Util.ProcessMode processMode = data.get("process_mode"); int limit = data.getInt("limit"); - switch (inventoryType) { - case INVENTORY: - modifyInventory(data, entity, processMode.getProcessor(), limit); - break; + if (Objects.requireNonNull(inventoryType) == InventoryType.INVENTORY) { + modifyInventory(data, entity, processMode.getProcessor(), limit); } } - public static @NotNull ActionTypeFactory getFactory() { + public static ActionTypeFactory getFactory() { return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("modify_inventory"), - SerializableData.serializableData() + new SerializableData() .add("inventory_type", ApoliDataTypes.INVENTORY_TYPE, InventoryType.INVENTORY) .add("process_mode", ApoliDataTypes.PROCESS_MODE, Util.ProcessMode.STACKS) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("item_action", ApoliDataTypes.ITEM_ACTION) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) - .add("slots", SerializableDataTypes.list(ApoliDataTypes.ITEM_SLOT), null) + .add("slots", SerializableDataBuilder.of(ApoliDataTypes.ITEM_SLOT.listOf()), null) .add("slot", ApoliDataTypes.ITEM_SLOT, null) + .add("power", ApoliDataTypes.POWER_REFERENCE, null) .add("limit", SerializableDataTypes.INT, 0), - ModifyInventoryAction::action + ModifyInventoryActionType::action ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyResourceActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyResourceActionType.java new file mode 100644 index 000000000..63a106ae9 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyResourceActionType.java @@ -0,0 +1,56 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.modifier.Modifier; +import io.github.dueris.originspaper.power.type.CooldownPower; +import io.github.dueris.originspaper.power.type.ResourcePower; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class ModifyResourceActionType { + + public static void action(Entity entity, PowerReference power, Modifier modifier) { + + int oldValue; + int newValue; + + switch (power.getType()) { + case ResourcePower varInt -> { + + oldValue = varInt.getValue(entity); + newValue = (int) modifier.apply(entity, oldValue); + + varInt.setValue(entity, newValue); + + } + case CooldownPower cooldown -> { + + oldValue = cooldown.getRemainingTicks(entity); + newValue = Math.max((int) modifier.apply(entity, oldValue), 0); + + cooldown.setCooldown(entity, newValue); + + } + case null, default -> { + + } + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("modify_resource"), + new SerializableData() + .add("resource", ApoliDataTypes.POWER_REFERENCE) + .add("modifier", Modifier.DATA_TYPE), + (data, entity) -> action(entity, + data.get("resource"), + data.get("modifier") + ) + ); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyStatAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyStatActionType.java similarity index 50% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyStatAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyStatActionType.java index 749fd2123..129b46607 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyStatAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ModifyStatActionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.stats.ServerStatsCounter; @@ -11,31 +11,32 @@ import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; -public class ModifyStatAction { +public class ModifyStatActionType { - public static void action(SerializableData.Instance data, Entity entity) { - if (!(entity instanceof ServerPlayer serverPlayerEntity)) return; + public static void action(Entity entity, Stat stat, Modifier modifier) { - Stat stat = data.get("stat"); - ServerStatsCounter serverStatHandler = serverPlayerEntity.getStats(); + if (!(entity instanceof ServerPlayer serverPlayerEntity)) { + return; + } - int newValue; + ServerStatsCounter serverStatHandler = serverPlayerEntity.getStats(); int originalValue = serverStatHandler.getValue(stat); serverPlayerEntity.resetStat(stat); + serverPlayerEntity.awardStat(stat, (int) modifier.apply(entity, originalValue)); - Modifier modifier = data.get("modifier"); - newValue = (int) modifier.apply(entity, originalValue); - - serverPlayerEntity.awardStat(stat, newValue); } public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("modify_stat"), - SerializableData.serializableData() + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("modify_stat"), + new SerializableData() .add("stat", SerializableDataTypes.STAT) .add("modifier", Modifier.DATA_TYPE), - ModifyStatAction::action + (data, entity) -> action(entity, + data.get("stat"), + data.get("modifier") + ) ); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/PassengerActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/PassengerActionType.java new file mode 100644 index 000000000..175bbcd01 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/PassengerActionType.java @@ -0,0 +1,59 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; +import java.util.function.Predicate; + +public class PassengerActionType { + + public static void action(@NotNull Entity entity, Consumer entityAction, Consumer> biEntityAction, Predicate> biEntityCondition, boolean recursive) { + + if (!entity.isVehicle()) { + return; + } + + Iterable passengers = recursive + ? entity.getIndirectPassengers() + : entity.getPassengers(); + + for (Entity passenger : passengers) { + + Tuple actorAndTarget = new Tuple<>(passenger, entity); + + if (biEntityCondition.test(actorAndTarget)) { + entityAction.accept(passenger); + biEntityAction.accept(actorAndTarget); + } + + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("passenger_action"), + new SerializableData() + .add("action", ApoliDataTypes.ENTITY_ACTION, null) + .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) + .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) + .add("recursive", SerializableDataTypes.BOOLEAN, false), + (data, entity) -> action(entity, + data.getOrElse("action", e -> { + }), + data.getOrElse("bientity_action", actorAndTarget -> { + }), + data.getOrElse("bientity_condition", actorAndTarget -> true), + data.get("recursive") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/PlaySoundActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/PlaySoundActionType.java new file mode 100644 index 000000000..9293d1e9d --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/PlaySoundActionType.java @@ -0,0 +1,36 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class PlaySoundActionType { + + public static void action(@NotNull Entity entity, SoundEvent sound, @Nullable SoundSource category, float volume, float pitch) { + entity.level().playSound(null, entity.blockPosition(), sound, category != null ? category : entity.getSoundSource(), volume, pitch); + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("play_sound"), + new SerializableData() + .add("sound", SerializableDataTypes.SOUND_EVENT) + .add("category", SerializableDataTypes.enumValue(SoundSource.class), null) + .add("volume", SerializableDataTypes.FLOAT, 1.0f) + .add("pitch", SerializableDataTypes.FLOAT, 1.0f), + (data, entity) -> action(entity, + data.get("sound"), + data.get("category"), + data.get("volume"), + data.get("pitch") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RandomTeleportAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RandomTeleportActionType.java similarity index 71% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RandomTeleportAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RandomTeleportActionType.java index 9fabede37..d1b81688c 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RandomTeleportAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RandomTeleportActionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; @@ -16,36 +16,24 @@ import net.minecraft.world.level.block.state.pattern.BlockInWorld; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; +import java.util.Optional; import java.util.function.Consumer; import java.util.function.Predicate; -public class RandomTeleportAction { +public class RandomTeleportActionType { - public static void action(SerializableData.Instance data, @NotNull Entity entity) { + public static void action(Entity entity, Consumer successAction, Consumer failAction, Predicate landingCondition, Predicate landingBlockCondition, Vec3 landingOffset, Heightmap.Types heightmap, boolean loadedChunksOnly, double areaWidth, double areaHeight, Optional attemptOptional) { if (!(entity.level() instanceof ServerLevel serverWorld)) { return; } - Predicate landingBlockCondition = data.isPresent("landing_block_condition") ? data.get("landing_block_condition") - : cachedBlockPosition -> cachedBlockPosition.getState().blocksMotion(); - Predicate landingCondition = data.isPresent("landing_condition") ? data.get("landing_condition") - : _entity -> serverWorld.noCollision(_entity) && !serverWorld.containsAnyLiquid(_entity.getBoundingBox()); - - Heightmap.Types heightmap = data.get("heightmap"); RandomSource random = RandomSource.create(); - Vec3 landingOffset = data.get("landing_offset"); - - boolean loadedChunksOnly = data.getBoolean("loaded_chunks_only"); boolean succeeded = false; - int attempts = data.isPresent("attempts") ? (int) ((data.getDouble("area_width") * 2) + (data.getDouble("area_height") * 2)) : 1; - - double areaWidth = data.getDouble("area_width") * 2; - double areaHeight = data.getDouble("area_height") * 2; double x, y, z; + int attempts = attemptOptional.orElse((int) ((areaWidth * 2) + (areaHeight * 2))); for (int i = 0; i < attempts; i++) { @@ -55,7 +43,7 @@ public static void action(SerializableData.Instance data, @NotNull Entity entity if (attemptToTeleport(entity, serverWorld, x, y, z, landingOffset.x(), landingOffset.y(), landingOffset.z(), areaHeight, loadedChunksOnly, heightmap, landingBlockCondition, landingCondition)) { - data.>ifPresent("success_action", successAction -> successAction.accept(entity)); + successAction.accept(entity); entity.resetFallDistance(); succeeded = true; @@ -66,7 +54,7 @@ public static void action(SerializableData.Instance data, @NotNull Entity entity } if (!succeeded) { - data.>ifPresent("fail_action", failAction -> failAction.accept(entity)); + failAction.accept(entity); } } @@ -145,21 +133,43 @@ private static boolean attemptToTeleport(Entity entity, ServerLevel serverWorld, } - public static @NotNull ActionTypeFactory getFactory() { + public static ActionTypeFactory getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("random_teleport"), - SerializableData.serializableData() - .add("area_width", SerializableDataTypes.DOUBLE, 8.0) - .add("area_height", SerializableDataTypes.DOUBLE, 8.0) - .add("heightmap", SerializableDataTypes.enumValue(Heightmap.Types.class), null) - .add("attempts", SerializableDataTypes.INT, 0) - .add("landing_block_condition", ApoliDataTypes.BLOCK_CONDITION, null) + new SerializableData() + .add("success_action", ApoliDataTypes.ENTITY_ACTION, null) + .add("fail_action", ApoliDataTypes.ENTITY_ACTION, null) .add("landing_condition", ApoliDataTypes.ENTITY_CONDITION, null) + .add("landing_block_condition", ApoliDataTypes.BLOCK_CONDITION, null) .add("landing_offset", SerializableDataTypes.VECTOR, Vec3.ZERO) + .add("heightmap", SerializableDataTypes.enumValue(Heightmap.Types.class), null) .add("loaded_chunks_only", SerializableDataTypes.BOOLEAN, true) - .add("success_action", ApoliDataTypes.ENTITY_ACTION, null) - .add("fail_action", ApoliDataTypes.ENTITY_ACTION, null), - RandomTeleportAction::action + .add("area_width", SerializableDataTypes.DOUBLE, 8.0) + .add("area_height", SerializableDataTypes.DOUBLE, 8.0) + .add("attempts", SerializableDataTypes.optional(SerializableDataTypes.INT), Optional.empty()), + (data, entity) -> { + + if (!(entity.level() instanceof ServerLevel serverWorld)) { + return; + } + + action(entity, + data.getOrElse("success_action", e -> { + }), + data.getOrElse("fail_action", e -> { + }), + data.getOrElse("landing_condition", e -> serverWorld.noCollision(e) && !serverWorld.containsAnyLiquid(e.getBoundingBox())), + data.getOrElse("landing_block_condition", cachedBlock -> cachedBlock.getState().blocksMotion()), + data.get("landing_offset"), + data.get("heightmap"), + data.get("loaded_chunks_only"), + data.getDouble("area_width") * 2, + data.getDouble("area_height") * 2, + data.get("attempts") + ); + + } ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RaycastAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RaycastActionType.java similarity index 88% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RaycastAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RaycastActionType.java index 569b90fb0..b1df5a8db 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RaycastAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RaycastActionType.java @@ -1,10 +1,10 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Space; import net.minecraft.commands.CommandSource; @@ -28,9 +28,9 @@ import java.util.function.Consumer; -public class RaycastAction { +public class RaycastActionType { - public static void action(@NotNull SerializableData.Instance data, @NotNull Entity entity) { + public static void action(SerializableData.@NotNull Instance data, @NotNull Entity entity) { Vec3 origin = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ()); Vec3 direction = entity.getViewVector(1); @@ -114,7 +114,7 @@ public static void action(@NotNull SerializableData.Instance data, @NotNull Enti } } - private static double getEntityReach(@NotNull SerializableData.Instance data, Entity entity) { + private static double getEntityReach(SerializableData.Instance data, Entity entity) { if (!data.isPresent("entity_distance") && !data.isPresent("distance")) { return entity instanceof LivingEntity livingEntity && livingEntity.getAttributes().hasAttribute(Attributes.ENTITY_INTERACTION_RANGE) @@ -128,7 +128,7 @@ private static double getEntityReach(@NotNull SerializableData.Instance data, En } - private static double getBlockReach(@NotNull SerializableData.Instance data, Entity entity) { + private static double getBlockReach(SerializableData.Instance data, Entity entity) { if (!data.isPresent("block_distance") && !data.isPresent("distance")) { return entity instanceof LivingEntity livingEntity && livingEntity.getAttributes().hasAttribute(Attributes.BLOCK_INTERACTION_RANGE) @@ -142,7 +142,7 @@ private static double getBlockReach(@NotNull SerializableData.Instance data, Ent } - private static void executeStepCommands(@NotNull Entity entity, Vec3 origin, Vec3 target, String command, double step) { + private static void executeStepCommands(Entity entity, Vec3 origin, Vec3 target, String command, double step) { MinecraftServer server = entity.level().getServer(); if (server != null) { Vec3 direction = target.subtract(origin).normalize(); @@ -164,7 +164,7 @@ private static void executeStepCommands(@NotNull Entity entity, Vec3 origin, Vec } } - private static void executeCommandAtHit(@NotNull Entity entity, Vec3 hitPosition, String command) { + private static void executeCommandAtHit(Entity entity, Vec3 hitPosition, String command) { MinecraftServer server = entity.level().getServer(); if (server != null) { boolean validOutput = !(entity instanceof ServerPlayer) || ((ServerPlayer) entity).connection != null; @@ -182,12 +182,12 @@ private static void executeCommandAtHit(@NotNull Entity entity, Vec3 hitPosition } } - private static @NotNull BlockHitResult performBlockRaycast(Entity source, Vec3 origin, Vec3 target, ClipContext.Block shapeType, ClipContext.Fluid fluidHandling) { + private static BlockHitResult performBlockRaycast(Entity source, Vec3 origin, Vec3 target, ClipContext.Block shapeType, ClipContext.Fluid fluidHandling) { ClipContext context = new ClipContext(origin, target, shapeType, fluidHandling, source); return source.level().clip(context); } - private static EntityHitResult performEntityRaycast(@NotNull Entity source, Vec3 origin, @NotNull Vec3 target, ConditionTypeFactory> biEntityCondition) { + private static EntityHitResult performEntityRaycast(Entity source, Vec3 origin, Vec3 target, ConditionTypeFactory> biEntityCondition) { Vec3 ray = target.subtract(origin); AABB box = source.getBoundingBox().expandTowards(ray).inflate(1.0D, 1.0D, 1.0D); EntityHitResult entityHitResult = ProjectileUtil.getEntityHitResult(source, origin, target, box, (entityx) -> { @@ -196,9 +196,9 @@ private static EntityHitResult performEntityRaycast(@NotNull Entity source, Vec3 return entityHitResult; } - public static @NotNull ActionTypeFactory getFactory() { + public static ActionTypeFactory getFactory() { return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("raycast"), - SerializableData.serializableData() + new SerializableData() .add("distance", SerializableDataTypes.DOUBLE, null) .add("block_distance", SerializableDataTypes.DOUBLE, null) .add("entity_distance", SerializableDataTypes.DOUBLE, null) @@ -219,7 +219,7 @@ private static EntityHitResult performEntityRaycast(@NotNull Entity source, Vec3 .add("before_action", ApoliDataTypes.ENTITY_ACTION, null) .add("hit_action", ApoliDataTypes.ENTITY_ACTION, null) .add("miss_action", ApoliDataTypes.ENTITY_ACTION, null), - RaycastAction::action + RaycastActionType::action ); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RemovePowerActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RemovePowerActionType.java new file mode 100644 index 000000000..1fe2c54e8 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RemovePowerActionType.java @@ -0,0 +1,37 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.origin.OriginLayer; +import io.github.dueris.originspaper.power.factory.PowerReference; +import io.github.dueris.originspaper.storage.OriginComponent; +import io.github.dueris.originspaper.util.entity.PowerUtils; +import net.minecraft.world.entity.Entity; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class RemovePowerActionType { + + public static void action(@NotNull Entity entity, PowerReference power) { + if (!(entity instanceof Player)) return; + + for (OriginLayer layer : OriginComponent.getLayers(entity.getBukkitEntity())) { + PowerUtils.removePower(entity.getBukkitEntity(), power.getType(), (Player) entity.getBukkitEntity(), layer, true); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("remove_power"), + new SerializableData() + .add("power", ApoliDataTypes.POWER_REFERENCE), + (data, entity) -> action(entity, + data.get("power") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ReplaceInventoryAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ReplaceInventoryActionType.java similarity index 60% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ReplaceInventoryAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ReplaceInventoryActionType.java index 6bc32ae30..b2cb48507 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ReplaceInventoryAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ReplaceInventoryActionType.java @@ -1,40 +1,45 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.InventoryType; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; +import java.util.Objects; + import static io.github.dueris.originspaper.util.Util.replaceInventory; -public class ReplaceInventoryAction { +public class ReplaceInventoryActionType { - public static void action(@NotNull SerializableData.Instance data, Entity entity) { + public static void action(SerializableData.@NotNull Instance data, Entity entity) { InventoryType inventoryType = data.get("inventory_type"); - switch (inventoryType) { - case INVENTORY -> replaceInventory(data, entity); + if (Objects.requireNonNull(inventoryType) == InventoryType.INVENTORY) { + replaceInventory(data, entity); } } public static @NotNull ActionTypeFactory getFactory() { return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("replace_inventory"), - SerializableData.serializableData() + new SerializableData() .add("inventory_type", ApoliDataTypes.INVENTORY_TYPE, InventoryType.INVENTORY) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("item_action", ApoliDataTypes.ITEM_ACTION, null) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) - .add("slots", SerializableDataTypes.list(ApoliDataTypes.ITEM_SLOT), null) + .add("slots", SerializableDataBuilder.of(ApoliDataTypes.ITEM_SLOT.listOf()), null) .add("slot", ApoliDataTypes.ITEM_SLOT, null) + .add("power", ApoliDataTypes.POWER_REFERENCE, null) .add("stack", SerializableDataTypes.ITEM_STACK) .add("merge_nbt", SerializableDataTypes.BOOLEAN, false), - ReplaceInventoryAction::action + ReplaceInventoryActionType::action ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RevokeAdvancementActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RevokeAdvancementActionType.java new file mode 100644 index 000000000..f1b023d00 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RevokeAdvancementActionType.java @@ -0,0 +1,60 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.advancements.AdvancementProgress; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.advancement.CraftAdvancement; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.HashSet; + +public class RevokeAdvancementActionType { + + public static void action(@NotNull Entity entity, @Nullable ResourceLocation advancementId, Collection criteria) { + + MinecraftServer server = entity.getServer(); + if (server == null || !(entity instanceof ServerPlayer serverPlayerEntity)) { + return; + } + + AdvancementHolder holder = ((CraftAdvancement) Bukkit.getAdvancement(CraftNamespacedKey.fromMinecraft(advancementId))).getHandle(); + AdvancementProgress progress = serverPlayerEntity.getAdvancements().getOrStartProgress(holder); + + for (String remainingCriterion : criteria.isEmpty() ? progress.getCompletedCriteria() : criteria) { + progress.revokeProgress(remainingCriterion); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("revoke_advancement"), + new SerializableData() + .add("advancement", SerializableDataTypes.IDENTIFIER, null) + .add("criterion", SerializableDataTypes.STRING, null) + .add("criteria", SerializableDataTypes.STRINGS, null), + (data, entity) -> { + + Collection criteria = new HashSet<>(); + + data.ifPresent("criterion", criteria::add); + data.ifPresent("criteria", criteria::addAll); + + action(entity, data.get("advancement"), criteria); + + } + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RevokeAllPowersActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RevokeAllPowersActionType.java new file mode 100644 index 000000000..e3d588b85 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RevokeAllPowersActionType.java @@ -0,0 +1,37 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.origin.OriginLayer; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.util.entity.PowerUtils; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class RevokeAllPowersActionType { + + public static void action(@NotNull Entity entity, ResourceLocation source) { + OriginLayer layer = OriginsPaper.getLayer(source); + + for (PowerType type : PowerHolderComponent.getPowers(entity.getBukkitEntity(), layer)) { + PowerUtils.removePower(entity.getBukkitEntity(), type, (Player) entity.getBukkitEntity(), layer, true); + } + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("revoke_all_powers"), + new SerializableData() + .add("source", SerializableDataTypes.IDENTIFIER), + (data, entity) -> action(entity, + data.get("source") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RevokePowerActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RevokePowerActionType.java new file mode 100644 index 000000000..3a417bfee --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RevokePowerActionType.java @@ -0,0 +1,35 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerReference; +import io.github.dueris.originspaper.util.entity.PowerUtils; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class RevokePowerActionType { + + public static void action(Entity entity, PowerReference power, ResourceLocation source) { + if (!(entity instanceof Player)) return; + PowerUtils.removePower(entity.getBukkitEntity(), power.getType(), (Player) entity.getBukkitEntity(), OriginsPaper.getLayer(source), true); + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("revoke_power"), + new SerializableData() + .add("power", ApoliDataTypes.POWER_REFERENCE) + .add("source", SerializableDataTypes.IDENTIFIER), + (data, entity) -> action(entity, + data.get("power"), + data.get("source") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RidingActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RidingActionType.java new file mode 100644 index 000000000..a7ee97471 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/RidingActionType.java @@ -0,0 +1,67 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; +import java.util.function.Predicate; + +public class RidingActionType { + + public static void action(@NotNull Entity entity, Consumer entityAction, Consumer> biEntityAction, Predicate> biEntityCondition, boolean recursive) { + + if (!entity.isPassenger()) { + return; + } + + Entity vehicle = entity.getVehicle(); + if (recursive) { + + while (vehicle != null) { + executeActions(entity, vehicle, entityAction, biEntityAction, biEntityCondition); + vehicle = vehicle.getVehicle(); + } + + } else { + executeActions(entity, vehicle, entityAction, biEntityAction, biEntityCondition); + } + + } + + private static void executeActions(Entity actor, Entity target, Consumer entityAction, Consumer> biEntityAction, @NotNull Predicate> biEntityCondition) { + + Tuple actorAndTarget = new Tuple<>(actor, target); + + if (biEntityCondition.test(actorAndTarget)) { + entityAction.accept(target); + biEntityAction.accept(actorAndTarget); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("riding_action"), + new SerializableData() + .add("action", ApoliDataTypes.ENTITY_ACTION, null) + .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) + .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) + .add("recursive", SerializableDataTypes.BOOLEAN, false), + (data, entity) -> action(entity, + data.getOrElse("action", e -> { + }), + data.getOrElse("bientity_action", actorAndTarget -> { + }), + data.getOrElse("bientity_condition", actorAndTarget -> true), + data.get("recursive") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SelectorAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SelectorActionType.java similarity index 50% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SelectorAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SelectorActionType.java index beeaa0ab2..4396cc898 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SelectorAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SelectorActionType.java @@ -1,16 +1,15 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.util.ArgumentWrapper; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.selector.EntitySelector; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; @@ -18,35 +17,27 @@ import java.util.function.Consumer; import java.util.function.Predicate; -public class SelectorAction { +public class SelectorActionType { - public static void action(SerializableData.Instance data, @NotNull Entity entity) { + public static void action(@NotNull Entity entity, EntitySelector selector, Consumer> biEntityAction, Predicate> biEntityCondition) { MinecraftServer server = entity.level().getServer(); - if (server == null) return; - - EntitySelector selector = data.>get("selector").get(); - Predicate> biEntityCondition = data.get("bientity_condition"); - Consumer> biEntityAction = data.get("bientity_action"); + if (server == null) { + return; + } - CommandSourceStack source = new CommandSourceStack( - CommandSource.NULL, - entity.position(), - entity.getRotationVector(), - (ServerLevel) entity.level(), - 2, - entity.getScoreboardName(), - entity.getName(), - server, - entity - ); + CommandSourceStack source = entity.createCommandSourceStack() + .withSource(OriginsPaper.showCommandOutput ? entity : CommandSource.NULL) + .withPermission(4); try { selector.findEntities(source) .stream() - .filter(e -> biEntityCondition == null || biEntityCondition.test(new Tuple<>(entity, e))) - .forEach(e -> biEntityAction.accept(new Tuple<>(entity, e))); + .map(selected -> new Tuple<>(entity, (Entity) selected)) + .filter(biEntityCondition) + .forEach(biEntityAction); } catch (CommandSyntaxException ignored) { + } } @@ -54,11 +45,16 @@ public static void action(SerializableData.Instance data, @NotNull Entity entity public static @NotNull ActionTypeFactory getFactory() { return new ActionTypeFactory<>( OriginsPaper.apoliIdentifier("selector_action"), - SerializableData.serializableData() + new SerializableData() .add("selector", ApoliDataTypes.ENTITIES_SELECTOR) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null), - SelectorAction::action + (data, entity) -> action(entity, + data.>get("selector").get(), + data.get("bientity_action"), + data.getOrElse("bientity_condition", actorAndTarget -> true) + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SetFallDistanceActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SetFallDistanceActionType.java new file mode 100644 index 000000000..6281af6fe --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SetFallDistanceActionType.java @@ -0,0 +1,27 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class SetFallDistanceActionType { + + public static void action(@NotNull Entity entity, float fallDistance) { + entity.fallDistance = fallDistance; + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("set_fall_distance"), + new SerializableData() + .add("fall_distance", SerializableDataTypes.FLOAT), + (data, entity) -> action(entity, + data.get("fall_distance") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SetOnFireActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SetOnFireActionType.java new file mode 100644 index 000000000..2e2cc9fd2 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SetOnFireActionType.java @@ -0,0 +1,27 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class SetOnFireActionType { + + public static void action(@NotNull Entity entity, float seconds) { + entity.igniteForSeconds(seconds); + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("set_on_fire"), + new SerializableData() + .add("duration", SerializableDataTypes.FLOAT), + (data, entity) -> action(entity, + data.get("duration") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SetResourceActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SetResourceActionType.java new file mode 100644 index 000000000..97e9f41c4 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SetResourceActionType.java @@ -0,0 +1,44 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.type.CooldownPower; +import io.github.dueris.originspaper.power.type.ResourcePower; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class SetResourceActionType { + + public static void action(Entity entity, PowerReference power, int value) { + switch (power.getType()) { + case ResourcePower varInt -> { + varInt.setValue(entity, value); + } + case CooldownPower cooldown -> { + cooldown.setCooldown(entity, value); + } + case null, default -> { + + } + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("set_resource"), + new SerializableData() + .add("resource", ApoliDataTypes.POWER_REFERENCE) + .add("value", SerializableDataTypes.INT), + (data, entity) -> action(entity, + data.get("resource"), + data.get("value") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SpawnEffectCloudActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SpawnEffectCloudActionType.java new file mode 100644 index 000000000..9ffb789f9 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SpawnEffectCloudActionType.java @@ -0,0 +1,59 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.AreaEffectCloud; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.alchemy.PotionContents; +import org.jetbrains.annotations.NotNull; + +public class SpawnEffectCloudActionType { + + public static void action(@NotNull Entity entity, PotionContents potionContents, float radius, float radiusOnUse, int duration, int durationOnUse, int waitTime) { + + if (!(entity.level() instanceof ServerLevel serverWorld)) { + return; + } + + AreaEffectCloud aec = new AreaEffectCloud(entity.level(), entity.getX(), entity.getY(), entity.getZ()); + if (entity instanceof LivingEntity living) { + aec.setOwner(living); + } + + aec.setPotionContents(potionContents); + aec.setRadius(radius); + aec.setRadiusOnUse(radiusOnUse); + aec.setDuration(duration); + aec.setDurationOnUse(durationOnUse); + aec.setWaitTime(waitTime); + + serverWorld.addFreshEntity(aec); + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("spawn_effect_cloud"), + new SerializableData() + .add("effect_component", SerializableDataTypes.POTION_CONTENTS_COMPONENT, PotionContents.EMPTY) + .add("radius", SerializableDataTypes.FLOAT, 3.0F) + .add("radius_on_use", SerializableDataTypes.FLOAT, -0.5F) + .add("duration", SerializableDataTypes.INT, 600) + .add("duration_on_use", SerializableDataTypes.INT, 0) + .add("wait_time", SerializableDataTypes.INT, 10), + (data, entity) -> action(entity, + data.get("effect_component"), + data.get("radius"), + data.get("radius_on_use"), + data.get("duration"), + data.get("duration_on_use"), + data.get("wait_time") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SpawnEntityActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SpawnEntityActionType.java new file mode 100644 index 000000000..45e05bfe7 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SpawnEntityActionType.java @@ -0,0 +1,65 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.util.Util; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; + +public class SpawnEntityActionType { + + public static void action(Entity entity, EntityType entityType, Consumer entityAction, Consumer> biEntityAction, CompoundTag entityNbt) { + + if (!(entity.level() instanceof ServerLevel serverWorld)) { + return; + } + + Entity entityToSpawn = Util.getEntityWithPassengers( + serverWorld, + entityType, + entityNbt, + entity.position(), + entity.getYRot(), + entity.getXRot() + ).orElse(null); + + if (entityToSpawn == null) { + return; + } + + serverWorld.tryAddFreshEntityWithPassengers(entityToSpawn); + + entityAction.accept(entityToSpawn); + biEntityAction.accept(new Tuple<>(entity, entityToSpawn)); + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("spawn_entity"), + new SerializableData() + .add("entity_type", SerializableDataTypes.ENTITY_TYPE) + .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) + .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) + .add("tag", SerializableDataTypes.NBT_COMPOUND, null), + (data, entity) -> action(entity, + data.get("entity_type"), + data.getOrElse("entity_action", e -> { + }), + data.getOrElse("bientity_action", at -> { + }), + data.get("tag") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SpawnParticlesAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SpawnParticlesActionType.java similarity index 50% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SpawnParticlesAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SpawnParticlesActionType.java index e79b7cbb0..fdbf57277 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SpawnParticlesAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SpawnParticlesActionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.server.level.ServerLevel; @@ -15,49 +15,49 @@ import java.util.function.Predicate; -public class SpawnParticlesAction { +public class SpawnParticlesActionType { - public static void action(SerializableData.Instance data, @NotNull Entity entity) { + public static void action(@NotNull Entity entity, ParticleOptions particle, Predicate> biEntityCondition, Vec3 offset, Vec3 spread, boolean force, float speed, int count) { if (!(entity.level() instanceof ServerLevel serverWorld)) { return; } - Vec3 delta = data - .get("spread") - .multiply(entity.getBbWidth(), entity.getEyeHeight(entity.getPose()), entity.getBbWidth()); - Vec3 pos = entity - .position() - .add(data.getDouble("offset_x"), data.getDouble("offset_y"), data.getDouble("offset_z")); - - Predicate> biEntityCondition = data.get("bientity_condition"); - ParticleOptions particleEffect = data.get("particle"); - - boolean force = data.getBoolean("force"); - float speed = data.getFloat("speed"); - int count = Math.max(0, data.getInt("count")); + Vec3 delta = spread.multiply(entity.getBbWidth(), entity.getBoundingBox().maxY, entity.getBbWidth()); + Vec3 pos = entity.position().add(offset); for (ServerPlayer player : serverWorld.players()) { - if (biEntityCondition == null || biEntityCondition.test(new Tuple<>(entity, player))) { - serverWorld.sendParticles(player, particleEffect, force, pos.x(), pos.y(), pos.z(), count, delta.x(), delta.y(), delta.z(), speed); + + if (biEntityCondition.test(new Tuple<>(entity, player))) { + serverWorld.sendParticles(player, particle, force, pos.x(), pos.y(), pos.z(), count, delta.x(), delta.y(), delta.z(), speed); } + } } public static @NotNull ActionTypeFactory getFactory() { return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("spawn_particles"), - SerializableData.serializableData() + new SerializableData() .add("particle", SerializableDataTypes.PARTICLE_EFFECT_OR_TYPE) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) - .add("count", SerializableDataTypes.INT, 1) - .add("speed", SerializableDataTypes.FLOAT, 0.0F) - .add("force", SerializableDataTypes.BOOLEAN, false) - .add("spread", SerializableDataTypes.VECTOR, new Vec3(0.5, 0.5, 0.5)) .add("offset_x", SerializableDataTypes.DOUBLE, 0.0D) .add("offset_y", SerializableDataTypes.DOUBLE, 0.5D) - .add("offset_z", SerializableDataTypes.DOUBLE, 0.0D), - SpawnParticlesAction::action + .add("offset_z", SerializableDataTypes.DOUBLE, 0.0D) + .add("spread", SerializableDataTypes.VECTOR, new Vec3(0.5, 0.5, 0.5)) + .add("force", SerializableDataTypes.BOOLEAN, false) + .add("speed", SerializableDataTypes.FLOAT, 0.0F) + .add("count", SerializableDataTypes.INT, 1), + (data, entity) -> action(entity, + data.get("particle"), + data.getOrElse("bientity_condition", actorAndTarget -> true), + new Vec3(data.get("offset_x"), data.get("offset_y"), data.get("offset_z")), + data.get("spread"), + data.get("force"), + data.get("speed"), + data.get("count") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SwingHandAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SwingHandActionType.java similarity index 50% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SwingHandAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SwingHandActionType.java index 5607a6b43..711771b5e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SwingHandAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/SwingHandActionType.java @@ -1,27 +1,32 @@ -package io.github.dueris.originspaper.action.types.entity; +package io.github.dueris.originspaper.action.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import org.jetbrains.annotations.NotNull; -public class SwingHandAction { +public class SwingHandActionType { + + public static void action(Entity entity, InteractionHand hand) { - public static void action(SerializableData.Instance data, Entity entity) { if (entity instanceof LivingEntity living) { - living.swing(data.get("hand"), true); + living.swing(hand, true); } + } public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("swing_hand"), - SerializableData.serializableData() + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("swing_hand"), + new SerializableData() .add("hand", SerializableDataTypes.HAND, InteractionHand.MAIN_HAND), - SwingHandAction::action + (data, entity) -> action(entity, + data.get("hand") + ) ); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ToggleActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ToggleActionType.java new file mode 100644 index 000000000..f9e39a18f --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/ToggleActionType.java @@ -0,0 +1,35 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.event.KeybindTriggerEvent; +import io.github.dueris.originspaper.power.type.TogglePower; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.world.entity.Entity; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class ToggleActionType { + + public static void action(Entity entity, @NotNull PowerReference power) { + + if (power.getType() instanceof TogglePower toggle && entity.getBukkitEntity() instanceof Player) { + toggle.onKey(new KeybindTriggerEvent((Player) entity.getBukkitEntity(), toggle.getKeybind().key())); + } + + } + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("toggle"), + new SerializableData() + .add("power", ApoliDataTypes.POWER_REFERENCE), + (data, entity) -> action(entity, + data.get("power") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/TriggerCooldownActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/TriggerCooldownActionType.java new file mode 100644 index 000000000..46729b2e8 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/entity/TriggerCooldownActionType.java @@ -0,0 +1,35 @@ +package io.github.dueris.originspaper.action.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.type.CooldownPower; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +public class TriggerCooldownActionType { + + public static void action(Entity entity, @NotNull PowerReference power) { + + if (power.getType() instanceof CooldownPower cooldown) { + cooldown.use(entity); + } + + } + + @Contract(" -> new") + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("trigger_cooldown"), + new SerializableData() + .add("power", ApoliDataTypes.POWER_REFERENCE), + (data, entity) -> action(entity, + data.get("power") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/item/ConsumeActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/ConsumeActionType.java new file mode 100644 index 000000000..0f60cba4e --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/ConsumeActionType.java @@ -0,0 +1,27 @@ +package io.github.dueris.originspaper.action.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ItemActionTypeFactory; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class ConsumeActionType { + + public static void action(@NotNull ItemStack stack, int amount) { + stack.shrink(amount); + } + + public static @NotNull ItemActionTypeFactory getFactory() { + return ItemActionTypeFactory.createItemStackBased( + OriginsPaper.apoliIdentifier("consume"), + new SerializableData() + .add("amount", SerializableDataTypes.INT, 1), + (data, worldAndStack) -> action(worldAndStack.getB(), + data.get("amount") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/item/DamageActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/DamageActionType.java new file mode 100644 index 000000000..668220c3d --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/DamageActionType.java @@ -0,0 +1,51 @@ +package io.github.dueris.originspaper.action.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ItemActionTypeFactory; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.SlotAccess; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +public class DamageActionType { + + public static void action(Level world, ItemStack stack, int amount, boolean ignoreUnbreaking) { + + if (!(world instanceof ServerLevel serverWorld)) { + return; + } + + if (ignoreUnbreaking) { + + if (amount >= stack.getMaxDamage()) { + stack.shrink(1); + } else { + stack.setDamageValue(stack.getDamageValue() + amount); + } + + } else { + stack.hurtAndBreak(amount, serverWorld, null, item -> { + }); + } + + } + + public static @NotNull ActionTypeFactory> getFactory() { + return ItemActionTypeFactory.createItemStackBased( + OriginsPaper.apoliIdentifier("damage"), + new SerializableData() + .add("amount", SerializableDataTypes.INT, 1) + .add("ignore_unbreaking", SerializableDataTypes.BOOLEAN, false), + (data, worldAndStack) -> action(worldAndStack.getA(), worldAndStack.getB(), + data.get("amount"), + data.get("ignore_unbreaking") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/item/MergeCustomDataActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/MergeCustomDataActionType.java new file mode 100644 index 000000000..bf9c0c541 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/MergeCustomDataActionType.java @@ -0,0 +1,33 @@ +package io.github.dueris.originspaper.action.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ItemActionTypeFactory; +import net.minecraft.core.component.DataComponents; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.SlotAccess; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.level.Level; + +public class MergeCustomDataActionType { + + public static void action(ItemStack stack, CompoundTag nbt) { + CustomData.update(DataComponents.CUSTOM_DATA, stack, oldNbt -> oldNbt.merge(nbt)); + } + + public static ActionTypeFactory> getFactory() { + return ItemActionTypeFactory.createItemStackBased( + OriginsPaper.apoliIdentifier("merge_custom_data"), + new SerializableData() + .add("nbt", SerializableDataTypes.NBT_COMPOUND), + (data, worldAndStack) -> action(worldAndStack.getB(), + data.get("nbt") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/ModifyAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/ModifyActionType.java similarity index 57% rename from origins/src/main/java/io/github/dueris/originspaper/action/types/item/ModifyAction.java rename to origins/src/main/java/io/github/dueris/originspaper/action/type/item/ModifyActionType.java index d717f4489..cb1b0b3f7 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/ModifyAction.java +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/ModifyActionType.java @@ -1,14 +1,13 @@ -package io.github.dueris.originspaper.action.types.item; +package io.github.dueris.originspaper.action.type.item; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ItemActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ItemActionTypeFactory; import io.github.dueris.originspaper.util.ApoliLootContextTypes; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.Tuple; import net.minecraft.world.entity.SlotAccess; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -16,43 +15,42 @@ import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.functions.LootItemFunction; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; -import org.jetbrains.annotations.NotNull; import java.util.Optional; -public class ModifyAction { +public class ModifyActionType { - public static void action(SerializableData.Instance data, @NotNull Tuple worldAndStack) { + public static void action(Level world, SlotAccess stackReference, ResourceKey itemModifierKey) { - if (!(worldAndStack.getA() instanceof ServerLevel serverWorld)) { + if (!(world instanceof ServerLevel serverWorld)) { return; } - ResourceKey itemModifierKey = data.get("modifier"); + ItemStack oldStack = stackReference.get(); LootItemFunction itemModifier = serverWorld.getServer().reloadableRegistries() .get() .registryOrThrow(Registries.ITEM_MODIFIER) .getOrThrow(itemModifierKey); - SlotAccess stack = worldAndStack.getB(); - LootParams lootContextParameterSet = new LootParams.Builder(serverWorld) .withParameter(LootContextParams.ORIGIN, serverWorld.getSharedSpawnPos().getCenter()) - .withParameter(LootContextParams.TOOL, stack.get()) + .withParameter(LootContextParams.TOOL, oldStack) .create(ApoliLootContextTypes.ANY); - LootContext lootContext = new LootContext.Builder(lootContextParameterSet).create(Optional.empty()); - ItemStack newStack = itemModifier.apply(stack.get(), lootContext); - stack.set(newStack); + ItemStack newStack = itemModifier.apply(oldStack, new LootContext.Builder(lootContextParameterSet).create(Optional.empty())); + stackReference.set(newStack); } - public static @NotNull ItemActionTypeFactory getFactory() { + public static ItemActionTypeFactory getFactory() { return new ItemActionTypeFactory( OriginsPaper.apoliIdentifier("modify"), - SerializableData.serializableData() + new SerializableData() .add("modifier", SerializableDataTypes.ITEM_MODIFIER), - ModifyAction::action + (data, worldAndStackRef) -> action(worldAndStackRef.getA(), worldAndStackRef.getB(), + data.get("modifier") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/item/RemoveEnchantmentActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/RemoveEnchantmentActionType.java new file mode 100644 index 000000000..e41b32b40 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/item/RemoveEnchantmentActionType.java @@ -0,0 +1,92 @@ +package io.github.dueris.originspaper.action.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ItemActionTypeFactory; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.SlotAccess; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.ItemEnchantments; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.HashSet; + +public class RemoveEnchantmentActionType { + + public static void action(RegistryAccess registryManager, @NotNull ItemStack stack, Collection> enchantmentKeys, @Nullable Integer levels, boolean resetRepairCost) { + + if (!stack.isEnchanted()) { + return; + } + + ItemEnchantments oldEnchantments = stack.getEnchantments(); + ItemEnchantments.Mutable newEnchantments = new ItemEnchantments.Mutable(oldEnchantments); + + boolean hasKeys = false; + for (ResourceKey enchantmentKey : enchantmentKeys) { + + // Since the registry keys are already validated, this should be fine. + Holder enchantment = registryManager.registryOrThrow(Registries.ENCHANTMENT).getHolderOrThrow(enchantmentKey); + hasKeys = true; + + if (oldEnchantments.keySet().contains(enchantment)) { + newEnchantments.set(enchantment, levels != null ? oldEnchantments.getLevel(enchantment) - levels : 0); + } + + } + + for (Holder oldEnchantment : oldEnchantments.keySet()) { + + if (hasKeys) { + break; + } else { + newEnchantments.set(oldEnchantment, levels != null ? oldEnchantments.getLevel(oldEnchantment) - levels : 0); + } + + } + + stack.set(DataComponents.ENCHANTMENTS, newEnchantments.toImmutable()); + if (resetRepairCost && !stack.isEnchanted()) { + stack.set(DataComponents.REPAIR_COST, 0); + } + + } + + public static @NotNull ActionTypeFactory> getFactory() { + return ItemActionTypeFactory.createItemStackBased( + OriginsPaper.apoliIdentifier("remove_enchantment"), + new SerializableData() + .add("enchantment", SerializableDataTypes.ENCHANTMENT, null) + .add("enchantments", SerializableDataBuilder.of(SerializableDataTypes.ENCHANTMENT.listOf()), null) + .add("levels", SerializableDataTypes.INT, null) + .add("reset_repair_cost", SerializableDataTypes.BOOLEAN, false), + (data, worldAndStack) -> { + + Collection> enchantmentKeys = new HashSet<>(); + + data.ifPresent("enchantment", enchantmentKeys::add); + data.ifPresent("enchantments", enchantmentKeys::addAll); + + action(worldAndStack.getA().registryAccess(), worldAndStack.getB(), + enchantmentKeys, + data.get("levels"), + data.get("reset_repair_cost") + ); + + } + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/AndActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/AndActionType.java new file mode 100644 index 000000000..fe54542a5 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/AndActionType.java @@ -0,0 +1,29 @@ +package io.github.dueris.originspaper.action.type.meta; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.List; +import java.util.function.Consumer; + +public class AndActionType { + + public static void action(T type, @NotNull Collection> actions) { + actions.forEach(action -> action.accept(type)); + } + + public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder>> listDataType) { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("and"), + new SerializableData() + .add("actions", listDataType), + (data, type) -> action(type, + data.get("actions") + ) + ); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/ChanceActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/ChanceActionType.java new file mode 100644 index 000000000..d3fc45b33 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/ChanceActionType.java @@ -0,0 +1,40 @@ +package io.github.dueris.originspaper.action.type.meta; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.util.RandomSource; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; + +public class ChanceActionType { + + public static void action(T type, Consumer successAction, Consumer failAction, float chance) { + + if (RandomSource.create().nextFloat() < chance) { + successAction.accept(type); + } else { + failAction.accept(type); + } + + } + + public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> dataType) { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("chance"), + new SerializableData() + .add("success_action", dataType) + .add("fail_action", dataType, null) + .add("chance", SerializableDataTypes.boundNumber(SerializableDataTypes.FLOAT, 0F, 1F)), + (data, type) -> action(type, + data.get("success_action"), + data.getOrElse("fail_action", t -> { + }), + data.get("chance") + ) + ); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/ChoiceActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/ChoiceActionType.java new file mode 100644 index 000000000..befbef39b --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/ChoiceActionType.java @@ -0,0 +1,37 @@ +package io.github.dueris.originspaper.action.type.meta; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import net.minecraft.world.entity.ai.behavior.ShufflingList; +import org.jetbrains.annotations.NotNull; + +import java.util.Iterator; +import java.util.function.Consumer; + +public class ChoiceActionType { + + public static void action(T type, @NotNull ShufflingList> actions) { + + actions.shuffle(); + Iterator> actionIterator = actions.iterator(); + + if (actionIterator.hasNext()) { + actionIterator.next().accept(type); + } + + } + + public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> dataType) { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("choice"), + new SerializableData() + .add("actions", SerializableDataTypes.weightedList(dataType)), + (data, type) -> action(type, + data.get("actions") + ) + ); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/DelayActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/DelayActionType.java new file mode 100644 index 000000000..71ac1066a --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/DelayActionType.java @@ -0,0 +1,33 @@ +package io.github.dueris.originspaper.action.type.meta; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.util.ApoliScheduler; + +import java.util.function.Consumer; + +public class DelayActionType { + + private static final ApoliScheduler SCHEDULER = new ApoliScheduler(); + + public static void action(T type, Consumer action, int ticks) { + SCHEDULER.queue(server -> action.accept(type), ticks); + } + + public static ActionTypeFactory getFactory(SerializableDataBuilder> dataType) { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("delay"), + new SerializableData() + .add("action", dataType) + .add("ticks", SerializableDataTypes.INT), + (data, type) -> action(type, + data.get("action"), + data.get("ticks") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/IfElseActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/IfElseActionType.java new file mode 100644 index 000000000..e825d4939 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/IfElseActionType.java @@ -0,0 +1,49 @@ +package io.github.dueris.originspaper.action.type.meta; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; + +public class IfElseActionType { + + public static void action(T type, @NotNull Predicate condition, Consumer ifAction, Consumer elseAction, @NotNull Function actionToConditionTypeFunction) { + + U convertedType = actionToConditionTypeFunction.apply(type); + + if (condition.test(convertedType)) { + ifAction.accept(type); + } else { + elseAction.accept(type); + } + + } + + public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> actionDataType, SerializableDataBuilder> conditionDataType, Function actionToConditionTypeFunction) { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("if_else"), + new SerializableData() + .add("condition", conditionDataType) + .add("if_action", actionDataType) + .add("else_action", actionDataType, null), + (data, t) -> action(t, + data.get("condition"), + data.get("if_action"), + data.getOrElse("else_action", _t -> { + }), + actionToConditionTypeFunction + ) + ); + } + + public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> actionDataType, SerializableDataBuilder> conditionDataType) { + return getFactory(actionDataType, conditionDataType, t -> t); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/IfElseListActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/IfElseListActionType.java new file mode 100644 index 000000000..9524a2614 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/IfElseListActionType.java @@ -0,0 +1,61 @@ +package io.github.dueris.originspaper.action.type.meta; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.util.Tuple; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; + +public class IfElseListActionType { + + public static void action(T type, @NotNull Collection, Predicate>> actions, @NotNull Function actionToConditionTypeFunction) { + + U convertedType = actionToConditionTypeFunction.apply(type); + + for (Tuple, Predicate> action : actions) { + + if (action.getB().test(convertedType)) { + action.getA().accept(type); + break; + } + + } + + } + + public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> actionDataType, SerializableDataBuilder> conditionDataType, Function actionToConditionTypeFunction) { + SerializableDataBuilder, ConditionTypeFactory>> dataType = SerializableDataBuilder.compound( + new SerializableData() + .add("action", actionDataType) + .add("condition", conditionDataType), + data -> new Tuple<>( + data.get("action"), + data.get("condition") + ), + Tuple.class + ); + + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("if_else_list"), + new SerializableData() + .add("actions", SerializableDataBuilder.of(dataType.listOf())), + (data, t) -> action(t, + data.get("actions"), + actionToConditionTypeFunction + ) + ); + + } + + public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> actionDataType, SerializableDataBuilder> conditionDataType) { + return getFactory(actionDataType, conditionDataType, t -> t); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/NothingActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/NothingActionType.java new file mode 100644 index 000000000..f65026f88 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/NothingActionType.java @@ -0,0 +1,19 @@ +package io.github.dueris.originspaper.action.type.meta; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import org.jetbrains.annotations.NotNull; + +public class NothingActionType { + + public static @NotNull ActionTypeFactory getFactory() { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("nothing"), + new SerializableData(), + (data, t) -> { + } + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/SideActionType.java b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/SideActionType.java new file mode 100644 index 000000000..0af8b8f52 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/action/type/meta/SideActionType.java @@ -0,0 +1,44 @@ +package io.github.dueris.originspaper.action.type.meta; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Function; + +public class SideActionType { + + public static void action(T type, ActionTypeFactory action, Side side, @NotNull Function serverCheck) { + + if ((side == Side.CLIENT) != serverCheck.apply(type)) { + action.accept(type); + } + + } + + public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> dataType, Function serverCheck) { + return new ActionTypeFactory<>( + OriginsPaper.apoliIdentifier("side"), + new SerializableData() + .add("action", dataType) + .add("side", SerializableDataTypes.enumValue(Side.class)), + (data, type) -> SideActionType.action(type, + data.get("action"), + data.get("side"), + serverCheck + ) + ); + } + + public static @NotNull ActionTypeFactory getFactory(SerializableDataBuilder> dataType) { + return getFactory(dataType, t -> true); + } + + public enum Side { + CLIENT, SERVER + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/BiEntityActions.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/BiEntityActions.java deleted file mode 100644 index 30a87c3c8..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/BiEntityActions.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.dueris.originspaper.action.types; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.action.ActionTypes; -import io.github.dueris.originspaper.action.meta.*; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; - -// Left is the actor, right is the target. -public class BiEntityActions { - - public static void register(ActionTypeFactory> factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.BIENTITY_ACTION).register(factory, factory.getSerializerId()); - } - - public static void registerAll() { - register(AndAction.getFactory(SerializableDataTypes.list(ApoliDataTypes.BIENTITY_ACTION))); - register(ChanceAction.getFactory(ApoliDataTypes.BIENTITY_ACTION)); - register(IfElseAction.getFactory(ApoliDataTypes.BIENTITY_ACTION, ApoliDataTypes.BIENTITY_CONDITION)); - register(ChoiceAction.getFactory(ApoliDataTypes.BIENTITY_ACTION)); - register(IfElseListAction.getFactory(ApoliDataTypes.BIENTITY_ACTION, ApoliDataTypes.BIENTITY_CONDITION)); - register(DelayAction.getFactory(ApoliDataTypes.BIENTITY_ACTION)); - register(NothingAction.getFactory()); - register(SideAction.getFactory(ApoliDataTypes.BIENTITY_ACTION, entities -> !entities.getA().level().isClientSide)); - - ActionTypes.registerPackage(BiEntityActions::register, "io.github.dueris.originspaper.action.types.bientity"); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/BlockActions.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/BlockActions.java deleted file mode 100644 index 39794dd1d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/BlockActions.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.github.dueris.originspaper.action.types; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.action.ActionTypes; -import io.github.dueris.originspaper.action.meta.*; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.apache.commons.lang3.tuple.Triple; - -public class BlockActions { - - public static void register(ActionTypeFactory> factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.BLOCK_ACTION).register(factory, factory.getSerializerId()); - } - - public static void registerAll() { - register(AndAction.getFactory(SerializableDataTypes.list(ApoliDataTypes.BLOCK_ACTION))); - register(ChanceAction.getFactory(ApoliDataTypes.BLOCK_ACTION)); - register(IfElseAction.getFactory(ApoliDataTypes.BLOCK_ACTION, ApoliDataTypes.BLOCK_CONDITION, - t -> new BlockInWorld(t.getLeft(), t.getMiddle(), true))); - register(ChoiceAction.getFactory(ApoliDataTypes.BLOCK_ACTION)); - register(IfElseListAction.getFactory(ApoliDataTypes.BLOCK_ACTION, ApoliDataTypes.BLOCK_CONDITION, - t -> new BlockInWorld(t.getLeft(), t.getMiddle(), true))); - register(DelayAction.getFactory(ApoliDataTypes.BLOCK_ACTION)); - register(NothingAction.getFactory()); - register(SideAction.getFactory(ApoliDataTypes.BLOCK_ACTION, block -> !block.getLeft().isClientSide)); - - ActionTypes.registerPackage(BlockActions::register, "io.github.dueris.originspaper.action.types.block"); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/EntityActions.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/EntityActions.java deleted file mode 100644 index 51a96f109..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/EntityActions.java +++ /dev/null @@ -1,85 +0,0 @@ -package io.github.dueris.originspaper.action.types; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.action.ActionTypes; -import io.github.dueris.originspaper.action.meta.*; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.origin.OriginLayer; -import io.github.dueris.originspaper.power.PowerType; -import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.storage.PowerHolderComponent; -import io.github.dueris.originspaper.util.entity.PowerUtils; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.Entity; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -public class EntityActions { - - public static void register(ActionTypeFactory factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.ENTITY_ACTION).register(factory, factory.getSerializerId()); - } - - public static void registerAll() { - register(AndAction.getFactory(SerializableDataTypes.list(ApoliDataTypes.ENTITY_ACTION))); - register(ChanceAction.getFactory(ApoliDataTypes.ENTITY_ACTION)); - register(IfElseAction.getFactory(ApoliDataTypes.ENTITY_ACTION, ApoliDataTypes.ENTITY_CONDITION)); - register(ChoiceAction.getFactory(ApoliDataTypes.ENTITY_ACTION)); - register(IfElseListAction.getFactory(ApoliDataTypes.ENTITY_ACTION, ApoliDataTypes.ENTITY_CONDITION)); - register(DelayAction.getFactory(ApoliDataTypes.ENTITY_ACTION)); - register(NothingAction.getFactory()); - register(SideAction.getFactory(ApoliDataTypes.ENTITY_ACTION, entity -> !entity.level().isClientSide)); - - register(new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("grant_power"), - SerializableData.serializableData() - .add("power", SerializableDataTypes.IDENTIFIER) - .add("source", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - if (entity.getBukkitEntity() instanceof Player p) { - PowerType powerContainer = OriginsPaper.getPlugin().registry.retrieve(Registries.CRAFT_POWER).get(data.getId("power")); - if (powerContainer == null) { - OriginsPaper.getPlugin().getLogger().severe("Searched PowerType was null when attempting to revoke a power: {}".replace("{}", data.getId("power").toString())); - return; - } - OriginLayer layer = OriginsPaper.getLayer(data.getId("source")); - PowerUtils.grantPower(Bukkit.getConsoleSender(), powerContainer, p, layer, false); - } - })); - register(new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("remove_power"), - SerializableData.serializableData() - .add("power", SerializableDataTypes.IDENTIFIER) - .add("source", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - if (entity.getBukkitEntity() instanceof Player p) { - PowerType powerContainer = OriginsPaper.getPlugin().registry.retrieve(Registries.CRAFT_POWER).get(data.getId("power")); - if (powerContainer == null) { - OriginsPaper.getPlugin().getLogger().severe("Searched PowerType was null when attempting to apply a new power: {}".replace("{}", data.getId("power").toString())); - return; - } - OriginLayer layer = OriginsPaper.getLayer(data.getId("source")); - PowerUtils.removePower(Bukkit.getConsoleSender(), powerContainer, p, layer, false); - } - })); - register(new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("revoke_all_powers"), - SerializableData.serializableData() - .add("source", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - if (entity instanceof Player p) { - for (ResourceLocation powerKey : PowerHolderComponent.getPowers(p).stream().map(PowerType::key).toList()) { - PowerType powerContainer = OriginsPaper.getPlugin().registry.retrieve(Registries.CRAFT_POWER).get(powerKey); - if (powerContainer == null) { - OriginsPaper.getPlugin().getLogger().severe("Searched PowerType was null when attempting to revoke a power: {}".replace("{}", powerKey.toString())); - return; - } - OriginLayer layer = OriginsPaper.getLayer(data.getId("source")); - PowerUtils.removePower(Bukkit.getConsoleSender(), powerContainer, p, layer, false); - } - } - })); - ActionTypes.registerPackage(EntityActions::register, "io.github.dueris.originspaper.action.types.entity"); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/ItemActions.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/ItemActions.java deleted file mode 100644 index 19d009586..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/ItemActions.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.dueris.originspaper.action.types; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.action.ActionTypes; -import io.github.dueris.originspaper.action.meta.*; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.SlotAccess; -import net.minecraft.world.level.Level; - -public class ItemActions { - - public static void register(ActionTypeFactory> factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.ITEM_ACTION).register(factory, factory.getSerializerId()); - } - - public static void registerAll() { - register(AndAction.getFactory(SerializableDataTypes.list(ApoliDataTypes.ITEM_ACTION))); - register(ChanceAction.getFactory(ApoliDataTypes.ITEM_ACTION)); - register(IfElseAction.getFactory(ApoliDataTypes.ITEM_ACTION, ApoliDataTypes.ITEM_CONDITION, - worldItemStackPair -> new Tuple<>(worldItemStackPair.getA(), worldItemStackPair.getB().get()))); - register(ChoiceAction.getFactory(ApoliDataTypes.ITEM_ACTION)); - register(IfElseListAction.getFactory(ApoliDataTypes.ITEM_ACTION, ApoliDataTypes.ITEM_CONDITION, - worldItemStackPair -> new Tuple<>(worldItemStackPair.getA(), worldItemStackPair.getB().get()))); - register(DelayAction.getFactory(ApoliDataTypes.ITEM_ACTION)); - register(NothingAction.getFactory()); - register(SideAction.getFactory(ApoliDataTypes.ITEM_ACTION, worldAndStack -> !worldAndStack.getA().isClientSide)); - - ActionTypes.registerPackage(ItemActions::register, "io.github.dueris.originspaper.action.types.item"); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/DamageAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/DamageAction.java deleted file mode 100644 index 6080c39dc..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/DamageAction.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.github.dueris.originspaper.action.types.bientity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.types.modifier.Modifier; -import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.resources.ResourceKey; -import net.minecraft.util.Tuple; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.DamageType; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -import java.util.LinkedList; -import java.util.List; - -public class DamageAction { - - public static void action(SerializableData.Instance data, @NotNull Tuple entities) { - - Entity actor = entities.getA(); - Entity target = entities.getB(); - - if (actor == null || target == null) { - return; - } - - Float damageAmount = data.get("amount"); - List modifiers = new LinkedList<>(); - - data.ifPresent("modifier", modifiers::add); - data.>ifPresent("modifiers", modifiers::addAll); - - if (!modifiers.isEmpty() && target instanceof LivingEntity livingTarget) { - damageAmount = (float) ModifierUtil.applyModifiers(actor, modifiers, livingTarget.getMaxHealth()); - } - - if (damageAmount == null) { - return; - } - - try { - DamageSource source; - if (data.isPresent("damage_type")) { - source = Util.getDamageSource(Util.DAMAGE_REGISTRY.get((ResourceKey) data.get("damage_type"))); - } else { - source = actor.level().damageSources().generic(); - } - if (data.isPresent("source") && !data.isPresent("damage_type")) { - OriginsPaper.getPlugin().getLogger().warning("A \"source\" field was provided in the bientity_action \"apoli:damage\", please use the \"damage_type\" field instead."); - } - target.hurt(source, damageAmount); - } catch (Throwable t) { - OriginsPaper.getPlugin().getLog4JLogger().error("Error trying to deal damage via the `damage` bi-entity action: {}", t.getMessage()); - } - - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("damage"), - SerializableData.serializableData() - .add("amount", SerializableDataTypes.FLOAT, null) - .add("damage_type", SerializableDataTypes.DAMAGE_TYPE, null) - .add("modifier", Modifier.DATA_TYPE, null) - .add("modifiers", Modifier.LIST_TYPE, null), - DamageAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/InvertAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/InvertAction.java deleted file mode 100644 index bac656494..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/InvertAction.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.dueris.originspaper.action.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Consumer; - -public class InvertAction { - - public static void action(@NotNull SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - data.>>get("action").accept(new Tuple<>(actorAndTarget.getB(), actorAndTarget.getA())); - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("invert"), - SerializableData.serializableData() - .add("action", ApoliDataTypes.BIENTITY_ACTION), - InvertAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/LeashAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/LeashAction.java deleted file mode 100644 index a03a4b71a..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/LeashAction.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.dueris.originspaper.action.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.Mob; -import org.jetbrains.annotations.NotNull; - -public class LeashAction { - - public static void action(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - if (actor == null || !(target instanceof Mob mobTarget)) { - return; - } - - if (!mobTarget.isLeashed()) { - mobTarget.setLeashedTo(actor, true); - } - - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("leash"), - SerializableData.serializableData(), - LeashAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/MountAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/MountAction.java deleted file mode 100644 index 03aad5e0f..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/MountAction.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.github.dueris.originspaper.action.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class MountAction { - - public static void action(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - if (actor == null || target == null) { - return; - } - - actor.startRiding(target, true); - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("mount"), - SerializableData.serializableData(), - MountAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/SetInLoveAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/SetInLoveAction.java deleted file mode 100644 index ad081bc20..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/SetInLoveAction.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.dueris.originspaper.action.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class SetInLoveAction { - - public static void action(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - if (actorAndTarget.getB() instanceof Animal targetAnimal && actorAndTarget.getA() instanceof Player actorPlayer) { - targetAnimal.setInLove(actorPlayer); - } - - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("set_in_love"), - SerializableData.serializableData(), - SetInLoveAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/TameAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/TameAction.java deleted file mode 100644 index 887d83c64..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/bientity/TameAction.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.github.dueris.originspaper.action.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.TamableAnimal; -import net.minecraft.world.entity.animal.horse.AbstractHorse; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class TameAction { - - public static void action(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - if (!(actor instanceof Player actorPlayer)) { - return; - } - - if (target instanceof TamableAnimal tameableTarget && !tameableTarget.isTame()) { - tameableTarget.tame(actorPlayer); - } else if (target instanceof AbstractHorse targetHorseLike && !targetHorseLike.isTamed()) { - targetHorseLike.tameWithName(actorPlayer); - } - - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("tame"), - SerializableData.serializableData(), - TameAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/AreaOfEffectAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/block/AreaOfEffectAction.java deleted file mode 100644 index ece4f5294..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/AreaOfEffectAction.java +++ /dev/null @@ -1,52 +0,0 @@ -package io.github.dueris.originspaper.action.types.block; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Shape; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Consumer; -import java.util.function.Predicate; - -public class AreaOfEffectAction { - - public static void action(@NotNull SerializableData.Instance data, @NotNull Triple block) { - - Level world = block.getLeft(); - BlockPos blockPos = block.getMiddle(); - Direction direction = block.getRight(); - - int radius = data.get("radius"); - - Shape shape = data.get("shape"); - Predicate blockCondition = data.get("block_condition"); - Consumer> blockAction = data.get("block_action"); - - for (BlockPos collectedBlockPos : Shape.getPositions(blockPos, shape, radius)) { - if (!(blockCondition == null || blockCondition.test(new BlockInWorld(world, collectedBlockPos, true)))) - continue; - if (blockAction != null) blockAction.accept(Triple.of(world, collectedBlockPos, direction)); - } - - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("area_of_effect"), - SerializableData.serializableData() - .add("block_action", ApoliDataTypes.BLOCK_ACTION) - .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) - .add("radius", SerializableDataTypes.INT, 16) - .add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE), - AreaOfEffectAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/BoneMealAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/block/BoneMealAction.java deleted file mode 100644 index 53c4aa3a9..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/BoneMealAction.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.github.dueris.originspaper.action.types.block; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.item.BoneMealItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.LevelEvent; -import net.minecraft.world.level.block.state.BlockState; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.NotNull; - -public class BoneMealAction { - - public static void action(@NotNull SerializableData.Instance data, @NotNull Triple block) { - Level world = block.getLeft(); - BlockPos blockPos = block.getMiddle(); - Direction side = block.getRight(); - BlockPos blockPos2 = blockPos.relative(side); - - boolean spawnEffects = data.getBoolean("effects"); - - if (BoneMealItem.growCrop(ItemStack.EMPTY, world, blockPos)) { - if (spawnEffects && !world.isClientSide) { - world.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, blockPos, 0); - } - } else { - BlockState blockState = world.getBlockState(blockPos); - boolean bl = blockState.isFaceSturdy(world, blockPos, side); - if (bl && BoneMealItem.growWaterPlant(ItemStack.EMPTY, world, blockPos2, side)) { - if (spawnEffects && !world.isClientSide) { - world.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, blockPos2, 0); - } - } - } - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("bonemeal"), - SerializableData.serializableData() - .add("effects", SerializableDataTypes.BOOLEAN, true), - BoneMealAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/ExecuteCommandAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/block/ExecuteCommandAction.java deleted file mode 100644 index 3e4decb41..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/ExecuteCommandAction.java +++ /dev/null @@ -1,46 +0,0 @@ -package io.github.dueris.originspaper.action.types.block; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.commands.CommandSource; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.network.chat.Component; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec2; -import net.minecraft.world.phys.Vec3; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.NotNull; - -public class ExecuteCommandAction { - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("execute_command"), - SerializableData.serializableData() - .add("command", SerializableDataTypes.STRING), - (data, block) -> { - MinecraftServer server = block.getLeft().getServer(); - if (server != null) { - String blockName = block.getLeft().getBlockState(block.getMiddle()).getBlock().getDescriptionId(); - CommandSourceStack source = new CommandSourceStack( - OriginsPaper.showCommandOutput ? server : CommandSource.NULL, - new Vec3(block.getMiddle().getX() + 0.5, block.getMiddle().getY() + 0.5, block.getMiddle().getZ() + 0.5), - new Vec2(0, 0), - (ServerLevel) block.getLeft(), - 4, - blockName, - Component.translatable(blockName), - server, - null); - server.getCommands().performPrefixedCommand(source, data.getString("command")); - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/ExplodeAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/block/ExplodeAction.java deleted file mode 100644 index cb3768238..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/ExplodeAction.java +++ /dev/null @@ -1,65 +0,0 @@ -package io.github.dueris.originspaper.action.types.block; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.ExplosionMask; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.ExplosionDamageCalculator; -import net.minecraft.world.level.Level; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.NotNull; - -public class ExplodeAction { - - public static void action(SerializableData.Instance data, @NotNull Triple block) { - - Level level = block.getLeft(); - if (level.isClientSide) { - return; - } - - float explosionPower = data.get("power"); - boolean create_fire = data.getBoolean("create_fire"); - - BlockPos location = block.getMiddle(); - - Explosion explosion = new Explosion( - level, - null, - level.damageSources().generic(), - new ExplosionDamageCalculator(), - location.getX(), - location.getY(), - location.getZ(), - explosionPower, - create_fire, - data.get("destruction_type"), - ParticleTypes.EXPLOSION, - ParticleTypes.EXPLOSION_EMITTER, - SoundEvents.GENERIC_EXPLODE - ); - ExplosionMask.getExplosionMask(explosion, level).apply(true, data.get("indestructible"), data.get("destructible"), true); - - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("explode"), - SerializableData.serializableData() - .add("power", SerializableDataTypes.FLOAT) - .add("destruction_type", ApoliDataTypes.BACKWARDS_COMPATIBLE_DESTRUCTION_TYPE, Explosion.BlockInteraction.DESTROY) - .add("indestructible", ApoliDataTypes.BLOCK_CONDITION, null) - .add("indestructible_resistance", SerializableDataTypes.FLOAT, 10.0f) - .add("destructible", ApoliDataTypes.BLOCK_CONDITION, null) - .add("create_fire", SerializableDataTypes.BOOLEAN, false), - ExplodeAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/ModifyBlockStateAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/block/ModifyBlockStateAction.java deleted file mode 100644 index cc8268a5e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/block/ModifyBlockStateAction.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.github.dueris.originspaper.action.types.block; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.ResourceOperation; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.Property; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; -import java.util.Optional; - -public class ModifyBlockStateAction { - - public static void action(@NotNull SerializableData.Instance data, @NotNull Triple block) { - BlockState state = block.getLeft().getBlockState(block.getMiddle()); - Collection> properties = state.getProperties(); - String desiredPropertyName = data.getString("property"); - Property property = null; - for (Property p : properties) { - if (p.getName().equals(desiredPropertyName)) { - property = p; - break; - } - } - if (property != null) { - if (data.getBoolean("cycle")) { - block.getLeft().setBlockAndUpdate(block.getMiddle(), state.cycle(property)); - } else { - Object value = state.getValue(property); - if (data.isPresent("enum") && value instanceof Enum) { - modifyEnumState(block.getLeft(), block.getMiddle(), state, property, data.getString("enum")); - } else if (data.isPresent("value") && value instanceof Boolean) { - block.getLeft().setBlockAndUpdate(block.getMiddle(), state.setValue((Property) property, data.getBoolean("value"))); - } else if (data.isPresent("operation") && data.isPresent("change") && value instanceof Integer) { - ResourceOperation op = data.get("operation"); - int opValue = data.getInt("change"); - int newValue = (int) value; - switch (op) { - case ADD -> newValue += opValue; - case SET -> newValue = opValue; - } - Property integerProperty = (Property) property; - if (integerProperty.getPossibleValues().contains(newValue)) { - block.getLeft().setBlockAndUpdate(block.getMiddle(), state.setValue(integerProperty, newValue)); - } - } - } - } - } - - private static > void modifyEnumState(Level world, BlockPos pos, BlockState originalState, @NotNull Property property, String value) { - Optional enumValue = property.getValue(value); - enumValue.ifPresent(v -> world.setBlockAndUpdate(pos, originalState.setValue(property, v))); - } - - public static @NotNull ActionTypeFactory> getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("modify_block_state"), - SerializableData.serializableData() - .add("property", SerializableDataTypes.STRING) - .add("operation", ApoliDataTypes.RESOURCE_OPERATION, ResourceOperation.ADD) - .add("change", SerializableDataTypes.INT, null) - .add("value", SerializableDataTypes.BOOLEAN, null) - .add("enum", SerializableDataTypes.STRING, null) - .add("cycle", SerializableDataTypes.BOOLEAN, false), - ModifyBlockStateAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/AddVelocityAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/AddVelocityAction.java deleted file mode 100644 index de3024cee..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/AddVelocityAction.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Space; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.apache.logging.log4j.util.TriConsumer; -import org.jetbrains.annotations.NotNull; -import org.joml.Vector3f; - -public class AddVelocityAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("add_velocity"), - SerializableData.serializableData() - .add("x", SerializableDataTypes.FLOAT, 0F) - .add("y", SerializableDataTypes.FLOAT, 0F) - .add("z", SerializableDataTypes.FLOAT, 0F) - .add("space", ApoliDataTypes.SPACE, Space.WORLD) - .add("client", SerializableDataTypes.BOOLEAN, true) - .add("server", SerializableDataTypes.BOOLEAN, true) - .add("set", SerializableDataTypes.BOOLEAN, false), - (data, entity) -> { - if (entity instanceof Player - && (entity.level().isClientSide ? - !data.getBoolean("client") : !data.getBoolean("server"))) - return; - Space space = data.get("space"); - Vector3f vec = new Vector3f(data.getFloat("x"), data.getFloat("y"), data.getFloat("z")); - TriConsumer method = entity::push; - if (data.getBoolean("set")) { - method = entity::setDeltaMovement; - } - space.toGlobal(vec, entity); - method.accept(vec.x, vec.y, vec.z); - entity.hurtMarked = true; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/AddXpAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/AddXpAction.java deleted file mode 100644 index 2721417af..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/AddXpAction.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class AddXpAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("add_xp"), - SerializableData.serializableData() - .add("points", SerializableDataTypes.INT, 0) - .add("levels", SerializableDataTypes.INT, 0), - (data, entity) -> { - if (entity instanceof Player) { - int points = data.getInt("points"); - int levels = data.getInt("levels"); - if (points > 0) { - ((Player) entity).giveExperiencePoints(points); - } - ((Player) entity).giveExperienceLevels(levels); - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ApplyEffectAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ApplyEffectAction.java deleted file mode 100644 index e564d7e2a..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ApplyEffectAction.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class ApplyEffectAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("apply_effect"), - SerializableData.serializableData() - .add("effect", SerializableDataTypes.STATUS_EFFECT_INSTANCE, null) - .add("effects", SerializableDataTypes.list(SerializableDataTypes.STATUS_EFFECT_INSTANCE), null), - (data, entity) -> { - if (entity instanceof LivingEntity le && !entity.level().isClientSide) { - if (data.isPresent("effect")) { - MobEffectInstance effect = data.get("effect"); - le.addEffect(new MobEffectInstance(effect)); - } - if (data.isPresent("effects")) { - ((List) data.get("effects")).forEach(e -> le.addEffect(new MobEffectInstance(e))); - } - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/BlockActionAtAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/BlockActionAtAction.java deleted file mode 100644 index d91aa68ad..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/BlockActionAtAction.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.NotNull; - -public class BlockActionAtAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("block_action_at"), - SerializableData.serializableData() - .add("block_action", ApoliDataTypes.BLOCK_ACTION), - (data, entity) -> ((ActionTypeFactory>) data.get("block_action")).accept( - Triple.of(entity.level(), entity.blockPosition(), Direction.UP))); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ChangeResourceAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ChangeResourceAction.java deleted file mode 100644 index f6bb8d139..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ChangeResourceAction.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.ResourceOperation; -import io.github.dueris.originspaper.power.ResourcePower; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.Locale; -import java.util.Optional; - -public class ChangeResourceAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("change_resource"), - SerializableData.serializableData() - .add("resource", SerializableDataTypes.IDENTIFIER) - .add("change", SerializableDataTypes.INT) - .add("operation", ApoliDataTypes.RESOURCE_OPERATION, ResourceOperation.ADD), - (data, entity) -> { - Optional resourceBar = ResourcePower.getDisplayedBar(entity, data.getId("resource").toString()); - resourceBar.ifPresent((bar) -> { - int change = data.get("change"); - ResourceOperation operation = data.get("operation"); - bar.change(change, operation.toString().toLowerCase(Locale.ROOT)); - }); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ClearEffectAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ClearEffectAction.java deleted file mode 100644 index 0a44de2a8..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ClearEffectAction.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class ClearEffectAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("clear_effect"), - SerializableData.serializableData() - .add("effect", SerializableDataTypes.STATUS_EFFECT_ENTRY, null), - (data, entity) -> { - if (entity instanceof LivingEntity le) { - if (data.isPresent("effect")) { - le.removeEffect(data.get("effect")); - } else { - le.removeAllEffects(); - } - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/CraftingTableAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/CraftingTableAction.java deleted file mode 100644 index d75e99b55..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/CraftingTableAction.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.stats.Stats; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class CraftingTableAction { - - public static void action(SerializableData.Instance data, Entity entity) { - - if (!(entity instanceof Player playerEntity)) { - return; - } - - playerEntity.getBukkitEntity().openWorkbench(null, true); - playerEntity.awardStat(Stats.INTERACT_WITH_CRAFTING_TABLE); - - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("crafting_table"), - SerializableData.serializableData(), - CraftingTableAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/DamageAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/DamageAction.java deleted file mode 100644 index a3fdfc658..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/DamageAction.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.types.modifier.Modifier; -import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.DamageType; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -import java.util.LinkedList; -import java.util.List; - -public class DamageAction { - - public static void action(@NotNull SerializableData.Instance data, Entity entity) { - - Float damageAmount = data.get("amount"); - List modifiers = new LinkedList<>(); - - data.ifPresent("modifier", modifiers::add); - data.>ifPresent("modifiers", modifiers::addAll); - - if (!modifiers.isEmpty() && entity instanceof LivingEntity livingEntity) { - damageAmount = (float) ModifierUtil.applyModifiers(livingEntity, modifiers, livingEntity.getMaxHealth()); - } - - if (damageAmount == null) { - return; - } - - try { - DamageSource source; - if (data.isPresent("damage_type")) { - source = Util.getDamageSource(Util.DAMAGE_REGISTRY.get((ResourceKey) data.get("damage_type"))); - } else { - source = entity.level().damageSources().generic(); - } - if (data.isPresent("source") && !data.isPresent("damage_type")) { - OriginsPaper.getPlugin().getLogger().warning("A \"source\" field was provided in the bientity_action \"apoli:damage\", please use the \"damage_type\" field instead."); - } - entity.hurt(source, damageAmount); - } catch (Throwable t) { - OriginsPaper.getPlugin().getLog4JLogger().error("Error trying to deal damage via the `damage` entity action: {}", t.getMessage()); - t.printStackTrace(); - } - - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("damage"), - SerializableData.serializableData() - .add("amount", SerializableDataTypes.FLOAT, null) - .add("damage_type", SerializableDataTypes.DAMAGE_TYPE, null) - .add("modifier", Modifier.DATA_TYPE, null) - .add("modifiers", Modifier.LIST_TYPE, null), - DamageAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/DismountAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/DismountAction.java deleted file mode 100644 index 3d9ad957b..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/DismountAction.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class DismountAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("dismount"), - SerializableData.serializableData(), - (data, entity) -> entity.stopRiding()); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/EmitGameEvent.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/EmitGameEvent.java deleted file mode 100644 index ff4b4dc50..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/EmitGameEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class EmitGameEvent { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("emit_game_event"), - SerializableData.serializableData() - .add("event", SerializableDataTypes.GAME_EVENT), - (data, entity) -> entity.gameEvent(data.get("event"))); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/EnderChestAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/EnderChestAction.java deleted file mode 100644 index 6d1066008..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/EnderChestAction.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.network.chat.Component; -import net.minecraft.stats.Stats; -import net.minecraft.world.SimpleMenuProvider; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.ChestMenu; -import net.minecraft.world.inventory.PlayerEnderChestContainer; -import org.jetbrains.annotations.NotNull; - -public class EnderChestAction { - - private static final Component TITLE = Component.translatable("container.enderchest"); - - public static void action(SerializableData.Instance data, Entity entity) { - if (!(entity instanceof Player player)) return; - - PlayerEnderChestContainer enderChestContainer = player.getEnderChestInventory(); - - player.openMenu( - new SimpleMenuProvider((i, inventory, _player) -> - ChestMenu.threeRows(i, inventory, enderChestContainer), - TITLE - ) - ); - - player.awardStat(Stats.OPEN_ENDERCHEST); - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("ender_chest"), - SerializableData.serializableData(), - EnderChestAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExecuteCommandAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExecuteCommandAction.java deleted file mode 100644 index 948a9c93d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExecuteCommandAction.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.commands.CommandSource; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class ExecuteCommandAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("execute_command"), - SerializableData.serializableData() - .add("command", SerializableDataTypes.STRING), - (data, entity) -> { - MinecraftServer server = entity.level().getServer(); - if (server != null) { - boolean validOutput = !(entity instanceof ServerPlayer) || ((ServerPlayer) entity).connection != null; - CommandSourceStack source = new CommandSourceStack( - OriginsPaper.showCommandOutput && validOutput ? entity : CommandSource.NULL, - entity.position(), - entity.getRotationVector(), - entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, - 4, - entity.getName().getString(), - entity.getDisplayName(), - entity.level().getServer(), - entity); - String cmd = data.getString("command"); - // Fix the command to support our pehuki implementation - if (cmd.contains("scale")) { - if (cmd.contains("@s")) { - cmd = cmd.replace(" @s", ""); - } - } - server.getCommands().performPrefixedCommand(source, cmd); - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExhaustAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExhaustAction.java deleted file mode 100644 index b922ed2a7..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExhaustAction.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class ExhaustAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("exhaust"), - SerializableData.serializableData() - .add("amount", SerializableDataTypes.FLOAT), - (data, entity) -> { - if (entity instanceof Player) - ((Player) entity).getFoodData().addExhaustion(data.getFloat("amount")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExplodeAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExplodeAction.java deleted file mode 100644 index a55dce129..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExplodeAction.java +++ /dev/null @@ -1,64 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.ExplosionMask; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.ExplosionDamageCalculator; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; - -public class ExplodeAction { - - public static void action(SerializableData.Instance data, @NotNull Entity entity) { - - Level level = entity.level(); - if (level.isClientSide) { - return; - } - - float explosionPower = data.get("power"); - boolean create_fire = data.getBoolean("create_fire"); - - Vec3 location = entity.position(); - - Explosion explosion = new Explosion( - level, - null, - level.damageSources().generic(), - new ExplosionDamageCalculator(), - location.x, - location.y, - location.z, - explosionPower, - create_fire, - data.get("destruction_type"), - ParticleTypes.EXPLOSION, - ParticleTypes.EXPLOSION_EMITTER, - SoundEvents.GENERIC_EXPLODE - ); - ExplosionMask.getExplosionMask(explosion, level).apply(true, data.get("indestructible"), data.get("destructible"), true); - - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("explode"), - SerializableData.serializableData() - .add("power", SerializableDataTypes.FLOAT) - .add("destruction_type", ApoliDataTypes.BACKWARDS_COMPATIBLE_DESTRUCTION_TYPE, Explosion.BlockInteraction.DESTROY) - .add("indestructible", ApoliDataTypes.BLOCK_CONDITION, null) - .add("indestructible_resistance", SerializableDataTypes.FLOAT, 10.0f) - .add("destructible", ApoliDataTypes.BLOCK_CONDITION, null) - .add("create_fire", SerializableDataTypes.BOOLEAN, false), - ExplodeAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExtinguishAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExtinguishAction.java deleted file mode 100644 index b00de1d34..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ExtinguishAction.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class ExtinguishAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("extinguish"), - SerializableData.serializableData(), - (data, entity) -> entity.clearFire()); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/FeedAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/FeedAction.java deleted file mode 100644 index 56efc57ac..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/FeedAction.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class FeedAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("feed"), - SerializableData.serializableData() - .add("food", SerializableDataTypes.INT) - .add("saturation", SerializableDataTypes.FLOAT), - (data, entity) -> { - if (entity instanceof Player) { - ((Player) entity).getFoodData().eat(data.getInt("food"), data.getFloat("saturation")); - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/GainAirAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/GainAirAction.java deleted file mode 100644 index b9aa94584..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/GainAirAction.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class GainAirAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("gain_air"), - SerializableData.serializableData() - .add("value", SerializableDataTypes.INT), - (data, entity) -> { - if (entity instanceof LivingEntity le) { - le.setAirSupply(Math.min(le.getAirSupply() + data.getInt("value"), le.getMaxAirSupply())); - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/GiveAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/GiveAction.java deleted file mode 100644 index 13892297d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/GiveAction.java +++ /dev/null @@ -1,86 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.SlotAccess; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Consumer; - -public class GiveAction { - - public static void action(SerializableData.Instance data, @NotNull Entity entity) { - - if (entity.level().isClientSide) { - return; - } - - ItemStack stack = data.get("stack").copy(); - if (stack.isEmpty()) { - return; - } - - SlotAccess stackReference = Util.createStackReference(stack); - if (data.isPresent("item_action")) { - Consumer> itemAction = data.get("item_action"); - itemAction.accept(new Tuple<>(entity.level(), stackReference)); - } - - stack = stackReference.get(); - - tryPreferredSlot: - if (data.isPresent("preferred_slot") && entity instanceof LivingEntity livingEntity) { - - EquipmentSlot preferredSlot = data.get("preferred_slot"); - ItemStack stackInSlot = livingEntity.getItemBySlot(preferredSlot); - - if (stackInSlot.isEmpty()) { - livingEntity.setItemSlot(preferredSlot, stack); - return; - } - - if (!ItemStack.matches(stackInSlot, stack) || stackInSlot.getCount() >= stackInSlot.getMaxStackSize()) { - break tryPreferredSlot; - } - - int itemsToGive = Math.min(stackInSlot.getMaxStackSize() - stackInSlot.getCount(), stack.getCount()); - - stackInSlot.grow(itemsToGive); - stack.shrink(itemsToGive); - - if (stack.isEmpty()) { - return; - } - - } - - if (entity instanceof Player playerEntity) { - playerEntity.getInventory().placeItemBackInInventory(stack); - } else { - Util.throwItem(entity, stack, false, false); - } - - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("give"), - SerializableData.serializableData() - .add("stack", SerializableDataTypes.ITEM_STACK) - .add("item_action", ApoliDataTypes.ITEM_ACTION, null) - .add("preferred_slot", SerializableDataTypes.EQUIPMENT_SLOT, null), - GiveAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/GrantAdvancementAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/GrantAdvancementAction.java deleted file mode 100644 index ca82c892e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/GrantAdvancementAction.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.bukkit.Bukkit; -import org.jetbrains.annotations.NotNull; - -public class GrantAdvancementAction { - - public static void action(@NotNull SerializableData.Instance data, @NotNull Entity entity) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "advancement grant $1 only $2" - .replace("$1", entity.getName().getString()) - .replace("$2", data.getString("advancement"))); - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("grant_advancement"), - SerializableData.serializableData() - .add("advancement", SerializableDataTypes.IDENTIFIER, null), - GrantAdvancementAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/HealAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/HealAction.java deleted file mode 100644 index 27fd92418..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/HealAction.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class HealAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("heal"), - SerializableData.serializableData() - .add("amount", SerializableDataTypes.FLOAT), - (data, entity) -> { - if (entity instanceof LivingEntity) { - ((LivingEntity) entity).heal(data.getFloat("amount")); - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyResourceAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyResourceAction.java deleted file mode 100644 index a28e96377..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ModifyResourceAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.types.modifier.Modifier; -import io.github.dueris.originspaper.power.ResourcePower; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.Optional; - -public class ModifyResourceAction { - - public static void action(SerializableData.@NotNull Instance data, Entity entity) { - Optional resourceBar = ResourcePower.getDisplayedBar(entity, data.getString("resource")); - resourceBar.ifPresent((bar) -> { - Modifier modifier = data.get("modifier"); - Long change = Math.round(modifier.apply(entity, bar.getMappedProgress())); - bar.change(change.intValue(), "set"); - }); - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("modify_resource"), - SerializableData.serializableData() - .add("modifier", Modifier.DATA_TYPE) - .add("resource", SerializableDataTypes.IDENTIFIER), - ModifyResourceAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/PassengerAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/PassengerAction.java deleted file mode 100644 index c75424fec..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/PassengerAction.java +++ /dev/null @@ -1,45 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Consumer; -import java.util.function.Predicate; - -public class PassengerAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("passenger_action"), - SerializableData.serializableData() - .add("action", ApoliDataTypes.ENTITY_ACTION, null) - .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) - .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) - .add("recursive", SerializableDataTypes.BOOLEAN, false), - (data, entity) -> { - Consumer entityAction = data.get("action"); - Consumer> bientityAction = data.get("bientity_action"); - Predicate> cond = data.get("bientity_condition"); - if (!entity.isVehicle() || (entityAction == null && bientityAction == null)) { - return; - } - Iterable passengers = data.getBoolean("recursive") ? entity.getIndirectPassengers() : entity.getPassengers(); - for (Entity passenger : passengers) { - if (cond == null || cond.test(new Tuple<>(passenger, entity))) { - if (entityAction != null) { - entityAction.accept(passenger); - } - if (bientityAction != null) { - bientityAction.accept(new Tuple<>(passenger, entity)); - } - } - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/PlaySoundAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/PlaySoundAction.java deleted file mode 100644 index c00d525d9..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/PlaySoundAction.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.sounds.SoundSource; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class PlaySoundAction { - - public static void action(@NotNull SerializableData.Instance data, @NotNull Entity entity) { - SoundSource category = data.isPresent("category") ? data.get("category") : entity.getSoundSource(); - entity.level().playSound(null, entity.blockPosition(), data.get("sound"), category, data.getFloat("volume"), data.getFloat("pitch")); - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("play_sound"), - SerializableData.serializableData() - .add("sound", SerializableDataTypes.SOUND_EVENT) - .add("category", SerializableDataTypes.enumValue(SoundSource.class), null) - .add("volume", SerializableDataTypes.FLOAT, 1.0f) - .add("pitch", SerializableDataTypes.FLOAT, 1.0f), - PlaySoundAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RemoveAdvancementAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RemoveAdvancementAction.java deleted file mode 100644 index ff78ee83e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RemoveAdvancementAction.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.bukkit.Bukkit; -import org.jetbrains.annotations.NotNull; - -public class RemoveAdvancementAction { - - public static void action(@NotNull SerializableData.Instance data, @NotNull Entity entity) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "advancement revoke $1 only $2" - .replace("$1", entity.getName().getString()) - .replace("$2", data.getString("advancement"))); - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("revoke_advancement"), - SerializableData.serializableData() - .add("advancement", SerializableDataTypes.IDENTIFIER, null), - RemoveAdvancementAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RidingAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RidingAction.java deleted file mode 100644 index b246584f7..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/RidingAction.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Consumer; -import java.util.function.Predicate; - -public class RidingAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("riding_action"), - SerializableData.serializableData() - .add("action", ApoliDataTypes.ENTITY_ACTION, null) - .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) - .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) - .add("recursive", SerializableDataTypes.BOOLEAN, false), - (data, entity) -> { - Consumer entityAction = data.get("action"); - Consumer> bientityAction = data.get("bientity_action"); - Predicate> cond = data.get("bientity_condition"); - if (!entity.isPassenger() || (entityAction == null && bientityAction == null)) { - return; - } - if (data.getBoolean("recursive")) { - Entity vehicle = entity.getVehicle(); - while (vehicle != null) { - if (cond == null || cond.test(new Tuple<>(entity, vehicle))) { - if (entityAction != null) { - entityAction.accept(vehicle); - } - if (bientityAction != null) { - bientityAction.accept(new Tuple<>(entity, vehicle)); - } - } - vehicle = vehicle.getVehicle(); - } - } else { - Entity vehicle = entity.getVehicle(); - if (cond == null || cond.test(new Tuple<>(entity, vehicle))) { - if (entityAction != null) { - entityAction.accept(vehicle); - } - if (bientityAction != null) { - bientityAction.accept(new Tuple<>(entity, vehicle)); - } - } - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SetFallDistanceAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SetFallDistanceAction.java deleted file mode 100644 index 621c1595a..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SetFallDistanceAction.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class SetFallDistanceAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("set_fall_distance"), - SerializableData.serializableData() - .add("fall_distance", SerializableDataTypes.FLOAT), - (data, entity) -> entity.fallDistance = data.getFloat("fall_distance")); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SetOnFireAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SetOnFireAction.java deleted file mode 100644 index 8986c877a..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SetOnFireAction.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class SetOnFireAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("set_on_fire"), - SerializableData.serializableData() - .add("duration", SerializableDataTypes.INT), - (data, entity) -> entity.igniteForSeconds(data.getInt("duration"))); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SetResourceAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SetResourceAction.java deleted file mode 100644 index 8b6f4787e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SetResourceAction.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.power.ResourcePower; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.Optional; - -public class SetResourceAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("set_resource"), - SerializableData.serializableData() - .add("resource", SerializableDataTypes.IDENTIFIER) - .add("value", SerializableDataTypes.INT), - (data, entity) -> { - Optional resourceBar = ResourcePower.getDisplayedBar(entity, data.getId("resource").toString()); - resourceBar.ifPresent((bar) -> { - int val = data.get("value"); - bar.change(val, "set"); - }); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ShowToastAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ShowToastAction.java deleted file mode 100644 index 3dd4f15df..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ShowToastAction.java +++ /dev/null @@ -1,77 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.ItemStack; -import org.bukkit.Bukkit; -import org.bukkit.advancement.Advancement; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; -import org.bukkit.scheduler.BukkitRunnable; -import org.jetbrains.annotations.NotNull; - -public class ShowToastAction { - - public static void action(SerializableData.Instance data, @NotNull Entity entity) { - - if (!entity.level().isClientSide) { - String title = data.getString("title"); - String description = data.getString("description"); - ItemStack icon = data.get("icon"); - - if (entity.getBukkitEntity() instanceof CraftPlayer player) { - String advancement = "{\n" + - " \"criteria\": {\n" + - " \"trigger\": {\n" + - " \"trigger\": \"minecraft:impossible\"\n" + - " }\n" + - " },\n" + - " \"display\": {\n" + - " \"icon\": {\n" + - " \"id\": \"" + icon.getBukkitStack().getType().getKey().asString() + "\"\n" + - " },\n" + - " \"title\": {\n" + - " \"text\": \"" + title + "\"\n" + - " },\n" + - " \"description\": {\n" + - " \"text\": \"" + description + "\"\n" + - " },\n" + - " \"background\": \"minecraft:textures/gui/advancements/backgrounds/adventure.png\",\n" + - " \"frame\": \"task\",\n" + - " \"announce_to_chat\": false,\n" + - " \"show_toast\": true,\n" + - " \"hidden\": true\n" + - " }\n" + - " }"; - Advancement possible = Bukkit.getAdvancement(CraftNamespacedKey.fromMinecraft(OriginsPaper.apoliIdentifier(title.replace(" ", "_").toLowerCase()))); - Advancement a = possible == null ? - Bukkit.getUnsafe().loadAdvancement(possible.getKey(), advancement) : possible; - // Advancement is loaded now - player.getAdvancementProgress(a).awardCriteria("trigger"); - new BukkitRunnable() { - @Override - public void run() { - player.getAdvancementProgress(a).revokeCriteria("trigger"); - } - }.runTaskLater(OriginsPaper.getPlugin(), 5); - } - } - - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("show_toast"), - SerializableData.serializableData() - .add("title", SerializableDataTypes.TEXT) - .add("description", SerializableDataTypes.TEXT) - .add("texture", SerializableDataTypes.IDENTIFIER, OriginsPaper.apoliIdentifier("toast/custom")) - .add("icon", SerializableDataTypes.ITEM_STACK, ItemStack.EMPTY) - .add("duration", SerializableDataTypes.POSITIVE_INT, 5000), - ShowToastAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SpawnEffectCloudAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SpawnEffectCloudAction.java deleted file mode 100644 index eae97a060..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SpawnEffectCloudAction.java +++ /dev/null @@ -1,46 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.AreaEffectCloud; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.alchemy.PotionContents; -import org.jetbrains.annotations.NotNull; - -public class SpawnEffectCloudAction { - - public static void action(SerializableData.Instance data, @NotNull Entity entity) { - - AreaEffectCloud aec = new AreaEffectCloud(entity.level(), entity.getX(), entity.getY(), entity.getZ()); - if (entity instanceof LivingEntity livingEntity) { - aec.setOwner(livingEntity); - } - - aec.setRadius(data.getFloat("radius")); - aec.setRadiusOnUse(data.getFloat("radius_on_use")); - aec.setDuration(data.getInt("duration")); - aec.setDurationOnUse(data.getInt("duration_on_use")); - aec.setWaitTime(data.getInt("wait_time")); - aec.setPotionContents(data.get("effect_component")); - - entity.level().addFreshEntity(aec); - - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("spawn_effect_cloud"), - SerializableData.serializableData() - .add("radius", SerializableDataTypes.FLOAT, 3.0F) - .add("radius_on_use", SerializableDataTypes.FLOAT, -0.5F) - .add("duration", SerializableDataTypes.INT, 600) - .add("duration_on_use", SerializableDataTypes.INT, 0) - .add("wait_time", SerializableDataTypes.INT, 10) - .add("effect_component", SerializableDataTypes.POTION_CONTENTS_COMPONENT, PotionContents.EMPTY), - SpawnEffectCloudAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SpawnEntityAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SpawnEntityAction.java deleted file mode 100644 index fbf7d51be..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/SpawnEntityAction.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import org.jetbrains.annotations.NotNull; - -import java.util.Optional; -import java.util.function.Consumer; - -public class SpawnEntityAction { - - public static void action(SerializableData.Instance data, @NotNull Entity entity) { - - if (entity.level().isClientSide) return; - - ServerLevel serverWorld = (ServerLevel) entity.level(); - EntityType entityType = data.get("entity_type"); - CompoundTag entityNbt = data.get("tag"); - - Optional opt$entityToSpawn = Util.getEntityWithPassengers( - serverWorld, - entityType, - entityNbt, - entity.position(), - entity.getYRot(), - entity.getXRot() - ); - - if (opt$entityToSpawn.isEmpty()) return; - Entity entityToSpawn = opt$entityToSpawn.get(); - - serverWorld.tryAddFreshEntityWithPassengers(entityToSpawn); - data.>ifPresent("entity_action", entityAction -> entityAction.accept(entityToSpawn)); - data.>>ifPresent("bientity_action", biEntityAction -> biEntityAction.accept(new Tuple<>(entity, entityToSpawn))); - - } - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>( - OriginsPaper.apoliIdentifier("spawn_entity"), - SerializableData.serializableData() - .add("entity_type", SerializableDataTypes.ENTITY_TYPE) - .add("tag", SerializableDataTypes.NBT_COMPOUND, null) - .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) - .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null), - SpawnEntityAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ToggleAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ToggleAction.java deleted file mode 100644 index 42efc3f56..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/ToggleAction.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class ToggleAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("toggle"), - SerializableData.serializableData() - .add("power", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - if (entity instanceof LivingEntity) { - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/TriggerCooldownAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/TriggerCooldownAction.java deleted file mode 100644 index 0d4c3d05c..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/entity/TriggerCooldownAction.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.dueris.originspaper.action.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.power.CooldownInterface; -import io.github.dueris.originspaper.power.CooldownPower; -import io.github.dueris.originspaper.power.PowerType; -import io.github.dueris.originspaper.storage.PowerHolderComponent; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; - -public class TriggerCooldownAction { - - public static @NotNull ActionTypeFactory getFactory() { - return new ActionTypeFactory<>(OriginsPaper.apoliIdentifier("trigger_cooldown"), - SerializableData.serializableData() - .add("power", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - if (entity instanceof Player player) { - Arrays.stream(new String[]{"apoli:action_on_hit", "apoli:action_when_damage_taken", "apoli:action_when_hit", - "apoli:action_self", "apoli:attacker_action_when_hit", "apoli:self_action_on_hit", - "apoli:self_action_on_kill", "apoli:self_action_when_hit", "apoli:target_action_on_hit", "apoli:cooldown"}).forEach(type -> { - for (PowerType powerContainer : PowerHolderComponent.getPowers((org.bukkit.entity.Player) player.getBukkitEntity(), type)) { - if (powerContainer instanceof CooldownInterface cooldownInterface) { - CooldownPower.addCooldown(player.getBukkitEntity(), cooldownInterface); - } - } - }); - } - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/ConsumeAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/item/ConsumeAction.java deleted file mode 100644 index 765bf8f23..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/ConsumeAction.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.action.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.action.ItemActionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.SlotAccess; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class ConsumeAction { - - public static @NotNull ActionTypeFactory> getFactory() { - return ItemActionTypeFactory.createItemStackBased(OriginsPaper.apoliIdentifier("consume"), SerializableData.serializableData() - .add("amount", SerializableDataTypes.INT, 1), - (data, worldAndStack) -> worldAndStack.getB().shrink(data.getInt("amount"))); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/DamageAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/item/DamageAction.java deleted file mode 100644 index 201edbec9..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/DamageAction.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.github.dueris.originspaper.action.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.action.ItemActionTypeFactory; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.SlotAccess; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class DamageAction { - - public static void action(SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - if (!(worldAndStack.getA() instanceof ServerLevel serverWorld)) { - return; - } - - ItemStack stack = worldAndStack.getB(); - int damageAmount = data.getInt("amount"); - - if (data.getBoolean("ignore_unbreaking")) { - - if (damageAmount >= stack.getMaxDamage()) { - stack.shrink(1); - } else { - stack.setDamageValue(stack.getDamageValue() + damageAmount); - } - - } else { - stack.hurtAndBreak(damageAmount, serverWorld, null, item -> { - }); - } - - } - - public static @NotNull ActionTypeFactory> getFactory() { - return ItemActionTypeFactory.createItemStackBased( - OriginsPaper.apoliIdentifier("damage"), - SerializableData.serializableData() - .add("amount", SerializableDataTypes.INT, 1) - .add("ignore_unbreaking", SerializableDataTypes.BOOLEAN, false), - DamageAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/MergeCustomDataAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/item/MergeCustomDataAction.java deleted file mode 100644 index 2090b7a57..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/MergeCustomDataAction.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.github.dueris.originspaper.action.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.action.ItemActionTypeFactory; -import net.minecraft.core.component.DataComponents; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.SlotAccess; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.component.CustomData; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class MergeCustomDataAction { - - public static void action(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - ItemStack stack = worldAndStack.getB(); - CompoundTag newNbt = data.get("nbt"); - - CustomData.update(DataComponents.CUSTOM_DATA, stack, oldNbt -> oldNbt.merge(newNbt)); - - } - - public static @NotNull ActionTypeFactory> getFactory() { - return ItemActionTypeFactory.createItemStackBased( - OriginsPaper.apoliIdentifier("merge_custom_data"), - SerializableData.serializableData() - .add("nbt", SerializableDataTypes.NBT_COMPOUND), - MergeCustomDataAction::action - ); - - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/RemoveEnchantmentAction.java b/origins/src/main/java/io/github/dueris/originspaper/action/types/item/RemoveEnchantmentAction.java deleted file mode 100644 index 59a4a42dc..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/action/types/item/RemoveEnchantmentAction.java +++ /dev/null @@ -1,87 +0,0 @@ -package io.github.dueris.originspaper.action.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.action.ItemActionTypeFactory; -import net.minecraft.core.Holder; -import net.minecraft.core.component.DataComponents; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.SlotAccess; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.item.enchantment.ItemEnchantments; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -import java.util.LinkedList; -import java.util.List; - -public class RemoveEnchantmentAction { - - public static void action(SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - ItemStack stack = worldAndStack.getB(); - Level world = worldAndStack.getA(); - - if (!stack.isEnchanted()) { - return; - } - - List> enchantmentKeys = new LinkedList<>(); - - data.>ifPresent("enchantment", enchantmentKeys::add); - data.>>ifPresent("enchantments", enchantmentKeys::addAll); - - ItemEnchantments component = stack.getEnchantments(); - ItemEnchantments.Mutable componentBuilder = new ItemEnchantments.Mutable(component); - - Integer levels = data.isPresent("levels") - ? data.getInt("levels") - : null; - - if (!enchantmentKeys.isEmpty()) { - - for (ResourceKey enchantmentKey : enchantmentKeys) { - - Holder enchantmentEntry = world.registryAccess() - .registryOrThrow(Registries.ENCHANTMENT) - .getHolder(enchantmentKey) - .orElseThrow(); - - if (component.keySet().contains(enchantmentEntry)) { - componentBuilder.set(enchantmentEntry, levels != null ? component.getLevel(enchantmentEntry) - levels : 0); - } - - } - - } else { - - for (Holder enchantment : component.keySet()) { - componentBuilder.set(enchantment, levels != null ? component.getLevel(enchantment) - levels : 0); - } - - } - - stack.set(DataComponents.ENCHANTMENTS, componentBuilder.toImmutable()); - if (data.getBoolean("reset_repair_cost") && !stack.isEnchanted()) { - stack.set(DataComponents.REPAIR_COST, 0); - } - - } - - public static @NotNull ActionTypeFactory> getFactory() { - return ItemActionTypeFactory.createItemStackBased( - OriginsPaper.apoliIdentifier("remove_enchantment"), - SerializableData.serializableData() - .add("enchantment", SerializableDataTypes.ENCHANTMENT, null) - .add("enchantments", SerializableDataTypes.list(SerializableDataTypes.ENCHANTMENT), null) - .add("levels", SerializableDataTypes.INT, null) - .add("reset_repair_cost", SerializableDataTypes.BOOLEAN, false), - RemoveEnchantmentAction::action - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/command/Commands.java b/origins/src/main/java/io/github/dueris/originspaper/command/Commands.java deleted file mode 100644 index 02f48b99c..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/command/Commands.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.github.dueris.originspaper.command; - -import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.commands.CommandSourceStack; -import org.jetbrains.annotations.NotNull; - -public class Commands { - public static void bootstrap(CommandDispatcher dispatcher) { - OriginCommand.register(dispatcher); -// PowerCommand.register(dispatcher); // TODO - ResourceCommand.register(dispatcher); - } - - public static void unload(@NotNull CommandDispatcher dispatcher) { - dispatcher.getRoot().removeCommand("origin"); - dispatcher.getRoot().removeCommand("power"); - dispatcher.getRoot().removeCommand("resource"); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/command/OriginCommand.java b/origins/src/main/java/io/github/dueris/originspaper/command/OriginCommand.java index d1b700aed..b8557706e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/command/OriginCommand.java +++ b/origins/src/main/java/io/github/dueris/originspaper/command/OriginCommand.java @@ -1,483 +1,314 @@ package io.github.dueris.originspaper.command; -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import io.github.dueris.calio.registry.Registrar; -import io.github.dueris.calio.registry.impl.CalioRegistry; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.content.OrbOfOrigins; -import io.github.dueris.originspaper.event.OriginChangeEvent; +import io.github.dueris.originspaper.command.argument.LayerArgumentType; +import io.github.dueris.originspaper.command.argument.OriginArgumentType; import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; -import io.github.dueris.originspaper.power.PowerType; -import io.github.dueris.originspaper.power.RecipePower; import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.screen.OriginPage; -import io.github.dueris.originspaper.screen.RandomOriginPage; -import io.github.dueris.originspaper.storage.OriginConfiguration; +import io.github.dueris.originspaper.storage.OriginComponent; import io.github.dueris.originspaper.storage.PowerHolderComponent; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.commands.Commands; +import io.github.dueris.originspaper.util.LangFile; +import io.github.dueris.originspaper.util.Util; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.command.brigadier.Commands; import net.minecraft.commands.arguments.EntityArgument; -import net.minecraft.commands.arguments.ResourceLocationArgument; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.commands.arguments.selector.EntitySelector; import net.minecraft.server.level.ServerPlayer; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.craftbukkit.inventory.CraftInventoryCustom; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; -import org.bukkit.persistence.PersistentDataType; -import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; -public class OriginCommand extends BukkitRunnable implements Listener { - public static final HashMap playerPage = new HashMap<>(); - public static HashMap> playerOrigins = new HashMap<>(); - protected static Registrar LAYERS = CalioRegistry.INSTANCE.retrieve(Registries.LAYER); - protected static Registrar ORIGINS = CalioRegistry.INSTANCE.retrieve(Registries.ORIGIN); - protected static Registrar POWERS = CalioRegistry.INSTANCE.retrieve(Registries.CRAFT_POWER); +import static io.papermc.paper.command.brigadier.Commands.argument; +import static io.papermc.paper.command.brigadier.Commands.literal; - public static void register(@NotNull CommandDispatcher dispatcher) { +public class OriginCommand { + public static void register(@NotNull Commands dispatcher) { dispatcher.register( - Commands.literal("origin") - .then( - (Commands.literal("set").requires(source -> source.hasPermission(2))) - .then( - Commands.argument("targets", EntityArgument.players()) - .then( - Commands.argument("layer", ResourceLocationArgument.id()) - .suggests( - (context, builder) -> { - LAYERS.forEach( - (location, layer) -> { - if (context.getInput().split(" ").length == 3 - || layer.getTag() - .startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1]) - || layer.getTag().split(":")[1] - .startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1])) { - builder.suggest(layer.getTag()); - } - } - ); - return builder.buildFuture(); - } - ) - .then( - Commands.argument("origin", ResourceLocationArgument.id()) - .suggests( - (context, builder) -> { - OriginLayer layer = OriginsPaper.getLayer(ResourceLocationArgument.getId(context, "layer")); - layer.getOriginIdentifiers().stream().map(ResourceLocation::toString).filter(tag -> { - String input = context.getInput().split(" ")[context.getInput().split(" ").length - 1]; - return (tag.startsWith(input)) || context.getInput().split(" ").length == 4; - }).forEach(builder::suggest); - return builder.buildFuture(); - } - ) - .executes( - context -> { - Collection targets = EntityArgument.getPlayers(context, "targets"); - OriginLayer layer = OriginsPaper.getLayer(ResourceLocationArgument.getId(context, "layer")); - Origin origin = OriginsPaper.getOrigin(ResourceLocationArgument.getId(context, "origin")); - if (!layer.getOriginIdentifiers().contains(ResourceLocation.parse(origin.getTag()))) { - context.getSource() - .sendFailure( - Component.literal( - "Origin \"%e%\" not found on layer: ".replace("%e%", origin.getTag()) - + CraftNamespacedKey.fromMinecraft(ResourceLocationArgument.getId(context, "layer")) - .asString() - ) - ); - return 0; - } else { - targets.forEach( - player -> { - PowerHolderComponent.setOrigin(player.getBukkitEntity(), layer, origin); - player.getBukkitEntity() - .getPersistentDataContainer() - .set( - CraftNamespacedKey.fromMinecraft( - ResourceLocation.fromNamespaceAndPath("originspaper", "in-phantomform") - ), - PersistentDataType.BOOLEAN, - false - ); - OriginChangeEvent originChangeEvent = new OriginChangeEvent( - player.getBukkitEntity(), origin, layer, false - ); - Bukkit.getServer().getPluginManager().callEvent(originChangeEvent); - } - ); - return 1; - } - } - ) - ) - ) - ) + literal("origin").requires(cs -> ((net.minecraft.commands.CommandSourceStack) cs).hasPermission(2)) + .then(literal("set") + .then(argument("targets", EntityArgument.players()) + .then(argument("layer", LayerArgumentType.layer()) + .then(argument("origin", OriginArgumentType.origin()) + .executes(OriginCommand::setOrigin)))) ) - .then( - Commands.literal("recipe") - .executes( - context -> { - if (context.getSource().isPlayer()) { - if (!OriginConfiguration.getConfiguration().getBoolean("orb-of-origins")) { - return 0; - } else { - CraftInventoryCustom custommenu = (CraftInventoryCustom) Bukkit.createInventory( - context.getSource().getPlayer().getBukkitEntity(), - InventoryType.WORKBENCH, - "Orb of Origins" - ); - - try { - CraftPlayer p = context.getSource().getPlayer().getBukkitEntity(); - custommenu.setItem( - 1, - new ItemStack( - Material.valueOf(OriginConfiguration.getOrbConfiguration().get("crafting.top.left").toString()) - ) - ); - custommenu.setItem( - 2, - new ItemStack( - Material.valueOf(OriginConfiguration.getOrbConfiguration().get("crafting.top.middle").toString()) - ) - ); - custommenu.setItem( - 3, - new ItemStack( - Material.valueOf(OriginConfiguration.getOrbConfiguration().get("crafting.top.right").toString()) - ) - ); - custommenu.setItem( - 4, - new ItemStack( - Material.valueOf(OriginConfiguration.getOrbConfiguration().get("crafting.middle.left").toString()) - ) - ); - custommenu.setItem( - 5, - new ItemStack( - Material.valueOf(OriginConfiguration.getOrbConfiguration().get("crafting.middle.middle").toString()) - ) - ); - custommenu.setItem( - 6, - new ItemStack( - Material.valueOf(OriginConfiguration.getOrbConfiguration().get("crafting.middle.right").toString()) - ) - ); - custommenu.setItem( - 7, - new ItemStack( - Material.valueOf(OriginConfiguration.getOrbConfiguration().get("crafting.bottom.left").toString()) - ) - ); - custommenu.setItem( - 8, - new ItemStack( - Material.valueOf(OriginConfiguration.getOrbConfiguration().get("crafting.bottom.middle").toString()) - ) - ); - custommenu.setItem( - 9, - new ItemStack( - Material.valueOf(OriginConfiguration.getOrbConfiguration().get("crafting.bottom.right").toString()) - ) - ); - custommenu.setItem(0, OrbOfOrigins.orb); - p.openInventory(custommenu); - p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 10.0F, 9.0F); - } catch (Exception var3) { - var3.printStackTrace(); - } - - return 1; - } - } else { - context.getSource().sendFailure(Component.literal("Only players can access this command")); - return 0; - } - } - ) + .then(literal("has") + .then(argument("targets", EntityArgument.players()) + .then(argument("layer", LayerArgumentType.layer()) + .then(argument("origin", OriginArgumentType.origin()) + .executes(OriginCommand::hasOrigin)))) ) - .then( - (Commands.literal("get").requires(source -> source.hasPermission(2))) - .then( - Commands.argument("targets", EntityArgument.players()) - .then( - Commands.argument("layer", ResourceLocationArgument.id()) - .suggests( - (context, builder) -> { - LAYERS.forEach( - (location, layer) -> { - if (context.getInput().split(" ").length == 3 - || layer.getTag().startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1]) - || layer.getTag().split(":")[1] - .startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1])) { - builder.suggest(layer.getTag()); - } - } - ); - return builder.buildFuture(); - } - ) - .executes( - context -> { - Collection targets = EntityArgument.getPlayers(context, "targets"); - OriginLayer layer = OriginsPaper.getLayer(ResourceLocationArgument.getId(context, "layer")); - targets.forEach( - player -> context.getSource() - .sendSystemMessage( - Component.literal( - "%player% has the following %layer% : %origin%" - .replace("%player%", player.getBukkitEntity().getName()) - .replace("%layer%", layer.getTag()) - .replace("%origin%", PowerHolderComponent.getOrigin(player.getBukkitEntity(), layer).getTag()) - ) - ) - ); - return 1; - } - ) - ) - ) - ) - .then( - (Commands.literal("random") - .requires(source -> source.hasPermission(2))) - .executes(context -> { - if (!context.getSource().isPlayer()) { - return 0; - } else { - ServerPlayer player = context.getSource().getPlayer(); - RandomOriginPage randomOriginPage = new RandomOriginPage(); - OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).values().forEach(layer -> randomOriginPage.onChoose(player, layer)); - return 1; - } - }) - .then( - (Commands.argument("targets", EntityArgument.players()).executes(context -> { - Collection targets = EntityArgument.getPlayers(context, "targets"); - RandomOriginPage randomOriginPage = new RandomOriginPage(); - targets.forEach(player -> OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).values().forEach(layer -> randomOriginPage.onChoose(player, layer))); - return 1; - })) - .then( - Commands.argument("layer", ResourceLocationArgument.id()) - .suggests( - (context, builder) -> { - LAYERS.forEach( - (location, layer) -> { - if (context.getInput().split(" ").length == 3 - || layer.getTag().startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1]) - || layer.getTag().split(":")[1] - .startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1])) { - builder.suggest(layer.getTag()); - } - } - ); - return builder.buildFuture(); - } - ) - .executes(context -> { - Collection targets = EntityArgument.getPlayers(context, "targets"); - OriginLayer layer = OriginsPaper.getLayer(ResourceLocationArgument.getId(context, "layer")); - RandomOriginPage randomOriginPage = new RandomOriginPage(); - targets.forEach(player -> randomOriginPage.onChoose(player, layer)); - return 1; - }) - ) + .then(literal("get") + .then(argument("target", EntityArgument.player()) + .then(argument("layer", LayerArgumentType.layer()) + .executes(OriginCommand::getOrigin) ) + ) ) - .then( - ((Commands.literal("gui") - .requires(source -> source.hasPermission(2))) - .executes(context -> { - if (!context.getSource().isPlayer()) { - return 0; - } else { - ServerPlayer player = context.getSource().getPlayer(); - OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).values().forEach(layer -> { - PowerHolderComponent.unloadPowers(player.getBukkitEntity(), layer); - PowerHolderComponent.setOrigin(player.getBukkitEntity(), layer, OriginsPaper.EMPTY_ORIGIN); - }); - return 1; - } - }) - .then( - (Commands.argument("targets", EntityArgument.players()).executes(context -> { - Collection targets = EntityArgument.getPlayers(context, "targets"); - targets.forEach(player -> { - for (OriginLayer layer : OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).values()) { - PowerHolderComponent.unloadPowers(player.getBukkitEntity(), layer); - PowerHolderComponent.setOrigin(player.getBukkitEntity(), layer, OriginsPaper.EMPTY_ORIGIN); - } - }); - return 1; - })) - .then( - Commands.argument("layer", ResourceLocationArgument.id()) - .suggests( - (context, builder) -> { - LAYERS.forEach( - (location, layer) -> { - if (context.getInput().split(" ").length == 3 - || layer.getTag().startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1]) - || layer.getTag().split(":")[1] - .startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1])) { - builder.suggest(layer.getTag()); - } - } - ); - return builder.buildFuture(); - } - ) - .executes(context -> { - Collection targets = EntityArgument.getPlayers(context, "targets"); - OriginLayer layer = OriginsPaper.getLayer(ResourceLocationArgument.getId(context, "layer")); - targets.forEach(player -> { - PowerHolderComponent.unloadPowers(player.getBukkitEntity(), layer); - PowerHolderComponent.setOrigin(player.getBukkitEntity(), layer, OriginsPaper.EMPTY_ORIGIN); - }); - return 1; - }) - ) + .then(literal("gui") + .executes(commandContext -> OriginCommand.openMultipleLayerScreens(commandContext, TargetType.INVOKER)) + .then(argument("targets", EntityArgument.players()) + .executes(commandContext -> OriginCommand.openMultipleLayerScreens(commandContext, TargetType.SPECIFY)) + .then(argument("layer", LayerArgumentType.layer()) + .executes(OriginCommand::openSingleLayerScreen) ) ) - ).then( - Commands.literal("info") - .executes( - context -> { - if (context.getSource().isPlayer()) { - ServerPlayer p = context.getSource().getPlayer(); - Map origins = PowerHolderComponent.getOrigin(p.getBukkitEntity()); - origins.entrySet().removeIf(entry -> entry.getKey().isHidden()); - playerOrigins.put(p.getBukkitEntity(), new ArrayList<>(origins.values())); - if (!playerPage.containsKey(p.getBukkitEntity())) { - playerPage.put(p.getBukkitEntity(), 0); - } - - Inventory help = Bukkit.createInventory( - p.getBukkitEntity(), 54, net.kyori.adventure.text.Component.text("Info - ").append(playerOrigins.get(p.getBukkitEntity()).get(playerPage.get(p.getBukkitEntity())).name()) - ); - help.setContents( - new OriginPage(playerOrigins.get(p.getBukkitEntity()).get(playerPage.get(p.getBukkitEntity()))).createDisplay(p, null) - ); - p.getBukkitEntity().openInventory(help); - p.getBukkitEntity().playSound(p.getBukkitEntity().getLocation(), Sound.UI_BUTTON_CLICK, 2.0F, 1.0F); - return 1; - } else { - context.getSource().sendFailure(Component.literal("Only players can access this command")); - return 0; - } - } - ) ) - .then( - (Commands.literal("give").requires(source -> source.hasPermission(2))) - .then( - Commands.argument("targets", EntityArgument.players()) - .then( - (Commands.argument("namespace", ResourceLocationArgument.id()) - .suggests((context, builder) -> { - RecipePower.tags.forEach(builder::suggest); - builder.suggest("origins:orb_of_origins"); - return builder.buildFuture(); - }) - .executes(context -> { - give(context, 1); - return 1; - })) - .then(Commands.argument("amount", IntegerArgumentType.integer()).executes(context -> { - give(context, IntegerArgumentType.getInteger(context, "amount")); - return 1; - })) - ) + .then(literal("random") + .executes(commandContext -> OriginCommand.randomizeOrigins(commandContext, TargetType.INVOKER)) + .then(argument("targets", EntityArgument.players()) + .executes(commandContext -> OriginCommand.randomizeOrigins(commandContext, TargetType.SPECIFY)) + .then(argument("layer", LayerArgumentType.layer()) + .executes(OriginCommand::randomizeOrigin) ) - )); + ) + ).build() + ); } - public static void give(CommandContext context, int amt) throws CommandSyntaxException { - String tag = CraftNamespacedKey.fromMinecraft(ResourceLocationArgument.getId(context, "namespace")).asString(); - if (RecipePower.taggedRegistry.containsKey(tag)) { - for (ServerPlayer player : EntityArgument.getPlayers(context, "targets")) { - Recipe recipe = RecipePower.taggedRegistry.get(tag); - ItemStack itemStack = recipe.getResult().clone(); - itemStack.setAmount(amt); - player.addItem(CraftItemStack.asNMSCopy(itemStack)); + /** + * Set the origin of the specified entities in the specified origin layer. + * + * @param commandContext the command context + * @return the number of players whose origin has been set + * @throws CommandSyntaxException if the entity is not found or if the entity is not an instance of {@link ServerPlayer} + */ + private static int setOrigin(@NotNull CommandContext commandContext) throws CommandSyntaxException { + + Collection targets = commandContext.getArgument("targets", EntitySelector.class).findPlayers((net.minecraft.commands.CommandSourceStack) commandContext.getSource()); + OriginLayer originLayer = LayerArgumentType.getLayer(commandContext, "layer"); + Origin origin = OriginArgumentType.getOrigin(commandContext, "origin"); + net.minecraft.commands.CommandSourceStack serverCommandSource = (net.minecraft.commands.CommandSourceStack) commandContext.getSource(); + + int processedTargets = 0; + + if (origin.equals(Origin.EMPTY) || Util.collapseList(originLayer.getOrigins().stream().map(OriginLayer.ConditionedOrigin::origins).toList()).contains(origin.getId())) { + + for (ServerPlayer target : targets) { + + OriginComponent.setOrigin(target.getBukkitEntity(), originLayer, origin); + processedTargets++; + } - } else { - context.getSource().sendFailure(Component.literal("Item not found in origins registry.")); - } + + if (processedTargets == 1) + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.origin.set.success.single", targets.iterator().next().getDisplayName().getString(), originLayer.getName(), origin.getName()), true); + else { + int finalProcessedTargets = processedTargets; + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.origin.set.success.multiple", finalProcessedTargets, originLayer.getName(), origin.getName()), true); + } + + } else + serverCommandSource.sendFailure(LangFile.translatable("commands.origin.unregistered_in_layer", origin.getId(), originLayer.getId())); + + return processedTargets; + + } + + /** + * Check if the specified entities has the specified origin in the specified origin layer. + * + * @param commandContext the command context + * @return the number of players that has the specified origin in the specified origin layer + * @throws CommandSyntaxException if the entity is not found or if the entity is not an instance of {@link ServerPlayer} + */ + private static int hasOrigin(@NotNull CommandContext commandContext) throws CommandSyntaxException { + + Collection targets = commandContext.getArgument("targets", EntitySelector.class).findPlayers((net.minecraft.commands.CommandSourceStack) commandContext.getSource()); + OriginLayer originLayer = LayerArgumentType.getLayer(commandContext, "layer"); + Origin origin = OriginArgumentType.getOrigin(commandContext, "origin"); + net.minecraft.commands.CommandSourceStack serverCommandSource = (net.minecraft.commands.CommandSourceStack) commandContext.getSource(); + + int processedTargets = 0; + + if (origin.equals(Origin.EMPTY) || originLayer.getOrigins().contains(origin.getId())) { + + for (ServerPlayer target : targets) { + if ((origin.equals(Origin.EMPTY) || OriginComponent.hasOrigin(target.getBukkitEntity(), originLayer)) && OriginComponent.getOrigin(target.getBukkitEntity(), originLayer).equals(origin)) + processedTargets++; + } + + if (processedTargets == 0) + serverCommandSource.sendFailure(LangFile.translatable("commands.execute.conditional.fail")); + else if (processedTargets == 1) + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.execute.conditional.pass"), true); + else { + int finalProcessedTargets = processedTargets; + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.execute.conditional.pass_count", finalProcessedTargets), true); + } + + } else + serverCommandSource.sendFailure(LangFile.translatable("commands.origin.unregistered_in_layer", origin.getId(), originLayer.getId())); + + return processedTargets; + + } + + /** + * Get the origin of the specified entity from the specified origin layer. + * + * @param commandContext the command context + * @return 1 + * @throws CommandSyntaxException if the entity is not found or if the entity is not an instance of {@link ServerPlayer} + */ + private static int getOrigin(@NotNull CommandContext commandContext) throws CommandSyntaxException { + + ServerPlayer target = commandContext.getArgument("target", EntitySelector.class).findSinglePlayer((net.minecraft.commands.CommandSourceStack) commandContext.getSource()); + net.minecraft.commands.CommandSourceStack serverCommandSource = (net.minecraft.commands.CommandSourceStack) commandContext.getSource(); + + OriginLayer originLayer = LayerArgumentType.getLayer(commandContext, "layer"); + Origin origin = OriginComponent.getOrigin(target.getBukkitEntity(), originLayer); + + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.origin.get.result", target.getDisplayName().getString(), originLayer.getName(), origin.getName(), origin.getId()), true); + + return 1; + } - @EventHandler - public void stopStealingInfo(InventoryClickEvent e) { - if (e.getView().getTitle().startsWith("Info")) { - e.setCancelled(true); + /** + * Open the 'Choose Origin' screen for the specified origin layer to the specified entities. + * + * @param commandContext the command context + * @return the number of players that had the 'Choose Origin' screen opened for them + * @throws CommandSyntaxException if the entity is not found or if the entity is not an instance of {@link ServerPlayer} + */ + private static int openSingleLayerScreen(@NotNull CommandContext commandContext) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack serverCommandSource = (net.minecraft.commands.CommandSourceStack) commandContext.getSource(); + Collection targets = commandContext.getArgument("targets", EntitySelector.class).findPlayers((net.minecraft.commands.CommandSourceStack) commandContext.getSource()); + OriginLayer originLayer = LayerArgumentType.getLayer(commandContext, "layer"); + + for (ServerPlayer target : targets) { + PowerHolderComponent.unloadPowers(target.getBukkitEntity(), originLayer, true); + OriginComponent.setOrigin(target.getBukkitEntity(), originLayer, Origin.EMPTY); } + + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.origin.gui.layer", targets.size(), originLayer.getName()), true); + return targets.size(); + } - @EventHandler - public void onMenuScroll(InventoryClickEvent e) { - ItemStack item = e.getCurrentItem(); - Player player = (Player) e.getWhoClicked(); - if (item != null) { - if (e.getView().getTitle().startsWith("Info")) { - if (item.getType() == Material.ARROW - && (item.getItemMeta().getDisplayName().equals("Back Origin") || item.getItemMeta().getDisplayName().equals("Next Origin"))) { - if (item.getItemMeta().getDisplayName().equals("Back Origin") && playerPage.get(player) > 0) { - playerPage.put(player, playerPage.get(player) - 1); - } - - if (item.getItemMeta().getDisplayName().equals("Next Origin") && playerPage.get(player) < playerOrigins.get(player).size() - 1) { - playerPage.put(player, playerPage.get(player) + 1); - } - - Inventory info = Bukkit.createInventory(player, 54, net.kyori.adventure.text.Component.text("Info - ").append(playerOrigins.get(player).get(playerPage.get(player)).name())); - info.setContents(new OriginPage(playerOrigins.get(player).get(playerPage.get(player))).createDisplay(((CraftPlayer) player).getHandle(), null)); - player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 2.0F, 1.0F); - player.closeInventory(); - player.openInventory(info); - } + /** + * Open the 'Choose Origin' screen for all the enabled origin layers to the specified entities. + * + * @param commandContext the command context + * @return the number of players that had the 'Choose Origin' screen opened for them + * @throws CommandSyntaxException if the entity is not found or if the entity is not an instance of {@link ServerPlayer} + */ + private static int openMultipleLayerScreens(@NotNull CommandContext commandContext, @NotNull TargetType targetType) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack serverCommandSource = (net.minecraft.commands.CommandSourceStack) commandContext.getSource(); + List targets = new LinkedList<>(); + + switch (targetType) { + case INVOKER -> targets.add(serverCommandSource.getPlayerOrException()); + case SPECIFY -> + targets.addAll(commandContext.getArgument("targets", EntitySelector.class).findPlayers((net.minecraft.commands.CommandSourceStack) commandContext.getSource())); + } + + for (ServerPlayer target : targets) { + for (OriginLayer layer : OriginComponent.getLayers(target.getBukkitEntity())) { + PowerHolderComponent.unloadPowers(target.getBukkitEntity(), layer, true); + OriginComponent.setOrigin(target.getBukkitEntity(), layer, Origin.EMPTY); } } + + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.origin.gui.all", targets.size()), false); + return targets.size(); + } - @EventHandler - public void stopStealingRecipe(InventoryClickEvent e) { - if (e.getView().getTitle().equalsIgnoreCase("Orb of Origins") && e.getView().getTopInventory().getType().equals(InventoryType.WORKBENCH)) { - e.setCancelled(true); + /** + * Randomize the origin of the specified entities in the specified origin layer. + * + * @param commandContext the command context + * @return the number of players that had their origin randomized in the specified origin layer + * @throws CommandSyntaxException if the entity is not found or if the entity is not an instance of {@link ServerPlayer} + */ + private static int randomizeOrigin(@NotNull CommandContext commandContext) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack serverCommandSource = (net.minecraft.commands.CommandSourceStack) commandContext.getSource(); + Collection targets = commandContext.getArgument("targets", EntitySelector.class).findPlayers((net.minecraft.commands.CommandSourceStack) commandContext.getSource()); + OriginLayer originLayer = LayerArgumentType.getLayer(commandContext, "layer"); + + if (originLayer.isRandomAllowed()) { + + Origin origin = null; + for (ServerPlayer target : targets) { + origin = getRandomOrigin(target, originLayer); + } + + if (targets.size() > 1) + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.origin.random.success.multiple", targets.size(), originLayer.getName()), true); + else if (targets.size() == 1) { + Origin finalOrigin = origin; + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.origin.random.success.single", targets.iterator().next().getDisplayName().getString(), finalOrigin.getName(), originLayer.getName()), false); + } + + return targets.size(); + + } else { + serverCommandSource.sendFailure(LangFile.translatable("commands.origin.random.not_allowed", originLayer.getName())); + return 0; } + } - public void run() { - for (Player player : Bukkit.getOnlinePlayers()) { - if (!player.getOpenInventory().getTitle().startsWith("Info")) { - playerPage.remove(player); - playerOrigins.remove(player); + /** + * Randomize the origins of the specified entities in all the origin layers that allows to be randomized. + * + * @param commandContext the command context + * @return the number of players that had their origins randomized in all the origin layers that allows to be randomized + * @throws CommandSyntaxException if the entity is not found or if the entity is not an instance of {@link ServerPlayer} + */ + private static int randomizeOrigins(@NotNull CommandContext commandContext, @NotNull TargetType targetType) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack serverCommandSource = (net.minecraft.commands.CommandSourceStack) commandContext.getSource(); + List targets = new LinkedList<>(); + List originLayers = OriginsPaper.getRegistry().retrieve(Registries.LAYER).stream().filter(OriginLayer::isRandomAllowed).toList(); + + switch (targetType) { + case INVOKER -> targets.add(serverCommandSource.getPlayerOrException()); + case SPECIFY -> + targets.addAll(commandContext.getArgument("targets", EntitySelector.class).findPlayers((net.minecraft.commands.CommandSourceStack) commandContext.getSource())); + } + + for (ServerPlayer target : targets) { + for (OriginLayer originLayer : originLayers) { + getRandomOrigin(target, originLayer); } } + + serverCommandSource.sendSuccess(() -> LangFile.translatable("commands.origin.random.all", targets.size(), originLayers.size()), false); + return targets.size(); + + } + + private static @NotNull Origin getRandomOrigin(@NotNull ServerPlayer target, @NotNull OriginLayer originLayer) { + + List origins = originLayer.getRandomOrigins(); + Origin origin = origins.get(new Random().nextInt(origins.size())); + + OriginComponent.setOrigin(target.getBukkitEntity(), originLayer, origin); + + OriginsPaper.LOGGER.info( + "Player {} was randomly assigned the origin {} for layer {}", + target.getDisplayName().getString(), + origin.getId().toString(), + originLayer.getId().toString() + ); + + return origin; + + } + + private enum TargetType { + INVOKER, + SPECIFY } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/command/PowerCommand.java b/origins/src/main/java/io/github/dueris/originspaper/command/PowerCommand.java new file mode 100644 index 000000000..66720bd11 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/command/PowerCommand.java @@ -0,0 +1,493 @@ +package io.github.dueris.originspaper.command; + +import com.mojang.brigadier.arguments.BoolArgumentType; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.command.argument.PowerArgumentType; +import io.github.dueris.originspaper.command.argument.PowerHolderArgumentType; +import io.github.dueris.originspaper.origin.OriginLayer; +import io.github.dueris.originspaper.power.type.MultiplePower; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.util.JsonTextFormatter; +import io.github.dueris.originspaper.util.LangFile; +import io.github.dueris.originspaper.util.Util; +import io.github.dueris.originspaper.util.entity.PowerUtils; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.command.brigadier.Commands; +import joptsimple.internal.Strings; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; +import net.minecraft.commands.arguments.ResourceLocationArgument; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.ComponentUtils; +import net.minecraft.network.chat.HoverEvent; +import net.minecraft.network.chat.Style; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +import static io.papermc.paper.command.brigadier.Commands.argument; +import static io.papermc.paper.command.brigadier.Commands.literal; + +public class PowerCommand { + + public static ResourceLocation POWER_SOURCE = ResourceLocation.fromNamespaceAndPath("apoli", "command"); + + public static void register(Commands dispatcher) { + dispatcher.register( + literal("power").requires(scs -> ((net.minecraft.commands.CommandSourceStack) scs).hasPermission(2)) + .then(literal("grant") + .then(argument("targets", PowerHolderArgumentType.entities()) + .then(argument("power", PowerArgumentType.power()) + .executes(context -> grantPower(context, false)) + .then(argument("source", ResourceLocationArgument.id()) + .executes(context -> grantPower(context, true))))) + ) + .then(Commands.literal("revoke") + .then(Commands.argument("targets", PowerHolderArgumentType.entities()) + .then(Commands.argument("power", PowerArgumentType.power()) + .executes(context -> revokePower(context, false)) + .then(Commands.argument("source", ResourceLocationArgument.id()) + .executes(context -> revokePower(context, true)))) + .then(Commands.literal("all") + .then(Commands.argument("source", ResourceLocationArgument.id()) + .executes(PowerCommand::revokeAllPowers)))) + ) + .then(literal("list") + .then(argument("target", PowerHolderArgumentType.entity()) + .executes(context -> listPowers(context, false)) + .then(argument("subpowers", BoolArgumentType.bool()) + .executes(context -> listPowers(context, BoolArgumentType.getBool(context, "subpowers"))))) + ) + .then(literal("has") + .then(argument("targets", PowerHolderArgumentType.entities()) + .then(argument("power", PowerArgumentType.power()) + .executes(PowerCommand::hasPower))) + ) + .then(literal("sources") + .then(argument("target", PowerHolderArgumentType.entity()) + .then(argument("power", PowerArgumentType.power()) + .executes(PowerCommand::getSourcesFromPower))) + ) + .then(literal("remove") + .then(argument("targets", PowerHolderArgumentType.entities()) + .then(argument("power", PowerArgumentType.power()) + .executes(PowerCommand::removePower))) + ) + .then(literal("clear") + .executes(context -> clearAllPowers(context, true)) + .then(argument("targets", PowerHolderArgumentType.entities()) + .executes(context -> clearAllPowers(context, false))) + ) + .then(literal("dump") + .then(argument("power", PowerArgumentType.power()) + .executes(context -> dumpPowerJson(context, false)) + .then(argument("indent", IntegerArgumentType.integer(0)) + .executes(context -> dumpPowerJson(context, true)))) + ).build() + ); + } + + private static int grantPower(@NotNull CommandContext context, boolean isSourceSpecified) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + + List targets = PowerHolderArgumentType.getHolders(context, "targets"); + + PowerType power = PowerArgumentType.getPower(context, "power"); + ResourceLocation powerSource = isSourceSpecified ? context.getArgument("source", ResourceLocation.class) : POWER_SOURCE; + + for (LivingEntity target : targets) { + + if (target instanceof ServerPlayer player) { + PowerUtils.grantPower(source.getSender(), power, player.getBukkitEntity(), OriginsPaper.getLayer(powerSource), true); + } + + } + + String powerTypeName = PlainTextComponentSerializer.plainText().serialize(power.name()); + String targetName = targets.getFirst().getName().getString(); + + int targetsSize = targets.size(); + int processedTargetsSize = targets.size(); + + if (processedTargetsSize == 0) { + + if (targetsSize == 1) { + source.sendFailure(LangFile.translatable("commands.apoli.grant.fail.single", targetName, powerTypeName, powerSource.toString())); + } else { + source.sendFailure(LangFile.translatable("commands.apoli.grant.fail.multiple", targetsSize, powerTypeName, powerSource.toString())); + } + + return processedTargetsSize; + + } + + String processedTargetName = targets.getFirst().getName().getString(); + if (isSourceSpecified) { + if (processedTargetsSize == 1) { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.grant_from_source.success.single", processedTargetName, powerTypeName, powerSource.toString()), true); + } else { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.grant_from_source.success.multiple", processedTargetsSize, powerTypeName, powerSource.toString()), true); + } + } else { + if (processedTargetsSize == 1) { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.grant.success.single", processedTargetName, powerTypeName), true); + } else { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.grant.success.multiple", processedTargetsSize, powerTypeName), true); + } + } + + return processedTargetsSize; + + } + + private static int revokePower(@NotNull CommandContext context, boolean isSourceSpecified) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + + List targets = PowerHolderArgumentType.getHolders(context, "targets"); + + PowerType power = PowerArgumentType.getPower(context, "power"); + ResourceLocation powerSource = isSourceSpecified ? context.getArgument("source", ResourceLocation.class) : POWER_SOURCE; + + for (LivingEntity target : targets) { + + if (target instanceof ServerPlayer player) { + PowerUtils.removePower(source.getBukkitSender(), power, player.getBukkitEntity(), OriginsPaper.getLayer(powerSource), true); + } + + } + + String powerTypeName = PlainTextComponentSerializer.plainText().serialize(power.name()); + + int processedTargetsSize = targets.size(); + + if (processedTargetsSize == 0) { + + source.sendFailure(LangFile.translatable("commands.apoli.revoke.fail.multiple", powerTypeName, powerSource.toString())); + + return processedTargetsSize; + + } + + String processedTargetName = targets.getFirst().getName().getString(); + if (isSourceSpecified) { + if (processedTargetsSize == 1) { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.revoke_from_source.success.single", processedTargetName, powerTypeName, powerSource.toString()), true); + } else { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.revoke_from_source.success.multiple", processedTargetsSize, powerTypeName, powerSource.toString()), true); + } + } else { + if (processedTargetsSize == 1) { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.revoke.success.single", processedTargetName, powerTypeName), true); + } else { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.revoke.success.multiple", processedTargetsSize, powerTypeName), true); + } + } + + return processedTargetsSize; + + } + + private static int revokeAllPowers(@NotNull CommandContext context) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + + List targets = PowerHolderArgumentType.getHolders(context, "targets"); + List processedTargets = new LinkedList<>(); + + ResourceLocation powerSource = context.getArgument("source", ResourceLocation.class); + int revokedPowers = 0; + + for (LivingEntity target : targets) { + + int revokedPowersFromSource = 0; + OriginLayer layer = OriginsPaper.getLayer(powerSource); + for (PowerType power : PowerHolderComponent.getPowersFromSource(layer, target.getBukkitEntity())) { + PowerUtils.removePower(source.getBukkitSender(), power, (org.bukkit.entity.Player) target.getBukkitEntity(), layer, true); + revokedPowersFromSource++; + } + revokedPowers += revokedPowersFromSource; + + if (revokedPowersFromSource > 0) { + processedTargets.add(target); + } + + } + + String targetName = targets.getFirst().getName().getString(); + + int targetsSize = targets.size(); + int processedTargetsSize = processedTargets.size(); + + if (processedTargetsSize == 0) { + if (targetsSize == 1) { + source.sendFailure(LangFile.translatable("commands.apoli.revoke_all.fail.single", targetName, powerSource.toString())); + } else { + source.sendFailure(LangFile.translatable("commands.apoli.revoke_all.fail.multiple", powerSource)); + } + } else { + + String processedTargetName = processedTargets.getFirst().getName().getString(); + int finalRevokedPowers = revokedPowers; + + if (processedTargetsSize == 1) { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.revoke_all.success.single", processedTargetName, finalRevokedPowers, powerSource.toString()), true); + } else { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.revoke_all.success.multiple", processedTargetsSize, finalRevokedPowers, powerSource.toString()), true); + } + + } + + return processedTargetsSize; + + } + + private static int listPowers(@NotNull CommandContext context, boolean includeSubpowers) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + LivingEntity target = PowerHolderArgumentType.getHolder(context, "target"); + + List powersTooltip = new LinkedList<>(); + int powers = 0; + + List powerTypes = new LinkedList<>(PowerHolderComponent.getPowers(target.getBukkitEntity())); + List multiples = PowerHolderComponent.getPowers(target.getBukkitEntity(), MultiplePower.class); + if (!includeSubpowers) { + powerTypes.removeAll(Util.collapseList(multiples.stream().map(MultiplePower::getSubPowers).toList())); + } + + for (PowerType power : powerTypes) { + + List sourcesTooltip = new LinkedList<>(); + PowerHolderComponent.getSources(power, target.getBukkitEntity()).forEach(id -> sourcesTooltip.add(Component.nullToEmpty(id.toString()))); + + HoverEvent sourceHoverEvent = new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + LangFile.translatable("commands.apoli.list.sources", ComponentUtils.formatList(sourcesTooltip, Component.nullToEmpty(","))) + ); + + Component powerTooltip = Component.literal(power.getId().toString()) + .setStyle(Style.EMPTY.withHoverEvent(sourceHoverEvent)); + + powersTooltip.add(powerTooltip); + powers++; + + } + + if (powers == 0) { + source.sendFailure(LangFile.translatable("commands.apoli.list.fail", target.getName())); + } else { + int finalPowers = powers; + source.sendSuccess(() -> LangFile.translatable("commands.apoli.list.pass", target.getName(), finalPowers, ComponentUtils.formatList(powersTooltip, Component.nullToEmpty(", "))), true); + } + + return powers; + + } + + private static int hasPower(@NotNull CommandContext context) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + + List targets = PowerHolderArgumentType.getHolders(context, "targets"); + List processedTargets = new LinkedList<>(); + + PowerType power = PowerArgumentType.getPower(context, "power"); + + for (LivingEntity target : targets) { + if (PowerHolderComponent.hasPower(target.getBukkitEntity(), power)) { + processedTargets.add(target); + } + } + + int targetsSize = targets.size(); + int processedTargetsSize = processedTargets.size(); + + if (processedTargetsSize == 0) { + if (targetsSize == 1) { + source.sendFailure(LangFile.translatable("commands.execute.conditional.fail")); + } else { + source.sendFailure(LangFile.translatable("commands.execute.conditional.fail_count", targetsSize)); + } + } else { + if (processedTargetsSize == 1) { + source.sendSuccess(() -> LangFile.translatable("commands.execute.conditional.pass"), true); + } else { + source.sendSuccess(() -> LangFile.translatable("commands.execute.conditional.pass_count", processedTargetsSize), true); + } + } + + return processedTargets.size(); + + } + + private static int getSourcesFromPower(@NotNull CommandContext context) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + + LivingEntity target = PowerHolderArgumentType.getHolder(context, "target"); + PowerType power = PowerArgumentType.getPower(context, "power"); + + StringBuilder powerSources = new StringBuilder(); + int powers = 0; + + String separator = ""; + for (ResourceLocation powerSource : PowerHolderComponent.getSources(power, target.getBukkitEntity())) { + + powerSources.append(separator).append(powerSource.toString()); + powers++; + + separator = ", "; + + } + + if (powers == 0) { + source.sendFailure(LangFile.translatable("commands.apoli.sources.fail", target.getName(), power.name())); + } else { + int finalPowers = powers; + source.sendSuccess(() -> LangFile.translatable("commands.apoli.sources.pass", target.getName(), finalPowers, power.name(), powerSources.toString()), true); + } + + return powers; + + } + + private static int removePower(@NotNull CommandContext context) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + + List targets = PowerHolderArgumentType.getHolders(context, "targets"); + List processedTargets = new LinkedList<>(); + + PowerType power = PowerArgumentType.getPower(context, "power"); + for (LivingEntity target : targets) { + if (!(target instanceof ServerPlayer player)) continue; + + AtomicInteger revokedPowers = new AtomicInteger(); + PowerHolderComponent.getSources(power, target.getBukkitEntity()).forEach(location -> { + OriginLayer layer = OriginsPaper.getLayer(location); + PowerUtils.removePower(source.getBukkitSender(), power, player.getBukkitEntity(), layer, true); + + revokedPowers.getAndIncrement(); + }); + + if (revokedPowers.get() > 0) { + processedTargets.add(target); + } + + } + + String targetName = targets.getFirst().getName().getString(); + String powerTypeName = PlainTextComponentSerializer.plainText().serialize(power.name()); + + int targetsSize = targets.size(); + int processedTargetsSize = processedTargets.size(); + + if (processedTargetsSize == 0) { + if (targetsSize == 1) { + source.sendFailure(LangFile.translatable("commands.apoli.remove.fail.single", targetName, powerTypeName)); + } else { + source.sendFailure(LangFile.translatable("commands.apoli.remove.fail.multiple", powerTypeName)); + } + } else { + String processedTargetName = processedTargets.getFirst().getName().getString(); + if (processedTargetsSize == 1) { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.remove.success.single", processedTargetName, powerTypeName), true); + } else { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.remove.success.multiple", processedTargetsSize, powerTypeName), true); + } + } + + return processedTargetsSize; + + } + + private static int clearAllPowers(@NotNull CommandContext context, boolean onlyTargetSelf) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + + List targets = new LinkedList<>(); + List processedTargets = new LinkedList<>(); + + if (!onlyTargetSelf) { + targets.addAll(PowerHolderArgumentType.getHolders(context, "targets")); + } else { + + Entity self = source.getEntityOrException(); + if (!(self instanceof LivingEntity livingSelf)) { + throw PowerHolderArgumentType.HOLDER_NOT_FOUND.create(self.getName()); + } + + targets.add(livingSelf); + + } + + int clearedPowers = 0; + for (LivingEntity target : targets) { + if (!(target instanceof ServerPlayer player)) continue; + + List powers = PowerHolderComponent.getPowers(target.getBukkitEntity()); + + if (powers.isEmpty()) continue; + + for (PowerType power : powers) { + PowerUtils.removePower(source.getBukkitSender(), power, player.getBukkitEntity(), null, true); + } + + clearedPowers += powers.size(); + processedTargets.add(target); + + } + + String targetName = targets.getFirst().getName().getString(); + + int targetsSize = targets.size(); + int processedTargetsSize = processedTargets.size(); + + if (processedTargetsSize == 0) { + if (targetsSize == 1) { + source.sendFailure(LangFile.translatable("commands.apoli.clear.fail.single", targetName)); + } else { + source.sendFailure(LangFile.translatable("commands.apoli.clear.fail.multiple")); + } + } else { + + String processedTargetName = processedTargets.getFirst().getName().getString(); + int finalClearedPowers = clearedPowers; + + if (processedTargetsSize == 1) { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.clear.success.single", processedTargetName, finalClearedPowers), true); + } else { + source.sendSuccess(() -> LangFile.translatable("commands.apoli.clear.success.multiple", processedTargetsSize, finalClearedPowers), true); + } + + } + + return clearedPowers; + + } + + private static int dumpPowerJson(@NotNull CommandContext context, boolean indentSpecified) { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + PowerType power = PowerArgumentType.getPower(context, "power"); + + String indent = Strings.repeat(' ', indentSpecified ? IntegerArgumentType.getInteger(context, "indent") : 4); + source.sendSuccess(() -> { + String append = ((net.minecraft.commands.CommandSourceStack) context.getSource()).isPlayer() ? "" : "\n"; + return Component.literal(append).append(new JsonTextFormatter(indent).apply(power.sourceObject)); + }, false); + return 1; + + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/command/ResourceCommand.java b/origins/src/main/java/io/github/dueris/originspaper/command/ResourceCommand.java index af81b0630..f502ec0c8 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/command/ResourceCommand.java +++ b/origins/src/main/java/io/github/dueris/originspaper/command/ResourceCommand.java @@ -1,243 +1,205 @@ package io.github.dueris.originspaper.command; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.power.PowerType; -import io.github.dueris.originspaper.power.ResourcePower; -import io.github.dueris.originspaper.storage.PowerHolderComponent; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.commands.Commands; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import io.github.dueris.originspaper.command.argument.PowerArgumentType; +import io.github.dueris.originspaper.command.argument.PowerHolderArgumentType; +import io.github.dueris.originspaper.command.argument.PowerOperationArgumentType; +import io.github.dueris.originspaper.power.type.CooldownPower; +import io.github.dueris.originspaper.power.type.ResourcePower; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.command.brigadier.Commands; import net.minecraft.commands.arguments.EntityArgument; -import net.minecraft.commands.arguments.ResourceLocationArgument; +import net.minecraft.commands.arguments.ObjectiveArgument; +import net.minecraft.commands.arguments.ScoreHolderArgument; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.scores.Objective; +import net.minecraft.world.scores.ScoreAccess; +import net.minecraft.world.scores.ScoreHolder; +import net.minecraft.world.scores.Scoreboard; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.Collections; +import java.util.function.Supplier; + +import static io.papermc.paper.command.brigadier.Commands.argument; +import static io.papermc.paper.command.brigadier.Commands.literal; public class ResourceCommand { - public static void register(CommandDispatcher dispatcher) { - LiteralArgumentBuilder main = net.minecraft.commands.Commands.literal("resource") - .requires(source -> source.hasPermission(2)); - (main.then( - Commands.literal("has") - .then( - Commands.argument("targets", EntityArgument.player()) - .then( - Commands.argument("power", ResourceLocationArgument.id()) - .suggests( - (context, builder) -> { - OriginCommand.POWERS - .forEach( - (location, power) -> { - if (context.getInput().split(" ").length == 2 - || power.getTag().startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1]) - || power.getTag().split(":")[1] - .startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1])) { - builder.suggest(power.getTag()); - } - } - ); - return builder.buildFuture(); - } - ) - .executes(context -> { - ResourceLocation power = ResourceLocationArgument.getId(context, "power"); - ServerPlayer player = EntityArgument.getPlayer(context, "targets"); - PowerType powerType = OriginsPaper.getPower(power); - if (powerType == null) { - throw new IllegalArgumentException("Provided power argument was not found!"); - } else { - if (PowerHolderComponent.hasPower(player.getBukkitEntity(), powerType.getTag()) - && PowerHolderComponent.isOfType(powerType, ResourcePower.class)) { - context.getSource().sendSystemMessage(Component.literal("Test passed")); - } else { - context.getSource().sendFailure(Component.literal("Test failed")); - } - - return 1; - } - }) - ) + private static final DynamicCommandExceptionType ERROR_OBJECTIVE_NOT_FOUND = new DynamicCommandExceptionType( + name -> Component.translatableEscape("arguments.objective.notFound", name) + ); + + public static void register(@NotNull Commands dispatcher) { + dispatcher.register( + literal("resource").requires(cs -> ((net.minecraft.commands.CommandSourceStack) cs).hasPermission(2)) + .then(literal("has") + .then(argument("target", PowerHolderArgumentType.entity()) + .then(argument("power", PowerArgumentType.power()) + .executes((command) -> resource(command, SubCommand.HAS)))) + ) + .then(literal("get") + .then(argument("target", PowerHolderArgumentType.entity()) + .then(argument("power", PowerArgumentType.power()) + .executes((command) -> resource(command, SubCommand.GET)))) + ) + .then(literal("set") + .then(argument("target", PowerHolderArgumentType.entity()) + .then(argument("power", PowerArgumentType.power()) + .then(argument("value", IntegerArgumentType.integer()) + .executes((command) -> resource(command, SubCommand.SET))))) + ) + .then(literal("change") + .then(argument("target", PowerHolderArgumentType.entity()) + .then(argument("power", PowerArgumentType.power()) + .then(argument("value", IntegerArgumentType.integer()) + .executes((command) -> resource(command, SubCommand.CHANGE))))) ) - )) - .then( - Commands.literal("get") - .then( - Commands.argument("targets", EntityArgument.player()) - .then( - Commands.argument("power", ResourceLocationArgument.id()) - .suggests( - (context, builder) -> { - OriginCommand.POWERS - .forEach( - (location, power) -> { - if (context.getInput().split(" ").length == 3 - || power.getTag().startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1]) - || power.getTag().split(":")[1] - .startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1])) { - builder.suggest(power.getTag()); - } - } - ); - return builder.buildFuture(); - } - ) - .executes( - context -> { - ResourceLocation power = ResourceLocationArgument.getId(context, "power"); - ServerPlayer player = EntityArgument.getPlayer(context, "targets"); - PowerType powerType = OriginsPaper.getPower(power); - if (powerType == null) { - throw new IllegalArgumentException("Provided power argument was not found!"); - } else { - Component failure = Component.literal( - "Can't get value of {%} for {$}; none is set".replace("{$}", player.displayName).replace("{%}", power.toString()) - ); - if (PowerHolderComponent.hasPower(player.getBukkitEntity(), powerType.getTag()) - && PowerHolderComponent.isOfType(powerType, ResourcePower.class)) { - ResourcePower resourcePower = (ResourcePower) powerType; - ResourcePower.getDisplayedBar(player, resourcePower.getTag()) - .ifPresentOrElse( - bar -> { - Integer mappedProgress = bar.getMappedProgress(); - context.getSource() - .sendSystemMessage( - Component.literal( - "Dueris has {%} {$}".replace("{%}", mappedProgress.toString()).replace("{$}", power.toString()) - ) - ); - }, - () -> context.getSource().sendFailure(failure) - ); - } else { - context.getSource().sendFailure(failure); - } - - return 1; - } - } - ) - ) - ) - ) - .then( - Commands.literal("set") - .then( - Commands.argument("targets", EntityArgument.player()) - .then( - Commands.argument("power", ResourceLocationArgument.id()) - .suggests( - (context, builder) -> { - OriginCommand.POWERS - .forEach( - (location, power) -> { - if (context.getInput().split(" ").length == 3 - || power.getTag().startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1]) - || power.getTag().split(":")[1] - .startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1])) { - builder.suggest(power.getTag()); - } - } - ); - return builder.buildFuture(); - } - ) - .then( - Commands.argument("value", IntegerArgumentType.integer()) - .executes( - context -> { - ResourceLocation power = ResourceLocationArgument.getId(context, "power"); - ServerPlayer player = EntityArgument.getPlayer(context, "targets"); - PowerType powerType = OriginsPaper.getPower(power); - int setTo = IntegerArgumentType.getInteger(context, "value"); - Component failure = Component.literal("No relevant score holders could be found"); - if (PowerHolderComponent.hasPower(player.getBukkitEntity(), powerType.getTag()) - && PowerHolderComponent.isOfType(powerType, ResourcePower.class)) { - ResourcePower resourcePower = (ResourcePower) powerType; - ResourcePower.getDisplayedBar(player, resourcePower.getTag()) - .ifPresentOrElse( - bar -> { - bar.change(setTo, "set"); - context.getSource() - .sendSystemMessage( - Component.literal( - "Set {%} for {&} to ".replace("{%}", power.toString()).replace("{&}", player.displayName) - + setTo - ) - ); - }, - () -> context.getSource().sendFailure(failure) - ); - } else { - context.getSource().sendFailure(failure); - } - - return 1; - } - ) - ) - ) - ) - ) - .then( - net.minecraft.commands.Commands.literal("change") - .then( - net.minecraft.commands.Commands.argument("targets", EntityArgument.player()) - .then( - net.minecraft.commands.Commands.argument("power", ResourceLocationArgument.id()) - .suggests( - (context, builder) -> { - OriginCommand.POWERS - .forEach( - (location, power) -> { - if (context.getInput().split(" ").length == 3 - || power.getTag().startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1]) - || power.getTag().split(":")[1] - .startsWith(context.getInput().split(" ")[context.getInput().split(" ").length - 1])) { - builder.suggest(power.getTag()); - } - } - ); - return builder.buildFuture(); - } - ) - .then( - net.minecraft.commands.Commands.argument("value", IntegerArgumentType.integer()) - .executes( - context -> { - ResourceLocation power = ResourceLocationArgument.getId(context, "power"); - ServerPlayer player = EntityArgument.getPlayer(context, "targets"); - PowerType powerType = OriginsPaper.getPower(power); - int setTo = IntegerArgumentType.getInteger(context, "value"); - Component failure = Component.literal("No relevant score holders could be found"); - if (PowerHolderComponent.hasPower(player.getBukkitEntity(), powerType.getTag()) - && PowerHolderComponent.isOfType(powerType, ResourcePower.class)) { - ResourcePower resourcePower = (ResourcePower) powerType; - ResourcePower.getDisplayedBar(player, resourcePower.getTag()) - .ifPresentOrElse( - bar -> { - bar.change(setTo, "add"); - context.getSource() - .sendSystemMessage( - Component.literal( - "Set {%} for {&} to ".replace("{%}", power.toString()).replace("{&}", player.displayName) + setTo - ) - ); - }, - () -> context.getSource().sendFailure(failure) - ); - } else { - context.getSource().sendFailure(failure); - } - - return 1; - } - ) - ) - ) - ) - ); - dispatcher.register(main); + .then(literal("operation") + .then(argument("target", PowerHolderArgumentType.entity()) + .then(argument("power", PowerArgumentType.power()) + .then(argument("operation", PowerOperationArgumentType.operation()) + .then(argument("entity", ScoreHolderArgument.scoreHolder()) + .then(argument("objective", ObjectiveArgument.objective()) + .executes((command) -> resource(command, SubCommand.OPERATION))))))) + ).build() + ); + } + + private static int resource(@NotNull CommandContext context, @NotNull SubCommand subCommand) throws CommandSyntaxException { + + net.minecraft.commands.CommandSourceStack source = (net.minecraft.commands.CommandSourceStack) context.getSource(); + LivingEntity target = PowerHolderArgumentType.getHolder(context, "target"); + + PowerType power = PowerArgumentType.getPower(context, "power"); + + return switch (subCommand) { + case HAS -> { + + if (isPowerInvalid(power)) { + source.sendFailure(Component.translatableEscape("commands.execute.conditional.fail")); + yield 0; + } + + source.sendSuccess(() -> Component.translatableEscape("commands.execute.conditional.pass"), true); + yield 1; + + } + case GET -> { + + if (isPowerInvalid(power)) { + source.sendFailure(Component.translatableEscape("commands.scoreboard.players.get.null", power.getId(), target.getName().getString())); + yield 0; + } + + int value = getValue(power, target); + source.sendSuccess(() -> Component.translatableEscape("commands.scoreboard.players.get.success", target.getName().getString(), value, power.getId()), true); + + yield value; + + } + case SET -> { + + if (isPowerInvalid(power)) { + source.sendFailure(Component.translatableEscape("argument.scoreHolder.empty")); + yield 0; + } + + int value = IntegerArgumentType.getInteger(context, "value"); + setValue(power, value, target); + + source.sendSuccess(() -> Component.translatableEscape("commands.scoreboard.players.set.success.single", power.getId(), target.getName().getString(), value), true); + + yield value; + + } + case CHANGE -> { + + if (isPowerInvalid(power)) { + source.sendFailure(Component.translatableEscape("argument.scoreHolder.empty")); + yield 0; + } + + int value = IntegerArgumentType.getInteger(context, "value"); + int total = getValue(power, target) + value; + + setValue(power, total, target); + + source.sendSuccess(() -> Component.translatableEscape("commands.scoreboard.players.add.success.single", value, power.getId(), target.getName().getString(), total), true); + yield total; + + } + case OPERATION -> { + + if (isPowerInvalid(power)) { + source.sendFailure(Component.translatableEscape("argument.scoreHolder.empty")); + yield 0; + } + + ScoreHolder scoreHolder = getNames(context, "entity", Collections::emptyList).iterator().next(); + Objective scoreboardObjective = getObjective(context, "objective"); + + ScoreAccess scoreAccess = source.getServer().getScoreboard().getOrCreatePlayerScore(scoreHolder, scoreboardObjective); + context.getArgument("operation", PowerOperationArgumentType.Operation.class).apply(power, scoreAccess, target); + + int value = getValue(power, target); + source.sendSuccess(() -> Component.translatableEscape("commands.scoreboard.players.operation.success.single", power.getId(), target.getName().getString(), value), true); + + yield value; + + } + }; + + } + + private static int getValue(PowerType powerType, ScoreHolder entity) { + if (powerType instanceof ResourcePower vip) { + return vip.getValue(entity); + } else if (powerType instanceof CooldownPower cp) { + return cp.getRemainingTicks(entity); + } else { + return 0; + } + } + + private static void setValue(PowerType powerType, int newValue, ScoreHolder entity) { + if (powerType instanceof ResourcePower vip) { + vip.setValue(entity, newValue); + } else if (powerType instanceof CooldownPower cp) { + cp.setCooldown(entity, newValue); + } + } + + private static boolean isPowerInvalid(PowerType powerType) { + return !(powerType instanceof ResourcePower) && !(powerType instanceof CooldownPower); + } + + public static @NotNull Collection getNames(@NotNull CommandContext context, String name, Supplier> players) throws CommandSyntaxException { + Collection collection = context.getArgument(name, ScoreHolderArgument.Result.class).getNames((net.minecraft.commands.CommandSourceStack) context.getSource(), players); + if (collection.isEmpty()) { + throw EntityArgument.NO_ENTITIES_FOUND.create(); + } else { + return collection; + } + } + + public static @NotNull Objective getObjective(@NotNull CommandContext context, String name) throws CommandSyntaxException { + String string = context.getArgument(name, String.class); + Scoreboard scoreboard = ((net.minecraft.commands.CommandSourceStack) context.getSource()).getServer().getScoreboard(); + Objective objective = scoreboard.getObjective(string); + if (objective == null) { + throw ERROR_OBJECTIVE_NOT_FOUND.create(string); + } else { + return objective; + } + } + + public enum SubCommand { + HAS, GET, SET, CHANGE, OPERATION } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/command/argument/LayerArgumentType.java b/origins/src/main/java/io/github/dueris/originspaper/command/argument/LayerArgumentType.java new file mode 100644 index 000000000..8470d4612 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/command/argument/LayerArgumentType.java @@ -0,0 +1,59 @@ +package io.github.dueris.originspaper.command.argument; + +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.arguments.ArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.origin.OriginLayer; +import io.github.dueris.originspaper.registry.Registries; +import io.github.dueris.originspaper.util.LangFile; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.command.brigadier.argument.ArgumentTypes; +import io.papermc.paper.command.brigadier.argument.CustomArgumentType; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.resources.ResourceLocation; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.CompletableFuture; + +public class LayerArgumentType implements CustomArgumentType { + + public static final DynamicCommandExceptionType LAYER_NOT_FOUND = new DynamicCommandExceptionType( + o -> LangFile.translatable("commands.origin.layer_not_found", o) + ); + + public static @NotNull LayerArgumentType layer() { + return new LayerArgumentType(); + } + + public static OriginLayer getLayer(CommandContext context, String argumentName) throws CommandSyntaxException { + + try { + return context.getArgument(argumentName, OriginLayer.class); + } catch (IllegalArgumentException e) { + throw LAYER_NOT_FOUND.create(null); + } + + } + + @Override + public OriginLayer parse(StringReader stringReader) throws CommandSyntaxException { + return OriginsPaper.getLayer(ResourceLocation.read(stringReader)); + } + + @Override + public @NotNull ArgumentType getNativeType() { + return ArgumentTypes.namespacedKey(); + } + + @Override + public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { + return SharedSuggestionProvider.suggestResource(OriginsPaper.getRegistry().retrieve(Registries.LAYER).stream().filter(OriginLayer::isEnabled).map(OriginLayer::getId), builder); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/command/argument/OriginArgumentType.java b/origins/src/main/java/io/github/dueris/originspaper/command/argument/OriginArgumentType.java new file mode 100644 index 000000000..59574be55 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/command/argument/OriginArgumentType.java @@ -0,0 +1,82 @@ +package io.github.dueris.originspaper.command.argument; + +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.arguments.ArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.origin.Origin; +import io.github.dueris.originspaper.origin.OriginLayer; +import io.github.dueris.originspaper.util.LangFile; +import io.github.dueris.originspaper.util.Util; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.command.brigadier.argument.ArgumentTypes; +import io.papermc.paper.command.brigadier.argument.CustomArgumentType; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.resources.ResourceLocation; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class OriginArgumentType implements CustomArgumentType { + + public static final DynamicCommandExceptionType ORIGIN_NOT_FOUND = new DynamicCommandExceptionType( + o -> LangFile.translatable("commands.origin.origin_not_found", o) + ); + + public static @NotNull OriginArgumentType origin() { + return new OriginArgumentType(); + } + + public static Origin getOrigin(@NotNull CommandContext context, String argumentName) throws CommandSyntaxException { + try { + return context.getArgument(argumentName, Origin.class); + } catch (IllegalArgumentException e) { + throw ORIGIN_NOT_FOUND.create(null); + } + + } + + public static @NotNull ResourceLocation parseNamespacedKey(@NotNull StringReader reader) throws CommandSyntaxException { + return ResourceLocation.read(reader.getString().split(" ")[3].split(" ")[0]).getOrThrow(); + } + + @Override + public @NotNull Origin parse(@NotNull StringReader reader) throws CommandSyntaxException { + return OriginsPaper.getOrigin(ResourceLocation.read(reader)); + } + + @Override + public @NotNull ArgumentType getNativeType() { + return ArgumentTypes.namespacedKey(); + } + + @Override + public CompletableFuture listSuggestions(@NotNull CommandContext context, @NotNull SuggestionsBuilder builder) { + + List availableOrigins = new LinkedList<>(); + availableOrigins.add(Origin.EMPTY.getId()); + + try { + OriginLayer originLayer = OriginsPaper.getLayer(parseNamespacedKey(new StringReader(builder.getInput()))); + if (originLayer != null) { + availableOrigins.addAll(Util.collapseList(originLayer.getOrigins().stream().map(OriginLayer.ConditionedOrigin::origins).toList())); + } + + } catch (IllegalArgumentException ignored) { + ignored.printStackTrace(); + } catch (CommandSyntaxException e) { + throw new RuntimeException(e); + } + + return SharedSuggestionProvider.suggestResource(availableOrigins.stream(), builder); + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/command/argument/PowerArgumentType.java b/origins/src/main/java/io/github/dueris/originspaper/command/argument/PowerArgumentType.java new file mode 100644 index 000000000..f2935e3ce --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/command/argument/PowerArgumentType.java @@ -0,0 +1,53 @@ +package io.github.dueris.originspaper.command.argument; + +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.arguments.ArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.registry.Registries; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.command.brigadier.argument.ArgumentTypes; +import io.papermc.paper.command.brigadier.argument.CustomArgumentType; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.CompletableFuture; + +public class PowerArgumentType implements CustomArgumentType { + public static final DynamicCommandExceptionType POWER_NOT_FOUND = new DynamicCommandExceptionType((o) -> { + return Component.literal("Power not found"); + }); + + public static @NotNull PowerArgumentType power() { + return new PowerArgumentType(); + } + + public static PowerType getPower(@NotNull CommandContext context, String argumentName) { + return context.getArgument(argumentName, PowerType.class); + } + + public PowerType parse(StringReader reader) throws CommandSyntaxException { + ResourceLocation id = ResourceLocation.readNonEmpty(reader); + return OriginsPaper.getRegistry().retrieve(Registries.POWER).getOptional(id).orElseThrow(() -> { + return POWER_NOT_FOUND.create(id); + }); + } + + @Override + public @NotNull ArgumentType getNativeType() { + return ArgumentTypes.namespacedKey(); + } + + @Override + public @NotNull CompletableFuture listSuggestions(@NotNull CommandContext context, @NotNull SuggestionsBuilder builder) { + return SharedSuggestionProvider.suggestResource(OriginsPaper.getRegistry().retrieve(Registries.POWER).keySet().stream(), builder); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/command/argument/PowerHolderArgumentType.java b/origins/src/main/java/io/github/dueris/originspaper/command/argument/PowerHolderArgumentType.java new file mode 100644 index 000000000..3a0775886 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/command/argument/PowerHolderArgumentType.java @@ -0,0 +1,79 @@ +package io.github.dueris.originspaper.command.argument; + +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.commands.arguments.selector.EntitySelector; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +public class PowerHolderArgumentType extends EntityArgument { + + public static final SimpleCommandExceptionType HOLDERS_NOT_FOUND = new SimpleCommandExceptionType( + Component.literal("No living entities were found") + ); + public static final DynamicCommandExceptionType HOLDER_NOT_FOUND = new DynamicCommandExceptionType( + o -> Component.literal("Entity is not a living entity") + ); + + protected PowerHolderArgumentType(boolean singleTarget, boolean playersOnly) { + super(singleTarget, playersOnly); + } + + public static LivingEntity getHolder(CommandContext context, String name) throws CommandSyntaxException { + + Entity entity = context.getArgument(name, EntitySelector.class).findSingleEntity((net.minecraft.commands.CommandSourceStack) context.getSource()); + if (!(entity instanceof LivingEntity livingEntity)) { + throw HOLDER_NOT_FOUND.create(entity.getName()); + } + + return livingEntity; + + } + + public static @NotNull List getHolders(CommandContext context, String name) throws CommandSyntaxException { + + List entities = new LinkedList<>(entities(context, name)); + List holders = entities.stream() + .filter(e -> e instanceof LivingEntity) + .map(e -> (LivingEntity) e) + .toList(); + + if (holders.isEmpty()) { + + if (entities.size() == 1) { + throw HOLDER_NOT_FOUND.create(entities.getFirst().getName()); + } else { + throw HOLDERS_NOT_FOUND.create(); + } + + } + + return holders; + + } + + public static @NotNull Collection entities(CommandContext context, String name) throws CommandSyntaxException { + Collection collection = optionalEntities(context, name); + + if (collection.isEmpty()) { + throw EntityArgument.NO_ENTITIES_FOUND.create(); + } else { + return collection; + } + } + + public static @NotNull Collection optionalEntities(@NotNull CommandContext context, String name) throws CommandSyntaxException { + return context.getArgument(name, EntitySelector.class).findEntities((net.minecraft.commands.CommandSourceStack) context.getSource()); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/command/argument/PowerOperationArgumentType.java b/origins/src/main/java/io/github/dueris/originspaper/command/argument/PowerOperationArgumentType.java new file mode 100644 index 000000000..e32e3d9b6 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/command/argument/PowerOperationArgumentType.java @@ -0,0 +1,149 @@ +package io.github.dueris.originspaper.command.argument; + +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.arguments.ArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import io.github.dueris.originspaper.power.type.CooldownPower; +import io.github.dueris.originspaper.power.type.ResourcePower; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.papermc.paper.command.brigadier.argument.CustomArgumentType; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.scores.ScoreAccess; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.CompletableFuture; + +public class PowerOperationArgumentType implements CustomArgumentType { + + public static final SimpleCommandExceptionType INVALID_OPERATION = new SimpleCommandExceptionType(Component.translatable("arguments.operation.invalid")); + public static final SimpleCommandExceptionType DIVISION_ZERO_EXCEPTION = new SimpleCommandExceptionType(Component.translatable("arguments.operation.div0")); + + public static @NotNull PowerOperationArgumentType operation() { + return new PowerOperationArgumentType(); + } + + @Override + public @NotNull CompletableFuture listSuggestions(@NotNull CommandContext context, @NotNull SuggestionsBuilder builder) { + return SharedSuggestionProvider.suggest(new String[]{"=", "+=", "-=", "*=", "/=", "%=", "<", ">", "><"}, builder); + } + + @Override + public PowerOperationArgumentType.@NotNull Operation parse(@NotNull StringReader stringReader) throws CommandSyntaxException { + if (!stringReader.canRead()) throw INVALID_OPERATION.create(); + + int i = stringReader.getCursor(); + while (stringReader.canRead() && stringReader.peek() != ' ') stringReader.skip(); + + String stringOperator = stringReader.getString().substring(i, stringReader.getCursor()); + return switch (stringOperator) { + case "=" -> (power, score, entity) -> { + if (power instanceof ResourcePower) { + ((ResourcePower) power).setValue(entity, score.get()); + } else if (power instanceof CooldownPower) { + ((CooldownPower) power).setCooldown(entity, score.get()); + } + }; + case "+=" -> (power, score, entity) -> { + if (power instanceof ResourcePower) { + ((ResourcePower) power).setValue(entity, ((ResourcePower) power).getValue(entity) + score.get()); + } else if (power instanceof CooldownPower cooldownPower) { + cooldownPower.setCooldown(entity, cooldownPower.getRemainingTicks(entity) + score.get()); + } + }; + case "-=" -> (power, score, entity) -> { + if (power instanceof ResourcePower) { + ((ResourcePower) power).setValue(entity, ((ResourcePower) power).getValue(entity) - score.get()); + } else if (power instanceof CooldownPower cooldownPower) { + cooldownPower.setCooldown(entity, cooldownPower.getRemainingTicks(entity) - score.get()); + } + }; + case "*=" -> (power, score, entity) -> { + if (power instanceof ResourcePower) { + ((ResourcePower) power).setValue(entity, ((ResourcePower) power).getValue(entity) * score.get()); + } else if (power instanceof CooldownPower) { + ((CooldownPower) power).setCooldown(entity, ((CooldownPower) power).getRemainingTicks(entity) * score.get()); + } + }; + case "/=" -> (power, score, entity) -> { + if (power instanceof ResourcePower resource) { + int r = resource.getValue(entity); + int s = score.get(); + if (s == 0) { + throw DIVISION_ZERO_EXCEPTION.create(); + } else { + resource.setValue(entity, Math.floorDiv(r, s)); + } + } else if (power instanceof CooldownPower cooldownPower) { + int c = cooldownPower.getRemainingTicks(entity); + int s = score.get(); + if (s == 0) { + throw DIVISION_ZERO_EXCEPTION.create(); + } else { + cooldownPower.setCooldown(entity, Math.floorDiv(c, s)); + } + } + }; + case "%=" -> (power, score, entity) -> { + if (power instanceof ResourcePower resource) { + int r = resource.getValue(entity); + int s = score.get(); + if (s == 0) { + throw DIVISION_ZERO_EXCEPTION.create(); + } else { + resource.setValue(entity, Math.floorMod(r, s)); + } + } else if (power instanceof CooldownPower cooldownPower) { + int c = cooldownPower.getRemainingTicks(entity); + int s = score.get(); + if (s == 0) { + throw DIVISION_ZERO_EXCEPTION.create(); + } else { + cooldownPower.setCooldown(entity, Math.floorMod(c, s)); + } + } + }; + case "<" -> (power, score, entity) -> { + if (power instanceof ResourcePower resource) { + resource.setValue(entity, Math.min(resource.getValue(entity), score.get())); + } else if (power instanceof CooldownPower cooldownPower) { + cooldownPower.setCooldown(entity, Math.min(cooldownPower.getRemainingTicks(entity), score.get())); + } + }; + case ">" -> (power, score, entity) -> { + if (power instanceof ResourcePower resource) { + resource.setValue(entity, Math.max(resource.getValue(entity), score.get())); + } else if (power instanceof CooldownPower cooldownPower) { + cooldownPower.setCooldown(entity, Math.max(cooldownPower.getRemainingTicks(entity), score.get())); + } + }; + case "><" -> (power, score, entity) -> { + if (power instanceof ResourcePower resource) { + int v = score.get(); + score.set(resource.getValue(entity)); + resource.setValue(entity, v); + } else if (power instanceof CooldownPower cooldownPower) { + int v = score.get(); + score.set(cooldownPower.getRemainingTicks(entity)); + cooldownPower.setCooldown(entity, v); + } + }; + default -> throw INVALID_OPERATION.create(); + }; + } + + @Override + public @NotNull ArgumentType getNativeType() { + return StringArgumentType.string(); + } + + public interface Operation { + void apply(PowerType powerType, ScoreAccess score, Entity entity) throws CommandSyntaxException; + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/ConditionTypes.java b/origins/src/main/java/io/github/dueris/originspaper/condition/ConditionTypes.java deleted file mode 100644 index 0d168d9b6..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/ConditionTypes.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.github.dueris.originspaper.condition; - -import io.github.classgraph.ClassGraph; -import io.github.classgraph.ScanResult; -import io.github.dueris.calio.util.ReflectionUtils; -import io.github.dueris.originspaper.condition.types.*; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.InvocationTargetException; -import java.util.function.Consumer; - -public class ConditionTypes { - - public static void registerAll() { - BiEntityConditions.registerAll(); - BiomeConditions.registerAll(); - BlockConditions.registerAll(); - DamageConditions.registerAll(); - EntityConditions.registerAll(); - FluidConditions.registerAll(); - ItemConditions.registerAll(); - } - - public static void registerPackage(@NotNull Consumer> factoryConsumer, String directory) { - try { - ScanResult result = new ClassGraph().whitelistPackages(directory).enableClassInfo().scan(); - - try { - result.getAllClasses().loadClasses() - .stream() - .filter(clz -> !clz.isAnnotation() && !clz.isInterface() && !clz.isEnum()) - .forEach( - clz -> { - try { - ConditionTypeFactory factory = ReflectionUtils.invokeStaticMethod(clz, "getFactory"); - factoryConsumer.accept(factory); - } catch (InvocationTargetException | IllegalAccessException | - NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - ); - } catch (Throwable var5) { - if (result != null) { - try { - result.close(); - } catch (Throwable var4) { - var5.addSuppressed(var4); - } - } - - throw var5; - } - - result.close(); - } catch (Exception var6) { - System.out.println("This would've been a zip error :P. Please tell us on discord if you see this ^-^"); - var6.printStackTrace(); - } - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/factory/BiEntityConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/BiEntityConditions.java new file mode 100644 index 000000000..b54cc8857 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/BiEntityConditions.java @@ -0,0 +1,51 @@ +package io.github.dueris.originspaper.condition.factory; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.type.bientity.*; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; +import java.util.function.BiPredicate; + +public class BiEntityConditions { + + public BiEntityConditions() { + } + + public static void register() { + MetaConditions.register(ApoliDataTypes.BIENTITY_CONDITION, BiEntityConditions::register); + register(InvertConditionType.getFactory()); + register(ActorConditionType.getFactory()); + register(TargetConditionType.getFactory()); + register(EitherConditionType.getFactory()); + register(BothConditionType.getFactory()); + register(UndirectedConditionType.getFactory()); + register(DistanceConditionType.getFactory()); + register(CanSeeConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("owner"), OwnerConditionType::condition)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("riding"), RidingConditionType::condition)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("riding_root"), RidingRootConditionType::condition)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("riding_recursive"), RidingRecursiveConditionType::condition)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("attack_target"), AttackTargetConditionType::condition)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("attacker"), AttackerConditionType::condition)); + register(RelativeRotationConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("equal"), Objects::equals)); + register(InEntitySetConditionType.getFactory()); + } + + public static @NotNull ConditionTypeFactory> createSimpleFactory(ResourceLocation id, BiPredicate condition) { + return new ConditionTypeFactory<>(id, new SerializableData(), (data, actorAndTarget) -> { + return condition.test(actorAndTarget.getA(), actorAndTarget.getB()); + }); + } + + public static ConditionTypeFactory> register(ConditionTypeFactory> conditionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.BIENTITY_CONDITION).register(conditionFactory, conditionFactory.getSerializerId()); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/factory/BiomeConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/BiomeConditions.java new file mode 100644 index 000000000..1bfd606f4 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/BiomeConditions.java @@ -0,0 +1,40 @@ +package io.github.dueris.originspaper.condition.factory; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.type.biome.InTagConditionType; +import io.github.dueris.originspaper.condition.type.biome.PrecipitationConditionType; +import io.github.dueris.originspaper.condition.type.biome.TemperatureConditionType; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Tuple; +import net.minecraft.world.level.biome.Biome; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class BiomeConditions { + + public static void register() { + MetaConditions.register(ApoliDataTypes.BIOME_CONDITION, BiomeConditions::register); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("high_humidity"), (biomeEntry) -> { + return biomeEntry.value().climateSettings.downfall() > 0.85F; + })); + register(TemperatureConditionType.getFactory()); + register(PrecipitationConditionType.getFactory()); + register(InTagConditionType.getFactory()); + } + + public static @NotNull ConditionTypeFactory>> createSimpleFactory(ResourceLocation id, Predicate> condition) { + return new ConditionTypeFactory<>(id, new SerializableData(), (data, posAndBiome) -> { + return condition.test(posAndBiome.getB()); + }); + } + + public static ConditionTypeFactory>> register(ConditionTypeFactory>> conditionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.BIOME_CONDITION).register(conditionFactory, conditionFactory.getSerializerId()); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/factory/BlockConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/BlockConditions.java new file mode 100644 index 000000000..f5ee45685 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/BlockConditions.java @@ -0,0 +1,61 @@ +package io.github.dueris.originspaper.condition.factory; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.type.block.*; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.LiquidBlockContainer; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class BlockConditions { + + public static void register() { + MetaConditions.register(ApoliDataTypes.BLOCK_CONDITION, BlockConditions::register); + register(OffsetConditionType.getFactory()); + register(HeightConditionType.getFactory()); + DistanceFromCoordinatesConditionRegistry.registerBlockCondition(BlockConditions::register); + register(BlockConditionType.getFactory()); + register(InTagConditionType.getFactory()); + register(AdjacentConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("replaceable"), (cachedBlock) -> { + return cachedBlock.getState().canBeReplaced(); + })); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("attachable"), AttachableConditionType::condition)); + register(FluidConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("movement_blocking"), MovementBlockingConditionType::condition)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("light_blocking"), (cachedBlock) -> { + return cachedBlock.getState().canOcclude(); + })); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("water_loggable"), (cachedBlock) -> { + return cachedBlock.getState().getBlock() instanceof LiquidBlockContainer; + })); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("exposed_to_sky"), (cachedBlock) -> { + return cachedBlock.getLevel().canSeeSky(cachedBlock.getPos()); + })); + register(LightLevelConditionType.getFactory()); + register(BlockStateConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("block_entity"), (cachedBlock) -> { + return cachedBlock.getEntity() != null; + })); + register(NbtConditionType.getFactory()); + register(SlipperinessConditionType.getFactory()); + register(BlastResistanceConditionType.getFactory()); + register(HardnessConditionType.getFactory()); + register(CommandConditionType.getFactory()); + } + + public static @NotNull ConditionTypeFactory createSimpleFactory(ResourceLocation id, Predicate condition) { + return new ConditionTypeFactory<>(id, new SerializableData(), (data, cachedBlock) -> { + return condition.test(cachedBlock); + }); + } + + public static @NotNull ConditionTypeFactory register(ConditionTypeFactory conditionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.BLOCK_CONDITION).register(conditionFactory, conditionFactory.getSerializerId()); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/ConditionTypeFactory.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/ConditionTypeFactory.java similarity index 85% rename from origins/src/main/java/io/github/dueris/originspaper/condition/ConditionTypeFactory.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/factory/ConditionTypeFactory.java index 3515a8745..110816c9f 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/ConditionTypeFactory.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/ConditionTypeFactory.java @@ -1,13 +1,13 @@ -package io.github.dueris.originspaper.condition; +package io.github.dueris.originspaper.condition.factory; import com.google.gson.JsonObject; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; import io.github.dueris.originspaper.Factory; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; -import java.util.Optional; import java.util.function.BiPredicate; import java.util.function.Predicate; @@ -49,7 +49,7 @@ public ConditionTypeFactory copy() { } public ConditionTypeFactory decompile(JsonObject object) { - this.deserializedFactory = SerializableData.Instance.decompileJsonObject(object, data, "Condition Factory", location.toString(), Optional.of(this.getClass())); + this.deserializedFactory = SerializableDataBuilder.compound(data, object, this.getClass()); if (data.postProcessor != null) { data.postProcessor.accept(deserializedFactory); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/factory/DamageConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/DamageConditions.java new file mode 100644 index 000000000..55b4baecb --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/DamageConditions.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.factory; + +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.type.damage.*; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.tags.DamageTypeTags; +import net.minecraft.util.Tuple; +import net.minecraft.world.damagesource.DamageSource; + +public class DamageConditions { + public static final ConditionTypeFactory> AMOUNT = register(AmountConditionType.getFactory()); + + public static void register() { + MetaConditions.register(ApoliDataTypes.DAMAGE_CONDITION, DamageConditions::register); + register(NameConditionType.getFactory()); + register(ProjectileConditionType.getFactory()); + register(AttackerConditionType.getFactory()); + register(InTagConditionType.createFactory(OriginsPaper.apoliIdentifier("fire"), DamageTypeTags.IS_FIRE)); + register(InTagConditionType.createFactory(OriginsPaper.apoliIdentifier("bypasses_armor"), DamageTypeTags.BYPASSES_ARMOR)); + register(InTagConditionType.createFactory(OriginsPaper.apoliIdentifier("explosive"), DamageTypeTags.IS_EXPLOSION)); + register(InTagConditionType.createFactory(OriginsPaper.apoliIdentifier("from_falling"), DamageTypeTags.IS_FALL)); + register(InTagConditionType.createFactory(OriginsPaper.apoliIdentifier("unblockable"), DamageTypeTags.BYPASSES_SHIELD)); + register(InTagConditionType.createFactory(OriginsPaper.apoliIdentifier("out_of_world"), DamageTypeTags.BYPASSES_INVULNERABILITY)); + register(InTagConditionType.getFactory()); + register(TypeConditionType.getFactory()); + } + + public static ConditionTypeFactory> register(ConditionTypeFactory> conditionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.DAMAGE_CONDITION).register(conditionFactory, conditionFactory.getSerializerId()); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/factory/DistanceFromCoordinatesConditionRegistry.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/DistanceFromCoordinatesConditionRegistry.java new file mode 100644 index 000000000..2de9d29a3 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/DistanceFromCoordinatesConditionRegistry.java @@ -0,0 +1,170 @@ +package io.github.dueris.originspaper.condition.factory; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import io.github.dueris.originspaper.data.types.Shape; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import net.minecraft.world.phys.Vec3; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.LinkedList; +import java.util.function.Consumer; + +public class DistanceFromCoordinatesConditionRegistry { + private static final LinkedList previousWarnings = new LinkedList<>(); + + public DistanceFromCoordinatesConditionRegistry() { + } + + private static void warnOnce(String warning, Object key) { + if (!previousWarnings.contains(key)) { + previousWarnings.add(key); + OriginsPaper.LOGGER.warn(warning); + } + + } + + private static void warnOnce(String warning) { + warnOnce(warning, warning); + } + + private static T warnCouldNotGetObject(String object, String from, T assumption) { + warnOnce("Could not retrieve " + object + " from " + from + " for distance_from_spawn condition, assuming " + assumption + " for condition."); + return assumption; + } + + private static String[] getAliases() { + return new String[]{"distance_from_spawn", "distance_from_coordinates"}; + } + + private static SerializableData getSerializableData(String alias) { + return new SerializableData() + .add("reference", SerializableDataTypes.STRING, alias.equals("distance_from_coordinates") ? "world_origin" : "world_spawn") + .add("offset", SerializableDataTypes.VECTOR, new Vec3(0.0, 0.0, 0.0)) + .add("coordinates", SerializableDataTypes.VECTOR, new Vec3(0.0, 0.0, 0.0)) + .add("ignore_x", SerializableDataTypes.BOOLEAN, false) + .add("ignore_y", SerializableDataTypes.BOOLEAN, false) + .add("ignore_z", SerializableDataTypes.BOOLEAN, false) + .add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE) + .add("scale_reference_to_dimension", SerializableDataTypes.BOOLEAN, true) + .add("scale_distance_to_dimension", SerializableDataTypes.BOOLEAN, false) + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.DOUBLE) + .add("result_on_wrong_dimension", SerializableDataTypes.BOOLEAN, null) + .add("round_to_digit", SerializableDataTypes.INT, null); + } + + private static boolean compareOutOfBounds(Comparison comparison) { + return comparison == Comparison.NOT_EQUAL || comparison == Comparison.GREATER_THAN || comparison == Comparison.GREATER_THAN_OR_EQUAL; + } + + private static boolean testCondition(SerializableData.Instance data, BlockInWorld block, Entity entity) { + boolean scaleReferenceToDimension = data.getBoolean("scale_reference_to_dimension"); + boolean setResultOnWrongDimension = data.isPresent("result_on_wrong_dimension"); + boolean resultOnWrongDimension = setResultOnWrongDimension && data.getBoolean("result_on_wrong_dimension"); + double x = 0.0; + double y = 0.0; + double z = 0.0; + Vec3 pos; + Level world; + if (block != null) { + BlockPos blockPos = block.getPos(); + pos = new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + LevelReader worldView = block.getLevel(); + if (!(worldView instanceof Level)) { + return warnCouldNotGetObject("world", "block", compareOutOfBounds(data.get("comparison"))); + } + + world = (Level) worldView; + } else { + pos = entity.position(); + world = entity.getCommandSenderWorld(); + } + + double currentDimensionCoordinateScale = world.dimensionType().coordinateScale(); + switch (data.getString("reference")) { + case "player_spawn": + case "player_natural_spawn": + if (entity instanceof Player) { + warnOnce("Used reference '" + data.getString("reference") + "' which is not implemented yet, defaulting to world spawn."); + } + + if (entity == null) { + warnOnce("Used entity-condition-only reference point in block condition, defaulting to world spawn."); + } + case "world_spawn": + if (setResultOnWrongDimension && world.dimension() != Level.OVERWORLD) { + return resultOnWrongDimension; + } + + BlockPos spawnPos = world.getSharedSpawnPos(); + + x = spawnPos.getX(); + y = spawnPos.getY(); + z = spawnPos.getZ(); + case "world_origin": + } + + Vec3 coords = data.get("coordinates"); + Vec3 offset = data.get("offset"); + x += coords.x + offset.x; + y += coords.y + offset.y; + z += coords.z + offset.z; + if (scaleReferenceToDimension && (x != 0.0 || z != 0.0)) { + if (currentDimensionCoordinateScale == 0.0) { + return compareOutOfBounds(data.get("comparison")); + } + + x /= currentDimensionCoordinateScale; + z /= currentDimensionCoordinateScale; + } + + double xDistance = data.getBoolean("ignore_x") ? 0.0 : Math.abs(pos.x() - x); + double yDistance = data.getBoolean("ignore_y") ? 0.0 : Math.abs(pos.y() - y); + double zDistance = data.getBoolean("ignore_z") ? 0.0 : Math.abs(pos.z() - z); + if (data.getBoolean("scale_distance_to_dimension")) { + xDistance *= currentDimensionCoordinateScale; + zDistance *= currentDimensionCoordinateScale; + } + + double distance = Shape.getDistance(data.get("shape"), xDistance, yDistance, zDistance); + if (data.isPresent("round_to_digit")) { + distance = (new BigDecimal(distance)).setScale(data.getInt("round_to_digit"), RoundingMode.HALF_UP).doubleValue(); + } + + return ((Comparison) data.get("comparison")).compare(distance, data.getDouble("compare_to")); + } + + public static void registerBlockCondition(Consumer> registryFunction) { + String[] var1 = getAliases(); + int var2 = var1.length; + + for (String alias : var1) { + registryFunction.accept(new ConditionTypeFactory<>(OriginsPaper.apoliIdentifier(alias), getSerializableData(alias), (data, block) -> { + return testCondition(data, block, null); + })); + } + + } + + public static void registerEntityCondition(Consumer> registryFunction) { + String[] var1 = getAliases(); + int var2 = var1.length; + + for (String alias : var1) { + registryFunction.accept(new ConditionTypeFactory<>(OriginsPaper.apoliIdentifier(alias), getSerializableData(alias), (data, entity) -> { + return testCondition(data, null, entity); + })); + } + + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/factory/EntityConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/EntityConditions.java new file mode 100644 index 000000000..0236be6a4 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/EntityConditions.java @@ -0,0 +1,157 @@ +package io.github.dueris.originspaper.condition.factory; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.type.entity.*; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import io.github.dueris.originspaper.power.type.ClimbingPower; +import io.github.dueris.originspaper.power.type.ElytraFlightPower; +import io.github.dueris.originspaper.registry.Registries; +import io.github.dueris.originspaper.storage.PowerHolderComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.OwnableEntity; +import net.minecraft.world.entity.player.Player; +import org.bukkit.Location; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; +import java.util.function.Predicate; + +public class EntityConditions { + private static final Location[] prevLoca = new Location[100000]; + + public static void register() { + MetaConditions.register(ApoliDataTypes.ENTITY_CONDITION, EntityConditions::register); + register(BlockCollisionConditionType.getFactory()); + register(BrightnessConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("daytime"), (entity) -> { + return TimeOfDayConditionType.condition(entity.level(), Comparison.LESS_THAN, 13000); + })); + register(TimeOfDayConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("fall_flying"), (entity) -> { + if (entity instanceof LivingEntity living) { + return living.isFallFlying() || PowerHolderComponent.doesHaveConditionedPower(living.getBukkitEntity(), ElytraFlightPower.class, p -> p.getGlidingPlayers().contains(living.getBukkitEntity().getUniqueId())); + } + return false; + })); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("exposed_to_sun"), ExposedToSunConditionType::condition)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("in_rain"), (entity) -> { + return entity.getBukkitEntity().isInRain(); + })); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("invisible"), Entity::isInvisible)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("on_fire"), Entity::isOnFire)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("exposed_to_sky"), ExposedToSkyConditionType::condition)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("sneaking"), Entity::isShiftKeyDown)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("sprinting"), Entity::isSprinting)); + register(PowerActiveConditionType.getFactory()); + register(SubmergedInConditionType.getFactory()); + register(FluidHeightConditionType.getFactory()); + register(PowerConditionType.getFactory()); + register(FoodLevelConditionType.getFactory()); + register(SaturationLevelConditionType.getFactory()); + register(OnBlockConditionType.getFactory()); + register(EquippedConditionType.getFactory()); + register(AttributeConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("swimming"), Entity::isSwimming)); + register(ResourceConditionType.getFactory()); + register(AirConditionType.getFactory()); + register(InBlockConditionType.getFactory()); + register(BlockInRadiusConditionType.getFactory()); + DistanceFromCoordinatesConditionRegistry.registerEntityCondition(EntityConditions::register); + register(DimensionConditionType.getFactory()); + register(XpLevelsConditionType.getFactory()); + register(XpPointsConditionType.getFactory()); + register(HealthConditionType.getFactory()); + register(RelativeHealthConditionType.getFactory()); + register(BiomeConditionType.getFactory()); + register(EntityTypeConditionType.getFactory()); + register(ScoreboardConditionType.getFactory()); + register(StatusEffectConditionType.getFactory()); + register(CommandConditionType.getFactory()); + register(PredicateConditionType.getFactory()); + register(FallDistanceConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("collided_horizontally"), (entity) -> { + return entity.horizontalCollision; + })); + register(InBlockAnywhereConditionType.getFactory()); + register(InTagConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("climbing"), (entity) -> { + if (entity instanceof LivingEntity living) { + return living.onClimbable() || PowerHolderComponent.doesHaveConditionedPower(living.getBukkitEntity(), ClimbingPower.class, p -> p.isActive(living)); + } + return false; + })); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("tamed"), (entity) -> { + if (entity instanceof OwnableEntity tameable) { + return tameable.getOwnerUUID() != null; + } + return false; + })); + register(UsingItemConditionType.getFactory()); + register(MovingConditionType.getFactory()); + register(EnchantmentConditionType.getFactory()); + register(RidingConditionType.getFactory()); + register(RidingRootConditionType.getFactory()); + register(RidingRecursiveConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("living"), (entity) -> { + return entity instanceof LivingEntity; + })); + register(PassengerConditionType.getFactory()); + register(PassengerRecursiveConditionType.getFactory()); + register(NbtConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("exists"), Objects::nonNull)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("creative_flying"), (entity) -> { + if (entity instanceof Player player) { + return player.getAbilities().flying; + } + return false; + })); + register(PowerTypeConditionType.getFactory()); + register(AbilityConditionType.getFactory()); + register(RaycastConditionType.getFactory()); + register(ElytraFlightPossibleConditionType.getFactory()); + register(InventoryConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("in_snow"), InSnowConditionType::condition)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("in_thunderstorm"), InThunderstormConditionType::condition)); + register(AdvancementConditionType.getFactory()); + register(EntitySetSizeConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("using_effective_tool"), UsingEffectiveToolConditionType::condition)); + register(GameModeConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("glowing"), Entity::isCurrentlyGlowing)); + register(EntityInRadiusConditionType.getFactory()); + register(HasCommandTagConditionType.getFactory()); + } + + public static @NotNull ConditionTypeFactory createSimpleFactory(ResourceLocation id, Predicate condition) { + return new ConditionTypeFactory<>(id, new SerializableData(), (data, entity) -> { + return condition.test(entity); + }); + } + + public static ConditionTypeFactory register(ConditionTypeFactory conditionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.ENTITY_CONDITION).register(conditionFactory, conditionFactory.getSerializerId()); + } + + public static boolean isEntityMovingHorizontal(@NotNull Entity entity) { + int entID = entity.getBukkitEntity().getEntityId(); + Location prevLocat = prevLoca[entID]; + Location cuLo = entity.getBukkitEntity().getLocation().clone(); + prevLoca[entID] = cuLo; + if (prevLocat == null) return true; + + return cuLo.getX() != prevLocat.getX() || prevLocat.getZ() != cuLo.getZ(); + } + + public static boolean isEntityMovingVertical(@NotNull Entity entity) { + int entID = entity.getBukkitEntity().getEntityId(); + Location prevLocat = prevLoca[entID]; + Location cuLo = entity.getBukkitEntity().getLocation().clone(); + prevLoca[entID] = cuLo; + if (prevLocat == null) return true; + + return cuLo.getY() != prevLocat.getY(); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/factory/FluidConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/FluidConditions.java new file mode 100644 index 000000000..55073492f --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/FluidConditions.java @@ -0,0 +1,33 @@ +package io.github.dueris.originspaper.condition.factory; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.type.fluid.FluidConditionType; +import io.github.dueris.originspaper.condition.type.fluid.InTagConditionType; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.material.FluidState; + +import java.util.function.Predicate; + +public class FluidConditions { + + public static void register() { + MetaConditions.register(ApoliDataTypes.FLUID_CONDITION, FluidConditions::register); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("empty"), FluidState::isEmpty)); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("still"), FluidState::isSource)); + register(InTagConditionType.getFactory()); + register(FluidConditionType.getFactory()); + } + + public static ConditionTypeFactory createSimpleFactory(ResourceLocation id, Predicate condition) { + return new ConditionTypeFactory<>(id, new SerializableData(), (data, fluidState) -> { + return condition.test(fluidState); + }); + } + + public static ConditionTypeFactory register(ConditionTypeFactory conditionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.FLUID_CONDITION).register(conditionFactory, conditionFactory.getSerializerId()); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/factory/ItemConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/ItemConditions.java new file mode 100644 index 000000000..cc71a0b46 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/ItemConditions.java @@ -0,0 +1,50 @@ +package io.github.dueris.originspaper.condition.factory; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.type.item.*; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.core.component.DataComponents; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +import java.util.function.Predicate; + +public class ItemConditions { + + public static void register() { + MetaConditions.register(ApoliDataTypes.ITEM_CONDITION, ItemConditions::register); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("food"), FoodConditionType::condition)); + register(SmeltableConditionType.getFactory()); + register(IngredientConditionType.getFactory()); + register(ArmorValueConditionType.getFactory()); + register(EnchantmentConditionType.getFactory()); + register(CustomDataConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("fire_resistant"), (stack) -> { + return stack.has(DataComponents.FIRE_RESISTANT); + })); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("enchantable"), ItemStack::isEnchantable)); + register(PowerCountConditionType.getFactory()); + register(HasPowerConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("empty"), ItemStack::isEmpty)); + register(AmountConditionType.getFactory()); + register(createSimpleFactory(OriginsPaper.apoliIdentifier("damageable"), ItemStack::isDamageableItem)); + register(DurabilityConditionType.getFactory()); + register(RelativeDurabilityConditionType.getFactory()); + register(EquippableConditionType.getFactory()); + register(FuelConditionType.getFactory()); + } + + public static ConditionTypeFactory> createSimpleFactory(ResourceLocation id, Predicate predicate) { + return new ConditionTypeFactory<>(id, new SerializableData(), (data, worldAndStack) -> { + return predicate.test(worldAndStack.getB()); + }); + } + + public static ConditionTypeFactory> register(ConditionTypeFactory> conditionFactory) { + return OriginsPaper.getRegistry().retrieve(Registries.ITEM_CONDITION).register(conditionFactory, conditionFactory.getSerializerId()); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/factory/MetaConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/MetaConditions.java new file mode 100644 index 000000000..86a9e1407 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/factory/MetaConditions.java @@ -0,0 +1,19 @@ +package io.github.dueris.originspaper.condition.factory; + +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.condition.type.meta.AndConditionType; +import io.github.dueris.originspaper.condition.type.meta.ChanceConditionType; +import io.github.dueris.originspaper.condition.type.meta.ConstantConditionType; +import io.github.dueris.originspaper.condition.type.meta.OrConditionType; + +import java.util.function.Consumer; + +public class MetaConditions { + + public static void register(SerializableDataBuilder> dataType, Consumer> registrant) { + registrant.accept(AndConditionType.getFactory(dataType)); + registrant.accept(ConstantConditionType.getFactory()); + registrant.accept(OrConditionType.getFactory(dataType)); + registrant.accept(ChanceConditionType.getFactory()); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/AndCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/meta/AndCondition.java deleted file mode 100644 index 9de24e0b6..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/AndCondition.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.dueris.originspaper.condition.meta; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.calio.registry.RegistryKey; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class AndCondition { - - public static @NotNull ConditionTypeFactory getFactory(RegistryKey> conditionDataType) { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("and"), - SerializableData.serializableData() - .add("conditions", SerializableDataTypes.list(ApoliDataTypes.condition(conditionDataType))), - (data, t) -> { - List> conditions = data.get("conditions"); - return conditions.stream().allMatch(condition -> condition.test(t)); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/ChanceCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/meta/ChanceCondition.java deleted file mode 100644 index b76eb1365..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/ChanceCondition.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.dueris.originspaper.condition.meta; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import org.jetbrains.annotations.NotNull; - -import java.util.Random; - -public class ChanceCondition { - private static final Random random = new Random(); - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("chance"), - SerializableData.serializableData() - .add("chance", SerializableDataTypes.FLOAT), - (data, t) -> { - return random.nextFloat() < data.getFloat("chance"); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/ConstantCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/meta/ConstantCondition.java deleted file mode 100644 index d8c440f7e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/ConstantCondition.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.dueris.originspaper.condition.meta; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import org.jetbrains.annotations.NotNull; - -public class ConstantCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("constant"), - SerializableData.serializableData() - .add("value", SerializableDataTypes.BOOLEAN), - (data, t) -> { - return data.getBoolean("value"); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/MetaConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/meta/MetaConditions.java deleted file mode 100644 index 7f79ff2da..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/MetaConditions.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.dueris.originspaper.condition.meta; - -import io.github.dueris.calio.registry.RegistryKey; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Consumer; - -public class MetaConditions { - - public static void register(RegistryKey> conditionDataType, @NotNull Consumer> factoryConsumer) { - factoryConsumer.accept(AndCondition.getFactory(conditionDataType)); - factoryConsumer.accept(ChanceCondition.getFactory()); - factoryConsumer.accept(ConstantCondition.getFactory()); - factoryConsumer.accept(OrCondition.getFactory(conditionDataType)); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/OrCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/meta/OrCondition.java deleted file mode 100644 index ad62d5da0..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/meta/OrCondition.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.dueris.originspaper.condition.meta; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.calio.registry.RegistryKey; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class OrCondition { - - public static @NotNull ConditionTypeFactory getFactory(RegistryKey> conditionDataType) { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("or"), - SerializableData.serializableData() - .add("conditions", SerializableDataTypes.list(ApoliDataTypes.condition(conditionDataType))), - (data, t) -> { - List> conditions = data.get("conditions"); - return conditions.stream().anyMatch(condition -> condition.test(t)); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/ActorCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/ActorConditionType.java similarity index 51% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/ActorCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/ActorConditionType.java index e70642ab8..e49330cf7 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/ActorCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/ActorConditionType.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.condition.types.bientity; +package io.github.dueris.originspaper.condition.type.bientity; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; @@ -10,17 +10,21 @@ import java.util.function.Predicate; -public class ActorCondition { +public class ActorConditionType { + + public static boolean condition(Entity actor, @NotNull Predicate condition) { + return condition.test(actor); + } public static @NotNull ConditionTypeFactory> getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("actor_condition"), - SerializableData.serializableData() + new SerializableData() .add("condition", ApoliDataTypes.ENTITY_CONDITION), - (data, actorAndTarget) -> { - Entity actor = actorAndTarget.getA(); - return actor != null && data.>get("condition").test(actor); - } + (data, actorAndTarget) -> condition(actorAndTarget.getA(), + data.get("condition") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/AttackTargetConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/AttackTargetConditionType.java new file mode 100644 index 000000000..0f2e29d20 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/AttackTargetConditionType.java @@ -0,0 +1,20 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.NeutralMob; + +public class AttackTargetConditionType { + + public static boolean condition(Entity actor, Entity target) { + + if (actor == null || target == null) { + return false; + } + + return (actor instanceof Mob mobActor && target.equals(mobActor.getTarget())) + || (actor instanceof NeutralMob angerableActor && target.equals(angerableActor.getTarget())); + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/AttackerConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/AttackerConditionType.java new file mode 100644 index 000000000..de4d0ee2a --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/AttackerConditionType.java @@ -0,0 +1,19 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; + +public class AttackerConditionType { + + public static boolean condition(Entity actor, Entity target) { + + if (actor == null || target == null) { + return false; + } + + return target instanceof LivingEntity livingTarget + && actor.equals(livingTarget.getLastHurtByMob()); + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/BothConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/BothConditionType.java new file mode 100644 index 000000000..2886ea915 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/BothConditionType.java @@ -0,0 +1,31 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class BothConditionType { + + public static boolean condition(Entity actor, Entity target, Predicate condition) { + return (actor != null && condition.test(actor)) + && (target != null && condition.test(target)); + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("both"), + new SerializableData() + .add("condition", ApoliDataTypes.ENTITY_CONDITION), + (data, actorAndTarget) -> condition(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("condition") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/CanSeeCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/CanSeeConditionType.java similarity index 66% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/CanSeeCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/CanSeeConditionType.java index 708a2a0a4..b38003250 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/CanSeeCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/CanSeeConditionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.condition.types.bientity; +package io.github.dueris.originspaper.condition.type.bientity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.ClipContext; @@ -11,12 +11,9 @@ import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; -public class CanSeeCondition { +public class CanSeeConditionType { - public static boolean condition(ClipContext.Block shapeType, ClipContext.Fluid fluidHandling, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); + public static boolean condition(Entity actor, Entity target, ClipContext.Block shapeType, ClipContext.Fluid fluidHandling) { if ((actor == null || target == null) || actor.level() != target.level()) { return false; @@ -37,10 +34,14 @@ public static boolean condition(ClipContext.Block shapeType, ClipContext.Fluid f public static @NotNull ConditionTypeFactory> getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("can_see"), - SerializableData.serializableData() + new SerializableData() .add("shape_type", SerializableDataTypes.SHAPE_TYPE, ClipContext.Block.VISUAL) .add("fluid_handling", SerializableDataTypes.FLUID_HANDLING, ClipContext.Fluid.NONE), - (data, entityPair) -> condition(data.get("shape_type"), data.get("fluid_handling"), entityPair) + (data, actorAndTarget) -> condition(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("shape_type"), + data.get("fluid_handling") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/DistanceConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/DistanceConditionType.java new file mode 100644 index 000000000..e81d0b83d --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/DistanceConditionType.java @@ -0,0 +1,34 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class DistanceConditionType { + + public static boolean condition(Entity actor, Entity target, Comparison comparison, double compareTo) { + return actor != null + && target != null + && comparison.compare(actor.position().distanceToSqr(target.position()), compareTo * compareTo); + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("distance"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.DOUBLE), + (data, actorAndTarget) -> condition(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/EitherConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/EitherConditionType.java new file mode 100644 index 000000000..1c8a4e7c4 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/EitherConditionType.java @@ -0,0 +1,31 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class EitherConditionType { + + public static boolean condition(Entity actor, Entity target, @NotNull Predicate condition) { + return condition.test(actor) + || condition.test(target); + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("either"), + new SerializableData() + .add("condition", ApoliDataTypes.ENTITY_CONDITION), + (data, actorAndTarget) -> condition(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("condition") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/InEntitySetConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/InEntitySetConditionType.java new file mode 100644 index 000000000..b4dd694c4 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/InEntitySetConditionType.java @@ -0,0 +1,30 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +// TODO - EntitySets - Dueris +public class InEntitySetConditionType { + + public static boolean condition(Entity actor, Entity target, PowerReference power) { + return false; + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("in_entity_set"), + new SerializableData() + .add("set", ApoliDataTypes.POWER_REFERENCE), + (data, actorAndTarget) -> condition(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("set") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/InvertConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/InvertConditionType.java new file mode 100644 index 000000000..8ddaa8248 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/InvertConditionType.java @@ -0,0 +1,30 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class InvertConditionType { + + public static boolean condition(Entity actor, Entity target, @NotNull Predicate> biEntityCondition) { + return biEntityCondition.test(new Tuple<>(target, actor)); + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("invert"), + new SerializableData() + .add("condition", ApoliDataTypes.BIENTITY_CONDITION), + (data, actorAndTarget) -> condition(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("condition") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/OwnerConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/OwnerConditionType.java new file mode 100644 index 000000000..481396508 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/OwnerConditionType.java @@ -0,0 +1,16 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.OwnableEntity; +import net.minecraft.world.entity.TraceableEntity; + +import java.util.Objects; + +public class OwnerConditionType { + + public static boolean condition(Entity actor, Entity target) { + return (target instanceof OwnableEntity tameable && Objects.equals(actor, tameable.getOwner())) + || (target instanceof TraceableEntity ownable && Objects.equals(actor, ownable.getOwner())); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RelativeRotationCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RelativeRotationConditionType.java similarity index 73% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RelativeRotationCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RelativeRotationConditionType.java index b85c7ea9a..75a6447a1 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RelativeRotationCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RelativeRotationConditionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.condition.types.bientity; +package io.github.dueris.originspaper.condition.type.bientity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.core.Direction; @@ -17,33 +17,21 @@ import java.util.EnumSet; import java.util.function.Function; -public class RelativeRotationCondition { +public class RelativeRotationConditionType { - public static boolean condition(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); + public static boolean condition(Entity actor, Entity target, RotationType actorRotationType, RotationType targetRotationType, EnumSet axes, Comparison comparison, double compareTo) { if (actor == null || target == null) { return false; } - RotationType actorRotationType = data.get("actor_rotation"); - RotationType targetRotationType = data.get("target_rotation"); - Vec3 actorRotation = actorRotationType.getRotation(actor); Vec3 targetRotation = targetRotationType.getRotation(target); - EnumSet axes = data.get("axes"); - actorRotation = reduceAxes(actorRotation, axes); targetRotation = reduceAxes(targetRotation, axes); - Comparison comparison = data.get("comparison"); - double compareTo = data.get("compare_to"); - double angle = getAngleBetween(actorRotation, targetRotation); - - return comparison.compare(angle, compareTo); + return comparison.compare(getAngleBetween(actorRotation, targetRotation), compareTo); } @@ -63,13 +51,19 @@ private static double getAngleBetween(@NotNull Vec3 a, Vec3 b) { public static @NotNull ConditionTypeFactory> getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("relative_rotation"), - SerializableData.serializableData() - .add("axes", SerializableDataTypes.enumSet(Direction.Axis.class, SerializableDataTypes.AXIS), EnumSet.allOf(Direction.Axis.class)) + new SerializableData() .add("actor_rotation", SerializableDataTypes.enumValue(RotationType.class), RotationType.HEAD) .add("target_rotation", SerializableDataTypes.enumValue(RotationType.class), RotationType.BODY) + .add("axes", SerializableDataTypes.enumSet(Direction.Axis.class, SerializableDataTypes.AXIS), EnumSet.allOf(Direction.Axis.class)) .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.DOUBLE), - RelativeRotationCondition::condition + (data, actorAndTarget) -> condition(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("actor_rotation"), + data.get("target_rotation"), + data.get("axes"), + data.get("comparison"), + data.get("compare_to") + ) ); } @@ -94,7 +88,7 @@ private static double getAngleBetween(@NotNull Vec3 a, Vec3 b) { public enum RotationType { HEAD(e -> e.getViewVector(1.0F)), - BODY(RelativeRotationCondition::getBodyRotationVector); + BODY(RelativeRotationConditionType::getBodyRotationVector); private final Function function; @@ -107,4 +101,5 @@ public Vec3 getRotation(Entity entity) { } } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RidingConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RidingConditionType.java new file mode 100644 index 000000000..dd568b664 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RidingConditionType.java @@ -0,0 +1,15 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import net.minecraft.world.entity.Entity; + +import java.util.Objects; + +public class RidingConditionType { + + public static boolean condition(Entity actor, Entity target) { + return actor != null + && target != null + && Objects.equals(actor.getVehicle(), target); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RidingRecursiveConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RidingRecursiveConditionType.java new file mode 100644 index 000000000..ef3b3fdb0 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RidingRecursiveConditionType.java @@ -0,0 +1,30 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import net.minecraft.world.entity.Entity; + +import java.util.Objects; + +public class RidingRecursiveConditionType { + + public static boolean condition(Entity actor, Entity target) { + + if (actor == null || target == null || !actor.isPassenger()) { + return false; + } + + Entity vehicle = actor.getVehicle(); + while (vehicle != null) { + + if (Objects.equals(vehicle, target)) { + return true; + } + + vehicle = vehicle.getVehicle(); + + } + + return false; + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RidingRootConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RidingRootConditionType.java new file mode 100644 index 000000000..9745f35ff --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/RidingRootConditionType.java @@ -0,0 +1,15 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import net.minecraft.world.entity.Entity; + +import java.util.Objects; + +public class RidingRootConditionType { + + public static boolean condition(Entity actor, Entity target) { + return actor != null + && target != null + && Objects.equals(actor.getRootVehicle(), target); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/TargetCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/TargetConditionType.java similarity index 51% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/TargetCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/TargetConditionType.java index 886f53c12..b3d05ddd2 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/TargetCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/TargetConditionType.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.condition.types.bientity; +package io.github.dueris.originspaper.condition.type.bientity; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; @@ -10,17 +10,21 @@ import java.util.function.Predicate; -public class TargetCondition { +public class TargetConditionType { + + public static boolean condition(Entity target, @NotNull Predicate condition) { + return condition.test(target); + } public static @NotNull ConditionTypeFactory> getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("target_condition"), - SerializableData.serializableData() + new SerializableData() .add("condition", ApoliDataTypes.ENTITY_CONDITION), - (data, actorAndTarget) -> { - Entity target = actorAndTarget.getB(); - return target != null && data.>get("condition").test(target); - } + (data, actorAndTarget) -> condition(actorAndTarget.getB(), + data.get("condition") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/UndirectedConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/UndirectedConditionType.java new file mode 100644 index 000000000..051237c79 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/bientity/UndirectedConditionType.java @@ -0,0 +1,31 @@ +package io.github.dueris.originspaper.condition.type.bientity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class UndirectedConditionType { + + public static boolean condition(Entity actor, Entity target, @NotNull Predicate> biEntityCondition) { + return biEntityCondition.test(new Tuple<>(actor, target)) + || biEntityCondition.test(new Tuple<>(target, actor)); + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("undirected"), + new SerializableData() + .add("condition", ApoliDataTypes.BIENTITY_CONDITION), + (data, actorAndTarget) -> condition(actorAndTarget.getA(), actorAndTarget.getB(), + data.get("condition") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/biome/InTagConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/biome/InTagConditionType.java new file mode 100644 index 000000000..249509786 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/biome/InTagConditionType.java @@ -0,0 +1,31 @@ +package io.github.dueris.originspaper.condition.type.biome; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.tags.TagKey; +import net.minecraft.util.Tuple; +import net.minecraft.world.level.biome.Biome; +import org.jetbrains.annotations.NotNull; + +public class InTagConditionType { + + public static boolean condition(@NotNull Holder biomeEntry, TagKey biomeTag) { + return biomeEntry.is(biomeTag); + } + + public static @NotNull ConditionTypeFactory>> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("in_tag"), + new SerializableData() + .add("tag", SerializableDataTypes.BIOME_TAG), + (data, posAndBiome) -> condition(posAndBiome.getB(), + data.get("tag") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/biome/PrecipitationConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/biome/PrecipitationConditionType.java new file mode 100644 index 000000000..16b179e01 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/biome/PrecipitationConditionType.java @@ -0,0 +1,30 @@ +package io.github.dueris.originspaper.condition.type.biome; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.util.Tuple; +import net.minecraft.world.level.biome.Biome; +import org.jetbrains.annotations.NotNull; + +public class PrecipitationConditionType { + + public static boolean condition(BlockPos pos, @NotNull Holder biomeEntry, Biome.Precipitation precipitation) { + return biomeEntry.value().getPrecipitationAt(pos) == precipitation; + } + + public static @NotNull ConditionTypeFactory>> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("precipitation"), + new SerializableData() + .add("precipitation", SerializableDataTypes.enumValue(Biome.Precipitation.class)), + (data, posAndBiome) -> condition(posAndBiome.getA(), posAndBiome.getB(), + data.get("precipitation") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/biome/TemperatureConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/biome/TemperatureConditionType.java new file mode 100644 index 000000000..9755ef89d --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/biome/TemperatureConditionType.java @@ -0,0 +1,34 @@ +package io.github.dueris.originspaper.condition.type.biome; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.util.Tuple; +import net.minecraft.world.level.biome.Biome; +import org.jetbrains.annotations.NotNull; + +public class TemperatureConditionType { + + public static boolean condition(@NotNull Holder biomeEntry, @NotNull Comparison comparison, float compareTo) { + return comparison.compare(biomeEntry.value().getBaseTemperature(), compareTo); + } + + public static @NotNull ConditionTypeFactory>> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("temperature"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.FLOAT), + (data, posAndBiome) -> condition(posAndBiome.getB(), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/AdjacentConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/AdjacentConditionType.java new file mode 100644 index 000000000..23f797159 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/AdjacentConditionType.java @@ -0,0 +1,47 @@ +package io.github.dueris.originspaper.condition.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class AdjacentConditionType { + + public static boolean condition(BlockInWorld cachedBlock, Predicate adjacentCondition, Comparison comparison, int compareTo) { + + int matchingAdjacents = 0; + for (Direction direction : Direction.values()) { + + if (adjacentCondition.test(new BlockInWorld(cachedBlock.getLevel(), cachedBlock.getPos().relative(direction), true))) { + matchingAdjacents++; + } + + } + + return comparison.compare(matchingAdjacents, compareTo); + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("adjacent"), + new SerializableData() + .add("adjacent_condition", ApoliDataTypes.BLOCK_CONDITION) + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, cachedBlock) -> condition(cachedBlock, + data.get("adjacent_condition"), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/AttachableConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/AttachableConditionType.java new file mode 100644 index 000000000..d88af6e1a --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/AttachableConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; + +public class AttachableConditionType { + + public static boolean condition(@NotNull BlockInWorld cachedBlock) { + + LevelReader worldView = cachedBlock.getLevel(); + BlockPos originPos = cachedBlock.getPos(); + + for (Direction direction : Direction.values()) { + + BlockPos offsetPos = originPos.relative(direction); + BlockState adjacentState = worldView.getBlockState(offsetPos); + + if (adjacentState.isFaceSturdy(worldView, originPos, direction.getOpposite())) { + return true; + } + + } + + return false; + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlastResistanceCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/BlastResistanceConditionType.java similarity index 53% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlastResistanceCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/block/BlastResistanceConditionType.java index 127139c6a..2ff990c04 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlastResistanceCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/BlastResistanceConditionType.java @@ -1,27 +1,32 @@ -package io.github.dueris.originspaper.condition.types.block; +package io.github.dueris.originspaper.condition.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import org.jetbrains.annotations.NotNull; -public class BlastResistanceCondition { +public class BlastResistanceConditionType { + + public static boolean condition(@NotNull BlockState blockState, @NotNull Comparison comparison, float compareTo) { + return comparison.compare(blockState.getBlock().getExplosionResistance(), compareTo); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("blast_resistance"), - SerializableData.serializableData() + new SerializableData() .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.FLOAT), - (data, block) -> { - BlockState state = block.getState(); - return ((Comparison) data.get("comparison")).compare(state.getBlock().getExplosionResistance(), data.getFloat("compare_to")); - } + (data, cachedBlock) -> condition(cachedBlock.getState(), + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlockCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/BlockConditionType.java similarity index 50% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlockCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/block/BlockConditionType.java index 9207e6895..ea6baa4c2 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlockCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/BlockConditionType.java @@ -1,21 +1,28 @@ -package io.github.dueris.originspaper.condition.types.block; +package io.github.dueris.originspaper.condition.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import org.jetbrains.annotations.NotNull; -public class BlockCondition { +public class BlockConditionType { + + public static boolean condition(@NotNull BlockInWorld cachedBlock, Block block) { + return cachedBlock.getState().is(block); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("block"), - SerializableData.serializableData() + new SerializableData() .add("block", SerializableDataTypes.BLOCK), - (data, block) -> block.getState().is((Block) data.get("block")) + (data, cachedBlock) -> condition(cachedBlock, + data.get("block") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/BlockStateConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/BlockStateConditionType.java new file mode 100644 index 000000000..be698d334 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/BlockStateConditionType.java @@ -0,0 +1,54 @@ +package io.github.dueris.originspaper.condition.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class BlockStateConditionType { + + public static boolean condition(@NotNull BlockState blockState, String propertyName, @Nullable Comparison comparison, @Nullable Integer compareTo, @Nullable Boolean value, @Nullable String enumName) { + + var propertyValue = blockState.getProperties() + .stream() + .filter(prop -> prop.getName().equals(propertyName)) + .map(blockState::getValue) + .findFirst() + .orElse(null); + + return switch (propertyValue) { + case Enum enumValue when enumName != null -> enumValue.name().equalsIgnoreCase(enumName); + case Boolean booleanValue when value != null -> booleanValue == value; + case Integer intValue when comparison != null && compareTo != null -> + comparison.compare(intValue, compareTo); + case null, default -> propertyValue != null; + }; + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("block_state"), + new SerializableData() + .add("property", SerializableDataTypes.STRING) + .add("comparison", ApoliDataTypes.COMPARISON, null) + .add("compare_to", SerializableDataTypes.INT, null) + .add("value", SerializableDataTypes.BOOLEAN, null) + .add("enum", SerializableDataTypes.STRING, null), + (data, cachedBlock) -> condition(cachedBlock.getState(), + data.get("property"), + data.get("comparison"), + data.get("compare_to"), + data.get("value"), + data.get("enum") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/CommandCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/CommandConditionType.java similarity index 61% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/block/CommandCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/block/CommandConditionType.java index 36dd37895..6ac1f6bb1 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/CommandCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/CommandConditionType.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.condition.types.block; +package io.github.dueris.originspaper.condition.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.MinecraftServer; import net.minecraft.world.level.Level; @@ -14,28 +15,23 @@ import java.util.concurrent.atomic.AtomicInteger; -public class CommandCondition { +public class CommandConditionType { - public static boolean condition(SerializableData.Instance data, @NotNull BlockInWorld cachedBlockPosition) { + public static boolean condition(@NotNull BlockInWorld cachedBlock, String command, Comparison comparison, int compareTo) { - MinecraftServer server = ((Level) cachedBlockPosition.getLevel()).getServer(); + MinecraftServer server = ((Level) cachedBlock.getLevel()).getServer(); if (server == null) { return false; } AtomicInteger result = new AtomicInteger(); CommandSourceStack source = server.createCommandSourceStack() - .withPosition(cachedBlockPosition.getPos().getCenter()) + .withSource(OriginsPaper.showCommandOutput ? server : CommandSource.NULL) + .withPosition(cachedBlock.getPos().getCenter()) .withPermission(4) - .withCallback((successful, returnValue) -> result.set(returnValue)) - .withSuppressedOutput(); + .withCallback((successful, returnValue) -> result.set(returnValue)); - Comparison comparison = data.get("comparison"); - String command = data.get("command"); - - int compareTo = data.get("compare_to"); server.getCommands().performPrefixedCommand(source, command); - return comparison.compare(result.get(), compareTo); } @@ -43,11 +39,16 @@ public static boolean condition(SerializableData.Instance data, @NotNull BlockIn public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("command"), - SerializableData.serializableData() + new SerializableData() .add("command", SerializableDataTypes.STRING) .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) .add("compare_to", SerializableDataTypes.INT, 1), - CommandCondition::condition + (data, cachedBlock) -> condition(cachedBlock, + data.get("command"), + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/FluidConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/FluidConditionType.java new file mode 100644 index 000000000..ec7ee5c05 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/FluidConditionType.java @@ -0,0 +1,30 @@ +package io.github.dueris.originspaper.condition.type.block; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import net.minecraft.world.level.material.FluidState; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class FluidConditionType { + + public static boolean condition(@NotNull BlockInWorld cachedBlock, @NotNull Predicate fluidCondition) { + return fluidCondition.test(cachedBlock.getLevel().getFluidState(cachedBlock.getPos())); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("fluid"), + new SerializableData() + .add("fluid_condition", ApoliDataTypes.FLUID_CONDITION), + (data, cachedBlock) -> condition(cachedBlock, + data.get("fluid_condition") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/HardnessCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/HardnessConditionType.java similarity index 53% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/block/HardnessCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/block/HardnessConditionType.java index dfc30df60..d62720da6 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/HardnessCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/HardnessConditionType.java @@ -1,27 +1,32 @@ -package io.github.dueris.originspaper.condition.types.block; +package io.github.dueris.originspaper.condition.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import org.jetbrains.annotations.NotNull; -public class HardnessCondition { +public class HardnessConditionType { + + public static boolean condition(@NotNull BlockState blockState, @NotNull Comparison comparison, float compareTo) { + return comparison.compare(blockState.getBlock().defaultDestroyTime(), compareTo); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("hardness"), - SerializableData.serializableData() + new SerializableData() .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.FLOAT), - (data, block) -> { - BlockState state = block.getState(); - return ((Comparison) data.get("comparison")).compare(state.getBlock().defaultDestroyTime(), data.getFloat("compare_to")); - } + (data, cachedBlock) -> condition(cachedBlock.getState(), + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/HeightCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/HeightConditionType.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/block/HeightCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/block/HeightConditionType.java index a31814bcf..7a1123a94 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/HeightCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/HeightConditionType.java @@ -1,23 +1,31 @@ -package io.github.dueris.originspaper.condition.types.block; +package io.github.dueris.originspaper.condition.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import org.jetbrains.annotations.NotNull; -public class HeightCondition { +public class HeightConditionType { + + public static boolean condition(@NotNull BlockInWorld cachedBlock, @NotNull Comparison comparison, int compareTo) { + return comparison.compare(cachedBlock.getPos().getY(), compareTo); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("height"), - SerializableData.serializableData() + new SerializableData() .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.INT), - (data, block) -> ((Comparison) data.get("comparison")).compare(block.getPos().getY(), data.getInt("compare_to")) + (data, cachedBlock) -> condition(cachedBlock, + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/InTagCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/InTagConditionType.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/block/InTagCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/block/InTagConditionType.java index 1daf2a1b5..fa20812d6 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/InTagCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/InTagConditionType.java @@ -1,27 +1,29 @@ -package io.github.dueris.originspaper.condition.types.block; +package io.github.dueris.originspaper.condition.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import org.jetbrains.annotations.NotNull; -public class InTagCondition { +public class InTagConditionType { + + public static boolean condition(@NotNull BlockInWorld cachedBlock, TagKey blockTag) { + return cachedBlock.getState().is(blockTag); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("in_tag"), - SerializableData.serializableData() + new SerializableData() .add("tag", SerializableDataTypes.BLOCK_TAG), - (data, block) -> { - if (block == null || block.getState() == null) { - return false; - } - return block.getState().is((TagKey) data.get("tag")); - } + (data, cachedBlock) -> condition(cachedBlock, + data.get("tag") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/LightLevelConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/LightLevelConditionType.java new file mode 100644 index 000000000..e0c5decff --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/LightLevelConditionType.java @@ -0,0 +1,56 @@ +package io.github.dueris.originspaper.condition.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class LightLevelConditionType { + + public static boolean condition(@NotNull BlockInWorld cachedBlock, @Nullable LightLayer lightType, Comparison comparison, int compareTo) { + + Level world = (Level) cachedBlock.getLevel(); + BlockPos pos = cachedBlock.getPos(); + + int lightLevel; + + if (lightType != null) { + lightLevel = world.getBrightness(lightType, pos); + } else { + + if (world.isClientSide) { + world.updateSkyBrightness(); + } + + lightLevel = world.getMaxLocalRawBrightness(pos); + + } + + return comparison.compare(lightLevel, compareTo); + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("light_level"), + new SerializableData() + .add("light_type", SerializableDataTypes.enumValue(LightLayer.class), null) + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, cachedBlock) -> condition(cachedBlock, + data.get("light_type"), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/MovementBlockingConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/MovementBlockingConditionType.java new file mode 100644 index 000000000..ab59b50a2 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/MovementBlockingConditionType.java @@ -0,0 +1,15 @@ +package io.github.dueris.originspaper.condition.type.block; + +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; + +public class MovementBlockingConditionType { + + public static boolean condition(@NotNull BlockInWorld cachedBlock) { + BlockState state = cachedBlock.getState(); + return state.blocksMotion() + && !state.getCollisionShape(cachedBlock.getLevel(), cachedBlock.getPos()).isEmpty(); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/NbtConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/NbtConditionType.java new file mode 100644 index 000000000..1a6f45903 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/NbtConditionType.java @@ -0,0 +1,37 @@ +package io.github.dueris.originspaper.condition.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.core.RegistryAccess; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; + +public class NbtConditionType { + + public static boolean condition(@NotNull BlockInWorld cachedBlock, CompoundTag nbt) { + + RegistryAccess registryManager = cachedBlock.getLevel().registryAccess(); + BlockEntity blockEntity = cachedBlock.getEntity(); + + return blockEntity != null + && NbtUtils.compareNbt(nbt, blockEntity.saveWithFullMetadata(registryManager), true); + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("nbt"), + new SerializableData() + .add("nbt", SerializableDataTypes.NBT_COMPOUND), + (data, cachedBlock) -> condition(cachedBlock, + data.get("nbt") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/OffsetConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/OffsetConditionType.java new file mode 100644 index 000000000..50303c45d --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/OffsetConditionType.java @@ -0,0 +1,35 @@ +package io.github.dueris.originspaper.condition.type.block; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class OffsetConditionType { + + public static boolean condition(@NotNull BlockInWorld cachedBlock, @NotNull Predicate blockCondition, Vec3i offset) { + return blockCondition.test(new BlockInWorld(cachedBlock.getLevel(), cachedBlock.getPos().offset(offset), true)); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("offset"), + new SerializableData() + .add("condition", ApoliDataTypes.BLOCK_CONDITION) + .add("x", SerializableDataTypes.INT, 0) + .add("y", SerializableDataTypes.INT, 0) + .add("z", SerializableDataTypes.INT, 0), + (data, cachedBlock) -> condition(cachedBlock, + data.get("condition"), + new Vec3i(data.get("x"), data.get("y"), data.get("z")) + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/SlipperinessCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/SlipperinessConditionType.java similarity index 53% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/block/SlipperinessCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/block/SlipperinessConditionType.java index 906435944..c71d6b8db 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/SlipperinessCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/block/SlipperinessConditionType.java @@ -1,27 +1,32 @@ -package io.github.dueris.originspaper.condition.types.block; +package io.github.dueris.originspaper.condition.type.block; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import org.jetbrains.annotations.NotNull; -public class SlipperinessCondition { +public class SlipperinessConditionType { + + public static boolean condition(@NotNull BlockState blockState, @NotNull Comparison comparison, float compareTo) { + return comparison.compare(blockState.getBlock().getFriction(), compareTo); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("slipperiness"), - SerializableData.serializableData() + new SerializableData() .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.FLOAT), - (data, block) -> { - BlockState state = block.getState(); - return ((Comparison) data.get("comparison")).compare(state.getBlock().getFriction(), data.getFloat("compare_to")); - } + (data, cachedBlock) -> condition(cachedBlock.getState(), + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/AmountConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/AmountConditionType.java new file mode 100644 index 000000000..f72d8bfe0 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/AmountConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.damage; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.damagesource.DamageSource; +import org.jetbrains.annotations.NotNull; + +public class AmountConditionType { + + public static boolean condition(float amount, @NotNull Comparison comparison, float compareTo) { + return comparison.compare(amount, compareTo); + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("amount"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.FLOAT), + (data, sourceAndAmount) -> condition(sourceAndAmount.getB(), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/AttackerConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/AttackerConditionType.java new file mode 100644 index 000000000..cbd46d24d --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/AttackerConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.damage; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; + +import java.util.function.Predicate; + +public class AttackerConditionType { + + public static boolean condition(DamageSource damageSource, Predicate entityCondition) { + Entity attacker = damageSource.getEntity(); + return attacker != null + && entityCondition.test(attacker); + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("attacker"), + new SerializableData() + .add("entity_condition", ApoliDataTypes.ENTITY_CONDITION, null), + (data, sourceAndAmount) -> condition(sourceAndAmount.getA(), + data.getOrElse("entity_condition", e -> true) + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/InTagConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/InTagConditionType.java new file mode 100644 index 000000000..101f2a8c6 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/InTagConditionType.java @@ -0,0 +1,39 @@ +package io.github.dueris.originspaper.condition.type.damage; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.util.Tuple; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageType; +import org.jetbrains.annotations.NotNull; + +public class InTagConditionType { + + public static boolean condition(@NotNull DamageSource damageSource, TagKey damageTypeTag) { + return damageSource.is(damageTypeTag); + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("in_tag"), + new SerializableData() + .add("tag", SerializableDataTypes.tag(Registries.DAMAGE_TYPE)), + (data, sourceAndAmount) -> condition(sourceAndAmount.getA(), + data.get("tag") + ) + ); + } + + public static @NotNull ConditionTypeFactory> createFactory(ResourceLocation id, TagKey damageTypeTag) { + return new ConditionTypeFactory<>(id, + new SerializableData(), + (data, sourceAndAmount) -> condition(sourceAndAmount.getA(), damageTypeTag) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/NameConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/NameConditionType.java new file mode 100644 index 000000000..de7c65109 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/NameConditionType.java @@ -0,0 +1,28 @@ +package io.github.dueris.originspaper.condition.type.damage; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.util.Tuple; +import net.minecraft.world.damagesource.DamageSource; +import org.jetbrains.annotations.NotNull; + +public class NameConditionType { + + public static boolean condition(@NotNull DamageSource damageSource, String name) { + return damageSource.getMsgId().equals(name); + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("name"), + new SerializableData() + .add("name", SerializableDataTypes.STRING), + (data, sourceAndAmount) -> condition(sourceAndAmount.getA(), + data.get("name") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/ProjectileConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/ProjectileConditionType.java new file mode 100644 index 000000000..a8118c02e --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/ProjectileConditionType.java @@ -0,0 +1,43 @@ +package io.github.dueris.originspaper.condition.type.damage; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.tags.DamageTypeTags; +import net.minecraft.util.Tuple; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class ProjectileConditionType { + + public static boolean condition(@NotNull DamageSource damageSource, EntityType projectileType, Predicate projectileCondition) { + + Entity source = damageSource.getDirectEntity(); + + return damageSource.is(DamageTypeTags.IS_PROJECTILE) + && source != null + && (projectileType == null || source.getType() == projectileType) + && projectileCondition.test(source); + + } + + public static @NotNull ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("projectile"), + new SerializableData() + .add("projectile", SerializableDataTypes.ENTITY_TYPE, null) + .add("projectile_condition", ApoliDataTypes.ENTITY_CONDITION, null), + (data, sourceAndAmount) -> condition(sourceAndAmount.getA(), + data.get("projectile"), + data.getOrElse("projectile_condition", e -> true) + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/TypeConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/TypeConditionType.java new file mode 100644 index 000000000..032e4bb0f --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/damage/TypeConditionType.java @@ -0,0 +1,28 @@ +package io.github.dueris.originspaper.condition.type.damage; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.Tuple; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageType; + +public class TypeConditionType { + + public static boolean condition(DamageSource damageSource, ResourceKey damageTypeKey) { + return damageSource.is(damageTypeKey); + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("type"), + new SerializableData() + .add("damage_type", SerializableDataTypes.DAMAGE_TYPE), + (data, sourceAndAmount) -> condition(sourceAndAmount.getA(), + data.get("damage_type")) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AbilityConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AbilityConditionType.java new file mode 100644 index 000000000..0fd6f1f39 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AbilityConditionType.java @@ -0,0 +1,46 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.NotNull; + +public class AbilityConditionType { + + public static boolean condition(Entity entity, SerializableData.Instance data) { + boolean enabled = false; + if (entity instanceof Player player && !entity.level().isClientSide) { + switch (data.getId("ability").toString()) { + case "minecraft:flying": + enabled = player.getAbilities().flying; + case "minecraft:instabuild": + enabled = player.getAbilities().instabuild; + case "minecraft:invulnerable": + enabled = player.getAbilities().invulnerable; + case "minecraft:mayBuild": + enabled = player.getAbilities().mayBuild; + case "minecraft:mayfly": + enabled = player.getAbilities().mayfly; + break; + default: + throw new IllegalStateException("Unexpected value: " + data.getId("ability").toString()); + } + } + return enabled; + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("ability"), + new SerializableData() + .add("ability", SerializableDataTypes.IDENTIFIER), + (data, entity) -> condition(entity, + data + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AdvancementConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AdvancementConditionType.java new file mode 100644 index 000000000..38d729a2e --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AdvancementConditionType.java @@ -0,0 +1,53 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.NotNull; + +public class AdvancementConditionType { + + public static boolean condition(Entity entity, ResourceLocation advancementId) { + + if (!(entity instanceof Player player)) { + return false; + } + + MinecraftServer server = player.getServer(); + if (server != null) { + + AdvancementHolder advancement = server.getAdvancements().get(advancementId); + if (advancement == null) { + OriginsPaper.LOGGER.warn("Advancement \"{}\" did not exist, but was referenced in an \"advancement\" entity condition!", advancementId); + return false; + } else { + return ((ServerPlayer) player).getAdvancements() + .getOrStartProgress(advancement) + .isDone(); + } + + } else { + return false; + } + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("advancement"), + new SerializableData() + .add("advancement", SerializableDataTypes.IDENTIFIER), + (data, entity) -> condition(entity, + data.get("advancement") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AirCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AirConditionType.java similarity index 51% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AirCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AirConditionType.java index 7795496b9..e2f2d2e54 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AirCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AirConditionType.java @@ -1,25 +1,31 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; -public class AirCondition { +public class AirConditionType { + + public static boolean condition(@NotNull Entity entity, @NotNull Comparison comparison, int compareTo) { + return comparison.compare(entity.getAirSupply(), compareTo); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("air"), - SerializableData.serializableData() + new SerializableData() .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.INT), - (data, entity) -> { - return ((Comparison) data.get("comparison")).compare(entity.getAirSupply(), data.getInt("compare_to")); - } + (data, entity) -> condition(entity, + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AttributeCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AttributeConditionType.java similarity index 84% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AttributeCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AttributeConditionType.java index 1ebe0b871..a92cf1d1e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AttributeCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/AttributeConditionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.core.Holder; @@ -13,7 +13,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeInstance; import org.jetbrains.annotations.NotNull; -public class AttributeCondition { +public class AttributeConditionType { public static boolean condition(Entity entity, Holder attributeEntry, Comparison comparison, double compareTo) { @@ -36,7 +36,7 @@ public static boolean condition(Entity entity, Holder attributeEntry, public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("attribute"), - SerializableData.serializableData() + new SerializableData() .add("attribute", SerializableDataTypes.ATTRIBUTE_ENTRY) .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.DOUBLE), @@ -48,4 +48,5 @@ public static boolean condition(Entity entity, Holder attributeEntry, ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BiomeCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BiomeConditionType.java similarity index 55% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BiomeCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BiomeConditionType.java index 82050b006..ef6576793 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BiomeCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BiomeConditionType.java @@ -1,38 +1,37 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; +import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.biome.Biome; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.function.Predicate; -public class BiomeCondition { +public class BiomeConditionType { - public static boolean condition(@NotNull Entity entity, @Nullable Predicate> biomeCondition, @NotNull Collection> specBiomeKeys) { + public static boolean condition(Entity entity, Predicate>> biomeCondition, Collection> specifiedBiomeKeys) { Holder biomeEntry = entity.level().getBiome(entity.blockPosition()); ResourceKey biomeKey = biomeEntry.unwrapKey().orElseThrow(); - return (!specBiomeKeys.isEmpty() && specBiomeKeys.contains(biomeKey)) - && (biomeCondition != null && biomeCondition.test(biomeEntry)); + return (specifiedBiomeKeys.isEmpty() || specifiedBiomeKeys.contains(biomeKey)) + && biomeCondition.test(new Tuple<>(entity.blockPosition(), biomeEntry)); } - public static @NotNull ConditionTypeFactory getFactory() { + public static ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("biome"), new SerializableData() @@ -41,17 +40,18 @@ public static boolean condition(@NotNull Entity entity, @Nullable Predicate { - Set> specBiomeKeys = new HashSet<>(); + Set> specifiedBiomeKeys = new HashSet<>(); - data.ifPresent("biome", specBiomeKeys::add); - data.ifPresent("biomes", specBiomeKeys::addAll); + data.ifPresent("biome", specifiedBiomeKeys::add); + data.ifPresent("biomes", specifiedBiomeKeys::addAll); return condition(entity, - data.get("condition"), - specBiomeKeys + data.getOrElse("condition", posAndBiome -> true), + specifiedBiomeKeys ); } ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BlockCollisionConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BlockCollisionConditionType.java new file mode 100644 index 000000000..9ca260685 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BlockCollisionConditionType.java @@ -0,0 +1,57 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.BlockCollisions; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class BlockCollisionConditionType { + + public static boolean condition(@NotNull Entity entity, Predicate blockCondition, Vec3 offset) { + + AABB boundingBox = entity.getBoundingBox().move(offset); + Level world = entity.level(); + + BlockCollisions spliterator = new BlockCollisions<>(world, entity, boundingBox, false, (pos, shape) -> pos); + + while (spliterator.hasNext()) { + + BlockPos pos = spliterator.next(); + + if (blockCondition.test(new BlockInWorld(world, pos, true))) { + return true; + } + + } + + return false; + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("block_collision"), + new SerializableData() + .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) + .add("offset_x", SerializableDataTypes.DOUBLE, 0.0) + .add("offset_y", SerializableDataTypes.DOUBLE, 0.0) + .add("offset_z", SerializableDataTypes.DOUBLE, 0.0), + (data, entity) -> condition(entity, + data.getOrElse("block_condition", cachedBlock -> true), + new Vec3(data.get("offset_x"), data.get("offset_y"), data.get("offset_z")) + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BlockInRadiusConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BlockInRadiusConditionType.java new file mode 100644 index 000000000..c67aa3d86 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BlockInRadiusConditionType.java @@ -0,0 +1,63 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import io.github.dueris.originspaper.data.types.Shape; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class BlockInRadiusConditionType { + + public static boolean condition(Entity entity, Predicate blockCondition, int radius, Shape shape, @NotNull Comparison comparison, int compareTo) { + + int countThreshold = switch (comparison) { + case EQUAL, LESS_THAN_OR_EQUAL, GREATER_THAN -> compareTo + 1; + case LESS_THAN, GREATER_THAN_OR_EQUAL -> compareTo; + default -> -1; + }; + + int count = 0; + for (BlockPos pos : Shape.getPositions(entity.blockPosition(), shape, radius)) { + + if (blockCondition.test(new BlockInWorld(entity.level(), pos, true))) { + ++count; + } + + if (count == countThreshold) { + break; + } + + } + + return comparison.compare(count, compareTo); + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("block_in_radius"), + new SerializableData() + .add("block_condition", ApoliDataTypes.BLOCK_CONDITION) + .add("radius", SerializableDataTypes.INT) + .add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE) + .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) + .add("compare_to", SerializableDataTypes.INT, 1), + (data, entity) -> condition(entity, + data.get("block_condition"), + data.get("radius"), + data.get("shape"), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BrightnessCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BrightnessConditionType.java similarity index 51% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BrightnessCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BrightnessConditionType.java index 02abdb613..58fd8a2c8 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BrightnessCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/BrightnessConditionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.core.BlockPos; @@ -11,16 +11,17 @@ import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; -public class BrightnessCondition { +public class BrightnessConditionType { - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Entity entity) { - Level world = entity.level(); + public static boolean condition(@NotNull Entity entity, Comparison comparison, float compareTo) { - Comparison comparison = data.get("comparison"); - float compareTo = data.get("compare_to"); + Level world = entity.level(); + if (world.isClientSide) { + world.updateSkyBrightness(); + } - BlockPos blockPos = BlockPos.containing(entity.getX(), entity.getY() + entity.getEyeHeight(entity.getPose()), entity.getZ()); - float brightness = world.getLightLevelDependentMagicValue(blockPos); + BlockPos pos = BlockPos.containing(entity.getX(), entity.getBoundingBox().maxY, entity.getZ()); + float brightness = world.getLightLevelDependentMagicValue(pos); return comparison.compare(brightness, compareTo); @@ -29,10 +30,14 @@ public static boolean condition(@NotNull SerializableData.Instance data, @NotNul public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("brightness"), - SerializableData.serializableData() + new SerializableData() .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.FLOAT), - BrightnessCondition::condition + (data, entity) -> condition(entity, + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/CommandCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/CommandConditionType.java similarity index 61% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/CommandCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/CommandConditionType.java index 578d896e8..76f5e4256 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/CommandCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/CommandConditionType.java @@ -1,23 +1,22 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; import java.util.concurrent.atomic.AtomicInteger; -public class CommandCondition { +public class CommandConditionType { - public static boolean condition(SerializableData.Instance data, @NotNull Entity entity) { + public static boolean condition(@NotNull Entity entity, String command, Comparison comparison, int compareTo) { MinecraftServer server = entity.getServer(); AtomicInteger result = new AtomicInteger(); @@ -26,20 +25,12 @@ public static boolean condition(SerializableData.Instance data, @NotNull Entity return false; } - CommandSource commandOutput = OriginsPaper.showCommandOutput && (!(entity instanceof ServerPlayer player) || player.connection != null) - ? entity - : CommandSource.NULL; CommandSourceStack source = entity.createCommandSourceStack() - .withSource(commandOutput) + .withSource(OriginsPaper.showCommandOutput ? entity : CommandSource.NULL) .withPermission(4) .withCallback((successful, returnValue) -> result.set(returnValue)); - Comparison comparison = data.get("comparison"); - String command = data.get("command"); - - int compareTo = data.get("compare_to"); server.getCommands().performPrefixedCommand(source, command); - return comparison.compare(result.get(), compareTo); } @@ -47,11 +38,16 @@ public static boolean condition(SerializableData.Instance data, @NotNull Entity public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("command"), - SerializableData.serializableData() + new SerializableData() .add("command", SerializableDataTypes.STRING) .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.INT), - CommandCondition::condition + (data, entity) -> condition(entity, + data.get("command"), + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/DimensionConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/DimensionConditionType.java new file mode 100644 index 000000000..031472832 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/DimensionConditionType.java @@ -0,0 +1,29 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +public class DimensionConditionType { + + public static boolean condition(@NotNull Entity entity, ResourceKey dimensionKey) { + return entity.level().dimension().equals(dimensionKey); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("dimension"), + new SerializableData() + .add("dimension", SerializableDataTypes.DIMENSION), + (data, entity) -> condition(entity, + data.get("dimension") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ElytraFlightPossibleConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ElytraFlightPossibleConditionType.java new file mode 100644 index 000000000..e3666b54b --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ElytraFlightPossibleConditionType.java @@ -0,0 +1,56 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.type.ElytraFlightPower; +import io.github.dueris.originspaper.storage.PowerHolderComponent; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ElytraItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; + +public class ElytraFlightPossibleConditionType { + + public static boolean condition(Entity entity, boolean checkState, boolean checkAbility) { + + if (!(entity instanceof LivingEntity living)) { + return false; + } + + boolean state = true; + boolean ability = true; + + if (checkAbility) { + ItemStack equippedChestStack = living.getItemBySlot(EquipmentSlot.CHEST); + ability = (equippedChestStack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(equippedChestStack) || + PowerHolderComponent.doesHaveConditionedPower(living.getBukkitEntity(), ElytraFlightPower.class, (p) -> p.getGlidingPlayers().contains(living.getBukkitEntity().getUniqueId()))); + } + + if (checkState) { + state = !living.onGround() + && !living.isFallFlying() + && !living.isInWater() + && !living.hasEffect(MobEffects.LEVITATION); + } + + return ability && state; + + } + + public static ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>(OriginsPaper.apoliIdentifier("elytra_flight_possible"), + new SerializableData() + .add("check_state", SerializableDataTypes.BOOLEAN, false) + .add("check_ability", SerializableDataTypes.BOOLEAN, true), + (data, entity) -> condition(entity, + data.get("check_state"), + data.get("check_ability") + ) + ); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EnchantmentCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EnchantmentConditionType.java similarity index 92% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EnchantmentCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EnchantmentConditionType.java index b16a4b88f..65d86c216 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EnchantmentCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EnchantmentConditionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.core.Holder; @@ -16,7 +16,7 @@ import net.minecraft.world.item.enchantment.Enchantment; import org.jetbrains.annotations.NotNull; -public class EnchantmentCondition { +public class EnchantmentConditionType { public static boolean condition(@NotNull Entity entity, ResourceKey enchantmentKey, Calculation calculation, Comparison comparison, int compareTo, boolean useModifications) { @@ -34,7 +34,7 @@ public static boolean condition(@NotNull Entity entity, ResourceKey public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("enchantment"), - SerializableData.serializableData() + new SerializableData() .add("enchantment", SerializableDataTypes.ENCHANTMENT) .add("calculation", SerializableDataTypes.enumValue(Calculation.class), Calculation.SUM) .add("comparison", ApoliDataTypes.COMPARISON) @@ -93,4 +93,5 @@ public int queryTotalLevel(LivingEntity entity, @NotNull Holder enc public abstract int queryLevel(ItemStack stack, Holder enchantmentEntry, boolean useModifications, int totalLevel); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EntityInRadiusCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EntityInRadiusConditionType.java similarity index 65% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EntityInRadiusCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EntityInRadiusConditionType.java index 30bbbfb0d..073d74226 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EntityInRadiusCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EntityInRadiusConditionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import io.github.dueris.originspaper.data.types.Shape; @@ -13,17 +13,10 @@ import java.util.function.Predicate; -public class EntityInRadiusCondition { +public class EntityInRadiusConditionType { - public static boolean condition(@NotNull SerializableData.Instance data, Entity entity) { + public static boolean condition(Entity entity, Predicate> biEntityCondition, Shape shape, double radius, @NotNull Comparison comparison, int compareTo) { - Predicate> biEntityCondition = data.get("bientity_condition"); - Shape shape = data.get("shape"); - - Comparison comparison = data.get("comparison"); - int compareTo = data.get("compare_to"); - - double radius = data.get("radius"); int countThreshold = switch (comparison) { case EQUAL, LESS_THAN_OR_EQUAL, GREATER_THAN -> compareTo + 1; case LESS_THAN, GREATER_THAN_OR_EQUAL -> compareTo; @@ -50,13 +43,20 @@ public static boolean condition(@NotNull SerializableData.Instance data, Entity public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("entity_in_radius"), - SerializableData.serializableData() + new SerializableData() .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION) .add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE) .add("radius", SerializableDataTypes.DOUBLE) - .add("compare_to", SerializableDataTypes.INT, 1) - .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL), - EntityInRadiusCondition::condition + .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) + .add("compare_to", SerializableDataTypes.INT, 1), + (data, entity) -> condition(entity, + data.get("bientity_condition"), + data.get("shape"), + data.get("radius"), + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EntitySetSizeConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EntitySetSizeConditionType.java new file mode 100644 index 000000000..6807e5423 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EntitySetSizeConditionType.java @@ -0,0 +1,39 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +// TODO - EntitySets - Dueris +public class EntitySetSizeConditionType { + + public static boolean condition(Entity entity, PowerReference power, @NotNull Comparison comparison, int compareTo) { + + int setSize = 0; + + return comparison.compare(setSize, compareTo); + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("entity_set_size"), + new SerializableData() + .add("set", ApoliDataTypes.POWER_REFERENCE) + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, entity) -> condition(entity, + data.get("set"), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EntityTypeConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EntityTypeConditionType.java new file mode 100644 index 000000000..92447fc76 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EntityTypeConditionType.java @@ -0,0 +1,28 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import org.jetbrains.annotations.NotNull; + +public class EntityTypeConditionType { + + public static boolean condition(@NotNull Entity entity, EntityType entityType) { + return entity.getType().equals(entityType); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("entity_type"), + new SerializableData() + .add("entity_type", SerializableDataTypes.ENTITY_TYPE), + (data, entity) -> condition(entity, + data.get("entity_type") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EquippedCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EquippedConditionType.java similarity index 59% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EquippedCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EquippedConditionType.java index 8eaa10c28..46e9eef5d 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EquippedCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/EquippedConditionType.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import net.minecraft.util.Tuple; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -14,21 +15,24 @@ import java.util.function.Predicate; -public class EquippedCondition { +public class EquippedConditionType { - public static boolean condition(@NotNull SerializableData.Instance data, Entity entity) { - Predicate> itemCondition = data.get("item_condition"); + public static boolean condition(Entity entity, Predicate> itemCondition, EquipmentSlot equipmentSlot) { return entity instanceof LivingEntity livingEntity - && itemCondition.test(new Tuple<>(livingEntity.level(), livingEntity.getItemBySlot(data.get("equipment_slot")))); + && itemCondition.test(new Tuple<>(livingEntity.level(), livingEntity.getItemBySlot(equipmentSlot))); } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("equipped_item"), - SerializableData.serializableData() + new SerializableData() .add("equipment_slot", SerializableDataTypes.EQUIPMENT_SLOT) .add("item_condition", ApoliDataTypes.ITEM_CONDITION), - EquippedCondition::condition + (data, entity) -> condition(entity, + data.get("item_condition"), + data.get("equipment_slot") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ExposedToSkyConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ExposedToSkyConditionType.java new file mode 100644 index 000000000..2d0f9f430 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ExposedToSkyConditionType.java @@ -0,0 +1,20 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +public class ExposedToSkyConditionType { + + public static boolean condition(@NotNull Entity entity) { + + Level world = entity.level(); + BlockPos pos = BlockPos.containing(entity.position()); + + return world.canSeeSky(pos.above()) + || world.canSeeSky(pos); + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ExposedToSunConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ExposedToSunConditionType.java new file mode 100644 index 000000000..2b5076d1f --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ExposedToSunConditionType.java @@ -0,0 +1,23 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +public class ExposedToSunConditionType { + + public static boolean condition(@NotNull Entity entity) { + + Level world = entity.level(); + BlockPos pos = BlockPos.containing(entity.getX(), entity.getBoundingBox().maxY, entity.getZ()); + + return world.isDay() + && !InRainConditionType.condition(entity) + && BrightnessConditionType.condition(entity, Comparison.GREATER_THAN, 0.5F) + && world.canSeeSky(pos); + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FallDistanceCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/FallDistanceConditionType.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FallDistanceCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/FallDistanceConditionType.java index 255a69665..2e642994a 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FallDistanceCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/FallDistanceConditionType.java @@ -1,23 +1,31 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; -public class FallDistanceCondition { +public class FallDistanceConditionType { + + public static boolean condition(@NotNull Entity entity, @NotNull Comparison comparison, float compareTo) { + return comparison.compare(entity.fallDistance, compareTo); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("fall_distance"), - SerializableData.serializableData() + new SerializableData() .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.FLOAT), - (data, entity) -> ((Comparison) data.get("comparison")).compare(entity.fallDistance, data.getFloat("compare_to")) + (data, entity) -> condition(entity, + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/FluidHeightConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/FluidHeightConditionType.java new file mode 100644 index 000000000..135fc0eb6 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/FluidHeightConditionType.java @@ -0,0 +1,36 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import io.github.dueris.originspaper.util.Util; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.material.Fluid; +import org.jetbrains.annotations.NotNull; + +public class FluidHeightConditionType { + + public static boolean condition(Entity entity, TagKey fluidTag, @NotNull Comparison comparison, double compareTo) { + return comparison.compare(Util.apoli$getFluidHeightLoosely(entity, fluidTag), compareTo); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("fluid_height"), + new SerializableData() + .add("fluid", SerializableDataTypes.FLUID_TAG) + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.DOUBLE), + (data, entity) -> condition(entity, + data.get("fluid"), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FoodLevelCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/FoodLevelConditionType.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FoodLevelCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/FoodLevelConditionType.java index 7f057764e..84ba26c72 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FoodLevelCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/FoodLevelConditionType.java @@ -1,29 +1,33 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.NotNull; -public class FoodLevelCondition { +public class FoodLevelConditionType { + + public static boolean condition(Entity entity, Comparison comparison, int compareTo) { + return entity instanceof Player player + && comparison.compare(player.getFoodData().getFoodLevel(), compareTo); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("food_level"), - SerializableData.serializableData() + new SerializableData() .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.INT), - (data, entity) -> { - if (entity instanceof Player) { - return ((Comparison) data.get("comparison")).compare(((Player) entity).getFoodData().getFoodLevel(), data.getInt("compare_to")); - } - return false; - } + (data, entity) -> condition(entity, + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/GameModeConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/GameModeConditionType.java new file mode 100644 index 000000000..432bf90ba --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/GameModeConditionType.java @@ -0,0 +1,40 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerPlayerGameMode; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.GameType; +import org.jetbrains.annotations.NotNull; + +public class GameModeConditionType { + + public static boolean condition(Entity entity, GameType gameMode) { + + if (!(entity instanceof Player player)) { + return false; + } else if (player instanceof ServerPlayer serverPlayer) { + ServerPlayerGameMode interactionManager = serverPlayer.gameMode; + return interactionManager.getGameModeForPlayer() == gameMode; + } else { + return false; + } + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("gamemode"), + new SerializableData() + .add("gamemode", ApoliDataTypes.GAME_MODE), + (data, entity) -> condition(entity, + data.get("gamemode") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/HasCommandTagConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/HasCommandTagConditionType.java new file mode 100644 index 000000000..c2409259f --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/HasCommandTagConditionType.java @@ -0,0 +1,43 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +public class HasCommandTagConditionType { + + public static boolean condition(@NotNull Entity entity, @NotNull Collection specifiedCommandTags) { + Set commandTags = entity.getTags(); + return specifiedCommandTags.isEmpty() + ? !commandTags.isEmpty() + : !Collections.disjoint(commandTags, specifiedCommandTags); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("has_command_tag"), + new SerializableData() + .add("command_tag", SerializableDataTypes.STRING, null) + .add("command_tags", SerializableDataTypes.STRINGS, null), + (data, entity) -> { + + Collection commandTags = new HashSet<>(); + + data.ifPresent("command_tag", commandTags::add); + data.ifPresent("command_tags", commandTags::addAll); + + return condition(entity, commandTags); + + } + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/HealthConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/HealthConditionType.java new file mode 100644 index 000000000..b2f54eb17 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/HealthConditionType.java @@ -0,0 +1,33 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +public class HealthConditionType { + + public static boolean condition(Entity entity, Comparison comparison, int compareTo) { + return entity instanceof LivingEntity living + && comparison.compare(living.getHealth(), compareTo); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("health"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, entity) -> condition(entity, + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InBlockAnywhereConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InBlockAnywhereConditionType.java new file mode 100644 index 000000000..2a3f01403 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InBlockAnywhereConditionType.java @@ -0,0 +1,67 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import net.minecraft.world.phys.AABB; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class InBlockAnywhereConditionType { + + public static boolean condition(@NotNull Entity entity, Predicate blockCondition, @NotNull Comparison comparison, int compareTo) { + + AABB boundingBox = entity.getBoundingBox(); + int countThreshold = switch (comparison) { + case EQUAL, LESS_THAN_OR_EQUAL, GREATER_THAN -> compareTo + 1; + case LESS_THAN, GREATER_THAN_OR_EQUAL -> compareTo; + default -> -1; + }; + + BlockPos minPos = BlockPos.containing(boundingBox.minX + 0.001D, boundingBox.minY + 0.001D, boundingBox.minZ + 0.001D); + BlockPos maxPos = BlockPos.containing(boundingBox.maxX - 0.001D, boundingBox.maxY - 0.001D, boundingBox.maxZ - 0.001D); + + BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); + int count = 0; + + for (int x = minPos.getX(); x <= maxPos.getX() && count < countThreshold; x++) { + for (int y = minPos.getY(); y <= maxPos.getY() && count < countThreshold; y++) { + for (int z = minPos.getZ(); z <= maxPos.getZ() && count < countThreshold; z++) { + + mutablePos.set(x, y, z); + + if (blockCondition.test(new BlockInWorld(entity.level(), mutablePos, true))) { + count++; + } + + } + } + } + + return comparison.compare(count, compareTo); + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("in_block_anywhere"), + new SerializableData() + .add("block_condition", ApoliDataTypes.BLOCK_CONDITION) + .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) + .add("compare_to", SerializableDataTypes.INT, 1), + (data, entity) -> condition(entity, + data.get("block_condition"), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InBlockConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InBlockConditionType.java new file mode 100644 index 000000000..004465805 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InBlockConditionType.java @@ -0,0 +1,30 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class InBlockConditionType { + + public static boolean condition(@NotNull Entity entity, @NotNull Predicate blockCondition) { + return blockCondition.test(new BlockInWorld(entity.level(), entity.blockPosition(), true)); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("in_block"), + new SerializableData() + .add("block_condition", ApoliDataTypes.BLOCK_CONDITION), + (data, entity) -> condition(entity, + data.get("block_condition") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InRainConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InRainConditionType.java new file mode 100644 index 000000000..a4e60c7ac --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InRainConditionType.java @@ -0,0 +1,11 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import net.minecraft.world.entity.Entity; + +public class InRainConditionType { + + public static boolean condition(Entity entity) { + return entity.isInRain(); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InSnowConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InSnowConditionType.java new file mode 100644 index 000000000..a578f8f3a --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InSnowConditionType.java @@ -0,0 +1,19 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.originspaper.util.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class InSnowConditionType { + + public static boolean condition(@NotNull Entity entity) { + + BlockPos downBlockPos = entity.blockPosition(); + BlockPos upBlockPos = BlockPos.containing(downBlockPos.getX(), entity.getBoundingBox().maxY, downBlockPos.getZ()); + + return Util.inSnow(entity.level(), downBlockPos, upBlockPos); + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InTagConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InTagConditionType.java new file mode 100644 index 000000000..5fd6dcf96 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InTagConditionType.java @@ -0,0 +1,29 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import org.jetbrains.annotations.NotNull; + +public class InTagConditionType { + + public static boolean condition(@NotNull Entity entity, TagKey> entityTag) { + return entity.getType().is(entityTag); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("in_tag"), + new SerializableData() + .add("tag", SerializableDataTypes.ENTITY_TAG), + (data, entity) -> condition(entity, + data.get("tag") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InThunderstormConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InThunderstormConditionType.java new file mode 100644 index 000000000..0fd340415 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InThunderstormConditionType.java @@ -0,0 +1,19 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.originspaper.util.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class InThunderstormConditionType { + + public static boolean condition(@NotNull Entity entity) { + + BlockPos downBlockPos = entity.blockPosition(); + BlockPos upBlockPos = BlockPos.containing(downBlockPos.getX(), entity.getBoundingBox().maxY, downBlockPos.getZ()); + + return Util.inThunderstorm(entity.level(), downBlockPos, upBlockPos); + + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InventoryCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InventoryConditionType.java similarity index 79% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InventoryCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InventoryConditionType.java index 501e3dae6..0aff3220d 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InventoryCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/InventoryConditionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import io.github.dueris.originspaper.data.types.InventoryType; @@ -14,9 +14,9 @@ import java.util.EnumSet; import java.util.Set; -public class InventoryCondition { +public class InventoryConditionType { - public static boolean condition(@NotNull SerializableData.Instance data, Entity entity) { + public static boolean condition(SerializableData.@NotNull Instance data, Entity entity) { Set inventoryTypes = data.get("inventory_types"); Util.ProcessMode processMode = data.get("process_mode"); @@ -36,15 +36,17 @@ public static boolean condition(@NotNull SerializableData.Instance data, Entity public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("inventory"), - SerializableData.serializableData() + new SerializableData() .add("inventory_types", SerializableDataTypes.enumSet(InventoryType.class, ApoliDataTypes.INVENTORY_TYPE), EnumSet.of(InventoryType.INVENTORY)) .add("process_mode", ApoliDataTypes.PROCESS_MODE, Util.ProcessMode.ITEMS) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) .add("slots", SerializableDataTypes.list(ApoliDataTypes.ITEM_SLOT), null) .add("slot", ApoliDataTypes.ITEM_SLOT, null) + .add("power", ApoliDataTypes.POWER_REFERENCE, null) .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN) .add("compare_to", SerializableDataTypes.INT, 0), - InventoryCondition::condition + InventoryConditionType::condition ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/MovingConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/MovingConditionType.java new file mode 100644 index 000000000..78fef9d48 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/MovingConditionType.java @@ -0,0 +1,31 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.EntityConditions; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class MovingConditionType { + + public static boolean condition(Entity entity, boolean horizontally, boolean vertically) { + return (horizontally && EntityConditions.isEntityMovingHorizontal(entity)) + || (vertically && EntityConditions.isEntityMovingVertical(entity)); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("moving"), + new SerializableData() + .add("horizontally", SerializableDataTypes.BOOLEAN, true) + .add("vertically", SerializableDataTypes.BOOLEAN, true), + (data, entity) -> condition(entity, + data.get("horizontally"), + data.get("vertically") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/NbtConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/NbtConditionType.java new file mode 100644 index 000000000..17332f96d --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/NbtConditionType.java @@ -0,0 +1,29 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class NbtConditionType { + + public static boolean condition(@NotNull Entity entity, CompoundTag nbt) { + return NbtUtils.compareNbt(nbt, entity.saveWithoutId(new CompoundTag()), true); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("nbt"), + new SerializableData() + .add("nbt", SerializableDataTypes.NBT_COMPOUND), + (data, entity) -> condition(entity, + data.get("nbt") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/OnBlockConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/OnBlockConditionType.java new file mode 100644 index 000000000..8f04a15de --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/OnBlockConditionType.java @@ -0,0 +1,33 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.state.pattern.BlockInWorld; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class OnBlockConditionType { + + public static boolean condition(@NotNull Entity entity, Predicate blockCondition) { + BlockPos pos = BlockPos.containing(entity.getX(), entity.getBoundingBox().minY - 0.5000001D, entity.getY()); + return entity.onGround() + && blockCondition.test(new BlockInWorld(entity.level(), pos, true)); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("on_block"), + new SerializableData() + .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null), + (data, entity) -> condition(entity, + data.getOrElse("block_condition", cachedBlock -> true) + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PassengerConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PassengerConditionType.java new file mode 100644 index 000000000..25a2b22bb --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PassengerConditionType.java @@ -0,0 +1,44 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class PassengerConditionType { + + public static boolean condition(@NotNull Entity entity, Predicate> biEntityCondition, @NotNull Comparison comparison, int compareTo) { + + int matches = (int) entity.getPassengers() + .stream() + .map(passenger -> new Tuple<>(passenger, entity)) + .filter(biEntityCondition) + .count(); + + return comparison.compare(matches, compareTo); + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("passenger"), + new SerializableData() + .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) + .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) + .add("compare_to", SerializableDataTypes.INT, 1), + (data, entity) -> condition(entity, + data.getOrElse("bientity_condition", actorAndTarget -> true), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PassengerRecursiveConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PassengerRecursiveConditionType.java new file mode 100644 index 000000000..e0356f9cd --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PassengerRecursiveConditionType.java @@ -0,0 +1,45 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class PassengerRecursiveConditionType { + + public static boolean condition(@NotNull Entity entity, Predicate> biEntityCondition, @NotNull Comparison comparison, int compareTo) { + + int matches = (int) entity.getPassengers() + .stream() + .flatMap(Entity::getSelfAndPassengers) + .map(passenger -> new Tuple<>(entity, passenger)) + .filter(biEntityCondition) + .count(); + + return comparison.compare(matches, compareTo); + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("passenger_recursive"), + new SerializableData() + .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) + .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) + .add("compare_to", SerializableDataTypes.INT, 1), + (data, entity) -> condition(entity, + data.getOrElse("bientity_condition", actorAndTarget -> true), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PowerActiveConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PowerActiveConditionType.java new file mode 100644 index 000000000..9d3d1f0b1 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PowerActiveConditionType.java @@ -0,0 +1,28 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class PowerActiveConditionType { + + public static boolean condition(Entity entity, @NotNull PowerReference powerReference) { + return powerReference.getType() != null && powerReference.getType().isActive(entity); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("power_active"), + new SerializableData() + .add("power", ApoliDataTypes.POWER_REFERENCE), + (data, entity) -> condition(entity, + data.get("power") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PowerConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PowerConditionType.java new file mode 100644 index 000000000..a40a3b02c --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PowerConditionType.java @@ -0,0 +1,41 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.origin.OriginLayer; +import io.github.dueris.originspaper.power.factory.PowerReference; +import io.github.dueris.originspaper.storage.PlayerPowerRepository; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class PowerConditionType { + + public static boolean condition(Entity entity, PowerReference power, @Nullable ResourceLocation source) { + OriginLayer layer = source == null ? null : OriginsPaper.getLayer(source); + if (entity instanceof Player player) { + return PlayerPowerRepository.getOrCreateRepo((ServerPlayer) player).getAppliedPowers(layer).contains(power.getType()); + } + return false; + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("power"), + new SerializableData() + .add("power", ApoliDataTypes.POWER_REFERENCE) + .add("source", SerializableDataTypes.IDENTIFIER, null), + (data, entity) -> condition(entity, + data.get("power"), + data.get("source") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PowerTypeConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PowerTypeConditionType.java new file mode 100644 index 000000000..ff88ef6eb --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PowerTypeConditionType.java @@ -0,0 +1,29 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.storage.PowerHolderComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class PowerTypeConditionType { + + public static boolean condition(@NotNull Entity entity, ResourceLocation powerTypeFactory) { + return PowerHolderComponent.hasPowerType(entity.getBukkitEntity(), powerTypeFactory); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("power_type"), + new SerializableData() + .add("power_type", SerializableDataTypes.IDENTIFIER), + (data, entity) -> condition(entity, + data.get("power_type") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/PredicateCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PredicateConditionType.java similarity index 70% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/PredicateCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PredicateConditionType.java index 9219fc9bf..3aaa64850 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/PredicateCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/PredicateConditionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerLevel; @@ -17,37 +17,36 @@ import java.util.Optional; -public class PredicateCondition { +public class PredicateConditionType { - public static boolean condition(SerializableData.Instance data, @NotNull Entity entity) { + public static boolean condition(@NotNull Entity entity, ResourceKey predicateKey) { if (!(entity.level() instanceof ServerLevel serverWorld)) { return false; } - ResourceKey predicateKey = data.get("predicate"); LootItemCondition predicate = serverWorld.getServer().reloadableRegistries() .get() .registryOrThrow(Registries.PREDICATE) .getOrThrow(predicateKey); - LootParams lootContextParameterSet = new LootParams.Builder(serverWorld) .withParameter(LootContextParams.ORIGIN, entity.position()) .withOptionalParameter(LootContextParams.THIS_ENTITY, entity) .create(LootContextParamSets.COMMAND); - LootContext lootContext = new LootContext.Builder(lootContextParameterSet) - .create(Optional.empty()); - return predicate.test(lootContext); + return predicate.test(new LootContext.Builder(lootContextParameterSet).create(Optional.empty())); } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("predicate"), - SerializableData.serializableData() + new SerializableData() .add("predicate", SerializableDataTypes.PREDICATE), - PredicateCondition::condition + (data, entity) -> condition(entity, + data.get("predicate") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RaycastCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RaycastConditionType.java similarity index 82% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RaycastCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RaycastConditionType.java index 24e9ff247..d622ef061 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RaycastCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RaycastConditionType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Space; import net.minecraft.util.Tuple; @@ -14,14 +14,13 @@ import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import net.minecraft.world.phys.*; -import org.jetbrains.annotations.NotNull; import org.joml.Vector3f; import java.util.function.Predicate; -public class RaycastCondition { +public class RaycastConditionType { - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Entity entity) { + public static boolean condition(SerializableData.Instance data, Entity entity) { Vec3 origin = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ()); Vec3 direction = entity.getViewVector(1); @@ -68,7 +67,7 @@ public static boolean condition(@NotNull SerializableData.Instance data, @NotNul return false; } - private static double getEntityReach(@NotNull SerializableData.Instance data, Entity entity) { + private static double getEntityReach(SerializableData.Instance data, Entity entity) { if (!data.isPresent("entity_distance") && !data.isPresent("distance")) { return entity instanceof LivingEntity livingEntity && livingEntity.getAttributes().hasAttribute(Attributes.ENTITY_INTERACTION_RANGE) @@ -83,7 +82,7 @@ private static double getEntityReach(@NotNull SerializableData.Instance data, En } - private static double getBlockReach(@NotNull SerializableData.Instance data, Entity entity) { + private static double getBlockReach(SerializableData.Instance data, Entity entity) { if (!data.isPresent("block_distance") && !data.isPresent("distance")) { return entity instanceof LivingEntity livingEntity && livingEntity.getAttributes().hasAttribute(Attributes.ENTITY_INTERACTION_RANGE) @@ -97,12 +96,12 @@ private static double getBlockReach(@NotNull SerializableData.Instance data, Ent } - private static @NotNull BlockHitResult performBlockRaycast(Entity source, Vec3 origin, Vec3 target, ClipContext.Block shapeType, ClipContext.Fluid fluidHandling) { + private static BlockHitResult performBlockRaycast(Entity source, Vec3 origin, Vec3 target, ClipContext.Block shapeType, ClipContext.Fluid fluidHandling) { ClipContext context = new ClipContext(origin, target, shapeType, fluidHandling, source); return source.level().clip(context); } - private static EntityHitResult performEntityRaycast(@NotNull Entity source, Vec3 origin, @NotNull Vec3 target, ConditionTypeFactory> biEntityCondition) { + private static EntityHitResult performEntityRaycast(Entity source, Vec3 origin, Vec3 target, ConditionTypeFactory> biEntityCondition) { Vec3 ray = target.subtract(origin); AABB box = source.getBoundingBox().expandTowards(ray).inflate(1.0D, 1.0D, 1.0D); EntityHitResult entityHitResult = ProjectileUtil.getEntityHitResult(source, origin, target, box, (entityx) -> { @@ -111,9 +110,9 @@ private static EntityHitResult performEntityRaycast(@NotNull Entity source, Vec3 return entityHitResult; } - public static @NotNull ConditionTypeFactory getFactory() { + public static ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>(OriginsPaper.apoliIdentifier("raycast"), - SerializableData.serializableData() + new SerializableData() .add("distance", SerializableDataTypes.DOUBLE, null) .add("block_distance", SerializableDataTypes.DOUBLE, null) .add("entity_distance", SerializableDataTypes.DOUBLE, null) @@ -126,7 +125,7 @@ private static EntityHitResult performEntityRaycast(@NotNull Entity source, Vec3 .add("match_bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("hit_bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null), - RaycastCondition::condition + RaycastConditionType::condition ); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RelativeHealthConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RelativeHealthConditionType.java new file mode 100644 index 000000000..9443fd42b --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RelativeHealthConditionType.java @@ -0,0 +1,33 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +public class RelativeHealthConditionType { + + public static boolean condition(Entity entity, Comparison comparison, int compareTo) { + return entity instanceof LivingEntity living + && comparison.compare(living.getHealth() / living.getMaxHealth(), compareTo); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("relative_health"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, entity) -> condition(entity, + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ResourceConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ResourceConditionType.java new file mode 100644 index 000000000..40ab38782 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ResourceConditionType.java @@ -0,0 +1,44 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import io.github.dueris.originspaper.power.type.CooldownPower; +import io.github.dueris.originspaper.power.type.ResourcePower; +import io.github.dueris.originspaper.power.factory.PowerReference; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class ResourceConditionType { + + public static boolean condition(Entity entity, PowerReference power, @NotNull Comparison comparison, int compareTo) { + return comparison.compare(getResourceValue(entity, power), compareTo); + } + + private static int getResourceValue(Entity entity, PowerReference power) { + return switch (power.getType()) { + case ResourcePower varInt -> varInt.getValue(entity); + case CooldownPower cooldown -> cooldown.getRemainingTicks(entity); + case null, default -> 0; + }; + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("resource"), + new SerializableData() + .add("resource", ApoliDataTypes.POWER_REFERENCE) + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, entity) -> condition(entity, + data.get("resource"), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RidingConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RidingConditionType.java new file mode 100644 index 000000000..b8eba2ccd --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RidingConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class RidingConditionType { + + public static boolean condition(@NotNull Entity entity, Predicate> biEntityCondition) { + Entity vehicle = entity.getVehicle(); + return vehicle != null + && biEntityCondition.test(new Tuple<>(entity, vehicle)); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("riding"), + new SerializableData() + .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null), + (data, entity) -> condition(entity, + data.getOrElse("bientity_condition", actorAndTarget -> true) + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RidingRecursiveConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RidingRecursiveConditionType.java new file mode 100644 index 000000000..8b9edf771 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RidingRecursiveConditionType.java @@ -0,0 +1,55 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class RidingRecursiveConditionType { + + public static boolean condition(@NotNull Entity entity, Predicate> biEntityCondition, Comparison comparison, int compareTo) { + + Entity vehicle = entity.getVehicle(); + int matches = 0; + + if (vehicle == null) { + return comparison.compare(matches, compareTo); + } + + while (vehicle != null) { + + if (biEntityCondition.test(new Tuple<>(entity, vehicle))) { + matches++; + } + + vehicle = vehicle.getVehicle(); + + } + + return comparison.compare(matches, compareTo); + + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("riding_recursive"), + new SerializableData() + .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) + .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) + .add("compare_to", SerializableDataTypes.INT, 1), + (data, entity) -> condition(entity, + data.getOrElse("bientity_condition", actorAndTarget -> true), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RidingRootConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RidingRootConditionType.java new file mode 100644 index 000000000..74a968b38 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/RidingRootConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Predicate; + +public class RidingRootConditionType { + + public static boolean condition(@NotNull Entity entity, Predicate> biEntityCondition) { + Entity vehicle = entity.getRootVehicle(); + return vehicle != null + && biEntityCondition.test(new Tuple<>(entity, vehicle)); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("riding_root"), + new SerializableData() + .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null), + (data, entity) -> condition(entity, + data.getOrElse("bientity_condition", actorAndTarget -> true) + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SaturationLevelCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/SaturationLevelConditionType.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SaturationLevelCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/SaturationLevelConditionType.java index 42c860683..b468e1d4b 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SaturationLevelCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/SaturationLevelConditionType.java @@ -1,29 +1,33 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Comparison; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.NotNull; -public class SaturationLevelCondition { +public class SaturationLevelConditionType { + + public static boolean condition(Entity entity, Comparison comparison, float compareTo) { + return entity instanceof Player player + && comparison.compare(player.getFoodData().getSaturationLevel(), compareTo); + } public static @NotNull ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("saturation_level"), - SerializableData.serializableData() + new SerializableData() .add("comparison", ApoliDataTypes.COMPARISON) .add("compare_to", SerializableDataTypes.FLOAT), - (data, entity) -> { - if (entity instanceof Player) { - return ((Comparison) data.get("comparison")).compare(((Player) entity).getFoodData().getSaturationLevel(), data.getFloat("compare_to")); - } - return false; - } + (data, entity) -> condition(entity, + data.get("comparison"), + data.get("compare_to") + ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ScoreboardConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ScoreboardConditionType.java new file mode 100644 index 000000000..1a370ca9e --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/ScoreboardConditionType.java @@ -0,0 +1,47 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.scores.ScoreHolder; +import net.minecraft.world.scores.Scoreboard; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; + +public class ScoreboardConditionType { + + public static boolean condition(Entity entity, @Nullable String holderName, String objectiveName, Comparison comparison, int compareTo) { + + ScoreHolder scoreHolder = ScoreHolder.forNameOnly(holderName != null ? holderName : entity.getScoreboardName()); + Scoreboard scoreboard = entity.level().getScoreboard(); + + return Optional.ofNullable(scoreboard.getObjective(objectiveName)) + .map(objective -> scoreboard.getOrCreatePlayerScore(scoreHolder, objective)) + .map(scoreAccess -> comparison.compare(scoreAccess.get(), compareTo)) + .orElse(false); + + } + + public static ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("scoreboard"), + new SerializableData() + .add("name", SerializableDataTypes.STRING, null) + .add("objective", SerializableDataTypes.STRING) + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, entity) -> condition(entity, + data.get("name"), + data.get("objective"), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/StatusEffectCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/StatusEffectConditionType.java similarity index 85% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/StatusEffectCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/StatusEffectConditionType.java index 9a52b82db..09c5f20e2 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/StatusEffectCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/StatusEffectConditionType.java @@ -1,16 +1,17 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import net.minecraft.core.Holder; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; -public class StatusEffectCondition { +public class StatusEffectConditionType { + public static boolean condition(Entity entity, Holder effect, int minAmplifier, int maxAmplifier, int minDuration, int maxDuration) { if (!(entity instanceof LivingEntity living)) { @@ -33,7 +34,7 @@ public static boolean condition(Entity entity, Holder effect, int min public static ConditionTypeFactory getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("status_effect"), - SerializableData.serializableData() + new SerializableData() .add("effect", SerializableDataTypes.STATUS_EFFECT_ENTRY) .add("min_amplifier", SerializableDataTypes.INT, 0) .add("max_amplifier", SerializableDataTypes.INT, Integer.MAX_VALUE) @@ -48,4 +49,5 @@ public static ConditionTypeFactory getFactory() { ) ); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/SubmergedInConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/SubmergedInConditionType.java new file mode 100644 index 000000000..72168b07e --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/SubmergedInConditionType.java @@ -0,0 +1,30 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.util.Util; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.material.Fluid; +import org.jetbrains.annotations.NotNull; + +public class SubmergedInConditionType { + + public static boolean condition(Entity entity, TagKey fluidTag) { + return Util.apoli$isSubmergedInLoosely(entity, fluidTag); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("submerged_in"), + new SerializableData() + .add("fluid", SerializableDataTypes.FLUID_TAG), + (data, entity) -> condition(entity, + data.get("fluid") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/TimeOfDayConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/TimeOfDayConditionType.java new file mode 100644 index 000000000..e8d2c031d --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/TimeOfDayConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +public class TimeOfDayConditionType { + + public static boolean condition(@NotNull Level world, @NotNull Comparison comparison, int compareTo) { + return comparison.compare(world.getDayTime() % 24000L, compareTo); + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("time_of_day"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, entity) -> condition(entity.level(), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/UsingEffectiveToolCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/UsingEffectiveToolConditionType.java similarity index 57% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/UsingEffectiveToolCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/UsingEffectiveToolConditionType.java index 5cdd39804..4d554e606 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/UsingEffectiveToolCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/UsingEffectiveToolConditionType.java @@ -1,8 +1,5 @@ -package io.github.dueris.originspaper.condition.types.entity; +package io.github.dueris.originspaper.condition.type.entity; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; import io.github.dueris.originspaper.util.Reflector; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; @@ -12,17 +9,17 @@ import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.Nullable; -public class UsingEffectiveToolCondition { +public class UsingEffectiveToolConditionType { - public static boolean condition(SerializableData.Instance data, Entity entity) { + public static boolean condition(Entity entity) { if (!(entity instanceof Player playerEntity)) { return false; } - if (playerEntity instanceof ServerPlayer serverPlayerEntity) { + if (playerEntity instanceof ServerPlayer serverPlayer) { - ServerPlayerGameMode interactionManager = serverPlayerEntity.gameMode; + ServerPlayerGameMode interactionManager = serverPlayer.gameMode; boolean isMining = Boolean.TRUE.equals(Reflector.accessField("isDestroyingBlock", ServerPlayerGameMode.class, interactionManager, Boolean.class)); if (!isMining) { return false; @@ -38,11 +35,4 @@ public static boolean condition(SerializableData.Instance data, Entity entity) { } - public static ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("using_effective_tool"), - SerializableData.serializableData(), - UsingEffectiveToolCondition::condition - ); - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/UsingItemConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/UsingItemConditionType.java new file mode 100644 index 000000000..f8548f88b --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/UsingItemConditionType.java @@ -0,0 +1,41 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import net.minecraft.util.Tuple; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +import java.util.function.Predicate; + +public class UsingItemConditionType { + + public static boolean condition(Entity entity, Predicate> itemCondition) { + + if (!(entity instanceof LivingEntity living) || !living.isUsingItem()) { + return false; + } + + InteractionHand activeHand = living.getUsedItemHand(); + ItemStack stackInHand = living.getItemInHand(activeHand); + + return itemCondition.test(new Tuple<>(living.level(), stackInHand)); + + } + + public static ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("using_item"), + new SerializableData() + .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null), + (data, entity) -> condition(entity, + data.getOrElse("item_condition", worldAndStack -> true)) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/XpLevelsConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/XpLevelsConditionType.java new file mode 100644 index 000000000..bc67546b7 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/XpLevelsConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; + +public class XpLevelsConditionType { + + public static boolean condition(Entity entity, Comparison comparison, int compareTo) { + return entity instanceof Player player + && comparison.compare(player.experienceLevel, compareTo); + } + + public static ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("xp_levels"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, entity) -> condition(entity, + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/XpPointsConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/XpPointsConditionType.java new file mode 100644 index 000000000..98a728a3e --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/entity/XpPointsConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.entity; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; + +public class XpPointsConditionType { + + public static boolean condition(Entity entity, Comparison comparison, int compareTo) { + return entity instanceof Player player + && comparison.compare(player.totalExperience, compareTo); + } + + public static ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("xp_points"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, entity) -> condition(entity, + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/fluid/FluidConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/fluid/FluidConditionType.java new file mode 100644 index 000000000..e36ec39ce --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/fluid/FluidConditionType.java @@ -0,0 +1,27 @@ +package io.github.dueris.originspaper.condition.type.fluid; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; + +public class FluidConditionType { + + public static boolean condition(FluidState fluidState, Fluid fluid) { + return fluidState.getType() == fluid; + } + + public static ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("fluid"), + new SerializableData() + .add("fluid", SerializableDataTypes.FLUID), + (data, fluidState) -> condition(fluidState, + data.get("fluid") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/fluid/InTagConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/fluid/InTagConditionType.java new file mode 100644 index 000000000..15e54aa2c --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/fluid/InTagConditionType.java @@ -0,0 +1,28 @@ +package io.github.dueris.originspaper.condition.type.fluid; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; + +public class InTagConditionType { + + public static boolean condition(FluidState fluidState, TagKey fluidTag) { + return fluidState.is(fluidTag); + } + + public static ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("in_tag"), + new SerializableData() + .add("tag", SerializableDataTypes.FLUID_TAG), + (data, fluidState) -> condition(fluidState, + data.get("tag") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/AmountConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/AmountConditionType.java new file mode 100644 index 000000000..bde30e381 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/AmountConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +public class AmountConditionType { + + public static boolean condition(ItemStack stack, Comparison comparison, int compareTo) { + return comparison.compare(stack.getCount(), compareTo); + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("amount"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/ArmorValueConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/ArmorValueConditionType.java new file mode 100644 index 000000000..41a19cd47 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/ArmorValueConditionType.java @@ -0,0 +1,39 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +public class ArmorValueConditionType { + + public static boolean condition(ItemStack stack, Comparison comparison, int compareTo) { + + int protection = stack.getItem() instanceof ArmorItem armorItem + ? armorItem.getDefense() + : 0; + + return comparison.compare(protection, compareTo); + + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("armor_value"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/CustomDataConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/CustomDataConditionType.java new file mode 100644 index 000000000..fec43a6bf --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/CustomDataConditionType.java @@ -0,0 +1,31 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.core.component.DataComponents; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.level.Level; + +public class CustomDataConditionType { + + public static boolean condition(ItemStack stack, CompoundTag nbt) { + return stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).matchedBy(nbt); + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("custom_data"), + new SerializableData() + .add("nbt", SerializableDataTypes.NBT_COMPOUND), + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("nbt") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/DurabilityConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/DurabilityConditionType.java new file mode 100644 index 000000000..c2d8a6dec --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/DurabilityConditionType.java @@ -0,0 +1,32 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +public class DurabilityConditionType { + + public static boolean condition(ItemStack stack, Comparison comparison, int compareTo) { + return comparison.compare(stack.getMaxDamage() - stack.getDamageValue(), compareTo); + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("durability"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/EnchantmentConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/EnchantmentConditionType.java new file mode 100644 index 000000000..a94ea8b40 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/EnchantmentConditionType.java @@ -0,0 +1,55 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.ItemEnchantments; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.Nullable; + +public class EnchantmentConditionType { + + public static boolean condition(RegistryAccess registryManager, ItemStack stack, @Nullable ResourceKey enchantmentKey, Comparison comparison, int compareTo, boolean useModifications) { + + Holder enchantment = enchantmentKey != null + ? registryManager.registryOrThrow(Registries.ENCHANTMENT).getHolderOrThrow(enchantmentKey) + : null; + + + ItemEnchantments enchantmentsComponent = stack.getEnchantments(); + int level = enchantment != null + ? enchantmentsComponent.getLevel(enchantment) + : enchantmentsComponent.size(); + + return comparison.compare(level, compareTo); + + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("enchantment"), + new SerializableData() + .add("enchantment", SerializableDataTypes.ENCHANTMENT, null) + .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN) + .add("compare_to", SerializableDataTypes.INT, 0) + .add("use_modifications", SerializableDataTypes.BOOLEAN, true), + (data, worldAndStack) -> condition(worldAndStack.getA().registryAccess(), worldAndStack.getB(), + data.get("enchantment"), + data.get("comparison"), + data.get("compare_to"), + data.get("use_modifications") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EquippableCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/EquippableConditionType.java similarity index 50% rename from origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EquippableCondition.java rename to origins/src/main/java/io/github/dueris/originspaper/condition/type/item/EquippableConditionType.java index 79deaff22..fd8b2d790 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EquippableCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/EquippableConditionType.java @@ -1,37 +1,34 @@ -package io.github.dueris.originspaper.condition.types.item; +package io.github.dueris.originspaper.condition.type.item; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import net.minecraft.util.Tuple; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.Equipable; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -public class EquippableCondition { +public class EquippableConditionType { - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - ItemStack stack = worldAndStack.getB(); + public static boolean condition(ItemStack stack, @Nullable EquipmentSlot slot) { Equipable equipment = Equipable.get(stack); - - EquipmentSlot equipmentSlot = data.get("equipment_slot"); - return (equipmentSlot == null && equipment != null) - || (equipment != null && equipment.getEquipmentSlot() == equipmentSlot); - + return equipment != null + && (slot == null || slot == equipment.getEquipmentSlot()); } public static @NotNull ConditionTypeFactory> getFactory() { return new ConditionTypeFactory<>( OriginsPaper.apoliIdentifier("equippable"), - SerializableData.serializableData() + new SerializableData() .add("equipment_slot", SerializableDataTypes.EQUIPMENT_SLOT, null), - EquippableCondition::condition + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("equipment_slot") + ) ); - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/FoodConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/FoodConditionType.java new file mode 100644 index 000000000..e4fdc017c --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/FoodConditionType.java @@ -0,0 +1,12 @@ +package io.github.dueris.originspaper.condition.type.item; + +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.item.ItemStack; + +public class FoodConditionType { + + public static boolean condition(ItemStack stack) { + return stack.has(DataComponents.FOOD); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/FuelConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/FuelConditionType.java new file mode 100644 index 000000000..a716d905c --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/FuelConditionType.java @@ -0,0 +1,34 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; + +public class FuelConditionType { + + public static boolean condition(ItemStack stack, Comparison comparison, int compareTo) { + Integer fuelTime = AbstractFurnaceBlockEntity.getFuel().get(stack.getItem()); + return comparison.compare(fuelTime == null ? 0 : fuelTime, compareTo); + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("fuel"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN) + .add("compare_to", SerializableDataTypes.INT, 0), + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/HasPowerConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/HasPowerConditionType.java new file mode 100644 index 000000000..e779583ee --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/HasPowerConditionType.java @@ -0,0 +1,34 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.EquipmentSlotGroup; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.Nullable; + +// TODO - PowerTypes in ItemStacks - Dueris +public class HasPowerConditionType { + + public static boolean condition(ItemStack stack, @Nullable EquipmentSlotGroup slot, ResourceLocation powerId) { + return false; + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("has_power"), + new SerializableData() + .add("slot", SerializableDataTypes.ATTRIBUTE_MODIFIER_SLOT) + .add("power", SerializableDataTypes.IDENTIFIER), + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("slot"), + data.get("power") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/IngredientConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/IngredientConditionType.java new file mode 100644 index 000000000..58155f2e6 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/IngredientConditionType.java @@ -0,0 +1,29 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.Level; + +public class IngredientConditionType { + + public static boolean condition(ItemStack stack, Ingredient ingredient) { + return ingredient.test(stack); + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("ingredient"), + new SerializableData() + .add("ingredient", SerializableDataTypes.INGREDIENT), + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("ingredient") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/PowerCountConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/PowerCountConditionType.java new file mode 100644 index 000000000..47f4446f5 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/PowerCountConditionType.java @@ -0,0 +1,38 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.EquipmentSlotGroup; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.Nullable; + +// TODO - PowerTypes in ItemStacks - Dueris +public class PowerCountConditionType { + + public static boolean condition(ItemStack stack, @Nullable EquipmentSlotGroup slot, Comparison comparison, int compareTo) { + return comparison.compare(0, compareTo); + + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("power_count"), + new SerializableData() + .add("slot", SerializableDataTypes.ATTRIBUTE_MODIFIER_SLOT) + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.INT), + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("slot"), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/RelativeDurabilityConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/RelativeDurabilityConditionType.java new file mode 100644 index 000000000..2ef041811 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/RelativeDurabilityConditionType.java @@ -0,0 +1,38 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.Comparison; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +public class RelativeDurabilityConditionType { + + public static boolean condition(ItemStack stack, Comparison comparison, float compareTo) { + + float durability = stack.isDamageableItem() + ? (float) (stack.getMaxDamage() - stack.getDamageValue()) / (float) stack.getMaxDamage() + : 1.0F; + + return comparison.compare(durability, compareTo); + + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("relative_durability"), + new SerializableData() + .add("comparison", ApoliDataTypes.COMPARISON) + .add("compare_to", SerializableDataTypes.FLOAT), + (data, worldAndStack) -> condition(worldAndStack.getB(), + data.get("comparison"), + data.get("compare_to") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/SmeltableConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/SmeltableConditionType.java new file mode 100644 index 000000000..3b45ee05b --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/item/SmeltableConditionType.java @@ -0,0 +1,28 @@ +package io.github.dueris.originspaper.condition.type.item; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.util.Tuple; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SingleRecipeInput; +import net.minecraft.world.level.Level; + +public class SmeltableConditionType { + + public static boolean condition(Level world, ItemStack stack) { + return world.getRecipeManager() + .getRecipeFor(RecipeType.SMELTING, new SingleRecipeInput(stack), world) + .isPresent(); + } + + public static ConditionTypeFactory> getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("smeltable"), + new SerializableData(), + (data, worldAndStack) -> condition(worldAndStack.getA(), worldAndStack.getB()) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/AndConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/AndConditionType.java new file mode 100644 index 000000000..d79a26dfd --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/AndConditionType.java @@ -0,0 +1,31 @@ +package io.github.dueris.originspaper.condition.type.meta; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.function.Predicate; + +public class AndConditionType { + + public static boolean condition(T type, @NotNull Collection> conditions) { + return conditions + .stream() + .allMatch(condition -> condition.test(type)); + } + + public static @NotNull ConditionTypeFactory getFactory(@NotNull SerializableDataBuilder> conditionDataType) { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("and"), + new SerializableData() + .add("conditions", SerializableDataBuilder.of(conditionDataType.listOf())), + (data, type) -> condition(type, + data.get("conditions") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/ChanceConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/ChanceConditionType.java new file mode 100644 index 000000000..d9de49ac3 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/ChanceConditionType.java @@ -0,0 +1,27 @@ +package io.github.dueris.originspaper.condition.type.meta; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import net.minecraft.util.RandomSource; +import org.jetbrains.annotations.NotNull; + +public class ChanceConditionType { + + public static boolean condition(float chance) { + return RandomSource.create().nextFloat() < chance; + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("chance"), + new SerializableData() + .add("chance", SerializableDataTypes.FLOAT), + (data, type) -> condition( + data.get("chance") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/ConstantConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/ConstantConditionType.java new file mode 100644 index 000000000..baef53a3a --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/ConstantConditionType.java @@ -0,0 +1,26 @@ +package io.github.dueris.originspaper.condition.type.meta; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import org.jetbrains.annotations.NotNull; + +public class ConstantConditionType { + + public static boolean condition(boolean value) { + return value; + } + + public static @NotNull ConditionTypeFactory getFactory() { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("constant"), + new SerializableData() + .add("value", SerializableDataTypes.BOOLEAN), + (data, type) -> condition( + data.get("value") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/OrConditionType.java b/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/OrConditionType.java new file mode 100644 index 000000000..62067dc83 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/condition/type/meta/OrConditionType.java @@ -0,0 +1,31 @@ +package io.github.dueris.originspaper.condition.type.meta; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.function.Predicate; + +public class OrConditionType { + + public static boolean condition(T type, @NotNull Collection> conditions) { + return conditions + .stream() + .anyMatch(condition -> condition.test(type)); + } + + public static @NotNull ConditionTypeFactory getFactory(@NotNull SerializableDataBuilder> conditionDataType) { + return new ConditionTypeFactory<>( + OriginsPaper.apoliIdentifier("or"), + new SerializableData() + .add("conditions", SerializableDataBuilder.of(conditionDataType.listOf())), + (data, type) -> condition(type, + data.get("conditions") + ) + ); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/BiEntityConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/BiEntityConditions.java deleted file mode 100644 index c59be9555..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/BiEntityConditions.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.dueris.originspaper.condition.types; - -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypes; -import io.github.dueris.originspaper.condition.meta.MetaConditions; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.bukkit.event.Listener; -import org.jetbrains.annotations.NotNull; - -public class BiEntityConditions implements Listener { - public static void registerAll() { - MetaConditions.register(Registries.BIENTITY_CONDITION, BiEntityConditions::register); - ConditionTypes.registerPackage(BiEntityConditions::register, "io.github.dueris.originspaper.condition.types.bientity"); - } - - public static void register(@NotNull ConditionTypeFactory> factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.BIENTITY_CONDITION).register(factory, factory.getSerializerId()); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/BiomeConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/BiomeConditions.java deleted file mode 100644 index 73613aa67..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/BiomeConditions.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.github.dueris.originspaper.condition.types; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.condition.meta.MetaConditions; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Holder; -import net.minecraft.tags.TagKey; -import net.minecraft.world.level.biome.Biome; -import org.jetbrains.annotations.NotNull; - -public class BiomeConditions { - public static void registerAll() { - MetaConditions.register(Registries.BIOME_CONDITION, BiomeConditions::register); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("high_humidity"), - SerializableData.serializableData(), - (data, biome) -> { - return biome.value().climateSettings.downfall() > 0.85F; - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("temperature"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.FLOAT), - (data, biome) -> { - return ((Comparison) data.get("comparison")).compare(biome.value().getBaseTemperature(), data.getFloat("compare_to")); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("precipitation"), - SerializableData.serializableData() - .add("precipitation", SerializableDataTypes.enumValue(Biome.Precipitation.class)), - (data, biome) -> { - return biome.value().getPrecipitationAt(new BlockPos(0, 64, 0)).equals(data.get("precipitation")); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("in_tag"), - SerializableData.serializableData() - .add("tag", SerializableDataTypes.BIOME_TAG), - (data, biome) -> { - TagKey biomeTag = data.get("tag"); - return biome.is(biomeTag); - } - )); - } - - public static void register(@NotNull ConditionTypeFactory> factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.BIOME_CONDITION).register(factory, factory.getSerializerId()); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/BlockConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/BlockConditions.java deleted file mode 100644 index a94ca3e59..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/BlockConditions.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.dueris.originspaper.condition.types; - -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypes; -import io.github.dueris.originspaper.condition.meta.MetaConditions; -import io.github.dueris.originspaper.condition.types.multi.DistanceFromCoordinatesConditionRegistry; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - - -public class BlockConditions { - - public static void registerAll() { - MetaConditions.register(Registries.BLOCK_CONDITION, BlockConditions::register); - DistanceFromCoordinatesConditionRegistry.registerBlockCondition(BlockConditions::register); - ConditionTypes.registerPackage(BlockConditions::register, "io.github.dueris.originspaper.condition.types.block"); - } - - public static void register(@NotNull ConditionTypeFactory factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.BLOCK_CONDITION).register(factory, factory.getSerializerId()); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/DamageConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/DamageConditions.java deleted file mode 100644 index 3246d2b9f..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/DamageConditions.java +++ /dev/null @@ -1,140 +0,0 @@ -package io.github.dueris.originspaper.condition.types; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.condition.meta.MetaConditions; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.tags.DamageTypeTags; -import net.minecraft.tags.TagKey; -import net.minecraft.util.Tuple; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.DamageType; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class DamageConditions { - - public static void registerAll() { - MetaConditions.register(Registries.DAMAGE_CONDITION, DamageConditions::register); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("amount"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.FLOAT), - (data, event) -> { - return ((Comparison) data.get("comparison")).compare(event.getB(), data.getFloat("compare_to")); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("name"), - SerializableData.serializableData(), - (data, event) -> { - return event.getA().getMsgId().equals(data.getString("name")); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("projectile"), - SerializableData.serializableData() - .add("projectile", SerializableDataTypes.ENTITY_TYPE, null) - .add("projectile_condition", ApoliDataTypes.ENTITY_CONDITION, null), - (data, event) -> { - DamageSource source = event.getA(); - if (source.is(DamageTypeTags.IS_PROJECTILE)) { - Entity projectile = source.getDirectEntity(); - if (projectile != null) { - if (data.isPresent("projectile") && projectile.getType() != data.get("projectile")) { - return false; - } - Predicate projectileCondition = data.get("projectile_condition"); - return projectileCondition == null || projectileCondition.test(projectile); - } - } - return false; - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("attacker"), - SerializableData.serializableData() - .add("entity_condition", ApoliDataTypes.ENTITY_CONDITION, null), - (data, event) -> { - DamageSource source = event.getA(); - Entity attacker = source.getEntity(); - if (attacker instanceof LivingEntity) { - return !data.isPresent("entity_condition") || ((ConditionTypeFactory) data.get("entity_condition")).test(attacker); - } - return false; - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("fire"), - SerializableData.serializableData(), - (data, event) -> { - return event.getA().is(DamageTypeTags.IS_FIRE); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("bypasses_armor"), - SerializableData.serializableData(), - (data, event) -> { - return event.getA().is(DamageTypeTags.BYPASSES_ARMOR); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("explosive"), - SerializableData.serializableData(), - (data, event) -> { - return event.getA().is(DamageTypeTags.IS_EXPLOSION); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("from_falling"), - SerializableData.serializableData(), - (data, event) -> { - return event.getA().is(DamageTypeTags.IS_FALL); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("unblockable"), - SerializableData.serializableData(), - (data, event) -> { - return event.getA().is(DamageTypeTags.BYPASSES_SHIELD); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("out_of_world"), - SerializableData.serializableData(), - (data, event) -> { - return event.getA().is(DamageTypeTags.BYPASSES_INVULNERABILITY); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("in_tag"), - SerializableData.serializableData() - .add("tag", SerializableDataTypes.tag(net.minecraft.core.registries.Registries.DAMAGE_TYPE)), - (data, event) -> { - return event.getA().is((TagKey) data.get("tag")); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("type"), - SerializableData.serializableData() - .add("damage_type", SerializableDataTypes.DAMAGE_TYPE), - (data, event) -> { - return event.getA().is((ResourceKey) data.get("damage_type")); - } - )); - } - - public static void register(@NotNull ConditionTypeFactory> factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.DAMAGE_CONDITION).register(factory, factory.getSerializerId()); - } - -} \ No newline at end of file diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/EntityConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/EntityConditions.java deleted file mode 100644 index 2f54ebacc..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/EntityConditions.java +++ /dev/null @@ -1,117 +0,0 @@ -package io.github.dueris.originspaper.condition.types; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypes; -import io.github.dueris.originspaper.condition.meta.MetaConditions; -import io.github.dueris.originspaper.condition.types.multi.DistanceFromCoordinatesConditionRegistry; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import io.github.dueris.originspaper.power.PowerType; -import io.github.dueris.originspaper.power.ResourcePower; -import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.storage.PowerHolderComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.player.Player; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.Optional; - -public class EntityConditions { - private static final Location[] prevLoca = new Location[100000]; - - public static void registerAll() { - MetaConditions.register(Registries.ENTITY_CONDITION, EntityConditions::register); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("power_type"), - SerializableData.serializableData() - .add("power_type", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - ResourceLocation location = data.getId("power_type"); - for (PowerType powerType : PowerHolderComponent.getPowers(entity.getBukkitEntity())) { - if (powerType.getType().equalsIgnoreCase(location.toString())) { - return true; - } - } - return false; - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("power"), - SerializableData.serializableData() - .add("power", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - ResourceLocation location = data.getId("power"); - return PowerHolderComponent.hasPower(entity.getBukkitEntity(), location.toString()); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("origin"), - SerializableData.serializableData() - .add("origin", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - ResourceLocation location = data.getId("origin"); - return entity.getBukkitEntity() instanceof org.bukkit.entity.Player p && PowerHolderComponent.hasOrigin(p, location.toString()); - } - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("power_active"), - SerializableData.serializableData() - .add("power", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - if (!(entity instanceof Player player)) return false; - PowerType found = PowerHolderComponent.getPower(entity.getBukkitEntity(), data.getId("power").toString()); - return found != null && found.isActive(player); - } - )); - DistanceFromCoordinatesConditionRegistry.registerEntityCondition(EntityConditions::register); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("resource"), - SerializableData.serializableData() - .add("resource", SerializableDataTypes.IDENTIFIER) - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT), - (data, entity) -> { - String resource = data.getId("resource").toString(); - Optional bar = ResourcePower.getDisplayedBar(entity, resource); - if (bar.isPresent()) { - return bar.get().meetsComparison(data.get("comparison"), data.getInt("compare_to")); - } - // We do a manual check of this as a backup for when people check for a non-functioning/displaying resource - // By checking the serverloaded bars(after we define that its not displayed) and seeing if the origin wants to check - // if its value is 0, then it would be true in apoli. - return ResourcePower.serverLoadedBars.containsKey(resource) && data.get("comparison").equals(Comparison.EQUAL) && data.getInt("compare_to") == 0; - } - )); - - ConditionTypes.registerPackage(EntityConditions::register, "io.github.dueris.originspaper.condition.types.entity"); - } - - public static void register(@NotNull ConditionTypeFactory factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.ENTITY_CONDITION).register(factory, factory.getSerializerId()); - } - - public static boolean isEntityMovingHorizontal(@NotNull Entity entity) { - int entID = entity.getEntityId(); - Location prevLocat = prevLoca[entID]; - Location cuLo = entity.getLocation().clone(); - prevLoca[entID] = cuLo; - if (prevLocat == null) return true; - - return cuLo.getX() != prevLocat.getX() || cuLo.getZ() != cuLo.getZ(); - } - - public static boolean isEntityMovingVertical(@NotNull Entity entity) { - int entID = entity.getEntityId(); - Location prevLocat = prevLoca[entID]; - Location cuLo = entity.getLocation().clone(); - prevLoca[entID] = cuLo; - if (prevLocat == null) return true; - - return cuLo.getY() != prevLocat.getY(); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/FluidConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/FluidConditions.java deleted file mode 100644 index 62acfffc4..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/FluidConditions.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.dueris.originspaper.condition.types; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.condition.meta.MetaConditions; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.tags.TagKey; -import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.material.FluidState; -import org.jetbrains.annotations.NotNull; - -public class FluidConditions { - public static void registerAll() { - MetaConditions.register(Registries.FLUID_CONDITION, FluidConditions::register); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("empty"), - SerializableData.serializableData(), - (data, fluid) -> fluid.isEmpty() - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("still"), - SerializableData.serializableData(), - (data, fluid) -> fluid.isSource() - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("in_tag"), - SerializableData.serializableData() - .add("tag", SerializableDataTypes.FLUID_TAG), - (data, fluid) -> fluid.holder().is((TagKey) data.get("tag")) - )); - register(new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("fluid"), - SerializableData.serializableData() - .add("fluid", SerializableDataTypes.FLUID), - (data, fluid) -> fluid.getType() == data.get("fluid") - )); - } - - public static void register(@NotNull ConditionTypeFactory factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.FLUID_CONDITION).register(factory, factory.getSerializerId()); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/ItemConditions.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/ItemConditions.java deleted file mode 100644 index 0cb172ed6..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/ItemConditions.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.dueris.originspaper.condition.types; - -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypes; -import io.github.dueris.originspaper.condition.meta.MetaConditions; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class ItemConditions { - - public static void registerAll() { - MetaConditions.register(Registries.ITEM_CONDITION, ItemConditions::register); - ConditionTypes.registerPackage(ItemConditions::register, "io.github.dueris.originspaper.condition.types.item"); - } - - public static void register(@NotNull ConditionTypeFactory> factory) { - OriginsPaper.getPlugin().registry.retrieve(Registries.ITEM_CONDITION).register(factory, factory.getSerializerId()); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/AttackTargetCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/AttackTargetCondition.java deleted file mode 100644 index e9e576b0e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/AttackTargetCondition.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.NeutralMob; -import org.jetbrains.annotations.NotNull; - -public class AttackTargetCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - if (actor == null || target == null) { - return false; - } - - return (actor instanceof Mob mobActor && target.equals(mobActor.getTarget())) - || (actor instanceof NeutralMob angerableActor && target.equals(angerableActor.getTarget())); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("attack_target"), - SerializableData.serializableData(), - AttackTargetCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/AttackerCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/AttackerCondition.java deleted file mode 100644 index 2f5ed0cb9..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/AttackerCondition.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class AttackerCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - if (actor == null || target == null) { - return false; - } - - return target instanceof LivingEntity livingTarget - && actor.equals(livingTarget.getLastHurtByMob()); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("attacker"), - SerializableData.serializableData(), - AttackerCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/BothCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/BothCondition.java deleted file mode 100644 index f733ad07d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/BothCondition.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class BothCondition { - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("both"), - SerializableData.serializableData() - .add("condition", ApoliDataTypes.ENTITY_CONDITION), - (data, actorAndTarget) -> { - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - Predicate entityCondition = data.get("condition"); - return (actor != null && entityCondition.test(actor)) - && (target != null && entityCondition.test(target)); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/DistanceCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/DistanceCondition.java deleted file mode 100644 index 68ec71577..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/DistanceCondition.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class DistanceCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getB(); - Entity target = actorAndTarget.getA(); - - if (actor == null || target == null) { - return false; - } - - Comparison comparison = data.get("comparison"); - double compareTo = data.get("compare_to"); - - compareTo *= compareTo; - return comparison.compare(actor.position().distanceToSqr(target.position()), compareTo); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("distance"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.DOUBLE), - DistanceCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/EitherCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/EitherCondition.java deleted file mode 100644 index 9bde011c4..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/EitherCondition.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class EitherCondition { - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("either"), - SerializableData.serializableData() - .add("condition", ApoliDataTypes.ENTITY_CONDITION), - (data, actorAndTarget) -> { - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - Predicate entityCondition = data.get("condition"); - return (actor != null && entityCondition.test(actor)) - || (target != null && entityCondition.test(target)); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/EqualCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/EqualCondition.java deleted file mode 100644 index e80c876c6..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/EqualCondition.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; - -public class EqualCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - return Objects.equals(actorAndTarget.getA(), actorAndTarget.getB()); - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("equal"), - SerializableData.serializableData(), - EqualCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/InvertCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/InvertCondition.java deleted file mode 100644 index 63651ef5d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/InvertCondition.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class InvertCondition { - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("invert"), - SerializableData.serializableData() - .add("condition", ApoliDataTypes.BIENTITY_CONDITION), - (data, actorAndTarget) -> { - return data.>>get("condition").test(new Tuple<>(actorAndTarget.getB(), actorAndTarget.getA())); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/OwnerCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/OwnerCondition.java deleted file mode 100644 index c69c28133..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/OwnerCondition.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.OwnableEntity; -import net.minecraft.world.entity.TraceableEntity; -import org.jetbrains.annotations.NotNull; - -public class OwnerCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - if (actor == null || target == null) { - return false; - } - - return (target instanceof OwnableEntity tamable && actor.equals(tamable.getOwner())) - || (target instanceof TraceableEntity ownable && actor.equals(ownable.getOwner())); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("owner"), - SerializableData.serializableData(), - OwnerCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RidingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RidingCondition.java deleted file mode 100644 index d0ff3291d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RidingCondition.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class RidingCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - if (actor == null || target == null) { - return false; - } - - return actor.getVehicle() != null - && actor.getVehicle().equals(target); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("riding"), - SerializableData.serializableData(), - RidingCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RidingRecursiveCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RidingRecursiveCondition.java deleted file mode 100644 index 9fe4f2b0c..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RidingRecursiveCondition.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class RidingRecursiveCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - if ((actor == null || target == null) || !actor.isPassenger()) { - return false; - } - - Entity vehicle = actor.getVehicle(); - while (vehicle != null && !vehicle.equals(target)) { - vehicle = vehicle.getVehicle(); - } - - return target.equals(vehicle); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("riding_recursive"), - SerializableData.serializableData(), - RidingRecursiveCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RidingRootCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RidingRootCondition.java deleted file mode 100644 index 835385ab9..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/RidingRootCondition.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class RidingRootCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple actorAndTarget) { - - Entity actor = actorAndTarget.getA(); - Entity target = actorAndTarget.getB(); - - if ((actor == null || target == null) || !actor.isPassenger()) { - return false; - } - - return actor.getRootVehicle().equals(target); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("riding_root"), - SerializableData.serializableData(), - RidingRootCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/UndirectedCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/UndirectedCondition.java deleted file mode 100644 index c3301c69b..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/bientity/UndirectedCondition.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.dueris.originspaper.condition.types.bientity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class UndirectedCondition { - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("undirected"), - SerializableData.serializableData() - .add("condition", ApoliDataTypes.BIENTITY_CONDITION), - (data, actorAndTarget) -> { - Predicate> biEntityCondition = data.get("condition"); - return biEntityCondition.test(actorAndTarget) - || biEntityCondition.test(new Tuple<>(actorAndTarget.getB(), actorAndTarget.getA())); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/AdjacentCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/AdjacentCondition.java deleted file mode 100644 index c4b583d9e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/AdjacentCondition.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class AdjacentCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("adjacent"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT) - .add("adjacent_condition", ApoliDataTypes.BLOCK_CONDITION), - (data, block) -> { - ConditionTypeFactory adjacentCondition = data.get("adjacent_condition"); - int adjacent = 0; - for (Direction d : Direction.values()) { - if (adjacentCondition.test(new BlockInWorld(block.getLevel(), block.getPos().relative(d), true))) { - adjacent++; - } - } - return ((Comparison) data.get("comparison")).compare(adjacent, data.getInt("compare_to")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/AttachableCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/AttachableCondition.java deleted file mode 100644 index d158badfa..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/AttachableCondition.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class AttachableCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("attachable"), - SerializableData.serializableData(), - (data, block) -> { - for (Direction d : Direction.values()) { - BlockPos adjacent = block.getPos().relative(d); - if (block.getLevel().getBlockState(adjacent).isFaceSturdy(block.getLevel(), block.getPos(), d.getOpposite())) { - return true; - } - } - return false; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlockEntityCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlockEntityCondition.java deleted file mode 100644 index 45b9f8246..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlockEntityCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class BlockEntityCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("block_entity"), - SerializableData.serializableData(), - (data, block) -> { - return block.getEntity() != null; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlockStateCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlockStateCondition.java deleted file mode 100644 index 69cd36d5d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/BlockStateCondition.java +++ /dev/null @@ -1,53 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import net.minecraft.world.level.block.state.properties.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; - -public class BlockStateCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("block_state"), - SerializableData.serializableData() - .add("property", SerializableDataTypes.STRING) - .add("comparison", ApoliDataTypes.COMPARISON, null) - .add("compare_to", SerializableDataTypes.INT, null) - .add("value", SerializableDataTypes.BOOLEAN, null) - .add("enum", SerializableDataTypes.STRING, null), - (data, block) -> { - BlockState state = block.getState(); - Collection> properties = state.getProperties(); - String desiredPropertyName = data.getString("property"); - Property property = null; - for (Property p : properties) { - if (p.getName().equals(desiredPropertyName)) { - property = p; - break; - } - } - if (property != null) { - Object value = state.getValue(property); - if (data.isPresent("enum") && value instanceof Enum) { - return ((Enum) value).name().equalsIgnoreCase(data.getString("enum")); - } else if (data.isPresent("value") && value instanceof Boolean) { - return (Boolean) value == data.getBoolean("value"); - } else if (data.isPresent("comparison") && data.isPresent("compare_to") && value instanceof Integer) { - return ((Comparison) data.get("comparison")).compare((Integer) value, data.getInt("compare_to")); - } - return true; - } - return false; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/ExposedToSkyCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/ExposedToSkyCondition.java deleted file mode 100644 index 14affc913..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/ExposedToSkyCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class ExposedToSkyCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("exposed_to_sky"), - SerializableData.serializableData(), - (data, block) -> { - return block.getLevel().canSeeSky(block.getPos()); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/FluidCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/FluidCondition.java deleted file mode 100644 index 2e80cab3a..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/FluidCondition.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import net.minecraft.world.level.material.FluidState; -import org.jetbrains.annotations.NotNull; - -public class FluidCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("fluid"), - SerializableData.serializableData() - .add("fluid_condition", ApoliDataTypes.FLUID_CONDITION), - (data, block) -> ((ConditionTypeFactory) data.get("fluid_condition")).test(block.getLevel().getFluidState(block.getPos())) - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/LightBlockingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/LightBlockingCondition.java deleted file mode 100644 index 2543e87de..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/LightBlockingCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class LightBlockingCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("light_blocking"), - SerializableData.serializableData(), - (data, block) -> { - return block.getState().canOcclude(); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/MovementBlockingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/MovementBlockingCondition.java deleted file mode 100644 index 85c4d5e0a..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/MovementBlockingCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class MovementBlockingCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("movement_blocking"), - SerializableData.serializableData(), - (data, block) -> { - return block.getState().blocksMotion() && !block.getState().getCollisionShape(block.getLevel(), block.getPos()).isEmpty(); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/NbtCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/NbtCondition.java deleted file mode 100644 index d66681352..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/NbtCondition.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtUtils; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class NbtCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("nbt"), - SerializableData.serializableData() - .add("nbt", SerializableDataTypes.NBT_COMPOUND), - (data, block) -> { - CompoundTag nbt = new CompoundTag(); - if (block.getEntity() != null) { - nbt = block.getEntity().saveWithFullMetadata(block.getLevel().registryAccess()); - } - return NbtUtils.compareNbt(data.get("nbt"), nbt, true); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/OffsetCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/OffsetCondition.java deleted file mode 100644 index bc8d9909e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/OffsetCondition.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class OffsetCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("offset"), - SerializableData.serializableData() - .add("condition", ApoliDataTypes.BLOCK_CONDITION) - .add("x", SerializableDataTypes.INT, 0) - .add("y", SerializableDataTypes.INT, 0) - .add("z", SerializableDataTypes.INT, 0), - (data, block) -> ((ConditionTypeFactory) data.get("condition")) - .test(new BlockInWorld( - block.getLevel(), - block.getPos().offset( - data.getInt("x"), - data.getInt("y"), - data.getInt("z") - ), true)) - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/ReplaceableCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/ReplaceableCondition.java deleted file mode 100644 index 093a9fd3e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/ReplaceableCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class ReplaceableCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("replaceable"), - SerializableData.serializableData(), - (data, block) -> { - return block.getState().canBeReplaced(); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/WaterLoggableCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/WaterLoggableCondition.java deleted file mode 100644 index ca22f3615..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/block/WaterLoggableCondition.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.dueris.originspaper.condition.types.block; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.level.block.LiquidBlockContainer; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class WaterLoggableCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("water_loggable"), - SerializableData.serializableData(), - (data, block) -> { - return block.getState().getBlock() instanceof LiquidBlockContainer; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AbilityCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AbilityCondition.java deleted file mode 100644 index a89dd51c3..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AbilityCondition.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class AbilityCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("ability"), - SerializableData.serializableData() - .add("ability", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - boolean enabled = false; - if (entity instanceof Player player && !entity.level().isClientSide) { - switch (data.getId("ability").toString()) { - case "minecraft:flying": - enabled = player.getAbilities().flying; - case "minecraft:instabuild": - enabled = player.getAbilities().instabuild; - case "minecraft:invulnerable": - enabled = player.getAbilities().invulnerable; - case "minecraft:mayBuild": - enabled = player.getAbilities().mayBuild; - case "minecraft:mayfly": - enabled = player.getAbilities().mayfly; - break; - default: - throw new IllegalStateException("Unexpected value: " + data.getId("ability").toString()); - } - } - return enabled; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AdvancementCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AdvancementCondition.java deleted file mode 100644 index 13eb2ea88..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/AdvancementCondition.java +++ /dev/null @@ -1,53 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.advancements.AdvancementHolder; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class AdvancementCondition { - - public static boolean condition(SerializableData.Instance data, Entity entity) { - - if (!(entity instanceof Player playerEntity)) { - return false; - } - - MinecraftServer server = playerEntity.getServer(); - ResourceLocation advancementId = data.get("advancement"); - - if (server != null) { - - AdvancementHolder advancementEntry = server.getAdvancements().get(advancementId); - if (advancementEntry == null) { - OriginsPaper.getPlugin().getLog4JLogger().warn("Advancement \"{}\" did not exist, but was referenced in an \"advancement\" entity condition!", advancementId); - return false; - } - - return ((ServerPlayer) playerEntity) - .getAdvancements() - .getOrStartProgress(advancementEntry) - .isDone(); - - } - - return false; - - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("advancement"), - SerializableData.serializableData() - .add("advancement", SerializableDataTypes.IDENTIFIER), - AdvancementCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BlockCollisionCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BlockCollisionCondition.java deleted file mode 100644 index 656bd62c3..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BlockCollisionCondition.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.BlockCollisions; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import net.minecraft.world.phys.AABB; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class BlockCollisionCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Entity entity) { - - AABB entityBoundingBox = entity.getBoundingBox(); - AABB offsetEntityBoundingBox = entityBoundingBox.move( - data.getFloat("offset_x") * entityBoundingBox.getXsize(), - data.getFloat("offset_y") * entityBoundingBox.getYsize(), - data.getFloat("offset_z") * entityBoundingBox.getZsize() - ); - - Predicate blockCondition = data.get("block_condition"); - Level world = entity.level(); - - BlockCollisions spliterator = new BlockCollisions<>(entity.level(), entity, offsetEntityBoundingBox, false, (pos, shape) -> pos); - - while (spliterator.hasNext()) { - - BlockPos blockPos = spliterator.next(); - - if (blockCondition == null || blockCondition.test(new BlockInWorld(world, blockPos, true))) { - return true; - } - - } - - return false; - - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("block_collision"), - SerializableData.serializableData() - .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) - .add("offset_x", SerializableDataTypes.FLOAT, 0F) - .add("offset_y", SerializableDataTypes.FLOAT, 0F) - .add("offset_z", SerializableDataTypes.FLOAT, 0F), - BlockCollisionCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BlockInRadiusCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BlockInRadiusCondition.java deleted file mode 100644 index 9d3d09cdd..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/BlockInRadiusCondition.java +++ /dev/null @@ -1,57 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import io.github.dueris.originspaper.data.types.Shape; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class BlockInRadiusCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("block_in_radius"), - SerializableData.serializableData() - .add("block_condition", ApoliDataTypes.BLOCK_CONDITION) - .add("radius", SerializableDataTypes.INT) - .add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE) - .add("compare_to", SerializableDataTypes.INT, 1) - .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL), - (data, entity) -> { - Predicate blockCondition = data.get("block_condition"); - int stopAt = -1; - Comparison comparison = data.get("comparison"); - int compareTo = data.getInt("compare_to"); - switch (comparison) { - case EQUAL: - case LESS_THAN_OR_EQUAL: - case GREATER_THAN: - stopAt = compareTo + 1; - break; - case LESS_THAN: - case GREATER_THAN_OR_EQUAL: - stopAt = compareTo; - break; - } - int count = 0; - for (BlockPos pos : Shape.getPositions(entity.blockPosition(), data.get("shape"), data.getInt("radius"))) { - if (blockCondition.test(new BlockInWorld(entity.level(), pos, true))) { - count++; - if (count == stopAt) { - break; - } - } - } - return comparison.compare(count, compareTo); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ClimbingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ClimbingCondition.java deleted file mode 100644 index e2211a520..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ClimbingCondition.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class ClimbingCondition { - - public static boolean condition(SerializableData.Instance data, Entity entity) { - return entity instanceof LivingEntity livingEntity && livingEntity.onClimbable(); - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("climbing"), - SerializableData.serializableData(), - ClimbingCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/CollidedHorizontallyCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/CollidedHorizontallyCondition.java deleted file mode 100644 index 152946bf0..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/CollidedHorizontallyCondition.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class CollidedHorizontallyCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("collided_horizontally"), - SerializableData.serializableData(), - (data, entity) -> entity.horizontalCollision - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/CreativeFlyingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/CreativeFlyingCondition.java deleted file mode 100644 index ba2327b63..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/CreativeFlyingCondition.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class CreativeFlyingCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("creative_flying"), - SerializableData.serializableData(), - (data, entity) -> { - return entity instanceof Player && ((Player) entity).getAbilities().flying; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/DaytimeCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/DaytimeCondition.java deleted file mode 100644 index 1a9a73559..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/DaytimeCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class DaytimeCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("daytime"), - SerializableData.serializableData(), - (data, entity) -> { - return entity.level().getDayTime() % 24000L < 13000L; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/DimensionCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/DimensionCondition.java deleted file mode 100644 index eaed32fea..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/DimensionCondition.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class DimensionCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("dimension"), - SerializableData.serializableData() - .add("dimension", SerializableDataTypes.IDENTIFIER), - (data, entity) -> { - return entity.level().dimension() == ResourceKey.create(Registries.DIMENSION, data.getId("dimension")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ElytraFlightPossibleCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ElytraFlightPossibleCondition.java deleted file mode 100644 index b7bd39c16..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ElytraFlightPossibleCondition.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ElytraItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import org.jetbrains.annotations.NotNull; - -public class ElytraFlightPossibleCondition { - - public static boolean condition(SerializableData.Instance data, Entity entity) { - if (!(entity instanceof LivingEntity livingEntity)) { - return false; - } - boolean ability = true; - if (data.getBoolean("check_ability")) { - ItemStack equippedChestItem = livingEntity.getItemBySlot(EquipmentSlot.CHEST); - ability = equippedChestItem.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(equippedChestItem); - } - boolean state = true; - if (data.getBoolean("check_state")) { - state = !livingEntity.onGround() && !livingEntity.isFallFlying() && !livingEntity.isInWater() && !livingEntity.hasEffect(MobEffects.LEVITATION); - } - return ability && state; - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>(OriginsPaper.apoliIdentifier("elytra_flight_possible"), - SerializableData.serializableData() - .add("check_state", SerializableDataTypes.BOOLEAN, false) - .add("check_ability", SerializableDataTypes.BOOLEAN, true), - ElytraFlightPossibleCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EntityTypeCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EntityTypeCondition.java deleted file mode 100644 index f61421751..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/EntityTypeCondition.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class EntityTypeCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("entity_type"), - SerializableData.serializableData() - .add("entity_type", SerializableDataTypes.ENTITY_TYPE), - (data, entity) -> { - return entity.getType() == data.get("entity_type"); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ExistsCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ExistsCondition.java deleted file mode 100644 index 18809d78d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ExistsCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class ExistsCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("exists"), - SerializableData.serializableData(), - (data, entity) -> { - return entity != null; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ExposedToSkyCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ExposedToSkyCondition.java deleted file mode 100644 index a090755ae..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ExposedToSkyCondition.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.vehicle.Boat; -import org.jetbrains.annotations.NotNull; - -public class ExposedToSkyCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("exposed_to_sky"), - SerializableData.serializableData(), - (data, entity) -> { - BlockPos blockPos = entity.getVehicle() instanceof Boat ? (BlockPos.containing(entity.getX(), (double) Math.round(entity.getY()), entity.getZ())).above() : BlockPos.containing(entity.getX(), (double) Math.round(entity.getY()), entity.getZ()); - return entity.level().canSeeSky(blockPos); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ExposedToSunCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ExposedToSunCondition.java deleted file mode 100644 index 545416538..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ExposedToSunCondition.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class ExposedToSunCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Entity entity) { - - Level world = entity.level(); - if (!world.isDay() || entity.getBukkitEntity().isInRain()) { - return false; - } - - BlockPos blockPos = BlockPos.containing(entity.getX(), entity.getBoundingBox().maxY, entity.getZ()); - float brightness = world.getLightLevelDependentMagicValue(blockPos); - - return brightness > 0.5 - && world.canSeeSky(blockPos); - - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("exposed_to_sun"), - SerializableData.serializableData(), - ExposedToSunCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FallFlyingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FallFlyingCondition.java deleted file mode 100644 index c03022091..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FallFlyingCondition.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.power.ElytraFlightPower; -import io.github.dueris.originspaper.storage.PowerHolderComponent; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class FallFlyingCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("fall_flying"), - SerializableData.serializableData(), - (data, entity) -> { - return entity instanceof LivingEntity && (((LivingEntity) entity).isFallFlying() || - PowerHolderComponent.doesHaveConditionedPower(entity.getBukkitEntity(), ElytraFlightPower.class, (p) -> p.getGlidingPlayers().contains(entity.getBukkitEntity().getUniqueId()))); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FluidHeightCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FluidHeightCondition.java deleted file mode 100644 index 1d16ef5f5..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/FluidHeightCondition.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class FluidHeightCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("fluid_height"), - SerializableData.serializableData() - .add("fluid", SerializableDataTypes.FLUID_TAG) - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.DOUBLE), - (data, entity) -> { - return ((Comparison) data.get("comparison")).compare(Util.apoli$getFluidHeightLoosely(entity, data.get("fluid")), data.getDouble("compare_to")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/GameModeCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/GameModeCondition.java deleted file mode 100644 index 785bb3821..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/GameModeCondition.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.level.ServerPlayerGameMode; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.GameType; -import org.jetbrains.annotations.NotNull; - -public class GameModeCondition { - - public static boolean condition(SerializableData.Instance data, Entity entity) { - - if (!(entity instanceof Player playerEntity)) { - return false; - } - - GameType specifiedGameMode = data.get("gamemode"); - if (playerEntity instanceof ServerPlayer serverPlayerEntity) { - - ServerPlayerGameMode interactionManager = serverPlayerEntity.gameMode; - return interactionManager.getGameModeForPlayer() == specifiedGameMode; - - } - - return false; - - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("gamemode"), - SerializableData.serializableData() - .add("gamemode", ApoliDataTypes.GAME_MODE), - GameModeCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/GlowingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/GlowingCondition.java deleted file mode 100644 index 5bc417e9e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/GlowingCondition.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class GlowingCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Entity entity) { - return !entity.level().isClientSide && entity.isCurrentlyGlowing(); - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("glowing"), - SerializableData.serializableData(), - GlowingCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/HasCommandTagCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/HasCommandTagCondition.java deleted file mode 100644 index 355575e31..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/HasCommandTagCondition.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -public class HasCommandTagCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Entity entity) { - - Set commandTags = entity.getTags(); - Set specifiedCommandTags = new HashSet<>(); - - data.ifPresent("tag", specifiedCommandTags::add); - data.ifPresent("tags", specifiedCommandTags::addAll); - data.ifPresent("command_tag", specifiedCommandTags::add); - data.ifPresent("command_tags", specifiedCommandTags::addAll); - - return specifiedCommandTags.isEmpty() - ? !commandTags.isEmpty() - : !Collections.disjoint(commandTags, specifiedCommandTags); - - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("has_command_tag"), - SerializableData.serializableData() - .add("tag", SerializableDataTypes.STRING, null) - .add("command_tag", SerializableDataTypes.STRING, null) - .add("tags", SerializableDataTypes.list(SerializableDataTypes.STRING), null) - .add("commands_tags", SerializableDataTypes.list(SerializableDataTypes.STRING), null), - HasCommandTagCondition::condition - ); - - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/HealthCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/HealthCondition.java deleted file mode 100644 index f4136296a..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/HealthCondition.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class HealthCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("health"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.FLOAT), - (data, entity) -> { - return ((Comparison) data.get("comparison")).compare(entity instanceof LivingEntity ? ((LivingEntity) entity).getHealth() : 0f, data.getFloat("compare_to")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InBlockAnywhereCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InBlockAnywhereCondition.java deleted file mode 100644 index 6a631146c..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InBlockAnywhereCondition.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import net.minecraft.world.phys.AABB; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class InBlockAnywhereCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("in_block_anywhere"), - SerializableData.serializableData() - .add("block_condition", ApoliDataTypes.BLOCK_CONDITION) - .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) - .add("compare_to", SerializableDataTypes.INT, 1), - (data, entity) -> { - Predicate blockCondition = data.get("block_condition"); - int stopAt = -1; - Comparison comparison = data.get("comparison"); - int compareTo = data.getInt("compare_to"); - switch (comparison) { - case EQUAL: - case LESS_THAN_OR_EQUAL: - case GREATER_THAN: - case NOT_EQUAL: - stopAt = compareTo + 1; - break; - case LESS_THAN: - case GREATER_THAN_OR_EQUAL: - stopAt = compareTo; - break; - } - int count = 0; - AABB box = entity.getBoundingBox(); - BlockPos blockPos = BlockPos.containing(box.minX + 0.001D, box.minY + 0.001D, box.minZ + 0.001D); - BlockPos blockPos2 = BlockPos.containing(box.maxX - 0.001D, box.maxY - 0.001D, box.maxZ - 0.001D); - BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); - for (int i = blockPos.getX(); i <= blockPos2.getX() && count < stopAt; ++i) { - for (int j = blockPos.getY(); j <= blockPos2.getY() && count < stopAt; ++j) { - for (int k = blockPos.getZ(); k <= blockPos2.getZ() && count < stopAt; ++k) { - mutable.set(i, j, k); - if (blockCondition.test(new BlockInWorld(entity.level(), mutable, true))) { - count++; - } - } - } - } - return comparison.compare(count, compareTo); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InBlockCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InBlockCondition.java deleted file mode 100644 index 28ef859e5..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InBlockCondition.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class InBlockCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("in_block"), - SerializableData.serializableData() - .add("block_condition", ApoliDataTypes.BLOCK_CONDITION), - (data, entity) -> { - return ((ConditionTypeFactory) data.get("block_condition")).test( - new BlockInWorld(entity.level(), entity.blockPosition(), true)); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InRainCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InRainCondition.java deleted file mode 100644 index a1d344671..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InRainCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class InRainCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("in_rain"), - SerializableData.serializableData(), - (data, entity) -> { - return entity.getBukkitEntity().isInRain(); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InSnowCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InSnowCondition.java deleted file mode 100644 index 73f902fe2..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InSnowCondition.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class InSnowCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Entity entity) { - - BlockPos downBlockPos = entity.blockPosition(); - BlockPos upBlockPos = BlockPos.containing(downBlockPos.getX(), entity.getBoundingBox().maxY, downBlockPos.getX()); - - return Util.inSnow(entity.level(), downBlockPos, upBlockPos); - - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("in_snow"), - SerializableData.serializableData(), - InSnowCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InTagCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InTagCondition.java deleted file mode 100644 index e77a907f8..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InTagCondition.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.tags.TagKey; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import org.jetbrains.annotations.NotNull; - -public class InTagCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Entity entity) { - TagKey> entityTypeTag = data.get("tag"); - return entity.getType().is(entityTypeTag); - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("in_tag"), - SerializableData.serializableData() - .add("tag", SerializableDataTypes.ENTITY_TAG), - InTagCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InThunderstormCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InThunderstormCondition.java deleted file mode 100644 index 1719605e4..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InThunderstormCondition.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class InThunderstormCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Entity entity) { - - BlockPos downBlockPos = entity.blockPosition(); - BlockPos upBlockPos = BlockPos.containing(downBlockPos.getX(), entity.getBoundingBox().maxY, downBlockPos.getX()); - - return Util.inThunderstorm(entity.level(), downBlockPos, upBlockPos); - - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("in_thunderstorm"), - SerializableData.serializableData(), - InThunderstormCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InvisibleCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InvisibleCondition.java deleted file mode 100644 index 7e4aa3a8d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/InvisibleCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class InvisibleCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("invisible"), - SerializableData.serializableData(), - (data, entity) -> { - return entity.isInvisible(); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/LivingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/LivingCondition.java deleted file mode 100644 index 427a43fda..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/LivingCondition.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class LivingCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("living"), - SerializableData.serializableData(), - (data, entity) -> { - return entity instanceof LivingEntity; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/MovingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/MovingCondition.java deleted file mode 100644 index 1bedc674e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/MovingCondition.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.condition.types.EntityConditions; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class MovingCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, Entity entity) { - return (data.getBoolean("horizontally") && EntityConditions.isEntityMovingHorizontal(entity.getBukkitEntity())) - || (data.getBoolean("vertically") && EntityConditions.isEntityMovingVertical(entity.getBukkitEntity())); - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("moving"), - SerializableData.serializableData() - .add("horizontally", SerializableDataTypes.BOOLEAN, true) - .add("vertically", SerializableDataTypes.BOOLEAN, true), - MovingCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/NbtCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/NbtCondition.java deleted file mode 100644 index 825abc555..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/NbtCondition.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtUtils; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class NbtCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("nbt"), - SerializableData.serializableData() - .add("nbt", SerializableDataTypes.NBT_COMPOUND), - (data, entity) -> { - CompoundTag nbt = new CompoundTag(); - entity.saveWithoutId(nbt); - return NbtUtils.compareNbt(data.get("nbt"), nbt, true); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/OnBlockCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/OnBlockCondition.java deleted file mode 100644 index 76826848c..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/OnBlockCondition.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import org.jetbrains.annotations.NotNull; - -public class OnBlockCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("on_block"), - SerializableData.serializableData() - .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null), - (data, entity) -> { - return entity.onGround() && - (!data.isPresent("block_condition") || ((ConditionTypeFactory) data.get("block_condition")).test( - new BlockInWorld(entity.level(), BlockPos.containing(entity.getX(), entity.getBoundingBox().minY - 0.5000001D, entity.getZ()), true))); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/OnFireCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/OnFireCondition.java deleted file mode 100644 index 801041f79..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/OnFireCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class OnFireCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("on_fire"), - SerializableData.serializableData(), - (data, entity) -> { - return entity.isOnFire(); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/PassengerCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/PassengerCondition.java deleted file mode 100644 index a6204453f..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/PassengerCondition.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class PassengerCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("passenger"), - SerializableData.serializableData() - .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) - .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) - .add("compare_to", SerializableDataTypes.INT, 1), - (data, entity) -> { - int count = 0; - if (entity.isVehicle()) { - if (data.isPresent("bientity_condition")) { - Predicate> condition = data.get("bientity_condition"); - count = (int) entity.getPassengers().stream().filter(e -> condition.test(new Tuple<>(e, entity))).count(); - } else { - count = entity.getPassengers().size(); - } - } - return ((Comparison) data.get("comparison")).compare(count, data.getInt("compare_to")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/PassengerRecursiveCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/PassengerRecursiveCondition.java deleted file mode 100644 index e24773ab9..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/PassengerRecursiveCondition.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.function.Predicate; - -public class PassengerRecursiveCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("passenger_recursive"), - SerializableData.serializableData() - .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) - .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) - .add("compare_to", SerializableDataTypes.INT, 1), - (data, entity) -> { - int count = 0; - if (entity.isVehicle()) { - if (data.isPresent("bientity_condition")) { - Predicate> condition = data.get("bientity_condition"); - List passengers = entity.getPassengers(); - count = (int) passengers.stream().flatMap(Entity::getSelfAndPassengers).filter(e -> condition.test(new Tuple<>(e, entity))).count(); - } else { - count = (int) entity.getPassengers().stream().flatMap(Entity::getSelfAndPassengers).count(); - } - } - return ((Comparison) data.get("comparison")).compare(count, data.getInt("compare_to")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RelativeHealthCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RelativeHealthCondition.java deleted file mode 100644 index 8e39d7d00..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RelativeHealthCondition.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; - -public class RelativeHealthCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("relative_health"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.FLOAT), - (data, entity) -> { - float health = 0f; - if (entity instanceof LivingEntity living) { - health = living.getHealth() / living.getMaxHealth(); - } - return ((Comparison) data.get("comparison")).compare(health, data.getFloat("compare_to")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RidingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RidingCondition.java deleted file mode 100644 index 4ef996383..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RidingCondition.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class RidingCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("riding"), - SerializableData.serializableData() - .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null), - (data, entity) -> { - if (entity.isPassenger()) { - if (data.isPresent("bientity_condition")) { - Predicate> condition = data.get("bientity_condition"); - Entity vehicle = entity.getVehicle(); - return condition.test(new Tuple<>(entity, vehicle)); - } - return true; - } - return false; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RidingRecursiveCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RidingRecursiveCondition.java deleted file mode 100644 index 5f191aa29..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RidingRecursiveCondition.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class RidingRecursiveCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("riding_recursive"), - SerializableData.serializableData() - .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) - .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN_OR_EQUAL) - .add("compare_to", SerializableDataTypes.INT, 1), - (data, entity) -> { - int count = 0; - if (entity.isPassenger()) { - Predicate> cond = data.get("bientity_condition"); - Entity vehicle = entity.getVehicle(); - while (vehicle != null) { - if (cond == null || cond.test(new Tuple<>(entity, vehicle))) { - count++; - } - vehicle = vehicle.getVehicle(); - } - } - return ((Comparison) data.get("comparison")).compare(count, data.getInt("compare_to")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RidingRootCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RidingRootCondition.java deleted file mode 100644 index 8d62842f3..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/RidingRootCondition.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class RidingRootCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("riding_root"), - SerializableData.serializableData() - .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null), - (data, entity) -> { - if (entity.isPassenger()) { - if (data.isPresent("bientity_condition")) { - Predicate> condition = data.get("bientity_condition"); - Entity vehicle = entity.getRootVehicle(); - return condition.test(new Tuple<>(entity, vehicle)); - } - return true; - } - return false; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ScoreboardCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ScoreboardCondition.java deleted file mode 100644 index bffbacb34..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/ScoreboardCondition.java +++ /dev/null @@ -1,46 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.scores.Objective; -import net.minecraft.world.scores.ScoreAccess; -import net.minecraft.world.scores.ScoreHolder; -import net.minecraft.world.scores.Scoreboard; -import org.jetbrains.annotations.NotNull; - -public class ScoreboardCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Entity entity) { - - ScoreHolder scoreHolder = ScoreHolder.forNameOnly(entity.getScoreboardName()); - Scoreboard scoreboard = entity.level().getScoreboard(); - - Objective scoreboardObjective = scoreboard.getObjective(data.get("objective")); - if (scoreboardObjective == null) { - return false; - } - - Comparison comparison = data.get("comparison"); - int compareTo = data.get("compare_to"); - - ScoreAccess scoreAccess = scoreboard.getOrCreatePlayerScore(scoreHolder, scoreboardObjective); - return comparison.compare(scoreAccess.get(), compareTo); - - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>(OriginsPaper.apoliIdentifier("scoreboard"), - SerializableData.serializableData() - .add("name", SerializableDataTypes.STRING, null) - .add("objective", SerializableDataTypes.STRING) - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT), - ScoreboardCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SneakingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SneakingCondition.java deleted file mode 100644 index 7f4dd0be1..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SneakingCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class SneakingCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("sneaking"), - SerializableData.serializableData(), - (data, entity) -> { - return entity.isShiftKeyDown(); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SprintingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SprintingCondition.java deleted file mode 100644 index ec66c6112..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SprintingCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class SprintingCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("sprinting"), - SerializableData.serializableData(), - (data, entity) -> { - return entity.isSprinting(); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SubmergedInCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SubmergedInCondition.java deleted file mode 100644 index 3e1986f09..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SubmergedInCondition.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class SubmergedInCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("submerged_in"), - SerializableData.serializableData() - .add("fluid", SerializableDataTypes.FLUID_TAG), - (data, entity) -> { - return Util.apoli$isSubmergedInLoosely(entity, data.get("fluid")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SwimmingCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SwimmingCondition.java deleted file mode 100644 index 4026e2f32..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/SwimmingCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class SwimmingCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("swimming"), - SerializableData.serializableData(), - (data, entity) -> { - return entity.isSwimming(); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/TamedCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/TamedCondition.java deleted file mode 100644 index ace2f65ad..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/TamedCondition.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.OwnableEntity; -import org.jetbrains.annotations.NotNull; - -public class TamedCondition { - - public static boolean condition(SerializableData.Instance data, Entity entity) { - return entity instanceof OwnableEntity tameable - && tameable.getOwnerUUID() != null; - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("tamed"), - SerializableData.serializableData(), - TamedCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/TimeOfDayCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/TimeOfDayCondition.java deleted file mode 100644 index de5467dca..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/TimeOfDayCondition.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class TimeOfDayCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("time_of_day"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT), - (data, entity) -> { - return ((Comparison) data.get("comparison")).compare(entity.level().getDayTime() % 24000L, data.getInt("compare_to")); - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/UsingItemCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/UsingItemCondition.java deleted file mode 100644 index 536a74337..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/UsingItemCondition.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import net.minecraft.util.Tuple; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Predicate; - -public class UsingItemCondition { - - public static boolean condition(SerializableData.Instance data, Entity entity) { - - if (!(entity instanceof LivingEntity livingEntity) || !livingEntity.isUsingItem()) { - return false; - } - - Predicate> itemCondition = data.get("item_condition"); - InteractionHand activeHand = livingEntity.getUsedItemHand(); - - ItemStack stackInHand = livingEntity.getItemInHand(activeHand); - return itemCondition == null || itemCondition.test(new Tuple<>(livingEntity.level(), stackInHand)); - - } - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("using_item"), - SerializableData.serializableData() - .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null), - UsingItemCondition::condition - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/XpLevelsCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/XpLevelsCondition.java deleted file mode 100644 index 68df7506c..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/XpLevelsCondition.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class XpLevelsCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("xp_levels"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT), - (data, entity) -> { - if (entity instanceof Player) { - return ((Comparison) data.get("comparison")).compare(((Player) entity).experienceLevel, data.getInt("compare_to")); - } - return false; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/XpPointsCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/XpPointsCondition.java deleted file mode 100644 index 88dd66e32..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/entity/XpPointsCondition.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.dueris.originspaper.condition.types.entity; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.NotNull; - -public class XpPointsCondition { - - public static @NotNull ConditionTypeFactory getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("xp_points"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT), - (data, entity) -> { - if (entity instanceof Player) { - return ((Comparison) data.get("comparison")).compare(((Player) entity).totalExperience, data.getInt("compare_to")); - } - return false; - } - ); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/AmountCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/AmountCondition.java deleted file mode 100644 index dcba75f27..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/AmountCondition.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class AmountCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - Comparison comparison = data.get("comparison"); - int compareTo = data.get("compare_to"); - - return comparison.compare(worldAndStack.getB().getCount(), compareTo); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("amount"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT), - AmountCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/ArmorValueCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/ArmorValueCondition.java deleted file mode 100644 index 5ffe4ba0d..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/ArmorValueCondition.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class ArmorValueCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - Comparison comparison = data.get("comparison"); - int compareTo = data.get("compare_to"); - - return worldAndStack.getB().getItem() instanceof ArmorItem armorItem - && comparison.compare(armorItem.getDefense(), compareTo); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("armor_value"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT), - ArmorValueCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/CustomDataCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/CustomDataCondition.java deleted file mode 100644 index 11a52d2b6..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/CustomDataCondition.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.core.component.DataComponents; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.component.CustomData; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class CustomDataCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - return worldAndStack.getB().getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).matchedBy(data.get("nbt")); - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("custom_data"), - SerializableData.serializableData() - .add("nbt", SerializableDataTypes.NBT_COMPOUND), - CustomDataCondition::condition - ); - - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/DamageableCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/DamageableCondition.java deleted file mode 100644 index 79c4dd72e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/DamageableCondition.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class DamageableCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple worldAndStack) { - return worldAndStack.getB().isDamageableItem(); - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("damageable"), - SerializableData.serializableData(), - DamageableCondition::condition - ); - - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/DurabilityCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/DurabilityCondition.java deleted file mode 100644 index 2a5d70f23..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/DurabilityCondition.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class DurabilityCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - Comparison comparison = data.get("comparison"); - int compareTo = data.get("compare_to"); - - ItemStack stack = worldAndStack.getB(); - int durability = stack.getMaxDamage() - stack.getDamageValue(); - - return comparison.compare(durability, compareTo); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("durability"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT), - DurabilityCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EmptyCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EmptyCondition.java deleted file mode 100644 index 71d993b71..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EmptyCondition.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class EmptyCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple worldAndStack) { - return worldAndStack.getB().isEmpty(); - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("empty"), - SerializableData.serializableData(), - EmptyCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EnchantableCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EnchantableCondition.java deleted file mode 100644 index 9366dca15..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EnchantableCondition.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class EnchantableCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple worldAndStack) { - return worldAndStack.getB().isEnchantable(); - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("enchantable"), - SerializableData.serializableData(), - EnchantableCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EnchantmentCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EnchantmentCondition.java deleted file mode 100644 index 05eb88314..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/EnchantmentCondition.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.core.Holder; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.item.enchantment.ItemEnchantments; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class EnchantmentCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - ResourceKey enchantmentKey = data.get("enchantment"); - Holder enchantment = enchantmentKey == null ? null : worldAndStack.getA().registryAccess().registryOrThrow(Registries.ENCHANTMENT) - .getHolder(enchantmentKey) - .orElseThrow(); - - Comparison comparison = data.get("comparison"); - int compareTo = data.get("compare_to"); - - ItemEnchantments component = worldAndStack.getB().getEnchantments(); - int level = enchantment != null ? component.getLevel(enchantment) - : component.keySet().size(); - return comparison.compare(level, compareTo); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("enchantment"), - SerializableData.serializableData() - .add("enchantment", SerializableDataTypes.ENCHANTMENT, null) - .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN) - .add("compare_to", SerializableDataTypes.INT, 0) - .add("use_modifications", SerializableDataTypes.BOOLEAN, true), - EnchantmentCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/FireResistantCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/FireResistantCondition.java deleted file mode 100644 index 65b5db86b..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/FireResistantCondition.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.core.component.DataComponents; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class FireResistantCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple worldAndStack) { - return worldAndStack.getB().has(DataComponents.FIRE_RESISTANT); - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("fire_resistant"), - SerializableData.serializableData(), - FireResistantCondition::condition - ); - - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/FoodCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/FoodCondition.java deleted file mode 100644 index 5995608c0..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/FoodCondition.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.core.component.DataComponents; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class FoodCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple worldAndStack) { - return worldAndStack.getB().has(DataComponents.FOOD); - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("food"), - SerializableData.serializableData(), - FoodCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/FuelCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/FuelCondition.java deleted file mode 100644 index 3905891c0..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/FuelCondition.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; -import org.jetbrains.annotations.NotNull; - -public class FuelCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - Integer fuelTime = AbstractFurnaceBlockEntity.getFuel().get(worldAndStack.getB().getItem().asItem()); - Comparison comparison = data.get("comparison"); - int compareTo = data.get("compare_to"); - - return fuelTime != null - && comparison.compare(fuelTime, compareTo); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("fuel"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON, Comparison.GREATER_THAN) - .add("compare_to", SerializableDataTypes.INT, 0), - FuelCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/HasPowerCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/HasPowerCondition.java deleted file mode 100644 index ec4211afd..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/HasPowerCondition.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class HasPowerCondition { - - public static boolean condition(SerializableData.Instance data, Tuple worldAndStack) { - return false; - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("has_power"), - SerializableData.serializableData() - .add("slot", SerializableDataTypes.EQUIPMENT_SLOT, null) - .add("power", SerializableDataTypes.IDENTIFIER), - HasPowerCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/IngredientCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/IngredientCondition.java deleted file mode 100644 index 92133c1fd..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/IngredientCondition.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class IngredientCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - return data.get("ingredient").test(worldAndStack.getB()); - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("ingredient"), - SerializableData.serializableData() - .add("ingredient", SerializableDataTypes.INGREDIENT), - IngredientCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/PowerCountCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/PowerCountCondition.java deleted file mode 100644 index 2b86ca103..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/PowerCountCondition.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class PowerCountCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, Tuple worldAndStack) { - - Comparison comparison = data.get("comparison"); - int compareTo = data.get("compare_to"); - int total = 0; - - return comparison.compare(total, compareTo); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("power_count"), - SerializableData.serializableData() - .add("slot", SerializableDataTypes.EQUIPMENT_SLOT, null) - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.INT), - PowerCountCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/RelativeDurabilityCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/RelativeDurabilityCondition.java deleted file mode 100644 index 326453d42..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/RelativeDurabilityCondition.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class RelativeDurabilityCondition { - - public static boolean condition(@NotNull SerializableData.Instance data, @NotNull Tuple worldAndStack) { - - Comparison comparison = data.get("comparison"); - float compareTo = data.get("compare_to"); - - ItemStack stack = worldAndStack.getB(); - float relativeDurability = (float) Math.abs(stack.getMaxDamage() - stack.getDamageValue()) / stack.getMaxDamage(); - - return comparison.compare(relativeDurability, compareTo); - - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("relative_durability"), - SerializableData.serializableData() - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.FLOAT), - RelativeDurabilityCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/SmeltableCondition.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/SmeltableCondition.java deleted file mode 100644 index 36e5797cf..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/item/SmeltableCondition.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.dueris.originspaper.condition.types.item; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.util.Tuple; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.item.crafting.SingleRecipeInput; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; - -public class SmeltableCondition { - - public static boolean condition(SerializableData.Instance data, @NotNull Tuple worldAndStack) { - Level world = worldAndStack.getA(); - return world != null && world.getRecipeManager() - .getRecipeFor(RecipeType.SMELTING, new SingleRecipeInput(worldAndStack.getB()), world) - .isPresent(); - } - - public static @NotNull ConditionTypeFactory> getFactory() { - return new ConditionTypeFactory<>( - OriginsPaper.apoliIdentifier("smeltable"), - SerializableData.serializableData(), - SmeltableCondition::condition - ); - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/condition/types/multi/DistanceFromCoordinatesConditionRegistry.java b/origins/src/main/java/io/github/dueris/originspaper/condition/types/multi/DistanceFromCoordinatesConditionRegistry.java deleted file mode 100644 index b65db8113..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/condition/types/multi/DistanceFromCoordinatesConditionRegistry.java +++ /dev/null @@ -1,200 +0,0 @@ -package io.github.dueris.originspaper.condition.types.multi; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import io.github.dueris.originspaper.data.types.Shape; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import net.minecraft.world.phys.Vec3; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.function.Consumer; - -/** - * @author Alluysl - * Handles the registry of the distance_from_spawn condition in both block and entity conditions to avoid duplicating code. - * Ported from Apoli - */ -public class DistanceFromCoordinatesConditionRegistry { - - private static final ArrayList previousWarnings = new ArrayList<>(); - - private static void warnOnce(String warning, Object key) { - if (!previousWarnings.contains(key)) { - previousWarnings.add(key); - OriginsPaper.getPlugin().getLog4JLogger().warn(warning); - } - } - - private static void warnOnce(String warning) { - warnOnce(warning, warning); - } - - /** - * Warns the user of an issue getting an information needed for expected behavior, but only once (doesn't spam the console). - * - * @param object the object that couldn't be acquired - * @param from the object that was supposed to provide the required object - * @param assumption the result assumed because of the lack of information - * @return the assumed result - */ - private static T warnCouldNotGetObject(String object, String from, T assumption) { - warnOnce("Could not retrieve " + object + " from " + from + " for distance_from_spawn condition, assuming " + assumption + " for condition."); - return assumption; - } - - /** - * Returns an array of aliases for the condition. - */ - private static String[] getAliases() { - return new String[]{"distance_from_spawn", "distance_from_coordinates"}; - } - - private static SerializableData getSerializableData(String alias) { - // Using doubles and not ints because the player position is a vector of doubles and the sqrt function (for the distance) returns a double so we might as well use that precision - return SerializableData.serializableData() - .add("reference", SerializableDataTypes.STRING, alias.equals("distance_from_coordinates") ? "world_origin" : "world_spawn") // the reference point -// .add("check_modified_spawn", SerializableDataTypes.BOOLEAN, true) // whether to check for modified spawns - .add("offset", SerializableDataTypes.VECTOR, new Vec3(0, 0, 0)) // offset to the reference point - .add("coordinates", SerializableDataTypes.VECTOR, new Vec3(0, 0, 0)) // adds up (instead of replacing, for simplicity) to the prior for aliasing - .add("ignore_x", SerializableDataTypes.BOOLEAN, false) // ignore the axis in the distance calculation - .add("ignore_y", SerializableDataTypes.BOOLEAN, false) // idem - .add("ignore_z", SerializableDataTypes.BOOLEAN, false) // idem - .add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE) // the shape / distance type - .add("scale_reference_to_dimension", SerializableDataTypes.BOOLEAN, true) // whether to scale the reference's coordinates according to the dimension it's in and the player is in - .add("scale_distance_to_dimension", SerializableDataTypes.BOOLEAN, false) // whether to scale the calculated distance to the current dimension - .add("comparison", ApoliDataTypes.COMPARISON) - .add("compare_to", SerializableDataTypes.DOUBLE) - .add("result_on_wrong_dimension", SerializableDataTypes.BOOLEAN, null) // if set and the dimension is not the same as the reference's, the value to set the condition to - .add("round_to_digit", SerializableDataTypes.INT, null); // if set, rounds the distance to this amount of digits (e.g. 0 for unitary values, 1 for decimals, -1 for multiples of ten) - } - - /** - * Infers the logically meaningful result of a distance comparison for out of bounds points (different dimension with corresponding parameter set, or infinite coordinates). - * - * @param comparison the comparison set in the data - * @return the result of that comparison against out-of-bounds points - */ - private static boolean compareOutOfBounds(Comparison comparison) { - return comparison == Comparison.NOT_EQUAL || comparison == Comparison.GREATER_THAN || comparison == Comparison.GREATER_THAN_OR_EQUAL; - } - - /** - * Tests the distance_from_spawn condition for either a block or an entity. - * No more and no less than one of either the block or entity argument must be null. - * - * @param data the condition's parsed data - * @param block the block to check the condition for - * @param entity the entity to check the condition for - * @return the result of the distance comparison - */ - private static boolean testCondition(SerializableData.Instance data, BlockInWorld block, Entity entity) { - boolean scaleReferenceToDimension = data.getBoolean("scale_reference_to_dimension"), - setResultOnWrongDimension = data.isPresent("result_on_wrong_dimension"), - resultOnWrongDimension = setResultOnWrongDimension && data.getBoolean("result_on_wrong_dimension"); - double x = 0, y = 0, z = 0; - Vec3 pos; - Level world; - // Get the world and its scale from the block/entity - if (block != null) { - BlockPos blockPos = block.getPos(); - pos = new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()); - LevelReader worldView = block.getLevel(); - if (!(worldView instanceof Level)) - return warnCouldNotGetObject("world", "block", compareOutOfBounds(data.get("comparison"))); - else - world = (Level) worldView; - } else { - pos = entity.position(); - world = entity.getCommandSenderWorld(); - } - double currentDimensionCoordinateScale = world.dimensionType().coordinateScale(); - - // Get the reference's scaled coordinates - switch (data.getString("reference")) { - case "player_spawn": -// if (entity instanceof ServerPlayerEntity) { // null instance of AnyClass is always false so the block case is covered -// -// } -// // No break on purpose (defaulting to natural spawn) - case "player_natural_spawn": // spawn not set through commands or beds/anchors - if (entity instanceof Player) { // && data.getBoolean("check_modified_spawn")){ - warnOnce("Used reference '" + data.getString("reference") + "' which is not implemented yet, defaulting to world spawn."); - } - // No break on purpose (defaulting to world spawn) - if (entity == null) - warnOnce("Used entity-condition-only reference point in block condition, defaulting to world spawn."); - case "world_spawn": - if (setResultOnWrongDimension && world.dimension() != Level.OVERWORLD) - return resultOnWrongDimension; - BlockPos spawnPos; - if (world instanceof ServerLevel) - spawnPos = world.getSharedSpawnPos(); - else - return warnCouldNotGetObject("world with spawn position", block != null ? "block" : "entity", compareOutOfBounds(data.get("comparison"))); - x = spawnPos.getX(); - y = spawnPos.getY(); - z = spawnPos.getZ(); - break; - case "world_origin": - break; - } - Vec3 coords = data.get("coordinates"); - Vec3 offset = data.get("offset"); - x += coords.x + offset.x; - y += coords.y + offset.y; - z += coords.z + offset.z; - if (scaleReferenceToDimension && (x != 0 || z != 0)) { - if (currentDimensionCoordinateScale == 0) // pocket dimensions? - // coordinate scale 0 means it takes 0 blocks to travel in the OW to travel 1 block in the dimension, - // so the dimension is folded on 0 0, so unless the OW reference is at 0 0, it gets scaled to infinity - return compareOutOfBounds(data.get("comparison")); - x /= currentDimensionCoordinateScale; - z /= currentDimensionCoordinateScale; - } - - // Get the distance to these coordinates - double distance, - xDistance = data.getBoolean("ignore_x") ? 0 : Math.abs(pos.x() - x), - yDistance = data.getBoolean("ignore_y") ? 0 : Math.abs(pos.y() - y), - zDistance = data.getBoolean("ignore_z") ? 0 : Math.abs(pos.z() - z); - if (data.getBoolean("scale_distance_to_dimension")) { - xDistance *= currentDimensionCoordinateScale; - zDistance *= currentDimensionCoordinateScale; - } - - distance = Shape.getDistance(data.get("shape"), xDistance, yDistance, zDistance); - - if (data.isPresent("round_to_digit")) - distance = new BigDecimal(distance).setScale(data.getInt("round_to_digit"), RoundingMode.HALF_UP).doubleValue(); - - return ((Comparison) data.get("comparison")).compare(distance, data.getDouble("compare_to")); - } - - // Watch Java generic type erasure destroy DRY - - public static void registerBlockCondition(Consumer> registryFunction) { - for (String alias : getAliases()) - registryFunction.accept(new ConditionTypeFactory<>(OriginsPaper.apoliIdentifier(alias), - getSerializableData(alias), - (data, block) -> testCondition(data, block, null))); - } - - public static void registerEntityCondition(Consumer> registryFunction) { - for (String alias : getAliases()) - registryFunction.accept(new ConditionTypeFactory<>(OriginsPaper.apoliIdentifier(alias), - getSerializableData(alias), - (data, entity) -> testCondition(data, null, entity))); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/content/NMSBootstrap.java b/origins/src/main/java/io/github/dueris/originspaper/content/NMSBootstrap.java deleted file mode 100644 index c38fd0b00..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/content/NMSBootstrap.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.dueris.originspaper.content; - -import io.github.dueris.originspaper.registry.nms.OriginLootCondition; -import io.github.dueris.originspaper.registry.nms.PowerLootCondition; -import io.github.dueris.originspaper.util.WrappedBootstrapContext; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; - -public class NMSBootstrap { -// public static EntityType ENDERIAN_PEARL_ENTITYTYPE = EntityType.Builder.of(ThrownEnderpearl::new, MobCategory.MISC).sized(0.25F, 0.25F).clientTrackingRange(4).updateInterval(10).build("enderian_pearl"); - - public static void bootstrap(@NotNull WrappedBootstrapContext context) { - context.registerBuiltin(BuiltInRegistries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath("apoli", "power"), PowerLootCondition.TYPE); - context.registerBuiltin(BuiltInRegistries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath("origins", "origin"), OriginLootCondition.TYPE); - //context.registerBuiltin(BuiltInRegistries.ENTITY_TYPE, ResourceLocation.fromNamespaceAndPath("origins", "enderian_pearl"), ENDERIAN_PEARL_ENTITYTYPE); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/content/OrbOfOrigins.java b/origins/src/main/java/io/github/dueris/originspaper/content/OrbOfOrigins.java index 31f5aabc4..9e45e75cd 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/content/OrbOfOrigins.java +++ b/origins/src/main/java/io/github/dueris/originspaper/content/OrbOfOrigins.java @@ -1,7 +1,7 @@ package io.github.dueris.originspaper.content; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.power.RecipePower; +import io.github.dueris.originspaper.power.type.RecipePower; import io.github.dueris.originspaper.storage.OriginConfiguration; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -60,7 +60,7 @@ public static void init() { RecipePower.taggedRegistry.put(sr.key().asString(), sr); return sr.getResult().clone(); } catch (Exception var5) { - OriginsPaper.getPlugin().getLog4JLogger().error("An unexpected error occured when trying to load the orb of origins! : {}", var5.getLocalizedMessage()); + OriginsPaper.LOGGER.error("An unexpected error occured when trying to load the orb of origins! : {}", var5.getLocalizedMessage()); throw var5; } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/ApoliDataTypes.java b/origins/src/main/java/io/github/dueris/originspaper/data/ApoliDataTypes.java index 394c52b75..c3fb35035 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/data/ApoliDataTypes.java +++ b/origins/src/main/java/io/github/dueris/originspaper/data/ApoliDataTypes.java @@ -12,9 +12,10 @@ import io.github.dueris.calio.registry.impl.CalioRegistry; import io.github.dueris.calio.util.ArgumentWrapper; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.*; +import io.github.dueris.originspaper.power.factory.PowerReference; import io.github.dueris.originspaper.registry.Registries; import io.github.dueris.originspaper.util.Util; import net.minecraft.commands.arguments.EntityArgument; @@ -54,7 +55,7 @@ public class ApoliDataTypes { public static final SerializableDataBuilder>> BLOCK_ACTION = action(Registries.BLOCK_ACTION); public static final SerializableDataBuilder>> ITEM_ACTION = action(Registries.ITEM_ACTION); public static final SerializableDataBuilder>> BIENTITY_CONDITION = condition(Registries.BIENTITY_CONDITION); - public static final SerializableDataBuilder>> BIOME_CONDITION = condition(Registries.BIOME_CONDITION); + public static final SerializableDataBuilder>>> BIOME_CONDITION = condition(Registries.BIOME_CONDITION); public static final SerializableDataBuilder> BLOCK_CONDITION = condition(Registries.BLOCK_CONDITION); public static final SerializableDataBuilder>> DAMAGE_CONDITION = condition(Registries.DAMAGE_CONDITION); public static final SerializableDataBuilder> ENTITY_CONDITION = condition(Registries.ENTITY_CONDITION); @@ -153,6 +154,7 @@ public class ApoliDataTypes { }, Map.class ); public static final SerializableDataBuilder GAME_MODE = SerializableDataTypes.enumValue(GameType.class); + public static final SerializableDataBuilder DESTRUCTION_TYPE = SerializableDataTypes.enumValue(Explosion.BlockInteraction.class); public static final SerializableDataBuilder DEFAULT_TRANSLATABLE_TEXT = SerializableDataBuilder.of( (jsonElement) -> { return jsonElement instanceof JsonPrimitive jsonPrimitive @@ -161,16 +163,15 @@ public class ApoliDataTypes { }, Component.class ); public static final SerializableDataBuilder ENTITY_POSE = SerializableDataTypes.enumValue(Pose.class); - public static final SerializableDataBuilder HUD_RENDER = SerializableDataBuilder.of( - (jsonElement) -> { - if (!(jsonElement instanceof JsonObject jo)) { - throw new JsonSyntaxException("HudRender should be instanceof a JsonObject!"); - } - return new HudRender( - jo.has("should_render") ? SerializableDataTypes.BOOLEAN.deserialize(jo.get("should_render")) : true, - jo.has("condition") ? ENTITY_CONDITION.deserialize(jo.get("condition")) : null - ); - }, HudRender.class + /** + *

A HUD render data type that accepts either a single HUD render or multiple HUD renders. The first HUD render will be considered + * the "parent" and the following HUD renders will be considered its "children."

+ * + *

If the children don't specify an order value, the order value of the parent will be inherited instead.

+ */ + public static final SerializableDataBuilder HUD_RENDER = HudRender.DATA_TYPE; + public static final SerializableDataBuilder POWER_REFERENCE = SerializableDataBuilder.of( + (jsonElement) -> new PowerReference(SerializableDataTypes.IDENTIFIER.deserialize(jsonElement)), PowerReference.class ); public static @NotNull SerializableDataBuilder> action(RegistryKey> registry) { @@ -181,16 +182,12 @@ public class ApoliDataTypes { } ResourceLocation factoryID = SerializableDataTypes.IDENTIFIER.deserialize(jsonObject.get("type")); - try { - ActionTypeFactory actionFactory = CalioRegistry.INSTANCE.retrieve(registry).get(factoryID); - if (actionFactory == null) { - throw new IllegalArgumentException("Unable to retrieve action of: " + jsonObject.get("type").getAsString()); - } - return actionFactory.copy().decompile(jsonObject); - } catch (Throwable e) { - OriginsPaper.getPlugin().getLog4JLogger().error("Unable to retrieve action of `{}` for Power!", factoryID.toString()); - throw e; + ActionTypeFactory actionFactory = CalioRegistry.INSTANCE.retrieve(registry).get(factoryID); + if (actionFactory == null) { + OriginsPaper.LOGGER.error("Unable to retrieve action of: {}", jsonObject.get("type").getAsString()); + return null; } + return actionFactory.copy().decompile(jsonObject); }, ActionTypeFactory.class ); } @@ -203,16 +200,12 @@ public class ApoliDataTypes { } ResourceLocation factoryID = SerializableDataTypes.IDENTIFIER.deserialize(jsonObject.get("type")); - try { - ConditionTypeFactory conditionTypeFactory = CalioRegistry.INSTANCE.retrieve(registry).get(factoryID); - if (conditionTypeFactory == null) { - throw new IllegalArgumentException("Unable to retrieve condition of: " + jsonObject.get("type").getAsString()); - } - return conditionTypeFactory.copy().decompile(jsonObject); - } catch (Throwable e) { - OriginsPaper.getPlugin().getLog4JLogger().error("Unable to retrieve condition of `{}` for Power!", factoryID.toString()); - throw e; + ConditionTypeFactory conditionTypeFactory = CalioRegistry.INSTANCE.retrieve(registry).get(factoryID); + if (conditionTypeFactory == null) { + OriginsPaper.LOGGER.error("Unable to retrieve condition of '{}'", jsonObject.get("type").getAsString()); + return null; } + return conditionTypeFactory.copy().decompile(jsonObject); }, ConditionTypeFactory.class ); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/OriginsDataTypes.java b/origins/src/main/java/io/github/dueris/originspaper/data/OriginsDataTypes.java index 39694f1ec..158999a21 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/data/OriginsDataTypes.java +++ b/origins/src/main/java/io/github/dueris/originspaper/data/OriginsDataTypes.java @@ -5,8 +5,8 @@ import com.google.gson.JsonPrimitive; import com.google.gson.JsonSyntaxException; import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; import io.github.dueris.originspaper.data.types.GuiTitle; import io.github.dueris.originspaper.data.types.Impact; import io.github.dueris.originspaper.data.types.OriginUpgrade; @@ -16,8 +16,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import java.util.Optional; - @SuppressWarnings("unused") public class OriginsDataTypes { @@ -49,7 +47,7 @@ public class OriginsDataTypes { public static final SerializableDataBuilder CONDITIONED_ORIGIN = SerializableDataBuilder.of( (jsonElement) -> { if (jsonElement instanceof JsonObject jsonObject && !jsonObject.isEmpty()) { - SerializableData.Instance factoryJson = SerializableData.Instance.decompileJsonObject(jsonObject, OriginLayer.ConditionedOrigin.DATA, "Origin/ConditionedOrigin", "null", Optional.of(OriginLayer.ConditionedOrigin.class)); + SerializableData.Instance factoryJson = SerializableDataBuilder.compound(OriginLayer.ConditionedOrigin.DATA, jsonObject, OriginLayer.ConditionedOrigin.class); return new OriginLayer.ConditionedOrigin(factoryJson.get("condition"), factoryJson.get("origins")); } else throw new JsonSyntaxException("Expected JsonObject for ConditionedOrigin!"); }, OriginLayer.ConditionedOrigin.class diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/pack/PluginRepositorySource.java b/origins/src/main/java/io/github/dueris/originspaper/data/pack/PluginRepositorySource.java new file mode 100644 index 000000000..c73d921cf --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/data/pack/PluginRepositorySource.java @@ -0,0 +1,148 @@ +package io.github.dueris.originspaper.data.pack; + +import com.mojang.logging.LogUtils; +import net.minecraft.network.chat.Component; +import net.minecraft.server.packs.*; +import net.minecraft.server.packs.linkfs.LinkFileSystem; +import net.minecraft.server.packs.repository.Pack; +import net.minecraft.server.packs.repository.PackDetector; +import net.minecraft.server.packs.repository.PackSource; +import net.minecraft.server.packs.repository.RepositorySource; +import net.minecraft.world.level.validation.ContentValidationException; +import net.minecraft.world.level.validation.DirectoryValidator; +import net.minecraft.world.level.validation.ForbiddenSymlinkInfo; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; + +import javax.annotation.Nullable; +import java.io.IOException; +import java.nio.file.*; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +public class PluginRepositorySource implements RepositorySource { + static final Logger LOGGER = LogUtils.getLogger(); + private static final PackSelectionConfig DISCOVERED_PACK_SELECTION_CONFIG = new PackSelectionConfig(false, Pack.Position.TOP, false); + private final Path folder; + private final PackType packType; + private final PackSource packSource; + private final DirectoryValidator validator; + private final String fileName; + + public PluginRepositorySource(Path packsDir, PackType type, PackSource source, DirectoryValidator symlinkFinder, String fileName) { + this.folder = packsDir; + this.packType = type; + this.packSource = source; + this.validator = symlinkFinder; + this.fileName = fileName; + } + + private static @NotNull String nameFromPath(@NotNull Path path) { + return path.getFileName().toString(); + } + + public static void discoverPacks(Path path, DirectoryValidator symlinkFinder, BiConsumer callback, String fileName) throws IOException { + PluginRepositorySource.FolderPackDetector folderPackDetector = new PluginRepositorySource.FolderPackDetector(symlinkFinder, fileName); + + try (DirectoryStream directoryStream = Files.newDirectoryStream(path)) { + for (Path path2 : directoryStream) { + try { + List list = new LinkedList<>(); + Pack.ResourcesSupplier resourcesSupplier = folderPackDetector.detectPackResources(path2, list); + if (!list.isEmpty()) { + LOGGER.warn("Ignoring potential pack entry: {}", ContentValidationException.getMessage(path2, list)); + } else if (resourcesSupplier != null) { + callback.accept(path2, resourcesSupplier); + } + } catch (IOException var10) { + LOGGER.warn("Failed to read properties of '{}', ignoring", path2, var10); + } + } + } + } + + @Override + public void loadPacks(@NotNull Consumer profileAdder) { + try { + discoverPacks(this.folder, this.validator, (path, packFactory) -> { + PackLocationInfo packLocationInfo = this.createDiscoveredFilePackInfo(path); + Pack pack = Pack.readMetaAndCreate(packLocationInfo, packFactory, this.packType, DISCOVERED_PACK_SELECTION_CONFIG); + if (pack != null) { + profileAdder.accept(pack); + } + }, this.fileName); + } catch (IOException var3) { + LOGGER.warn("Failed to list packs in {}", this.folder, var3); + } + } + + private @NotNull PackLocationInfo createDiscoveredFilePackInfo(Path path) { + String string = nameFromPath(path); + return new PackLocationInfo("assets/origins/" + string, Component.literal(string), this.packSource, Optional.empty()); + } + + static class FolderPackDetector extends PackDetector { + private final DirectoryValidator validator; + private final String fileName; + + protected FolderPackDetector(DirectoryValidator symlinkFinder, String fileName) { + super(symlinkFinder); + this.validator = symlinkFinder; + this.fileName = fileName; + } + + @Nullable + @Override + protected Pack.ResourcesSupplier createZipPack(@NotNull Path path) { + FileSystem fileSystem = path.getFileSystem(); + if (fileSystem != FileSystems.getDefault() && !(fileSystem instanceof LinkFileSystem)) { + PluginRepositorySource.LOGGER.info("Can't open pack archive at {}", path); + return null; + } else { + return new FilePackResources.FileResourcesSupplier(path); + } + } + + @Override + protected Pack.ResourcesSupplier createDirectoryPack(@NotNull Path path) { + return new PathPackResources.PathResourcesSupplier(path); + } + + @Override + public Pack.ResourcesSupplier detectPackResources(@NotNull Path path, @NotNull List foundSymlinks) throws IOException { + Path path2 = path; + + BasicFileAttributes basicFileAttributes; + try { + basicFileAttributes = Files.readAttributes(path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS); + } catch (NoSuchFileException var6) { + return null; + } + + if (basicFileAttributes.isSymbolicLink()) { + this.validator.validateSymlink(path, foundSymlinks); + if (!foundSymlinks.isEmpty()) { + return null; + } + + path2 = Files.readSymbolicLink(path); + basicFileAttributes = Files.readAttributes(path2, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS); + } + + if (basicFileAttributes.isDirectory()) { + this.validator.validateKnownDirectory(path2, foundSymlinks); + if (!foundSymlinks.isEmpty()) { + return null; + } else { + return !Files.isRegularFile(path2.resolve("pack.mcmeta")) ? null : this.createDirectoryPack(path2); + } + } else { + return basicFileAttributes.isRegularFile() && path2.getFileName().toString().equalsIgnoreCase(this.fileName) ? this.createZipPack(path2) : null; + } + } + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/types/ContainerType.java b/origins/src/main/java/io/github/dueris/originspaper/data/types/ContainerType.java index 61a12211c..d6cff0a1e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/data/types/ContainerType.java +++ b/origins/src/main/java/io/github/dueris/originspaper/data/types/ContainerType.java @@ -1,9 +1,12 @@ package io.github.dueris.originspaper.data.types; +import io.github.dueris.originspaper.util.LangFile; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; +import org.jetbrains.annotations.NotNull; import java.util.Optional; @@ -30,8 +33,8 @@ public int getSize() { return this.size; } - public Inventory createInventory(Optional string) { - Component name = Component.text(string.orElse("container.inventory")); + public @NotNull Inventory createInventory(@NotNull Optional string) { + Component name = PlainTextComponentSerializer.plainText().deserialize(LangFile.translatable(string.orElse("container.inventory")).getString()); return this == DOUBLE_CHEST ? Bukkit.createInventory(null, this.getSize(), name) : this == CHEST ? Bukkit.createInventory(null, this.getSize(), name) : Bukkit.createInventory(null, this.bukkit, name); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/types/ExplosionMask.java b/origins/src/main/java/io/github/dueris/originspaper/data/types/ExplosionMask.java deleted file mode 100644 index dbeaab0c4..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/data/types/ExplosionMask.java +++ /dev/null @@ -1,241 +0,0 @@ -package io.github.dueris.originspaper.data.types; - -import com.mojang.datafixers.util.Pair; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.core.BlockPos; -import net.minecraft.core.particles.ParticleOptions; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.BaseFireBlock; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.CraftParticle; -import org.bukkit.craftbukkit.block.CraftBlock; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.util.CraftLocation; -import org.bukkit.event.block.BlockExplodeEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class ExplosionMask { - List blocks; - Explosion explosion; - ServerLevel level; - boolean fire; - - public ExplosionMask(Explosion explosion, ServerLevel level) { - this.blocks = new ArrayList<>(); - this.explosion = explosion; - this.level = level; - } - - @Contract(value = "_, _ -> new", pure = true) - public static @NotNull ExplosionMask getExplosionMask(Explosion explosion, ServerLevel level) { - return new ExplosionMask(explosion, level); - } - - @Contract(value = "_, _ -> new", pure = true) - public static @NotNull ExplosionMask getExplosionMask(Explosion explosion, Level level) { - return getExplosionMask(explosion, (ServerLevel) level); - } - - private static void addOrAppendStack(List> stacks, @NotNull ItemStack stack, BlockPos pos) { - if (stack.isEmpty()) return; - for (int i = 0; i < stacks.size(); ++i) { - Pair pair = stacks.get(i); - ItemStack itemstack1 = pair.getFirst(); - - if (ItemEntity.areMergable(itemstack1, stack)) { - stacks.set(i, Pair.of(ItemEntity.merge(itemstack1, stack, 16), pair.getSecond())); - if (stack.isEmpty()) { - return; - } - } - } - - stacks.add(Pair.of(stack, pos)); - } - - public ExplosionMask apply(boolean fire, @Nullable ConditionTypeFactory indestructible, @Nullable ConditionTypeFactory destructible, boolean destroyAfterMask) { - this.explosion.explode(); // Setup explosion stuff -- includes iterator for explosions - this.fire = fire; - this.blocks = createBlockList(this.explosion.getToBlow(), this.level); - List finalBlocks = new ArrayList<>(); - - boolean testFilters = indestructible != null || destructible != null; - - if (testFilters) { - this.blocks.forEach((block) -> { - boolean addBlock = true; - - if (indestructible != null) { - if (indestructible.test((CraftBlock) block)) { - addBlock = false; - } - } - - if (destructible != null) { - if (!destructible.test((CraftBlock) block)) { - addBlock = false; - } - } - - if (addBlock) { - finalBlocks.add(block); - } - }); - } else { - finalBlocks.addAll(this.blocks); - } - - this.explosion.clearToBlow(); - this.explosion.getToBlow().addAll(createBlockPosList(finalBlocks)); - - if (destroyAfterMask) { - destroyBlocks(); - } - return this; - } - - - public void destroyBlocks() { - ParticleOptions particleparam; - - if (this.explosion.radius() >= 2.0F && this.explosion.interactsWithBlocks()) { - particleparam = this.explosion.getLargeExplosionParticles(); - } else { - particleparam = this.explosion.getSmallExplosionParticles(); - } - - double x = this.explosion.center().x; - double y = this.explosion.center().y; - double z = this.explosion.center().z; - - this.level.getWorld().playSound(new Location(this.level.getWorld(), x, y, z), Sound.ENTITY_GENERIC_EXPLODE, 1, 1); - this.level.getWorld().spawnParticle(CraftParticle.minecraftToBukkit(particleparam.getType()), new Location(this.level.getWorld(), x, y, z), 4); - - boolean flag1 = this.explosion.interactsWithBlocks(); - - if (flag1) { - List> list = new ArrayList(); - - net.minecraft.Util.shuffle(this.explosion.getToBlow(), this.level.random); - Iterator objectlistiterator = this.explosion.getToBlow().iterator(); - org.bukkit.World bworld = this.level.getWorld(); - org.bukkit.entity.Entity explode = this.explosion.source == null ? null : this.explosion.source.getBukkitEntity(); - Location location = new Location(bworld, this.explosion.center().x, this.explosion.center().y, this.explosion.center().z); - - List blockList = new ObjectArrayList<>(); - for (int i1 = this.explosion.getToBlow().size() - 1; i1 >= 0; i1--) { - BlockPos cpos = this.explosion.getToBlow().get(i1); - org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ()); - if (!bblock.getType().isAir()) { - blockList.add(bblock); - } - } - - List bukkitBlocks; - - if (explode != null) { - EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.explosion.source, blockList, this.explosion.yield, this.explosion.getBlockInteraction()); - this.explosion.wasCanceled = event.isCancelled(); - bukkitBlocks = event.blockList(); - this.explosion.yield = event.getYield(); - } else { - org.bukkit.block.Block block = location.getBlock(); - org.bukkit.block.BlockState blockState = block.getState(); - BlockExplodeEvent event = CraftEventFactory.callBlockExplodeEvent(block, blockState, blockList, this.explosion.yield, this.explosion.getBlockInteraction()); - this.explosion.wasCanceled = event.isCancelled(); - bukkitBlocks = event.blockList(); - this.explosion.yield = event.getYield(); - } - - this.explosion.getToBlow().clear(); - - for (org.bukkit.block.Block bblock : bukkitBlocks) { - BlockPos coords = new BlockPos(bblock.getX(), bblock.getY(), bblock.getZ()); - this.explosion.getToBlow().add(coords); - } - - if (this.explosion.wasCanceled) { - return; - } - objectlistiterator = this.explosion.getToBlow().iterator(); - - while (objectlistiterator.hasNext()) { - BlockPos blockposition = objectlistiterator.next(); - BlockState iblockdata = this.level.getBlockState(blockposition); - net.minecraft.world.level.block.Block block = iblockdata.getBlock(); - if (block instanceof net.minecraft.world.level.block.TntBlock) { - Entity sourceEntity = this.explosion.source == null ? null : this.explosion.source; - BlockPos sourceBlock = sourceEntity == null ? BlockPos.containing(this.explosion.center().x, this.explosion.center().y, this.explosion.center().z) : null; - if (!CraftEventFactory.callTNTPrimeEvent(this.level, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.EXPLOSION, sourceEntity, sourceBlock)) { - this.level.sendBlockUpdated(blockposition, Blocks.AIR.defaultBlockState(), iblockdata, 3); // Update the block on the client - continue; - } - } - - this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this.explosion, (itemstack, blockposition1) -> { - addOrAppendStack(list, itemstack, blockposition1); - }); - } - - Iterator> iterator = list.iterator(); - - while (iterator.hasNext()) { - Pair pair = iterator.next(); - - net.minecraft.world.level.block.Block.popResource(this.level, pair.getSecond(), pair.getFirst()); - } - } - - if (this.fire) { - - for (BlockPos blockposition1 : this.explosion.getToBlow()) { - if (this.level.random.nextInt(3) == 0 && this.level.getBlockState(blockposition1).isAir() && this.level.getBlockState(blockposition1.below()).isSolidRender(this.level, blockposition1.below())) { - if (!CraftEventFactory.callBlockIgniteEvent(this.level, blockposition1, this.explosion).isCancelled()) { - this.level.setBlockAndUpdate(blockposition1, BaseFireBlock.getState(this.level, blockposition1)); - } - } - } - } - } - - private @NotNull List createBlockList(@NotNull List blockPos, ServerLevel level) { - List blocks = new ArrayList<>(); - blockPos.forEach(pos -> { - blocks.add(level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); - }); - return blocks; - } - - private @NotNull List createBlockPosList(@NotNull List blocks) { - List positions = new ArrayList<>(); - blocks.forEach(block -> { - positions.add(CraftLocation.toBlockPosition(block.getLocation())); - }); - return positions; - } - - public Explosion getExplosion() { - return this.explosion; - } - - public List getBlocksToDestroy() { - return this.blocks; - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/types/GuiTitle.java b/origins/src/main/java/io/github/dueris/originspaper/data/types/GuiTitle.java index 17a76691b..c05b20f8b 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/data/types/GuiTitle.java +++ b/origins/src/main/java/io/github/dueris/originspaper/data/types/GuiTitle.java @@ -1,7 +1,7 @@ package io.github.dueris.originspaper.data.types; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import net.kyori.adventure.text.Component; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/types/HudRender.java b/origins/src/main/java/io/github/dueris/originspaper/data/types/HudRender.java index 98e75f87a..8ee3b3617 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/data/types/HudRender.java +++ b/origins/src/main/java/io/github/dueris/originspaper/data/types/HudRender.java @@ -1,15 +1,84 @@ package io.github.dueris.originspaper.data.types; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.util.Renderer; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; +import org.bukkit.boss.BarColor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -public record HudRender(boolean shouldRender, ConditionTypeFactory condition) { - public static final HudRender DONT_RENDER = new HudRender(false, null); +import java.util.List; +import java.util.Optional; + +public record HudRender(@Nullable ConditionTypeFactory condition, Renderer.RenderImpl render, + boolean shouldRender, boolean inverted, int order) implements Comparable { + + public static final ResourceLocation DEFAULT_SPRITE = OriginsPaper.apoliIdentifier("textures/gui/resource_bar.png"); + public static final HudRender DONT_RENDER = new HudRender(null, new Renderer.RenderImpl(0, DEFAULT_SPRITE, null, BarColor.WHITE), false, false, 0); + + public static final SerializableDataBuilder DATA_TYPE = SerializableDataBuilder.compound( + new SerializableData() + .add("condition", ApoliDataTypes.ENTITY_CONDITION, null) + .add("sprite_location", SerializableDataTypes.IDENTIFIER, DEFAULT_SPRITE) + .add("should_render", SerializableDataTypes.BOOLEAN, true) + .add("inverted", SerializableDataTypes.BOOLEAN, false) + .add("bar_index", SerializableDataTypes.NON_NEGATIVE_INT, 0) + .add("order", SerializableDataTypes.INT, 0), + data -> new HudRender( + data.get("condition"), + Renderer.findRender(data.getInt("bar_index"), data.getId("sprite_location")), + data.getBoolean("should_render"), + data.getBoolean("inverted"), + data.getInt("order") + ), HudRender.class + ); + + public static final SerializableDataBuilder> LIST_DATA_TYPE = SerializableDataBuilder.of(DATA_TYPE.listOf(1, Integer.MAX_VALUE)); + + @Override + public int compareTo(@NotNull HudRender other) { + int orderResult = Integer.compare(this.order(), other.order()); + return orderResult != 0 + ? orderResult + : this.render.spriteLocation().compareTo(other.render.spriteLocation()); + } + + + public boolean shouldRender(Entity viewer) { + return this.shouldRender() && (this.condition() == null || this.condition().test(viewer)); + } + + + public HudRender withOrder(int order) { + + if (this.order() != 0) { + return this; + } + + return new HudRender( + this.condition(), + this.render, + this.shouldRender(), + this.inverted(), + order + ); + + } + + public Optional getActive(Entity viewer) { + + if (this.shouldRender(viewer)) { + return Optional.of(this); + } else { + return Optional.empty(); + } + + } - public static SerializableData DATA = SerializableData.serializableData() - .add("should_render", SerializableDataTypes.BOOLEAN, true) - .add("condition", ApoliDataTypes.ENTITY_CONDITION, null); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/IModifierOperation.java b/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/IModifierOperation.java index 055d51fee..73e49810e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/IModifierOperation.java +++ b/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/IModifierOperation.java @@ -1,8 +1,8 @@ package io.github.dueris.originspaper.data.types.modifier; import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; import io.github.dueris.originspaper.registry.Registries; import net.minecraft.world.entity.Entity; diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/Modifier.java b/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/Modifier.java index 18c0fc5eb..a0b1c5f49 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/Modifier.java +++ b/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/Modifier.java @@ -3,15 +3,14 @@ import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; import io.github.dueris.calio.data.exceptions.DataException; -import io.github.dueris.calio.parser.SerializableData; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.List; -import java.util.Optional; import java.util.function.Consumer; public class Modifier implements Comparable { @@ -30,7 +29,7 @@ public class Modifier implements Comparable { try { IModifierOperation operation = IModifierOperation.DATA_TYPE.deserialize(jsonObject.get("operation")); - SerializableData.Instance data = SerializableData.Instance.decompileJsonObject(jsonObject, operation.getData(), "Modifier", "null", Optional.of(Modifier.class)); + SerializableData.Instance data = SerializableDataBuilder.compound(operation.getData(), jsonObject, Modifier.class); return new Modifier(operation, data); diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/ModifierOperation.java b/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/ModifierOperation.java index 44b4ac659..99cf302b7 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/ModifierOperation.java +++ b/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/ModifierOperation.java @@ -1,7 +1,7 @@ package io.github.dueris.originspaper.data.types.modifier; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import net.minecraft.data.models.blockstates.PropertyDispatch; import net.minecraft.world.entity.Entity; diff --git a/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/ModifierUtil.java b/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/ModifierUtil.java index 038a0ec15..659373752 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/ModifierUtil.java +++ b/origins/src/main/java/io/github/dueris/originspaper/data/types/modifier/ModifierUtil.java @@ -1,7 +1,8 @@ package io.github.dueris.originspaper.data.types.modifier; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; import org.jetbrains.annotations.NotNull; import java.util.HashMap; @@ -11,6 +12,18 @@ public class ModifierUtil { + public static @NotNull Modifier fromAttributeModifier(@NotNull AttributeModifier attributeModifier) { + + ModifierOperation operation = switch (attributeModifier.operation()) { + case ADD_VALUE -> ModifierOperation.ADD_BASE_EARLY; + case ADD_MULTIPLIED_BASE -> ModifierOperation.MULTIPLY_BASE_MULTIPLICATIVE; + case ADD_MULTIPLIED_TOTAL -> ModifierOperation.MULTIPLY_TOTAL_MULTIPLICATIVE; + }; + + return Modifier.of(operation, attributeModifier.amount()); + + } + public static @NotNull Map> sortModifiers(@NotNull List modifiers) { Map> buckets = new HashMap<>(); for (Modifier modifier : modifiers) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/event/AttributeExecuteEvent.java b/origins/src/main/java/io/github/dueris/originspaper/event/AttributeExecuteEvent.java index dabfa450e..f68fd57f4 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/event/AttributeExecuteEvent.java +++ b/origins/src/main/java/io/github/dueris/originspaper/event/AttributeExecuteEvent.java @@ -1,6 +1,6 @@ package io.github.dueris.originspaper.event; -import io.github.dueris.originspaper.power.PowerType; +import io.github.dueris.originspaper.power.factory.PowerType; import org.bukkit.attribute.Attribute; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; diff --git a/origins/src/main/java/io/github/dueris/originspaper/event/PlayerHitGroundEvent.java b/origins/src/main/java/io/github/dueris/originspaper/event/PlayerHitGroundEvent.java deleted file mode 100644 index 69b3fcb9e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/event/PlayerHitGroundEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.github.dueris.originspaper.event; - -import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerEvent; -import org.jetbrains.annotations.NotNull; - -public class PlayerHitGroundEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - - public PlayerHitGroundEvent(@NotNull Player who) { - super(who); - } - - public static HandlerList getHandlerList() { - return handlers; - } - - public HandlerList getHandlers() { - return handlers; - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/event/PowerUpdateEvent.java b/origins/src/main/java/io/github/dueris/originspaper/event/PowerUpdateEvent.java index 3dbda8334..d2b78d18f 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/event/PowerUpdateEvent.java +++ b/origins/src/main/java/io/github/dueris/originspaper/event/PowerUpdateEvent.java @@ -1,6 +1,6 @@ package io.github.dueris.originspaper.event; -import io.github.dueris.originspaper.power.PowerType; +import io.github.dueris.originspaper.power.factory.PowerType; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/At.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/At.java index cef5dd20f..5696c1529 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/At.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/At.java @@ -19,6 +19,9 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.ItemEnchantments; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.ApiStatus; public final class At { diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockBehaviorMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockBehaviorMixin.java index 23f2204d9..9584fd556 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockBehaviorMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockBehaviorMixin.java @@ -1,8 +1,8 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; -import io.github.dueris.originspaper.power.ModifyBreakSpeedPower; -import io.github.dueris.originspaper.power.ModifyHarvestPower; +import io.github.dueris.originspaper.power.type.ModifyBreakSpeedPower; +import io.github.dueris.originspaper.power.type.ModifyHarvestPower; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.player.Player; diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockItemMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockItemMixin.java index 605eb6958..c37b92edc 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockItemMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockItemMixin.java @@ -1,7 +1,7 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; -import io.github.dueris.originspaper.power.PreventBlockPlacePower; +import io.github.dueris.originspaper.power.type.PreventBlockPlacePower; import io.github.dueris.originspaper.storage.PowerHolderComponent; import io.github.dueris.originspaper.util.Reflector; import net.minecraft.core.BlockPos; diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockMixin.java new file mode 100644 index 000000000..52348531e --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/BlockMixin.java @@ -0,0 +1,20 @@ +package io.github.dueris.originspaper.mixin; + +import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; +import io.github.dueris.originspaper.power.type.ActionOnLandPower; +import io.github.dueris.originspaper.storage.PowerHolderComponent; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; + +@Mixin({Block.class}) +public class BlockMixin { + + @Inject(method = "fallOn", locator = At.Value.HEAD) + public static void apoli$actionOnLand(Block instance, Level world, BlockState state, BlockPos pos, @NotNull Entity entity, float fallDistance, CallbackInfo info) { + PowerHolderComponent.getPowers(entity.getBukkitEntity(), ActionOnLandPower.class).forEach(p -> p.executeAction(entity)); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/CreeperMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/CreeperMixin.java index 163212d62..62a03694c 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/CreeperMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/CreeperMixin.java @@ -1,7 +1,7 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; -import io.github.dueris.originspaper.power.origins.ScareCreepersPower; +import io.github.dueris.originspaper.power.type.simple.ScareCreepersPower; import net.minecraft.world.entity.monster.Creeper; @Mixin(Creeper.class) diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/EntityMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/EntityMixin.java new file mode 100644 index 000000000..e47b65a21 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/EntityMixin.java @@ -0,0 +1,35 @@ +package io.github.dueris.originspaper.mixin; + +import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; +import io.github.dueris.originspaper.power.type.FireImmunityPower; +import io.github.dueris.originspaper.power.type.InvulnerablePower; +import io.github.dueris.originspaper.storage.PowerHolderComponent; +import net.minecraft.tags.DamageTypeTags; +import net.minecraft.tags.EntityTypeTags; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +@Mixin(Entity.class) +public class EntityMixin { + + @Inject(method = "fireImmune", locator = At.Value.RETURN) + public static void apoli$fireImmunity(@NotNull Entity instance, @NotNull CallbackInfo info) { + info.setReturned(true); + info.setReturnValue(instance.getType().fireImmune() || + PowerHolderComponent.doesHaveConditionedPower(instance.getBukkitEntity(), FireImmunityPower.class, p -> p.isActive(instance))); + } + + @Inject(method = "isInvulnerableTo", locator = At.Value.RETURN) + public static void apoli$invulnerability(@NotNull Entity instance, DamageSource damageSource, @NotNull CallbackInfo info) { + boolean original = instance.isRemoved() || instance.isInvulnerable() && + !damageSource.is(DamageTypeTags.BYPASSES_INVULNERABILITY) && !damageSource.isCreativePlayer() || + damageSource.is(DamageTypeTags.IS_FIRE) && instance.fireImmune() || damageSource.is(DamageTypeTags.IS_FALL) && + instance.getType().is(EntityTypeTags.FALL_DAMAGE_IMMUNE); + + info.setReturnValue(original || + PowerHolderComponent.doesHaveConditionedPower(instance.getBukkitEntity(), InvulnerablePower.class, p -> p.doesApply(damageSource))); + info.setReturned(true); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/EntityTypeMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/EntityTypeMixin.java index 4b1846631..19b0d76f5 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/EntityTypeMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/EntityTypeMixin.java @@ -1,15 +1,15 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; -import io.github.dueris.originspaper.power.ModifyTypeTagPower; +import io.github.dueris.originspaper.power.type.ModifyTypeTagPower; import net.minecraft.core.HolderSet; import net.minecraft.tags.TagKey; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; @Mixin(EntityType.class) @@ -21,7 +21,7 @@ public class EntityTypeMixin { boolean original = entryList.contains(instance.builtInRegistryHolder()); boolean modifyTypeTag = false; - for (Player player : PLAYER_TAG_TIE.getOrDefault(instance, new ArrayList<>())) { + for (Player player : PLAYER_TAG_TIE.getOrDefault(instance, new LinkedList<>())) { if (ModifyTypeTagPower.doesApply(player, entryList)) { modifyTypeTag = true; break; @@ -39,7 +39,7 @@ public class EntityTypeMixin { boolean original = instance.builtInRegistryHolder().is(tag); boolean modifyTypeTag = false; - for (Player player : PLAYER_TAG_TIE.getOrDefault(instance, new ArrayList<>())) { + for (Player player : PLAYER_TAG_TIE.getOrDefault(instance, new LinkedList<>())) { if (ModifyTypeTagPower.doesApply(player, tag)) { modifyTypeTag = true; break; diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/ItemEnchantmentsMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/ItemEnchantmentsMixin.java index 04c5b195d..0b98d8f9b 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/ItemEnchantmentsMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/ItemEnchantmentsMixin.java @@ -2,7 +2,7 @@ import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; -import io.github.dueris.originspaper.power.ModifyEnchantmentLevelPower; +import io.github.dueris.originspaper.power.type.ModifyEnchantmentLevelPower; import it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap; import net.minecraft.core.Holder; import net.minecraft.world.item.enchantment.Enchantment; diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/ItemEntityMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/ItemEntityMixin.java index 06162f98f..35a2fa28e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/ItemEntityMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/ItemEntityMixin.java @@ -1,7 +1,7 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; -import io.github.dueris.originspaper.power.PreventItemPickupPower; +import io.github.dueris.originspaper.power.type.PreventItemPickupPower; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/LivingEntityMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/LivingEntityMixin.java index 3f2aa288a..bb93ddba7 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/LivingEntityMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/LivingEntityMixin.java @@ -2,8 +2,8 @@ import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; -import io.github.dueris.originspaper.power.*; -import io.github.dueris.originspaper.power.origins.WaterBreathingPower; +import io.github.dueris.originspaper.power.type.simple.WaterBreathingPower; +import io.github.dueris.originspaper.power.type.*; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.core.Holder; import net.minecraft.tags.EntityTypeTags; diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/MinecraftServerMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/MinecraftServerMixin.java index daeb007c4..48b829cb9 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/MinecraftServerMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/MinecraftServerMixin.java @@ -1,9 +1,21 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; +import io.github.dueris.calio.CraftCalio; +import io.github.dueris.calio.data.DataBuildDirective; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.origin.Origin; +import io.github.dueris.originspaper.origin.OriginLayer; +import io.github.dueris.originspaper.power.factory.PowerTypeFactory; +import io.github.dueris.originspaper.registry.BuiltinRegistry; +import io.github.dueris.originspaper.registry.Registries; import io.github.dueris.originspaper.util.ApoliScheduler; import net.minecraft.server.MinecraftServer; +import org.jetbrains.annotations.NotNull; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; import java.util.function.BooleanSupplier; @Mixin(MinecraftServer.class) @@ -14,4 +26,36 @@ public static void tickHook(MinecraftServer server, BooleanSupplier shouldKeepTi ApoliScheduler scheduler = ApoliScheduler.INSTANCE; scheduler.tick(server); } + + @Inject(method = "runServer", locator = At.Value.HEAD) + public static void originspaper$init(@NotNull MinecraftServer server, CallbackInfo info) { + CraftCalio calio = CraftCalio.buildInstance().startBuilder() + .withAccessor(new DataBuildDirective<>(List.of(), "powers", PowerTypeFactory.DATA, 0, Registries.POWER)) + .withAccessor(new DataBuildDirective<>(List.of(), "origins", Origin.DATA, 1, Registries.ORIGIN)) + .withAccessor(new DataBuildDirective<>(List.of(), "origin_layers", OriginLayer.DATA, 2, Registries.LAYER)) + .build(); + PackRepositoryMixin.getAvailable(server.getPackRepository()).forEach((id, pack) -> { + Path packPath = null; + if (id.startsWith("file/")) { + String packName = id.split("file/")[1]; + packPath = PackRepositoryMixin.DATAPACK_PATH.get().resolve(packName); + } else if (id.startsWith("assets/origins/")) { + String pluginName = id.split("origins/")[1]; + packPath = Paths.get("plugins/").resolve(pluginName); + } + + if (packPath != null) { + calio.parse(packPath.toAbsolutePath()); + } + }); + + BuiltinRegistry.bootstrap(); + int[] registrySizes = new int[]{ + OriginsPaper.getRegistry().retrieve(Registries.POWER).registrySize(), OriginsPaper.getRegistry().retrieve(Registries.ORIGIN).registrySize(), OriginsPaper.getRegistry().retrieve(Registries.LAYER).registrySize() + }; + OriginsPaper.LOGGER.info("Registry contains {} powers, {} origins, and {} layers.", registrySizes[0], registrySizes[1], registrySizes[2]); + OriginsPaper.LOGGER.info("OriginsPaper {} has initialized. Ready to power up your game!", OriginsPaper.pluginData.getFullVersion()); + + calio.shutdown(); + } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/OriginsMixins.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/OriginsMixins.java index a9d5bb5a7..0e5458991 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/OriginsMixins.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/OriginsMixins.java @@ -1,15 +1,16 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.MixBukkit; +import com.dragoncommissions.mixbukkit.MixinPluginInstance; import com.dragoncommissions.mixbukkit.addons.AutoMapper; import com.dragoncommissions.mixbukkit.api.MixinPlugin; import com.dragoncommissions.mixbukkit.api.action.impl.MActionInsertShellCode; +import com.dragoncommissions.mixbukkit.api.action.impl.MActionMethodReplacer; import com.dragoncommissions.mixbukkit.api.locator.HookLocator; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.ShellCodeReflectionMixinPluginMethodCall; import io.github.classgraph.ClassGraph; import io.github.classgraph.ScanResult; import io.github.dueris.originspaper.OriginsPaper; -import org.bukkit.ChatColor; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Method; @@ -19,10 +20,10 @@ public class OriginsMixins { public static void init(@NotNull MixBukkit bukkit) { - MixinPlugin mixinPlugin = bukkit.registerMixinPlugin(OriginsPaper.getPlugin(), AutoMapper.getMappingAsStream()); + MixinPlugin mixinPlugin = bukkit.registerMixinPlugin(new MixinPluginInstance("OriginsPaper"), AutoMapper.getMappingAsStream()); ScanResult result = new ClassGraph().whitelistPackages("io.github.dueris.originspaper.mixin").enableClassInfo().scan(); - OriginsPaper.getPlugin().getServer().getConsoleSender().sendMessage(ChatColor.YELLOW + "[!] Starting Mixin transformers..."); + OriginsPaper.LOGGER.info("Starting Mixin transformers..."); AtomicInteger count = new AtomicInteger(); try { @@ -69,6 +70,33 @@ public static void init(@NotNull MixBukkit bukkit) { ); count.getAndIncrement(); + } else if (method.isAnnotationPresent(Overwrite.class)) { + Overwrite replace = method.getAnnotation(Overwrite.class); + + Method toMixin = null; + Class[] params = new Class[0]; + for (Method declared : mixin.getDeclaredMethods()) { + String methodName = declared.getName(); + String injectMethodName = replace.method().trim(); + + if (methodName.equalsIgnoreCase(injectMethodName)) { + toMixin = declared; + params = declared.getParameterTypes(); + break; + } + } + if (toMixin == null) + throw new IllegalArgumentException("Unable to locate method to mixin to!"); + + if (!Arrays.stream(replace.params()).toList().isEmpty()) { + params = replace.params(); + } + + MActionMethodReplacer replacer = new MActionMethodReplacer(toMixin); + String namespace = baseNamespace + "(" + method.getName() + ")"; + mixinPlugin.registerMixin( + namespace, replacer, mixin, toMixin.getName(), toMixin.getReturnType(), params + ); } } } @@ -87,6 +115,6 @@ public static void init(@NotNull MixBukkit bukkit) { } result.close(); - OriginsPaper.getPlugin().getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[!] Injected {} mixins successfully!".replace("{}", count.toString())); + OriginsPaper.LOGGER.info("Injected {} mixins successfully!", count.toString()); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/Overwrite.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/Overwrite.java new file mode 100644 index 000000000..a0b636428 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/Overwrite.java @@ -0,0 +1,12 @@ +package io.github.dueris.originspaper.mixin; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface Overwrite { + + String method(); + + Class[] params() default {}; +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/PackRepositoryMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/PackRepositoryMixin.java new file mode 100644 index 000000000..5109dc01a --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/PackRepositoryMixin.java @@ -0,0 +1,78 @@ +package io.github.dueris.originspaper.mixin; + +import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.data.pack.PluginRepositorySource; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.repository.*; +import net.minecraft.world.level.validation.DirectoryValidator; + +import java.lang.reflect.Field; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; + +@SuppressWarnings("unchecked") +@Mixin(PackRepository.class) +public class PackRepositoryMixin { + static final AtomicReference DATAPACK_PATH = new AtomicReference<>(); + + @Inject(method = "reload", locator = At.Value.HEAD) + public static void origins$loadPack(PackRepository instance, CallbackInfo info) { + RepositorySource toAdd = null; + + for (RepositorySource source : getSources(instance)) { + if (source instanceof FolderRepositorySource folderRepositorySource) { + try { + Field folder = FolderRepositorySource.class.getDeclaredField("folder"); + Field validator = FolderRepositorySource.class.getDeclaredField("validator"); + folder.setAccessible(true); + validator.setAccessible(true); + + Path datapackFolder = (Path) folder.get(folderRepositorySource); + toAdd = new PluginRepositorySource(Paths.get("plugins/"), PackType.SERVER_DATA, PackSource.WORLD, (DirectoryValidator) validator.get(folderRepositorySource), OriginsPaper.jarFile.getFileName().toString()); + + DATAPACK_PATH.set(datapackFolder); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + Set sources = new HashSet<>(getSources(instance)); + if (!sources.stream().map(Object::getClass).toList().contains(PluginRepositorySource.class)) { + sources.add(toAdd); + try { + Field sourceField = PackRepository.class.getDeclaredField("sources"); + sourceField.setAccessible(true); + sourceField.set(instance, sources); + OriginsPaper.LOGGER.info("Loaded PluginPackRepository in repository sources."); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + public static Set getSources(PackRepository instance) { + try { + Field sources = PackRepository.class.getDeclaredField("sources"); + sources.setAccessible(true); + return (Set) sources.get(instance); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + + public static Map getAvailable(PackRepository instance) { + try { + Field available = PackRepository.class.getDeclaredField("available"); + available.setAccessible(true); + return (Map) available.get(instance); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/PlayerMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/PlayerMixin.java index c7b3d6610..6b0e42d5d 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/PlayerMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/PlayerMixin.java @@ -1,8 +1,12 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; -import io.github.dueris.originspaper.power.origins.LikeWaterPower; +import io.github.dueris.originspaper.power.type.ActionOnWakeUpPower; +import io.github.dueris.originspaper.power.type.PhasingPower; +import io.github.dueris.originspaper.power.type.simple.LikeWaterPower; import io.github.dueris.originspaper.storage.PowerHolderComponent; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.tags.FluidTags; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; @@ -16,9 +20,12 @@ @Mixin(Player.class) public class PlayerMixin { - @Inject(method = "tick", locator = At.Value.HEAD) - public static void apoli$likeWater(Player instance, CallbackInfo info) { + @Inject(method = "tick", locator = At.Value.RETURN) + public static void apoli$likeWater(@NotNull Player instance, CallbackInfo info) { LikeWaterPower.tick((org.bukkit.entity.Player) instance.getBukkitEntity()); + if (PowerHolderComponent.hasPowerType(instance.getBukkitEntity(), PhasingPower.class)) { + instance.noPhysics = true; + } } @Inject(method = "turtleHelmetTick", locator = At.Value.HEAD) @@ -32,4 +39,12 @@ public class PlayerMixin { info.setReturned(true); } + + @Inject(method = "stopSleepInBed", locator = At.Value.HEAD) + public static void apoli$actionOnWakeUp(Player instance, boolean bl, boolean updateSleepingPlayers, CallbackInfo info) { + if(!bl && !updateSleepingPlayers && instance.getSleepingPos().isPresent()) { + BlockPos sleepingPos = instance.getSleepingPos().get(); + PowerHolderComponent.getPowers(instance.getBukkitEntity(), ActionOnWakeUpPower.class).stream().filter(p -> p.doesApply(sleepingPos, instance)).forEach(p -> p.executeActions(sleepingPos, Direction.DOWN, instance)); + } + } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/ServerLevelMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/ServerLevelMixin.java index c6ef3a004..04cc832d5 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/ServerLevelMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/ServerLevelMixin.java @@ -1,7 +1,7 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; -import io.github.dueris.originspaper.power.PreventGameEventPower; +import io.github.dueris.originspaper.power.type.PreventGameEventPower; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.core.Holder; import net.minecraft.server.level.ServerLevel; diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/ServerPlayerMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/ServerPlayerMixin.java index e9cce2ded..99ad8f034 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/ServerPlayerMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/ServerPlayerMixin.java @@ -3,8 +3,9 @@ import com.destroystokyo.paper.event.player.PlayerSetSpawnEvent; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; import com.mojang.datafixers.util.Either; -import io.github.dueris.originspaper.power.PreventSleepPower; +import io.github.dueris.originspaper.power.type.PreventSleepPower; import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.util.LangFile; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; @@ -12,7 +13,7 @@ import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import static io.github.dueris.originspaper.mixin.EntityTypeMixin.PLAYER_TAG_TIE; @@ -27,7 +28,7 @@ public class ServerPlayerMixin { return p.doesPrevent(player.level(), blockposition); })) { prevent = true; - Component component = power.getMessage(); + Component component = LangFile.translatable(power.getMessage().getString()); if (power.doesAllowSpawnPoint() && !respawnSet) { player.setRespawnPosition(player.level().dimension(), blockposition, player.getYRot(), false, true, PlayerSetSpawnEvent.Cause.BED); @@ -44,9 +45,9 @@ public class ServerPlayerMixin { } @Inject(method = "tick", locator = At.Value.HEAD) - public static void apoli$modifyTypeTagUpdater(ServerPlayer player, CallbackInfo info) { + public static void apoli$modifyTypeTagUpdater(@NotNull ServerPlayer player, CallbackInfo info) { if (!PLAYER_TAG_TIE.containsKey(player.getType())) { - PLAYER_TAG_TIE.put(player.getType(), new ArrayList<>()); + PLAYER_TAG_TIE.put(player.getType(), new LinkedList<>()); PLAYER_TAG_TIE.get(player.getType()).add(player); } else if (!PLAYER_TAG_TIE.get(player.getType()).contains(player)) { PLAYER_TAG_TIE.get(player.getType()).add(player); diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/StatusEffectMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/StatusEffectMixin.java index 39b1e8a92..550218e1e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/mixin/StatusEffectMixin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/StatusEffectMixin.java @@ -1,7 +1,7 @@ package io.github.dueris.originspaper.mixin; import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; -import io.github.dueris.originspaper.power.EffectImmunityPower; +import io.github.dueris.originspaper.power.type.EffectImmunityPower; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.effect.MobEffect; diff --git a/origins/src/main/java/io/github/dueris/originspaper/mixin/ThrownEnderpearlMixin.java b/origins/src/main/java/io/github/dueris/originspaper/mixin/ThrownEnderpearlMixin.java new file mode 100644 index 000000000..3ea1ab04b --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/mixin/ThrownEnderpearlMixin.java @@ -0,0 +1,49 @@ +package io.github.dueris.originspaper.mixin; + +import com.dragoncommissions.mixbukkit.api.shellcode.impl.api.CallbackInfo; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.phys.HitResult; + +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +@Mixin(ThrownEnderpearl.class) +public class ThrownEnderpearlMixin { + public static List ENDERIAN_PEARLS = new CopyOnWriteArrayList<>(); + + @Inject(method = "onHit", locator = At.Value.HEAD) + public static void origins$enderianPearlHit(ThrownEnderpearl instance, HitResult result, CallbackInfo info) { + if (ENDERIAN_PEARLS.contains(instance)) { + ENDERIAN_PEARLS.remove(instance); + info.setReturned(true); + info.setReturnValue(false); + Entity entity = instance.getOwner(); + + for (int i = 0; i < 32; ++i) { + instance.level().addParticle(ParticleTypes.PORTAL, instance.getX(), instance.getY() + instance.random.nextDouble() * 2.0D, instance.getZ(), instance.random.nextGaussian(), 0.0D, instance.random.nextGaussian()); + } + + if (!instance.level().isClientSide && !instance.isRemoved()) { + if (entity instanceof ServerPlayer serverPlayerEntity) { + if (serverPlayerEntity.connection.isAcceptingMessages() && serverPlayerEntity.level() == instance.level() && !serverPlayerEntity.isSleeping()) { + + if (entity.isPassenger()) { + entity.stopRiding(); + } + + entity.teleportTo(instance.getX(), instance.getY(), instance.getZ()); + entity.fallDistance = 0.0F; + } + } else if (entity != null) { + entity.teleportTo(instance.getX(), instance.getY(), instance.getZ()); + entity.fallDistance = 0.0F; + } + + instance.discard(); + } + } + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/origin/Origin.java b/origins/src/main/java/io/github/dueris/originspaper/origin/Origin.java index b7a90cbe6..cfd246bea 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/origin/Origin.java +++ b/origins/src/main/java/io/github/dueris/originspaper/origin/Origin.java @@ -1,14 +1,19 @@ package io.github.dueris.originspaper.origin; +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.calio.parser.RootResult; +import io.github.dueris.calio.util.Util; import io.github.dueris.calio.util.holder.TriPair; import io.github.dueris.originspaper.data.OriginsDataTypes; import io.github.dueris.originspaper.data.types.Impact; import io.github.dueris.originspaper.data.types.OriginUpgrade; import io.github.dueris.originspaper.util.AsyncUpgradeTracker; +import io.github.dueris.originspaper.util.ComponentUtil; import io.github.dueris.originspaper.util.LangFile; -import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -21,6 +26,23 @@ import java.util.List; public class Origin { + public static Origin EMPTY; + public static SerializableDataBuilder> DATA = SerializableDataBuilder.of( + (jsonElement) -> { + if (!(jsonElement instanceof JsonObject jo)) { + throw new JsonSyntaxException("Expected JsonObject for root 'Origin'"); + } + + try { + SerializableData.Instance compound = SerializableDataBuilder.compound(getFactory(), jo, Origin.class); + return new RootResult<>( + Util.generateConstructor(Origin.class, getFactory()), compound + ); + } catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + }, Origin.class + ); private final List powers; private final net.minecraft.world.item.ItemStack icon; private final boolean unchoosable; @@ -45,17 +67,17 @@ public Origin(@NotNull ResourceLocation key, List powers, net. if (upgrade != null) { AsyncUpgradeTracker.upgrades.put(this, new TriPair<>(upgrade.advancementCondition(), upgrade.upgradeToOrigin(), upgrade.announcement())); } - this.name = Component.text( - LangFile.transform((name != null ? name.getString() : "origin.$namespace.$path.name") + this.name = ComponentUtil.nmsToKyori( + LangFile.translatable((name != null ? name.getString() : "origin.$namespace.$path.name") .replace("$namespace", key.getNamespace()).replace("$path", key.getPath())) ); - this.description = Component.text( - LangFile.transform((description != null ? description.getString() : "origin.$namespace.$path.description") + this.description = ComponentUtil.nmsToKyori( + LangFile.translatable((description != null ? description.getString() : "origin.$namespace.$path.description") .replace("$namespace", key.getNamespace()).replace("$path", key.getPath())) ); } - public static SerializableData buildFactory() { + public static SerializableData getFactory() { return SerializableData.serializableData() .add("powers", SerializableDataTypes.list(SerializableDataTypes.IDENTIFIER), new LinkedList<>()) .add("icon", SerializableDataTypes.ITEM_STACK, Items.PLAYER_HEAD.getDefaultInstance()) @@ -96,15 +118,15 @@ public int loadingPriority() { return loadingPriority; } - public TextComponent name() { + public TextComponent getName() { return name; } - public TextComponent description() { + public TextComponent getDescription() { return description; } - public @NotNull ResourceLocation key() { + public @NotNull ResourceLocation getId() { return key; } diff --git a/origins/src/main/java/io/github/dueris/originspaper/origin/OriginLayer.java b/origins/src/main/java/io/github/dueris/originspaper/origin/OriginLayer.java index e1187717c..edf3a2001 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/origin/OriginLayer.java +++ b/origins/src/main/java/io/github/dueris/originspaper/origin/OriginLayer.java @@ -1,16 +1,21 @@ package io.github.dueris.originspaper.origin; +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.calio.parser.RootResult; import io.github.dueris.calio.registry.Registrar; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.OriginsDataTypes; import io.github.dueris.originspaper.data.types.GuiTitle; import io.github.dueris.originspaper.registry.Registries; import io.github.dueris.originspaper.screen.ScreenNavigator; -import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.storage.OriginComponent; +import io.github.dueris.originspaper.util.ComponentUtil; import io.github.dueris.originspaper.util.LangFile; import io.github.dueris.originspaper.util.Util; import net.kyori.adventure.text.TextComponent; @@ -20,12 +25,27 @@ import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.function.Predicate; public class OriginLayer { + public static SerializableDataBuilder> DATA = SerializableDataBuilder.of( + (jsonElement) -> { + if (!(jsonElement instanceof JsonObject jo)) { + throw new JsonSyntaxException("Expected JsonObject for root 'OriginLayer'"); + } + + try { + SerializableData.Instance compound = SerializableDataBuilder.compound(getFactory(), jo, OriginLayer.class); + return new RootResult<>( + io.github.dueris.calio.util.Util.generateConstructor(OriginLayer.class, getFactory()), compound + ); + } catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + }, OriginLayer.class + ); private final ResourceLocation key; private final String tag; private final int loadingPriority; @@ -52,8 +72,8 @@ public OriginLayer(@NotNull ResourceLocation key, int order, int loadingPriority this.origins = origins; this.replace = replace; this.enabled = enabled; - this.name = net.kyori.adventure.text.Component.text( - LangFile.transform((name != null ? name.getString() : "origin.$namespace.$path.name") + this.name = ComponentUtil.nmsToKyori( + LangFile.translatable((name != null ? name.getString() : "origin.$namespace.$path.name") .replace("$namespace", key.getNamespace()).replace("$path", key.getPath())) ); this.guiTitle = guiTitle; @@ -66,7 +86,7 @@ public OriginLayer(@NotNull ResourceLocation key, int order, int loadingPriority this.hidden = hidden; } - public static SerializableData buildFactory() { + public static SerializableData getFactory() { return SerializableData.serializableData() .add("order", SerializableDataTypes.INT, Integer.MAX_VALUE) .add("loading_priority", SerializableDataTypes.INT, 0) @@ -97,7 +117,7 @@ public List getOrigins() { } public List testChoosable(net.minecraft.world.entity.Entity entity) { - List tested = new ArrayList<>(); + List tested = new LinkedList<>(); for (ConditionedOrigin origin : this.getOrigins()) { List conditionedOrigins = origin.origins.stream().map(OriginsPaper::getOrigin).toList(); @@ -115,15 +135,15 @@ public boolean testDefaultOrigin(net.minecraft.world.entity.player.Player entity boolean autoChoose = this.isAutoChoose(); if (defaultOrigin == null) return false; if (autoChoose) { - PowerHolderComponent.setOrigin(entity.getBukkitEntityRaw(), this, OriginsPaper.getOrigin(defaultOrigin)); + OriginComponent.setOrigin(entity.getBukkitEntityRaw(), this, OriginsPaper.getOrigin(defaultOrigin)); return true; } else if (ScreenNavigator.orbChoosing.contains(entity)) { return false; } else { - if (!defaultOrigin.equals(OriginsPaper.EMPTY_ORIGIN.key())) { - Origin origin = OriginsPaper.getPlugin().registry.retrieve(Registries.ORIGIN).get(defaultOrigin); + if (!defaultOrigin.equals(Origin.EMPTY.getId())) { + Origin origin = OriginsPaper.getRegistry().retrieve(Registries.ORIGIN).get(defaultOrigin); if (origin != null) { - PowerHolderComponent.setOrigin(entity.getBukkitEntityRaw(), this, origin); + OriginComponent.setOrigin(entity.getBukkitEntityRaw(), this, origin); return true; } } @@ -137,15 +157,15 @@ public List getOriginIdentifiers() { } public List getRandomOrigins() { - return !this.isAllowRandom() - ? new ArrayList<>() + return !this.isRandomAllowed() + ? new LinkedList<>() : getOriginIdentifiers().stream() .map(OriginsPaper::getOrigin) .filter(origin -> !origin.unchoosable() || this.isAllowRandomUnchoosable()) .filter(origin -> { if (!this.getExcludeRandom().isEmpty()) { for (ResourceLocation identifier : this.getExcludeRandom().stream().toList()) { - if (origin.key().equals(identifier)) { + if (origin.getId().equals(identifier)) { return false; } } @@ -172,7 +192,7 @@ public GuiTitle getGuiTitle() { return guiTitle; } - public boolean isAllowRandom() { + public boolean isRandomAllowed() { return allowRandom; } @@ -201,7 +221,7 @@ public boolean isHidden() { } public boolean canRegister() { - Registrar registrar = OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER); + Registrar registrar = OriginsPaper.getRegistry().retrieve(Registries.LAYER); boolean merge = registrar.keySet().contains(this.key); if (merge) { OriginLayer otherLayer = registrar.get(this.key); @@ -240,7 +260,7 @@ public boolean canRegister() { return true; } - public ResourceLocation key() { + public ResourceLocation getId() { return key; } @@ -266,11 +286,6 @@ public ConditionTypeFactory getCondition() { return condition; } - @Deprecated - public List getOrigins() { - return origins; - } - @Override public String toString() { return "ConditionedOrigin{" + diff --git a/origins/src/main/java/io/github/dueris/originspaper/plugin/OriginsPlugin.java b/origins/src/main/java/io/github/dueris/originspaper/plugin/OriginsPlugin.java new file mode 100644 index 000000000..94b678b34 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/plugin/OriginsPlugin.java @@ -0,0 +1,96 @@ +package io.github.dueris.originspaper.plugin; + +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.content.OrbOfOrigins; +import io.github.dueris.originspaper.integration.CraftPehuki; +import io.github.dueris.originspaper.power.type.RecipePower; +import io.github.dueris.originspaper.registry.Registries; +import io.github.dueris.originspaper.screen.ChoosingPage; +import io.github.dueris.originspaper.screen.RandomOriginPage; +import io.github.dueris.originspaper.screen.ScreenNavigator; +import io.github.dueris.originspaper.storage.PlayerPowerRepository; +import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.util.ApoliScheduler; +import io.github.dueris.originspaper.util.AsyncUpgradeTracker; +import io.github.dueris.originspaper.util.BstatsMetrics; +import io.github.dueris.originspaper.util.KeybindUtil; +import io.github.dueris.originspaper.util.entity.GlowingEntitiesUtils; +import io.github.dueris.originspaper.util.entity.PlayerManager; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.server.ServerLoadEvent; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +public final class OriginsPlugin extends JavaPlugin implements Listener { + public static OriginsPlugin plugin; + public static GlowingEntitiesUtils glowingEntitiesUtils; + public static BstatsMetrics metrics; + + @Override + public void onEnable() { + plugin = this; + metrics = new BstatsMetrics(this, 18536); + OriginsPaper.server = MinecraftServer.getServer(); + glowingEntitiesUtils = new GlowingEntitiesUtils(this); + registerListeners(); + + new BukkitRunnable() { + @Override + public void run() { + ApoliScheduler.tickAsyncScheduler(); + } + }.runTaskTimerAsynchronously(this, 0L, 1L); + + CraftPehuki.onLoad(); + Bukkit.updateRecipes(); + } + + @Override + public void onDisable() { + try { + for (Player player : Bukkit.getOnlinePlayers()) { + player.closeInventory(); + player.getPersistentDataContainer() + .set(new NamespacedKey(this, "powers"), PersistentDataType.STRING, + PlayerPowerRepository.getOrCreateRepo(((CraftPlayer) player).getHandle()).serializePowers(new CompoundTag(), ((CraftPlayer) player).getHandle()).toString()); + PowerHolderComponent.unloadPowers(player); + } + + glowingEntitiesUtils.disable(); + RecipePower.recipeMapping.clear(); + RecipePower.tags.clear(); + OriginsPaper.getRegistry().clearRegistries(); + } catch (Throwable var3) { + OriginsPaper.LOGGER.error("An unhandled exception occurred when disabling OriginsPaper!"); + } + } + + private void registerListeners() { + this.getServer().getPluginManager().registerEvents(this, this); + this.getServer().getPluginManager().registerEvents(new PlayerManager(), this); + this.getServer().getPluginManager().registerEvents(new ScreenNavigator(), this); + this.getServer().getPluginManager().registerEvents(new KeybindUtil(), this); + this.getServer().getPluginManager().registerEvents(new AsyncUpgradeTracker(), this); + this.getServer().getPluginManager().registerEvents(new PowerHolderComponent(), this); + this.getServer().getPluginManager().registerEvents(new CraftPehuki(), this); + OriginsPaper.getRegistry().retrieve(Registries.POWER).values().forEach(powerType -> { + this.getServer().getPluginManager().registerEvents(powerType, this); + }); + } + + @EventHandler + public void loadEvent(ServerLoadEvent e) { + ChoosingPage.registerInstances(); + ScreenNavigator.layerPages.values().forEach(pages -> pages.add(pages.size(), new RandomOriginPage())); + OrbOfOrigins.init(); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/CooldownInterface.java b/origins/src/main/java/io/github/dueris/originspaper/power/CooldownInterface.java deleted file mode 100644 index 1a98d50a6..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/power/CooldownInterface.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.dueris.originspaper.power; - -public interface CooldownInterface extends ResourceInterface { - int getCooldown(); -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/CooldownPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/CooldownPower.java deleted file mode 100644 index 3a44e8e1f..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/power/CooldownPower.java +++ /dev/null @@ -1,155 +0,0 @@ -package io.github.dueris.originspaper.power; - -import com.destroystokyo.paper.event.server.ServerTickEndEvent; -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.calio.util.holder.Pair; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.HudRender; -import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.util.ModifiableFloatPair; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.Entity; -import org.bukkit.Bukkit; -import org.bukkit.boss.KeyedBossBar; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.server.ServerLoadEvent; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import static io.github.dueris.originspaper.power.ResourcePower.currentlyDisplayed; -import static io.github.dueris.originspaper.power.ResourcePower.serverLoadedBars; - -public class CooldownPower extends PowerType implements CooldownInterface { - private static final ConcurrentHashMap timingsTracker = new ConcurrentHashMap<>(); - private static final Set ticked = new HashSet<>(); - public static ConcurrentHashMap>> cooldowns = new ConcurrentHashMap<>(); - private final HudRender hudRender; - private final int cooldown; - - public CooldownPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, - HudRender hudRender, int cooldown) { - super(key, type, name, description, hidden, condition, loadingPriority); - this.hudRender = hudRender; - this.cooldown = cooldown; - } - - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("cooldown")) - .add("hud_render", ApoliDataTypes.HUD_RENDER, HudRender.DONT_RENDER) - .add("cooldown", SerializableDataTypes.INT, 0); - } - - public static void addCooldown(org.bukkit.entity.Entity player, CooldownInterface power) { - if (power.getCooldown() <= 1 || !(player instanceof Player)) return; - addCooldown((Player) player, power); - } - - protected static void addCooldown(Player player, CooldownInterface power) { - if (power.getCooldown() <= 1) return; - cooldowns.putIfAbsent(player, new ArrayList<>()); - if (isInCooldown(player, power)) return; // Already in cooldown - ResourcePower.Bar bar = new ResourcePower.Bar(power, player); - currentlyDisplayed.putIfAbsent(player, new ArrayList<>()); - currentlyDisplayed.get(player).add(bar); - Pair pair = new Pair<>(bar.renderedBar, power); - cooldowns.get(player).add(pair); - timingsTracker.put(pair.first(), new ModifiableFloatPair(power.getCooldown(), power.getCooldown())); - } - - public static boolean isInCooldown(org.bukkit.entity.Entity player, ResourceInterface power) { - if (!(player instanceof Player)) return false; - cooldowns.putIfAbsent((Player) player, new ArrayList<>()); - for (Pair pair : cooldowns.get(player)) { - if (pair.second().getTag().equalsIgnoreCase(power.getTag())) return true; - } - return false; - } - - @Override - public boolean isActive(@NotNull Entity player) { - return super.isActive(player) && isInCooldown(player.getBukkitEntity(), this); - } - - @EventHandler(priority = EventPriority.HIGH) - public void preLoad(ServerLoadEvent e) { - OriginsPaper.getPlugin().registry.retrieve(Registries.CRAFT_POWER).values().stream() - .filter(p -> (p.getType().equalsIgnoreCase(getType()))).forEach(power -> { - serverLoadedBars.put(power.getTag(), null); - }); - } - - @EventHandler - public void serverTickEnd(ServerTickEndEvent e) { - ticked.clear(); - } - - @Override - public void tick() { - Util.collapseList(new ArrayList<>(cooldowns.values())).forEach((pair) -> { - KeyedBossBar bar = pair.first(); - String keyString = bar.getKey().asString(); - if (ticked.contains(keyString)) { - return; - } - ticked.add(keyString); - ModifiableFloatPair floatPair = timingsTracker.get(bar); - float max = floatPair.a(); - float cur = floatPair.setB(floatPair.b() - 1); - if (cur <= 0) { - for (Player player : bar.getPlayers()) { - currentlyDisplayed.putIfAbsent(player, new ArrayList<>()); - ResourcePower.Bar b = null; - for (ResourcePower.Bar b1 : currentlyDisplayed.get(player)) { - if (b1.renderedBar.equals(bar)) { - b = b1; - break; - } - } - if (b != null) { - currentlyDisplayed.get(player).remove(b); - } - } - bar.setProgress(0); - bar.setVisible(false); - bar.removeAll(); - Bukkit.getServer().removeBossBar(bar.getKey()); - scheduleRemoval(pair); - } else { - bar.setProgress(1 - (cur / max)); - } - }); - } - - private void scheduleRemoval(Pair pair) { - for (Player p : cooldowns.keySet()) { - if (cooldowns.get(p).contains(pair)) { - cooldowns.get(p).remove(pair); - break; - } - } - - timingsTracker.remove(pair.first()); - } - - @Override - public HudRender getHudRender() { - return hudRender; - } - - @Override - public int getCooldown() { - return cooldown; - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/DontRegister.java b/origins/src/main/java/io/github/dueris/originspaper/power/DontRegister.java deleted file mode 100644 index 0e7e889b1..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/power/DontRegister.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.github.dueris.originspaper.power; - -public interface DontRegister { -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/FireImmunityPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/FireImmunityPower.java deleted file mode 100644 index bdf5ac90e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/power/FireImmunityPower.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.github.dueris.originspaper.power; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.Entity; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class FireImmunityPower extends PowerType { - private static final List POSSIBLE_CAUSES = List.of(EntityDamageEvent.DamageCause.FIRE, EntityDamageEvent.DamageCause.FIRE_TICK, EntityDamageEvent.DamageCause.LAVA, EntityDamageEvent.DamageCause.HOT_FLOOR); - - public FireImmunityPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority) { - super(key, type, name, description, hidden, condition, loadingPriority); - } - - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("fire_immunity")); - } - - @EventHandler - public void onDamage(@NotNull EntityDamageEvent e) { - if (e.getEntity().isDead()) return; - if (e.getEntity() instanceof Player player && POSSIBLE_CAUSES.contains(e.getCause())) { - net.minecraft.world.entity.player.Player nms = ((CraftPlayer) player).getHandle(); - if (getPlayers().contains(nms) && isActive(nms)) { - e.setCancelled(true); - e.setDamage(0); - } - } - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/MultiplePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/MultiplePower.java deleted file mode 100644 index 36d37dc73..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/power/MultiplePower.java +++ /dev/null @@ -1,78 +0,0 @@ -package io.github.dueris.originspaper.power; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.dueris.calio.data.AccessorKey; -import io.github.dueris.calio.parser.CalioParser; -import io.github.dueris.calio.parser.ParsingStrategy; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.calio.util.ReflectionUtils; -import io.github.dueris.calio.util.holder.ObjectProvider; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.registry.Registries; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Tuple; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.concurrent.ConcurrentLinkedQueue; - -public class MultiplePower extends PowerType { - private final List subPowers = new ArrayList<>(); - - public MultiplePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority) { - super(key, type, name, description, hidden, condition, loadingPriority); - } - - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("multiple")); - } - - @Override - @SuppressWarnings("unchecked") - public void onBootstrap() { - for (String key : sourceObject.keySet()) { - JsonElement element = sourceObject.get(key); - if (!element.isJsonObject()) continue; - - JsonObject jo = sourceObject.getAsJsonObject(key); - AccessorKey accessorKey = new AccessorKey<>(List.of("apoli", "origins"), "power", PowerType.class, 0, ParsingStrategy.TYPED, Registries.CRAFT_POWER); - - ConcurrentLinkedQueue>> typedTempInstance = new ConcurrentLinkedQueue<>(); - final Class[] defaultType = new Class[]{null}; - Class clz = accessorKey.strategy().equals(ParsingStrategy.DEFAULT) ? accessorKey.toBuild() : - ((ObjectProvider>) () -> { - try { - ConcurrentLinkedQueue> instanceTypes = (ConcurrentLinkedQueue>) ReflectionUtils.getStaticFieldValue(accessorKey.toBuild(), "INSTANCE_TYPES"); - for (Class instanceType : instanceTypes) { - if (ReflectionUtils.hasMethod(instanceType, "buildFactory", true)) { - typedTempInstance.add(new Tuple<>(ReflectionUtils.invokeStaticMethod(instanceType, "buildFactory"), instanceType)); - } - } - if (ReflectionUtils.hasField(accessorKey.toBuild(), "DEFAULT_TYPE", true)) { - defaultType[0] = (Class) ReflectionUtils.getStaticFieldValue(accessorKey.toBuild(), "DEFAULT_TYPE"); - } - } catch (Throwable throwable) { - throw new RuntimeException("Unable to parse INSTANCE_TYPES field for class '" + accessorKey.toBuild().getSimpleName() + "'"); - } - return (Class) accessorKey.toBuild(); - }).get(); - Tuple pathAndSource = new Tuple<>( - ResourceLocation.fromNamespaceAndPath(key().getNamespace(), key().getPath() + "_" + key.toLowerCase(Locale.getDefault())), jo.toString()); - PowerType type = CalioParser.parseFile(pathAndSource, clz, accessorKey, defaultType, typedTempInstance); - if (type != null) { - subPowers.add(type); - } - } - } - - public List getSubPowers() { - return subPowers; - } - -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ResourcePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/ResourcePower.java deleted file mode 100644 index 8819c61b2..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ResourcePower.java +++ /dev/null @@ -1,395 +0,0 @@ -package io.github.dueris.originspaper.power; - -import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.calio.util.holder.ObjectProvider; -import io.github.dueris.calio.util.holder.Pair; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.data.types.Comparison; -import io.github.dueris.originspaper.data.types.HudRender; -import io.github.dueris.originspaper.event.PowerUpdateEvent; -import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.storage.PowerHolderComponent; -import io.github.dueris.originspaper.util.Util; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.Entity; -import org.bukkit.Bukkit; -import org.bukkit.NamespacedKey; -import org.bukkit.boss.BarColor; -import org.bukkit.boss.BarStyle; -import org.bukkit.boss.KeyedBossBar; -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.server.ServerLoadEvent; -import org.bukkit.persistence.PersistentDataType; -import org.bukkit.scheduler.BukkitRunnable; -import org.jetbrains.annotations.NotNull; - -import java.util.*; -import java.util.function.BinaryOperator; - -public class ResourcePower extends PowerType implements ResourceInterface { - public static HashMap serverLoadedBars = new HashMap<>(); - public static HashMap> currentlyDisplayed = new HashMap<>(); - - static { - OriginsPaper.preShutdownTasks.add(() -> { - serverLoadedBars.values().stream().filter(Objects::nonNull).forEach(Bar::delete); - currentlyDisplayed.forEach((player, list) -> list.forEach(Bar::delete)); - }); - } - - protected final int min; - protected final int max; - protected final int startValue; - protected final ActionTypeFactory minAction; - protected final ActionTypeFactory maxAction; - protected final HudRender hudRender; - - public ResourcePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, - int min, int max, Optional startValue, ActionTypeFactory minAction, ActionTypeFactory maxAction, HudRender hudRender) { - super(key, type, name, description, hidden, condition, loadingPriority); - this.min = min; - this.max = max; - this.startValue = ((ObjectProvider) () -> startValue.isPresent() ? startValue.get() : min).get(); - this.minAction = minAction; - this.maxAction = maxAction; - this.hudRender = hudRender; - } - - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("resource")) - .add("min", SerializableDataTypes.INT) - .add("max", SerializableDataTypes.INT) - .add("start_value", SerializableDataTypes.optional(SerializableDataTypes.INT), Optional.empty()) - .add("min_action", ApoliDataTypes.ENTITY_ACTION, null) - .add("max_action", ApoliDataTypes.ENTITY_ACTION, null) - .add("hud_render", ApoliDataTypes.HUD_RENDER, HudRender.DONT_RENDER); - } - - public static Optional getDisplayedBar(@NotNull Entity player, String identifier) { - currentlyDisplayed.putIfAbsent((Player) player.getBukkitEntity(), new ArrayList<>()); - - for (Bar bar : currentlyDisplayed.get((Player) player.getBukkitEntity())) { - if (bar.power.getTag().equalsIgnoreCase(identifier)) { - return Optional.of(bar); - } - } - - return Optional.empty(); - } - - protected static @NotNull KeyedBossBar createRender(String title, double currentProgress, final @NotNull ResourceInterface power, final Player player) { - ResourceLocation f = ResourceLocation.parse(power.getTag() + "_bar_server_loaded"); - final KeyedBossBar bossBar = Bukkit.createBossBar( - player == null ? CraftNamespacedKey.fromMinecraft(f) : NamespacedKey.fromString(power.getTag() + "_bar_" + player.getName().toLowerCase()), - title, - Bar.getBarColor(power.getHudRender()), - BarStyle.SEGMENTED_6 - ); - bossBar.setProgress(currentProgress); - new BukkitRunnable() { - @Override - public void run() { - if (!power.getHudRender().shouldRender()) { - bossBar.setVisible(false); - this.cancel(); - } else { - if (power.getHudRender().condition() != null) { - if (player == null) return; - bossBar.setVisible(power.getHudRender().condition().test(((CraftPlayer) player).getHandle())); - } else { - bossBar.setVisible(true); - } - } - } - }.runTaskTimer(OriginsPaper.getPlugin(), 0, 1); - return bossBar; - } - - @Deprecated(forRemoval = true) - private static @NotNull Map> createOperationMappings( - BinaryOperator addition, - BinaryOperator subtraction, - BinaryOperator multiplication, - BinaryOperator division, - BinaryOperator multiplyBase, - BinaryOperator multiplyTotal, - BinaryOperator multiplyTotalAddictive, - BinaryOperator minBase, - BinaryOperator maxBase) { - - Map> operationMap = new HashMap<>(); - operationMap.put("addition", addition); - operationMap.put("add", addition); - operationMap.put("add_value", addition); - operationMap.put("subtract_value", addition); - operationMap.put("subtraction", subtraction); - operationMap.put("subtract", subtraction); - operationMap.put("multiplication", multiplication); - operationMap.put("multiply", multiplication); - operationMap.put("division", division); - operationMap.put("divide", division); - operationMap.put("multiply_base", multiplyBase); - operationMap.put("multiply_total", multiplyTotal); - operationMap.put("set_total", (a, b) -> b); - operationMap.put("set", (a, b) -> b); - operationMap.put("add_base_early", addition); - operationMap.put("multiply_base_additive", multiplyBase); - operationMap.put("multiply_base_multiplicative", multiplyTotal); - operationMap.put("add_base_late", addition); - operationMap.put("multiply_total_additive", multiplyTotalAddictive); - operationMap.put("multiply_total_multiplicative", multiplyTotal); - operationMap.put("min_base", minBase); - operationMap.put("max_base", maxBase); - operationMap.put("min_total", minBase); - operationMap.put("max_total", maxBase); - return operationMap; - } - - @Deprecated(forRemoval = true) - public static @NotNull Map> getOperationMappingsDouble() { - return createOperationMappings( - Double::sum, - (a, b) -> a - b, - (a, b) -> a * b, - (a, b) -> a / b, - (a, b) -> a + a * b, - (a, b) -> a * (1.0 + b), - (a, b) -> a * a * b, - (a, b) -> a > b ? a : b, - (a, b) -> a < b ? a : b - ); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void preLoad(ServerLoadEvent e) { - OriginsPaper.getPlugin() - .registry - .retrieve(Registries.CRAFT_POWER) - .values() - .stream() - .filter(p -> p.getType().equalsIgnoreCase(this.getType())) - .forEach(power -> { - Bar bar = new Bar((ResourcePower) power, null); - serverLoadedBars.put(power.getTag(), bar); - }); - - for (Player player : Bukkit.getOnlinePlayers()) { - PowerHolderComponent.getPowers(player, ResourcePower.class).forEach(power -> this.powerAdd(new PowerUpdateEvent(player, power, false, false))); - } - } - - @EventHandler - public void powerAdd(@NotNull PowerUpdateEvent e) { - if (e.getPower() instanceof ResourcePower && e.getPower().getTag().equalsIgnoreCase(this.getTag())) { - currentlyDisplayed.putIfAbsent(e.getPlayer(), new ArrayList<>()); - if (!e.isRemoved()) { - if (serverLoadedBars.containsKey(e.getPower().getTag())) { - Bar displayed = serverLoadedBars.get(e.getPower().getTag()); - if (!currentlyDisplayed.get(e.getPlayer()).contains(displayed) && - !currentlyDisplayed.get(e.getPlayer()).stream().map(Bar::getPower).toList().contains(displayed.power)) { - currentlyDisplayed.get(e.getPlayer()).add(displayed.cloneForPlayer(e.getPlayer())); - } - } - } else if (currentlyDisplayed.containsKey(e.getPlayer())) { - Bar cD = getDisplayedBar(((CraftPlayer) e.getPlayer()).getHandle(), e.getPower().getTag()).orElse(null); - if (cD == null) { - return; - } - - cD.delete(); - } - } - } - - @EventHandler - public void leave(@NotNull PlayerQuitEvent e) { - Player p = e.getPlayer(); - StringBuilder cooldownBuilder = new StringBuilder(); - cooldownBuilder.append("["); - CooldownPower.cooldowns.putIfAbsent(p, new ArrayList<>()); - - for (Pair barPair : CooldownPower.cooldowns.get(p)) { - cooldownBuilder.append(barPair.first().getKey().asString() + "<::>" + barPair.first().getProgress()); - cooldownBuilder.append(","); - } - - cooldownBuilder.append("]"); - p.getPersistentDataContainer() - .set( - CraftNamespacedKey.fromMinecraft(OriginsPaper.apoliIdentifier("current_cooldowns")), - PersistentDataType.STRING, - new String(cooldownBuilder).replace(",]", "]") - ); - if (currentlyDisplayed.containsKey(p)) { - currentlyDisplayed.get(p).forEach(Bar::delete); - currentlyDisplayed.get(p).clear(); - } - - if (CooldownPower.cooldowns.containsKey(p)) { - CooldownPower.cooldowns.get(p).forEach(pair -> Bukkit.getServer().removeBossBar(pair.first().getKey())); - CooldownPower.cooldowns.get(p).clear(); - } - } - - @EventHandler - public void join(@NotNull PlayerJoinEvent e) { - Player p = e.getPlayer(); - if (p.getPersistentDataContainer().has(CraftNamespacedKey.fromMinecraft(OriginsPaper.apoliIdentifier("current_cooldowns")))) { - String encoded = p.getPersistentDataContainer() - .get(CraftNamespacedKey.fromMinecraft(OriginsPaper.apoliIdentifier("current_cooldowns")), PersistentDataType.STRING); - encoded = encoded.replace("[", "").replace("]", ""); - if (encoded.equalsIgnoreCase("")) { - return; - } - - Arrays.stream(encoded.split(",")).forEach(key -> { - String a = key.split("<::>")[0]; - double b = Double.parseDouble(key.split("<::>")[1]); - if (OriginsPaper.getPower(ResourceLocation.parse(a.split("_cooldown_")[0])) instanceof CooldownInterface cooldownInterface) { - CooldownPower.addCooldown(p, cooldownInterface); - } - }); - } - } - - @Override - public HudRender getHudRender() { - return hudRender; - } - - public static class Bar { - String title; - ResourceInterface power; - int min; - int max; - Double currentProgress; - Integer mappedProgress; - KeyedBossBar renderedBar; - double oneInc; - - Bar(@NotNull CooldownInterface power, @NotNull Player player) { - this.title = Util.getNameOrTag((PowerType) power); - this.power = power; - this.min = 0; - this.max = power.getCooldown(); - this.currentProgress = (double) power.getCooldown(); - this.mappedProgress = power.getCooldown(); - this.renderedBar = ResourcePower.createRender(Util.getNameOrTag((PowerType) power), this.formatForFirstRender(this.currentProgress), power, player); - this.renderedBar.setVisible(true); - this.oneInc = 1.0 / (double) this.max; - this.renderedBar.addPlayer(player); - this.change(power.getCooldown(), "set", false); - } - - Bar(ResourcePower power, Player player) { - this.title = Util.getNameOrTag(power); - this.power = power; - this.min = power.min; - this.max = power.max; - this.currentProgress = Double.valueOf(power.startValue); - this.mappedProgress = this.currentProgress.intValue(); - this.renderedBar = ResourcePower.createRender(this.title, this.formatForFirstRender(this.currentProgress), power, player); - this.renderedBar.setVisible(true); - this.oneInc = 1.0 / (double) this.max; - if (player != null) { - this.renderedBar.addPlayer(player); - } - - this.change(power.startValue, "set", false); - } - - public static BarColor getBarColor(HudRender element) { - return BarColor.WHITE; - } - - public Bar cloneForPlayer(Player player) { - return new Bar((ResourcePower) this.power, player); - } - - public void delete() { - this.renderedBar.setVisible(false); - this.renderedBar.setProgress(0.0); - this.renderedBar.removeAll(); - Bukkit.getServer().removeBossBar(this.renderedBar.getKey()); - } - - public void change(int by, String operation, boolean updateMapped) { - Map> operator = getOperationMappingsDouble(); - double change = this.oneInc * (double) by; - this.renderedBar - .setProgress(this.preVerifyProgress(operator.get(operation).apply(Double.valueOf(this.renderedBar.getProgress()), Double.valueOf(change)))); - this.currentProgress = this.renderedBar.getProgress(); - if (updateMapped) { - int f = operator.get(operation).apply(Double.valueOf(this.mappedProgress.doubleValue()), Double.valueOf(by)).intValue(); - if (f < 0) { - f = 0; - } - - this.mappedProgress = f; - } - - this.renderedBar.getPlayers().forEach(entity -> { - if (this.power instanceof ResourcePower resource) { - if (this.renderedBar.getProgress() == 1.0) { - if (resource.maxAction != null) resource.maxAction.accept(((CraftEntity) entity).getHandle()); - } else if (this.renderedBar.getProgress() == 0.0) { - if (resource.minAction != null) resource.minAction.accept(((CraftEntity) entity).getHandle()); - } - } - }); - } - - public void change(int by, String operation) { - this.change(by, operation, true); - } - - public boolean meetsComparison(@NotNull Comparison comparison, double e) { - return comparison.compare(this.mappedProgress.intValue(), e); - } - - private double formatForFirstRender(double e) { - if (e == 0.0) { - return 0.0; - } else { - double f = 1.0 / e; - if (f > 1.0) { - return 1.0; - } else { - return f < 0.0 ? 0.0 : f; - } - } - } - - private double preVerifyProgress(double e) { - if (e > 1.0) { - return 1.0; - } else { - return e < 0.0 ? 0.0 : e; - } - } - - public ResourceInterface getPower() { - return this.power; - } - - public Integer getMappedProgress() { - return this.mappedProgress; - } - - public Double getCurrentProgress() { - return this.currentProgress; - } - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/SimplePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/SimplePower.java deleted file mode 100644 index 1ae3341bb..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/power/SimplePower.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.github.dueris.originspaper.power; - -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.Entity; -import org.jetbrains.annotations.NotNull; - -public class SimplePower extends PowerType { - public SimplePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority) { - super(key, type, name, description, hidden, condition, loadingPriority); - } - - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("simple")); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/factory/PowerReference.java b/origins/src/main/java/io/github/dueris/originspaper/power/factory/PowerReference.java new file mode 100644 index 000000000..104c0305f --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/power/factory/PowerReference.java @@ -0,0 +1,15 @@ +package io.github.dueris.originspaper.power.factory; + +import io.github.dueris.originspaper.OriginsPaper; +import net.minecraft.resources.ResourceLocation; + +public record PowerReference(ResourceLocation location) { + + public ResourceLocation getId() { + return location; + } + + public PowerType getType() { + return OriginsPaper.getPower(getId()); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PowerType.java b/origins/src/main/java/io/github/dueris/originspaper/power/factory/PowerType.java similarity index 67% rename from origins/src/main/java/io/github/dueris/originspaper/power/PowerType.java rename to origins/src/main/java/io/github/dueris/originspaper/power/factory/PowerType.java index ee43b12ca..41c1d4e46 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PowerType.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/factory/PowerType.java @@ -1,34 +1,35 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.factory; import com.google.gson.JsonObject; import io.github.classgraph.ClassGraph; import io.github.classgraph.ScanResult; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.util.ReflectionUtils; import io.github.dueris.calio.util.annotations.SourceProvider; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.util.ComponentUtil; import io.github.dueris.originspaper.util.LangFile; import net.kyori.adventure.text.TextComponent; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; -import org.bukkit.Bukkit; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ConcurrentLinkedQueue; public class PowerType implements Listener { - public static ConcurrentLinkedQueue> INSTANCE_TYPES = new ConcurrentLinkedQueue<>(); - public static Class DEFAULT_TYPE = SimplePower.class; + static Map> type2Class = new HashMap<>(); private final ResourceLocation key; private final @NotNull TextComponent name; private final @NotNull TextComponent description; @@ -45,22 +46,21 @@ public PowerType(@NotNull ResourceLocation key, @NotNull ResourceLocation type, this.key = key; this.cachedTagString = key.toString(); this.cachedTypeString = type.toString(); - this.name = net.kyori.adventure.text.Component.text( - LangFile.transform((name != null ? name.getString() : "power.$namespace.$path.name") + this.name = ComponentUtil.nmsToKyori( + LangFile.translatable((name != null ? name.getString() : "power.$namespace.$path.name") .replace("$namespace", key.getNamespace()).replace("$path", key.getPath())) ); - this.description = net.kyori.adventure.text.Component.text( - LangFile.transform((description != null ? description.getString() : "power.$namespace.$path.description") + this.description = ComponentUtil.nmsToKyori( + LangFile.translatable((description != null ? description.getString() : "power.$namespace.$path.description") .replace("$namespace", key.getNamespace()).replace("$path", key.getPath())) ); this.hidden = hidden; this.condition = condition; this.loadingPriority = loadingPriority; - Bukkit.getPluginManager().registerEvents(this, OriginsPaper.getPlugin()); } - public static SerializableData buildFactory() { - return SerializableData.serializableData() + public static SerializableData getFactory() { + return SerializableData.serializableData().typedRegistry(OriginsPaper.apoliIdentifier("simple")) .add("type", SerializableDataTypes.IDENTIFIER) .add("name", SerializableDataTypes.TEXT, null) .add("description", SerializableDataTypes.TEXT, null) @@ -70,32 +70,23 @@ public static SerializableData buildFactory() { } public static void registerAll() { - List> holders = new ArrayList<>() { - @Override - public boolean addAll(@NotNull Collection> c) { - for (Class clazz : c) { - try { - Class.forName(clazz.getName(), true, clazz.getClassLoader()); - } catch (ClassNotFoundException e) { - System.err.println("Error Preloading a powertype!"); - e.printStackTrace(); - } - } - return super.addAll(c); - } - }; - try { - ScanResult result = new ClassGraph().whitelistPackages("io.github.dueris.originspaper.power").enableClassInfo().scan(); + ScanResult result = new ClassGraph().acceptPackages("io.github.dueris.originspaper.power.type").enableClassInfo().scan(); try { - holders.addAll( - result.getSubclasses(PowerType.class) - .loadClasses(PowerType.class) - .stream() - .filter(clz -> !clz.isAnnotation() && !clz.isInterface() && !clz.isEnum()) - .toList() - ); + for (Class powerTypeClass : result.getSubclasses(PowerType.class) + .loadClasses(PowerType.class) + .stream() + .filter(clz -> !clz.isAnnotation() && !clz.isInterface() && !clz.isEnum()) + .toList()) { + if (ReflectionUtils.hasMethod(powerTypeClass, "getFactory", true)) { + Method factory = powerTypeClass.getMethod("getFactory"); + factory.setAccessible(true); + + SerializableData data = (SerializableData) factory.invoke(null); + type2Class.put(data.typedInstance, powerTypeClass); + } + } } catch (Throwable var5) { if (result != null) { try { @@ -110,13 +101,16 @@ public boolean addAll(@NotNull Collection> result.close(); } catch (Exception var6) { - System.out.println("This would've been a zip error :P. Please tell us on discord if you see this ^-^"); + OriginsPaper.LOGGER.warn("This would've been a zip error :P. Please tell us on discord if you see this ^-^"); } - INSTANCE_TYPES.addAll(holders); } - public ResourceLocation key() { + public static void register(ResourceLocation type, Class classType) { + PowerType.type2Class.put(type, classType); + } + + public ResourceLocation getId() { return key; } @@ -203,13 +197,13 @@ public boolean shouldTick() { * Allows for saving data in the player repository for that power */ @Nullable - public CompoundTag saveData() { + public CompoundTag saveData(ServerPlayer player) { return null; } /** * Allows parsing the data provided from the player repository for that power */ - public void loadFromData(@NotNull CompoundTag tag) { + public void loadFromData(@NotNull CompoundTag tag, ServerPlayer player) { } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/factory/PowerTypeFactory.java b/origins/src/main/java/io/github/dueris/originspaper/power/factory/PowerTypeFactory.java new file mode 100644 index 000000000..904d7c42f --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/power/factory/PowerTypeFactory.java @@ -0,0 +1,69 @@ +package io.github.dueris.originspaper.power.factory; + +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.data.SerializableDataBuilder; +import io.github.dueris.calio.parser.RootResult; +import io.github.dueris.calio.util.Util; +import io.github.dueris.originspaper.Factory; +import net.minecraft.resources.ResourceLocation; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +public class PowerTypeFactory implements Factory { + + @SuppressWarnings("unchecked") + public static SerializableDataBuilder> DATA = SerializableDataBuilder.of( + (jsonElement) -> { + if (!(jsonElement instanceof JsonObject jo)) { + throw new JsonSyntaxException("Expected JsonObject for root 'PowerType'"); + } + + ResourceLocation type = jo.has("type") ? SerializableDataTypes.IDENTIFIER.deserialize(jo.get("type")) : PowerType.getFactory().typedInstance; + Class powerClass = PowerType.type2Class.get(type); + + if (powerClass == null) { + throw new IllegalArgumentException("Provided type field, '{}', in Power was not found in the registry!".replace("{}", type.toString())); + } + + try { + Method factoryField = powerClass.getDeclaredMethod("getFactory"); + factoryField.setAccessible(true); + + SerializableData data = (SerializableData) factoryField.invoke(null); + SerializableData.Instance compound = SerializableDataBuilder.compound(data, jo, powerClass); + if (compound != null) { + Constructor parsedConstructor = (Constructor) Util.generateConstructor(powerClass, data); + return new RootResult<>(parsedConstructor, compound); + } + } catch (Throwable e) { + throw new RuntimeException(e); + } + + return null; + }, PowerType.class, false + ); + + protected final ResourceLocation id; + protected SerializableData serializableData; + + public PowerTypeFactory(ResourceLocation id, SerializableData serializableData) { + this.id = id; + this.serializableData = new SerializableData(serializableData); + } + + @Override + public ResourceLocation getSerializerId() { + return id; + } + + @Override + public SerializableData getSerializableData() { + return serializableData; + } + +} + diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBeingUsedPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBeingUsedPower.java similarity index 91% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBeingUsedPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBeingUsedPower.java index 0b611f5fb..f69540bed 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBeingUsedPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBeingUsedPower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -50,8 +51,8 @@ public ActionOnBeingUsedPower(@NotNull ResourceLocation key, @NotNull ResourceLo this.resultItemAction = resultItemAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_being_used")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_being_used")) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBlockBreakPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBlockBreakPower.java similarity index 88% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBlockBreakPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBlockBreakPower.java index f44a2a5c2..c10ac8252 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBlockBreakPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBlockBreakPower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; @@ -40,8 +41,8 @@ public ActionOnBlockBreakPower(@NotNull ResourceLocation key, @NotNull ResourceL this.onlyWhenHarvested = onlyWhenHarvested; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_block_break")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_block_break")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("block_action", ApoliDataTypes.BLOCK_ACTION, null) .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBlockPlacePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBlockPlacePower.java similarity index 94% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBlockPlacePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBlockPlacePower.java index d83a92f82..1400cbb8e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBlockPlacePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBlockPlacePower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -66,8 +67,8 @@ public ActionOnBlockPlacePower(@NotNull ResourceLocation key, @NotNull ResourceL this.heldItemAction = heldItemAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_block_place")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_block_place")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("place_to_action", ApoliDataTypes.BLOCK_ACTION, null) .add("place_on_action", ApoliDataTypes.BLOCK_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBlockUsePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBlockUsePower.java similarity index 93% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBlockUsePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBlockUsePower.java index 522d87d39..6d842552a 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnBlockUsePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnBlockUsePower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -60,8 +61,8 @@ public ActionOnBlockUsePower(@NotNull ResourceLocation key, @NotNull ResourceLoc this.hands = hands; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_block_use")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_block_use")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("block_action", ApoliDataTypes.BLOCK_ACTION, null) .add("held_item_action", ApoliDataTypes.ITEM_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnCallbackPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnCallbackPower.java similarity index 86% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnCallbackPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnCallbackPower.java index 2c3f24e23..0c2124242 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnCallbackPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnCallbackPower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -31,8 +32,8 @@ public ActionOnCallbackPower(@NotNull ResourceLocation key, @NotNull ResourceLoc this.entityActionAdded = entityActionAdded; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_callback")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_callback")) .add("entity_action_respawned", ApoliDataTypes.ENTITY_ACTION, null) .add("entity_action_removed", ApoliDataTypes.ENTITY_ACTION, null) .add("entity_action_gained", ApoliDataTypes.ENTITY_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnDeathPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnDeathPower.java similarity index 80% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnDeathPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnDeathPower.java index 837838216..2b72a9c19 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnDeathPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnDeathPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -25,8 +26,8 @@ public ActionOnDeathPower(@NotNull ResourceLocation key, @NotNull ResourceLocati this.bientityCondition = bientityCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_death")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_death")) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION, null) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null); diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnEntityUsePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnEntityUsePower.java similarity index 92% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnEntityUsePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnEntityUsePower.java index 7061e1de4..f53d91604 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnEntityUsePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnEntityUsePower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -49,8 +50,8 @@ public ActionOnEntityUsePower(@NotNull ResourceLocation key, @NotNull ResourceLo this.resultItemAction = resultItemAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_entity_use")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_entity_use")) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnHitPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnHitPower.java similarity index 77% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnHitPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnHitPower.java index 6da06da0b..ce5891192 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnHitPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnHitPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -20,25 +21,21 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.jetbrains.annotations.NotNull; -public class ActionOnHitPower extends PowerType implements CooldownInterface { +public class ActionOnHitPower extends CooldownPower { private final ActionTypeFactory> bientityAction; private final ConditionTypeFactory> damageCondition; - private final int cooldown; - private final HudRender hudRender; private final ConditionTypeFactory> bientityCondition; public ActionOnHitPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory> bientityAction, ConditionTypeFactory> damageCondition, int cooldown, HudRender hudRender, ConditionTypeFactory> bientityCondition) { - super(key, type, name, description, hidden, condition, loadingPriority); + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.bientityAction = bientityAction; this.damageCondition = damageCondition; - this.cooldown = cooldown; - this.hudRender = hudRender; this.bientityCondition = bientityCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_hit")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_hit")) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION, null) .add("cooldown", SerializableDataTypes.INT, 1) @@ -47,14 +44,14 @@ public static SerializableData buildFactory() { } public boolean doesApply(Entity target, @NotNull Entity entity, DamageSource source, float amount) { - return !CooldownPower.isInCooldown(entity.getBukkitEntity(), this) + return canUse(entity) && (bientityCondition == null || bientityCondition.test(new Tuple<>(entity, target))) && (damageCondition == null || damageCondition.test(new Tuple<>(source, amount))); } public void onHit(Entity target, Entity entity) { this.bientityAction.accept(new Tuple<>(entity, target)); - CooldownPower.addCooldown(entity.getBukkitEntity(), this); + use(entity); } @EventHandler @@ -70,13 +67,4 @@ public void onHit(@NotNull EntityDamageByEntityEvent e) { } } - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnItemPickupPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnItemPickupPower.java similarity index 86% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnItemPickupPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnItemPickupPower.java index 9ad845615..dd1f78d40 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnItemPickupPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnItemPickupPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -35,8 +36,8 @@ public ActionOnItemPickupPower(@NotNull ResourceLocation key, @NotNull ResourceL this.itemCondition = itemCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_item_pickup")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_item_pickup")) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) .add("item_action", ApoliDataTypes.ITEM_ACTION, null) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnItemUsePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnItemUsePower.java similarity index 85% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnItemUsePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnItemUsePower.java index 723b7fbbf..2db907a22 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnItemUsePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnItemUsePower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -32,8 +33,8 @@ public ActionOnItemUsePower(@NotNull ResourceLocation key, @NotNull ResourceLoca this.itemAction = itemAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_item_use")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_item_use")) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("item_action", ApoliDataTypes.ITEM_ACTION, null); diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnLandPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnLandPower.java similarity index 50% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnLandPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnLandPower.java index eab7b0dd2..72f1869bd 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnLandPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnLandPower.java @@ -1,17 +1,14 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.event.PlayerHitGroundEvent; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.event.EventHandler; import org.jetbrains.annotations.NotNull; public class ActionOnLandPower extends PowerType { @@ -22,16 +19,14 @@ public ActionOnLandPower(@NotNull ResourceLocation key, @NotNull ResourceLocatio this.entityAction = entityAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_land")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_land")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null); } - @EventHandler - public void onLand(@NotNull PlayerHitGroundEvent e) { - Player player = ((CraftPlayer) e.getPlayer()).getHandle(); - if (getPlayers().contains(player) && isActive(player)) { - entityAction.accept(player); + public void executeAction(Entity entity) { + if (isActive(entity)) { + entityAction.accept(entity); } } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnWakeUpPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnWakeUpPower.java similarity index 52% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOnWakeUpPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnWakeUpPower.java index 235e751d5..76b56996f 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOnWakeUpPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOnWakeUpPower.java @@ -1,34 +1,29 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import org.apache.commons.lang3.tuple.Triple; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.craftbukkit.util.CraftLocation; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerBedLeaveEvent; -import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; public class ActionOnWakeUpPower extends PowerType { private final ActionTypeFactory entityAction; private final ActionTypeFactory> blockAction; private final ConditionTypeFactory blockCondition; - private final List tickedAlready = new ArrayList<>(); + private final List tickedAlready = new LinkedList<>(); public ActionOnWakeUpPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory entityAction, ActionTypeFactory> blockAction, ConditionTypeFactory blockCondition) { @@ -38,8 +33,8 @@ public ActionOnWakeUpPower(@NotNull ResourceLocation key, @NotNull ResourceLocat this.blockCondition = blockCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_wake_up")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_on_wake_up")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("block_action", ApoliDataTypes.BLOCK_ACTION, null) .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null); @@ -47,45 +42,22 @@ public static SerializableData buildFactory() { public boolean doesApply(BlockPos pos, @NotNull Entity entity) { BlockInWorld cbp = new BlockInWorld(entity.level(), pos, true); - return doesApply(cbp); + return doesApply(cbp) && isActive(entity); } public boolean doesApply(BlockInWorld pos) { return blockCondition == null || blockCondition.test(pos); } - public void executeActions(BlockPos pos, Direction dir, Entity entity) { + public void executeActions(BlockPos pos, Direction direction, Entity entity) { + if (blockAction != null) { - blockAction.accept(Triple.of(entity.level(), pos, dir)); + blockAction.accept(Triple.of(entity.level(), pos, direction)); } + if (entityAction != null) { entityAction.accept(entity); } - } - @EventHandler - public void onWakeUp(PlayerBedLeaveEvent e) { - new BukkitRunnable() { - @Override - public void run() { - Player player = ((CraftPlayer) e.getPlayer()).getHandle(); - if (e.getPlayer().getWorld().isDayTime() && getPlayers().contains(player)) { - if (tickedAlready.contains(e.getPlayer())) return; - tickedAlready.add(e.getPlayer()); - BlockPos pos = CraftLocation.toBlockPosition(e.getBed().getLocation()); - if (doesApply(pos, player)) { - executeActions(pos, Direction.DOWN, player); - } - new BukkitRunnable() { - @Override - public void run() { - tickedAlready.remove(player.getBukkitEntity()); - } - }.runTaskLater(OriginsPaper.getPlugin(), 1); - } - } - } - // We delay this by 3 ticks to give time for the world to become marked as "daytime", because it doesnt when the event is called... - .runTaskLater(OriginsPaper.getPlugin(), 3); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOverTimePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOverTimePower.java similarity index 83% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionOverTimePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOverTimePower.java index bf135518c..2e14dd9b9 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionOverTimePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionOverTimePower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -32,8 +33,8 @@ public ActionOverTimePower(@NotNull ResourceLocation key, @NotNull ResourceLocat this.fallingAction = fallingAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_over_time")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_over_time")) .add("interval", SerializableDataTypes.POSITIVE_INT, 20) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("rising_action", ApoliDataTypes.ENTITY_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActionWhenHitPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionWhenHitPower.java similarity index 77% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActionWhenHitPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActionWhenHitPower.java index 08408cebb..240ccefe1 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActionWhenHitPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActionWhenHitPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -21,25 +22,21 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class ActionWhenHitPower extends PowerType implements CooldownInterface { +public class ActionWhenHitPower extends CooldownPower { private final ActionTypeFactory> bientityAction; private final ConditionTypeFactory> damageCondition; - private final int cooldown; - private final HudRender hudRender; private final ConditionTypeFactory> bientityCondition; public ActionWhenHitPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory> bientityAction, ConditionTypeFactory> damageCondition, int cooldown, HudRender hudRender, ConditionTypeFactory> bientityCondition) { - super(key, type, name, description, hidden, condition, loadingPriority); + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.bientityAction = bientityAction; this.damageCondition = damageCondition; - this.cooldown = cooldown; - this.hudRender = hudRender; this.bientityCondition = bientityCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_when_hit")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("action_when_hit")) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION, null) .add("cooldown", SerializableDataTypes.INT, 1) @@ -49,14 +46,14 @@ public static SerializableData buildFactory() { public boolean doesApply(@Nullable Entity attacker, Entity entity, DamageSource source, float amount) { return attacker != null - && !CooldownPower.isInCooldown(entity.getBukkitEntity(), this) + && canUse(entity) && (bientityCondition == null || bientityCondition.test(new Tuple<>(attacker, entity))) && (damageCondition == null || damageCondition.test(new Tuple<>(source, amount))); } public void whenHit(Entity attacker, Entity entity) { this.bientityAction.accept(new Tuple<>(attacker, entity)); - CooldownPower.addCooldown(entity.getBukkitEntity(), this); + use(entity); } @EventHandler @@ -72,13 +69,4 @@ public void whenHit(@NotNull EntityDamageByEntityEvent e) { } } - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ActiveSelfPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActiveSelfPower.java similarity index 69% rename from origins/src/main/java/io/github/dueris/originspaper/power/ActiveSelfPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ActiveSelfPower.java index 066f2f463..6c08ab9b0 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ActiveSelfPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ActiveSelfPower.java @@ -1,14 +1,15 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; import io.github.dueris.originspaper.data.types.Keybind; import io.github.dueris.originspaper.event.KeybindTriggerEvent; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.KeybindUtil; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -19,27 +20,23 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; -public class ActiveSelfPower extends PowerType implements CooldownInterface { +public class ActiveSelfPower extends CooldownPower { private final ActionTypeFactory entityAction; - private final int cooldown; - private final HudRender hudRender; private final Keybind keybind; - private final List alreadyTicked = new ArrayList<>(); + private final List alreadyTicked = new LinkedList<>(); public ActiveSelfPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory entityAction, int cooldown, HudRender hudRender, Keybind keybind) { - super(key, type, name, description, hidden, condition, loadingPriority); + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.entityAction = entityAction; - this.cooldown = cooldown; - this.hudRender = hudRender; this.keybind = keybind; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("active_self")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("active_self")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION) .add("cooldown", SerializableDataTypes.INT, 1) .add("hud_render", ApoliDataTypes.HUD_RENDER, HudRender.DONT_RENDER) @@ -50,11 +47,11 @@ public static SerializableData buildFactory() { public void onKey(@NotNull KeybindTriggerEvent e) { Player player = ((CraftPlayer) e.getPlayer()).getHandle(); if (!getPlayers().contains(player)) return; - if (isActive(player) && !CooldownPower.isInCooldown(e.getPlayer(), this)) { + if (isActive(player) && canUse(player)) { if (KeybindUtil.isKeyActive(keybind.key(), e.getPlayer()) && keybind.key().equalsIgnoreCase(e.getKey()) && !alreadyTicked.contains(player)) { entityAction.accept(player); if (cooldown > 1) { - CooldownPower.addCooldown(e.getPlayer(), this); + use(player); } alreadyTicked.add(player); new BukkitRunnable() { @@ -67,14 +64,4 @@ public void run() { } } - - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/AttackerActionWhenHitPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/AttackerActionWhenHitPower.java similarity index 74% rename from origins/src/main/java/io/github/dueris/originspaper/power/AttackerActionWhenHitPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/AttackerActionWhenHitPower.java index 6fb1f9644..767ee97b8 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/AttackerActionWhenHitPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/AttackerActionWhenHitPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -20,23 +21,19 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.jetbrains.annotations.NotNull; -public class AttackerActionWhenHitPower extends PowerType implements CooldownInterface { +public class AttackerActionWhenHitPower extends CooldownPower { private final ActionTypeFactory entityAction; private final ConditionTypeFactory> damageCondition; - private final int cooldown; - private final HudRender hudRender; public AttackerActionWhenHitPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory entityAction, ConditionTypeFactory> damageCondition, int cooldown, HudRender hudRender) { - super(key, type, name, description, hidden, condition, loadingPriority); + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.entityAction = entityAction; this.damageCondition = damageCondition; - this.cooldown = cooldown; - this.hudRender = hudRender; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("attacker_action_when_hit")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("attacker_action_when_hit")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION, null) .add("cooldown", SerializableDataTypes.INT, 1) @@ -45,13 +42,13 @@ public static SerializableData buildFactory() { public boolean doesApply(@NotNull DamageSource source, float amount, Entity entity) { return source.getEntity() != null - && !CooldownPower.isInCooldown(entity.getBukkitEntity(), this) + && canUse(entity) && (damageCondition == null || damageCondition.test(new Tuple<>(source, amount))); } public void whenHit(Entity attacker, @NotNull Entity entity) { this.entityAction.accept(attacker); - CooldownPower.addCooldown(entity.getBukkitEntity(), this); + use(entity); } @EventHandler @@ -67,13 +64,4 @@ public void whenHit(@NotNull EntityDamageByEntityEvent e) { } } - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/AttributePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/AttributePower.java similarity index 81% rename from origins/src/main/java/io/github/dueris/originspaper/power/AttributePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/AttributePower.java index 6c3adb5c7..d30428122 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/AttributePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/AttributePower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import com.mojang.datafixers.util.Pair; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.AttributedEntityAttributeModifier; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -14,6 +15,10 @@ import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.player.Player; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,8 +41,8 @@ public AttributePower(@NotNull ResourceLocation key, @NotNull ResourceLocation t } } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("attribute")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("attribute")) .add("modifier", ApoliDataTypes.ATTRIBUTED_ATTRIBUTE_MODIFIER, null) .add("modifiers", SerializableDataTypes.list(ApoliDataTypes.ATTRIBUTED_ATTRIBUTE_MODIFIER), null) .add("update_health", SerializableDataTypes.BOOLEAN, true); @@ -64,6 +69,19 @@ public void onRemoved(Player player) { this.removeTempMods(player); } + @Override + public void onLost(Player player) { + this.removeTempMods(player); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onJoin(@NotNull PlayerJoinEvent e) { + Player player = ((CraftPlayer) e.getPlayer()).getHandle(); + if (getPlayers().contains(player)) { + applyTempMods(player); + } + } + protected void applyTempMods(@NotNull Player entity) { if (entity.level().isClientSide) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/BurnPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/BurnPower.java similarity index 75% rename from origins/src/main/java/io/github/dueris/originspaper/power/BurnPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/BurnPower.java index ea33c733f..dca44397b 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/BurnPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/BurnPower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -20,8 +21,8 @@ public BurnPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, this.burnDuration = burnDuration; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("burn")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("burn")) .add("interval", SerializableDataTypes.POSITIVE_INT) .add("burn_duration", SerializableDataTypes.POSITIVE_INT); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ClimbingPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ClimbingPower.java similarity index 76% rename from origins/src/main/java/io/github/dueris/originspaper/power/ClimbingPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ClimbingPower.java index 8f3c43406..2540a38f1 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ClimbingPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ClimbingPower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import com.destroystokyo.paper.event.player.PlayerJumpEvent; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -15,18 +16,18 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; public class ClimbingPower extends PowerType { - public static ArrayList active_climbing = new ArrayList<>(); - public ArrayList allowedToClimb = new ArrayList<>(); + public static LinkedList active_climbing = new LinkedList<>(); + public LinkedList allowedToClimb = new LinkedList<>(); public ClimbingPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority) { super(key, type, name, description, hidden, condition, loadingPriority); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("climbing")); + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("climbing")); } @Override diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ConditionedAttributePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ConditionedAttributePower.java similarity index 82% rename from origins/src/main/java/io/github/dueris/originspaper/power/ConditionedAttributePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ConditionedAttributePower.java index 80347f13f..db6038a6d 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ConditionedAttributePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ConditionedAttributePower.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.AttributedEntityAttributeModifier; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -23,8 +23,8 @@ public ConditionedAttributePower(@NotNull ResourceLocation key, @NotNull Resourc this.tickRate = tickRate; } - public static SerializableData buildFactory() { - return AttributePower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("conditioned_attribute")) + public static SerializableData getFactory() { + return AttributePower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("conditioned_attribute")) .add("tick_rate", SerializableDataTypes.POSITIVE_INT, 20); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ConditionedRestrictArmorPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ConditionedRestrictArmorPower.java similarity index 73% rename from origins/src/main/java/io/github/dueris/originspaper/power/ConditionedRestrictArmorPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ConditionedRestrictArmorPower.java index 1c5cf84f6..448ecc6da 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ConditionedRestrictArmorPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ConditionedRestrictArmorPower.java @@ -1,12 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; -import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -15,6 +15,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import org.bukkit.Material; import org.bukkit.craftbukkit.CraftEquipmentSlot; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.event.EventHandler; @@ -48,8 +49,8 @@ public ConditionedRestrictArmorPower(@NotNull ResourceLocation key, @NotNull Res this.armorConditions = restrictions; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("conditioned_restrict_armor")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("conditioned_restrict_armor")) .add("head", ApoliDataTypes.ITEM_CONDITION, null) .add("chest", ApoliDataTypes.ITEM_CONDITION, null) .add("legs", ApoliDataTypes.ITEM_CONDITION, null) @@ -57,6 +58,20 @@ public static SerializableData buildFactory() { .add("tick_rate", SerializableDataTypes.POSITIVE_INT, 80); } + private static void moveEquipmentInventory(@NotNull org.bukkit.entity.Player player, org.bukkit.inventory.EquipmentSlot equipmentSlot) { + org.bukkit.inventory.ItemStack item = player.getInventory().getItem(equipmentSlot); + if (item != null && item.getType() != Material.AIR) { + int emptySlot = player.getInventory().firstEmpty(); + if (emptySlot != -1) { + player.getInventory().setItem(equipmentSlot, null); + player.getInventory().setItem(emptySlot, item); + } else { + player.getWorld().dropItem(player.getLocation(), item); + player.getInventory().setItem(equipmentSlot, null); + } + } + } + public boolean canEquip(ItemStack itemStack, EquipmentSlot slot, @NotNull Entity entity) { return !armorConditions.get(slot).test(new Tuple<>(entity.level(), itemStack)); } @@ -84,7 +99,7 @@ private void tickPower(@NotNull Player entity) { ItemStack equippedItem = entity.getItemBySlot(slot); if (!equippedItem.isEmpty()) { if (!canEquip(equippedItem, slot, entity)) { - PowerHolderComponent.moveEquipmentInventory((org.bukkit.entity.Player) entity.getBukkitEntity(), CraftEquipmentSlot.getSlot(slot)); + moveEquipmentInventory((org.bukkit.entity.Player) entity.getBukkitEntity(), CraftEquipmentSlot.getSlot(slot)); } } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/type/CooldownPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/CooldownPower.java new file mode 100644 index 000000000..3508ff365 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/CooldownPower.java @@ -0,0 +1,99 @@ +package io.github.dueris.originspaper.power.type; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.HudRender; +import io.github.dueris.originspaper.power.factory.PowerType; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.scores.ScoreHolder; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; + +public class CooldownPower extends PowerType implements ResourceInterface { + final int cooldown; + private final HudRender hudRender; + private final Map holder2Render = new ConcurrentHashMap<>(); + private final List tickingCooldowns = new CopyOnWriteArrayList<>(); + + public CooldownPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, + HudRender hudRender, int cooldown) { + super(key, type, name, description, hidden, condition, loadingPriority); + this.hudRender = hudRender; + this.cooldown = cooldown; + } + + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("cooldown")) + .add("hud_render", ApoliDataTypes.HUD_RENDER, HudRender.DONT_RENDER) + .add("cooldown", SerializableDataTypes.INT, 0); + } + + public ResourcePower.BarRender getRender(ScoreHolder holder) { + if (holder instanceof net.minecraft.world.entity.player.Player player) { + cleanup(player); + } + return holder2Render.get(holder); + } + + private void cleanup(ScoreHolder player) { + if (!holder2Render.containsKey(player)) { + holder2Render.put(player, new ResourcePower.BarRender(player, this, this.cooldown, cooldown, 0, null, null)); + } + } + + @Override + public void tick() { + for (ScoreHolder holder : tickingCooldowns) { + if (holder instanceof ServerPlayer player && player.hasDisconnected()) continue; + cleanup(holder); + ResourcePower.BarRender render = holder2Render.get(holder); + render.setRendering(shouldRender(holder) && (holder instanceof Entity entity && isActive(entity))); + render.setValue(render.getValue() - 1); + + if (render.getValue() <= 0) { + render.destroy(); + tickingCooldowns.remove(holder); + holder2Render.remove(holder); + } + } + } + + public boolean shouldRender(ScoreHolder entity) { + return entity instanceof Entity && hudRender.shouldRender((Entity) entity); + } + + public boolean canUse(ScoreHolder holder) { + return !tickingCooldowns.contains(holder); + } + + public void use(ScoreHolder holder) { + tickingCooldowns.add(holder); + } + + public int getRemainingTicks(ScoreHolder holder) { + return getRender(holder).getValue(); + } + + public void setCooldown(ScoreHolder holder, int newValue) { + getRender(holder).setValue(newValue); + } + + @Override + public HudRender getHudRender() { + return hudRender; + } + + public int getCooldown() { + return cooldown; + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/CreativeFlightPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/CreativeFlightPower.java similarity index 89% rename from origins/src/main/java/io/github/dueris/originspaper/power/CreativeFlightPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/CreativeFlightPower.java index 40e620622..427bc4951 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/CreativeFlightPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/CreativeFlightPower.java @@ -1,8 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -21,8 +22,8 @@ public CreativeFlightPower(@NotNull ResourceLocation key, @NotNull ResourceLocat super(key, type, name, description, hidden, condition, loadingPriority); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("creative_flight")); + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("creative_flight")); } public static void tickPlayer(@NotNull Player p, @Nullable CreativeFlightPower power) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/DamageOverTimePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/DamageOverTimePower.java similarity index 93% rename from origins/src/main/java/io/github/dueris/originspaper/power/DamageOverTimePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/DamageOverTimePower.java index 7a00bcd4f..90889b11d 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/DamageOverTimePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/DamageOverTimePower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; @@ -54,8 +55,8 @@ public DamageOverTimePower(@NotNull ResourceLocation key, @NotNull ResourceLocat this.onsetDelay = onsetDelay.orElse(interval); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("damage_over_time")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("damage_over_time")) .add("interval", SerializableDataTypes.POSITIVE_INT, 20) .add("onset_delay", SerializableDataTypes.optional(SerializableDataTypes.INT), Optional.empty()) .add("damage", SerializableDataTypes.FLOAT) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/DisableRegenPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/DisableRegenPower.java similarity index 73% rename from origins/src/main/java/io/github/dueris/originspaper/power/DisableRegenPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/DisableRegenPower.java index e5ecfa343..313030fe9 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/DisableRegenPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/DisableRegenPower.java @@ -1,8 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -17,8 +18,8 @@ public DisableRegenPower(@NotNull ResourceLocation key, @NotNull ResourceLocatio super(key, type, name, description, hidden, condition, loadingPriority); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("disable_regen")); + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("disable_regen")); } @EventHandler diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/EdibleItemPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/EdibleItemPower.java similarity index 94% rename from origins/src/main/java/io/github/dueris/originspaper/power/EdibleItemPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/EdibleItemPower.java index 8717dc8d5..41978f663 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/EdibleItemPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/EdibleItemPower.java @@ -1,13 +1,14 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -35,7 +36,6 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -51,7 +51,7 @@ public class EdibleItemPower extends PowerType { private final List consumingTimeModifiers; private final NamespacedKey EDIBLE_ITEM_MODIFIED_KEY = CraftNamespacedKey.fromMinecraft(OriginsPaper.apoliIdentifier("edible_item_modified")); - private final List tickedAlready = new ArrayList<>(); + private final List tickedAlready = new LinkedList<>(); public EdibleItemPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory entityAction, ActionTypeFactory> consumedItemAction, ActionTypeFactory> resultItemAction, ConditionTypeFactory> itemCondition, @@ -77,8 +77,8 @@ public EdibleItemPower(@NotNull ResourceLocation key, @NotNull ResourceLocation this.foodComponent = resolveFoodComponent(foodComponent); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("edible_item")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("edible_item")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("item_action", ApoliDataTypes.ITEM_ACTION, null) .add("result_item_action", ApoliDataTypes.ITEM_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/EffectImmunityPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/EffectImmunityPower.java similarity index 74% rename from origins/src/main/java/io/github/dueris/originspaper/power/EffectImmunityPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/EffectImmunityPower.java index 547545c5b..980a69436 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/EffectImmunityPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/EffectImmunityPower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -12,18 +13,18 @@ import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; public class EffectImmunityPower extends PowerType { private final boolean inverted; - private final ArrayList> effects; + private final LinkedList> effects; public EffectImmunityPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, Holder mobEffect, List> mobEffects, boolean inverted) { super(key, type, name, description, hidden, condition, loadingPriority); this.inverted = inverted; - this.effects = new ArrayList<>(); + this.effects = new LinkedList<>(); if (mobEffect != null) { effects.add(mobEffect); } @@ -33,8 +34,8 @@ public EffectImmunityPower(@NotNull ResourceLocation key, @NotNull ResourceLocat } } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("effect_immunity")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("effect_immunity")) .add("effect", SerializableDataTypes.STATUS_EFFECT_ENTRY, null) .add("effects", SerializableDataTypes.list(SerializableDataTypes.STATUS_EFFECT_ENTRY), null) .add("inverted", SerializableDataTypes.BOOLEAN, false); @@ -48,7 +49,7 @@ public boolean doesApply(Holder effect) { return inverted ^ effects.contains(effect); } - public ArrayList> getEffects() { + public LinkedList> getEffects() { return effects; } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ElytraFlightPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ElytraFlightPower.java similarity index 91% rename from origins/src/main/java/io/github/dueris/originspaper/power/ElytraFlightPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ElytraFlightPower.java index 80dcedc0a..bb3af0d7d 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ElytraFlightPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ElytraFlightPower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.event.PowerUpdateEvent; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -31,21 +32,21 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.UUID; public class ElytraFlightPower extends PowerType { - private final ArrayList glidingPlayers = new ArrayList<>(); + private final LinkedList glidingPlayers = new LinkedList<>(); public ElytraFlightPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority) { super(key, type, name, description, hidden, condition, loadingPriority); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("elytra_flight")); + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("elytra_flight")); } - public ArrayList getGlidingPlayers() { + public LinkedList getGlidingPlayers() { return glidingPlayers; } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/EntityGlowPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/EntityGlowPower.java similarity index 90% rename from origins/src/main/java/io/github/dueris/originspaper/power/EntityGlowPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/EntityGlowPower.java index d7c18ef7f..a3c81fd97 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/EntityGlowPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/EntityGlowPower.java @@ -1,12 +1,14 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.util.holder.ObjectProvider; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Shape; +import io.github.dueris.originspaper.plugin.OriginsPlugin; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.entity.GlowingEntitiesUtils; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -43,8 +45,8 @@ public EntityGlowPower(@NotNull ResourceLocation key, @NotNull ResourceLocation this.blue = blue; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("entity_glow")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("entity_glow")) .add("entity_condition", ApoliDataTypes.ENTITY_CONDITION, null) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("use_teams", SerializableDataTypes.BOOLEAN, true) @@ -71,7 +73,7 @@ public void tick(@NotNull Player player) { ServerLevel level = (ServerLevel) player.level(); Set entities = Shape.getEntities(Shape.SPHERE, level, CraftLocation.toVec3D(p.getLocation()), 45); entities.add(player); - GlowingEntitiesUtils utils = OriginsPaper.glowingEntitiesUtils; + GlowingEntitiesUtils utils = OriginsPlugin.glowingEntitiesUtils; try { if (isActive(player)) { for (Entity entity : entities) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ExhaustOverTimePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ExhaustOverTimePower.java similarity index 75% rename from origins/src/main/java/io/github/dueris/originspaper/power/ExhaustOverTimePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ExhaustOverTimePower.java index 163bc961a..d7003a68e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ExhaustOverTimePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ExhaustOverTimePower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -21,8 +22,8 @@ public ExhaustOverTimePower(@NotNull ResourceLocation key, @NotNull ResourceLoca this.exhaustion = exhaustion; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("exhaust")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("exhaust")) .add("interval", SerializableDataTypes.POSITIVE_INT, 20) .add("exhaustion", SerializableDataTypes.FLOAT); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/type/FireImmunityPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/FireImmunityPower.java new file mode 100644 index 000000000..a5ccc3209 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/FireImmunityPower.java @@ -0,0 +1,22 @@ +package io.github.dueris.originspaper.power.type; + +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +public class FireImmunityPower extends PowerType { + + public FireImmunityPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority) { + super(key, type, name, description, hidden, condition, loadingPriority); + } + + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("fire_immunity")); + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/FireProjectilePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/FireProjectilePower.java similarity index 83% rename from origins/src/main/java/io/github/dueris/originspaper/power/FireProjectilePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/FireProjectilePower.java index 44f00d5fd..1faab1be7 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/FireProjectilePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/FireProjectilePower.java @@ -1,14 +1,16 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; import io.github.dueris.originspaper.data.types.Keybind; import io.github.dueris.originspaper.event.KeybindTriggerEvent; +import io.github.dueris.originspaper.mixin.ThrownEnderpearlMixin; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -23,20 +25,18 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.entity.projectile.ThrownEnderpearl; import net.minecraft.world.phys.Vec3; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerTeleportEvent; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; @Deprecated -public class FireProjectilePower extends PowerType implements CooldownInterface { - public static final List IS_ENDERIAN_PEARL = new ArrayList<>(); - private final int cooldown; +public class FireProjectilePower extends CooldownPower { + public static final List IS_ENDERIAN_PEARL = new LinkedList<>(); private final int projectileCount; private final int interval; private final int startDelay; @@ -44,12 +44,10 @@ public class FireProjectilePower extends PowerType implements CooldownInterface private final float divergence; private final SoundEvent soundEvent; private final EntityType entityType; - private final HudRender hudRender; private final CompoundTag tag; private final Keybind keybind; private final ActionTypeFactory projectileAction; private final ActionTypeFactory shooterAction; - private final ConcurrentLinkedQueue enderian_pearl = new ConcurrentLinkedQueue<>(); protected long lastUseTime; private boolean isFiringProjectiles; private boolean finishedStartDelay; @@ -58,8 +56,7 @@ public class FireProjectilePower extends PowerType implements CooldownInterface public FireProjectilePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, int cooldown, int count, int interval, int startDelay, float speed, float divergence, SoundEvent sound, EntityType entityType, HudRender hudRender, CompoundTag tag, Keybind keybind, ActionTypeFactory projectileAction, ActionTypeFactory shooterAction) { - super(key, type, name, description, hidden, condition, loadingPriority); - this.cooldown = cooldown; + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.projectileCount = count; this.interval = interval; this.startDelay = startDelay; @@ -67,15 +64,14 @@ public FireProjectilePower(@NotNull ResourceLocation key, @NotNull ResourceLocat this.divergence = divergence; this.soundEvent = sound; this.entityType = entityType; - this.hudRender = hudRender; this.tag = tag; this.keybind = keybind; this.projectileAction = projectileAction; this.shooterAction = shooterAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("fire_projectile")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("fire_projectile")) .add("cooldown", SerializableDataTypes.INT, 1) .add("count", SerializableDataTypes.INT, 1) .add("interval", SerializableDataTypes.POSITIVE_INT, 0) @@ -91,23 +87,13 @@ public static SerializableData buildFactory() { .add("shooter_action", ApoliDataTypes.ENTITY_ACTION, null); } - @EventHandler - public void enderianPearl(@NotNull PlayerTeleportEvent e) { - if (enderian_pearl.contains(e.getPlayer()) && e.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { - e.setCancelled(true); - e.getPlayer().teleportAsync(e.getTo()); - e.getPlayer().setFallDistance(0); - enderian_pearl.remove(e.getPlayer()); - } - } - @EventHandler public void onKeybind(@NotNull KeybindTriggerEvent e) { Player nms = ((CraftPlayer) e.getPlayer()).getHandle(); - if (e.getKey().equalsIgnoreCase(keybind.key()) && getPlayers().contains(nms) && !CooldownPower.isInCooldown(e.getPlayer(), this)) { + if (e.getKey().equalsIgnoreCase(keybind.key()) && getPlayers().contains(nms) && canUse(nms)) { this.lastUseTime = nms.level().getGameTime(); this.isFiringProjectiles = true; - CooldownPower.addCooldown(e.getPlayer(), this); + use(nms); } } @@ -228,8 +214,8 @@ private void fireProjectile(Entity entity) { if (entityToSpawn instanceof Projectile projectileToSpawn) { projectileToSpawn.setOwner(entity); - if (IS_ENDERIAN_PEARL.contains(key())) { - enderian_pearl.add(entity.getBukkitEntity()); + if (IS_ENDERIAN_PEARL.contains(getId()) && projectileToSpawn instanceof ThrownEnderpearl pearl) { + ThrownEnderpearlMixin.ENDERIAN_PEARLS.add(pearl); } } @@ -244,13 +230,4 @@ private void fireProjectile(Entity entity) { } - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/FreezePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/FreezePower.java similarity index 70% rename from origins/src/main/java/io/github/dueris/originspaper/power/FreezePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/FreezePower.java index 70444d226..ec70521a1 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/FreezePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/FreezePower.java @@ -1,8 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -14,8 +15,8 @@ public FreezePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type super(key, type, name, description, hidden, condition, loadingPriority); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("freeze")); + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("freeze")); } @Override diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/GroundedPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/GroundedPower.java similarity index 90% rename from origins/src/main/java/io/github/dueris/originspaper/power/GroundedPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/GroundedPower.java index c80a3bafa..46d979cb7 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/GroundedPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/GroundedPower.java @@ -1,8 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -29,8 +30,8 @@ public GroundedPower(@NotNull ResourceLocation key, @NotNull ResourceLocation ty super(key, type, name, description, hidden, condition, loadingPriority); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("grounded")); + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("grounded")); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/InventoryPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/InventoryPower.java similarity index 89% rename from origins/src/main/java/io/github/dueris/originspaper/power/InventoryPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/InventoryPower.java index a89dab520..42dd128aa 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/InventoryPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/InventoryPower.java @@ -1,13 +1,14 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.ContainerType; import io.github.dueris.originspaper.data.types.Keybind; import io.github.dueris.originspaper.event.KeybindTriggerEvent; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.storage.PowerHolderComponent; import io.github.dueris.originspaper.util.KeybindUtil; import io.github.dueris.originspaper.util.Util; @@ -112,8 +113,8 @@ public static void storeItems(@NotNull List items, @NotNull org.bukki } } - public static @NotNull ArrayList getItems(org.bukkit.entity.Player p, String tag) { - ArrayList items = new ArrayList<>(); + public static @NotNull LinkedList getItems(org.bukkit.entity.Player p, String tag) { + LinkedList items = new LinkedList<>(); String encodedItems = getInNbtIO(tag, p); @@ -141,8 +142,8 @@ public static void storeItems(@NotNull List items, @NotNull org.bukki return items; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("inventory")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("inventory")) .add("title", SerializableDataTypes.STRING, "container.inventory") .add("container_type", SerializableDataTypes.enumValue(ContainerType.class), ContainerType.DROPPER) .add("drop_on_death", SerializableDataTypes.BOOLEAN, false) @@ -155,8 +156,8 @@ public static SerializableData buildFactory() { public void onLost(Player p) { org.bukkit.entity.Player player = (org.bukkit.entity.Player) p.getBukkitEntity(); if (!PlayerManager.playersLeaving.contains(player)) { - ArrayList vaultItems = getItems(player, getTag()); - for (ItemStack item : new ArrayList<>(vaultItems)) { + LinkedList vaultItems = getItems(player, getTag()); + for (ItemStack item : new LinkedList<>(vaultItems)) { if (item != null && item.getType() != Material.AIR) { if (recoverable) { player.getWorld().dropItemNaturally(player.getLocation(), item); @@ -165,7 +166,7 @@ public void onLost(Player p) { } } - storeItems(new ArrayList<>(), player, getTag()); + storeItems(new LinkedList<>(), player, getTag()); } } @@ -174,7 +175,7 @@ public void onUse(@NotNull KeybindTriggerEvent e) { if (getPlayers().contains(((CraftPlayer) e.getPlayer()).getHandle())) { if (isActive(((CraftPlayer) e.getPlayer()).getHandle())) { if (KeybindUtil.isKeyActive(keybind.key(), e.getPlayer())) { - ArrayList vaultItems = getItems(e.getPlayer(), getTag()); + LinkedList vaultItems = getItems(e.getPlayer(), getTag()); org.bukkit.inventory.Inventory vault = containerType.createInventory(Util.createIfPresent(title)); vaultItems.forEach(vault::addItem); e.getPlayer().openInventory(vault); @@ -193,8 +194,8 @@ public void onDeath(@NotNull PlayerDeathEvent e) { } private void dropItems(org.bukkit.entity.Player p) { - ArrayList vaultItems = getItems(p, getTag()); - for (ItemStack item : new ArrayList<>(vaultItems)) { + LinkedList vaultItems = getItems(p, getTag()); + for (ItemStack item : new LinkedList<>(vaultItems)) { if (item != null && item.getType() != Material.AIR && dropOnDeathFilter.test(new Tuple<>(((CraftPlayer) p).getHandle().level(), CraftItemStack.unwrap(item)))) { p.getWorld().dropItemNaturally(p.getLocation(), item); vaultItems.remove(item); @@ -210,7 +211,7 @@ public void onInventoryClose(@NotNull InventoryCloseEvent e) { for (InventoryPower power : PowerHolderComponent.getPowers(p, InventoryPower.class)) { if (matches(e.getView(), power)) { - ArrayList prunedItems = new ArrayList<>(); + LinkedList prunedItems = new LinkedList<>(); Arrays.stream(e.getInventory().getContents()) .filter(Objects::nonNull) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/InvisibilityPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/InvisibilityPower.java similarity index 73% rename from origins/src/main/java/io/github/dueris/originspaper/power/InvisibilityPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/InvisibilityPower.java index f0abe22e1..e223c2936 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/InvisibilityPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/InvisibilityPower.java @@ -1,8 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -16,8 +17,8 @@ public InvisibilityPower(@NotNull ResourceLocation key, @NotNull ResourceLocatio super(key, type, name, description, hidden, condition, loadingPriority); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("invisibility")); + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("invisibility")); } @Override diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/InvulnerablePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/InvulnerablePower.java similarity index 58% rename from origins/src/main/java/io/github/dueris/originspaper/power/InvulnerablePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/InvulnerablePower.java index f6b903e47..0c75ba778 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/InvulnerablePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/InvulnerablePower.java @@ -1,20 +1,16 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; -import io.github.dueris.originspaper.condition.types.item.AmountCondition; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.type.damage.AmountConditionType; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import org.bukkit.craftbukkit.damage.CraftDamageSource; -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent; import org.jetbrains.annotations.NotNull; public class InvulnerablePower extends PowerType { @@ -24,15 +20,15 @@ public InvulnerablePower(@NotNull ResourceLocation key, @NotNull ResourceLocatio @NotNull ConditionTypeFactory> damageCondition) { super(key, type, name, description, hidden, condition, loadingPriority); - if (damageCondition.getSerializableData() == AmountCondition.getFactory().getSerializableData()) { + if (damageCondition.getSerializableData() == AmountConditionType.getFactory().getSerializableData()) { throw new IllegalArgumentException("Using the 'amount' damage condition type in a power that uses the 'invulnerability' power type is not allowed!"); } this.damageCondition = damageCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("invulnerability")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("invulnerability")) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION) .postProcessor(data -> { @@ -45,16 +41,8 @@ public static SerializableData buildFactory() { }); } - @EventHandler - public void DamageEvent(@NotNull EntityDamageEvent e) { - if (((CraftEntity) e.getEntity()).getHandle() instanceof Player p) { - if (getPlayers().contains(p)) { - if (isActive(p) && damageCondition.test(new Tuple<>(((CraftDamageSource) e.getDamageSource()).getHandle(), 0.0F))) { - e.setCancelled(true); - e.setDamage(0); - } - - } - } + public boolean doesApply(DamageSource source) { + return damageCondition.test(new Tuple<>(source, 0.0F)); } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ItemOnItemPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ItemOnItemPower.java similarity index 91% rename from origins/src/main/java/io/github/dueris/originspaper/power/ItemOnItemPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ItemOnItemPower.java index 99c145027..446368a7d 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ItemOnItemPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ItemOnItemPower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -50,8 +51,8 @@ public ItemOnItemPower(@NotNull ResourceLocation key, @NotNull ResourceLocation this.resultFromOnStack = resultFromOnStack; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("item_on_item")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("item_on_item")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("using_item_action", ApoliDataTypes.ITEM_ACTION, null) .add("on_item_action", ApoliDataTypes.ITEM_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/KeepInventoryPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/KeepInventoryPower.java similarity index 88% rename from origins/src/main/java/io/github/dueris/originspaper/power/KeepInventoryPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/KeepInventoryPower.java index 2b5089ad3..23ef96735 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/KeepInventoryPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/KeepInventoryPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -34,8 +35,8 @@ public KeepInventoryPower(@NotNull ResourceLocation key, @NotNull ResourceLocati this.slots = slots == null ? null : new HashSet<>(slots); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("keep_inventory")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("keep_inventory")) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) .add("slots", SerializableDataTypes.INTS, null); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/LaunchPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/LaunchPower.java similarity index 75% rename from origins/src/main/java/io/github/dueris/originspaper/power/LaunchPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/LaunchPower.java index 3fa92d39c..0f85e8ae9 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/LaunchPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/LaunchPower.java @@ -1,13 +1,14 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; import io.github.dueris.originspaper.data.types.Keybind; import io.github.dueris.originspaper.event.KeybindTriggerEvent; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.KeybindUtil; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.chat.Component; @@ -21,25 +22,21 @@ import org.bukkit.event.EventHandler; import org.jetbrains.annotations.NotNull; -public class LaunchPower extends PowerType implements CooldownInterface { - private final int cooldown; +public class LaunchPower extends CooldownPower { private final float speed; private final SoundEvent sound; - private final HudRender hudRender; private final Keybind keybind; public LaunchPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, int cooldown, float speed, SoundEvent sound, HudRender hudRender, Keybind keybind) { - super(key, type, name, description, hidden, condition, loadingPriority); - this.cooldown = cooldown; + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.speed = speed; this.sound = sound; - this.hudRender = hudRender; this.keybind = keybind; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("launch")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("launch")) .add("cooldown", SerializableDataTypes.INT, 1) .add("speed", SerializableDataTypes.FLOAT) .add("sound", SerializableDataTypes.SOUND_EVENT, null) @@ -51,7 +48,7 @@ public static SerializableData buildFactory() { public void onKey(@NotNull KeybindTriggerEvent e) { Player p = ((CraftPlayer) e.getPlayer()).getHandle(); if (getPlayers().contains(p) && KeybindUtil.isKeyActive(keybind.key(), e.getPlayer())) { - if (!p.level().isClientSide && isActive(p) && !CooldownPower.isInCooldown(e.getPlayer(), this)) { + if (!p.level().isClientSide && isActive(p) && canUse(p)) { p.push(0, speed, 0); p.hurtMarked = true; if (sound != null) { @@ -62,19 +59,10 @@ public void onKey(@NotNull KeybindTriggerEvent e) { } if (cooldown > 1) { - CooldownPower.addCooldown(e.getPlayer(), this); + use(p); } } } } - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifierPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifierPower.java similarity index 78% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifierPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifierPower.java index a9ee10366..b7e678953 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifierPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifierPower.java @@ -1,8 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -26,8 +27,8 @@ public ModifierPower(@NotNull ResourceLocation key, @NotNull ResourceLocation ty } } - public static SerializableData buildFactory() { - return PowerType.buildFactory() + public static SerializableData getFactory() { + return PowerType.getFactory() .add("modifier", Modifier.DATA_TYPE, null) .add("modifiers", Modifier.LIST_TYPE, null); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyAirSpeedPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyAirSpeedPower.java similarity index 88% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyAirSpeedPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyAirSpeedPower.java index 2da6968db..12ebb6258 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyAirSpeedPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyAirSpeedPower.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; import io.github.dueris.originspaper.util.Util; @@ -29,8 +29,8 @@ public ModifyAirSpeedPower(@NotNull ResourceLocation key, @NotNull ResourceLocat super(key, type, name, description, hidden, condition, loadingPriority, modifier, modifiers); } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_air_speed")); + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_air_speed")); } @Override diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyBlockRenderPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyBlockRenderPower.java similarity index 88% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyBlockRenderPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyBlockRenderPower.java index 680a71ff3..c9ed8ef6e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyBlockRenderPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyBlockRenderPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import com.destroystokyo.paper.event.server.ServerTickEndEvent; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Shape; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.chunk.LevelChunkUtil; import io.papermc.paper.event.packet.PlayerChunkLoadEvent; import io.papermc.paper.math.Position; @@ -26,12 +27,12 @@ import org.bukkit.event.EventHandler; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class ModifyBlockRenderPower extends PowerType { - public static ArrayList que = new ArrayList<>(); + public static LinkedList que = new LinkedList<>(); private final ConditionTypeFactory blockCondition; private final BlockState state; @@ -42,8 +43,8 @@ public ModifyBlockRenderPower(@NotNull ResourceLocation key, @NotNull ResourceLo this.state = state; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_block_render")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_block_render")) .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) .add("block", SerializableDataTypes.BLOCK_STATE); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyBreakSpeedPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyBreakSpeedPower.java similarity index 86% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyBreakSpeedPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyBreakSpeedPower.java index cdef70d2c..000296ee3 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyBreakSpeedPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyBreakSpeedPower.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; @@ -53,8 +53,8 @@ public ModifyBreakSpeedPower(@NotNull ResourceLocation key, @NotNull ResourceLoc } } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_break_speed")) + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_break_speed")) .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) .add("hardness_modifier", Modifier.DATA_TYPE, null) .add("hardness_modifiers", Modifier.LIST_TYPE, null); @@ -65,7 +65,7 @@ public LinkedList getHardnessModifiers() { } public boolean doesApply(BlockPos pos, Entity entity) { - return blockCondition == null || blockCondition.test(new BlockInWorld(entity.level(), pos, true)); + return isActive(entity) && (blockCondition == null || blockCondition.test(new BlockInWorld(entity.level(), pos, true))); } public void applyPower(BlockPos pos, @NotNull Player player, boolean modifyHardness) { @@ -76,8 +76,8 @@ public void applyPower(BlockPos pos, @NotNull Player player, boolean modifyHardn if (modifyHardness ? getHardnessModifiers().isEmpty() : getModifiers().isEmpty()) return; // Don't apply empty modifiers instance.setBaseValue( - Math.abs(doesApply(pos, player) ? ModifierUtil.applyModifiers(player, - modifyHardness ? getHardnessModifiers() : getModifiers(), b) : b) + doesApply(pos, player) ? ModifierUtil.applyModifiers(player, + modifyHardness ? getHardnessModifiers() : getModifiers(), b) : b ); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyCraftingPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyCraftingPower.java similarity index 89% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyCraftingPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyCraftingPower.java index e3be88ebe..24614e95b 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyCraftingPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyCraftingPower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -46,8 +47,8 @@ public ModifyCraftingPower(@NotNull ResourceLocation key, @NotNull ResourceLocat this.blockAction = blockAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_crafting")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_crafting")) .add("recipe", SerializableDataTypes.IDENTIFIER, null) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) .add("result", SerializableDataTypes.ITEM_STACK, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyDamageDealtPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyDamageDealtPower.java similarity index 91% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyDamageDealtPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyDamageDealtPower.java index 6b084ba66..721a75a5e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyDamageDealtPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyDamageDealtPower.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; @@ -45,8 +45,8 @@ public ModifyDamageDealtPower(@NotNull ResourceLocation key, @NotNull ResourceLo this.damageCondition = damageCondition; } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_damage_dealt")) + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_damage_dealt")) .add("self_action", ApoliDataTypes.ENTITY_ACTION, null) .add("target_action", ApoliDataTypes.ENTITY_ACTION, null) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyDamageTakenPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyDamageTakenPower.java similarity index 90% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyDamageTakenPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyDamageTakenPower.java index 02ef3af9d..4bdbf91be 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyDamageTakenPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyDamageTakenPower.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; @@ -40,8 +40,8 @@ public ModifyDamageTakenPower(@NotNull ResourceLocation key, @NotNull ResourceLo this.damageCondition = damageCondition; } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_damage_taken")) + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_damage_taken")) .add("self_action", ApoliDataTypes.ENTITY_ACTION, null) .add("attacker_action", ApoliDataTypes.ENTITY_ACTION, null) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyEnchantmentLevelPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyEnchantmentLevelPower.java similarity index 89% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyEnchantmentLevelPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyEnchantmentLevelPower.java index 515297649..2d15d95f8 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyEnchantmentLevelPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyEnchantmentLevelPower.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.mixin.ItemEnchantmentsMixin; @@ -36,8 +36,8 @@ public ModifyEnchantmentLevelPower(@NotNull ResourceLocation key, @NotNull Resou this.itemCondition = itemCondition; } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_enchantment_level")) + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_enchantment_level")) .add("enchantment", SerializableDataTypes.ENCHANTMENT) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyExhaustionPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyExhaustionPower.java similarity index 81% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyExhaustionPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyExhaustionPower.java index 5cd1e6d31..ab89a3bee 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyExhaustionPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyExhaustionPower.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; import net.minecraft.network.chat.Component; @@ -23,8 +23,8 @@ public ModifyExhaustionPower(@NotNull ResourceLocation key, @NotNull ResourceLoc super(key, type, name, description, hidden, condition, loadingPriority, modifier, modifiers); } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_exhaustion")); + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_exhaustion")); } @EventHandler diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyExperiencePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyExperiencePower.java similarity index 82% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyExperiencePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyExperiencePower.java index 98b73a77f..824859b18 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyExperiencePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyExperiencePower.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; import net.minecraft.network.chat.Component; @@ -23,8 +23,8 @@ public ModifyExperiencePower(@NotNull ResourceLocation key, @NotNull ResourceLoc super(key, type, name, description, hidden, condition, loadingPriority, modifier, modifiers); } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_xp_gain")); + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_xp_gain")); } @EventHandler(priority = EventPriority.LOWEST) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyFallingPowerType.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyFallingPowerType.java similarity index 80% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyFallingPowerType.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyFallingPowerType.java index a44e08c7d..cc041fd5e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyFallingPowerType.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyFallingPowerType.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierOperation; import net.minecraft.network.chat.Component; @@ -25,8 +25,8 @@ public ModifyFallingPowerType(@NotNull ResourceLocation key, @NotNull ResourceLo this.addModifier(Modifier.of(ModifierOperation.SET_TOTAL, velocity)); } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_falling")) + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_falling")) .add("velocity", SerializableDataTypes.DOUBLE) .add("take_fall_damage", SerializableDataTypes.BOOLEAN, true); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyHarvestPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyHarvestPower.java similarity index 87% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyHarvestPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyHarvestPower.java index ff5ce2597..0a9d217d1 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyHarvestPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyHarvestPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.ApoliScheduler; import io.netty.util.internal.ConcurrentSet; import net.minecraft.core.BlockPos; @@ -35,8 +36,8 @@ public ModifyHarvestPower(@NotNull ResourceLocation key, @NotNull ResourceLocati this.allow = allow; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_harvest")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_harvest")) .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) .add("allow", SerializableDataTypes.BOOLEAN); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyHealingPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyHealingPower.java similarity index 81% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyHealingPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyHealingPower.java index be542374f..5b22282d1 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyHealingPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyHealingPower.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; import net.minecraft.network.chat.Component; @@ -23,8 +23,8 @@ public ModifyHealingPower(@NotNull ResourceLocation key, @NotNull ResourceLocati super(key, type, name, description, hidden, condition, loadingPriority, modifier, modifiers); } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_healing")); + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_healing")); } @EventHandler diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyJumpPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyJumpPower.java similarity index 90% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyJumpPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyJumpPower.java index 1a4c076b4..1c6ea3a1a 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyJumpPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyJumpPower.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; import io.github.dueris.originspaper.util.Util; @@ -31,8 +31,8 @@ public ModifyJumpPower(@NotNull ResourceLocation key, @NotNull ResourceLocation super(key, type, name, description, hidden, condition, loadingPriority, modifier, modifiers); } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_jump")); + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_jump")); } @Override diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyLavaSpeedPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyLavaSpeedPower.java similarity index 85% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyLavaSpeedPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyLavaSpeedPower.java index 3b2d973e4..a123b20ac 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyLavaSpeedPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyLavaSpeedPower.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; import net.minecraft.network.chat.Component; @@ -31,8 +31,8 @@ public ModifyLavaSpeedPower(@NotNull ResourceLocation key, @NotNull ResourceLoca super(key, type, name, description, hidden, condition, loadingPriority, modifier, modifiers); } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_lava_speed")); + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_lava_speed")); } @Override diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyPlayerSpawnPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyPlayerSpawnPower.java similarity index 92% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyPlayerSpawnPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyPlayerSpawnPower.java index 03fb9f15b..7e15cc8bc 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyPlayerSpawnPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyPlayerSpawnPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.ChatFormatting; import net.minecraft.core.*; import net.minecraft.core.registries.Registries; @@ -35,7 +36,7 @@ import org.jetbrains.annotations.NotNull; import java.lang.reflect.Method; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; @@ -68,8 +69,8 @@ public ModifyPlayerSpawnPower(@NotNull ResourceLocation key, @NotNull ResourceLo this.dimensionDistanceMultiplier = dimensionDistanceMultiplier; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_player_spawn")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_player_spawn")) .add("dimension", SerializableDataTypes.DIMENSION) .add("structure", SerializableDataTypes.registryKey(Registries.STRUCTURE), null) .add("structure_tag", SerializableDataTypes.tag(Registries.STRUCTURE), null) @@ -100,7 +101,7 @@ public void teleportToModifiedSpawn(Entity entity) { Tuple spawnPoint = this.getSpawn(entity).orElse(null); if (spawnPoint == null) { - OriginsPaper.getPlugin().getLog4JLogger().warn("Power \"{}\" couldnt build spawn point for player!", getTag()); + OriginsPaper.LOGGER.warn("Power \"{}\" couldnt build spawn point for player!", getTag()); return; } @@ -112,7 +113,7 @@ public void teleportToModifiedSpawn(Entity entity) { Vec3 placement = DismountHelper.findSafeDismountLocation(serverPlayer.getType(), spawnPointDimension, spawnPointPosition, true); if (placement == null) { - OriginsPaper.getPlugin().getLog4JLogger().warn("Power \"{}\" could not find a suitable spawn point for player {}! Teleporting to the found location directly...", getTag(), entity.getName().getString()); + OriginsPaper.LOGGER.warn("Power \"{}\" could not find a suitable spawn point for player {}! Teleporting to the found location directly...", getTag(), entity.getName().getString()); Location bukkitLocation = new Location(spawnPointDimension.getWorld(), spawnPointPosition.getX(), spawnPointPosition.getY(), spawnPointPosition.getZ(), pitch, yaw); serverPlayer.getBukkitEntity().teleport(bukkitLocation); } else { @@ -190,7 +191,7 @@ private Optional getBiomePos(Entity entity, ServerLevel targetDimensio name.append(!name.isEmpty() ? " or " : "").append("any biomes from tag \"").append(biomeTag.location()).append("\""); } - OriginsPaper.getPlugin().getLog4JLogger().warn("Power \"{}\" could not set player {}'s spawn point at {} as none can be found nearby in dimension \"{}\".", getTag(), entity.getName().getString(), name, dimensionKey.location()); + OriginsPaper.LOGGER.warn("Power \"{}\" could not set player {}'s spawn point at {} as none can be found nearby in dimension \"{}\".", getTag(), entity.getName().getString(), name, dimensionKey.location()); entity.sendSystemMessage(Component.literal("Power \"%s\" couldn't set spawn point at %s as none can be found nearby in dimension \"%s\"!".formatted(getTag(), name, dimensionKey.location())).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY)); return Optional.empty(); @@ -207,7 +208,7 @@ private Optional> getStructurePos(Entity entity, Serv } Registry structureRegistry = dimension.registryAccess().registryOrThrow(Registries.STRUCTURE); - List> structureEntries = new ArrayList<>(); + List> structureEntries = new LinkedList<>(); if (structureKey != null) { structureEntries.add(structureRegistry.getHolderOrThrow(structureKey)); @@ -249,7 +250,7 @@ private Optional> getStructurePos(Entity entity, Serv name.append(!name.isEmpty() ? " or " : "").append("any structures from tag \"").append(structureTag.location()).append("\""); } - OriginsPaper.getPlugin().getLog4JLogger().warn("Power \"{}\" could not set player {}'s spawn point at {} as none can be found nearby in dimension \"{}\".", getTag(), entity.getName().getString(), name, dimensionKey.location()); + OriginsPaper.LOGGER.warn("Power \"{}\" could not set player {}'s spawn point at {} as none can be found nearby in dimension \"{}\".", getTag(), entity.getName().getString(), name, dimensionKey.location()); entity.sendSystemMessage(Component.literal("Power \"%s\" couldn't set spawn point at %s as none can be found nearby in dimension \"%s\"!".formatted(getTag(), name, dimensionKey.location())).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY)); return Optional.empty(); diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyProjectileDamagePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyProjectileDamagePower.java similarity index 89% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyProjectileDamagePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyProjectileDamagePower.java index e91026969..e8ca14594 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyProjectileDamagePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyProjectileDamagePower.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; @@ -42,8 +42,8 @@ public ModifyProjectileDamagePower(@NotNull ResourceLocation key, @NotNull Resou this.damageCondition = damageCondition; } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_projectile_damage")) + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_projectile_damage")) .add("self_action", ApoliDataTypes.ENTITY_ACTION, null) .add("target_action", ApoliDataTypes.ENTITY_ACTION, null) .add("target_condition", ApoliDataTypes.ENTITY_CONDITION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyStatusEffectAmplifierPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyStatusEffectAmplifierPower.java similarity index 79% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyStatusEffectAmplifierPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyStatusEffectAmplifierPower.java index 46f6911cf..167d180ed 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyStatusEffectAmplifierPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyStatusEffectAmplifierPower.java @@ -1,10 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; @@ -36,13 +36,13 @@ public ModifyStatusEffectAmplifierPower(@NotNull ResourceLocation key, @NotNull } } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_status_effect_amplifier")) + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_status_effect_amplifier")) .add("status_effect", SerializableDataTypes.STATUS_EFFECT_ENTRY, null) .add("status_effects", SerializableDataBuilder.of(SerializableDataTypes.STATUS_EFFECT_ENTRY.listOf()), null); } public boolean doesApply(Holder statusEffect) { - return statusEffects.contains(statusEffect); + return statusEffects.isEmpty() || statusEffects.contains(statusEffect); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyStatusEffectDurationPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyStatusEffectDurationPower.java similarity index 79% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyStatusEffectDurationPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyStatusEffectDurationPower.java index 0986a6166..c43a351c6 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyStatusEffectDurationPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyStatusEffectDurationPower.java @@ -1,10 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; @@ -36,13 +36,13 @@ public ModifyStatusEffectDurationPower(@NotNull ResourceLocation key, @NotNull R } } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_status_effect_duration")) + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_status_effect_duration")) .add("status_effect", SerializableDataTypes.STATUS_EFFECT_ENTRY, null) .add("status_effects", SerializableDataBuilder.of(SerializableDataTypes.STATUS_EFFECT_ENTRY.listOf()), null); } public boolean doesApply(Holder statusEffect) { - return statusEffects.contains(statusEffect); + return statusEffects.isEmpty() || statusEffects.contains(statusEffect); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifySwimSpeedPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifySwimSpeedPower.java similarity index 83% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifySwimSpeedPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifySwimSpeedPower.java index 3162fe419..b9a271324 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifySwimSpeedPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifySwimSpeedPower.java @@ -1,8 +1,8 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.Modifier; import io.github.dueris.originspaper.data.types.modifier.ModifierUtil; import net.minecraft.network.chat.Component; @@ -23,8 +23,8 @@ public ModifySwimSpeedPower(@NotNull ResourceLocation key, @NotNull ResourceLoca super(key, type, name, description, hidden, condition, loadingPriority, modifier, modifiers); } - public static SerializableData buildFactory() { - return ModifierPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_swim_speed")); + public static SerializableData getFactory() { + return ModifierPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_swim_speed")); } @Override diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyTypeTagPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyTypeTagPower.java similarity index 79% rename from origins/src/main/java/io/github/dueris/originspaper/power/ModifyTypeTagPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyTypeTagPower.java index b13c772fd..13751eb26 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ModifyTypeTagPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ModifyTypeTagPower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.core.HolderSet; import net.minecraft.network.chat.Component; @@ -34,8 +35,8 @@ public static boolean doesApply(Entity entity, @NotNull HolderSet> .orElse(false); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_type_tag")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("modify_type_tag")) .add("tag", SerializableDataTypes.ENTITY_TAG); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/type/MultiplePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/MultiplePower.java new file mode 100644 index 000000000..433ba9e9f --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/MultiplePower.java @@ -0,0 +1,56 @@ +package io.github.dueris.originspaper.power.type; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.dueris.calio.data.DataBuildDirective; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.calio.parser.CalioParser; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.power.factory.PowerTypeFactory; +import io.github.dueris.originspaper.registry.Registries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; + +public class MultiplePower extends PowerType { + private final List subPowers = new LinkedList<>(); + + public MultiplePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority) { + super(key, type, name, description, hidden, condition, loadingPriority); + } + + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("multiple")); + } + + @Override + public void onBootstrap() { + for (String key : sourceObject.keySet()) { + JsonElement element = sourceObject.get(key); + if (!element.isJsonObject()) continue; + + JsonObject jo = sourceObject.getAsJsonObject(key); + DataBuildDirective dataBuildDirective = new DataBuildDirective<>(List.of("apoli", "origins"), "power", PowerTypeFactory.DATA, 0, Registries.POWER); + PowerType type = CalioParser.parseFile( + new Tuple<>(ResourceLocation.fromNamespaceAndPath(this.getId().getNamespace(), getId().getPath() + "_" + key.toLowerCase(Locale.getDefault())), jo.toString()), dataBuildDirective + ); + if (type == null) { + continue; + } + subPowers.add(type); + } + } + + public List getSubPowers() { + return subPowers; + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/NightVisionPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/NightVisionPower.java similarity index 72% rename from origins/src/main/java/io/github/dueris/originspaper/power/NightVisionPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/NightVisionPower.java index 286c04127..05fc6d2c8 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/NightVisionPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/NightVisionPower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffectInstance; @@ -21,8 +22,8 @@ public NightVisionPower(@NotNull ResourceLocation key, @NotNull ResourceLocation this.strength = strength; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("night_vision")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("night_vision")) .add("strength", SerializableDataTypes.FLOAT, 1.0F); } @@ -40,4 +41,9 @@ public void tick(Player player) { } } } + + @Override + public void onRemoved(@NotNull Player player) { + player.removeEffect(MobEffects.NIGHT_VISION); + } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/OverlayPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/OverlayPower.java similarity index 66% rename from origins/src/main/java/io/github/dueris/originspaper/power/OverlayPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/OverlayPower.java index 05651cfae..baa65a451 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/OverlayPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/OverlayPower.java @@ -1,8 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -13,22 +14,20 @@ import org.jetbrains.annotations.NotNull; public class OverlayPower extends PowerType { - private static final CraftWorldBorder border; - - static { - border = (CraftWorldBorder) Bukkit.createWorldBorder(); - border.setWarningDistance(999999999); - } + private static CraftWorldBorder border = null; public OverlayPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority) { super(key, type, name, description, hidden, condition, loadingPriority); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("overlay")); + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("overlay")); } public static void init(@NotNull Player player) { + if (border == null) { + border = buildBorder(); + } border.setCenter(player.level().getWorld().getWorldBorder().getCenter()); border.setSize(player.level().getWorld().getWorldBorder().getSize()); ((CraftPlayer) player.getBukkitEntity()).setWorldBorder(border); @@ -38,6 +37,12 @@ public static void reset(@NotNull Player player) { ((CraftPlayer) player.getBukkitEntity()).setWorldBorder(player.level().getWorld().getWorldBorder()); } + public static @NotNull CraftWorldBorder buildBorder() { + CraftWorldBorder worldBorder = (CraftWorldBorder) Bukkit.createWorldBorder(); + worldBorder.setWarningDistance(999999999); + return worldBorder; + } + @Override public void onRemoved(Player player) { reset(player); diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ParticlePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ParticlePower.java similarity index 91% rename from origins/src/main/java/io/github/dueris/originspaper/power/ParticlePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ParticlePower.java index dea1266b9..06fb5c6d2 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ParticlePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ParticlePower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -47,8 +48,8 @@ public ParticlePower(@NotNull ResourceLocation key, @NotNull ResourceLocation ty this.visibleWhileInvisible = visibleWhileInvisible; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("particle")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("particle")) .add("particle", SerializableDataTypes.PARTICLE_EFFECT_OR_TYPE) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("count", SerializableDataTypes.INT, 1) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PhasingPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PhasingPower.java similarity index 84% rename from origins/src/main/java/io/github/dueris/originspaper/power/PhasingPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PhasingPower.java index 2ae4fc83f..86939675a 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PhasingPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PhasingPower.java @@ -1,12 +1,14 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import com.destroystokyo.paper.event.server.ServerTickEndEvent; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; +import io.papermc.paper.event.player.PlayerFailMoveEvent; import net.minecraft.Optionull; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -44,8 +46,8 @@ import java.util.function.Predicate; public class PhasingPower extends PowerType { - private static final NamespacedKey INSIDE_BLOCK_KEY = new NamespacedKey(OriginsPaper.getPlugin(), "insideblock"); - public static ArrayList PHASING_BLOCKS = new ArrayList<>(); + private static final NamespacedKey INSIDE_BLOCK_KEY = new NamespacedKey("originspaper", "insideblock"); + public static LinkedList PHASING_BLOCKS = new LinkedList<>(); public static HashMap RESYNCED = new HashMap<>(); public static HashMap> TRACKED_BLOCKPOS = new HashMap<>(); public static AttributeModifier PHASING_SPEED_FIX = new AttributeModifier(NamespacedKey.fromString("origins:phasing_patch"), 1, AttributeModifier.Operation.ADD_NUMBER); @@ -84,8 +86,8 @@ public PhasingPower(@NotNull ResourceLocation key, @NotNull ResourceLocation typ this.phaseDownCondition = phaseDownCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("phasing")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("phasing")) .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) .add("blacklist", SerializableDataTypes.BOOLEAN, false) .add("render_type", SerializableDataTypes.enumValue(RenderType.class), RenderType.BLINDNESS) @@ -121,13 +123,6 @@ public void sendPhasingPackets(ServerPlayer player) { p.setFlying(true); } - @EventHandler - public void serverTickEnd(ServerTickEndEvent event) { - for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) { - ((CraftPlayer) player).getHandle().noPhysics = true; - } - } - @EventHandler public void onShift(PlayerToggleSneakEvent e) { new BukkitRunnable() { @@ -136,11 +131,9 @@ public void run() { if (e.isSneaking()) { org.bukkit.entity.Player p = e.getPlayer(); Player player = ((CraftPlayer) p).getHandle(); - if (getPlayers().contains(player)) { - if (isActive(player) && (p.getLocation().add(0, -0.5, 0).getBlock().isCollidable() || p.getLocation().add(0, -0.5, 0).getBlock().isSolid())) { - if (phaseDownCondition.test(player)) { - p.teleportAsync(p.getLocation().add(0, -0.1, 0)); - } + if (getPlayers().contains(player) && isActive(player) && (p.getLocation().add(0, -0.5, 0).getBlock().isCollidable() || p.getLocation().add(0, -0.5, 0).getBlock().isSolid())) { + if (phaseDownCondition.test(player)) { + p.teleportAsync(p.getLocation().add(0, -0.1, 0)); } } } @@ -204,24 +197,35 @@ public void tick(@NotNull Player player) { PHASING_BLOCKS.remove(player); p.getPersistentDataContainer().set(INSIDE_BLOCK_KEY, PersistentDataType.BOOLEAN, false); } - } else { - PHASING_BLOCKS.remove(player); - if (RESYNCED.get(player) == null) { - RESYNCED.put(player, false); - } else if (RESYNCED.get(player)) { - resyncJavaPlayer((ServerPlayer) player); - if (renderType.equals(RenderType.BLINDNESS)) { - p.removePotionEffect(PotionEffectType.BLINDNESS); - } - if (TRACKED_BLOCKPOS.get(player) != null) { - ClientboundRemoveEntitiesPacket removeEntitiesPacket = new ClientboundRemoveEntitiesPacket(Util.convertToIntArray(TRACKED_BLOCKPOS.get(player).values())); - ((ServerPlayer) player).connection.send(removeEntitiesPacket); - TRACKED_BLOCKPOS.clear(); - } - p.setFlySpeed(0.1F); - p.getPersistentDataContainer().set(INSIDE_BLOCK_KEY, PersistentDataType.BOOLEAN, false); - RESYNCED.put(player, false); + } else if (getPlayers().contains(player)) { + callUndo(player); + } + } + + @Override + public void onRemoved(Player player) { + callUndo(player); + } + + public void callUndo(@NotNull Player player) { + CraftPlayer p = (CraftPlayer) player.getBukkitEntity(); + + PHASING_BLOCKS.remove(player); + if (RESYNCED.get(player) == null) { + RESYNCED.put(player, false); + } else if (RESYNCED.get(player)) { + resyncJavaPlayer((ServerPlayer) player); + if (renderType.equals(RenderType.BLINDNESS)) { + p.removePotionEffect(PotionEffectType.BLINDNESS); + } + if (TRACKED_BLOCKPOS.get(player) != null) { + ClientboundRemoveEntitiesPacket removeEntitiesPacket = new ClientboundRemoveEntitiesPacket(Util.convertToIntArray(TRACKED_BLOCKPOS.get(player).values())); + ((ServerPlayer) player).connection.send(removeEntitiesPacket); + TRACKED_BLOCKPOS.clear(); } + p.setFlySpeed(0.1F); + p.getPersistentDataContainer().set(INSIDE_BLOCK_KEY, PersistentDataType.BOOLEAN, false); + RESYNCED.put(player, false); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventBeingUsedPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventBeingUsedPower.java similarity index 92% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventBeingUsedPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventBeingUsedPower.java index 36449abba..0d691b157 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventBeingUsedPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventBeingUsedPower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -49,8 +50,8 @@ public PreventBeingUsedPower(@NotNull ResourceLocation key, @NotNull ResourceLoc this.resultItemAction = resultItemAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_being_used")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_being_used")) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventBlockPlacePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventBlockPlacePower.java similarity index 93% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventBlockPlacePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventBlockPlacePower.java index 3c436b94c..94f423e2b 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventBlockPlacePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventBlockPlacePower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -57,8 +58,8 @@ public PreventBlockPlacePower(@NotNull ResourceLocation key, @NotNull ResourceLo this.heldItemAction = heldItemAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_block_place")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_block_place")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("place_to_action", ApoliDataTypes.BLOCK_ACTION, null) .add("place_on_action", ApoliDataTypes.BLOCK_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventBlockUsePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventBlockUsePower.java similarity index 93% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventBlockUsePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventBlockUsePower.java index 94b740eb6..a6df80817 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventBlockUsePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventBlockUsePower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -59,8 +60,8 @@ public PreventBlockUsePower(@NotNull ResourceLocation key, @NotNull ResourceLoca this.hands = hands; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_block_use")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_block_use")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("block_action", ApoliDataTypes.BLOCK_ACTION, null) .add("result_item_action", ApoliDataTypes.ITEM_ACTION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventDeathPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventDeathPower.java similarity index 76% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventDeathPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventDeathPower.java index ab6e39be1..8e243b8c8 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventDeathPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventDeathPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -26,8 +27,8 @@ public PreventDeathPower(@NotNull ResourceLocation key, @NotNull ResourceLocatio this.damageCondition = damageCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_death")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_death")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION, null); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventElytraFlightPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventElytraFlightPower.java similarity index 76% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventElytraFlightPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventElytraFlightPower.java index 022887de7..6d3738ace 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventElytraFlightPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventElytraFlightPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -23,8 +24,8 @@ public PreventElytraFlightPower(@NotNull ResourceLocation key, @NotNull Resource this.entityAction = entityAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_elytra_flight")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_elytra_flight")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION, null); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventEntityCollisionPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventEntityCollisionPower.java similarity index 77% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventEntityCollisionPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventEntityCollisionPower.java index 9b9d8ad39..38261c29a 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventEntityCollisionPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventEntityCollisionPower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -21,8 +22,8 @@ public PreventEntityCollisionPower(@NotNull ResourceLocation key, @NotNull Resou this.biEntityCondition = biEntityCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_entity_collision")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_entity_collision")) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventEntityRenderPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventEntityRenderPower.java similarity index 78% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventEntityRenderPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventEntityRenderPower.java index f08d0c604..f7e292a6a 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventEntityRenderPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventEntityRenderPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Shape; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -13,14 +14,15 @@ import org.bukkit.craftbukkit.entity.CraftPlayer; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; public class PreventEntityRenderPower extends PowerType { private final ConditionTypeFactory entityCondition; private final ConditionTypeFactory> bientityCondition; - private final ConcurrentHashMap> hiddenEntities = new ConcurrentHashMap<>(); + private final ConcurrentHashMap> hiddenEntities = new ConcurrentHashMap<>(); public PreventEntityRenderPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ConditionTypeFactory entityCondition, ConditionTypeFactory> bientityCondition) { @@ -29,8 +31,8 @@ public PreventEntityRenderPower(@NotNull ResourceLocation key, @NotNull Resource this.bientityCondition = bientityCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_entity_render")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_entity_render")) .add("entity_condition", ApoliDataTypes.ENTITY_CONDITION, null) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null); } @@ -53,7 +55,7 @@ public void tick(@NotNull Player player) { private void markHidden(Player player, Entity entity) { if (!hiddenEntities.containsKey(player)) { - hiddenEntities.put(player, new ArrayList<>()); + hiddenEntities.put(player, new ConcurrentLinkedQueue<>()); markHidden(player, entity); return; } @@ -62,7 +64,7 @@ private void markHidden(Player player, Entity entity) { private boolean isHidden(Player player, Entity entity) { if (!hiddenEntities.containsKey(player)) { - hiddenEntities.put(player, new ArrayList<>()); + hiddenEntities.put(player, new ConcurrentLinkedQueue<>()); return isHidden(player, entity); } return hiddenEntities.get(player).contains(entity); @@ -70,7 +72,7 @@ private boolean isHidden(Player player, Entity entity) { private void markShown(Player player, Entity entity) { if (!hiddenEntities.containsKey(player)) { - hiddenEntities.put(player, new ArrayList<>()); + hiddenEntities.put(player, new ConcurrentLinkedQueue<>()); markShown(player, entity); return; } @@ -79,9 +81,10 @@ private void markShown(Player player, Entity entity) { @Override public void onRemoved(Player player) { - if (hiddenEntities.containsKey(player)) { + if (hiddenEntities.containsKey(player) && hiddenEntities.get(player) != null) { CraftPlayer craftPlayer = (CraftPlayer) player.getBukkitEntity(); for (Entity entity : hiddenEntities.get(player)) { + if (entity == null) continue; craftPlayer.showEntity(OriginsPaper.getPlugin(), entity.getBukkitEntity()); markShown(player, entity); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventEntityUsePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventEntityUsePower.java similarity index 92% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventEntityUsePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventEntityUsePower.java index 15b6e5611..dfe0df6dd 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventEntityUsePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventEntityUsePower.java @@ -1,11 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -49,8 +50,8 @@ public PreventEntityUsePower(@NotNull ResourceLocation key, @NotNull ResourceLoc this.resultItemAction = resultItemAction; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_entity_use")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_entity_use")) .add("bientity_action", ApoliDataTypes.BIENTITY_ACTION, null) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventGameEventPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventGameEventPower.java similarity index 81% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventGameEventPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventGameEventPower.java index 9e40a41fd..ee4006c03 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventGameEventPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventGameEventPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -40,8 +41,8 @@ public PreventGameEventPower(@NotNull ResourceLocation key, @NotNull ResourceLoc } } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_game_event")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_game_event")) .add("event", SerializableDataTypes.GAME_EVENT_ENTRY, null) .add("events", SerializableDataBuilder.of(SerializableDataTypes.GAME_EVENT_ENTRY.listOf()), null) .add("tag", SerializableDataTypes.GAME_EVENT_TAG, null) diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventItemPickupPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventItemPickupPower.java similarity index 85% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventItemPickupPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventItemPickupPower.java index a33ff6fc3..491864547 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventItemPickupPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventItemPickupPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.storage.PowerHolderComponent; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; @@ -51,8 +52,8 @@ public static boolean doesPrevent(ItemEntity itemEntity, Entity entity) { } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_item_pickup")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_item_pickup")) .add("bientity_action_item", ApoliDataTypes.BIENTITY_ACTION, null) .add("item_action", ApoliDataTypes.ITEM_ACTION, null) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null); diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventItemUsePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventItemUsePower.java similarity index 82% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventItemUsePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventItemUsePower.java index 3e47cda93..4da60b69f 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventItemUsePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventItemUsePower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -26,8 +27,8 @@ public PreventItemUsePower(@NotNull ResourceLocation key, @NotNull ResourceLocat this.itemCondition = itemCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_item_use")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_item_use")) .add("item_condition", ApoliDataTypes.ITEM_CONDITION, null); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/PreventSleepPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventSleepPower.java similarity index 81% rename from origins/src/main/java/io/github/dueris/originspaper/power/PreventSleepPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/PreventSleepPower.java index 028aa7043..1a4d01189 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/PreventSleepPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/PreventSleepPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -26,8 +27,8 @@ public PreventSleepPower(@NotNull ResourceLocation key, @NotNull ResourceLocatio this.setSpawnPoint = setSpawnPoint; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_sleep")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("prevent_sleep")) .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) .add("message", ApoliDataTypes.DEFAULT_TRANSLATABLE_TEXT, Component.literal("You cannot sleep")) .add("set_spawn_point", SerializableDataTypes.BOOLEAN, false); diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/RecipePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/RecipePower.java similarity index 77% rename from origins/src/main/java/io/github/dueris/originspaper/power/RecipePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/RecipePower.java index eb1523878..e48a5035c 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/RecipePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/RecipePower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -20,14 +21,16 @@ import org.bukkit.inventory.ShapelessRecipe; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; public class RecipePower extends PowerType { public static HashMap> recipeMapping = new HashMap<>(); public static HashMap taggedRegistry = new HashMap<>(); - public static List tags = new ArrayList<>(); + public static List tags = new LinkedList<>(); + public static List BUILT_RECIPES = new CopyOnWriteArrayList<>(); private final RecipeHolder> recipeHolder; private final org.bukkit.inventory.Recipe bukkitRecipe; @@ -36,13 +39,13 @@ public RecipePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type super(key, type, name, description, hidden, condition, loadingPriority); this.recipeHolder = recipeHolder; this.bukkitRecipe = recipeHolder.toBukkitRecipe(); - Bukkit.addRecipe(bukkitRecipe); + BUILT_RECIPES.add(bukkitRecipe); tags.add(computeTag(bukkitRecipe)); taggedRegistry.put(computeTag(bukkitRecipe), bukkitRecipe); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("recipe")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("recipe")) .add("recipe", SerializableDataTypes.RECIPE); } @@ -61,7 +64,9 @@ public RecipeHolder> getNmsRecipe() { @EventHandler(priority = EventPriority.HIGHEST) public void load(ServerLoadEvent e) { - Bukkit.getOnlinePlayers().forEach(pl -> this.updateTaggedRegistry(pl)); + Bukkit.getOnlinePlayers().forEach(this::updateTaggedRegistry); + BUILT_RECIPES.forEach(Bukkit::addRecipe); + Bukkit.updateRecipes(); } public void updateTaggedRegistry(Player p) { @@ -78,7 +83,7 @@ public void updateTaggedRegistry(Player p) { if (recipeMapping.containsKey(p)) { recipeMapping.get(p).add(id); } else { - recipeMapping.put(p, new ArrayList<>(List.of(id))); + recipeMapping.put(p, new LinkedList<>(List.of(id))); } } } @@ -89,7 +94,7 @@ public void craft(@NotNull PrepareItemCraftEvent e) { String key = computeTag(e.getRecipe()); if (key != null) { updateTaggedRegistry((Player) e.getView().getPlayer()); - if (tags.contains(key) && !recipeMapping.getOrDefault(e.getView().getPlayer(), new ArrayList<>()).contains(key)) { + if (tags.contains(key) && !recipeMapping.getOrDefault(e.getView().getPlayer(), new LinkedList<>()).contains(key)) { e.getInventory().setResult(null); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ReplaceLootTablePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ReplaceLootTablePower.java similarity index 88% rename from origins/src/main/java/io/github/dueris/originspaper/power/ReplaceLootTablePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ReplaceLootTablePower.java index 4d96b6bf5..36d424db3 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ReplaceLootTablePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ReplaceLootTablePower.java @@ -1,9 +1,10 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; @@ -34,7 +35,7 @@ import org.bukkit.event.world.LootGenerateEvent; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; @@ -55,8 +56,8 @@ public ReplaceLootTablePower(@NotNull ResourceLocation key, @NotNull ResourceLoc this.itemCondition = itemCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("replace_loot_table")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("replace_loot_table")) .add("replace", ApoliDataTypes.REGEX_MAP) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("block_condition", ApoliDataTypes.BLOCK_CONDITION, null) @@ -67,7 +68,7 @@ public static SerializableData buildFactory() { public void inventoryPopulate(@NotNull LootGenerateEvent e) { if (e.getEntity() instanceof org.bukkit.entity.Player p && getPlayers().contains(((CraftPlayer) p).getHandle()) && isActive(((CraftPlayer) p).getHandle())) { e.setLoot(modifyLootTable( - new ArrayList<>(e.getLoot().stream().map(CraftItemStack::unwrap).toList()), + new LinkedList<>(e.getLoot().stream().map(CraftItemStack::unwrap).toList()), CraftNamespacedKey.toMinecraft(e.getLootTable().getKey()), ((CraftPlayer) p).getHandle().level(), e.getEntity().getLocation()).stream().map(ItemStack::getBukkitStack).toList()); } } @@ -82,7 +83,7 @@ public void dropEvent(@NotNull EntityDeathEvent e) { net.minecraft.world.entity.player.Player player = ((CraftPlayer) p).getHandle(); Entity entity = ((CraftEntity) e.getEntity()).getHandle(); if (getPlayers().contains(player) && isActive(player) && (bientityCondition == null || bientityCondition.test(new Tuple<>(player, entity)))) { - modifyLootTable(new ArrayList<>(e.getDrops().stream().map(CraftItemStack::unwrap).toList()), + modifyLootTable(new LinkedList<>(e.getDrops().stream().map(CraftItemStack::unwrap).toList()), CraftNamespacedKey.toMinecraft(k), player.level(), e.getEntity().getLocation()); } } @@ -94,7 +95,7 @@ public void blockDropEvent(@NotNull BlockDropItemEvent e) { net.minecraft.world.entity.player.Player player = ((CraftPlayer) e.getPlayer()).getHandle(); if (getPlayers().contains(player)) { String formattedKey = "minecraft:blocks/" + e.getBlockState().getType().getKey().getKey(); - List drops = new ArrayList<>(modifyLootTable(new ArrayList<>(e.getBlockState().getDrops().stream().map(CraftItemStack::unwrap).toList()), + List drops = new LinkedList<>(modifyLootTable(new LinkedList<>(e.getBlockState().getDrops().stream().map(CraftItemStack::unwrap).toList()), ResourceLocation.parse(formattedKey), player.level(), e.getBlock().getLocation())); if (!drops.isEmpty() && isActive(player) && (blockCondition == null || blockCondition.test(new BlockInWorld(player.level(), ((CraftBlock) e.getBlock()).getPosition(), false)))) { e.setCancelled(true); @@ -121,6 +122,6 @@ protected List modifyLootTable(List items, ResourceLocatio return items; } } - return new ArrayList<>(); + return new LinkedList<>(); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ResourceInterface.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ResourceInterface.java similarity index 54% rename from origins/src/main/java/io/github/dueris/originspaper/power/ResourceInterface.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ResourceInterface.java index fc720dbb9..c5ecefb98 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ResourceInterface.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ResourceInterface.java @@ -1,9 +1,12 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.originspaper.data.types.HudRender; +import net.kyori.adventure.text.TextComponent; public interface ResourceInterface { HudRender getHudRender(); + TextComponent name(); + String getTag(); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/type/ResourcePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ResourcePower.java new file mode 100644 index 000000000..2244451d4 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ResourcePower.java @@ -0,0 +1,192 @@ +package io.github.dueris.originspaper.power.type; + +import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.data.types.HudRender; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.util.LangFile; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.scores.ScoreHolder; +import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; +import org.bukkit.boss.BarStyle; +import org.bukkit.boss.KeyedBossBar; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; + +public class ResourcePower extends PowerType implements ResourceInterface { + protected final int min; + protected final int max; + protected final int startValue; + protected final ActionTypeFactory minAction; + protected final ActionTypeFactory maxAction; + protected final HudRender hudRender; + + private final Map players2Render = new ConcurrentHashMap<>(); + + public ResourcePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, + int min, int max, @NotNull Optional startValue, ActionTypeFactory minAction, ActionTypeFactory maxAction, HudRender hudRender) { + super(key, type, name, description, hidden, condition, loadingPriority); + this.min = min; + this.max = max; + this.startValue = startValue.orElse(min); + this.minAction = minAction; + this.maxAction = maxAction; + this.hudRender = hudRender; + } + + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("resource")) + .add("min", SerializableDataTypes.INT) + .add("max", SerializableDataTypes.INT) + .add("start_value", SerializableDataTypes.optional(SerializableDataTypes.INT), Optional.empty()) + .add("min_action", ApoliDataTypes.ENTITY_ACTION, null) + .add("max_action", ApoliDataTypes.ENTITY_ACTION, null) + .add("hud_render", ApoliDataTypes.HUD_RENDER, HudRender.DONT_RENDER); + } + + @Override + public void tick(Player player) { + cleanup(player); + BarRender render = players2Render.get(player); + render.setRendering(shouldRender(player) && isActive(player)); + } + + public BarRender getRender(ScoreHolder holder) { + if (holder instanceof Player player) { + cleanup(player); + } + return players2Render.get(holder); + } + + private void cleanup(Player player) { + if (!players2Render.containsKey(player)) { + players2Render.put(player, new BarRender(player, this)); + } + } + + @Override + public HudRender getHudRender() { + return hudRender; + } + + public boolean shouldRender(Entity entity) { + return hudRender.shouldRender(entity); + } + + public int getValue(ScoreHolder holder) { + return getRender(holder).getValue(); + } + + public void setValue(ScoreHolder holder, int newValue) { + getRender(holder).setValue(newValue); + } + + public static class BarRender { + private final ScoreHolder holder; + private final int maxValue; + private final int minValue; + private @Nullable + final ActionTypeFactory minAction; + private @Nullable + final ActionTypeFactory maxAction; + private boolean isRendering = false; + private @Nullable KeyedBossBar backboard; + private int currentTicks; + + BarRender(ScoreHolder holder, ResourcePower power) { + this(holder, power, power.max, power.startValue, power.min, power.minAction, power.maxAction); + } + + BarRender(ScoreHolder holder, @NotNull ResourceInterface resourceInterface, int maxValue, int startValue, int minValue, @Nullable ActionTypeFactory minAction, @Nullable ActionTypeFactory maxAction) { + this.holder = holder; + this.maxValue = maxValue; + this.minValue = minValue; + this.minAction = minAction; + this.maxAction = maxAction; + this.currentTicks = startValue; + + if (resourceInterface.getHudRender() != null && resourceInterface.getHudRender().shouldRender()) { + this.backboard = Bukkit.createBossBar( + Objects.requireNonNull(NamespacedKey.fromString(resourceInterface.getTag())), LangFile.translatable(PlainTextComponentSerializer.plainText().serialize(resourceInterface.name())).getString(), resourceInterface.getHudRender().render().renderColor(), BarStyle.SEGMENTED_6 + ); + this.backboard.setProgress(0); + } + } + + public boolean isRendering() { + return isRendering; + } + + public void setRendering(boolean render) { + isRendering = render; + + if (backboard != null) { + if (holder instanceof ServerPlayer player) { + backboard.addPlayer(player.getBukkitEntity()); + } + backboard.setVisible(isRendering); + } + } + + public int getValue() { + return currentTicks; + } + + /** + * @param value IS IN TICKS, DO NOT USE RENDERED PROGRESS FOR INTERACTING WITH API + */ + public void setValue(int value) { + this.currentTicks = value; + double d = ((double) currentTicks / maxValue); + if (getBackboard() != null) { + getBackboard().setProgress((d > 1) ? 1 : ((d < 0) ? 0 : d)); + } + + if (currentTicks >= maxValue) { + currentTicks = maxValue; + if (holder instanceof Entity entity && maxAction != null) { + maxAction.accept(entity); + } + } + + if (currentTicks <= minValue) { + currentTicks = minValue; + if (holder instanceof Entity entity && minAction != null) { + minAction.accept(entity); + } + } + } + + @Nullable + KeyedBossBar getBackboard() { + return backboard; + } + + public void destroy() { + this.setRendering(false); + if (getBackboard() != null) { + for (org.bukkit.entity.Player player : getBackboard().getPlayers()) { + getBackboard().removePlayer(player); + } + + Bukkit.removeBossBar(getBackboard().getKey()); + } + } + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/SelfActionOnHitPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/SelfActionOnHitPower.java similarity index 75% rename from origins/src/main/java/io/github/dueris/originspaper/power/SelfActionOnHitPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/SelfActionOnHitPower.java index c1e398175..a121891bc 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/SelfActionOnHitPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/SelfActionOnHitPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -19,25 +20,21 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.jetbrains.annotations.NotNull; -public class SelfActionOnHitPower extends PowerType implements CooldownInterface { +public class SelfActionOnHitPower extends CooldownPower { private final ActionTypeFactory entityAction; private final ConditionTypeFactory targetCondition; private final ConditionTypeFactory> damageCondition; - private final HudRender hudRender; - private final int cooldown; public SelfActionOnHitPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory entityAction, ConditionTypeFactory targetCondition, ConditionTypeFactory> damageCondition, HudRender hudRender, int cooldown) { - super(key, type, name, description, hidden, condition, loadingPriority); + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.entityAction = entityAction; this.targetCondition = targetCondition; this.damageCondition = damageCondition; - this.hudRender = hudRender; - this.cooldown = cooldown; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("self_action_on_hit")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("self_action_on_hit")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION) .add("target_condition", ApoliDataTypes.ENTITY_CONDITION, null) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION, null) @@ -46,7 +43,7 @@ public static SerializableData buildFactory() { } public boolean doesApply(Entity target, @NotNull Entity entity, DamageSource source, float amount) { - return !CooldownPower.isInCooldown(entity.getBukkitEntity(), this) + return canUse(entity) && (targetCondition == null || targetCondition.test(target)) && (damageCondition == null || damageCondition.test(new Tuple<>(source, amount))); } @@ -65,17 +62,8 @@ public void onHit(@NotNull EntityDamageByEntityEvent e) { } public void onHit(@NotNull Entity entity) { - CooldownPower.addCooldown(entity.getBukkitEntity(), this); + use(entity); this.entityAction.accept(entity); } - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/SelfActionOnKillPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/SelfActionOnKillPower.java similarity index 77% rename from origins/src/main/java/io/github/dueris/originspaper/power/SelfActionOnKillPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/SelfActionOnKillPower.java index 2c7f41222..3dec6d05e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/SelfActionOnKillPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/SelfActionOnKillPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -22,25 +23,21 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.jetbrains.annotations.NotNull; -public class SelfActionOnKillPower extends PowerType implements CooldownInterface { +public class SelfActionOnKillPower extends CooldownPower { private final ActionTypeFactory entityAction; private final ConditionTypeFactory targetCondition; private final ConditionTypeFactory> damageCondition; - private final HudRender hudRender; - private final int cooldown; public SelfActionOnKillPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory entityAction, ConditionTypeFactory targetCondition, ConditionTypeFactory> damageCondition, HudRender hudRender, int cooldown) { - super(key, type, name, description, hidden, condition, loadingPriority); + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.entityAction = entityAction; this.targetCondition = targetCondition; this.damageCondition = damageCondition; - this.hudRender = hudRender; - this.cooldown = cooldown; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("self_action_on_kill")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("self_action_on_kill")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION) .add("target_condition", ApoliDataTypes.ENTITY_CONDITION, null) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION, null) @@ -49,13 +46,13 @@ public static SerializableData buildFactory() { } public boolean doesApply(Entity target, @NotNull Entity entity, DamageSource source, float amount) { - return !CooldownPower.isInCooldown(entity.getBukkitEntity(), this) + return canUse(entity) && (targetCondition == null || targetCondition.test(target)) && (damageCondition == null || damageCondition.test(new Tuple<>(source, amount))); } public void executeAction(@NotNull Entity entity) { - CooldownPower.addCooldown(entity.getBukkitEntity(), this); + use(entity); entityAction.accept(entity); } @@ -74,13 +71,4 @@ public void onDamage(@NotNull EntityDamageByEntityEvent e) { } } - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/SelfActionWhenHitPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/SelfActionWhenHitPower.java similarity index 72% rename from origins/src/main/java/io/github/dueris/originspaper/power/SelfActionWhenHitPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/SelfActionWhenHitPower.java index fce9e5d08..54d0aa3f3 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/SelfActionWhenHitPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/SelfActionWhenHitPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -19,23 +20,19 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.jetbrains.annotations.NotNull; -public class SelfActionWhenHitPower extends PowerType implements CooldownInterface { +public class SelfActionWhenHitPower extends CooldownPower { private final ActionTypeFactory entityAction; private final ConditionTypeFactory> damageCondition; - private final HudRender hudRender; - private final int cooldown; public SelfActionWhenHitPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory entityAction, ConditionTypeFactory> damageCondition, HudRender hudRender, int cooldown) { - super(key, type, name, description, hidden, condition, loadingPriority); + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.entityAction = entityAction; this.damageCondition = damageCondition; - this.hudRender = hudRender; - this.cooldown = cooldown; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("self_action_when_hit")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("self_action_when_hit")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION, null) .add("hud_render", ApoliDataTypes.HUD_RENDER, HudRender.DONT_RENDER) @@ -43,12 +40,12 @@ public static SerializableData buildFactory() { } public boolean doesApply(@NotNull Entity entity, DamageSource source, float amount) { - return !CooldownPower.isInCooldown(entity.getBukkitEntity(), this) + return canUse(entity) && (damageCondition == null || damageCondition.test(new Tuple<>(source, amount))); } public void whenHit(@NotNull Entity entity) { - CooldownPower.addCooldown(entity.getBukkitEntity(), this); + use(entity); this.entityAction.accept(entity); } @@ -62,13 +59,4 @@ public void onDamage(@NotNull EntityDamageEvent e) { } } - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/SelfGlowPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/SelfGlowPower.java similarity index 85% rename from origins/src/main/java/io/github/dueris/originspaper/power/SelfGlowPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/SelfGlowPower.java index 18f1f7410..dfffd7556 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/SelfGlowPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/SelfGlowPower.java @@ -1,11 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Shape; +import io.github.dueris.originspaper.plugin.OriginsPlugin; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.entity.GlowingEntitiesUtils; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -20,7 +22,7 @@ import java.awt.*; import java.util.Set; -import static io.github.dueris.originspaper.power.EntityGlowPower.translateBarColor; +import static io.github.dueris.originspaper.power.type.EntityGlowPower.translateBarColor; public class SelfGlowPower extends PowerType { private final ConditionTypeFactory entityCondition; @@ -41,8 +43,8 @@ public SelfGlowPower(@NotNull ResourceLocation key, @NotNull ResourceLocation ty this.b = b; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("self_glow")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("self_glow")) .add("entity_condition", ApoliDataTypes.ENTITY_CONDITION, null) .add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) .add("use_teams", SerializableDataTypes.BOOLEAN, true) @@ -56,7 +58,7 @@ public void tick(@NotNull Player player) { ServerLevel level = (ServerLevel) player.level(); Set entities = Shape.getEntities(Shape.SPHERE, level, player.position(), 60); entities.add(player); - GlowingEntitiesUtils utils = OriginsPaper.glowingEntitiesUtils; + GlowingEntitiesUtils utils = OriginsPlugin.glowingEntitiesUtils; try { if (isActive(player)) { for (Entity entity : entities) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/SimpleStatusEffectPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/SimpleStatusEffectPower.java similarity index 80% rename from origins/src/main/java/io/github/dueris/originspaper/power/SimpleStatusEffectPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/SimpleStatusEffectPower.java index b97a36389..3edb169ba 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/SimpleStatusEffectPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/SimpleStatusEffectPower.java @@ -1,6 +1,6 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/SprintingPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/SprintingPower.java similarity index 68% rename from origins/src/main/java/io/github/dueris/originspaper/power/SprintingPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/SprintingPower.java index 4a734f8e6..4e3807703 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/SprintingPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/SprintingPower.java @@ -1,8 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -17,8 +18,8 @@ public SprintingPower(@NotNull ResourceLocation key, @NotNull ResourceLocation t super(key, type, name, description, hidden, condition, loadingPriority); } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("sprinting")); + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("sprinting")); } @Override diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/StackingStatusEffectPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/StackingStatusEffectPower.java similarity index 85% rename from origins/src/main/java/io/github/dueris/originspaper/power/StackingStatusEffectPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/StackingStatusEffectPower.java index 694d9d355..7e477f146 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/StackingStatusEffectPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/StackingStatusEffectPower.java @@ -1,10 +1,11 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffectInstance; @@ -41,8 +42,8 @@ public StackingStatusEffectPower(@NotNull ResourceLocation key, @NotNull Resourc } } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("stacking_status_effect")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("stacking_status_effect")) .add("min_stacks", SerializableDataTypes.INT) .add("max_stacks", SerializableDataTypes.INT) .add("duration_per_stack", SerializableDataTypes.INT) @@ -77,7 +78,7 @@ public void tick(@NotNull Player entity) { } @Override - public void applyEffects(LivingEntity entity, int currentStack) { + public void applyEffects(@NotNull LivingEntity entity, int currentStack) { effects.forEach(sei -> { int duration = durationPerStack * currentStack; if (duration > 0) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/StartingEquipmentPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/StartingEquipmentPower.java similarity index 89% rename from origins/src/main/java/io/github/dueris/originspaper/power/StartingEquipmentPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/StartingEquipmentPower.java index ae5757c34..16773584d 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/StartingEquipmentPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/StartingEquipmentPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent; import io.github.dueris.calio.SerializableDataTypes; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.data.SerializableDataBuilder; -import io.github.dueris.calio.parser.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -63,8 +64,8 @@ public StartingEquipmentPower(@NotNull ResourceLocation key, @NotNull ResourceLo } } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("starting_equipment")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("starting_equipment")) .add("stack", ApoliDataTypes.POSITIONED_ITEM_STACK, null) .add("stacks", SerializableDataBuilder.of(ApoliDataTypes.POSITIONED_ITEM_STACK.listOf()), null) .add("recurrent", SerializableDataTypes.BOOLEAN, false); diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/StatusEffectPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/StatusEffectPower.java similarity index 88% rename from origins/src/main/java/io/github/dueris/originspaper/power/StatusEffectPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/StatusEffectPower.java index 13a19d372..8513ccb4a 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/StatusEffectPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/StatusEffectPower.java @@ -1,6 +1,7 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/TargetActionOnHitPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/TargetActionOnHitPower.java similarity index 74% rename from origins/src/main/java/io/github/dueris/originspaper/power/TargetActionOnHitPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/TargetActionOnHitPower.java index f2a6f18bf..3f2db2d29 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/TargetActionOnHitPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/TargetActionOnHitPower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.HudRender; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; @@ -19,25 +20,21 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.jetbrains.annotations.NotNull; -public class TargetActionOnHitPower extends PowerType implements CooldownInterface { +public class TargetActionOnHitPower extends CooldownPower { private final ActionTypeFactory entityAction; private final ConditionTypeFactory> damageCondition; - private final int cooldown; - private final HudRender hudRender; private final ConditionTypeFactory targetCondition; public TargetActionOnHitPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, ActionTypeFactory entityAction, ConditionTypeFactory> damageCondition, int cooldown, HudRender hudRender, ConditionTypeFactory targetCondition) { - super(key, type, name, description, hidden, condition, loadingPriority); + super(key, type, name, description, hidden, condition, loadingPriority, hudRender, cooldown); this.entityAction = entityAction; this.damageCondition = damageCondition; - this.cooldown = cooldown; - this.hudRender = hudRender; this.targetCondition = targetCondition; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("target_action_on_hit")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("target_action_on_hit")) .add("entity_action", ApoliDataTypes.ENTITY_ACTION) .add("damage_condition", ApoliDataTypes.DAMAGE_CONDITION, null) .add("cooldown", SerializableDataTypes.INT, 1) @@ -46,14 +43,13 @@ public static SerializableData buildFactory() { } public boolean doesApply(Entity target, @NotNull Entity entity, DamageSource source, float amount) { - return !CooldownPower.isInCooldown(entity.getBukkitEntity(), this) - && (targetCondition == null || targetCondition.test(target)) + return canUse(entity) && (targetCondition == null || targetCondition.test(target)) && (damageCondition == null || damageCondition.test(new Tuple<>(source, amount))); } public void onHit(Entity target, @NotNull Entity entity) { this.entityAction.accept(target); - CooldownPower.addCooldown(entity.getBukkitEntity(), this); + use(entity); } @EventHandler @@ -69,13 +65,4 @@ public void onHit(@NotNull EntityDamageByEntityEvent e) { } } - @Override - public int getCooldown() { - return cooldown; - } - - @Override - public HudRender getHudRender() { - return hudRender; - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/ToggleNightVisionPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/ToggleNightVisionPower.java similarity index 84% rename from origins/src/main/java/io/github/dueris/originspaper/power/ToggleNightVisionPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/ToggleNightVisionPower.java index c301ea0b6..e62ae972a 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/ToggleNightVisionPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/ToggleNightVisionPower.java @@ -1,9 +1,9 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Keybind; import io.github.dueris.originspaper.event.KeybindTriggerEvent; @@ -16,8 +16,8 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -26,7 +26,7 @@ public class ToggleNightVisionPower extends NightVisionPower { private final boolean activeByDefault; private final Map playerToggledStates = new HashMap<>(); - private final List TICKED = new ArrayList<>(); + private final List TICKED = new LinkedList<>(); public ToggleNightVisionPower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, float strength, boolean activeByDefault, Keybind keybind) { @@ -35,8 +35,8 @@ public ToggleNightVisionPower(@NotNull ResourceLocation key, @NotNull ResourceLo this.keybind = keybind; } - public static SerializableData buildFactory() { - return NightVisionPower.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("toggle_night_vision")) + public static SerializableData getFactory() { + return NightVisionPower.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("toggle_night_vision")) .add("active_by_default", SerializableDataTypes.BOOLEAN, false) .add("key", ApoliDataTypes.KEYBIND, Keybind.DEFAULT_KEYBIND); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/TogglePower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/TogglePower.java similarity index 85% rename from origins/src/main/java/io/github/dueris/originspaper/power/TogglePower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/TogglePower.java index 2361214fb..be5927469 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/TogglePower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/TogglePower.java @@ -1,12 +1,13 @@ -package io.github.dueris.originspaper.power; +package io.github.dueris.originspaper.power.type; import io.github.dueris.calio.SerializableDataTypes; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.ApoliDataTypes; import io.github.dueris.originspaper.data.types.Keybind; import io.github.dueris.originspaper.event.KeybindTriggerEvent; +import io.github.dueris.originspaper.power.factory.PowerType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -16,8 +17,8 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -27,7 +28,7 @@ public class TogglePower extends PowerType { private final boolean activeByDefault; private final Map playerToggledStates = new HashMap<>(); - private final List TICKED = new ArrayList<>(); + private final List TICKED = new LinkedList<>(); public TogglePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type, Component name, Component description, boolean hidden, ConditionTypeFactory condition, int loadingPriority, boolean activeByDefault, boolean retainState, Keybind keybind) { @@ -37,8 +38,8 @@ public TogglePower(@NotNull ResourceLocation key, @NotNull ResourceLocation type this.keybind = keybind; } - public static SerializableData buildFactory() { - return PowerType.buildFactory().typedRegistry(OriginsPaper.apoliIdentifier("toggle")) + public static SerializableData getFactory() { + return PowerType.getFactory().typedRegistry(OriginsPaper.apoliIdentifier("toggle")) .add("active_by_default", SerializableDataTypes.BOOLEAN, true) .add("retain_state", SerializableDataTypes.BOOLEAN, true) .add("key", ApoliDataTypes.KEYBIND, Keybind.DEFAULT_KEYBIND); diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/origins/LikeWaterPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/simple/LikeWaterPower.java similarity index 95% rename from origins/src/main/java/io/github/dueris/originspaper/power/origins/LikeWaterPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/simple/LikeWaterPower.java index 0e6a42c0e..869f372b8 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/origins/LikeWaterPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/simple/LikeWaterPower.java @@ -1,4 +1,4 @@ -package io.github.dueris.originspaper.power.origins; +package io.github.dueris.originspaper.power.type.simple; import io.github.dueris.originspaper.OriginsPaper; import io.github.dueris.originspaper.storage.PowerHolderComponent; diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/origins/ScareCreepersPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/simple/ScareCreepersPower.java similarity index 96% rename from origins/src/main/java/io/github/dueris/originspaper/power/origins/ScareCreepersPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/simple/ScareCreepersPower.java index 876aa9935..1b80ab396 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/origins/ScareCreepersPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/simple/ScareCreepersPower.java @@ -1,4 +1,4 @@ -package io.github.dueris.originspaper.power.origins; +package io.github.dueris.originspaper.power.type.simple; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.world.entity.EntitySelector; diff --git a/origins/src/main/java/io/github/dueris/originspaper/power/origins/WaterBreathingPower.java b/origins/src/main/java/io/github/dueris/originspaper/power/type/simple/WaterBreathingPower.java similarity index 92% rename from origins/src/main/java/io/github/dueris/originspaper/power/origins/WaterBreathingPower.java rename to origins/src/main/java/io/github/dueris/originspaper/power/type/simple/WaterBreathingPower.java index 43c5dff2a..c2c117657 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/power/origins/WaterBreathingPower.java +++ b/origins/src/main/java/io/github/dueris/originspaper/power/type/simple/WaterBreathingPower.java @@ -1,4 +1,4 @@ -package io.github.dueris.originspaper.power.origins; +package io.github.dueris.originspaper.power.type.simple; import io.github.dueris.originspaper.OriginsPaper; import io.github.dueris.originspaper.storage.PowerHolderComponent; @@ -10,6 +10,7 @@ import net.minecraft.world.damagesource.DamageType; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.LivingEntity; +import org.bukkit.craftbukkit.CraftRegistry; import org.jetbrains.annotations.NotNull; import java.lang.reflect.InvocationTargetException; @@ -63,7 +64,7 @@ public static void tick(@NotNull LivingEntity entity) { } entity.setAirSupply(0); - entity.hurt(Util.getDamageSource(Util.DAMAGE_REGISTRY.get(NO_WATER_FOR_GILLS)), 2.0F); + entity.hurt(Util.getDamageSource(CraftRegistry.getMinecraftRegistry().registryOrThrow(Registries.DAMAGE_TYPE).get(NO_WATER_FOR_GILLS)), 2.0F); for (int i = 0; i < 8; ++i) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/registry/BuiltinRegistry.java b/origins/src/main/java/io/github/dueris/originspaper/registry/BuiltinRegistry.java index 463c94ce2..1a79ecb15 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/registry/BuiltinRegistry.java +++ b/origins/src/main/java/io/github/dueris/originspaper/registry/BuiltinRegistry.java @@ -20,11 +20,11 @@ public class BuiltinRegistry { public static void bootstrap() { for (OriginLayer layer : builtinLayers) { - OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).register(layer, ResourceLocation.parse("apoli:command")); + OriginsPaper.getRegistry().retrieve(Registries.LAYER).register(layer, ResourceLocation.parse("apoli:command")); } - OriginsPaper.EMPTY_ORIGIN = new Origin( + Origin.EMPTY = new Origin( ResourceLocation.parse("origins:empty"), List.of(), new ItemStack(Items.AIR), true, Integer.MAX_VALUE, Impact.NONE, 0, null, net.minecraft.network.chat.Component.empty(), net.minecraft.network.chat.Component.empty() ); - OriginsPaper.getPlugin().registry.retrieve(Registries.ORIGIN).register(OriginsPaper.EMPTY_ORIGIN, ResourceLocation.parse("origins:empty")); + OriginsPaper.getRegistry().retrieve(Registries.ORIGIN).register(Origin.EMPTY, ResourceLocation.parse("origins:empty")); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/registry/Registries.java b/origins/src/main/java/io/github/dueris/originspaper/registry/Registries.java index c18f683b3..822bca627 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/registry/Registries.java +++ b/origins/src/main/java/io/github/dueris/originspaper/registry/Registries.java @@ -2,15 +2,17 @@ import io.github.dueris.calio.registry.RegistryKey; import io.github.dueris.calio.util.Util; -import io.github.dueris.originspaper.action.ActionTypeFactory; -import io.github.dueris.originspaper.condition.ConditionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; +import io.github.dueris.originspaper.condition.factory.ConditionTypeFactory; import io.github.dueris.originspaper.data.types.modifier.IModifierOperation; import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; -import io.github.dueris.originspaper.power.PowerType; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.screen.ChoosingPage; import io.github.dueris.originspaper.util.LangFile; -import net.minecraft.core.*; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Holder; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraft.world.damagesource.DamageSource; @@ -28,7 +30,7 @@ public class Registries { public static final RegistryKey ORIGIN = new RegistryKey<>(Origin.class, apoliIdentifier("origin")); public static final RegistryKey LAYER = new RegistryKey<>(OriginLayer.class, apoliIdentifier("layer")); - public static final RegistryKey CRAFT_POWER = new RegistryKey<>(PowerType.class, apoliIdentifier("craft_power")); + public static final RegistryKey POWER = new RegistryKey<>(PowerType.class, apoliIdentifier("craft_power")); public static final RegistryKey> FLUID_CONDITION = new RegistryKey<>(Util.castClass(ConditionTypeFactory.class), apoliIdentifier("fluid_condition")); public static final RegistryKey>> ITEM_CONDITION = new RegistryKey<>(Util.castClass(ConditionTypeFactory.class), apoliIdentifier("item_condition")); @@ -36,7 +38,7 @@ public class Registries { public static final RegistryKey>> DAMAGE_CONDITION = new RegistryKey<>(Util.castClass(ConditionTypeFactory.class), apoliIdentifier("damage_condition")); public static final RegistryKey>> BIENTITY_CONDITION = new RegistryKey<>(Util.castClass(ConditionTypeFactory.class), apoliIdentifier("bientity_condition")); public static final RegistryKey> BLOCK_CONDITION = new RegistryKey<>(Util.castClass(ConditionTypeFactory.class), apoliIdentifier("block_condition")); - public static final RegistryKey>> BIOME_CONDITION = new RegistryKey<>(Util.castClass(ConditionTypeFactory.class), apoliIdentifier("biome_condition")); + public static final RegistryKey>>> BIOME_CONDITION = new RegistryKey<>(Util.castClass(ConditionTypeFactory.class), apoliIdentifier("biome_condition")); public static final RegistryKey>> ITEM_ACTION = new RegistryKey<>(Util.castClass(ActionTypeFactory.class), apoliIdentifier("item_action")); public static final RegistryKey> ENTITY_ACTION = new RegistryKey<>(Util.castClass(ActionTypeFactory.class), apoliIdentifier("entity_action")); diff --git a/origins/src/main/java/io/github/dueris/originspaper/registry/nms/OriginLootCondition.java b/origins/src/main/java/io/github/dueris/originspaper/registry/nms/OriginLootCondition.java index 813e549bb..a140ab3e4 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/registry/nms/OriginLootCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/registry/nms/OriginLootCondition.java @@ -6,7 +6,7 @@ import io.github.dueris.originspaper.OriginsPaper; import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.storage.OriginComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.storage.loot.LootContext; @@ -39,8 +39,8 @@ public boolean test(LootContext context) { Entity entity = context.getParam(LootContextParams.THIS_ENTITY); CraftEntity var4 = entity.getBukkitEntity(); if (var4 instanceof Player player) { - Origin origin = OriginsPaper.getPlugin().registry.retrieve(Registries.ORIGIN).get(this.originId); - return PowerHolderComponent.hasOrigin(player, origin.getTag()); + Origin origin = OriginsPaper.getRegistry().retrieve(Registries.ORIGIN).get(this.originId); + return OriginComponent.hasOrigin(player, origin.getTag()); } else { return false; } diff --git a/origins/src/main/java/io/github/dueris/originspaper/registry/nms/PowerLootCondition.java b/origins/src/main/java/io/github/dueris/originspaper/registry/nms/PowerLootCondition.java index e68126cba..f7167b15f 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/registry/nms/PowerLootCondition.java +++ b/origins/src/main/java/io/github/dueris/originspaper/registry/nms/PowerLootCondition.java @@ -4,7 +4,7 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.power.PowerType; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.registry.Registries; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.resources.ResourceLocation; @@ -38,7 +38,7 @@ public boolean test(LootContext context) { Entity entity = context.getParam(LootContextParams.THIS_ENTITY); CraftEntity var4 = entity.getBukkitEntity(); if (var4 instanceof Player player) { - PowerType power = OriginsPaper.getPlugin().registry.retrieve(Registries.CRAFT_POWER).get(this.powerId); + PowerType power = OriginsPaper.getRegistry().retrieve(Registries.POWER).get(this.powerId); return PowerHolderComponent.hasPower(player, power.getTag()); } else { return false; diff --git a/origins/src/main/java/io/github/dueris/originspaper/screen/ChoosingPage.java b/origins/src/main/java/io/github/dueris/originspaper/screen/ChoosingPage.java index dcad446d0..dd8fa743c 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/screen/ChoosingPage.java +++ b/origins/src/main/java/io/github/dueris/originspaper/screen/ChoosingPage.java @@ -8,29 +8,28 @@ import net.minecraft.world.entity.player.Player; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; import java.util.Comparator; +import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; public interface ChoosingPage { static void registerInstances() { - OriginsPaper.getPlugin() - .registry + OriginsPaper.getRegistry() .retrieve(Registries.LAYER) .values() .stream() .filter(OriginLayer::isEnabled) .forEach( layer -> { - ScreenNavigator.layerPages.put(layer, new ArrayList<>()); + ScreenNavigator.layerPages.put(layer, new LinkedList<>()); List choosable = layer.getOriginIdentifiers() .stream() .map(OriginsPaper::getOrigin) .filter(origin -> !origin.unchoosable()) .sorted(Comparator.comparingInt(Origin::order)) .sorted(Comparator.comparingInt(Origin::impactValue)) - .collect(Collectors.toCollection(ArrayList::new)); + .collect(Collectors.toCollection(LinkedList::new)); Origin defaultOrigin = null; if (layer.getDefaultOrigin() != null && !layer.getDefaultOrigin().toString().equalsIgnoreCase("origins:empty")) { defaultOrigin = choosable.stream() @@ -49,7 +48,7 @@ static void registerInstances() { ); ScreenNavigator.layerPages.values().forEach(list -> { for (ChoosingPage page : list) { - OriginsPaper.getPlugin().registry.retrieve(Registries.CHOOSING_PAGE).register(page, page.key()); + OriginsPaper.getRegistry().retrieve(Registries.CHOOSING_PAGE).register(page, page.key()); } }); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/screen/GuiTicker.java b/origins/src/main/java/io/github/dueris/originspaper/screen/GuiTicker.java index 80b0e0d79..b34151530 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/screen/GuiTicker.java +++ b/origins/src/main/java/io/github/dueris/originspaper/screen/GuiTicker.java @@ -4,30 +4,28 @@ import io.github.dueris.originspaper.event.OriginChoosePromptEvent; import io.github.dueris.originspaper.origin.OriginLayer; import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.storage.OriginComponent; import org.bukkit.Bukkit; import org.bukkit.NamespacedKey; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import static io.github.dueris.originspaper.screen.ScreenNavigator.inChoosingLayer; -public class GuiTicker extends BukkitRunnable { - public static List delayedPlayers = new ArrayList<>(); +public class GuiTicker { + public static List delayedPlayers = new LinkedList<>(); - @Override - public void run() { + public static void tick() { if (ScreenNavigator.layerPages.isEmpty()) return; // No pages to display. for (Player p : Bukkit.getOnlinePlayers()) { if (delayedPlayers.contains(p)) continue; - for (OriginLayer layer : OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).values().stream().filter(OriginLayer::isEnabled).toList()) { + for (OriginLayer layer : OriginsPaper.getRegistry().retrieve(Registries.LAYER).values().stream().filter(OriginLayer::isEnabled).toList()) { if (layer.testChoosable(((CraftPlayer) p).getHandle()).isEmpty()) continue; try { - if (PowerHolderComponent.getOrigin(p, layer).getTag().equalsIgnoreCase("origins:empty")) { + if (OriginComponent.getOrigin(p, layer).getTag().equalsIgnoreCase("origins:empty")) { if (layer.testDefaultOrigin(((CraftPlayer) p).getHandle())) continue; if (!inChoosingLayer.containsKey(((CraftPlayer) p).getHandle())) { OriginChoosePromptEvent event = new OriginChoosePromptEvent(p); diff --git a/origins/src/main/java/io/github/dueris/originspaper/screen/OriginPage.java b/origins/src/main/java/io/github/dueris/originspaper/screen/OriginPage.java index 7b54e4580..518274b4d 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/screen/OriginPage.java +++ b/origins/src/main/java/io/github/dueris/originspaper/screen/OriginPage.java @@ -5,8 +5,9 @@ import io.github.dueris.originspaper.data.types.Impact; import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; -import io.github.dueris.originspaper.power.ModifyPlayerSpawnPower; -import io.github.dueris.originspaper.power.PowerType; +import io.github.dueris.originspaper.power.type.ModifyPlayerSpawnPower; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.storage.OriginComponent; import io.github.dueris.originspaper.storage.PowerHolderComponent; import io.github.dueris.originspaper.util.ComponentUtil; import io.github.dueris.originspaper.util.LangFile; @@ -30,8 +31,8 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.Arrays; +import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -69,7 +70,7 @@ public static void setAttributesToDefault(net.minecraft.world.entity.player.@Not } if (lore != null) { - itemMeta.lore(cutStringIntoLines(lore).stream().map(OriginPage::noItalic).toList()); + itemMeta.lore(cutStringIntoLines(net.minecraft.network.chat.Component.literal(lore)).stream().map(OriginPage::noItalic).toList()); } item.setItemMeta(itemMeta); @@ -82,8 +83,9 @@ public static void setAttributesToDefault(net.minecraft.world.entity.player.@Not .color(NamedTextColor.GRAY); } - public static List cutStringIntoLines(@NotNull String string) { - ArrayList strings = new ArrayList<>(); + public static List cutStringIntoLines(@NotNull net.minecraft.network.chat.Component component) { + String string = component.getString(); + LinkedList strings = new LinkedList<>(); int startStringLength = string.length(); while (string.length() > 40) { @@ -114,13 +116,13 @@ public int getOrder() { @Override public @NotNull ResourceLocation key() { - return ResourceLocation.parse(this.origin.key() + "_page"); + return ResourceLocation.parse(this.origin.getId() + "_page"); } @Override public ItemStack @NotNull [] createDisplay(net.minecraft.world.entity.player.Player player, OriginLayer layer) { - List stacks = new ArrayList<>(); - List powerContainers = new ArrayList<>(this.origin.powers().stream() + List stacks = new LinkedList<>(); + List powerContainers = new LinkedList<>(this.origin.powers().stream() .filter(Objects::nonNull).map(OriginsPaper::getPower).filter(p -> p != null && !p.isHidden()).toList()); for (int i = 0; i < 54; i++) { @@ -174,9 +176,9 @@ public int getOrder() { if (!powerContainers.isEmpty()) { ItemStack originPower = new ItemStack(Material.FILLED_MAP); ItemMeta meta = originPower.getItemMeta(); - meta.displayName(ComponentUtil.stringToComponent(LangFile.transform(PlainTextComponentSerializer.plainText().serialize(powerContainers.get(0).name()))).decoration(TextDecoration.ITALIC, false)); + meta.displayName(ComponentUtil.nmsToKyori(LangFile.translatable(PlainTextComponentSerializer.plainText().serialize(powerContainers.get(0).name()))).decoration(TextDecoration.ITALIC, false)); Arrays.stream(ItemFlag.values()).toList().forEach(originPower::addItemFlags); - List lore = cutStringIntoLines(LangFile.transform(PlainTextComponentSerializer.plainText().serialize(powerContainers.get(0).description()))).stream().map(OriginPage::noItalic).toList(); + List lore = cutStringIntoLines(LangFile.translatable(PlainTextComponentSerializer.plainText().serialize(powerContainers.get(0).description()))).stream().map(OriginPage::noItalic).toList(); meta.lore(lore); originPower.setItemMeta(meta); Arrays.stream(ItemFlag.values()).toList().forEach(originPower::addItemFlags); @@ -212,14 +214,14 @@ public int getOrder() { originIcon.setItemMeta(skull_p); } - return itemProperties(originIcon, this.origin.name() + return itemProperties(originIcon, this.origin.getName() .decoration(TextDecoration.ITALIC, false) - .color(NamedTextColor.WHITE), ItemFlag.values(), null, PlainTextComponentSerializer.plainText().serialize(this.origin.description())); + .color(NamedTextColor.WHITE), ItemFlag.values(), null, PlainTextComponentSerializer.plainText().serialize(this.origin.getDescription())); } @Override public void onChoose(net.minecraft.world.entity.player.@NotNull Player player, OriginLayer layer) { - PowerHolderComponent.setOrigin(player.getBukkitEntity(), layer, this.origin); + OriginComponent.setOrigin(player.getBukkitEntity(), layer, this.origin); player.getBukkitEntity().getOpenInventory().close(); final Player bukkitEntity = (Player) player.getBukkitEntity(); if (PlayerManager.firstJoin.contains(bukkitEntity)) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/screen/RandomOriginPage.java b/origins/src/main/java/io/github/dueris/originspaper/screen/RandomOriginPage.java index 762af9dd6..9abf58680 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/screen/RandomOriginPage.java +++ b/origins/src/main/java/io/github/dueris/originspaper/screen/RandomOriginPage.java @@ -5,7 +5,7 @@ import io.github.dueris.originspaper.event.OriginChangeEvent; import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; -import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.storage.OriginComponent; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.TextComponent; @@ -27,16 +27,16 @@ public class RandomOriginPage implements ChoosingPage { @Override public ItemStack[] createDisplay(Player player, @NotNull OriginLayer layer) { - List stacks = new ArrayList<>(); - List randomOrigins = new ArrayList<>(layer.getRandomOrigins()); + List stacks = new LinkedList<>(); + List randomOrigins = new LinkedList<>(layer.getRandomOrigins()); randomOrigins.sort(Comparator.comparingInt(Origin::impactValue).thenComparingInt(Origin::order)); - List> texts = new ArrayList<>(); + List> texts = new LinkedList<>(); int batchSize = 12; for (int i = 0; i < randomOrigins.size(); i += batchSize) { int endIndex = Math.min(i + batchSize, randomOrigins.size()); List sublist = randomOrigins.subList(i, endIndex); - texts.add(new ArrayList<>(sublist)); + texts.add(new LinkedList<>(sublist)); } int iE = 1; @@ -57,7 +57,7 @@ public ItemStack[] createDisplay(Player player, @NotNull OriginLayer layer) { Arrays.stream(ItemFlag.values()).toList().forEach(xva$0 -> blank.addItemFlags(xva$0)); stacks.add(blank); } else { - List cL = texts.get(0).stream().map(Origin::name).toList(); + List cL = texts.get(0).stream().map(Origin::getName).toList(); texts.remove(0); ItemStack stack = new ItemStack(Material.FILLED_MAP); stack.lore(cL); @@ -100,7 +100,7 @@ public ItemStack getChoosingStack(Player player) { public void onChoose(@NotNull Player player, @NotNull OriginLayer layer) { int r = this.random.nextInt(layer.getRandomOrigins().size()); Origin origin = layer.getRandomOrigins().get(Math.max(r, 1)); - PowerHolderComponent.setOrigin(player.getBukkitEntity(), layer, origin); + OriginComponent.setOrigin(player.getBukkitEntity(), layer, origin); OriginChangeEvent e = new OriginChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), origin, layer, ScreenNavigator.orbChoosing.contains(player)); Bukkit.getPluginManager().callEvent(e); player.getBukkitEntity().getOpenInventory().close(); diff --git a/origins/src/main/java/io/github/dueris/originspaper/screen/ScreenNavigator.java b/origins/src/main/java/io/github/dueris/originspaper/screen/ScreenNavigator.java index bd83d4b41..3b5b842b0 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/screen/ScreenNavigator.java +++ b/origins/src/main/java/io/github/dueris/originspaper/screen/ScreenNavigator.java @@ -3,10 +3,13 @@ import io.github.dueris.originspaper.OriginsPaper; import io.github.dueris.originspaper.content.OrbOfOrigins; import io.github.dueris.originspaper.event.OrbInteractEvent; +import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; import io.github.dueris.originspaper.registry.Registries; +import io.github.dueris.originspaper.storage.OriginComponent; import io.github.dueris.originspaper.storage.OriginConfiguration; import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.util.ApoliScheduler; import io.github.dueris.originspaper.util.Util; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; @@ -33,8 +36,8 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.function.BiConsumer; @@ -44,11 +47,11 @@ public class ScreenNavigator implements Listener { public static final ItemStack NEXT_ITEMSTACK; public static final ItemStack BACK_ITEMSTACK; public static HashMap inChoosingLayer = new HashMap<>(); - public static ArrayList orbChoosing = new ArrayList<>(); + public static LinkedList orbChoosing = new LinkedList<>(); public static HashMap> layerPages = new HashMap<>(); public static Object2IntMap currentDisplayingPage = new Object2IntOpenHashMap(); public static HashMap> itemActions = new HashMap<>(); - public static ArrayList tickCooldown = new ArrayList<>(); + public static LinkedList tickCooldown = new LinkedList<>(); static { ItemStack next = new ItemStack(Material.ARROW); @@ -107,7 +110,9 @@ public static void open(Player player, OriginLayer layer, boolean inOrbChoosing) ) ); gui.setContents(layerPages.get(layer).get(currentDisplayingPage.getInt(player)).createDisplay(player, layer)); - OriginsPaper.scheduler.parent.scheduleMainThreadCall(() -> player.getBukkitEntity().openInventory(gui)); + ApoliScheduler.INSTANCE.queue((m) -> { + player.getBukkitEntity().openInventory(gui); + }, 1); } public static void open(org.bukkit.entity.Player player, OriginLayer layer, boolean inOrbChoosing) { @@ -190,9 +195,9 @@ public void onOrbClick(@NotNull PlayerInteractEvent e) { if (!((CraftPlayer) p).getHandle().getAbilities().instabuild) { Util.consumeItem(e.getItem()); } - OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).values().forEach(layer -> { - PowerHolderComponent.unloadPowers(p, layer); - PowerHolderComponent.setOrigin(p, layer, OriginsPaper.EMPTY_ORIGIN); + OriginsPaper.getRegistry().retrieve(Registries.LAYER).values().forEach(layer -> { + PowerHolderComponent.unloadPowers(p, layer, true); + OriginComponent.setOrigin(p, layer, Origin.EMPTY); }); OrbInteractEvent event = new OrbInteractEvent(p); getServer().getPluginManager().callEvent(event); diff --git a/origins/src/main/java/io/github/dueris/originspaper/storage/OriginComponent.java b/origins/src/main/java/io/github/dueris/originspaper/storage/OriginComponent.java new file mode 100644 index 000000000..45c5d055a --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/storage/OriginComponent.java @@ -0,0 +1,101 @@ +package io.github.dueris.originspaper.storage; + +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.event.OriginChangeEvent; +import io.github.dueris.originspaper.origin.Origin; +import io.github.dueris.originspaper.origin.OriginLayer; +import io.github.dueris.originspaper.power.type.MultiplePower; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.registry.Registries; +import io.github.dueris.originspaper.screen.ScreenNavigator; +import io.github.dueris.originspaper.util.BstatsMetrics; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.*; + +import static io.github.dueris.originspaper.origin.Origin.EMPTY; + +public class OriginComponent { + + private static ServerPlayer getNMS(Player player) { + return ((CraftPlayer) player).getHandle(); + } + + public static boolean hasOrigin(Player player, String originTag) { + Origin origin = OriginsPaper.getRegistry().retrieve(Registries.ORIGIN).get(ResourceLocation.parse(originTag)); + return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAllOrigins().contains(origin); + } + + public static @NotNull Origin getOrigin(Player player, OriginLayer layer) { + return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getOriginOrDefault(EMPTY, layer); + } + + public static void setOrigin(final @NotNull Entity entity, final OriginLayer layer, final Origin origin) { + if (!(entity instanceof Player player)) return; + Map origins = new HashMap<>(); + for (OriginLayer l : PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getLayers()) { + origins.put(l, PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getOrigin(l)); + } + if (OriginsPaper.getRegistry().retrieve(Registries.LAYER).values().contains(layer)) { + if (!origin.getTag().equals(EMPTY.getTag())) { + PowerHolderComponent.unloadPowers(player, layer, true); + } + + for (OriginLayer layers : origins.keySet()) { + if (layer.getTag().equals(layers.getTag())) { + origins.replace(layers, origin); + } + } + + String originTag = origin.getTag(); + if (!originTag.equals(EMPTY.getTag())) { + BstatsMetrics.originPopularity(player); + } + + PlayerPowerRepository repository = PlayerPowerRepository.getOrCreateRepo(getNMS(player)); + for (ResourceLocation power : origin.powers()) { + PowerType rootPower = OriginsPaper.getPower(power); + if (rootPower == null) { + PowerHolderComponent.printNotFound(power, origin); + continue; + } + List types = new LinkedList<>(List.of(rootPower)); + if (rootPower instanceof MultiplePower multiplePower) { + types.addAll(multiplePower.getSubPowers()); + } + + for (PowerType powerType : types) { + if (powerType == null) { + PowerHolderComponent.printNotFound(power, origin); + continue; + } + repository.addPower(powerType, layer); + } + } + + repository.setOrigin(origin, layer); + + PowerHolderComponent.loadPowers(player, layer, true); + + OriginChangeEvent e = new OriginChangeEvent(player, origin, layer, ScreenNavigator.orbChoosing.contains(getNMS(player))); + Bukkit.getPluginManager().callEvent(e); + ScreenNavigator.inChoosingLayer.remove(getNMS(player)); + } + } + + public static Set getLayers(Entity entity) { + if (!(entity instanceof Player player)) return new HashSet<>(); + return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getLayers(); + } + + public static boolean hasOrigin(Entity entity, OriginLayer originLayer) { + if (!(entity instanceof Player player)) return false; + return !PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getOrigin(originLayer).equals(EMPTY); + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/storage/OriginConfiguration.java b/origins/src/main/java/io/github/dueris/originspaper/storage/OriginConfiguration.java index c0cfb3bcd..5a5d18a1b 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/storage/OriginConfiguration.java +++ b/origins/src/main/java/io/github/dueris/originspaper/storage/OriginConfiguration.java @@ -1,9 +1,7 @@ package io.github.dueris.originspaper.storage; -import io.github.dueris.originspaper.OriginsPaper; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import java.io.File; @@ -17,13 +15,13 @@ public class OriginConfiguration { private static File orb; public static void load() throws IOException { - JavaPlugin plugin = OriginsPaper.getPlugin(); - if (!plugin.getDataFolder().exists()) { - plugin.getDataFolder().mkdirs(); + File dataFolder = new File("plugins/OriginsPaper/"); + if (!dataFolder.exists()) { + dataFolder.mkdirs(); } - File orbFile = fillFile("orb-of-origin.yml", new File(plugin.getDataFolder(), "orb-of-origin.yml")); - File originServer = fillFile("origin-server.yml", new File(plugin.getDataFolder(), "origin-server.yml")); + File orbFile = fillFile("orb-of-origin.yml", new File(dataFolder, "orb-of-origin.yml")); + File originServer = fillFile("origin-server.yml", new File(dataFolder, "origin-server.yml")); server = originServer; orb = orbFile; if (getConfiguration() == null) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/storage/PlayerPowerRepository.java b/origins/src/main/java/io/github/dueris/originspaper/storage/PlayerPowerRepository.java index be1181266..64355d9ae 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/storage/PlayerPowerRepository.java +++ b/origins/src/main/java/io/github/dueris/originspaper/storage/PlayerPowerRepository.java @@ -7,7 +7,7 @@ import io.github.dueris.originspaper.OriginsPaper; import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; -import io.github.dueris.originspaper.power.PowerType; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.registry.Registries; import io.github.dueris.originspaper.util.Util; import net.minecraft.nbt.CompoundTag; @@ -15,30 +15,30 @@ import net.minecraft.nbt.StringTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.Tuple; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; +import java.util.LinkedList; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.atomic.AtomicReference; -public final class PlayerPowerRepository { +public final class PlayerPowerRepository extends RepositoryComponent { static final ConcurrentMap REPO = new ConcurrentHashMap<>() { }; private static final Logger log = LogManager.getLogger(PlayerPowerRepository.class); - final Map origins = new ConcurrentHashMap<>(); private final ServerPlayer player; - private final Map> appliedPowers = new ConcurrentHashMap<>() { - }; - public PlayerPowerRepository(ServerPlayer player) { + public PlayerPowerRepository(ServerPlayer player, RepositoryComponent component) { this.player = player; } @@ -46,13 +46,10 @@ public static PlayerPowerRepository getOrCreateRepo(ServerPlayer player) { if (REPO.containsKey(player)) { return REPO.get(player); } - REPO.put(player, new PlayerPowerRepository(player)); + REPO.put(player, new PlayerPowerRepository(player, new RepositoryComponent())); return REPO.get(player); } - public ServerPlayer player() { - return player; - } @Override public boolean equals(Object obj) { @@ -62,67 +59,39 @@ public boolean equals(Object obj) { return Objects.equals(this.player, that.player); } - public void addOrigin(Origin origin, OriginLayer layer) { - origins.put(layer, origin); - } - - public void removeOrigin(Origin origin, OriginLayer layer) { - origins.remove(layer, origin); - } - - public void addPower(PowerType type, OriginLayer layer) { - if (type == null) return; - if (appliedPowers.containsKey(layer)) { - appliedPowers.get(layer).add(type); - return; - } - appliedPowers.put(layer, new CopyOnWriteArraySet<>()); - appliedPowers.get(layer).add(type); - } - - public void removePower(PowerType type, OriginLayer layer) { - if (type == null) return; - if (appliedPowers.containsKey(layer)) { - appliedPowers.get(layer).remove(type); - return; - } - appliedPowers.put(layer, new CopyOnWriteArraySet<>()); - appliedPowers.get(layer).remove(type); - } - @Unmodifiable public @NotNull List getAppliedPowers() { - return Util.collapseSet(appliedPowers.values()).stream().filter(Objects::nonNull).toList(); + return Util.collapseList(repo.values().stream().map(Tuple::getA).toList()); } @Unmodifiable public @NotNull List getAppliedPowers(OriginLayer layer) { - return appliedPowers.getOrDefault(layer, new CopyOnWriteArraySet<>()).stream().filter(Objects::nonNull).toList(); + return new CopyOnWriteArrayList<>(layer == null ? getAppliedPowers() : repo.get(layer).getA()); } - public synchronized @NotNull CompoundTag serializePowers(@NotNull CompoundTag nbt) { + public synchronized @NotNull CompoundTag serializePowers(@NotNull CompoundTag nbt, ServerPlayer player) { if (nbt.contains("PowerRepository")) { nbt.put("PowerRepository", new ListTag()); } ListTag repository = nbt.getList("PowerRepository", 10); - for (OriginLayer layer : this.appliedPowers.keySet()) { + for (OriginLayer layer : this.repo.keySet()) { CompoundTag tag = new CompoundTag(); tag.putString("Layer", layer.getTag()); ListTag powers = new ListTag(); - for (PowerType type : this.appliedPowers.get(layer)) { + for (PowerType type : this.repo.get(layer).getA()) { if (type == null) continue; CompoundTag powerTag = new CompoundTag(); powerTag.put("Power", StringTag.valueOf(type.getTag())); - @Nullable CompoundTag extra = type.saveData(); + @Nullable CompoundTag extra = type.saveData(player); if (extra != null) { powerTag.merge(extra); } powers.add(powerTag); } tag.put("Powers", powers); - tag.putString("Origin", origins.getOrDefault(layer, OriginsPaper.EMPTY_ORIGIN).getTag()); + tag.putString("Origin", this.getOriginOrDefault(Origin.EMPTY, layer).getTag()); repository.add(tag); } @@ -130,12 +99,12 @@ public void removePower(PowerType type, OriginLayer layer) { return nbt; } - public void readPowers(@Nullable String nbt) { + public void readPowers(@Nullable String nbt, ServerPlayer player) { if (nbt == null) throw new IllegalArgumentException("Provided NBT was null!"); - readPowers(CompoundTag.CODEC.decode(JsonOps.INSTANCE, new Gson().fromJson(nbt, JsonElement.class)).getOrThrow().getFirst()); + readPowers(CompoundTag.CODEC.decode(JsonOps.INSTANCE, new Gson().fromJson(nbt, JsonElement.class)).getOrThrow().getFirst(), player); } - public synchronized void readPowers(@NotNull CompoundTag nbt) { + public synchronized void readPowers(@NotNull CompoundTag nbt, ServerPlayer player) { if (!nbt.contains("PowerRepository")) return; ListTag repository = nbt.getList("PowerRepository", 10); repository.forEach(layerObject -> { @@ -149,34 +118,39 @@ public synchronized void readPowers(@NotNull CompoundTag nbt) { tag.getList("Powers", 10).forEach(powerTag -> { CompoundTag power = (CompoundTag) powerTag; ResourceLocation powerLocation = ResourceLocation.parse(power.getString("Power")); - PowerType powerType = OriginsPaper.getPlugin().registry.retrieve(Registries.CRAFT_POWER).get(powerLocation); + PowerType powerType = OriginsPaper.getRegistry().retrieve(Registries.POWER).get(powerLocation); if (powerType == null) { log.error("Stored PowerType not found! ID: {}, skipping power..", powerLocation.toString()); + return; } - powerType.loadFromData(power); + powerType.loadFromData(power, player); powerTypes.add(powerType); }); - OriginLayer layer = OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).get(layerLocation); + OriginLayer layer = OriginsPaper.getRegistry().retrieve(Registries.LAYER).get(layerLocation); if (layer == null) { log.error("Stored Layer not found! ID: {}, skipping layer..", layerLocation.toString()); } else { - appliedPowers.put(layer, powerTypes); - origins.put(layer, OriginsPaper.getPlugin().registry.retrieve(Registries.ORIGIN).getOptional(originLocation).orElse(OriginsPaper.EMPTY_ORIGIN)); + for (PowerType type : powerTypes) { + this.addPower(type, layer); + } + this.setOrigin(OriginsPaper.getRegistry().retrieve(Registries.ORIGIN).getOptional(originLocation).orElse(Origin.EMPTY), layer); } } else throw new JsonSyntaxException("Layer value not found in CompoundTag!"); }); // Final check to ensure all layers have a value - for (OriginLayer layer : OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).values()) { - if (!appliedPowers.containsKey(layer)) { - appliedPowers.put(layer, new CopyOnWriteArraySet<>()); - } - if (!origins.containsKey(layer)) { - origins.put(layer, OriginsPaper.EMPTY_ORIGIN); + for (OriginLayer layer : OriginsPaper.getRegistry().retrieve(Registries.LAYER).values()) { + if (!this.repo.containsKey(layer)) { + this.repo.put(layer, new Tuple<>(new LinkedList<>(), new AtomicReference<>(Origin.EMPTY))); } } } + + public ServerPlayer player() { + return player; + } + } diff --git a/origins/src/main/java/io/github/dueris/originspaper/storage/PowerHolderComponent.java b/origins/src/main/java/io/github/dueris/originspaper/storage/PowerHolderComponent.java index d4f6c896b..5714517e2 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/storage/PowerHolderComponent.java +++ b/origins/src/main/java/io/github/dueris/originspaper/storage/PowerHolderComponent.java @@ -1,21 +1,14 @@ package io.github.dueris.originspaper.storage; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.event.OriginChangeEvent; import io.github.dueris.originspaper.event.PowerUpdateEvent; import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; -import io.github.dueris.originspaper.power.MultiplePower; -import io.github.dueris.originspaper.power.PowerType; -import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.screen.ScreenNavigator; -import io.github.dueris.originspaper.util.BstatsMetrics; +import io.github.dueris.originspaper.power.type.MultiplePower; +import io.github.dueris.originspaper.power.factory.PowerType; import io.github.dueris.originspaper.util.entity.PowerUtils; -import net.md_5.bungee.api.ChatColor; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; -import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -23,63 +16,28 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerToggleSprintEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.function.Predicate; public class PowerHolderComponent implements Listener { - public static ArrayList currentSprintingPlayersFallback = new ArrayList<>(); + public static LinkedList currentSprintingPlayersFallback = new LinkedList<>(); private static ServerPlayer getNMS(Player player) { return ((CraftPlayer) player).getHandle(); } - public static void moveEquipmentInventory(@NotNull Player player, EquipmentSlot equipmentSlot) { - ItemStack item = player.getInventory().getItem(equipmentSlot); - if (item != null && item.getType() != Material.AIR) { - int emptySlot = player.getInventory().firstEmpty(); - if (emptySlot != -1) { - player.getInventory().setItem(equipmentSlot, null); - player.getInventory().setItem(emptySlot, item); - } else { - player.getWorld().dropItem(player.getLocation(), item); - player.getInventory().setItem(equipmentSlot, null); - } - } - } - - public static boolean hasOrigin(Player player, String originTag) { - Origin origin = OriginsPaper.getPlugin().registry.retrieve(Registries.ORIGIN).get(ResourceLocation.parse(originTag)); - return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).origins.containsValue(origin); - } - - public static Origin getOrigin(Player player, OriginLayer layer) { - return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).origins.getOrDefault(layer, OriginsPaper.EMPTY_ORIGIN); - } - - public static Map getOrigin(Player player) { - return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).origins; - } - @Unmodifiable public static @NotNull List getPowers(Entity entity, Class typeOf) { if (!(entity instanceof Player player)) return List.of(); return getPowers(player, (powerType) -> powerType.getClass().equals(typeOf)); } - @Unmodifiable - public static @NotNull List getPowers(Player p, String typeOf) { - return getPowers(p, (powerType) -> powerType.getType().equalsIgnoreCase(typeOf)); - } - @Unmodifiable @SuppressWarnings("unchecked") public static @NotNull List getPowers(Player player, Predicate powerTypePredicate) { @@ -90,25 +48,43 @@ public static Map getOrigin(Player player) { @Unmodifiable public static @NotNull List getPowers(Entity p) { - if (!(p instanceof Player player)) return new ArrayList<>(); + if (!(p instanceof Player player)) return new LinkedList<>(); return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAppliedPowers(); } @Unmodifiable public static @NotNull List getPowers(Entity p, OriginLayer layer) { - if (!(p instanceof Player player)) return new ArrayList<>(); + if (!(p instanceof Player player)) return new LinkedList<>(); return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAppliedPowers(layer); } - public static @Nullable PowerType getPower(Entity p, String powerKey) { + public static @Nullable PowerType getPower(Entity p, ResourceLocation powerKey) { if (!(p instanceof Player player)) return null; return (PowerType) getPowers(player, (powerType) -> { - return powerType.getTag().equalsIgnoreCase(powerKey); + return powerType.getTag().equalsIgnoreCase(powerKey.toString()); }).stream().findFirst().orElse(null); } - public static @NotNull ArrayList getNestedPowerTypes(PowerType power) { - ArrayList nested = new ArrayList<>(); + public static @NotNull List getPowersFromSource(OriginLayer layer, Entity entity) { + if (!(entity instanceof Player player)) return new LinkedList<>(); + return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAppliedPowers(layer); + } + + /** + * @return the power and all nested powers if its a multiple power instance + */ + public static @NotNull LinkedList getAllPowers(ResourceLocation location) { + PowerType source = OriginsPaper.getPower(location); + LinkedList powers = new LinkedList<>(List.of(source)); + if (source instanceof MultiplePower) { + powers.addAll(getNestedPowerTypes(source)); + } + + return powers; + } + + public static @NotNull LinkedList getNestedPowerTypes(PowerType power) { + LinkedList nested = new LinkedList<>(); if (power != null) { if (power instanceof MultiplePower multiple) { nested.addAll(multiple.getSubPowers()); @@ -124,99 +100,66 @@ public static boolean hasPower(Entity p, String powerKey) { .stream().map(PowerType::getTag).toList().contains(powerKey); } - public static boolean hasPowerType(Entity p, Class typeOf) { + public static boolean hasPower(Entity p, PowerType type) { if (!(p instanceof Player player)) return false; - return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAppliedPowers() - .stream().map(PowerType::getClass).toList().contains(typeOf); + return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAppliedPowers().contains(type); } - public static void setOrigin(final @NotNull Entity entity, final OriginLayer layer, final Origin origin) { - if (!(entity instanceof Player player)) return; - Map origins = getOrigin(player); - if (OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).values().contains(layer)) { - if (!origin.getTag().equals(OriginsPaper.EMPTY_ORIGIN.getTag())) { - unloadPowers(player, layer); - } - - for (OriginLayer layers : origins.keySet()) { - if (layer.getTag().equals(layers.getTag())) { - origins.replace(layers, origin); - } - } - - String originTag = origin.getTag(); - if (!originTag.equals(OriginsPaper.EMPTY_ORIGIN.getTag())) { - BstatsMetrics.originPopularity(player); - } - - PlayerPowerRepository repository = PlayerPowerRepository.getOrCreateRepo(getNMS(player)); - for (ResourceLocation power : origin.powers()) { - PowerType rootPower = OriginsPaper.getPower(power); - if (rootPower == null) { - printNotFound(power, origin); - continue; - } - List types = new ArrayList<>(List.of(rootPower)); - if (rootPower instanceof MultiplePower multiplePower) { - types.addAll(multiplePower.getSubPowers()); - } - - for (PowerType powerType : types) { - if (powerType == null) { - printNotFound(power, origin); - continue; - } - repository.addPower(powerType, layer); - } - } - - repository.origins.put(layer, origin); - - PowerHolderComponent.loadPowers(player, layer, true); + public static boolean hasPowerType(Entity p, ResourceLocation typeOf) { + if (!(p instanceof Player player)) return false; + return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAppliedPowers() + .stream().map(PowerType::getType).toList().contains(typeOf.toString()); + } - OriginChangeEvent e = new OriginChangeEvent(player, origin, layer, ScreenNavigator.orbChoosing.contains(getNMS(player))); - Bukkit.getPluginManager().callEvent(e); - ScreenNavigator.inChoosingLayer.remove(getNMS(player)); - } + public static boolean hasPowerType(Entity p, Class typeOf) { + if (!(p instanceof Player player)) return false; + return PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAppliedPowers() + .stream().map(PowerType::getClass).toList().contains(typeOf); } - private static void printNotFound(ResourceLocation location) { + protected static void printNotFound(ResourceLocation location) { printNotFound(location, null); } - private static void printNotFound(@NotNull ResourceLocation location, @Nullable Origin origin) { - OriginsPaper.getPlugin().getLog4JLogger().error("Specified PowerType '{}'{} was not found in the registry.", location.toString(), + protected static void printNotFound(@NotNull ResourceLocation location, @Nullable Origin origin) { + OriginsPaper.LOGGER.error("Specified PowerType '{}'{} was not found in the registry.", location.toString(), origin == null ? "" : " in Origin '{}'".replace("{}", origin.getTag())); } - public static List getPowersApplied(Player p) { + public static @NotNull @Unmodifiable List getPowersApplied(Player p) { return PlayerPowerRepository.getOrCreateRepo(getNMS(p)).getAppliedPowers(); } public static void checkForDuplicates(Player p) { - List keys = new ArrayList<>(); - List duplicates = new ArrayList<>(); - - for (PowerType power : getPowersApplied(p)) { - if (keys.contains(power.key())) { - duplicates.add(power); - } else { - keys.add(power.key()); + PlayerPowerRepository repo = PlayerPowerRepository.getOrCreateRepo(getNMS(p)); + + for (OriginLayer layer : OriginComponent.getLayers(p)) { + List keys = new LinkedList<>(); + List duplicates = new LinkedList<>(); + + for (PowerType power : getPowersFromSource(layer, p)) { + if (keys.contains(power.getId())) { + duplicates.add(power); + } else { + keys.add(power.getId()); + } } - } - duplicates.forEach(powerx -> getPowersApplied(p).remove(powerx)); + duplicates.forEach(powerx -> { + repo.removePower(powerx, layer); + }); + } } public static boolean isOfType(@NotNull PowerType type, Class typeOf) { return type.getClass().equals(typeOf); } - public static void loadPower(Player player, PowerType power, OriginLayer layer, boolean suppress) { - loadPower(player, power, layer, suppress, false); + public static void loadPower(Player player, PowerType power, OriginLayer layer) { + loadPower(player, power, layer, false); } - public static void loadPower(Player player, PowerType power, OriginLayer layer, boolean suppress, boolean isNew) { + public static void loadPower(Player player, PowerType power, OriginLayer layer, boolean isNew) { if (power != null) { power.forPlayer(((CraftPlayer) player).getHandle()); PlayerPowerRepository.getOrCreateRepo(getNMS(player)).addPower(power, layer); @@ -225,57 +168,51 @@ public static void loadPower(Player player, PowerType power, OriginLayer layer, power.onAdded(((CraftPlayer) player).getHandle()); } PowerUtils.markGained(power, player); - if (!suppress) { - Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Assigned power[" + power.getTag() + "] to player " + player.getName()); - } new PowerUpdateEvent(player, power, false, isNew).callEvent(); } } - public static void unloadPower(Player player, PowerType power, OriginLayer layer, boolean suppress) { - unloadPower(player, power, layer, suppress, false); + public static void unloadPower(Player player, PowerType power, OriginLayer layer) { + unloadPower(player, power, layer, false); } - public static void unloadPower(Player player, PowerType power, OriginLayer layer, boolean suppress, boolean isNew) { + public static void unloadPower(Player player, PowerType power, OriginLayer layer, boolean isNew) { if (power != null) { if (isNew) { power.onRemoved(((CraftPlayer) player).getHandle()); } PlayerPowerRepository.getOrCreateRepo(getNMS(player)).removePower(power, layer); power.removePlayer(((CraftPlayer) player).getHandle()); - if (!suppress) { - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Removed power[" + power.getTag() + "] from player " + player.getName()); - } new PowerUpdateEvent(player, power, true, isNew).callEvent(); } } public static void unloadPowers(@NotNull Player player) { - Map origins = getOrigin(player); - - for (OriginLayer layer : origins.keySet()) { + for (OriginLayer layer : OriginComponent.getLayers(player)) { unloadPowers(player, layer); } } public static void loadPowers(@NotNull Player player) { - Map origins = getOrigin(player); - - for (OriginLayer layer : origins.keySet()) { + for (OriginLayer layer : OriginComponent.getLayers(player)) { loadPowers(player, layer); } } public static void unloadPowers(@NotNull Player player, OriginLayer layer) { + unloadPowers(player, layer, false); + } + + public static void unloadPowers(@NotNull Player player, OriginLayer layer, boolean isNew) { if (layer == null) { - OriginsPaper.getPlugin().getLogger().severe("Provided layer was null! Was it removed? Skipping power application..."); + OriginsPaper.LOGGER.error("Provided layer was null! Was it removed? Skipping power application..."); return; } for (PowerType power : PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAppliedPowers(layer)) { - unloadPower(player, power, layer, false); + unloadPower(player, power, layer, isNew); } } @@ -285,17 +222,17 @@ public static void loadPowers(@NotNull Player player, OriginLayer layer) { public static void loadPowers(@NotNull Player player, OriginLayer layer, boolean isNew) { if (layer == null) { - OriginsPaper.getPlugin().getLogger().severe("Provided layer was null! Was it removed? Skipping power application..."); + OriginsPaper.LOGGER.error("Provided layer was null! Was it removed? Skipping power application..."); return; } for (PowerType power : PlayerPowerRepository.getOrCreateRepo(getNMS(player)).getAppliedPowers(layer)) { - loadPower(player, power, layer, false, isNew); + loadPower(player, power, layer, isNew); } } - public static List gatherConditionedPowers(Entity p, Class type, Predicate predicate) { - ArrayList powers = new ArrayList<>(); + public static @NotNull List gatherConditionedPowers(Entity p, Class type, Predicate predicate) { + LinkedList powers = new LinkedList<>(); if (hasPowerType(p, type)) { for (T power : getPowers(p, type)) { if (predicate.test(power)) { @@ -318,6 +255,21 @@ public static boolean doesHaveConditionedPower(Entity p, C return pass; } + public static @NotNull List getSources(PowerType power, Entity entity) { + if (!(entity instanceof Player player)) return new LinkedList<>(); + List locations = new LinkedList<>(); + + PlayerPowerRepository repo = PlayerPowerRepository.getOrCreateRepo(getNMS(player)); + for (OriginLayer layer : repo.getLayers()) { + + if (repo.getAppliedPowers(layer).contains(power)) { + locations.add(layer.getId()); + } + } + + return locations; + } + @EventHandler(priority = EventPriority.MONITOR) public void sprint(@NotNull PlayerToggleSprintEvent e) { if (e.isSprinting()) { diff --git a/origins/src/main/java/io/github/dueris/originspaper/storage/RepositoryComponent.java b/origins/src/main/java/io/github/dueris/originspaper/storage/RepositoryComponent.java new file mode 100644 index 000000000..ac01126d4 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/storage/RepositoryComponent.java @@ -0,0 +1,99 @@ +package io.github.dueris.originspaper.storage; + +import io.github.dueris.originspaper.origin.Origin; +import io.github.dueris.originspaper.origin.OriginLayer; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.util.Util; +import net.minecraft.util.Tuple; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; + +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicReference; + +public class RepositoryComponent implements Iterable, AtomicReference>> { + protected final ConcurrentHashMap, AtomicReference>> repo = new ConcurrentHashMap<>(); + + public int size() { + return repo.size(); + } + + public boolean isEmpty() { + return repo.isEmpty(); + } + + public @NotNull Set getLayers() { + return repo.keySet(); + } + + public @Unmodifiable @NotNull List getAllPowers() { + return Util.collapseList(repo.values().stream().map(Tuple::getA).toList()); + } + + public @Unmodifiable @NotNull List getAllOrigins() { + return repo.values().stream().map(Tuple::getB).map(AtomicReference::get).toList(); + } + + @Override + public @NotNull Iterator, AtomicReference>> iterator() { + return repo.values().iterator(); + } + + public void put(OriginLayer layer) { + repo.put(layer, new Tuple<>(new CopyOnWriteArrayList<>(), new AtomicReference<>(Origin.EMPTY))); + } + + public void addPower(PowerType type, OriginLayer layer) { + if (!repo.containsKey(layer)) { + put(layer); + } + + repo.get(layer).getA().add(type); + } + + public void removePower(PowerType type, OriginLayer layer) { + if (!repo.containsKey(layer)) { + put(layer); + } + + repo.get(layer).getA().remove(type); + } + + public Origin getOrigin(OriginLayer layer) { + if (!repo.containsKey(layer)) { + put(layer); + } + + return repo.get(layer).getB().get(); + } + + @NotNull + public Origin getOriginOrDefault(@NotNull Origin def, OriginLayer layer) { + if (!repo.containsKey(layer)) { + put(layer); + } + + Origin retrieved = repo.get(layer).getB().get(); + + return retrieved == null ? def : retrieved; + } + + public void setOrigin(Origin origin, OriginLayer layer) { + if (!repo.containsKey(layer)) { + put(layer); + } + + repo.get(layer).getB().set(origin); + } + + @Override + public @NotNull String toString() { + return "RepositoryComponent{" + + "repo=" + repo + + '}'; + } +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/ApoliScheduler.java b/origins/src/main/java/io/github/dueris/originspaper/util/ApoliScheduler.java index cda05eb89..534488e78 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/ApoliScheduler.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/ApoliScheduler.java @@ -1,21 +1,45 @@ package io.github.dueris.originspaper.util; +import io.github.dueris.originspaper.OriginsPaper; +import io.github.dueris.originspaper.power.type.CreativeFlightPower; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.registry.Registries; +import io.github.dueris.originspaper.screen.GuiTicker; +import io.github.dueris.originspaper.storage.PowerHolderComponent; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.server.MinecraftServer; -import org.bukkit.event.Listener; +import net.minecraft.world.entity.player.Player; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; import java.util.List; import java.util.function.Consumer; import java.util.function.IntPredicate; -public class ApoliScheduler implements Listener { +public class ApoliScheduler { public static ApoliScheduler INSTANCE = new ApoliScheduler(); private final Int2ObjectMap>> taskQueue = new Int2ObjectOpenHashMap<>(); private int currentTick = 0; - public void tick(MinecraftServer m) { + public static void tickAsyncScheduler() { + for (org.bukkit.entity.Player p : Bukkit.getOnlinePlayers()) { + for (PowerType c : PowerHolderComponent.getPowersApplied(p)) { + c.tickAsync(((CraftPlayer) p).getHandle()); + } + } + + for (org.bukkit.entity.Player p : Bukkit.getOnlinePlayers()) { + CreativeFlightPower.tickPlayer(((CraftPlayer) p).getHandle(), null); + } + + GuiTicker.tick(); + } + + public void tick(@NotNull MinecraftServer m) { this.currentTick = m.getTickCount(); List> runnables = this.taskQueue.remove(this.currentTick); if (runnables != null) for (int i = 0; i < runnables.size(); i++) { @@ -27,6 +51,8 @@ public void tick(MinecraftServer m) { this.queue(runnable, ((Repeating) runnable).next); } } + + tick(); } /** @@ -36,7 +62,7 @@ public void tick(MinecraftServer m) { * @param task the action to perform */ public void queue(Consumer task, int tick) { - this.taskQueue.computeIfAbsent(this.currentTick + tick + 1, t -> new ArrayList<>()).add(task); + this.taskQueue.computeIfAbsent(this.currentTick + tick + 1, t -> new LinkedList<>()).add(task); } /** @@ -81,6 +107,43 @@ public boolean test(int value) { }, tick, interval); } + public String toString() { + return "OriginSchedulerTree$run()"; + } + + public void tick() { + for (PowerType power : OriginsPaper.getRegistry().retrieve(Registries.POWER).values()) { + power.tick(); + if (power.hasPlayers()) { + for (Player p : power.getPlayers()) { + if (Bukkit.getServer().getCurrentTick() % 20 == 0) { + PowerHolderComponent.checkForDuplicates((CraftPlayer) p.getBukkitEntity()); + } + + try { + if (power.shouldTick()) { + power.tick(p); + } + } catch (Throwable var8) { + String[] stacktrace = new String[]{"\n"}; + Arrays.stream(var8.getStackTrace()) + .map(StackTraceElement::toString) + .forEach(string -> stacktrace[0] = stacktrace[0] + "\tat " + string + "\n"); + OriginsPaper.LOGGER + .error("An unhandled exception occurred when ticking a Power! [{}]", var8.getClass().getSimpleName()); + String t = power.getType(); + if (t == null) { + t = power.getId().toString(); + } + + OriginsPaper.LOGGER + .error("Player: {} | Power: {} | CraftPower: {} | Throwable: {} {}", p.getName(), power.getTag(), t, var8.getMessage() == null ? var8.getClass().getSimpleName() : var8.getMessage(), stacktrace[0]); + } + } + } + } + } + private static final class Repeating implements Consumer { public final int next; private final Consumer task; diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/AsyncUpgradeTracker.java b/origins/src/main/java/io/github/dueris/originspaper/util/AsyncUpgradeTracker.java index d733d2258..c6888bc91 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/AsyncUpgradeTracker.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/AsyncUpgradeTracker.java @@ -5,7 +5,7 @@ import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; import io.github.dueris.originspaper.registry.Registries; -import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.storage.OriginComponent; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementProgress; import net.minecraft.resources.ResourceLocation; @@ -33,20 +33,20 @@ public void run() { MinecraftServer server = OriginsPaper.server; for (Map.Entry> entry : upgrades.entrySet()) { for (CraftPlayer player : ((CraftServer) Bukkit.getServer()).getOnlinePlayers()) { - for (OriginLayer layer : OriginsPaper.getPlugin().registry.retrieve(Registries.LAYER).values()) { - if (PowerHolderComponent.getOrigin(player, layer).equals(entry.getKey())) { + for (OriginLayer layer : OriginsPaper.getRegistry().retrieve(Registries.LAYER).values()) { + if (OriginComponent.getOrigin(player, layer).equals(entry.getKey())) { ResourceLocation advancement = entry.getValue().a(); ResourceLocation originToSet = entry.getValue().b(); String announcement = entry.getValue().c(); AdvancementHolder advancementHolder = server.getAdvancements().get(advancement); if (advancementHolder == null) { - OriginsPaper.getPlugin().getLog4JLogger().error("Advancement \"{}\" did not exist but was referenced in the an origin upgrade!", advancement); + OriginsPaper.LOGGER.error("Advancement \"{}\" did not exist but was referenced in the an origin upgrade!", advancement); } AdvancementProgress progress = player.getHandle().getAdvancements().getOrStartProgress(advancementHolder); if (progress.isDone()) { - PowerHolderComponent.setOrigin(player, layer, OriginsPaper.getPlugin().registry.retrieve(Registries.ORIGIN).get(originToSet)); + OriginComponent.setOrigin(player, layer, OriginsPaper.getRegistry().retrieve(Registries.ORIGIN).get(originToSet)); if (!announcement.equals(NO_ANNOUNCEMENT)) { player.sendMessage(announcement); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/BstatsMetrics.java b/origins/src/main/java/io/github/dueris/originspaper/util/BstatsMetrics.java index a265693d7..a392f0496 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/BstatsMetrics.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/BstatsMetrics.java @@ -15,9 +15,10 @@ package io.github.dueris.originspaper.util; import io.github.dueris.originspaper.origin.Origin; -import io.github.dueris.originspaper.storage.PowerHolderComponent; +import io.github.dueris.originspaper.storage.PlayerPowerRepository; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; @@ -39,7 +40,7 @@ import java.util.stream.Collectors; import java.util.zip.GZIPOutputStream; -import static io.github.dueris.originspaper.OriginsPaper.metrics; +import static io.github.dueris.originspaper.plugin.OriginsPlugin.metrics; public class BstatsMetrics { @@ -105,7 +106,7 @@ public BstatsMetrics(JavaPlugin plugin, int serviceId) { } public static void originPopularity(Player p) { - for (Origin origin : PowerHolderComponent.getOrigin(p).values()) { + for (Origin origin : PlayerPowerRepository.getOrCreateRepo(((CraftPlayer) p).getHandle()).getAllOrigins()) { metrics.addCustomChart(new BstatsMetrics.DrilldownPie("originPopularity", () -> { Map> map = new HashMap<>(); Map entry = new HashMap<>(); diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/ComponentUtil.java b/origins/src/main/java/io/github/dueris/originspaper/util/ComponentUtil.java index a669de43a..75d55596e 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/ComponentUtil.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/ComponentUtil.java @@ -1,10 +1,11 @@ package io.github.dueris.originspaper.util; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; public class ComponentUtil { @@ -14,8 +15,13 @@ public class ComponentUtil { return Component.text(string); } + @Contract("_ -> new") + public static @NotNull TextComponent nmsToKyori(net.minecraft.network.chat.@NotNull Component component) { + return Component.text(component.getString()); + } + public static @NotNull List stringListToComponent(@NotNull List string) { - List compList = new ArrayList<>(); + List compList = new LinkedList<>(); string.forEach((st) -> { compList.add(ComponentUtil.stringToComponent(st)); }); diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/EntityLinkedItemStack.java b/origins/src/main/java/io/github/dueris/originspaper/util/EntityLinkedItemStack.java deleted file mode 100644 index c2502820e..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/util/EntityLinkedItemStack.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.github.dueris.originspaper.util; - -import io.papermc.paper.event.player.PlayerInventorySlotChangeEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.concurrent.ConcurrentHashMap; - -public class EntityLinkedItemStack implements Listener { - private static EntityLinkedItemStack instance; - private final ConcurrentHashMap itemHolderMap = new ConcurrentHashMap<>(); - - public static EntityLinkedItemStack getInstance() { - if (instance == null) { - instance = new EntityLinkedItemStack(); - } - - return instance; - } - - public void updateHolder(ItemStack itemStack, Player player) { - if (player == null) { - this.itemHolderMap.remove(itemStack); - } else { - this.itemHolderMap.put(itemStack, player); - } - } - - public Player getHolder(ItemStack itemStack) { - return this.itemHolderMap.get(itemStack); - } - - @EventHandler - public void onItemPickup(@NotNull PlayerPickupItemEvent e) { - Player player = e.getPlayer(); - ItemStack itemStack = e.getItem().getItemStack(); - this.updateHolder(itemStack, player); - } - - @EventHandler - public void onItemDrop(@NotNull PlayerDropItemEvent e) { - ItemStack itemStack = e.getItemDrop().getItemStack(); - this.updateHolder(itemStack, e.getPlayer()); - } - - @EventHandler - public void onItemSwitch(@NotNull PlayerInventorySlotChangeEvent e) { - ItemStack itemStack = e.getNewItemStack(); - this.updateHolder(itemStack, e.getPlayer()); - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/KeybindUtil.java b/origins/src/main/java/io/github/dueris/originspaper/util/KeybindUtil.java index 14e8d907d..bdbe6180b 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/KeybindUtil.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/KeybindUtil.java @@ -27,11 +27,11 @@ import org.bukkit.persistence.PersistentDataType; import org.bukkit.scheduler.BukkitRunnable; -import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; public class KeybindUtil implements Listener { - public static HashMap> activeKeys = new HashMap<>(); + public static HashMap> activeKeys = new HashMap<>(); private static void clearOldData(Player player) { for (ItemStack itemStack : player.getInventory().getContents().clone()) { @@ -81,7 +81,7 @@ public static void triggerExecution(String key, Player player) { } private static void triggerActiveKey(Player player, String key) { - activeKeys.putIfAbsent(player, new ArrayList<>()); + activeKeys.putIfAbsent(player, new LinkedList<>()); activeKeys.get(player).add(key); new BukkitRunnable() { @Override @@ -94,7 +94,7 @@ public void run() { // Keybind triggers end public static boolean isKeyActive(String key, Player player) { - activeKeys.putIfAbsent(player, new ArrayList<>()); + activeKeys.putIfAbsent(player, new LinkedList<>()); return activeKeys.get(player).contains(key); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/LangFile.java b/origins/src/main/java/io/github/dueris/originspaper/util/LangFile.java index 58ef8a3a2..5b36d12fc 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/LangFile.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/LangFile.java @@ -5,6 +5,8 @@ import io.github.dueris.originspaper.OriginsPaper; import io.github.dueris.originspaper.registry.Registries; import io.github.dueris.originspaper.storage.OriginConfiguration; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; @@ -33,15 +35,50 @@ public static void init() { LANGUAGE = OriginConfiguration.getConfiguration().getString("language", "en_us"); String langInput = Util.readResource("/assets/origins/lang/%%.json".replace("%%", LANGUAGE)); ResourceLocation location = ResourceLocation.parse("origins:" + LANGUAGE); - OriginsPaper.getPlugin().registry.retrieve(Registries.LANG).register(new LangFile(new Gson().fromJson(langInput, JsonObject.class)), location); + OriginsPaper.getRegistry().retrieve(Registries.LANG).register(new LangFile(new Gson().fromJson(langInput, JsonObject.class)), location); } - public static String transform(String original) { + public static @NotNull Component translatable(String original, Object... args) { if (langMap.get(LANGUAGE).containsKey(original)) { - return langMap.get(LANGUAGE).get(original); + return Component.literal(fixArgs(langMap.get(LANGUAGE).get(original), args)); } - return original; + return Component.translatable(original); + } + + private static @NotNull String fixArgs(@NotNull String template, Object... values) { + if (!template.contains("%s")) return template; + StringBuilder result = new StringBuilder(); + int lastIndex = 0; + int placeholderIndex = 0; + + for (int i = 0; i < template.length(); i++) { + if (i + 2 < template.length() && template.charAt(i) == '%' && template.charAt(i + 1) == 's') { + if (placeholderIndex < values.length) { + result.append(template, lastIndex, i); + result.append(format(values[placeholderIndex])); + lastIndex = i + 2; + placeholderIndex++; + } + i++; + } + } + result.append(template.substring(lastIndex)); + + return result.toString(); + } + + /** + * @return The object as a string. If its a component then serialize it to a String text + */ + private static String format(Object object) { + if (object instanceof Component component) { + return component.getString(); + } else if (object instanceof net.kyori.adventure.text.Component component) { + return translatable(PlainTextComponentSerializer.plainText().serialize(component)).getString(); + } + + return object.toString(); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/LogoutBugWorkaround.java b/origins/src/main/java/io/github/dueris/originspaper/util/LogoutBugWorkaround.java deleted file mode 100644 index 3bb077da5..000000000 --- a/origins/src/main/java/io/github/dueris/originspaper/util/LogoutBugWorkaround.java +++ /dev/null @@ -1,80 +0,0 @@ -package io.github.dueris.originspaper.util; - -import io.github.dueris.originspaper.OriginsPaper; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.NamespacedKey; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.persistence.PersistentDataType; -import org.bukkit.scheduler.BukkitRunnable; - -public class LogoutBugWorkaround implements Listener { - static { - OriginsPaper.preShutdownTasks.add(() -> { - for (Player p : Bukkit.getOnlinePlayers()) { - p.getPersistentDataContainer().set(new NamespacedKey(OriginsPaper.getPlugin(), "logoutWorkaroundLocation"), PersistentDataType.STRING, formatLocation(p.getLocation())); - } - }); - } - - public static String formatLocation(Location location) { - return location.x() + "//" + location.getY() + "//" + location.getZ() + "//" + location.getYaw() + "//" + location.getPitch(); - } - - @EventHandler - public void logout(PlayerQuitEvent e) { - Player p = e.getPlayer(); - p.getPersistentDataContainer().set(new NamespacedKey(OriginsPaper.getPlugin(), "logoutWorkaroundLocation"), PersistentDataType.STRING, formatLocation(p.getLocation())); - } - - @EventHandler - public void login(PlayerJoinEvent e) { - if (!e.getPlayer().getLocation().getChunk().isLoaded()) { - e.getPlayer().getLocation().getChunk().load(true); - } - freezeLogin(e.getPlayer()); - } - - @EventHandler - public void teleport(PlayerTeleportEvent e) { - if (!e.getTo().getChunk().isLoaded()) { - e.getTo().getChunk().load(true); - } - } - - public void freezeLogin(Player p) { - if (p.getPersistentDataContainer().has(new NamespacedKey(OriginsPaper.getPlugin(), "logoutWorkaroundLocation"), PersistentDataType.STRING)) { - String logoutData = p.getPersistentDataContainer().get(new NamespacedKey(OriginsPaper.getPlugin(), "logoutWorkaroundLocation"), PersistentDataType.STRING); - String[] splitData = logoutData.split("//"); - Location location = new Location( - p.getWorld(), - Double.parseDouble(splitData[0]), - Double.parseDouble(splitData[1]), - Double.parseDouble(splitData[2]), - Float.parseFloat(splitData[3]), - Float.parseFloat(splitData[4]) - ); - final int[] i = {0}; - new BukkitRunnable() { - @Override - public void run() { - if (i[0] > 15) cancel(); - p.teleportAsync(location); - i[0]++; - } - }.runTaskTimer(OriginsPaper.getPlugin(), 0, 1); - } - } - - @EventHandler - public void endPlatformFix(PlayerTeleportEvent e) { // Fixes spawning inside the platform, making the player fall into the void if the platform is floating - if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) { - e.setTo(new Location(e.getTo().getWorld(), e.getTo().getX(), 51, e.getTo().getZ(), e.getTo().getYaw(), e.getTo().getPitch())); - } - } -} diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/Renderer.java b/origins/src/main/java/io/github/dueris/originspaper/util/Renderer.java new file mode 100644 index 000000000..b77c3ea78 --- /dev/null +++ b/origins/src/main/java/io/github/dueris/originspaper/util/Renderer.java @@ -0,0 +1,142 @@ +package io.github.dueris.originspaper.util; + +import net.minecraft.resources.ResourceLocation; +import org.bukkit.boss.BarColor; +import org.jetbrains.annotations.NotNull; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Path; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +public class Renderer { + private static final Map namespace2path; + private static final Map RENDER_MAP = new HashMap<>(); + + static { + List spriteLocations = List.of( + "origins:textures/gui/resource_bar.png", + "origins:textures/gui/community/spiderkolo/resource_bar_01.png", + "origins:textures/gui/community/spiderkolo/resource_bar_02.png", + "origins:textures/gui/community/spiderkolo/resource_bar_03.png", + "origins:textures/gui/community/spiderkolo/resource_bar_points_01.png", + "origins:textures/gui/community/huang/resource_bar_01.png", + "origins:textures/gui/community/huang/resource_bar_02.png" + ); + Map map = new HashMap<>(); + for (String spriteLocation : spriteLocations) { + map.put(ResourceLocation.parse(spriteLocation), "assets/origins/" + spriteLocation.split(":")[1]); + } + namespace2path = Collections.unmodifiableMap(map); + } + + public static void init() throws Throwable { + JarFile plugin = new JarFile(Path.of(Renderer.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toFile()); + for (Map.Entry entry : namespace2path.entrySet()) { + ResourceLocation resourceLocation = entry.getKey(); + JarEntry jarEntry = plugin.getJarEntry(entry.getValue()); + + if (jarEntry == null) { + throw new IOException("Unable to locate " + entry.getValue() + " render image!"); + } + + try (InputStream entryStream = plugin.getInputStream(jarEntry)) { + BufferedImage image = ImageIO.read(entryStream); + if (image == null) { + throw new IOException("Failed to read image for " + resourceLocation); + } + + RenderMap textureLocation = new RenderMap( + ResourceLocation.fromNamespaceAndPath(resourceLocation.getNamespace(), resourceLocation.getPath()), image); + + int index = 0; + for (Map.Entry colorEntry : textureLocation.renderMap.entrySet()) { + RENDER_MAP.put(colorEntry.getKey(), new RenderImpl(index, resourceLocation, image, colorEntry.getValue())); + index++; + } + } + } + } + + public static @NotNull RenderImpl findRender(int index, ResourceLocation spriteLocation) { + RenderImpl foundSprite = RENDER_MAP.get(spriteLocation + "=" + index); + if (foundSprite != null) { + return foundSprite; + } + + throw new IllegalArgumentException("Unable to locate render impl of '" + spriteLocation + "' at index [" + index + "]"); + } + + public record RenderImpl(int index, ResourceLocation spriteLocation, BufferedImage backend, BarColor renderColor) { + } + + private static class RenderMap { + private final HashMap renderMap = new HashMap<>(); + + public RenderMap(ResourceLocation key, @NotNull BufferedImage image) { + int height = image.getHeight(); + + Color[] originalPixels = new Color[height]; + Color[] modifiedPixels = new Color[height]; + + for (int y = 0; y < height; y++) { + originalPixels[y] = new Color(image.getRGB(2, y)); + } + + int currentIndex = 0; + while (currentIndex < height) { + if (currentIndex >= 180) break; + + currentIndex += 2; + modifiedPixels[currentIndex] = originalPixels[currentIndex]; + currentIndex += 9; + if (height - currentIndex <= 3) { + break; + } + modifiedPixels[currentIndex] = originalPixels[currentIndex]; + currentIndex += 9; + } + + int index = 0; + for (Color color : modifiedPixels) { + if (color == null) continue; + BarColor c = convertToBarColor(color); + renderMap.put(key + "=" + (index - 1), c); + index++; + } + } + + public static BarColor convertToBarColor(@NotNull Color color) { + int rgb = color.getRGB(); + int red = (rgb >> 16) & 0xFF; + int green = (rgb >> 8) & 0xFF; + int blue = rgb & 0xFF; + + if (red > green && red > blue) { + if (red - green < 30) return BarColor.YELLOW; + return BarColor.RED; + } else if (green > red && green > blue) { + return BarColor.GREEN; + } else if (blue > red && blue > green) { + return BarColor.BLUE; + } else if (red == green && red == blue) { + return BarColor.WHITE; + } else if (red == green) { + return BarColor.YELLOW; + } else if (red == blue) { + return BarColor.PURPLE; + } else { + return BarColor.GREEN; + } + } + } + +} diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/Util.java b/origins/src/main/java/io/github/dueris/originspaper/util/Util.java index 582cb4a4a..18f1fcfba 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/Util.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/Util.java @@ -11,12 +11,12 @@ import com.mojang.serialization.DataResult; import com.mojang.serialization.DataResult.Error; import com.mojang.serialization.JsonOps; -import io.github.dueris.calio.parser.SerializableData; +import io.github.dueris.calio.data.SerializableData; import io.github.dueris.calio.util.ArgumentWrapper; import io.github.dueris.originspaper.OriginsPaper; -import io.github.dueris.originspaper.action.ActionTypeFactory; +import io.github.dueris.originspaper.action.factory.ActionTypeFactory; import io.github.dueris.originspaper.origin.Origin; -import io.github.dueris.originspaper.power.PowerType; +import io.github.dueris.originspaper.power.factory.PowerType; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntLists; @@ -27,14 +27,17 @@ import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.component.DataComponents; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.protocol.game.ClientboundExplodePacket; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.TicketType; +import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.TagKey; import net.minecraft.util.Mth; import net.minecraft.util.Tuple; @@ -51,26 +54,23 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.component.CustomData; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.Level; +import net.minecraft.world.level.*; import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.levelgen.Heightmap.Types; import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.Vec3; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.NamespacedKey; import org.bukkit.boss.BarColor; -import org.bukkit.configuration.ConfigurationSection; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.damage.CraftDamageSource; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.inventory.Inventory; -import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -83,9 +83,6 @@ import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; import java.util.*; import java.util.function.BiPredicate; import java.util.function.Consumer; @@ -96,7 +93,7 @@ import java.util.zip.ZipFile; public class Util { - private static final List SLOTS = net.minecraft.Util.make(new ArrayList<>(), list -> { + private static final List SLOTS = net.minecraft.Util.make(new LinkedList<>(), list -> { addSingleSlot(list, "contents", 0); addSlotRange(list, "container.", 0, 54); addSlotRange(list, "hotbar.", 0, 9); @@ -127,7 +124,6 @@ public class Util { addSlotRange(list, "player.crafting.", 500, 4); }); private static final List EXEMPT_SLOTS = List.of("weapon", "weapon.mainhand"); - public static Registry DAMAGE_REGISTRY = CraftRegistry.getMinecraftRegistry().registryOrThrow(Registries.DAMAGE_TYPE); public static MinecraftServer server = OriginsPaper.server; public static Logger LOGGER = LogManager.getLogger("OriginsPaper"); @@ -135,12 +131,14 @@ public static DamageSource getDamageSource(DamageType type) { return getDamageSource(type, null); } - public static DamageSource getDamageSource(DamageType type, Entity attacker) { + public static DamageSource getDamageSource(@NotNull DamageType type, Entity attacker) { DamageSource source = null; - for (ResourceKey dkey : DAMAGE_REGISTRY.registryKeySet()) { - if (DAMAGE_REGISTRY.get(dkey).equals(type)) { - source = new DamageSource(DAMAGE_REGISTRY.getHolderOrThrow(dkey), attacker, attacker, attacker == null ? null : attacker.position()); + Registry registry = CraftRegistry.getMinecraftRegistry().registryOrThrow(Registries.DAMAGE_TYPE); + for (ResourceKey dkey : registry.registryKeySet()) { + if (dkey == null) continue; + if (registry.get(dkey) == type) { + source = new DamageSource(registry.getHolderOrThrow(dkey), attacker, attacker, attacker == null ? null : attacker.position()); break; } } @@ -179,12 +177,12 @@ public static void addPositionedItemStack(@NotNull Inventory inventory, org.bukk public static String getNameOrTag(@NotNull PowerType power) { return PlainTextComponentSerializer.plainText().serialize(power.name()).equalsIgnoreCase(("power.$namespace.$path.name") - .replace("$namespace", power.key().getNamespace()).replace("$path", power.key().getPath())) ? power.getTag() : PlainTextComponentSerializer.plainText().serialize(power.name()); + .replace("$namespace", power.getId().getNamespace()).replace("$path", power.getId().getPath())) ? power.getTag() : PlainTextComponentSerializer.plainText().serialize(power.name()); } public static String getNameOrTag(@NotNull Origin origin) { - return PlainTextComponentSerializer.plainText().serialize(origin.name()).equalsIgnoreCase(("origin.$namespace.$path.name") - .replace("$namespace", origin.key().getNamespace()).replace("$path", origin.key().getPath())) ? origin.getTag() : PlainTextComponentSerializer.plainText().serialize(origin.name()); + return PlainTextComponentSerializer.plainText().serialize(origin.getName()).equalsIgnoreCase(("origin.$namespace.$path.name") + .replace("$namespace", origin.getId().getNamespace()).replace("$path", origin.getId().getPath())) ? origin.getTag() : PlainTextComponentSerializer.plainText().serialize(origin.getName()); } public static boolean inSnow(Level world, BlockPos... blockPositions) { @@ -199,7 +197,7 @@ public static boolean inSnow(Level world, BlockPos... blockPositions) { public static double apoli$getFluidHeightLoosely(Entity entity, TagKey tag) { if (tag == null) return 0; Optional>> fluidHeightMap = getFluidHeightMap(entity); - if (fluidHeightMap.isPresent() && fluidHeightMap.get() != null) { + if (fluidHeightMap.isPresent()) { Object2DoubleMap> fluidHeight = fluidHeightMap.get(); if (fluidHeight.containsKey(tag)) { return fluidHeight.getDouble(tag); @@ -219,7 +217,7 @@ public static boolean inSnow(Level world, BlockPos... blockPositions) { return false; } else { Optional>> submergedSet = getSubmergedSet(entity); - return submergedSet.isPresent() && submergedSet.get() != null && submergedSet.get().contains(tag); + return submergedSet.isPresent() && submergedSet.get().contains(tag); } } @@ -233,6 +231,7 @@ public static boolean areTagsEqual(TagKey tag1, TagKey tag2) { } } + @SuppressWarnings("unchecked") protected static Optional>> getFluidHeightMap(Entity entity) { try { return Optional.of(Reflector.accessField("fluidHeight", Entity.class, entity, Object2DoubleMap.class)); @@ -242,6 +241,7 @@ protected static Optional>> getFluidHeightMap(Ent } } + @SuppressWarnings("unchecked") protected static Optional>> getSubmergedSet(Entity entity) { try { return Optional.of(Reflector.accessField("fluidOnEyes", Entity.class, entity, Set.class)); @@ -277,55 +277,9 @@ public static boolean hasChangedBlockCoordinates(@NotNull Location fromLoc, @Not return builder.toString(); } - public static void downloadFileFromURL(String fileUrl) throws IOException { - URL url = new URL(fileUrl); - - try (BufferedInputStream in = new BufferedInputStream(url.openStream())) { - Path savePath = Path.of(System.getProperty("user.home"), "Downloads"); - Files.createDirectories(savePath); - String fileName = url.getFile().substring(url.getFile().lastIndexOf(47) + 1); - Path filePath = savePath.resolve(fileName); - Files.copy(in, filePath, StandardCopyOption.REPLACE_EXISTING); - } - } - - public static void downloadFileFromURL(String fileUrl, String saveDirectory) throws IOException { - URL url = new URL(fileUrl); - - try (BufferedInputStream in = new BufferedInputStream(url.openStream())) { - Path savePath = Path.of(saveDirectory); - Files.createDirectories(savePath); - Path filePath = savePath.resolve(getFileNameFromUrl(fileUrl)); - Files.copy(in, filePath, StandardCopyOption.REPLACE_EXISTING); - } - } - - public static void downloadFileFromURL(String fileUrl, String saveDirectory, String fileName) throws IOException { - URL url = new URL(fileUrl); - - try (BufferedInputStream in = new BufferedInputStream(url.openStream())) { - Path savePath = Path.of(saveDirectory); - Files.createDirectories(savePath); - Path filePath = savePath.resolve(fileName); - Files.copy(in, filePath, StandardCopyOption.REPLACE_EXISTING); - } - } - - public static PotionEffectType getPotionEffectType(String key) { - return key == null ? null : org.bukkit.Registry.EFFECT.get(NamespacedKey.fromString(key)); - } - - public static PotionEffectType getPotionEffectType(NamespacedKey key) { - return key == null ? null : org.bukkit.Registry.EFFECT.get(key); - } - - public static @NotNull String makeDescriptionId(String type, @Nullable ResourceLocation id) { - return id == null ? type + ".unregistered_sadface" : type + "." + id.getNamespace() + "." + id.getPath().replace('/', '.'); - } - @Unmodifiable public static @NotNull List collapseList(@NotNull Collection> collection) { - List lC = new ArrayList<>(); + List lC = new LinkedList<>(); collection.forEach(lC::addAll); return Collections.unmodifiableList(lC); } @@ -337,28 +291,6 @@ public static PotionEffectType getPotionEffectType(NamespacedKey key) { return Collections.unmodifiableSet(lC); } - @Contract(pure = true) - private static String getFileNameFromUrl(@NotNull String fileUrl) { - String[] segments = fileUrl.split("/"); - return segments[segments.length - 1]; - } - - public static void printValues(@NotNull ConfigurationSection section, String indent) { - StringBuilder values = new StringBuilder(); - - for (String key : section.getKeys(false)) { - String path = section.getCurrentPath() + "|" + key; - Object value = section.get(key); - if (value instanceof ConfigurationSection subsection) { - printValues(subsection, indent + " "); - } else { - values.append(indent).append(path).append(": ").append(value).append(" "); - } - } - - Bukkit.getLogger().info(values.toString()); - } - @Contract(value = "_, !null -> !null", pure = true) public static T getOrAbsent(@NotNull Optional optional, T absent) { return optional.orElse(absent); @@ -379,6 +311,34 @@ public static Optional createIfPresent(T instance) { return optional; } + public static boolean allPresent(SerializableData.Instance data, String @NotNull ... fieldNames) { + + for (String field : fieldNames) { + + if (!data.isPresent(field)) { + return false; + } + + } + + return true; + + } + + public static boolean anyPresent(SerializableData.Instance data, String @NotNull ... fields) { + + for (String field : fields) { + + if (data.isPresent(field)) { + return true; + } + + } + + return false; + + } + public static @NotNull JsonArray toJsonStringArray(@NotNull List strings) { JsonArray array = new JsonArray(); @@ -389,6 +349,62 @@ public static Optional createIfPresent(T instance) { return array; } + public static void createExplosion(Level world, Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType, ExplosionDamageCalculator behavior) { + createExplosion(world, null, pos, power, createFire, destructionType, behavior); + } + + public static void createExplosion(Level world, Entity entity, @NotNull Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType, ExplosionDamageCalculator behavior) { + createExplosion(world, entity, null, pos.x(), pos.y(), pos.z(), power, createFire, destructionType, behavior); + } + + public static void createExplosion(Level world, @Nullable Entity entity, @Nullable DamageSource damageSource, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ExplosionDamageCalculator behavior) { + + Explosion explosion = new Explosion(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE); + + explosion.explode(); + explosion.finalizeExplosion(world.isClientSide); + + // Sync the explosion effect to the client if the explosion is created on the server + if (!(world instanceof ServerLevel serverWorld)) { + return; + } + + if (!explosion.interactsWithBlocks()) { + explosion.clearToBlow(); + } + + for (ServerPlayer serverPlayerEntity : serverWorld.players()) { + if (serverPlayerEntity.distanceToSqr(x, y, z) < 4096.0) { + serverPlayerEntity.connection.send(new ClientboundExplodePacket(x, y, z, power, explosion.getToBlow(), explosion.getHitPlayers().get(serverPlayerEntity), explosion.getBlockInteraction(), explosion.getSmallExplosionParticles(), explosion.getLargeExplosionParticles(), explosion.getExplosionSound())); + } + } + + } + + @Nullable + public static ExplosionDamageCalculator getExplosionBehavior(Level world, float indestructibleResistance, @Nullable Predicate indestructibleCondition) { + return indestructibleCondition == null ? null : new ExplosionDamageCalculator() { + + @Override + public Optional getBlockExplosionResistance(Explosion explosion, BlockGetter blockView, BlockPos pos, BlockState blockState, FluidState fluidState) { + + BlockInWorld cachedBlockPosition = new BlockInWorld(world, pos, true); + + Optional defaultValue = super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState); + Optional newValue = indestructibleCondition.test(cachedBlockPosition) ? Optional.of(indestructibleResistance) : Optional.empty(); + + return defaultValue.isPresent() ? (newValue.isPresent() ? (defaultValue.get() > newValue.get() ? (defaultValue) : newValue) : defaultValue) : defaultValue; + + } + + @Override + public boolean shouldBlockExplode(Explosion explosion, BlockGetter blockView, BlockPos pos, BlockState state, float power) { + return !indestructibleCondition.test(new BlockInWorld(world, pos, true)); + } + + }; + } + public static Optional getEntityWithPassengers(Level world, EntityType entityType, @Nullable CompoundTag entityNbt, Vec3 pos, float yaw, float pitch) { return getEntityWithPassengers(world, entityType, entityNbt, pos, Optional.of(yaw), Optional.of(pitch)); } @@ -472,74 +488,6 @@ public static void unzip(String zipFilePath, String destDirectory) { } } - public static void fillMissingNumbers(List numbers, int min, int max) { - Set numberSet = new HashSet<>(numbers); - - for (int i = min; i <= max; i++) { - if (!numberSet.contains(i)) { - numbers.add(i); - } - } - } - - @Contract(pure = true) - public static int @NotNull [] missingNumbers(Integer @NotNull [] array, int minRange, int maxRange) { - boolean[] found = new boolean[maxRange - minRange + 1]; - int missingCount = 0; - Integer[] missingNumbers = array; - int index = array.length; - - for (int i = 0; i < index; i++) { - int num = missingNumbers[i]; - int adjustedIndex = num - minRange; - if (adjustedIndex >= 0 && adjustedIndex < found.length) { - found[adjustedIndex] = true; - } - } - - for (boolean val : found) { - if (!val) { - missingCount++; - } - } - - int[] missingNumbersx = new int[missingCount]; - index = 0; - - for (int ix = minRange; ix <= maxRange; ix++) { - int adjustedIndex = ix - minRange; - if (adjustedIndex >= 0 && adjustedIndex < found.length && !found[adjustedIndex]) { - missingNumbersx[index++] = ix; - } - } - - return missingNumbersx; - } - - public static BarColor convertToBarColor(java.awt.@NotNull Color color) { - int rgb = color.getRGB(); - int red = (rgb >> 16) & 0xFF; - int green = (rgb >> 8) & 0xFF; - int blue = rgb & 0xFF; - - if (red > green && red > blue) { - if (red - green < 30) return BarColor.YELLOW; - return BarColor.RED; - } else if (green > red && green > blue) { - return BarColor.GREEN; - } else if (blue > red && blue > green) { - return BarColor.BLUE; - } else if (red == green && red == blue) { - return BarColor.WHITE; - } else if (red == green) { - return BarColor.YELLOW; - } else if (red == blue) { - return BarColor.PURPLE; - } else { - return BarColor.GREEN; - } - } - @Contract(pure = true) public static double slope(double @NotNull [] p1, double @NotNull [] p2) { if (p2[0] - p1[0] == 0.0) { @@ -853,11 +801,11 @@ public static boolean slotNotWithinBounds(@NotNull Entity entity, int slot) { return new SlotAccess() { ItemStack stack = startingStack; - public ItemStack get() { + public @NotNull ItemStack get() { return this.stack; } - public boolean set(ItemStack stack) { + public boolean set(@NotNull ItemStack stack) { this.stack = stack; return true; } diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/WrappedBootstrapContext.java b/origins/src/main/java/io/github/dueris/originspaper/util/WrappedBootstrapContext.java index 1e859cbb1..868025b47 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/WrappedBootstrapContext.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/WrappedBootstrapContext.java @@ -1,38 +1,20 @@ package io.github.dueris.originspaper.util; -import com.google.common.io.Files; -import com.google.gson.JsonObject; import io.github.dueris.calio.registry.IRegistry; import io.github.dueris.calio.registry.Registrar; import io.github.dueris.calio.registry.RegistryKey; import io.github.dueris.calio.registry.impl.CalioRegistry; -import io.github.dueris.calio.util.holder.ObjectProvider; import io.papermc.paper.plugin.bootstrap.BootstrapContext; import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Tuple; -import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; - public class WrappedBootstrapContext { public final Logger LOGGER = LogManager.getLogger("ApoliBootstrapContext"); private final BootstrapContext context; private final IRegistry registry; - private final List registryPointers = new CopyOnWriteArrayList<>(); - private final ConcurrentHashMap, ResourceLocation>, JsonObject> registered = new ConcurrentHashMap<>(); public WrappedBootstrapContext(BootstrapContext context) { this.context = context; @@ -49,83 +31,6 @@ public void createRegistries(RegistryKey @NotNull ... keys) { } } - public void addDataDrivenPointer(@NotNull ResourceKey key) { - this.registryPointers.add(key.location().getPath()); - } - - public void registerData(@NotNull ResourceKey key, JsonObject data, ResourceLocation location) { - if (!this.registryPointers.contains(key.location().getPath())) { - this.registryPointers.add(key.location().getPath()); - } - - this.LOGGER.log(Level.INFO, "Registered new data for location: {}", location.getPath()); - this.registered.put(new Tuple<>(key, location), data); - } - - public void initRegistries(@NotNull Path datapackPath) { - LOGGER.log(Level.INFO, "Creating data-driven registries..."); - File data; - if (datapackPath.toFile().listFiles() == null) { - data = datapackPath.resolve("datapack").toFile(); - data.mkdirs(); - } else { - data = Arrays.stream(Objects.requireNonNull(Arrays.stream(datapackPath.toFile().listFiles()) - .filter(Objects::nonNull) - .filter(f -> { - return f.getName().equalsIgnoreCase("datapack"); - }).filter(File::isDirectory) - .findFirst().orElseThrow().listFiles())).filter(f -> { - return f.getName().equalsIgnoreCase("data"); - }).filter(File::isDirectory) - .findFirst().orElse(((ObjectProvider) () -> { - File d = datapackPath.resolve("datapack").toFile(); - d.mkdirs(); - return d; - }).get()); - } - - if (!data.exists()) { - data.mkdirs(); - } - - for (Tuple, ResourceLocation> key : this.registered.keySet()) { - String namespace = key.getB().getNamespace(); - String registryLocation = key.getA().location().getPath(); - File namespaceFile = new File(data, namespace); - if (!namespaceFile.exists()) { - namespaceFile.mkdirs(); - } - - File registryLocationFile = new File(namespaceFile, registryLocation); - if (!registryLocationFile.exists()) { - registryLocationFile.mkdirs(); - } - - File registryFile = new File(registryLocationFile, key.getB().getPath() + ".json"); - if (registryFile.exists()) { - try { - List lines = Files.readLines(registryFile, StandardCharsets.UTF_8); - String finishedLines = this.compileStrings(lines); - if (this.registered.get(key).toString().equalsIgnoreCase(finishedLines)) { - continue; - } - } catch (IOException var18) { - throw new RuntimeException(var18); - } - } - - try { - Files.write(this.registered.get(key).toString(), registryFile, StandardCharsets.UTF_8); - } catch (IOException var16) { - throw new RuntimeException(var16); - } finally { - this.LOGGER.log(Level.INFO, "Created registry entry ({}) for registry \"{}\"", key.getB().toString(), registryLocation); - } - } - - this.registered.clear(); - } - public void registerBuiltin(Registry registry, ResourceLocation location, T type) { Registry.register(registry, location, type); } @@ -137,10 +42,4 @@ public IRegistry registry() { public BootstrapContext context() { return this.context; } - - private @NotNull String compileStrings(@NotNull List strings) { - StringBuilder builder = new StringBuilder(); - strings.forEach(builder::append); - return builder.toString(); - } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/entity/GlowingEntitiesUtils.java b/origins/src/main/java/io/github/dueris/originspaper/util/entity/GlowingEntitiesUtils.java index a6dd2cfc0..412645c6a 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/entity/GlowingEntitiesUtils.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/entity/GlowingEntitiesUtils.java @@ -587,7 +587,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) byte newFlags = computeFlags(glowingData); if (newFlags != flags) { edited = true; - items = new ArrayList<>(items); + items = new LinkedList<>(items); // we cannot simply edit the item as it may be backed in the datawatcher, so we // make a copy of the list items.set(i, createFlagWatcherItem(newFlags)); @@ -611,7 +611,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) byte flags = computeFlags(glowingData); if (flags != 0) { edited = true; - items = new ArrayList<>(items); + items = new LinkedList<>(items); items.add(createFlagWatcherItem(flags)); } } diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/entity/PlayerManager.java b/origins/src/main/java/io/github/dueris/originspaper/util/entity/PlayerManager.java index 3b6253c91..2fdb1b5c2 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/entity/PlayerManager.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/entity/PlayerManager.java @@ -3,13 +3,16 @@ import io.github.dueris.calio.util.holder.ObjectProvider; import io.github.dueris.originspaper.OriginsPaper; import io.github.dueris.originspaper.event.PowerUpdateEvent; +import io.github.dueris.originspaper.origin.Origin; import io.github.dueris.originspaper.origin.OriginLayer; import io.github.dueris.originspaper.screen.GuiTicker; +import io.github.dueris.originspaper.storage.OriginComponent; import io.github.dueris.originspaper.storage.OriginConfiguration; import io.github.dueris.originspaper.storage.PlayerPowerRepository; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; import org.bukkit.NamespacedKey; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.util.CraftNamespacedKey; @@ -24,26 +27,27 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; +import java.util.LinkedList; public class PlayerManager implements Listener { - public static ArrayList firstJoin = new ArrayList<>(); - public static ArrayList playersLeaving = new ArrayList<>(); + public static LinkedList firstJoin = new LinkedList<>(); + public static LinkedList playersLeaving = new LinkedList<>(); private static @NotNull NamespacedKey identifier(String id) { return new NamespacedKey(OriginsPaper.getPlugin(), id); } @EventHandler( - priority = EventPriority.HIGHEST + priority = EventPriority.LOWEST ) public void playerJoin(@NotNull PlayerJoinEvent e) { final Player p = e.getPlayer(); + ServerPlayer nms = ((CraftPlayer) p).getHandle(); PlayerPowerRepository.getOrCreateRepo(((CraftPlayer) e.getPlayer()).getHandle()).readPowers( p.getPersistentDataContainer().has(identifier("powers")) ? p.getPersistentDataContainer().get(identifier("powers"), PersistentDataType.STRING) : ((ObjectProvider) () -> { firstJoin.add(p); return "{}"; - }).get() + }).get(), nms ); PersistentDataContainer data = p.getPersistentDataContainer(); if (data.has(identifier("shulker-box"), PersistentDataType.STRING)) { @@ -89,19 +93,20 @@ public void run() { }).runTaskLater(OriginsPaper.getPlugin(), OriginConfiguration.getConfiguration().getInt("choosing_delay")); OriginLayer originLayer = OriginsPaper.getLayer(ResourceLocation.parse("origins:origin")); if (!p.getPersistentDataContainer().has(identifier("updated")) - && !PowerHolderComponent.getOrigin(p, originLayer).equals(OriginsPaper.EMPTY_ORIGIN)) { - PowerHolderComponent.setOrigin( - p, originLayer, PowerHolderComponent.getOrigin(p, originLayer) + && !OriginComponent.getOrigin(p, originLayer).equals(Origin.EMPTY)) { + OriginComponent.setOrigin( + p, originLayer, OriginComponent.getOrigin(p, originLayer) ); p.getPersistentDataContainer().set(identifier("updated"), PersistentDataType.BOOLEAN, true); } } @EventHandler - public void playerQuitHandler(PlayerQuitEvent e) { + public void playerQuitHandler(@NotNull PlayerQuitEvent e) { playersLeaving.add(e.getPlayer()); e.getPlayer().saveData(); - String saveData = PlayerPowerRepository.getOrCreateRepo(((CraftPlayer) e.getPlayer()).getHandle()).serializePowers(new CompoundTag()).toString(); + ServerPlayer nms = ((CraftPlayer) e.getPlayer()).getHandle(); + String saveData = PlayerPowerRepository.getOrCreateRepo(nms).serializePowers(new CompoundTag(), nms).toString(); e.getPlayer().getPersistentDataContainer() .set(identifier("powers"), PersistentDataType.STRING, saveData); PowerHolderComponent.unloadPowers(e.getPlayer()); @@ -110,7 +115,7 @@ public void playerQuitHandler(PlayerQuitEvent e) { } @EventHandler - public void powerUpdate(PowerUpdateEvent e) { + public void powerUpdate(@NotNull PowerUpdateEvent e) { Player p = e.getPlayer(); p.setGravity(true); } diff --git a/origins/src/main/java/io/github/dueris/originspaper/util/entity/PowerUtils.java b/origins/src/main/java/io/github/dueris/originspaper/util/entity/PowerUtils.java index 396f9c039..bb7354b69 100644 --- a/origins/src/main/java/io/github/dueris/originspaper/util/entity/PowerUtils.java +++ b/origins/src/main/java/io/github/dueris/originspaper/util/entity/PowerUtils.java @@ -6,7 +6,8 @@ import com.google.gson.JsonPrimitive; import io.github.dueris.originspaper.OriginsPaper; import io.github.dueris.originspaper.origin.OriginLayer; -import io.github.dueris.originspaper.power.PowerType; +import io.github.dueris.originspaper.power.factory.PowerType; +import io.github.dueris.originspaper.registry.Registries; import io.github.dueris.originspaper.storage.PlayerPowerRepository; import io.github.dueris.originspaper.storage.PowerHolderComponent; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; @@ -17,47 +18,65 @@ import org.bukkit.persistence.PersistentDataType; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; import java.util.Set; public class PowerUtils { public static Gson GSON = new Gson(); public static void removePower(CommandSender executor, PowerType powerType, Player p, OriginLayer layer, boolean suppress) { - ArrayList powersToEdit = new ArrayList<>(); + LinkedList powersToEdit = new LinkedList<>(); powersToEdit.add(powerType); powersToEdit.addAll(PowerHolderComponent.getNestedPowerTypes(powerType)); - for (PowerType power : powersToEdit) { - if (PowerHolderComponent.hasPower(p, power.getTag())) { - PlayerPowerRepository.getOrCreateRepo(((CraftPlayer) p).getHandle()).removePower(power, layer); - PowerHolderComponent.unloadPower(p, power, layer, suppress, true); - if (!suppress) { - executor.sendMessage("Entity %name% had the power %power% removed" - .replace("%power%", PlainTextComponentSerializer.plainText().serialize(power.name())) - .replace("%name%", p.getName()) - ); + List layers = new LinkedList<>(); + if (layer != null) { + layers.add(layer); + } else { + layers.addAll(OriginsPaper.getRegistry().retrieve(Registries.LAYER).stream().toList()); + } + for (OriginLayer originLayer : layers) { + for (PowerType power : powersToEdit) { + if (PowerHolderComponent.hasPower(p, power.getTag())) { + PlayerPowerRepository.getOrCreateRepo(((CraftPlayer) p).getHandle()).removePower(power, originLayer); + PowerHolderComponent.unloadPower(p, power, originLayer, true); + if (!suppress) { + executor.sendMessage("Entity %name% had the power %power% removed" + .replace("%power%", PlainTextComponentSerializer.plainText().serialize(power.name())) + .replace("%name%", p.getName()) + ); + } } } } } public static void grantPower(CommandSender executor, PowerType powerType, Player p, OriginLayer layer, boolean suppress) { - ArrayList powersToEdit = new ArrayList<>(); + LinkedList powersToEdit = new LinkedList<>(); powersToEdit.add(powerType); powersToEdit.addAll(PowerHolderComponent.getNestedPowerTypes(powerType)); - for (PowerType power : powersToEdit) { - if (!PowerHolderComponent.hasPower(p, power.getTag())) { - PlayerPowerRepository.getOrCreateRepo(((CraftPlayer) p).getHandle()).addPower(power, layer); - PowerHolderComponent.loadPower(p, power, layer, suppress, true); - if (!suppress) { - executor.sendMessage("Entity %name% was granted the power %power%" - .replace("%power%", PlainTextComponentSerializer.plainText().serialize(power.name())) - .replace("%name%", p.getName()) - ); + List layers = new LinkedList<>(); + if (layer != null) { + layers.add(layer); + } else { + layers.addAll(OriginsPaper.getRegistry().retrieve(Registries.LAYER).stream().toList()); + } + for (OriginLayer originLayer : layers) { + for (PowerType power : powersToEdit) { + if (!PowerHolderComponent.hasPower(p, power.getTag())) { + PlayerPowerRepository.getOrCreateRepo(((CraftPlayer) p).getHandle()).addPower(power, originLayer); + PowerHolderComponent.loadPower(p, power, originLayer, true); + if (!suppress) { + executor.sendMessage("Entity %name% was granted the power %power%" + .replace("%power%", PlainTextComponentSerializer.plainText().serialize(power.name())) + .replace("%name%", p.getName()) + ); + } } } } + } public static void markGained(@NotNull PowerType power, @NotNull Player player) { diff --git a/origins/src/main/resources/assets/origins/blockstates/temporary_cobweb.json b/origins/src/main/resources/assets/origins/blockstates/temporary_cobweb.json index 1cf1f9acc..e6ff7040e 100644 --- a/origins/src/main/resources/assets/origins/blockstates/temporary_cobweb.json +++ b/origins/src/main/resources/assets/origins/blockstates/temporary_cobweb.json @@ -1,7 +1,5 @@ { - "variants": { - "": { - "model": "minecraft:block/cobweb" + "variants": { + "": { "model": "minecraft:block/cobweb" } } - } } diff --git a/origins/src/main/resources/assets/origins/lang/de_de.json b/origins/src/main/resources/assets/origins/lang/de_de.json deleted file mode 100644 index 54719d9f9..000000000 --- a/origins/src/main/resources/assets/origins/lang/de_de.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Mensch", - "origin.origins.human.description": "Ein gewöhnlicher Mensch. Dein normales Minecrafterlebnis erwartet dich.", - "origin.origins.merling.name": "Meerling", - "origin.origins.merling.description": "Diese ursprünglichen Bewohner des Ozeans sind es nicht gewohnt zu lange außerhalb des Wassers zu sein.", - "origin.origins.arachnid.name": "Arachnide", - "origin.origins.arachnid.description": "Ihre Kletterkünste und die Fähigkeit ihre Feinde in Spinnennetzen zu fangen machen die Arachniden zu perfekten Jägern.", - "origin.origins.blazeborn.name": "Lohenwesen", - "origin.origins.blazeborn.description": "Als entfernte Verwandte der Lohe besitzen Lohenwesen eine natürliche Immunität gegen die Gefahren des Nether.", - "origin.origins.avian.name": "Vogelwesen", - "origin.origins.avian.description": "Die Vogelwesen haben ihre Flugfähigkeit vor langer Zeit verloren. Heutzutage können diese friedliebenden Kreaturen dabei beobachtet werden wie sie von einem Platz zum nächsten gleiten.", - "origin.origins.phantom.name": "Phantom", - "origin.origins.phantom.description": "Als Kind eines Menschen und eines Phantoms können diese Kraturen zwischen ihrer normalen Gestalt und ihrer Phantomgestalt wechseln.", - "origin.origins.feline.name": "Samtpfote", - "origin.origins.feline.description": "Mit ihrem katzenartigen Aussehen schlagen die Samtpfoten Creeper in die Flucht. Mit der Geschicklichkeit einer Katze landen sie immer sicher auf ihren Füßen.", - "origin.origins.elytrian.name": "Elytraner", - "origin.origins.elytrian.description": "Da sie häufig mit den Winden herumfliegen, fühlen sich Elytraner unwohl, wenn sie nicht genug Platz über ihren Köpfen haben.", - "origin.origins.enderian.name": "Enderling", - "origin.origins.enderian.description": "Als Töchter und Söhne des Enderdrachen können sich Enderlinge teleportieren, nehmen jedoch Schaden im Wasser.", - "power.origins.water_breathing.name": "Kiemen", - "power.origins.water_breathing.description": "Du kannst unter Wasser atmen, jedoch nicht an Land.", - "power.origins.aqua_affinity.name": "Wasseraffinität", - "power.origins.aqua_affinity.description": "Du kannst Blöcke unter Wasser so problemlos zerstören wie andere an Land.", - "power.origins.water_vision.name": "Feuchte Augen", - "power.origins.water_vision.description": "Deine Sicht unter Wasser ist perfekt.", - "power.origins.swim_speed.name": "Flossen", - "power.origins.swim_speed.description": "Deine Geschwindigkeit unter Wasser ist erhöht.", - "power.origins.like_water.name": "Wie Wasser", - "power.origins.like_water.description": "Unter Wasser sinkst du nur zum Grund, wenn du es willst.", - "power.origins.fragile.name": "Fragil", - "power.origins.fragile.description": "Du hast 3 Lebensherzen weniger als Menschen.", - "power.origins.webbing.name": "Netz", - "power.origins.webbing.description": "Wenn du Gegner im Nahkampf schlägst, bleiben sie in einem Spinnennetz kleben.", - "power.origins.climbing.name": "Klettern", - "power.origins.climbing.description": "Du kannst jede Wand hochklettern, nicht nur Leitern.", - "power.origins.carnivore.name": "Fleischfresser", - "power.origins.carnivore.description": "Deine Ernährung beschränkt sich auf Fleisch, du kannst kein Gemüse essen.", - "power.origins.fire_immunity.name": "Feuerimmunität", - "power.origins.fire_immunity.description": "Du bist gegen sämtlichen Feuerschaden immun.", - "power.origins.nether_spawn.name": "Bewohner des Nethers", - "power.origins.nether_spawn.description": "Dein natürlicher Startpunkt ist im Nether.", - "power.origins.burning_wrath.name": "Flammender Zorn", - "power.origins.burning_wrath.description": "Deine Attacken machen mehr Schaden während du brennst.", - "power.origins.hotblooded.name": "Heißblut", - "power.origins.hotblooded.description": "Durch deinen heißen Körper verbrennen Gifte. Dadurch bist du immun zu Gift- und Hungereffekten.", - "power.origins.water_vulnerability.name": "Hydrophobie", - "power.origins.water_vulnerability.description": "Du nimmst mit der Zeit Schaden im Wasser.", - "power.origins.tailwind.name": "Rückenwind", - "power.origins.tailwind.description": "Zu Fuß bist du ein bisschen schneller unterwegs als andere.", - "power.origins.slow_falling.name": "Federgewicht", - "power.origins.slow_falling.description": "Du sinkst langsam wie eine Feder zum Boden, außer wenn du schleichst.", - "power.origins.vegetarian.name": "Vegetarier", - "power.origins.vegetarian.description": "Du kannst kein Fleisch verdauen.", - "power.origins.fresh_air.name": "Frische Luft", - "power.origins.fresh_air.description": "Zum Schlafen muss dein Bett sich auf einer Höhe von mindestens 86 Blöcken befinden, damit du frische Luft atmen kannst.", - "power.origins.phasing.name": "Schemenform", - "power.origins.phasing.description": "In der Phantomform kannst du durch festes Material, mit Ausnahme von Obsidian, laufen.", - "power.origins.invisibility.name": "Unsichtbarkeit", - "power.origins.invisibility.description": "In der Phantomform bist du unsichtbar.", - "power.origins.hunger_over_time.name": "Schneller Stoffwechsel", - "power.origins.hunger_over_time.description": "In der Phantomform zu sein macht dich hungrig.", - "power.origins.burn_in_daylight.name": "Lichtempfindlich", - "power.origins.burn_in_daylight.description": "Du fängst im Tageslicht an zu brennen, wenn du nicht unsichtbar bist.", - "power.origins.fall_immunity.name": "Akrobatik", - "power.origins.fall_immunity.description": "Du nimmst keinen Fallschaden, egal von welcher Höhe du fällst.", - "power.origins.sprint_jump.name": "Starke Knöchel", - "power.origins.sprint_jump.description": "Während du sprintest kannst du höher springen.", - "power.origins.nine_lives.name": "Neun Leben", - "power.origins.nine_lives.description": "Du hast ein Lebensherz weniger als Menschen.", - "power.origins.cat_vision.name": "Nachtaktiv", - "power.origins.cat_vision.description": "Du kannst etwas besser im Dunkeln sehen solange du nicht im Wasser bist.", - "power.origins.weak_arms.name": "Schwache Arme", - "power.origins.weak_arms.description": "Solange du nicht under dem Effekt eines Stärketranks stehst, kannst du nur natürliche Steine abbauen, wenn maximal 2 natürliche Steine angrenzen.", - "power.origins.scare_creepers.name": "Katzenähnliche Gestalt", - "power.origins.scare_creepers.description": "Creeper haben Angst vor dir und explodieren nur, wenn du sie zuerst angreifst.", - "power.origins.launch_into_air.name": "Geschenk der Winde", - "power.origins.launch_into_air.description": "Alle 30 Sekunden kannst du dich ungefähr 20 Blöcke in die Luft schießen.", - "power.origins.elytra.name": "Geflügelt", - "power.origins.elytra.description": "Du hast Elytren ohne sie ausrüsten zu müssen.", - "power.origins.light_armor.name": "Bedürfnis nach Bewegung", - "power.origins.light_armor.description": "Du kannst keine schwere Rüstung tragen (Rüstungswerte über denen von Kettenrüstung).", - "power.origins.claustrophobia.name": "Klaustrophobie", - "power.origins.claustrophobia.description": "Zu lange irgendwo mit einer niedrigen Decke zu sein wird dich schwächen und verlangsamen.", - "power.origins.more_kinetic_damage.name": "Brüchige Knochen", - "power.origins.more_kinetic_damage.description": "Du nimmst mehr Schaden vom Fallen und Fliegen gegen Blöcke.", - "power.origins.aerial_combatant.name": "Luftiger Kämpfer", - "power.origins.aerial_combatant.description": "Du machst deutlich mehr Schaden während du im Elytrenflug bist.", - "power.origins.throw_ender_pearl.name": "Teleportation", - "power.origins.throw_ender_pearl.description": "Wenn du willst, kannst du eine Enderperle, welche es dir erlaubt dich zu teleportieren und keinen Schaden macht, werfen.", - "power.origins.pumpkin_hate.name": "Angst vor Kürbissen", - "power.origins.pumpkin_hate.description": "Du hast Angst vor Kürbissen. Aus gutem Grund.", - "power.origins.extra_reach.name": "Feingliedriger Körper", - "power.origins.extra_reach.description": "Du kannst Blöcke und Wesen weiter weg erreichen.", - "category.origins": "Origins", - "key.origins.primary_active": "Aktive Fähigkeit", - "key.origins.view_origin": "Zeige Ursprung", - "item.origins.orb_of_origin": "Kugel des Ursprungs", - "enchantment.origins.water_protection": "Wasserschutz", - "origins.gui.select": "Auswählen", - "origins.gui.close": "Schließen", - "origins.gui.choose_origin.title": "Wähle deinen Ursprung", - "origins.gui.view_origin.title": "Dies ist dein Ursprung", - "origins.gui.impact.impact": "Auswirkung", - "origins.gui.impact.none": "Keine", - "origins.gui.impact.low": "Niedrig", - "origins.gui.impact.medium": "Mittel", - "origins.gui.impact.high": "Hoch", - "death.attack.no_water_for_gills": "%s hat es nicht geschafft nass zu bleiben.", - "death.attack.hurt_by_water": "%s hat zu lange gebadet.", - "commands.origin.origin_not_found": "Unbekannter Ursprung: %s", - "commands.origin.set.success.single": "Ursprung von %s wurde auf %s gesetzt.", - "commands.origin.set.success.multiple": "Ursprung von %s Zielen wurde auf %s gesetzt.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Related to Shulkers, the bodies of the Shulk are outfitted with a protective shell-like skin.", - "power.origins.shulker_inventory.name": "Hoarder", - "power.origins.shulker_inventory.description": "You have access to an additional 9 slots of inventory, which keep the items on death.", - "power.origins.natural_armor.name": "Sturdy Skin", - "power.origins.natural_armor.description": "Even without wearing armor, your skin provides natural protection.", - "power.origins.more_exhaustion.name": "Large Appetite", - "power.origins.more_exhaustion.description": "You exhaust much quicker than others, thus requiring you to eat more.", - "power.origins.no_shield.name": "Unwieldy", - "power.origins.no_shield.description": "The way your hands are formed provide no way of holding a shield upright.", - "power.origins.strong_arms.name": "Strong Arms", - "power.origins.strong_arms.description": "You are strong enough to break natural stones without using a pickaxe.", - "power.origins.translucent.name": "Translucent", - "power.origins.translucent.description": "Your skin is translucent.", - "power.origins.end_spawn.name": "End Inhabitant", - "power.origins.end_spawn.description": "Your journey begins in the End.", - "power.origins.master_of_webs.name": "Master of Webs", - "power.origins.master_of_webs.description": "You navigate cobweb perfectly, and are able to climb in them. When you hit an enemy in melee, they get stuck in cobweb for a while. Non-arthropods stuck in cobweb will be sensed by you. You are able to craft cobweb from string.", - "power.origins.lay_eggs.name": "Oviparous", - "power.origins.lay_eggs.description": "Whenever you wake up in the morning, you will lay an egg.", - "power.origins.phantomize.name": "Phantom Form", - "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", - "power.origins.like_air.name": "Like Air", - "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", - "power.origins.velvet_paws.name": "Velvet Paws", - "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", - "key.origins.secondary_active": "Active Power (Secondary)", - "text.autoconfig.origins.title": "Origins Configuration", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "component.item.origins.origin.layer": "Lets you choose a new %s.", - "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", - "container.shulker_inventory_power": "Shulker Inventory", - "origins.gui.choose": "Choose", - "origins.gui.view_origin.empty": "You can not have any Origins.", - "origins.gui.view_origin.not_installed": "The server does not have Origins installed.", - "origins.gui.version_mismatch": "This server is running a different version of Origins (v%1$s) which is incompatible with the one you have installed (v%2$s).", - "origins.gui.badge.active": "Active ability, use with %s.", - "origins.gui.badge.toggle": "Toggle with %s.", - "origins.gui.unbound_key": "§ounbound§r", - "origin.origins.random.name": "Random", - "origin.origins.random.description": "You'll be assigned one of the following:", - "layer.origins.origin.name": "Origin", - "origin.origins.empty.name": "Missing", - "origin.origins.empty.description": "You do not have an Origin.", - "death.attack.no_water_for_gills.player": "%1$s didn't manage to keep wet because they were fighting %2$s", - "death.attack.hurt_by_water.player": "%1$s was put underwater by %2$s", - "death.attack.genericDamageOverTime": "%1$s died to a damage over time effect", - "death.attack.genericDamageOverTime.player": "%1$s died to a damage over time effect whilst fighting %2$s", - "commands.origin.get.result": "%s has the following %s: %s (%s)", - "commands.origin.gui.all": "Opened the selection GUI for %s players.", - "commands.origin.gui.layer": "Opened the \"%2$s\" selection GUI for %1$s players.", - "origins.avian_sleep_fail": "You need fresh air to sleep", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/en_us.json b/origins/src/main/resources/assets/origins/lang/en_us.json index 188c5350b..9b5ca63b1 100644 --- a/origins/src/main/resources/assets/origins/lang/en_us.json +++ b/origins/src/main/resources/assets/origins/lang/en_us.json @@ -1,136 +1,200 @@ { "origin.origins.human.name": "Human", "origin.origins.human.description": "A regular human. Your ordinary Minecraft experience awaits.", + "origin.origins.merling.name": "Merling", "origin.origins.merling.description": "These natural inhabitants of the ocean are not used to being out of the water for too long.", + "origin.origins.arachnid.name": "Arachnid", "origin.origins.arachnid.description": "Their climbing abilities and the ability to trap their foes in spiderweb make the Arachnid perfect hunters.", + "origin.origins.blazeborn.name": "Blazeborn", "origin.origins.blazeborn.description": "Late descendants of the Blaze, the Blazeborn are naturally immune to the perils of the Nether.", + "origin.origins.avian.name": "Avian", "origin.origins.avian.description": "The Avian race has lost their ability to fly a long time ago. Now these peaceful creatures can be seen gliding from one place to another.", + "origin.origins.phantom.name": "Phantom", "origin.origins.phantom.description": "As half-human and half-phantom beings, these creatures can switch between a Phantom and a normal form.", + "origin.origins.feline.name": "Feline", "origin.origins.feline.description": "With their cat-like appearance, the Feline scare creepers away. With the dexterity of cats, they always land safely on their feet.", + "origin.origins.elytrian.name": "Elytrian", "origin.origins.elytrian.description": "Often flying around in the winds, Elytrians are uncomfortable when they don't have enough space above their head.", + "origin.origins.enderian.name": "Enderian", "origin.origins.enderian.description": "Born as children of the Ender Dragon, Enderians are capable of teleporting but are vulnerable to water.", + "origin.origins.shulk.name": "Shulk", "origin.origins.shulk.description": "Related to Shulkers, the bodies of the Shulk are outfitted with a protective shell-like skin.", + "power.origins.water_breathing.name": "Gills", "power.origins.water_breathing.description": "You can breathe underwater, but not on land.", + "power.origins.aqua_affinity.name": "Aqua Affinity", "power.origins.aqua_affinity.description": "You may break blocks underwater as others do on land.", + "power.origins.water_vision.name": "Wet Eyes", "power.origins.water_vision.description": "Your vision underwater is perfect.", + "power.origins.swim_speed.name": "Fins", "power.origins.swim_speed.description": "Your underwater speed is increased.", + "power.origins.like_water.name": "Like Water", "power.origins.like_water.description": "When underwater, you do not sink to the ground unless you want to.", + "power.origins.fragile.name": "Fragile", "power.origins.fragile.description": "You have 3 less hearts of health than humans.", + "power.origins.webbing.name": "Webbing", "power.origins.webbing.description": "When you hit an enemy in melee, they get stuck in cobweb.", + "power.origins.climbing.name": "Climbing", "power.origins.climbing.description": "You are able to climb up any kind of wall, not just ladders.", + "power.origins.carnivore.name": "Carnivore", "power.origins.carnivore.description": "Your diet is restricted to meat, you can't eat vegetables.", + "power.origins.fire_immunity.name": "Fire Immunity", "power.origins.fire_immunity.description": "You are immune to all types of fire damage.", + "power.origins.nether_spawn.name": "Nether Inhabitant", "power.origins.nether_spawn.description": "Your natural spawn will be in the Nether.", + "power.origins.burning_wrath.name": "Burning Wrath", "power.origins.burning_wrath.description": "When on fire, you deal additional damage with your attacks.", + "power.origins.hotblooded.name": "Hotblooded", "power.origins.hotblooded.description": "Due to your hot body, venoms burn up, making you immune to poison and hunger status effects.", + "power.origins.water_vulnerability.name": "Hydrophobia", "power.origins.water_vulnerability.description": "You receive damage over time while in contact with water.", + "power.origins.tailwind.name": "Tailwind", "power.origins.tailwind.description": "You are a little bit quicker on foot than others.", + "power.origins.slow_falling.name": "Featherweight", "power.origins.slow_falling.description": "You fall as gently to the ground as a feather would, unless you sneak.", + "power.origins.vegetarian.name": "Vegetarian", "power.origins.vegetarian.description": "You can't digest any meat.", + "power.origins.fresh_air.name": "Fresh Air", "power.origins.fresh_air.description": "When sleeping, your bed needs to be at an altitude of at least 86 blocks, so you can breathe fresh air.", + "power.origins.phasing.name": "Phasing", "power.origins.phasing.description": "While phantomized, you can walk through solid material, except Obsidian.", + "power.origins.invisibility.name": "Invisibility", "power.origins.invisibility.description": "While phantomized, you are invisible.", + "power.origins.hunger_over_time.name": "Fast Metabolism", "power.origins.hunger_over_time.description": "Being phantomized causes you to become hungry.", + "power.origins.burn_in_daylight.name": "Photoallergic", "power.origins.burn_in_daylight.description": "You begin to burn in daylight if you are not invisible.", + "power.origins.fall_immunity.name": "Acrobatics", "power.origins.fall_immunity.description": "You never take fall damage, no matter from which height you fall.", + "power.origins.sprint_jump.name": "Strong Ankles", "power.origins.sprint_jump.description": "You are able to jump higher by jumping while sprinting.", + "power.origins.nine_lives.name": "Nine Lives", "power.origins.nine_lives.description": "You have 1 less heart of health than humans.", + "power.origins.cat_vision.name": "Nocturnal", "power.origins.cat_vision.description": "You can slightly see in the dark when not in water.", + "power.origins.weak_arms.name": "Weak Arms", "power.origins.weak_arms.description": "When not under the effect of a strength potion, you can only mine natural stone if there are at most 2 other natural stone blocks adjacent to it.", + "power.origins.scare_creepers.name": "Catlike Appearance", "power.origins.scare_creepers.description": "Creepers are scared of you and will only explode if you attack them first.", + "power.origins.launch_into_air.name": "Gift of the Winds", "power.origins.launch_into_air.description": "Every 30 seconds, you are able to launch about 20 blocks up into the air.", + "power.origins.elytra.name": "Winged", "power.origins.elytra.description": "You have Elytra wings without needing to equip any.", + "power.origins.light_armor.name": "Need for Mobility", "power.origins.light_armor.description": "You can not wear any heavy armor (armor with protection values higher than chainmail).", + "power.origins.claustrophobia.name": "Claustrophobia", "power.origins.claustrophobia.description": "Being somewhere with a low ceiling for too long will weaken you and make you slower.", + "power.origins.more_kinetic_damage.name": "Brittle Bones", "power.origins.more_kinetic_damage.description": "You take more damage from falling and flying into blocks.", + "power.origins.aerial_combatant.name": "Aerial Combatant", "power.origins.aerial_combatant.description": "You deal substantially more damage while in Elytra flight.", + "power.origins.throw_ender_pearl.name": "Teleportation", "power.origins.throw_ender_pearl.description": "Whenever you want, you may throw an ender pearl which deals no damage, allowing you to teleport.", + "power.origins.pumpkin_hate.name": "Scared of Gourds", "power.origins.pumpkin_hate.description": "You are afraid of pumpkins. For a good reason.", + "power.origins.extra_reach.name": "Slender Body", "power.origins.extra_reach.description": "You can reach blocks and entities further away.", + "power.origins.shulker_inventory.name": "Hoarder", "power.origins.shulker_inventory.description": "You have access to an additional 9 slots of inventory, which keep the items on death.", + "power.origins.natural_armor.name": "Sturdy Skin", "power.origins.natural_armor.description": "Even without wearing armor, your skin provides natural protection.", + "power.origins.more_exhaustion.name": "Large Appetite", "power.origins.more_exhaustion.description": "You exhaust much quicker than others, thus requiring you to eat more.", + "power.origins.no_shield.name": "Unwieldy", "power.origins.no_shield.description": "The way your hands are formed provide no way of holding a shield upright.", + "power.origins.strong_arms.name": "Strong Arms", "power.origins.strong_arms.description": "You are strong enough to break natural stones without using a pickaxe.", + "power.origins.translucent.name": "Translucent", "power.origins.translucent.description": "Your skin is translucent.", + "power.origins.end_spawn.name": "End Inhabitant", "power.origins.end_spawn.description": "Your journey begins in the End.", + "power.origins.master_of_webs.name": "Master of Webs", "power.origins.master_of_webs.description": "You navigate cobweb perfectly, and are able to climb in them. When you hit an enemy in melee, they get stuck in cobweb for a while. Non-arthropods stuck in cobweb will be sensed by you. You are able to craft cobweb from string.", + "power.origins.lay_eggs.name": "Oviparous", "power.origins.lay_eggs.description": "Whenever you wake up in the morning, you will lay an egg.", + "power.origins.phantomize.name": "Phantom Form", "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", + "power.origins.like_air.name": "Like Air", "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", + "power.origins.velvet_paws.name": "Velvet Paws", "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", + "category.origins": "Origins", "key.origins.primary_active": "Active Power (Primary)", "key.origins.secondary_active": "Active Power (Secondary)", "key.origins.view_origin": "View Origin", + "text.autoconfig.origins.title": "Origins Configuration", "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", + "item.origins.orb_of_origin": "Orb of Origin", "component.item.origins.origin.layer": "Lets you choose a new %s.", "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", "component.item.origins.origin.generic": "Lets you choose origin(s).", + "enchantment.origins.water_protection": "Water Protection", + "container.shulker_inventory_power": "Shulker Inventory", + "origins.gui.select": "Select", "origins.gui.close": "Close", "origins.gui.choose": "Choose", @@ -144,22 +208,28 @@ "origins.gui.impact.medium": "Medium", "origins.gui.impact.high": "High", "origins.gui.version_mismatch": "This server is running a different version of Origins (v%1$s) which is incompatible with the one you have installed (v%2$s).", + "origins.gui.badge.active": "Active ability, use with %s.", "origins.gui.badge.toggle": "Toggle with %s.", "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (shaped):", "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (shapeless):", + "origins.gui.unbound_key": "§ounbound§r", + "origin.origins.random.name": "Random", "origin.origins.random.description": "You'll be assigned one of the following:", + "layer.origins.origin.name": "Origin", "origin.origins.empty.name": "Missing", "origin.origins.empty.description": "You do not have an Origin.", + "death.attack.no_water_for_gills": "%1$s didn't manage to keep wet", "death.attack.no_water_for_gills.player": "%1$s didn't manage to keep wet because they were fighting %2$s", "death.attack.hurt_by_water": "%1$s took a bath for too long", "death.attack.hurt_by_water.player": "%1$s was put underwater by %2$s", "death.attack.genericDamageOverTime": "%1$s died to a damage over time effect", "death.attack.genericDamageOverTime.player": "%1$s died to a damage over time effect whilst fighting %2$s", + "commands.origin.origin_not_found": "Unknown origin: %s", "commands.origin.layer_not_found": "Unknown layer: %s", "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", @@ -172,5 +242,79 @@ "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s", "commands.origin.set.success.multiple": "Set origin of %s targets in layer %s to %s", "commands.origin.set.success.single": "Set origin of %s in layer %s to %s.", - "origins.avian_sleep_fail": "You need fresh air to sleep" + + "origins.avian_sleep_fail": "You need fresh air to sleep", + + "apoli.gui.version_mismatch": "This server is running a different version of Apoli (v%1$s) which is incompatible with the one you have installed (v%2$s).", + "argument.apoli.power_holder.not_found.multiple": "No living entities were found", + "argument.apoli.power_holder.not_found.single": "Entity %s is not a living entity", + "category.apoli": "Apoli", + "commands.apoli.clear.fail.multiple": "No entity had any power to clear.", + "commands.apoli.clear.fail.single": "Entity %s did not have any power to clear.", + "commands.apoli.clear.success.multiple": "%s entities had in total %s powers cleared.", + "commands.apoli.clear.success.single": "Entity %s had %s powers cleared.", + "commands.apoli.grant.fail.multiple": "All %s entities already had the power %s from source %s.", + "commands.apoli.grant.fail.single": "Entity %s already had the power %s from source %s.", + "commands.apoli.grant.success.multiple": "%s entities were granted the power %s.", + "commands.apoli.grant.success.single": "Entity %s was granted the power %s.", + "commands.apoli.grant_from_source.success.multiple": "%s entities were granted the power %s from source %s.", + "commands.apoli.grant_from_source.success.single": "Entity %s was granted the power %s from source %s.", + "commands.apoli.list.fail": "Entity %s did not have any powers.", + "commands.apoli.list.pass": "Entity %s has %s powers: [%s]", + "commands.apoli.list.sources": "Sources: [%s]", + "commands.apoli.power_not_found": "Unknown power: %s", + "commands.apoli.remove.fail.multiple": "No entity had the power %s.", + "commands.apoli.remove.fail.single": "Entity %s did not have the power %s.", + "commands.apoli.remove.success.multiple": "%s entities had the power %s removed.", + "commands.apoli.remove.success.single": "Entity %s had the power %s removed.", + "commands.apoli.revoke.fail.multiple": "No entity had the power %s from source %s.", + "commands.apoli.revoke.fail.single": "Entity %s did not have the power %s from source %s.", + "commands.apoli.revoke.success.multiple": "%s entities had the power %s revoked.", + "commands.apoli.revoke.success.single": "Entity %s had the power %s revoked.", + "commands.apoli.revoke_all.fail.multiple": "No entity had any power from source %s.", + "commands.apoli.revoke_all.fail.single": "Entity %s did not have any power from source %s.", + "commands.apoli.revoke_all.success.multiple": "%s entities had %s powers revoked from source %s.", + "commands.apoli.revoke_all.success.single": "Entity %s had %s powers revoked from source %s.", + "commands.apoli.revoke_from_source.success.multiple": "%s entities had the power %s revoked from source %s.", + "commands.apoli.revoke_from_source.success.single": "Entity %s had the power %s revoked from source %s.", + "commands.apoli.sources.fail": "Entity %s did not have the power %s.", + "commands.apoli.sources.pass": "Entity %s has %s sources of power %s: [%s]", + "key.apoli.usability_hint.show_powers": "Show Powers in Usability Hints", + "text.apoli.cannot_sleep": "You cannot sleep", + "text.autoconfig.power_config.option.executeCommand": "Execute Command", + "text.autoconfig.power_config.option.executeCommand.permissionLevel": "Permission Level", + "text.autoconfig.power_config.option.executeCommand.showOutput": "Show Output in Chat", + "text.autoconfig.power_config.option.modifyPlayerSpawnPower": "Modify Player Spawn Power", + "text.autoconfig.power_config.option.modifyPlayerSpawnPower.horizontalBlockCheckInterval": "Search Block (Horizontal) Interval", + "text.autoconfig.power_config.option.modifyPlayerSpawnPower.radius": "Search Radius", + "text.autoconfig.power_config.option.modifyPlayerSpawnPower.verticalBlockCheckInterval": "Search Block (Vertical) Interval", + "text.autoconfig.power_config.option.resourcesAndCooldowns": "Resources & Cooldowns", + "text.autoconfig.power_config.option.resourcesAndCooldowns.hudOffsetX": "HUD Offset X", + "text.autoconfig.power_config.option.resourcesAndCooldowns.hudOffsetY": "HUD Offset Y", + "text.autoconfig.power_config.option.tooltips": "Tooltips", + "text.autoconfig.power_config.option.tooltips.compactUsabilityHints": "Compact Usability Hints", + "text.autoconfig.power_config.option.tooltips.showUsabilityHints": "Show Usability Hints", + "text.autoconfig.power_config.title": "Apoli Power Config", + "tooltip.apoli.stack_power.description": " %s", + "tooltip.apoli.stack_power.name": "+ %s (Power)", + "tooltip.apoli.unusable.block.multiple": "Unusable (%s)", + "tooltip.apoli.unusable.block.single": "Unusable (%s)", + "tooltip.apoli.unusable.bow.multiple": "Unusable (%s)", + "tooltip.apoli.unusable.bow.single": "Unusable (%s)", + "tooltip.apoli.unusable.crossbow.multiple": "Unusable (%s)", + "tooltip.apoli.unusable.crossbow.single": "Unusable (%s)", + "tooltip.apoli.unusable.drink.multiple": "Undrinkable (%s)", + "tooltip.apoli.unusable.drink.single": "Undrinkable (%s)", + "tooltip.apoli.unusable.eat.multiple": "Inedible (%s)", + "tooltip.apoli.unusable.eat.single": "Inedible (%s)", + "tooltip.apoli.unusable.none.multiple": "Unusable (%s)", + "tooltip.apoli.unusable.none.single": "Unusable (%s)", + "tooltip.apoli.unusable.spear.multiple": "Unusable (%s)", + "tooltip.apoli.unusable.spear.single": "Unusable (%s)", + "tooltip.apoli.unusable.spyglass.multiple": "Unusable (%s)", + "tooltip.apoli.unusable.spyglass.single": "Unusable (%s)", + "tooltip.apoli.unusable.toot_horn.multiple": "Untootable (%s)", + "tooltip.apoli.unusable.toot_horn.single": "Untootable (%s)", + "tooltip.apoli.usability_hint.power_count": "%s powers", + "tooltip.apoli.usability_hint.show_powers": "Hold [%s] to show the powers" } diff --git a/origins/src/main/resources/assets/origins/lang/es_ar.json b/origins/src/main/resources/assets/origins/lang/es_ar.json deleted file mode 100644 index 1c23b20bb..000000000 --- a/origins/src/main/resources/assets/origins/lang/es_ar.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Humano", - "origin.origins.human.description": "Un ser humano común y corriente. Una aventura normal te espera.", - "origin.origins.merling.name": "Tritón", - "origin.origins.merling.description": "Estos habitantes del océano no están acostumbrados a estar fuera del agua por mucho tiempo.", - "origin.origins.arachnid.name": "Arácnido", - "origin.origins.arachnid.description": "Sus habilidades trepadoras y la habilidad de atrapar a sus oponentes en telaraña les hacen grandes cazadores.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "Descendientes de los Blazes. Son naturalmente inmunes a los peligros del Nether.", - "origin.origins.avian.name": "Aviar", - "origin.origins.avian.description": "La raza Aviar ha perdido la habilidad de volar hace mucho tiempo. Ahora se puede ver a estas pacificas criaturas planeando de un lugar a otro.", - "origin.origins.phantom.name": "Fantasma", - "origin.origins.phantom.description": "Mitad Humanos y mitad Fantasmas, estas criaturas pueden cambiar entre su forma normal y Fantasma a su antojo.", - "origin.origins.feline.name": "Felino", - "origin.origins.feline.description": "Con su aspecto gatuno, pueden asustar a los Creepers. Gracias a su destreza felina siempre caen de pie y sin ningún daño.", - "origin.origins.elytrian.name": "Elitria", - "origin.origins.elytrian.description": "Usualmente volando con el viento, los Elitrias se incomodan cuando no tienen suficiente espacio para volar.", - "origin.origins.enderian.name": "Enderianos", - "origin.origins.enderian.description": "Nacidos del Ender Dragon, los Enderianos son capaces de teletransportarse, pero son heridos por el agua.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Relacionados a los Shulkers, los cuerpos de esta especie están cubiertos por una piel tan dura como una armadura.", - "power.origins.water_breathing.name": "Branquias", - "power.origins.water_breathing.description": "Puedes respirar en el agua, pero no en tierra firme.", - "power.origins.aqua_affinity.name": "Afinidad Acuática", - "power.origins.aqua_affinity.description": "Puedes romper bloques bajo el agua a la misma velocidad que otros en tierra.", - "power.origins.water_vision.name": "Ojos Húmedos", - "power.origins.water_vision.description": "Tu visión bajo el agua es perfecta.", - "power.origins.swim_speed.name": "Aletas", - "power.origins.swim_speed.description": "Tu velocidad de nado es mayor que la de otros orígenes.", - "power.origins.like_water.name": "Como el Agua", - "power.origins.like_water.description": "Cuando estás bajo el agua, no te hundes como los demás.", - "power.origins.fragile.name": "Frágil", - "power.origins.fragile.description": "Tienes 3 corazones menos.", - "power.origins.webbing.name": "Tejedor", - "power.origins.webbing.description": "Cuando golpeas a un oponente, quedan atrapados en telaraña.", - "power.origins.climbing.name": "Trepador", - "power.origins.climbing.description": "Eres capaz de escalar cualquier tipo de pared, no sólo escaleras.", - "power.origins.carnivore.name": "Carnívoro", - "power.origins.carnivore.description": "Tu dieta se compone exclusivamente de carne, no puedes digerir vegetales.", - "power.origins.fire_immunity.name": "Inmunidad al Fuego", - "power.origins.fire_immunity.description": "Eres inmune a cualquier tipo de daño por fuego.", - "power.origins.nether_spawn.name": "Habitante del Nether", - "power.origins.nether_spawn.description": "Tu Spawn predeterminado es el Nether.", - "power.origins.burning_wrath.name": "Ira Ardiente", - "power.origins.burning_wrath.description": "Cuando estás ardiendo, haces más daño.", - "power.origins.hotblooded.name": "Sangre Caliente", - "power.origins.hotblooded.description": "Gracias a tu temperatura corporal, el veneno se neutraliza en su sangre, haciéndote inmune a cualquier tipo de efecto venenoso.", - "power.origins.water_vulnerability.name": "Hidrofobia", - "power.origins.water_vulnerability.description": "Recibes daño al entrar en contacto con el agua.", - "power.origins.tailwind.name": "Pie Veloz", - "power.origins.tailwind.description": "Eres un poco más veloz que los otros orígenes.", - "power.origins.slow_falling.name": "Como una Pluma", - "power.origins.slow_falling.description": "Caes lenta y grácilmente como una pluma.", - "power.origins.vegetarian.name": "Vegetariano", - "power.origins.vegetarian.description": "No puedes digerir carnes.", - "power.origins.fresh_air.name": "Aire Fresco", - "power.origins.fresh_air.description": "Para dormir, debes tener tu cama a al menos 86 bloques de altura, para poder respirar aire fresco.", - "power.origins.phasing.name": "Intangible", - "power.origins.phasing.description": "Cuando te conviertes en Fantasma, puedes traspasar cualquier tipo de material, exceptuando Obsidiana y Piedra Base.", - "power.origins.invisibility.name": "Invisibilidad", - "power.origins.invisibility.description": "Cuando te conviertes en Fantasma, eres invisible.", - "power.origins.hunger_over_time.name": "Metabolismo Rápido", - "power.origins.hunger_over_time.description": "Cuando te conviertes en Fantasma te da hambre más rápido.", - "power.origins.burn_in_daylight.name": "Fotoalérgico", - "power.origins.burn_in_daylight.description": "Te empiezas a quemar por el sol si no estás convertido en Fantasma.", - "power.origins.fall_immunity.name": "Acrobacias", - "power.origins.fall_immunity.description": "No recibes daño por caída, sin importar la altura.", - "power.origins.sprint_jump.name": "Tobillos Fuertes", - "power.origins.sprint_jump.description": "Saltas más alto mientras corres.", - "power.origins.nine_lives.name": "Nueve Vidas", - "power.origins.nine_lives.description": "Tienes 1 corazón menos que los humanos.", - "power.origins.cat_vision.name": "Nocturno", - "power.origins.cat_vision.description": "Puedes ver un poco en la oscuridad, a menos que estés en el agua.", - "power.origins.weak_arms.name": "Brazos Débiles", - "power.origins.weak_arms.description": "A menos que estés bajo el efecto de una Poción de Fuerza, sólo puedes minar piedras naturales si tiene menos de 2 otros bloques de piedra adyacentes.", - "power.origins.scare_creepers.name": "Aspecto Felino", - "power.origins.scare_creepers.description": "Los Creepers te tienen miedo y solo explotarán si les atacas.", - "power.origins.launch_into_air.name": "Bendición del Viento", - "power.origins.launch_into_air.description": "Cada 30 Segundos, puedes lanzarte hasta 20 bloques en el aire.", - "power.origins.elytra.name": "Alado", - "power.origins.elytra.description": "Tienes Élitros sin tener que equiparte nada.", - "power.origins.light_armor.name": "Necesidad de Movilidad", - "power.origins.light_armor.description": "No puedes llevar armadura pesada (Armaduras con más protección que cota de mallas).", - "power.origins.claustrophobia.name": "Claustrofobia", - "power.origins.claustrophobia.description": "Estar bajo techo por mucho tiempo te dará Lentitud y Debilidad.", - "power.origins.more_kinetic_damage.name": "Huesos Frágiles", - "power.origins.more_kinetic_damage.description": "Te haces más daño al caer y por chocar volando.", - "power.origins.aerial_combatant.name": "Guerrero Aéreo", - "power.origins.aerial_combatant.description": "Haces más daño al volar con Élitros.", - "power.origins.throw_ender_pearl.name": "Teletransportación", - "power.origins.throw_ender_pearl.description": "Te puedes teletransportar cuando quieras lanzando una Perla de Ender sin hacerte daño.", - "power.origins.pumpkin_hate.name": "Cucurbitofobia", - "power.origins.pumpkin_hate.description": "Le tienes miedo a las calabazas, por buenos motivos.", - "power.origins.extra_reach.name": "Cuerpo Esbelto", - "power.origins.extra_reach.description": "Puede alcanzar bloques y mobs de más lejos.", - "power.origins.shulker_inventory.name": "Acumulador", - "power.origins.shulker_inventory.description": "Tienes 9 espacios de inventario extra, los cuales se mantienen después de morir.", - "power.origins.natural_armor.name": "Armadura Natural", - "power.origins.natural_armor.description": "Incluso sin armadura, tu piel te proporciona protección.", - "power.origins.more_exhaustion.name": "Gran Apetito", - "power.origins.more_exhaustion.description": "Te da hambre más rápido.", - "power.origins.no_shield.name": "Manos Deformes", - "power.origins.no_shield.description": "La forma de tus manos no te permite cubrirte con escudos.", - "power.origins.strong_arms.name": "Brazos Fuertes", - "power.origins.strong_arms.description": "Eres lo suficientemente fuerte como para romper piedra con tus manos.", - "power.origins.translucent.name": "Transparente", - "power.origins.translucent.description": "Tu piel es transparente.", - "power.origins.end_spawn.name": "Habitante del End", - "power.origins.end_spawn.description": "Tu aventura empieza en el End.", - "power.origins.master_of_webs.name": "Maestro de redes", - "power.origins.master_of_webs.description": "Puedes pasar a través de telarañas sin problemas y puedes hasta escalarlas. Cuando golpeas a un enemigo cuerpo a cuerpo, se quedará atrapado en una telaraña por un rato. Mobs no-artrópodos que se queden atrapados en telarañas serán más fáciles de ver para ti. Puedes fabricar telaraña con hilo.", - "power.origins.lay_eggs.name": "Ovíparo", - "power.origins.lay_eggs.description": "Todas las mañanas cuando despiertes, pondrás un huevo.", - "power.origins.phantomize.name": "Forma Fantasma", - "power.origins.phantomize.description": "Puedes cambiar entre forma fantasma y humana a voluntad, pero si te agotas lo suficiente para no poder correr, vuelves a tu forma humana.", - "power.origins.like_air.name": "Como el Viento", - "power.origins.like_air.description": "Tu velocidad en la tierra se mantiene igual en el aire.", - "power.origins.velvet_paws.name": "Patas Acolchadas", - "power.origins.velvet_paws.description": "Las almohadillas en tus patas hacen que tus pisadas no causen vibraciones, lo que hace que no te puedan detectar los Sensores de Sculk.", - "category.origins": "Orígenes", - "key.origins.primary_active": "Poder Activo (Principal)", - "key.origins.secondary_active": "Poder Activo (Secundario)", - "key.origins.view_origin": "Ver Origen", - "text.autoconfig.origins.title": "Origins Configuration", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "item.origins.orb_of_origin": "Orbe de Orígenes", - "component.item.origins.origin.layer": "Te deja escoger un nuevo %s.", - "component.item.origins.origin.layer_and_origin": "Asigna tu %1$s a \"%2$s\".", - "enchantment.origins.water_protection": "Protección Acuática", - "enchantment.origins.water_protection.desc": "Retrasa el daño por hidrofobia.", - "container.shulker_inventory_power": "Inventario de Shulker", - "origins.gui.select": "Seleccionar", - "origins.gui.close": "Cerrar", - "origins.gui.choose": "Elige", - "origins.gui.choose_origin.title": "Elige tu %s.", - "origins.gui.view_origin.title": "Este es tu %s.", - "origins.gui.view_origin.empty": "No puedes tener ningún origen.", - "origins.gui.view_origin.not_installed": "El servidor no tiene Origins instalado.", - "origins.gui.impact.impact": "Impacto", - "origins.gui.impact.none": "Ninguno", - "origins.gui.impact.low": "Bajo", - "origins.gui.impact.medium": "Intermedio", - "origins.gui.impact.high": "Alto", - "origins.gui.version_mismatch": "Este servidor está usando una versión de Origins (v%1$s) que es incompatible con la que tienes instalada (v%2$s)", - "origins.gui.badge.active": "Habilidad activa. Presione %s para activarla.", - "origins.gui.badge.toggle": "Alternar con %s.", - "origins.gui.badge.recipe.crafting.shaped": "Este poder te deja usar esta Receta (Con forma definida):", - "origins.gui.badge.recipe.crafting.shapeless": "Este poder te deja usar esta Receta (Sin forma definida):", - "origins.gui.unbound_key": "§ono asignado§r", - "origin.origins.random.name": "Aleatorio", - "origin.origins.random.description": "Se te será asignado uno de los siguientes orígenes:", - "layer.origins.origin.name": "Origen", - "origin.origins.empty.name": "Vacío", - "origin.origins.empty.description": "No tienes ningún origen asignado.", - "death.attack.no_water_for_gills": "%1$s no pudo mantenerse hidratado.", - "death.attack.no_water_for_gills.player": "%1$s no pudo mantenerse hidratado por estar peleando contra %2$s.", - "death.attack.hurt_by_water": "%1$s se tomó un baño muy largo.", - "death.attack.hurt_by_water.player": "%1$s está durmiendo con los peces gracias a %2$s.", - "death.attack.genericDamageOverTime": "%1$s murió por daño constante.", - "death.attack.genericDamageOverTime.player": "%1$s murió por daño constante mientras peleaba contra %2$s.", - "commands.origin.origin_not_found": "Origen Desconocido: %s", - "commands.origin.set.success.single": "Origen de %s en la capa %s cambiado a %s.", - "commands.origin.set.success.multiple": "Orígenes de %s objetivos en la capa %s cambiados a %s.", - "commands.origin.get.result": "%s tiene el siguiente %s: &s (%s)", - "commands.origin.gui.all": "Se le ha abierto la pantalla de selección a %s jugadores.", - "commands.origin.gui.layer": "Se le ha abierto la pantalla de selección de \"%2$s\" a %1$s jugadores.", - "origins.avian_sleep_fail": "Necesitas aire fresco para dormir.", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/es_cl.json b/origins/src/main/resources/assets/origins/lang/es_cl.json deleted file mode 100644 index 1c23b20bb..000000000 --- a/origins/src/main/resources/assets/origins/lang/es_cl.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Humano", - "origin.origins.human.description": "Un ser humano común y corriente. Una aventura normal te espera.", - "origin.origins.merling.name": "Tritón", - "origin.origins.merling.description": "Estos habitantes del océano no están acostumbrados a estar fuera del agua por mucho tiempo.", - "origin.origins.arachnid.name": "Arácnido", - "origin.origins.arachnid.description": "Sus habilidades trepadoras y la habilidad de atrapar a sus oponentes en telaraña les hacen grandes cazadores.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "Descendientes de los Blazes. Son naturalmente inmunes a los peligros del Nether.", - "origin.origins.avian.name": "Aviar", - "origin.origins.avian.description": "La raza Aviar ha perdido la habilidad de volar hace mucho tiempo. Ahora se puede ver a estas pacificas criaturas planeando de un lugar a otro.", - "origin.origins.phantom.name": "Fantasma", - "origin.origins.phantom.description": "Mitad Humanos y mitad Fantasmas, estas criaturas pueden cambiar entre su forma normal y Fantasma a su antojo.", - "origin.origins.feline.name": "Felino", - "origin.origins.feline.description": "Con su aspecto gatuno, pueden asustar a los Creepers. Gracias a su destreza felina siempre caen de pie y sin ningún daño.", - "origin.origins.elytrian.name": "Elitria", - "origin.origins.elytrian.description": "Usualmente volando con el viento, los Elitrias se incomodan cuando no tienen suficiente espacio para volar.", - "origin.origins.enderian.name": "Enderianos", - "origin.origins.enderian.description": "Nacidos del Ender Dragon, los Enderianos son capaces de teletransportarse, pero son heridos por el agua.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Relacionados a los Shulkers, los cuerpos de esta especie están cubiertos por una piel tan dura como una armadura.", - "power.origins.water_breathing.name": "Branquias", - "power.origins.water_breathing.description": "Puedes respirar en el agua, pero no en tierra firme.", - "power.origins.aqua_affinity.name": "Afinidad Acuática", - "power.origins.aqua_affinity.description": "Puedes romper bloques bajo el agua a la misma velocidad que otros en tierra.", - "power.origins.water_vision.name": "Ojos Húmedos", - "power.origins.water_vision.description": "Tu visión bajo el agua es perfecta.", - "power.origins.swim_speed.name": "Aletas", - "power.origins.swim_speed.description": "Tu velocidad de nado es mayor que la de otros orígenes.", - "power.origins.like_water.name": "Como el Agua", - "power.origins.like_water.description": "Cuando estás bajo el agua, no te hundes como los demás.", - "power.origins.fragile.name": "Frágil", - "power.origins.fragile.description": "Tienes 3 corazones menos.", - "power.origins.webbing.name": "Tejedor", - "power.origins.webbing.description": "Cuando golpeas a un oponente, quedan atrapados en telaraña.", - "power.origins.climbing.name": "Trepador", - "power.origins.climbing.description": "Eres capaz de escalar cualquier tipo de pared, no sólo escaleras.", - "power.origins.carnivore.name": "Carnívoro", - "power.origins.carnivore.description": "Tu dieta se compone exclusivamente de carne, no puedes digerir vegetales.", - "power.origins.fire_immunity.name": "Inmunidad al Fuego", - "power.origins.fire_immunity.description": "Eres inmune a cualquier tipo de daño por fuego.", - "power.origins.nether_spawn.name": "Habitante del Nether", - "power.origins.nether_spawn.description": "Tu Spawn predeterminado es el Nether.", - "power.origins.burning_wrath.name": "Ira Ardiente", - "power.origins.burning_wrath.description": "Cuando estás ardiendo, haces más daño.", - "power.origins.hotblooded.name": "Sangre Caliente", - "power.origins.hotblooded.description": "Gracias a tu temperatura corporal, el veneno se neutraliza en su sangre, haciéndote inmune a cualquier tipo de efecto venenoso.", - "power.origins.water_vulnerability.name": "Hidrofobia", - "power.origins.water_vulnerability.description": "Recibes daño al entrar en contacto con el agua.", - "power.origins.tailwind.name": "Pie Veloz", - "power.origins.tailwind.description": "Eres un poco más veloz que los otros orígenes.", - "power.origins.slow_falling.name": "Como una Pluma", - "power.origins.slow_falling.description": "Caes lenta y grácilmente como una pluma.", - "power.origins.vegetarian.name": "Vegetariano", - "power.origins.vegetarian.description": "No puedes digerir carnes.", - "power.origins.fresh_air.name": "Aire Fresco", - "power.origins.fresh_air.description": "Para dormir, debes tener tu cama a al menos 86 bloques de altura, para poder respirar aire fresco.", - "power.origins.phasing.name": "Intangible", - "power.origins.phasing.description": "Cuando te conviertes en Fantasma, puedes traspasar cualquier tipo de material, exceptuando Obsidiana y Piedra Base.", - "power.origins.invisibility.name": "Invisibilidad", - "power.origins.invisibility.description": "Cuando te conviertes en Fantasma, eres invisible.", - "power.origins.hunger_over_time.name": "Metabolismo Rápido", - "power.origins.hunger_over_time.description": "Cuando te conviertes en Fantasma te da hambre más rápido.", - "power.origins.burn_in_daylight.name": "Fotoalérgico", - "power.origins.burn_in_daylight.description": "Te empiezas a quemar por el sol si no estás convertido en Fantasma.", - "power.origins.fall_immunity.name": "Acrobacias", - "power.origins.fall_immunity.description": "No recibes daño por caída, sin importar la altura.", - "power.origins.sprint_jump.name": "Tobillos Fuertes", - "power.origins.sprint_jump.description": "Saltas más alto mientras corres.", - "power.origins.nine_lives.name": "Nueve Vidas", - "power.origins.nine_lives.description": "Tienes 1 corazón menos que los humanos.", - "power.origins.cat_vision.name": "Nocturno", - "power.origins.cat_vision.description": "Puedes ver un poco en la oscuridad, a menos que estés en el agua.", - "power.origins.weak_arms.name": "Brazos Débiles", - "power.origins.weak_arms.description": "A menos que estés bajo el efecto de una Poción de Fuerza, sólo puedes minar piedras naturales si tiene menos de 2 otros bloques de piedra adyacentes.", - "power.origins.scare_creepers.name": "Aspecto Felino", - "power.origins.scare_creepers.description": "Los Creepers te tienen miedo y solo explotarán si les atacas.", - "power.origins.launch_into_air.name": "Bendición del Viento", - "power.origins.launch_into_air.description": "Cada 30 Segundos, puedes lanzarte hasta 20 bloques en el aire.", - "power.origins.elytra.name": "Alado", - "power.origins.elytra.description": "Tienes Élitros sin tener que equiparte nada.", - "power.origins.light_armor.name": "Necesidad de Movilidad", - "power.origins.light_armor.description": "No puedes llevar armadura pesada (Armaduras con más protección que cota de mallas).", - "power.origins.claustrophobia.name": "Claustrofobia", - "power.origins.claustrophobia.description": "Estar bajo techo por mucho tiempo te dará Lentitud y Debilidad.", - "power.origins.more_kinetic_damage.name": "Huesos Frágiles", - "power.origins.more_kinetic_damage.description": "Te haces más daño al caer y por chocar volando.", - "power.origins.aerial_combatant.name": "Guerrero Aéreo", - "power.origins.aerial_combatant.description": "Haces más daño al volar con Élitros.", - "power.origins.throw_ender_pearl.name": "Teletransportación", - "power.origins.throw_ender_pearl.description": "Te puedes teletransportar cuando quieras lanzando una Perla de Ender sin hacerte daño.", - "power.origins.pumpkin_hate.name": "Cucurbitofobia", - "power.origins.pumpkin_hate.description": "Le tienes miedo a las calabazas, por buenos motivos.", - "power.origins.extra_reach.name": "Cuerpo Esbelto", - "power.origins.extra_reach.description": "Puede alcanzar bloques y mobs de más lejos.", - "power.origins.shulker_inventory.name": "Acumulador", - "power.origins.shulker_inventory.description": "Tienes 9 espacios de inventario extra, los cuales se mantienen después de morir.", - "power.origins.natural_armor.name": "Armadura Natural", - "power.origins.natural_armor.description": "Incluso sin armadura, tu piel te proporciona protección.", - "power.origins.more_exhaustion.name": "Gran Apetito", - "power.origins.more_exhaustion.description": "Te da hambre más rápido.", - "power.origins.no_shield.name": "Manos Deformes", - "power.origins.no_shield.description": "La forma de tus manos no te permite cubrirte con escudos.", - "power.origins.strong_arms.name": "Brazos Fuertes", - "power.origins.strong_arms.description": "Eres lo suficientemente fuerte como para romper piedra con tus manos.", - "power.origins.translucent.name": "Transparente", - "power.origins.translucent.description": "Tu piel es transparente.", - "power.origins.end_spawn.name": "Habitante del End", - "power.origins.end_spawn.description": "Tu aventura empieza en el End.", - "power.origins.master_of_webs.name": "Maestro de redes", - "power.origins.master_of_webs.description": "Puedes pasar a través de telarañas sin problemas y puedes hasta escalarlas. Cuando golpeas a un enemigo cuerpo a cuerpo, se quedará atrapado en una telaraña por un rato. Mobs no-artrópodos que se queden atrapados en telarañas serán más fáciles de ver para ti. Puedes fabricar telaraña con hilo.", - "power.origins.lay_eggs.name": "Ovíparo", - "power.origins.lay_eggs.description": "Todas las mañanas cuando despiertes, pondrás un huevo.", - "power.origins.phantomize.name": "Forma Fantasma", - "power.origins.phantomize.description": "Puedes cambiar entre forma fantasma y humana a voluntad, pero si te agotas lo suficiente para no poder correr, vuelves a tu forma humana.", - "power.origins.like_air.name": "Como el Viento", - "power.origins.like_air.description": "Tu velocidad en la tierra se mantiene igual en el aire.", - "power.origins.velvet_paws.name": "Patas Acolchadas", - "power.origins.velvet_paws.description": "Las almohadillas en tus patas hacen que tus pisadas no causen vibraciones, lo que hace que no te puedan detectar los Sensores de Sculk.", - "category.origins": "Orígenes", - "key.origins.primary_active": "Poder Activo (Principal)", - "key.origins.secondary_active": "Poder Activo (Secundario)", - "key.origins.view_origin": "Ver Origen", - "text.autoconfig.origins.title": "Origins Configuration", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "item.origins.orb_of_origin": "Orbe de Orígenes", - "component.item.origins.origin.layer": "Te deja escoger un nuevo %s.", - "component.item.origins.origin.layer_and_origin": "Asigna tu %1$s a \"%2$s\".", - "enchantment.origins.water_protection": "Protección Acuática", - "enchantment.origins.water_protection.desc": "Retrasa el daño por hidrofobia.", - "container.shulker_inventory_power": "Inventario de Shulker", - "origins.gui.select": "Seleccionar", - "origins.gui.close": "Cerrar", - "origins.gui.choose": "Elige", - "origins.gui.choose_origin.title": "Elige tu %s.", - "origins.gui.view_origin.title": "Este es tu %s.", - "origins.gui.view_origin.empty": "No puedes tener ningún origen.", - "origins.gui.view_origin.not_installed": "El servidor no tiene Origins instalado.", - "origins.gui.impact.impact": "Impacto", - "origins.gui.impact.none": "Ninguno", - "origins.gui.impact.low": "Bajo", - "origins.gui.impact.medium": "Intermedio", - "origins.gui.impact.high": "Alto", - "origins.gui.version_mismatch": "Este servidor está usando una versión de Origins (v%1$s) que es incompatible con la que tienes instalada (v%2$s)", - "origins.gui.badge.active": "Habilidad activa. Presione %s para activarla.", - "origins.gui.badge.toggle": "Alternar con %s.", - "origins.gui.badge.recipe.crafting.shaped": "Este poder te deja usar esta Receta (Con forma definida):", - "origins.gui.badge.recipe.crafting.shapeless": "Este poder te deja usar esta Receta (Sin forma definida):", - "origins.gui.unbound_key": "§ono asignado§r", - "origin.origins.random.name": "Aleatorio", - "origin.origins.random.description": "Se te será asignado uno de los siguientes orígenes:", - "layer.origins.origin.name": "Origen", - "origin.origins.empty.name": "Vacío", - "origin.origins.empty.description": "No tienes ningún origen asignado.", - "death.attack.no_water_for_gills": "%1$s no pudo mantenerse hidratado.", - "death.attack.no_water_for_gills.player": "%1$s no pudo mantenerse hidratado por estar peleando contra %2$s.", - "death.attack.hurt_by_water": "%1$s se tomó un baño muy largo.", - "death.attack.hurt_by_water.player": "%1$s está durmiendo con los peces gracias a %2$s.", - "death.attack.genericDamageOverTime": "%1$s murió por daño constante.", - "death.attack.genericDamageOverTime.player": "%1$s murió por daño constante mientras peleaba contra %2$s.", - "commands.origin.origin_not_found": "Origen Desconocido: %s", - "commands.origin.set.success.single": "Origen de %s en la capa %s cambiado a %s.", - "commands.origin.set.success.multiple": "Orígenes de %s objetivos en la capa %s cambiados a %s.", - "commands.origin.get.result": "%s tiene el siguiente %s: &s (%s)", - "commands.origin.gui.all": "Se le ha abierto la pantalla de selección a %s jugadores.", - "commands.origin.gui.layer": "Se le ha abierto la pantalla de selección de \"%2$s\" a %1$s jugadores.", - "origins.avian_sleep_fail": "Necesitas aire fresco para dormir.", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/es_ec.json b/origins/src/main/resources/assets/origins/lang/es_ec.json deleted file mode 100644 index 1c23b20bb..000000000 --- a/origins/src/main/resources/assets/origins/lang/es_ec.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Humano", - "origin.origins.human.description": "Un ser humano común y corriente. Una aventura normal te espera.", - "origin.origins.merling.name": "Tritón", - "origin.origins.merling.description": "Estos habitantes del océano no están acostumbrados a estar fuera del agua por mucho tiempo.", - "origin.origins.arachnid.name": "Arácnido", - "origin.origins.arachnid.description": "Sus habilidades trepadoras y la habilidad de atrapar a sus oponentes en telaraña les hacen grandes cazadores.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "Descendientes de los Blazes. Son naturalmente inmunes a los peligros del Nether.", - "origin.origins.avian.name": "Aviar", - "origin.origins.avian.description": "La raza Aviar ha perdido la habilidad de volar hace mucho tiempo. Ahora se puede ver a estas pacificas criaturas planeando de un lugar a otro.", - "origin.origins.phantom.name": "Fantasma", - "origin.origins.phantom.description": "Mitad Humanos y mitad Fantasmas, estas criaturas pueden cambiar entre su forma normal y Fantasma a su antojo.", - "origin.origins.feline.name": "Felino", - "origin.origins.feline.description": "Con su aspecto gatuno, pueden asustar a los Creepers. Gracias a su destreza felina siempre caen de pie y sin ningún daño.", - "origin.origins.elytrian.name": "Elitria", - "origin.origins.elytrian.description": "Usualmente volando con el viento, los Elitrias se incomodan cuando no tienen suficiente espacio para volar.", - "origin.origins.enderian.name": "Enderianos", - "origin.origins.enderian.description": "Nacidos del Ender Dragon, los Enderianos son capaces de teletransportarse, pero son heridos por el agua.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Relacionados a los Shulkers, los cuerpos de esta especie están cubiertos por una piel tan dura como una armadura.", - "power.origins.water_breathing.name": "Branquias", - "power.origins.water_breathing.description": "Puedes respirar en el agua, pero no en tierra firme.", - "power.origins.aqua_affinity.name": "Afinidad Acuática", - "power.origins.aqua_affinity.description": "Puedes romper bloques bajo el agua a la misma velocidad que otros en tierra.", - "power.origins.water_vision.name": "Ojos Húmedos", - "power.origins.water_vision.description": "Tu visión bajo el agua es perfecta.", - "power.origins.swim_speed.name": "Aletas", - "power.origins.swim_speed.description": "Tu velocidad de nado es mayor que la de otros orígenes.", - "power.origins.like_water.name": "Como el Agua", - "power.origins.like_water.description": "Cuando estás bajo el agua, no te hundes como los demás.", - "power.origins.fragile.name": "Frágil", - "power.origins.fragile.description": "Tienes 3 corazones menos.", - "power.origins.webbing.name": "Tejedor", - "power.origins.webbing.description": "Cuando golpeas a un oponente, quedan atrapados en telaraña.", - "power.origins.climbing.name": "Trepador", - "power.origins.climbing.description": "Eres capaz de escalar cualquier tipo de pared, no sólo escaleras.", - "power.origins.carnivore.name": "Carnívoro", - "power.origins.carnivore.description": "Tu dieta se compone exclusivamente de carne, no puedes digerir vegetales.", - "power.origins.fire_immunity.name": "Inmunidad al Fuego", - "power.origins.fire_immunity.description": "Eres inmune a cualquier tipo de daño por fuego.", - "power.origins.nether_spawn.name": "Habitante del Nether", - "power.origins.nether_spawn.description": "Tu Spawn predeterminado es el Nether.", - "power.origins.burning_wrath.name": "Ira Ardiente", - "power.origins.burning_wrath.description": "Cuando estás ardiendo, haces más daño.", - "power.origins.hotblooded.name": "Sangre Caliente", - "power.origins.hotblooded.description": "Gracias a tu temperatura corporal, el veneno se neutraliza en su sangre, haciéndote inmune a cualquier tipo de efecto venenoso.", - "power.origins.water_vulnerability.name": "Hidrofobia", - "power.origins.water_vulnerability.description": "Recibes daño al entrar en contacto con el agua.", - "power.origins.tailwind.name": "Pie Veloz", - "power.origins.tailwind.description": "Eres un poco más veloz que los otros orígenes.", - "power.origins.slow_falling.name": "Como una Pluma", - "power.origins.slow_falling.description": "Caes lenta y grácilmente como una pluma.", - "power.origins.vegetarian.name": "Vegetariano", - "power.origins.vegetarian.description": "No puedes digerir carnes.", - "power.origins.fresh_air.name": "Aire Fresco", - "power.origins.fresh_air.description": "Para dormir, debes tener tu cama a al menos 86 bloques de altura, para poder respirar aire fresco.", - "power.origins.phasing.name": "Intangible", - "power.origins.phasing.description": "Cuando te conviertes en Fantasma, puedes traspasar cualquier tipo de material, exceptuando Obsidiana y Piedra Base.", - "power.origins.invisibility.name": "Invisibilidad", - "power.origins.invisibility.description": "Cuando te conviertes en Fantasma, eres invisible.", - "power.origins.hunger_over_time.name": "Metabolismo Rápido", - "power.origins.hunger_over_time.description": "Cuando te conviertes en Fantasma te da hambre más rápido.", - "power.origins.burn_in_daylight.name": "Fotoalérgico", - "power.origins.burn_in_daylight.description": "Te empiezas a quemar por el sol si no estás convertido en Fantasma.", - "power.origins.fall_immunity.name": "Acrobacias", - "power.origins.fall_immunity.description": "No recibes daño por caída, sin importar la altura.", - "power.origins.sprint_jump.name": "Tobillos Fuertes", - "power.origins.sprint_jump.description": "Saltas más alto mientras corres.", - "power.origins.nine_lives.name": "Nueve Vidas", - "power.origins.nine_lives.description": "Tienes 1 corazón menos que los humanos.", - "power.origins.cat_vision.name": "Nocturno", - "power.origins.cat_vision.description": "Puedes ver un poco en la oscuridad, a menos que estés en el agua.", - "power.origins.weak_arms.name": "Brazos Débiles", - "power.origins.weak_arms.description": "A menos que estés bajo el efecto de una Poción de Fuerza, sólo puedes minar piedras naturales si tiene menos de 2 otros bloques de piedra adyacentes.", - "power.origins.scare_creepers.name": "Aspecto Felino", - "power.origins.scare_creepers.description": "Los Creepers te tienen miedo y solo explotarán si les atacas.", - "power.origins.launch_into_air.name": "Bendición del Viento", - "power.origins.launch_into_air.description": "Cada 30 Segundos, puedes lanzarte hasta 20 bloques en el aire.", - "power.origins.elytra.name": "Alado", - "power.origins.elytra.description": "Tienes Élitros sin tener que equiparte nada.", - "power.origins.light_armor.name": "Necesidad de Movilidad", - "power.origins.light_armor.description": "No puedes llevar armadura pesada (Armaduras con más protección que cota de mallas).", - "power.origins.claustrophobia.name": "Claustrofobia", - "power.origins.claustrophobia.description": "Estar bajo techo por mucho tiempo te dará Lentitud y Debilidad.", - "power.origins.more_kinetic_damage.name": "Huesos Frágiles", - "power.origins.more_kinetic_damage.description": "Te haces más daño al caer y por chocar volando.", - "power.origins.aerial_combatant.name": "Guerrero Aéreo", - "power.origins.aerial_combatant.description": "Haces más daño al volar con Élitros.", - "power.origins.throw_ender_pearl.name": "Teletransportación", - "power.origins.throw_ender_pearl.description": "Te puedes teletransportar cuando quieras lanzando una Perla de Ender sin hacerte daño.", - "power.origins.pumpkin_hate.name": "Cucurbitofobia", - "power.origins.pumpkin_hate.description": "Le tienes miedo a las calabazas, por buenos motivos.", - "power.origins.extra_reach.name": "Cuerpo Esbelto", - "power.origins.extra_reach.description": "Puede alcanzar bloques y mobs de más lejos.", - "power.origins.shulker_inventory.name": "Acumulador", - "power.origins.shulker_inventory.description": "Tienes 9 espacios de inventario extra, los cuales se mantienen después de morir.", - "power.origins.natural_armor.name": "Armadura Natural", - "power.origins.natural_armor.description": "Incluso sin armadura, tu piel te proporciona protección.", - "power.origins.more_exhaustion.name": "Gran Apetito", - "power.origins.more_exhaustion.description": "Te da hambre más rápido.", - "power.origins.no_shield.name": "Manos Deformes", - "power.origins.no_shield.description": "La forma de tus manos no te permite cubrirte con escudos.", - "power.origins.strong_arms.name": "Brazos Fuertes", - "power.origins.strong_arms.description": "Eres lo suficientemente fuerte como para romper piedra con tus manos.", - "power.origins.translucent.name": "Transparente", - "power.origins.translucent.description": "Tu piel es transparente.", - "power.origins.end_spawn.name": "Habitante del End", - "power.origins.end_spawn.description": "Tu aventura empieza en el End.", - "power.origins.master_of_webs.name": "Maestro de redes", - "power.origins.master_of_webs.description": "Puedes pasar a través de telarañas sin problemas y puedes hasta escalarlas. Cuando golpeas a un enemigo cuerpo a cuerpo, se quedará atrapado en una telaraña por un rato. Mobs no-artrópodos que se queden atrapados en telarañas serán más fáciles de ver para ti. Puedes fabricar telaraña con hilo.", - "power.origins.lay_eggs.name": "Ovíparo", - "power.origins.lay_eggs.description": "Todas las mañanas cuando despiertes, pondrás un huevo.", - "power.origins.phantomize.name": "Forma Fantasma", - "power.origins.phantomize.description": "Puedes cambiar entre forma fantasma y humana a voluntad, pero si te agotas lo suficiente para no poder correr, vuelves a tu forma humana.", - "power.origins.like_air.name": "Como el Viento", - "power.origins.like_air.description": "Tu velocidad en la tierra se mantiene igual en el aire.", - "power.origins.velvet_paws.name": "Patas Acolchadas", - "power.origins.velvet_paws.description": "Las almohadillas en tus patas hacen que tus pisadas no causen vibraciones, lo que hace que no te puedan detectar los Sensores de Sculk.", - "category.origins": "Orígenes", - "key.origins.primary_active": "Poder Activo (Principal)", - "key.origins.secondary_active": "Poder Activo (Secundario)", - "key.origins.view_origin": "Ver Origen", - "text.autoconfig.origins.title": "Origins Configuration", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "item.origins.orb_of_origin": "Orbe de Orígenes", - "component.item.origins.origin.layer": "Te deja escoger un nuevo %s.", - "component.item.origins.origin.layer_and_origin": "Asigna tu %1$s a \"%2$s\".", - "enchantment.origins.water_protection": "Protección Acuática", - "enchantment.origins.water_protection.desc": "Retrasa el daño por hidrofobia.", - "container.shulker_inventory_power": "Inventario de Shulker", - "origins.gui.select": "Seleccionar", - "origins.gui.close": "Cerrar", - "origins.gui.choose": "Elige", - "origins.gui.choose_origin.title": "Elige tu %s.", - "origins.gui.view_origin.title": "Este es tu %s.", - "origins.gui.view_origin.empty": "No puedes tener ningún origen.", - "origins.gui.view_origin.not_installed": "El servidor no tiene Origins instalado.", - "origins.gui.impact.impact": "Impacto", - "origins.gui.impact.none": "Ninguno", - "origins.gui.impact.low": "Bajo", - "origins.gui.impact.medium": "Intermedio", - "origins.gui.impact.high": "Alto", - "origins.gui.version_mismatch": "Este servidor está usando una versión de Origins (v%1$s) que es incompatible con la que tienes instalada (v%2$s)", - "origins.gui.badge.active": "Habilidad activa. Presione %s para activarla.", - "origins.gui.badge.toggle": "Alternar con %s.", - "origins.gui.badge.recipe.crafting.shaped": "Este poder te deja usar esta Receta (Con forma definida):", - "origins.gui.badge.recipe.crafting.shapeless": "Este poder te deja usar esta Receta (Sin forma definida):", - "origins.gui.unbound_key": "§ono asignado§r", - "origin.origins.random.name": "Aleatorio", - "origin.origins.random.description": "Se te será asignado uno de los siguientes orígenes:", - "layer.origins.origin.name": "Origen", - "origin.origins.empty.name": "Vacío", - "origin.origins.empty.description": "No tienes ningún origen asignado.", - "death.attack.no_water_for_gills": "%1$s no pudo mantenerse hidratado.", - "death.attack.no_water_for_gills.player": "%1$s no pudo mantenerse hidratado por estar peleando contra %2$s.", - "death.attack.hurt_by_water": "%1$s se tomó un baño muy largo.", - "death.attack.hurt_by_water.player": "%1$s está durmiendo con los peces gracias a %2$s.", - "death.attack.genericDamageOverTime": "%1$s murió por daño constante.", - "death.attack.genericDamageOverTime.player": "%1$s murió por daño constante mientras peleaba contra %2$s.", - "commands.origin.origin_not_found": "Origen Desconocido: %s", - "commands.origin.set.success.single": "Origen de %s en la capa %s cambiado a %s.", - "commands.origin.set.success.multiple": "Orígenes de %s objetivos en la capa %s cambiados a %s.", - "commands.origin.get.result": "%s tiene el siguiente %s: &s (%s)", - "commands.origin.gui.all": "Se le ha abierto la pantalla de selección a %s jugadores.", - "commands.origin.gui.layer": "Se le ha abierto la pantalla de selección de \"%2$s\" a %1$s jugadores.", - "origins.avian_sleep_fail": "Necesitas aire fresco para dormir.", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/es_es.json b/origins/src/main/resources/assets/origins/lang/es_es.json deleted file mode 100644 index 1c23b20bb..000000000 --- a/origins/src/main/resources/assets/origins/lang/es_es.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Humano", - "origin.origins.human.description": "Un ser humano común y corriente. Una aventura normal te espera.", - "origin.origins.merling.name": "Tritón", - "origin.origins.merling.description": "Estos habitantes del océano no están acostumbrados a estar fuera del agua por mucho tiempo.", - "origin.origins.arachnid.name": "Arácnido", - "origin.origins.arachnid.description": "Sus habilidades trepadoras y la habilidad de atrapar a sus oponentes en telaraña les hacen grandes cazadores.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "Descendientes de los Blazes. Son naturalmente inmunes a los peligros del Nether.", - "origin.origins.avian.name": "Aviar", - "origin.origins.avian.description": "La raza Aviar ha perdido la habilidad de volar hace mucho tiempo. Ahora se puede ver a estas pacificas criaturas planeando de un lugar a otro.", - "origin.origins.phantom.name": "Fantasma", - "origin.origins.phantom.description": "Mitad Humanos y mitad Fantasmas, estas criaturas pueden cambiar entre su forma normal y Fantasma a su antojo.", - "origin.origins.feline.name": "Felino", - "origin.origins.feline.description": "Con su aspecto gatuno, pueden asustar a los Creepers. Gracias a su destreza felina siempre caen de pie y sin ningún daño.", - "origin.origins.elytrian.name": "Elitria", - "origin.origins.elytrian.description": "Usualmente volando con el viento, los Elitrias se incomodan cuando no tienen suficiente espacio para volar.", - "origin.origins.enderian.name": "Enderianos", - "origin.origins.enderian.description": "Nacidos del Ender Dragon, los Enderianos son capaces de teletransportarse, pero son heridos por el agua.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Relacionados a los Shulkers, los cuerpos de esta especie están cubiertos por una piel tan dura como una armadura.", - "power.origins.water_breathing.name": "Branquias", - "power.origins.water_breathing.description": "Puedes respirar en el agua, pero no en tierra firme.", - "power.origins.aqua_affinity.name": "Afinidad Acuática", - "power.origins.aqua_affinity.description": "Puedes romper bloques bajo el agua a la misma velocidad que otros en tierra.", - "power.origins.water_vision.name": "Ojos Húmedos", - "power.origins.water_vision.description": "Tu visión bajo el agua es perfecta.", - "power.origins.swim_speed.name": "Aletas", - "power.origins.swim_speed.description": "Tu velocidad de nado es mayor que la de otros orígenes.", - "power.origins.like_water.name": "Como el Agua", - "power.origins.like_water.description": "Cuando estás bajo el agua, no te hundes como los demás.", - "power.origins.fragile.name": "Frágil", - "power.origins.fragile.description": "Tienes 3 corazones menos.", - "power.origins.webbing.name": "Tejedor", - "power.origins.webbing.description": "Cuando golpeas a un oponente, quedan atrapados en telaraña.", - "power.origins.climbing.name": "Trepador", - "power.origins.climbing.description": "Eres capaz de escalar cualquier tipo de pared, no sólo escaleras.", - "power.origins.carnivore.name": "Carnívoro", - "power.origins.carnivore.description": "Tu dieta se compone exclusivamente de carne, no puedes digerir vegetales.", - "power.origins.fire_immunity.name": "Inmunidad al Fuego", - "power.origins.fire_immunity.description": "Eres inmune a cualquier tipo de daño por fuego.", - "power.origins.nether_spawn.name": "Habitante del Nether", - "power.origins.nether_spawn.description": "Tu Spawn predeterminado es el Nether.", - "power.origins.burning_wrath.name": "Ira Ardiente", - "power.origins.burning_wrath.description": "Cuando estás ardiendo, haces más daño.", - "power.origins.hotblooded.name": "Sangre Caliente", - "power.origins.hotblooded.description": "Gracias a tu temperatura corporal, el veneno se neutraliza en su sangre, haciéndote inmune a cualquier tipo de efecto venenoso.", - "power.origins.water_vulnerability.name": "Hidrofobia", - "power.origins.water_vulnerability.description": "Recibes daño al entrar en contacto con el agua.", - "power.origins.tailwind.name": "Pie Veloz", - "power.origins.tailwind.description": "Eres un poco más veloz que los otros orígenes.", - "power.origins.slow_falling.name": "Como una Pluma", - "power.origins.slow_falling.description": "Caes lenta y grácilmente como una pluma.", - "power.origins.vegetarian.name": "Vegetariano", - "power.origins.vegetarian.description": "No puedes digerir carnes.", - "power.origins.fresh_air.name": "Aire Fresco", - "power.origins.fresh_air.description": "Para dormir, debes tener tu cama a al menos 86 bloques de altura, para poder respirar aire fresco.", - "power.origins.phasing.name": "Intangible", - "power.origins.phasing.description": "Cuando te conviertes en Fantasma, puedes traspasar cualquier tipo de material, exceptuando Obsidiana y Piedra Base.", - "power.origins.invisibility.name": "Invisibilidad", - "power.origins.invisibility.description": "Cuando te conviertes en Fantasma, eres invisible.", - "power.origins.hunger_over_time.name": "Metabolismo Rápido", - "power.origins.hunger_over_time.description": "Cuando te conviertes en Fantasma te da hambre más rápido.", - "power.origins.burn_in_daylight.name": "Fotoalérgico", - "power.origins.burn_in_daylight.description": "Te empiezas a quemar por el sol si no estás convertido en Fantasma.", - "power.origins.fall_immunity.name": "Acrobacias", - "power.origins.fall_immunity.description": "No recibes daño por caída, sin importar la altura.", - "power.origins.sprint_jump.name": "Tobillos Fuertes", - "power.origins.sprint_jump.description": "Saltas más alto mientras corres.", - "power.origins.nine_lives.name": "Nueve Vidas", - "power.origins.nine_lives.description": "Tienes 1 corazón menos que los humanos.", - "power.origins.cat_vision.name": "Nocturno", - "power.origins.cat_vision.description": "Puedes ver un poco en la oscuridad, a menos que estés en el agua.", - "power.origins.weak_arms.name": "Brazos Débiles", - "power.origins.weak_arms.description": "A menos que estés bajo el efecto de una Poción de Fuerza, sólo puedes minar piedras naturales si tiene menos de 2 otros bloques de piedra adyacentes.", - "power.origins.scare_creepers.name": "Aspecto Felino", - "power.origins.scare_creepers.description": "Los Creepers te tienen miedo y solo explotarán si les atacas.", - "power.origins.launch_into_air.name": "Bendición del Viento", - "power.origins.launch_into_air.description": "Cada 30 Segundos, puedes lanzarte hasta 20 bloques en el aire.", - "power.origins.elytra.name": "Alado", - "power.origins.elytra.description": "Tienes Élitros sin tener que equiparte nada.", - "power.origins.light_armor.name": "Necesidad de Movilidad", - "power.origins.light_armor.description": "No puedes llevar armadura pesada (Armaduras con más protección que cota de mallas).", - "power.origins.claustrophobia.name": "Claustrofobia", - "power.origins.claustrophobia.description": "Estar bajo techo por mucho tiempo te dará Lentitud y Debilidad.", - "power.origins.more_kinetic_damage.name": "Huesos Frágiles", - "power.origins.more_kinetic_damage.description": "Te haces más daño al caer y por chocar volando.", - "power.origins.aerial_combatant.name": "Guerrero Aéreo", - "power.origins.aerial_combatant.description": "Haces más daño al volar con Élitros.", - "power.origins.throw_ender_pearl.name": "Teletransportación", - "power.origins.throw_ender_pearl.description": "Te puedes teletransportar cuando quieras lanzando una Perla de Ender sin hacerte daño.", - "power.origins.pumpkin_hate.name": "Cucurbitofobia", - "power.origins.pumpkin_hate.description": "Le tienes miedo a las calabazas, por buenos motivos.", - "power.origins.extra_reach.name": "Cuerpo Esbelto", - "power.origins.extra_reach.description": "Puede alcanzar bloques y mobs de más lejos.", - "power.origins.shulker_inventory.name": "Acumulador", - "power.origins.shulker_inventory.description": "Tienes 9 espacios de inventario extra, los cuales se mantienen después de morir.", - "power.origins.natural_armor.name": "Armadura Natural", - "power.origins.natural_armor.description": "Incluso sin armadura, tu piel te proporciona protección.", - "power.origins.more_exhaustion.name": "Gran Apetito", - "power.origins.more_exhaustion.description": "Te da hambre más rápido.", - "power.origins.no_shield.name": "Manos Deformes", - "power.origins.no_shield.description": "La forma de tus manos no te permite cubrirte con escudos.", - "power.origins.strong_arms.name": "Brazos Fuertes", - "power.origins.strong_arms.description": "Eres lo suficientemente fuerte como para romper piedra con tus manos.", - "power.origins.translucent.name": "Transparente", - "power.origins.translucent.description": "Tu piel es transparente.", - "power.origins.end_spawn.name": "Habitante del End", - "power.origins.end_spawn.description": "Tu aventura empieza en el End.", - "power.origins.master_of_webs.name": "Maestro de redes", - "power.origins.master_of_webs.description": "Puedes pasar a través de telarañas sin problemas y puedes hasta escalarlas. Cuando golpeas a un enemigo cuerpo a cuerpo, se quedará atrapado en una telaraña por un rato. Mobs no-artrópodos que se queden atrapados en telarañas serán más fáciles de ver para ti. Puedes fabricar telaraña con hilo.", - "power.origins.lay_eggs.name": "Ovíparo", - "power.origins.lay_eggs.description": "Todas las mañanas cuando despiertes, pondrás un huevo.", - "power.origins.phantomize.name": "Forma Fantasma", - "power.origins.phantomize.description": "Puedes cambiar entre forma fantasma y humana a voluntad, pero si te agotas lo suficiente para no poder correr, vuelves a tu forma humana.", - "power.origins.like_air.name": "Como el Viento", - "power.origins.like_air.description": "Tu velocidad en la tierra se mantiene igual en el aire.", - "power.origins.velvet_paws.name": "Patas Acolchadas", - "power.origins.velvet_paws.description": "Las almohadillas en tus patas hacen que tus pisadas no causen vibraciones, lo que hace que no te puedan detectar los Sensores de Sculk.", - "category.origins": "Orígenes", - "key.origins.primary_active": "Poder Activo (Principal)", - "key.origins.secondary_active": "Poder Activo (Secundario)", - "key.origins.view_origin": "Ver Origen", - "text.autoconfig.origins.title": "Origins Configuration", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "item.origins.orb_of_origin": "Orbe de Orígenes", - "component.item.origins.origin.layer": "Te deja escoger un nuevo %s.", - "component.item.origins.origin.layer_and_origin": "Asigna tu %1$s a \"%2$s\".", - "enchantment.origins.water_protection": "Protección Acuática", - "enchantment.origins.water_protection.desc": "Retrasa el daño por hidrofobia.", - "container.shulker_inventory_power": "Inventario de Shulker", - "origins.gui.select": "Seleccionar", - "origins.gui.close": "Cerrar", - "origins.gui.choose": "Elige", - "origins.gui.choose_origin.title": "Elige tu %s.", - "origins.gui.view_origin.title": "Este es tu %s.", - "origins.gui.view_origin.empty": "No puedes tener ningún origen.", - "origins.gui.view_origin.not_installed": "El servidor no tiene Origins instalado.", - "origins.gui.impact.impact": "Impacto", - "origins.gui.impact.none": "Ninguno", - "origins.gui.impact.low": "Bajo", - "origins.gui.impact.medium": "Intermedio", - "origins.gui.impact.high": "Alto", - "origins.gui.version_mismatch": "Este servidor está usando una versión de Origins (v%1$s) que es incompatible con la que tienes instalada (v%2$s)", - "origins.gui.badge.active": "Habilidad activa. Presione %s para activarla.", - "origins.gui.badge.toggle": "Alternar con %s.", - "origins.gui.badge.recipe.crafting.shaped": "Este poder te deja usar esta Receta (Con forma definida):", - "origins.gui.badge.recipe.crafting.shapeless": "Este poder te deja usar esta Receta (Sin forma definida):", - "origins.gui.unbound_key": "§ono asignado§r", - "origin.origins.random.name": "Aleatorio", - "origin.origins.random.description": "Se te será asignado uno de los siguientes orígenes:", - "layer.origins.origin.name": "Origen", - "origin.origins.empty.name": "Vacío", - "origin.origins.empty.description": "No tienes ningún origen asignado.", - "death.attack.no_water_for_gills": "%1$s no pudo mantenerse hidratado.", - "death.attack.no_water_for_gills.player": "%1$s no pudo mantenerse hidratado por estar peleando contra %2$s.", - "death.attack.hurt_by_water": "%1$s se tomó un baño muy largo.", - "death.attack.hurt_by_water.player": "%1$s está durmiendo con los peces gracias a %2$s.", - "death.attack.genericDamageOverTime": "%1$s murió por daño constante.", - "death.attack.genericDamageOverTime.player": "%1$s murió por daño constante mientras peleaba contra %2$s.", - "commands.origin.origin_not_found": "Origen Desconocido: %s", - "commands.origin.set.success.single": "Origen de %s en la capa %s cambiado a %s.", - "commands.origin.set.success.multiple": "Orígenes de %s objetivos en la capa %s cambiados a %s.", - "commands.origin.get.result": "%s tiene el siguiente %s: &s (%s)", - "commands.origin.gui.all": "Se le ha abierto la pantalla de selección a %s jugadores.", - "commands.origin.gui.layer": "Se le ha abierto la pantalla de selección de \"%2$s\" a %1$s jugadores.", - "origins.avian_sleep_fail": "Necesitas aire fresco para dormir.", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/es_mx.json b/origins/src/main/resources/assets/origins/lang/es_mx.json deleted file mode 100644 index 1c23b20bb..000000000 --- a/origins/src/main/resources/assets/origins/lang/es_mx.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Humano", - "origin.origins.human.description": "Un ser humano común y corriente. Una aventura normal te espera.", - "origin.origins.merling.name": "Tritón", - "origin.origins.merling.description": "Estos habitantes del océano no están acostumbrados a estar fuera del agua por mucho tiempo.", - "origin.origins.arachnid.name": "Arácnido", - "origin.origins.arachnid.description": "Sus habilidades trepadoras y la habilidad de atrapar a sus oponentes en telaraña les hacen grandes cazadores.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "Descendientes de los Blazes. Son naturalmente inmunes a los peligros del Nether.", - "origin.origins.avian.name": "Aviar", - "origin.origins.avian.description": "La raza Aviar ha perdido la habilidad de volar hace mucho tiempo. Ahora se puede ver a estas pacificas criaturas planeando de un lugar a otro.", - "origin.origins.phantom.name": "Fantasma", - "origin.origins.phantom.description": "Mitad Humanos y mitad Fantasmas, estas criaturas pueden cambiar entre su forma normal y Fantasma a su antojo.", - "origin.origins.feline.name": "Felino", - "origin.origins.feline.description": "Con su aspecto gatuno, pueden asustar a los Creepers. Gracias a su destreza felina siempre caen de pie y sin ningún daño.", - "origin.origins.elytrian.name": "Elitria", - "origin.origins.elytrian.description": "Usualmente volando con el viento, los Elitrias se incomodan cuando no tienen suficiente espacio para volar.", - "origin.origins.enderian.name": "Enderianos", - "origin.origins.enderian.description": "Nacidos del Ender Dragon, los Enderianos son capaces de teletransportarse, pero son heridos por el agua.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Relacionados a los Shulkers, los cuerpos de esta especie están cubiertos por una piel tan dura como una armadura.", - "power.origins.water_breathing.name": "Branquias", - "power.origins.water_breathing.description": "Puedes respirar en el agua, pero no en tierra firme.", - "power.origins.aqua_affinity.name": "Afinidad Acuática", - "power.origins.aqua_affinity.description": "Puedes romper bloques bajo el agua a la misma velocidad que otros en tierra.", - "power.origins.water_vision.name": "Ojos Húmedos", - "power.origins.water_vision.description": "Tu visión bajo el agua es perfecta.", - "power.origins.swim_speed.name": "Aletas", - "power.origins.swim_speed.description": "Tu velocidad de nado es mayor que la de otros orígenes.", - "power.origins.like_water.name": "Como el Agua", - "power.origins.like_water.description": "Cuando estás bajo el agua, no te hundes como los demás.", - "power.origins.fragile.name": "Frágil", - "power.origins.fragile.description": "Tienes 3 corazones menos.", - "power.origins.webbing.name": "Tejedor", - "power.origins.webbing.description": "Cuando golpeas a un oponente, quedan atrapados en telaraña.", - "power.origins.climbing.name": "Trepador", - "power.origins.climbing.description": "Eres capaz de escalar cualquier tipo de pared, no sólo escaleras.", - "power.origins.carnivore.name": "Carnívoro", - "power.origins.carnivore.description": "Tu dieta se compone exclusivamente de carne, no puedes digerir vegetales.", - "power.origins.fire_immunity.name": "Inmunidad al Fuego", - "power.origins.fire_immunity.description": "Eres inmune a cualquier tipo de daño por fuego.", - "power.origins.nether_spawn.name": "Habitante del Nether", - "power.origins.nether_spawn.description": "Tu Spawn predeterminado es el Nether.", - "power.origins.burning_wrath.name": "Ira Ardiente", - "power.origins.burning_wrath.description": "Cuando estás ardiendo, haces más daño.", - "power.origins.hotblooded.name": "Sangre Caliente", - "power.origins.hotblooded.description": "Gracias a tu temperatura corporal, el veneno se neutraliza en su sangre, haciéndote inmune a cualquier tipo de efecto venenoso.", - "power.origins.water_vulnerability.name": "Hidrofobia", - "power.origins.water_vulnerability.description": "Recibes daño al entrar en contacto con el agua.", - "power.origins.tailwind.name": "Pie Veloz", - "power.origins.tailwind.description": "Eres un poco más veloz que los otros orígenes.", - "power.origins.slow_falling.name": "Como una Pluma", - "power.origins.slow_falling.description": "Caes lenta y grácilmente como una pluma.", - "power.origins.vegetarian.name": "Vegetariano", - "power.origins.vegetarian.description": "No puedes digerir carnes.", - "power.origins.fresh_air.name": "Aire Fresco", - "power.origins.fresh_air.description": "Para dormir, debes tener tu cama a al menos 86 bloques de altura, para poder respirar aire fresco.", - "power.origins.phasing.name": "Intangible", - "power.origins.phasing.description": "Cuando te conviertes en Fantasma, puedes traspasar cualquier tipo de material, exceptuando Obsidiana y Piedra Base.", - "power.origins.invisibility.name": "Invisibilidad", - "power.origins.invisibility.description": "Cuando te conviertes en Fantasma, eres invisible.", - "power.origins.hunger_over_time.name": "Metabolismo Rápido", - "power.origins.hunger_over_time.description": "Cuando te conviertes en Fantasma te da hambre más rápido.", - "power.origins.burn_in_daylight.name": "Fotoalérgico", - "power.origins.burn_in_daylight.description": "Te empiezas a quemar por el sol si no estás convertido en Fantasma.", - "power.origins.fall_immunity.name": "Acrobacias", - "power.origins.fall_immunity.description": "No recibes daño por caída, sin importar la altura.", - "power.origins.sprint_jump.name": "Tobillos Fuertes", - "power.origins.sprint_jump.description": "Saltas más alto mientras corres.", - "power.origins.nine_lives.name": "Nueve Vidas", - "power.origins.nine_lives.description": "Tienes 1 corazón menos que los humanos.", - "power.origins.cat_vision.name": "Nocturno", - "power.origins.cat_vision.description": "Puedes ver un poco en la oscuridad, a menos que estés en el agua.", - "power.origins.weak_arms.name": "Brazos Débiles", - "power.origins.weak_arms.description": "A menos que estés bajo el efecto de una Poción de Fuerza, sólo puedes minar piedras naturales si tiene menos de 2 otros bloques de piedra adyacentes.", - "power.origins.scare_creepers.name": "Aspecto Felino", - "power.origins.scare_creepers.description": "Los Creepers te tienen miedo y solo explotarán si les atacas.", - "power.origins.launch_into_air.name": "Bendición del Viento", - "power.origins.launch_into_air.description": "Cada 30 Segundos, puedes lanzarte hasta 20 bloques en el aire.", - "power.origins.elytra.name": "Alado", - "power.origins.elytra.description": "Tienes Élitros sin tener que equiparte nada.", - "power.origins.light_armor.name": "Necesidad de Movilidad", - "power.origins.light_armor.description": "No puedes llevar armadura pesada (Armaduras con más protección que cota de mallas).", - "power.origins.claustrophobia.name": "Claustrofobia", - "power.origins.claustrophobia.description": "Estar bajo techo por mucho tiempo te dará Lentitud y Debilidad.", - "power.origins.more_kinetic_damage.name": "Huesos Frágiles", - "power.origins.more_kinetic_damage.description": "Te haces más daño al caer y por chocar volando.", - "power.origins.aerial_combatant.name": "Guerrero Aéreo", - "power.origins.aerial_combatant.description": "Haces más daño al volar con Élitros.", - "power.origins.throw_ender_pearl.name": "Teletransportación", - "power.origins.throw_ender_pearl.description": "Te puedes teletransportar cuando quieras lanzando una Perla de Ender sin hacerte daño.", - "power.origins.pumpkin_hate.name": "Cucurbitofobia", - "power.origins.pumpkin_hate.description": "Le tienes miedo a las calabazas, por buenos motivos.", - "power.origins.extra_reach.name": "Cuerpo Esbelto", - "power.origins.extra_reach.description": "Puede alcanzar bloques y mobs de más lejos.", - "power.origins.shulker_inventory.name": "Acumulador", - "power.origins.shulker_inventory.description": "Tienes 9 espacios de inventario extra, los cuales se mantienen después de morir.", - "power.origins.natural_armor.name": "Armadura Natural", - "power.origins.natural_armor.description": "Incluso sin armadura, tu piel te proporciona protección.", - "power.origins.more_exhaustion.name": "Gran Apetito", - "power.origins.more_exhaustion.description": "Te da hambre más rápido.", - "power.origins.no_shield.name": "Manos Deformes", - "power.origins.no_shield.description": "La forma de tus manos no te permite cubrirte con escudos.", - "power.origins.strong_arms.name": "Brazos Fuertes", - "power.origins.strong_arms.description": "Eres lo suficientemente fuerte como para romper piedra con tus manos.", - "power.origins.translucent.name": "Transparente", - "power.origins.translucent.description": "Tu piel es transparente.", - "power.origins.end_spawn.name": "Habitante del End", - "power.origins.end_spawn.description": "Tu aventura empieza en el End.", - "power.origins.master_of_webs.name": "Maestro de redes", - "power.origins.master_of_webs.description": "Puedes pasar a través de telarañas sin problemas y puedes hasta escalarlas. Cuando golpeas a un enemigo cuerpo a cuerpo, se quedará atrapado en una telaraña por un rato. Mobs no-artrópodos que se queden atrapados en telarañas serán más fáciles de ver para ti. Puedes fabricar telaraña con hilo.", - "power.origins.lay_eggs.name": "Ovíparo", - "power.origins.lay_eggs.description": "Todas las mañanas cuando despiertes, pondrás un huevo.", - "power.origins.phantomize.name": "Forma Fantasma", - "power.origins.phantomize.description": "Puedes cambiar entre forma fantasma y humana a voluntad, pero si te agotas lo suficiente para no poder correr, vuelves a tu forma humana.", - "power.origins.like_air.name": "Como el Viento", - "power.origins.like_air.description": "Tu velocidad en la tierra se mantiene igual en el aire.", - "power.origins.velvet_paws.name": "Patas Acolchadas", - "power.origins.velvet_paws.description": "Las almohadillas en tus patas hacen que tus pisadas no causen vibraciones, lo que hace que no te puedan detectar los Sensores de Sculk.", - "category.origins": "Orígenes", - "key.origins.primary_active": "Poder Activo (Principal)", - "key.origins.secondary_active": "Poder Activo (Secundario)", - "key.origins.view_origin": "Ver Origen", - "text.autoconfig.origins.title": "Origins Configuration", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "item.origins.orb_of_origin": "Orbe de Orígenes", - "component.item.origins.origin.layer": "Te deja escoger un nuevo %s.", - "component.item.origins.origin.layer_and_origin": "Asigna tu %1$s a \"%2$s\".", - "enchantment.origins.water_protection": "Protección Acuática", - "enchantment.origins.water_protection.desc": "Retrasa el daño por hidrofobia.", - "container.shulker_inventory_power": "Inventario de Shulker", - "origins.gui.select": "Seleccionar", - "origins.gui.close": "Cerrar", - "origins.gui.choose": "Elige", - "origins.gui.choose_origin.title": "Elige tu %s.", - "origins.gui.view_origin.title": "Este es tu %s.", - "origins.gui.view_origin.empty": "No puedes tener ningún origen.", - "origins.gui.view_origin.not_installed": "El servidor no tiene Origins instalado.", - "origins.gui.impact.impact": "Impacto", - "origins.gui.impact.none": "Ninguno", - "origins.gui.impact.low": "Bajo", - "origins.gui.impact.medium": "Intermedio", - "origins.gui.impact.high": "Alto", - "origins.gui.version_mismatch": "Este servidor está usando una versión de Origins (v%1$s) que es incompatible con la que tienes instalada (v%2$s)", - "origins.gui.badge.active": "Habilidad activa. Presione %s para activarla.", - "origins.gui.badge.toggle": "Alternar con %s.", - "origins.gui.badge.recipe.crafting.shaped": "Este poder te deja usar esta Receta (Con forma definida):", - "origins.gui.badge.recipe.crafting.shapeless": "Este poder te deja usar esta Receta (Sin forma definida):", - "origins.gui.unbound_key": "§ono asignado§r", - "origin.origins.random.name": "Aleatorio", - "origin.origins.random.description": "Se te será asignado uno de los siguientes orígenes:", - "layer.origins.origin.name": "Origen", - "origin.origins.empty.name": "Vacío", - "origin.origins.empty.description": "No tienes ningún origen asignado.", - "death.attack.no_water_for_gills": "%1$s no pudo mantenerse hidratado.", - "death.attack.no_water_for_gills.player": "%1$s no pudo mantenerse hidratado por estar peleando contra %2$s.", - "death.attack.hurt_by_water": "%1$s se tomó un baño muy largo.", - "death.attack.hurt_by_water.player": "%1$s está durmiendo con los peces gracias a %2$s.", - "death.attack.genericDamageOverTime": "%1$s murió por daño constante.", - "death.attack.genericDamageOverTime.player": "%1$s murió por daño constante mientras peleaba contra %2$s.", - "commands.origin.origin_not_found": "Origen Desconocido: %s", - "commands.origin.set.success.single": "Origen de %s en la capa %s cambiado a %s.", - "commands.origin.set.success.multiple": "Orígenes de %s objetivos en la capa %s cambiados a %s.", - "commands.origin.get.result": "%s tiene el siguiente %s: &s (%s)", - "commands.origin.gui.all": "Se le ha abierto la pantalla de selección a %s jugadores.", - "commands.origin.gui.layer": "Se le ha abierto la pantalla de selección de \"%2$s\" a %1$s jugadores.", - "origins.avian_sleep_fail": "Necesitas aire fresco para dormir.", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/es_uy.json b/origins/src/main/resources/assets/origins/lang/es_uy.json deleted file mode 100644 index 1c23b20bb..000000000 --- a/origins/src/main/resources/assets/origins/lang/es_uy.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Humano", - "origin.origins.human.description": "Un ser humano común y corriente. Una aventura normal te espera.", - "origin.origins.merling.name": "Tritón", - "origin.origins.merling.description": "Estos habitantes del océano no están acostumbrados a estar fuera del agua por mucho tiempo.", - "origin.origins.arachnid.name": "Arácnido", - "origin.origins.arachnid.description": "Sus habilidades trepadoras y la habilidad de atrapar a sus oponentes en telaraña les hacen grandes cazadores.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "Descendientes de los Blazes. Son naturalmente inmunes a los peligros del Nether.", - "origin.origins.avian.name": "Aviar", - "origin.origins.avian.description": "La raza Aviar ha perdido la habilidad de volar hace mucho tiempo. Ahora se puede ver a estas pacificas criaturas planeando de un lugar a otro.", - "origin.origins.phantom.name": "Fantasma", - "origin.origins.phantom.description": "Mitad Humanos y mitad Fantasmas, estas criaturas pueden cambiar entre su forma normal y Fantasma a su antojo.", - "origin.origins.feline.name": "Felino", - "origin.origins.feline.description": "Con su aspecto gatuno, pueden asustar a los Creepers. Gracias a su destreza felina siempre caen de pie y sin ningún daño.", - "origin.origins.elytrian.name": "Elitria", - "origin.origins.elytrian.description": "Usualmente volando con el viento, los Elitrias se incomodan cuando no tienen suficiente espacio para volar.", - "origin.origins.enderian.name": "Enderianos", - "origin.origins.enderian.description": "Nacidos del Ender Dragon, los Enderianos son capaces de teletransportarse, pero son heridos por el agua.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Relacionados a los Shulkers, los cuerpos de esta especie están cubiertos por una piel tan dura como una armadura.", - "power.origins.water_breathing.name": "Branquias", - "power.origins.water_breathing.description": "Puedes respirar en el agua, pero no en tierra firme.", - "power.origins.aqua_affinity.name": "Afinidad Acuática", - "power.origins.aqua_affinity.description": "Puedes romper bloques bajo el agua a la misma velocidad que otros en tierra.", - "power.origins.water_vision.name": "Ojos Húmedos", - "power.origins.water_vision.description": "Tu visión bajo el agua es perfecta.", - "power.origins.swim_speed.name": "Aletas", - "power.origins.swim_speed.description": "Tu velocidad de nado es mayor que la de otros orígenes.", - "power.origins.like_water.name": "Como el Agua", - "power.origins.like_water.description": "Cuando estás bajo el agua, no te hundes como los demás.", - "power.origins.fragile.name": "Frágil", - "power.origins.fragile.description": "Tienes 3 corazones menos.", - "power.origins.webbing.name": "Tejedor", - "power.origins.webbing.description": "Cuando golpeas a un oponente, quedan atrapados en telaraña.", - "power.origins.climbing.name": "Trepador", - "power.origins.climbing.description": "Eres capaz de escalar cualquier tipo de pared, no sólo escaleras.", - "power.origins.carnivore.name": "Carnívoro", - "power.origins.carnivore.description": "Tu dieta se compone exclusivamente de carne, no puedes digerir vegetales.", - "power.origins.fire_immunity.name": "Inmunidad al Fuego", - "power.origins.fire_immunity.description": "Eres inmune a cualquier tipo de daño por fuego.", - "power.origins.nether_spawn.name": "Habitante del Nether", - "power.origins.nether_spawn.description": "Tu Spawn predeterminado es el Nether.", - "power.origins.burning_wrath.name": "Ira Ardiente", - "power.origins.burning_wrath.description": "Cuando estás ardiendo, haces más daño.", - "power.origins.hotblooded.name": "Sangre Caliente", - "power.origins.hotblooded.description": "Gracias a tu temperatura corporal, el veneno se neutraliza en su sangre, haciéndote inmune a cualquier tipo de efecto venenoso.", - "power.origins.water_vulnerability.name": "Hidrofobia", - "power.origins.water_vulnerability.description": "Recibes daño al entrar en contacto con el agua.", - "power.origins.tailwind.name": "Pie Veloz", - "power.origins.tailwind.description": "Eres un poco más veloz que los otros orígenes.", - "power.origins.slow_falling.name": "Como una Pluma", - "power.origins.slow_falling.description": "Caes lenta y grácilmente como una pluma.", - "power.origins.vegetarian.name": "Vegetariano", - "power.origins.vegetarian.description": "No puedes digerir carnes.", - "power.origins.fresh_air.name": "Aire Fresco", - "power.origins.fresh_air.description": "Para dormir, debes tener tu cama a al menos 86 bloques de altura, para poder respirar aire fresco.", - "power.origins.phasing.name": "Intangible", - "power.origins.phasing.description": "Cuando te conviertes en Fantasma, puedes traspasar cualquier tipo de material, exceptuando Obsidiana y Piedra Base.", - "power.origins.invisibility.name": "Invisibilidad", - "power.origins.invisibility.description": "Cuando te conviertes en Fantasma, eres invisible.", - "power.origins.hunger_over_time.name": "Metabolismo Rápido", - "power.origins.hunger_over_time.description": "Cuando te conviertes en Fantasma te da hambre más rápido.", - "power.origins.burn_in_daylight.name": "Fotoalérgico", - "power.origins.burn_in_daylight.description": "Te empiezas a quemar por el sol si no estás convertido en Fantasma.", - "power.origins.fall_immunity.name": "Acrobacias", - "power.origins.fall_immunity.description": "No recibes daño por caída, sin importar la altura.", - "power.origins.sprint_jump.name": "Tobillos Fuertes", - "power.origins.sprint_jump.description": "Saltas más alto mientras corres.", - "power.origins.nine_lives.name": "Nueve Vidas", - "power.origins.nine_lives.description": "Tienes 1 corazón menos que los humanos.", - "power.origins.cat_vision.name": "Nocturno", - "power.origins.cat_vision.description": "Puedes ver un poco en la oscuridad, a menos que estés en el agua.", - "power.origins.weak_arms.name": "Brazos Débiles", - "power.origins.weak_arms.description": "A menos que estés bajo el efecto de una Poción de Fuerza, sólo puedes minar piedras naturales si tiene menos de 2 otros bloques de piedra adyacentes.", - "power.origins.scare_creepers.name": "Aspecto Felino", - "power.origins.scare_creepers.description": "Los Creepers te tienen miedo y solo explotarán si les atacas.", - "power.origins.launch_into_air.name": "Bendición del Viento", - "power.origins.launch_into_air.description": "Cada 30 Segundos, puedes lanzarte hasta 20 bloques en el aire.", - "power.origins.elytra.name": "Alado", - "power.origins.elytra.description": "Tienes Élitros sin tener que equiparte nada.", - "power.origins.light_armor.name": "Necesidad de Movilidad", - "power.origins.light_armor.description": "No puedes llevar armadura pesada (Armaduras con más protección que cota de mallas).", - "power.origins.claustrophobia.name": "Claustrofobia", - "power.origins.claustrophobia.description": "Estar bajo techo por mucho tiempo te dará Lentitud y Debilidad.", - "power.origins.more_kinetic_damage.name": "Huesos Frágiles", - "power.origins.more_kinetic_damage.description": "Te haces más daño al caer y por chocar volando.", - "power.origins.aerial_combatant.name": "Guerrero Aéreo", - "power.origins.aerial_combatant.description": "Haces más daño al volar con Élitros.", - "power.origins.throw_ender_pearl.name": "Teletransportación", - "power.origins.throw_ender_pearl.description": "Te puedes teletransportar cuando quieras lanzando una Perla de Ender sin hacerte daño.", - "power.origins.pumpkin_hate.name": "Cucurbitofobia", - "power.origins.pumpkin_hate.description": "Le tienes miedo a las calabazas, por buenos motivos.", - "power.origins.extra_reach.name": "Cuerpo Esbelto", - "power.origins.extra_reach.description": "Puede alcanzar bloques y mobs de más lejos.", - "power.origins.shulker_inventory.name": "Acumulador", - "power.origins.shulker_inventory.description": "Tienes 9 espacios de inventario extra, los cuales se mantienen después de morir.", - "power.origins.natural_armor.name": "Armadura Natural", - "power.origins.natural_armor.description": "Incluso sin armadura, tu piel te proporciona protección.", - "power.origins.more_exhaustion.name": "Gran Apetito", - "power.origins.more_exhaustion.description": "Te da hambre más rápido.", - "power.origins.no_shield.name": "Manos Deformes", - "power.origins.no_shield.description": "La forma de tus manos no te permite cubrirte con escudos.", - "power.origins.strong_arms.name": "Brazos Fuertes", - "power.origins.strong_arms.description": "Eres lo suficientemente fuerte como para romper piedra con tus manos.", - "power.origins.translucent.name": "Transparente", - "power.origins.translucent.description": "Tu piel es transparente.", - "power.origins.end_spawn.name": "Habitante del End", - "power.origins.end_spawn.description": "Tu aventura empieza en el End.", - "power.origins.master_of_webs.name": "Maestro de redes", - "power.origins.master_of_webs.description": "Puedes pasar a través de telarañas sin problemas y puedes hasta escalarlas. Cuando golpeas a un enemigo cuerpo a cuerpo, se quedará atrapado en una telaraña por un rato. Mobs no-artrópodos que se queden atrapados en telarañas serán más fáciles de ver para ti. Puedes fabricar telaraña con hilo.", - "power.origins.lay_eggs.name": "Ovíparo", - "power.origins.lay_eggs.description": "Todas las mañanas cuando despiertes, pondrás un huevo.", - "power.origins.phantomize.name": "Forma Fantasma", - "power.origins.phantomize.description": "Puedes cambiar entre forma fantasma y humana a voluntad, pero si te agotas lo suficiente para no poder correr, vuelves a tu forma humana.", - "power.origins.like_air.name": "Como el Viento", - "power.origins.like_air.description": "Tu velocidad en la tierra se mantiene igual en el aire.", - "power.origins.velvet_paws.name": "Patas Acolchadas", - "power.origins.velvet_paws.description": "Las almohadillas en tus patas hacen que tus pisadas no causen vibraciones, lo que hace que no te puedan detectar los Sensores de Sculk.", - "category.origins": "Orígenes", - "key.origins.primary_active": "Poder Activo (Principal)", - "key.origins.secondary_active": "Poder Activo (Secundario)", - "key.origins.view_origin": "Ver Origen", - "text.autoconfig.origins.title": "Origins Configuration", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "item.origins.orb_of_origin": "Orbe de Orígenes", - "component.item.origins.origin.layer": "Te deja escoger un nuevo %s.", - "component.item.origins.origin.layer_and_origin": "Asigna tu %1$s a \"%2$s\".", - "enchantment.origins.water_protection": "Protección Acuática", - "enchantment.origins.water_protection.desc": "Retrasa el daño por hidrofobia.", - "container.shulker_inventory_power": "Inventario de Shulker", - "origins.gui.select": "Seleccionar", - "origins.gui.close": "Cerrar", - "origins.gui.choose": "Elige", - "origins.gui.choose_origin.title": "Elige tu %s.", - "origins.gui.view_origin.title": "Este es tu %s.", - "origins.gui.view_origin.empty": "No puedes tener ningún origen.", - "origins.gui.view_origin.not_installed": "El servidor no tiene Origins instalado.", - "origins.gui.impact.impact": "Impacto", - "origins.gui.impact.none": "Ninguno", - "origins.gui.impact.low": "Bajo", - "origins.gui.impact.medium": "Intermedio", - "origins.gui.impact.high": "Alto", - "origins.gui.version_mismatch": "Este servidor está usando una versión de Origins (v%1$s) que es incompatible con la que tienes instalada (v%2$s)", - "origins.gui.badge.active": "Habilidad activa. Presione %s para activarla.", - "origins.gui.badge.toggle": "Alternar con %s.", - "origins.gui.badge.recipe.crafting.shaped": "Este poder te deja usar esta Receta (Con forma definida):", - "origins.gui.badge.recipe.crafting.shapeless": "Este poder te deja usar esta Receta (Sin forma definida):", - "origins.gui.unbound_key": "§ono asignado§r", - "origin.origins.random.name": "Aleatorio", - "origin.origins.random.description": "Se te será asignado uno de los siguientes orígenes:", - "layer.origins.origin.name": "Origen", - "origin.origins.empty.name": "Vacío", - "origin.origins.empty.description": "No tienes ningún origen asignado.", - "death.attack.no_water_for_gills": "%1$s no pudo mantenerse hidratado.", - "death.attack.no_water_for_gills.player": "%1$s no pudo mantenerse hidratado por estar peleando contra %2$s.", - "death.attack.hurt_by_water": "%1$s se tomó un baño muy largo.", - "death.attack.hurt_by_water.player": "%1$s está durmiendo con los peces gracias a %2$s.", - "death.attack.genericDamageOverTime": "%1$s murió por daño constante.", - "death.attack.genericDamageOverTime.player": "%1$s murió por daño constante mientras peleaba contra %2$s.", - "commands.origin.origin_not_found": "Origen Desconocido: %s", - "commands.origin.set.success.single": "Origen de %s en la capa %s cambiado a %s.", - "commands.origin.set.success.multiple": "Orígenes de %s objetivos en la capa %s cambiados a %s.", - "commands.origin.get.result": "%s tiene el siguiente %s: &s (%s)", - "commands.origin.gui.all": "Se le ha abierto la pantalla de selección a %s jugadores.", - "commands.origin.gui.layer": "Se le ha abierto la pantalla de selección de \"%2$s\" a %1$s jugadores.", - "origins.avian_sleep_fail": "Necesitas aire fresco para dormir.", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/es_ve.json b/origins/src/main/resources/assets/origins/lang/es_ve.json deleted file mode 100644 index 1c23b20bb..000000000 --- a/origins/src/main/resources/assets/origins/lang/es_ve.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Humano", - "origin.origins.human.description": "Un ser humano común y corriente. Una aventura normal te espera.", - "origin.origins.merling.name": "Tritón", - "origin.origins.merling.description": "Estos habitantes del océano no están acostumbrados a estar fuera del agua por mucho tiempo.", - "origin.origins.arachnid.name": "Arácnido", - "origin.origins.arachnid.description": "Sus habilidades trepadoras y la habilidad de atrapar a sus oponentes en telaraña les hacen grandes cazadores.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "Descendientes de los Blazes. Son naturalmente inmunes a los peligros del Nether.", - "origin.origins.avian.name": "Aviar", - "origin.origins.avian.description": "La raza Aviar ha perdido la habilidad de volar hace mucho tiempo. Ahora se puede ver a estas pacificas criaturas planeando de un lugar a otro.", - "origin.origins.phantom.name": "Fantasma", - "origin.origins.phantom.description": "Mitad Humanos y mitad Fantasmas, estas criaturas pueden cambiar entre su forma normal y Fantasma a su antojo.", - "origin.origins.feline.name": "Felino", - "origin.origins.feline.description": "Con su aspecto gatuno, pueden asustar a los Creepers. Gracias a su destreza felina siempre caen de pie y sin ningún daño.", - "origin.origins.elytrian.name": "Elitria", - "origin.origins.elytrian.description": "Usualmente volando con el viento, los Elitrias se incomodan cuando no tienen suficiente espacio para volar.", - "origin.origins.enderian.name": "Enderianos", - "origin.origins.enderian.description": "Nacidos del Ender Dragon, los Enderianos son capaces de teletransportarse, pero son heridos por el agua.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Relacionados a los Shulkers, los cuerpos de esta especie están cubiertos por una piel tan dura como una armadura.", - "power.origins.water_breathing.name": "Branquias", - "power.origins.water_breathing.description": "Puedes respirar en el agua, pero no en tierra firme.", - "power.origins.aqua_affinity.name": "Afinidad Acuática", - "power.origins.aqua_affinity.description": "Puedes romper bloques bajo el agua a la misma velocidad que otros en tierra.", - "power.origins.water_vision.name": "Ojos Húmedos", - "power.origins.water_vision.description": "Tu visión bajo el agua es perfecta.", - "power.origins.swim_speed.name": "Aletas", - "power.origins.swim_speed.description": "Tu velocidad de nado es mayor que la de otros orígenes.", - "power.origins.like_water.name": "Como el Agua", - "power.origins.like_water.description": "Cuando estás bajo el agua, no te hundes como los demás.", - "power.origins.fragile.name": "Frágil", - "power.origins.fragile.description": "Tienes 3 corazones menos.", - "power.origins.webbing.name": "Tejedor", - "power.origins.webbing.description": "Cuando golpeas a un oponente, quedan atrapados en telaraña.", - "power.origins.climbing.name": "Trepador", - "power.origins.climbing.description": "Eres capaz de escalar cualquier tipo de pared, no sólo escaleras.", - "power.origins.carnivore.name": "Carnívoro", - "power.origins.carnivore.description": "Tu dieta se compone exclusivamente de carne, no puedes digerir vegetales.", - "power.origins.fire_immunity.name": "Inmunidad al Fuego", - "power.origins.fire_immunity.description": "Eres inmune a cualquier tipo de daño por fuego.", - "power.origins.nether_spawn.name": "Habitante del Nether", - "power.origins.nether_spawn.description": "Tu Spawn predeterminado es el Nether.", - "power.origins.burning_wrath.name": "Ira Ardiente", - "power.origins.burning_wrath.description": "Cuando estás ardiendo, haces más daño.", - "power.origins.hotblooded.name": "Sangre Caliente", - "power.origins.hotblooded.description": "Gracias a tu temperatura corporal, el veneno se neutraliza en su sangre, haciéndote inmune a cualquier tipo de efecto venenoso.", - "power.origins.water_vulnerability.name": "Hidrofobia", - "power.origins.water_vulnerability.description": "Recibes daño al entrar en contacto con el agua.", - "power.origins.tailwind.name": "Pie Veloz", - "power.origins.tailwind.description": "Eres un poco más veloz que los otros orígenes.", - "power.origins.slow_falling.name": "Como una Pluma", - "power.origins.slow_falling.description": "Caes lenta y grácilmente como una pluma.", - "power.origins.vegetarian.name": "Vegetariano", - "power.origins.vegetarian.description": "No puedes digerir carnes.", - "power.origins.fresh_air.name": "Aire Fresco", - "power.origins.fresh_air.description": "Para dormir, debes tener tu cama a al menos 86 bloques de altura, para poder respirar aire fresco.", - "power.origins.phasing.name": "Intangible", - "power.origins.phasing.description": "Cuando te conviertes en Fantasma, puedes traspasar cualquier tipo de material, exceptuando Obsidiana y Piedra Base.", - "power.origins.invisibility.name": "Invisibilidad", - "power.origins.invisibility.description": "Cuando te conviertes en Fantasma, eres invisible.", - "power.origins.hunger_over_time.name": "Metabolismo Rápido", - "power.origins.hunger_over_time.description": "Cuando te conviertes en Fantasma te da hambre más rápido.", - "power.origins.burn_in_daylight.name": "Fotoalérgico", - "power.origins.burn_in_daylight.description": "Te empiezas a quemar por el sol si no estás convertido en Fantasma.", - "power.origins.fall_immunity.name": "Acrobacias", - "power.origins.fall_immunity.description": "No recibes daño por caída, sin importar la altura.", - "power.origins.sprint_jump.name": "Tobillos Fuertes", - "power.origins.sprint_jump.description": "Saltas más alto mientras corres.", - "power.origins.nine_lives.name": "Nueve Vidas", - "power.origins.nine_lives.description": "Tienes 1 corazón menos que los humanos.", - "power.origins.cat_vision.name": "Nocturno", - "power.origins.cat_vision.description": "Puedes ver un poco en la oscuridad, a menos que estés en el agua.", - "power.origins.weak_arms.name": "Brazos Débiles", - "power.origins.weak_arms.description": "A menos que estés bajo el efecto de una Poción de Fuerza, sólo puedes minar piedras naturales si tiene menos de 2 otros bloques de piedra adyacentes.", - "power.origins.scare_creepers.name": "Aspecto Felino", - "power.origins.scare_creepers.description": "Los Creepers te tienen miedo y solo explotarán si les atacas.", - "power.origins.launch_into_air.name": "Bendición del Viento", - "power.origins.launch_into_air.description": "Cada 30 Segundos, puedes lanzarte hasta 20 bloques en el aire.", - "power.origins.elytra.name": "Alado", - "power.origins.elytra.description": "Tienes Élitros sin tener que equiparte nada.", - "power.origins.light_armor.name": "Necesidad de Movilidad", - "power.origins.light_armor.description": "No puedes llevar armadura pesada (Armaduras con más protección que cota de mallas).", - "power.origins.claustrophobia.name": "Claustrofobia", - "power.origins.claustrophobia.description": "Estar bajo techo por mucho tiempo te dará Lentitud y Debilidad.", - "power.origins.more_kinetic_damage.name": "Huesos Frágiles", - "power.origins.more_kinetic_damage.description": "Te haces más daño al caer y por chocar volando.", - "power.origins.aerial_combatant.name": "Guerrero Aéreo", - "power.origins.aerial_combatant.description": "Haces más daño al volar con Élitros.", - "power.origins.throw_ender_pearl.name": "Teletransportación", - "power.origins.throw_ender_pearl.description": "Te puedes teletransportar cuando quieras lanzando una Perla de Ender sin hacerte daño.", - "power.origins.pumpkin_hate.name": "Cucurbitofobia", - "power.origins.pumpkin_hate.description": "Le tienes miedo a las calabazas, por buenos motivos.", - "power.origins.extra_reach.name": "Cuerpo Esbelto", - "power.origins.extra_reach.description": "Puede alcanzar bloques y mobs de más lejos.", - "power.origins.shulker_inventory.name": "Acumulador", - "power.origins.shulker_inventory.description": "Tienes 9 espacios de inventario extra, los cuales se mantienen después de morir.", - "power.origins.natural_armor.name": "Armadura Natural", - "power.origins.natural_armor.description": "Incluso sin armadura, tu piel te proporciona protección.", - "power.origins.more_exhaustion.name": "Gran Apetito", - "power.origins.more_exhaustion.description": "Te da hambre más rápido.", - "power.origins.no_shield.name": "Manos Deformes", - "power.origins.no_shield.description": "La forma de tus manos no te permite cubrirte con escudos.", - "power.origins.strong_arms.name": "Brazos Fuertes", - "power.origins.strong_arms.description": "Eres lo suficientemente fuerte como para romper piedra con tus manos.", - "power.origins.translucent.name": "Transparente", - "power.origins.translucent.description": "Tu piel es transparente.", - "power.origins.end_spawn.name": "Habitante del End", - "power.origins.end_spawn.description": "Tu aventura empieza en el End.", - "power.origins.master_of_webs.name": "Maestro de redes", - "power.origins.master_of_webs.description": "Puedes pasar a través de telarañas sin problemas y puedes hasta escalarlas. Cuando golpeas a un enemigo cuerpo a cuerpo, se quedará atrapado en una telaraña por un rato. Mobs no-artrópodos que se queden atrapados en telarañas serán más fáciles de ver para ti. Puedes fabricar telaraña con hilo.", - "power.origins.lay_eggs.name": "Ovíparo", - "power.origins.lay_eggs.description": "Todas las mañanas cuando despiertes, pondrás un huevo.", - "power.origins.phantomize.name": "Forma Fantasma", - "power.origins.phantomize.description": "Puedes cambiar entre forma fantasma y humana a voluntad, pero si te agotas lo suficiente para no poder correr, vuelves a tu forma humana.", - "power.origins.like_air.name": "Como el Viento", - "power.origins.like_air.description": "Tu velocidad en la tierra se mantiene igual en el aire.", - "power.origins.velvet_paws.name": "Patas Acolchadas", - "power.origins.velvet_paws.description": "Las almohadillas en tus patas hacen que tus pisadas no causen vibraciones, lo que hace que no te puedan detectar los Sensores de Sculk.", - "category.origins": "Orígenes", - "key.origins.primary_active": "Poder Activo (Principal)", - "key.origins.secondary_active": "Poder Activo (Secundario)", - "key.origins.view_origin": "Ver Origen", - "text.autoconfig.origins.title": "Origins Configuration", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "item.origins.orb_of_origin": "Orbe de Orígenes", - "component.item.origins.origin.layer": "Te deja escoger un nuevo %s.", - "component.item.origins.origin.layer_and_origin": "Asigna tu %1$s a \"%2$s\".", - "enchantment.origins.water_protection": "Protección Acuática", - "enchantment.origins.water_protection.desc": "Retrasa el daño por hidrofobia.", - "container.shulker_inventory_power": "Inventario de Shulker", - "origins.gui.select": "Seleccionar", - "origins.gui.close": "Cerrar", - "origins.gui.choose": "Elige", - "origins.gui.choose_origin.title": "Elige tu %s.", - "origins.gui.view_origin.title": "Este es tu %s.", - "origins.gui.view_origin.empty": "No puedes tener ningún origen.", - "origins.gui.view_origin.not_installed": "El servidor no tiene Origins instalado.", - "origins.gui.impact.impact": "Impacto", - "origins.gui.impact.none": "Ninguno", - "origins.gui.impact.low": "Bajo", - "origins.gui.impact.medium": "Intermedio", - "origins.gui.impact.high": "Alto", - "origins.gui.version_mismatch": "Este servidor está usando una versión de Origins (v%1$s) que es incompatible con la que tienes instalada (v%2$s)", - "origins.gui.badge.active": "Habilidad activa. Presione %s para activarla.", - "origins.gui.badge.toggle": "Alternar con %s.", - "origins.gui.badge.recipe.crafting.shaped": "Este poder te deja usar esta Receta (Con forma definida):", - "origins.gui.badge.recipe.crafting.shapeless": "Este poder te deja usar esta Receta (Sin forma definida):", - "origins.gui.unbound_key": "§ono asignado§r", - "origin.origins.random.name": "Aleatorio", - "origin.origins.random.description": "Se te será asignado uno de los siguientes orígenes:", - "layer.origins.origin.name": "Origen", - "origin.origins.empty.name": "Vacío", - "origin.origins.empty.description": "No tienes ningún origen asignado.", - "death.attack.no_water_for_gills": "%1$s no pudo mantenerse hidratado.", - "death.attack.no_water_for_gills.player": "%1$s no pudo mantenerse hidratado por estar peleando contra %2$s.", - "death.attack.hurt_by_water": "%1$s se tomó un baño muy largo.", - "death.attack.hurt_by_water.player": "%1$s está durmiendo con los peces gracias a %2$s.", - "death.attack.genericDamageOverTime": "%1$s murió por daño constante.", - "death.attack.genericDamageOverTime.player": "%1$s murió por daño constante mientras peleaba contra %2$s.", - "commands.origin.origin_not_found": "Origen Desconocido: %s", - "commands.origin.set.success.single": "Origen de %s en la capa %s cambiado a %s.", - "commands.origin.set.success.multiple": "Orígenes de %s objetivos en la capa %s cambiados a %s.", - "commands.origin.get.result": "%s tiene el siguiente %s: &s (%s)", - "commands.origin.gui.all": "Se le ha abierto la pantalla de selección a %s jugadores.", - "commands.origin.gui.layer": "Se le ha abierto la pantalla de selección de \"%2$s\" a %1$s jugadores.", - "origins.avian_sleep_fail": "Necesitas aire fresco para dormir.", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/fi_fi.json b/origins/src/main/resources/assets/origins/lang/fi_fi.json deleted file mode 100644 index f2b7a5427..000000000 --- a/origins/src/main/resources/assets/origins/lang/fi_fi.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Ihminen", - "origin.origins.human.description": "Tavallinen ihminen. Tavanomainen Minecraft-kokemuksesi odottaa.", - "origin.origins.merling.name": "Merliini", - "origin.origins.merling.description": "Nämä meren asukkaat eivät ole tottuneet olemaan liian pitkään ilman vettä.", - "origin.origins.arachnid.name": "Hämähäkkieläin", - "origin.origins.arachnid.description": "Kiipeilytaito ja kyky vangita vihollisensa hämähäkinverkkoon tekevät niistä täydellisiä metsästäjiä.", - "origin.origins.blazeborn.name": "Roihukainen", - "origin.origins.blazeborn.description": "Roihun jälkeläisinä roihukaiset ovat luonnostaan immuuneja Netherin vaaroille.", - "origin.origins.avian.name": "Siivekäs", - "origin.origins.avian.description": "Siivekäs-rotu on menettänyt lentokykynsä jo kauan sitten. Nyt näitä rauhallisia olentoja voi havaita liitelevän paikasta toiseen.", - "origin.origins.phantom.name": "Aave", - "origin.origins.phantom.description": "Puoliksi ihminen ja puoliksi aave, nämä olennot pystyvät vaihtamaan aaveen ja normaalin muodon välillä.", - "origin.origins.feline.name": "Kissaeläin", - "origin.origins.feline.description": "Kissamaisen ulkonäkönsä ansiosta kissaeläimet pelottavat creeperit pois. Ne laskeutuvat aina turvallisesti jaloilleen kissan näppäryydellä.", - "origin.origins.elytrian.name": "Elytrialainen", - "origin.origins.elytrian.description": "Elytrialaiset lentävät usein tuulien mukana, ja tuntevat olonsa epämukavaksi, kun heidän yläpuolella ei ole tarpeeksi tilaa.", - "origin.origins.enderian.name": "Enderialainen", - "origin.origins.enderian.description": "Ender-lohikäärmeen lapsina syntyneet enderialaiset kykenevät teleportaatioon, mutta ovat alttiita vedelle.", - "origin.origins.shulk.name": "Shulkki", - "origin.origins.shulk.description": "Samoin kuin shulkerit, shulkkien vartalot on varustettu suojaavalla kuorimaisella iholla.", - "power.origins.water_breathing.name": "Kidukset", - "power.origins.water_breathing.description": "Voit hengittää veden alla, mutta et kuivalla maalla.", - "power.origins.aqua_affinity.name": "Vesimieltymys", - "power.origins.aqua_affinity.description": "Voit rikkoa kuutioita veden alla, kuten muut tekevät kuivalla maalla.", - "power.origins.water_vision.name": "Kosteat silmät", - "power.origins.water_vision.description": "Näkösi veden alla on täydellinen.", - "power.origins.swim_speed.name": "Evät", - "power.origins.swim_speed.description": "Vedenalainen nopeutesi on suurempi.", - "power.origins.like_water.name": "Kuin vettä", - "power.origins.like_water.description": "Kun olet veden alla, et painu pohjaan, ellet halua.", - "power.origins.fragile.name": "Hauras", - "power.origins.fragile.description": "Sinulla on 3 sydäntä vähemmän elinvoimaa kuin ihmisillä.", - "power.origins.webbing.name": "Verkosto", - "power.origins.webbing.description": "Kun osut viholliseen lähitaistelussa, se takertuu hämähäkinseittiin.", - "power.origins.climbing.name": "Kiipeily", - "power.origins.climbing.description": "Pystyt kiipeämään ylös mitä tahansa seinää, etkä vain tikkaita.", - "power.origins.carnivore.name": "Lihansyöjä", - "power.origins.carnivore.description": "Ruokavaliosi koostuu vain lihasta, et voi syödä kasvisruokia.", - "power.origins.fire_immunity.name": "Tuli immuniteetti", - "power.origins.fire_immunity.description": "Olet immuuni kaikenlaiselle tulivahingolle.", - "power.origins.nether_spawn.name": "Nether asukki", - "power.origins.nether_spawn.description": "Syntymäpisteesi on Netherissä.", - "power.origins.burning_wrath.name": "Palava raivo", - "power.origins.burning_wrath.description": "Kun olet tulessa, aiheutat lisävahinkoa hyökkäyksilläsi.", - "power.origins.hotblooded.name": "Kuumaverinen", - "power.origins.hotblooded.description": "Kuuman kehosi ansiosta myrkyt palavat, jolloin olet immuuni myrkky- ja nälkätilavaikutuksille.", - "power.origins.water_vulnerability.name": "Vesikammo", - "power.origins.water_vulnerability.description": "Otat vahinkoa ajan myötä, kun olet kosketuksissa veden kanssa.", - "power.origins.tailwind.name": "Myötätuuli", - "power.origins.tailwind.description": "Olet hieman nopeampi kuin muut.", - "power.origins.slow_falling.name": "Höyhensarjalainen", - "power.origins.slow_falling.description": "Putoat maahan yhtä kevyesti kuin höyhen, ellet hiivi.", - "power.origins.vegetarian.name": "Kasvissyöjä", - "power.origins.vegetarian.description": "Et pysty syömään lihaa.", - "power.origins.fresh_air.name": "Raikas ilma", - "power.origins.fresh_air.description": "Kun nukut, sänkysi on oltava vähintään 86 kuution korkeudessa, jotta voit hengittää raitista ilmaa.", - "power.origins.phasing.name": "Aineeton", - "power.origins.phasing.description": "Kun olet aave muodossa, voit kävellä kiinteiden materiaalien läpi, paitsi obsidiaanin.", - "power.origins.invisibility.name": "Näkymättömyys", - "power.origins.invisibility.description": "Kun olet aave muodossa, olet näkymätön.", - "power.origins.hunger_over_time.name": "Nopea aineenvaihdunta", - "power.origins.hunger_over_time.description": "Aave muodossa oleminen tekee sinusta nälkäisen.", - "power.origins.burn_in_daylight.name": "Valoallerginen", - "power.origins.burn_in_daylight.description": "Palat päivänvalossa, jos et ole näkymätön.", - "power.origins.fall_immunity.name": "Akrobatia", - "power.origins.fall_immunity.description": "Et ota koskaan putoamisvahinkoa, riippumatta siitä, miltä korkeudelta putoat.", - "power.origins.sprint_jump.name": "Vahvat nilkat", - "power.origins.sprint_jump.description": "Voit hypätä korkeammalle hyppäämällä samalla kun juokset.", - "power.origins.nine_lives.name": "Yhdeksän elämää", - "power.origins.nine_lives.description": "Sinulla on 1 sydän vähemmän elinvoimaa kuin ihmisillä.", - "power.origins.cat_vision.name": "Öinen", - "power.origins.cat_vision.description": "Näet hieman pimeässä, mikäli et ole vedessä.", - "power.origins.weak_arms.name": "Heikot kädet", - "power.origins.weak_arms.description": "Kun et ole vahvuuden taikajuoman vaikutuksen alaisena, voit louhia luonnonkiviä vain, jos sen ympärillä on enintään 2 muuta luonnonkivikuutiota.", - "power.origins.scare_creepers.name": "Kissamainen ulkonäkö", - "power.origins.scare_creepers.description": "Creeperit pelkäävät sinua ja räjähtävät vain, jos hyökkäät niiden kimppuun ensin.", - "power.origins.launch_into_air.name": "Tuulten lahja", - "power.origins.launch_into_air.description": "Joka 30. sekunti voit laukaista itsesi noin 20 kuution korkeuteen.", - "power.origins.elytra.name": "Siivekäs", - "power.origins.elytra.description": "Sinulla on elytra-siivet ilman, että sinun tarvitsee pukea niitä.", - "power.origins.light_armor.name": "Liikkumisen tarve", - "power.origins.light_armor.description": "Et voi käyttää raskaita panssareita (panssareita, joiden suojaavuus on suurempi kuin rengashaarniskan).", - "power.origins.claustrophobia.name": "Klaustrofobia", - "power.origins.claustrophobia.description": "Liian pitkä oleskelu matalassa tilassa heikentää sinua ja tekee sinusta hitaamman.", - "power.origins.more_kinetic_damage.name": "Hauraat luut", - "power.origins.more_kinetic_damage.description": "Otat enemmän vahinkoa putoamisesta ja kuutioihin lentämisestä.", - "power.origins.aerial_combatant.name": "Lentotaistelija", - "power.origins.aerial_combatant.description": "Aiheutat huomattavasti enemmän vahinkoa, kun olet elytralennossa.", - "power.origins.throw_ender_pearl.name": "Teleportaatio", - "power.origins.throw_ender_pearl.description": "Voit aina halutessasi heittää ender-helmen, joka ei aiheuta vahinkoa ja jonka avulla voit teleportata.", - "power.origins.pumpkin_hate.name": "Kurpitsoja pelkäävä", - "power.origins.pumpkin_hate.description": "Pelkäät kurpitsoja. Hyvästä syystä.", - "power.origins.extra_reach.name": "Hoikka vartalo", - "power.origins.extra_reach.description": "Yletyt kauempana oleviin kuutioihin ja olioihin.", - "power.origins.shulker_inventory.name": "Hamstraaja", - "power.origins.shulker_inventory.description": "Sinulla on käytössäsi 9 ylimääräistä tavaraluettelon paikkaa, jotka säilyttävät esineet kuoleman sattuessa.", - "power.origins.natural_armor.name": "Vankka iho", - "power.origins.natural_armor.description": "Ihosi tarjoaa luonnollisen suojan myös ilman panssaria.", - "power.origins.more_exhaustion.name": "Suuri ruokahalu", - "power.origins.more_exhaustion.description": "Sinä uuvut paljon nopeammin kuin muut, joten sinun on syötävä enemmän.", - "power.origins.no_shield.name": "Kömpelö", - "power.origins.no_shield.description": "Tapa, miten kätesi ovat muotoutuneet, ei anna mahdollisuutta pitää kilpiä pystyasennossa.", - "power.origins.strong_arms.name": "Vahvat kädet", - "power.origins.strong_arms.description": "Olet niin vahva, että pystyt rikkomaan luonnonkiviä ilman hakkua.", - "power.origins.translucent.name": "Läpikuultava", - "power.origins.translucent.description": "Ihosi on läpikuultava.", - "power.origins.end_spawn.name": "End asukki", - "power.origins.end_spawn.description": "Matkasi alkaa Endissä.", - "power.origins.master_of_webs.name": "Verkkojen mestari", - "power.origins.master_of_webs.description": "Liikut täydellisesti hämähäkinseiteissä ja pystyt kiipeilemään niissä. Kun osut viholliseen lähitaistelussa, se takertuu hämähäkinseittiin hetkeksi. Tunnistat hämähäkinseittiin juuttuneet, jos ne ei ole niveljalkaisia. Pystyt valmistamaan hämähäkinverkkoa narusta.", - "power.origins.lay_eggs.name": "Ovipaarinen", - "power.origins.lay_eggs.description": "Aina kun heräät aamulla, munit munan.", - "power.origins.phantomize.name": "Aave muoto", - "power.origins.phantomize.description": "Voit vaihtaa halutessasi ihmis- ja aavemuodon välillä, mutta vain silloin, kun olet tarpeeksi kylläinen juostaksesi.", - "power.origins.like_air.name": "Kuin ilmaa", - "power.origins.like_air.description": "Kävelynopeuden määrittelyjä käytetään myös ilmassa ollessasi.", - "power.origins.velvet_paws.name": "Samettitassut", - "power.origins.velvet_paws.description": "Askeleesi eivät aiheuta värähtelyjä, jotka läheiset elämänmuodot voisivat muuten havaita.", - "category.origins": "Alkuperät", - "key.origins.primary_active": "Aktiivinen voima (ensisijainen)", - "key.origins.secondary_active": "Aktiivinen voima (toissijainen)", - "key.origins.view_origin": "Näytä alkuperä", - "text.autoconfig.origins.title": "Origins-konfiguraatio", - "text.autoconfig.origins.option.xOffset": "Jäähdytyspalkin poikkeama X", - "text.autoconfig.origins.option.yOffset": "Jäähdytyspalkin poikkeama Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Aave muodon voimakkuus", - "item.origins.orb_of_origin": "Alkuperän pallo", - "component.item.origins.origin.layer": "Antaa sinun valita uuden %sn.", - "component.item.origins.origin.layer_and_origin": "Asettaa sinun %1$sn arvoksi \"%2$s\".", - "enchantment.origins.water_protection": "Vesisuojaus", - "enchantment.origins.water_protection.desc": "Viivästyttää vesikammon aiheuttamaa vahinkoa.", - "container.shulker_inventory_power": "Shulkerin tavaraluettelo", - "origins.gui.select": "Valitse", - "origins.gui.close": "Sulje", - "origins.gui.choose": "Valitse", - "origins.gui.choose_origin.title": "Valitse oma %s.", - "origins.gui.view_origin.title": "Tämä on sinun %s.", - "origins.gui.view_origin.empty": "Sinulla ei voi olla mitään alkuperää.", - "origins.gui.view_origin.not_installed": "Palvelimelle ei ole asennettu Originsia.", - "origins.gui.impact.impact": "Vaikutus", - "origins.gui.impact.none": "Ei yhtään", - "origins.gui.impact.low": "Matala", - "origins.gui.impact.medium": "Keskisuuri", - "origins.gui.impact.high": "Korkea", - "origins.gui.version_mismatch": "Tällä palvelimella on käytössä eri versio Originsista (v%1$s), joka ei ole yhteensopiva asentamasi version (v%2$s) kanssa.", - "origins.gui.badge.active": "Aktiivinen voima, käytä näppäimellä %s.", - "origins.gui.badge.toggle": "Kytke näppäimellä %s.", - "origins.gui.badge.recipe.crafting.shaped": "Resepti (muotoiltu):", - "origins.gui.badge.recipe.crafting.shapeless": "Resepti (muodoton):", - "origins.gui.unbound_key": "§oei näppäintä§r", - "origin.origins.random.name": "Satunnainen", - "origin.origins.random.description": "Sinulle asetetaan yksi seuraavista vaihtoehdoista:", - "layer.origins.origin.name": "Alkuperä", - "origin.origins.empty.name": "Puuttuu", - "origin.origins.empty.description": "Sinulla ei ole alkuperää.", - "death.attack.no_water_for_gills": "%1$s ei onnistunut pysymään kosteana", - "death.attack.no_water_for_gills.player": "%1$s ei onnistunut pysymään kosteana koska taisteli pelaajaa %2$s vastaan", - "death.attack.hurt_by_water": "%1$s kylpi liian kauan", - "death.attack.hurt_by_water.player": "%1$s upotettiin veden alle pelaajan %2$s toimesta", - "death.attack.genericDamageOverTime": "%1$s kuoli ajan myötä tapahtuvaan vahinkoon", - "death.attack.genericDamageOverTime.player": "%1$s kuoli ajan myötä tapahtuvaan vahinkoon taistellessaan pelaajaa %2$s vastaan", - "commands.origin.origin_not_found": "Tuntematon alkuperä: %s", - "commands.origin.layer_not_found": "Tuntematon kerros: %s", - "commands.origin.unregistered_in_layer": "Alkuperä %1$s ei ole rekisteröity kerrokseen %2$s!", - "commands.origin.get.result": "Pelaajalla %s on seuraava %s: %s (%s)", - "commands.origin.gui.all": "Valintakäyttöliittymä avattu %s pelaajalle", - "commands.origin.gui.layer": "Valintakäyttöliittymä \"%2$s\" avattu %1$s pelaajalle", - "commands.origin.random.all": "Satunnaisesti asetettiin alkuperä %1$s kohteelle %2$s kerroksessa", - "commands.origin.random.not_allowed": "Kerros %1$s ei salli satunnaisia alkuperiä!", - "commands.origin.random.success.multiple": "Satunnaisesti asetettiin alkuperä %1$s kohteelle kerroksessa %2$s", - "commands.origin.random.success.single": "Satunnaisesti asetettiin alkuperä %2$s pelaajalle %1$s kerroksessa %3$s", - "commands.origin.set.success.multiple": "Asetettiin %s kohteen alkuperä kerroksessa %s arvoon %s", - "commands.origin.set.success.single": "Asetettiin pelaajan %s alkuperä kerroksessa %s arvoon %s.", - "origins.avian_sleep_fail": "Tarvitset raikasta ilmaa nukkuaksesi" -} diff --git a/origins/src/main/resources/assets/origins/lang/fr_fr.json b/origins/src/main/resources/assets/origins/lang/fr_fr.json deleted file mode 100644 index ce2c29763..000000000 --- a/origins/src/main/resources/assets/origins/lang/fr_fr.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Humain", - "origin.origins.human.description": "Un être humain ordinaire, qui aura une expérience Minecraft ordinaire.", - "origin.origins.merling.name": "Sirènet", - "origin.origins.merling.description": "Ces habitants de la mer ne sont pas habitués à rester hors de l'eau.", - "origin.origins.arachnid.name": "Arachnide", - "origin.origins.arachnid.description": "Grimpeurs et trappeurs naturels, les arachnides font des chasseurs hors pair.", - "origin.origins.blazeborn.name": "Enfantage du Blaze", - "origin.origins.blazeborn.description": "Quelques personnes rares sont descendants des Blazes ; elles seront à l'aise dans les mers de lave du Nether.", - "origin.origins.avian.name": "Aviaire", - "origin.origins.avian.description": "Il était une époque où les aviaires pouvaient voler – aujourd'hui, on ne les voit guère que planant d'un endroit à l'autre.", - "origin.origins.phantom.name": "Demi-Phantom", - "origin.origins.phantom.description": "En tant qu'hybrides des Hommes et des Phantoms, ils peuvent passer d'une forme à l'autre.", - "origin.origins.feline.name": "Félin", - "origin.origins.feline.description": "Les Creepers ont peur de leur apparence féline et leur instinct acrobatique leur permet de toujours retomber sur leurs pieds.", - "origin.origins.elytrian.name": "Élytrien", - "origin.origins.elytrian.description": "Habitués à virevolter dans le vent, les Élytriens ne se sentent pas à l'aise sous les plafonds bas.", - "origin.origins.enderian.name": "Enderien", - "origin.origins.enderian.description": "Les fils et filles de l'Ender Dragon peuvent se téléporter, mais l'eau leur nuira.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Apparentés aux Shulkers, les corps de Shulk sont habillés d'une peau protectrice telle une coquille.", - "power.origins.water_breathing.name": "Branchies", - "power.origins.water_breathing.description": "Vous ne pourrez respirer que sous l'eau.", - "power.origins.aqua_affinity.name": "Affinité aquatique", - "power.origins.aqua_affinity.description": "Vous pourrez détruire les blocs sous l'eau comme d'autres le font sur la surface.", - "power.origins.water_vision.name": "Yeux mouillés", - "power.origins.water_vision.description": "Votre vision sous l'eau sera parfaite.", - "power.origins.swim_speed.name": "Nageoires", - "power.origins.swim_speed.description": "Vous serez plus rapide sous l'eau.", - "power.origins.like_water.name": "Comme l'eau", - "power.origins.like_water.description": "Vous ne coulerez pas sous l'eau, sauf si vous le voulez.", - "power.origins.fragile.name": "Fragile", - "power.origins.fragile.description": "Vous avez trois cœurs de moins que la plupart.", - "power.origins.webbing.name": "Toile d'araignée", - "power.origins.webbing.description": "Si vous attaquez un monstre, il se trouvera coincé dans votre toile.", - "power.origins.climbing.name": "Grimpe-partout", - "power.origins.climbing.description": "Vous pourrez grimper à n'importe quel mur.", - "power.origins.carnivore.name": "Carnivore", - "power.origins.carnivore.description": "Vous ne pourrez manger que de la viande.", - "power.origins.fire_immunity.name": "Immunité au feu", - "power.origins.fire_immunity.description": "Le feu ne vous endommagera jamais.", - "power.origins.nether_spawn.name": "Résident du Nether", - "power.origins.nether_spawn.description": "Vous trouverez votre point de réapparition au Nether.", - "power.origins.burning_wrath.name": "Courroux du Blaze", - "power.origins.burning_wrath.description": "Vos coups seront plus puissants si vous êtes en feu.", - "power.origins.hotblooded.name": "Hyperthermie", - "power.origins.hotblooded.description": "Votre sang sera si chaud que ni les poisons ni la putréfaction vous affecteront.", - "power.origins.water_vulnerability.name": "Hydrophobie", - "power.origins.water_vulnerability.description": "Rester dans l'eau vous endommagera.", - "power.origins.tailwind.name": "Vent arrière", - "power.origins.tailwind.description": "Vous serez un peu plus rapide à pied que la moyenne.", - "power.origins.slow_falling.name": "Légèreté", - "power.origins.slow_falling.description": "Vous tomberez doucement comme une plume, tant que vous ne vous accroupissez pas.", - "power.origins.vegetarian.name": "Végétarien", - "power.origins.vegetarian.description": "Vous ne pourrez pas digérer la viande.", - "power.origins.fresh_air.name": "L'air frais", - "power.origins.fresh_air.description": "S'endormir nécessite un lit à une hauteur d'au moins 86 blocs, afin que vous puissiez respirer un air vraiment frais.", - "power.origins.phasing.name": "Incorporel", - "power.origins.phasing.description": "Adopter une forme de Phantom vous laisse passer dans des blocs solides (sauf l'obsidienne).", - "power.origins.invisibility.name": "Invisibilité", - "power.origins.invisibility.description": "Adopter une forme de Phantom vous rend invisible.", - "power.origins.hunger_over_time.name": "Métabolisme rapide", - "power.origins.hunger_over_time.description": "Adopter une forme de Phantom vous donne faim.", - "power.origins.burn_in_daylight.name": "Colère du soleil", - "power.origins.burn_in_daylight.description": "Si vous ne restez pas invisible, le soleil vous brûlera.", - "power.origins.fall_immunity.name": "Acrobaties", - "power.origins.fall_immunity.description": "Vous avez l'art de ne jamais vous blesser en tombant.", - "power.origins.sprint_jump.name": "Chevilles fortes", - "power.origins.sprint_jump.description": "Vos sauts seront plus hauts si vous sprintez.", - "power.origins.nine_lives.name": "Neuf vies ?", - "power.origins.nine_lives.description": "Vous avez un cœur en moins que la plupart.", - "power.origins.cat_vision.name": "Nocturne", - "power.origins.cat_vision.description": "Vous pouvez voir dans le noir (sauf dans l'eau).", - "power.origins.weak_arms.name": "Bras faibles", - "power.origins.weak_arms.description": "Si vous ne buvez pas une potion de force, vous ne pourrez miner que des blocs de roche naturelle isolés (moins de deux blocs de roche naturelle adjacents).", - "power.origins.scare_creepers.name": "Visage du chat", - "power.origins.scare_creepers.description": "Votre apparence effraie les Creepers ; ils n'exploseront qu'après que vous les frappez.", - "power.origins.launch_into_air.name": "Don du vent", - "power.origins.launch_into_air.description": "Vous pourrez vous lancer environ vingt blocs dans les airs toutes les trente secondes.", - "power.origins.elytra.name": "Ailé", - "power.origins.elytra.description": "Vous avez des ailes d'Élytres sans même en équiper.", - "power.origins.light_armor.name": "20 Minutes du Mans", - "power.origins.light_armor.description": "Les armures plus lourdes que la maille ne vous conviennent pas.", - "power.origins.claustrophobia.name": "Claustrophobie", - "power.origins.claustrophobia.description": "Rester sous un plafond bas trop longtemps vous ralentira et vous affaiblira.", - "power.origins.more_kinetic_damage.name": "Os cassants", - "power.origins.more_kinetic_damage.description": "Vous vous blesserez plus lourdement si vous tombez, ou si vous percutez un bloc en vol.", - "power.origins.aerial_combatant.name": "Chasseur extraordinaire", - "power.origins.aerial_combatant.description": "Vos coups seront considérablement plus forts lorsque vous volez avec des élytres.", - "power.origins.throw_ender_pearl.name": "Téléportation", - "power.origins.throw_ender_pearl.description": "Vous pouvez lancer une perle de l'Ender pour vous téléporter n'importe quand – elle n'infligera pas de dégâts.", - "power.origins.pumpkin_hate.name": "Citrouilles effrayantes", - "power.origins.pumpkin_hate.description": "Vous avez raison d'avoir peur des citrouilles.", - "power.origins.extra_reach.name": "Mince et souple", - "power.origins.extra_reach.description": "Vous pourrez atteindre les choses de plus loin.", - "power.origins.shulker_inventory.name": "Thésauriseur", - "power.origins.shulker_inventory.description": "Vous avez accès à 9 emplacements d'inventaire supplémentaires, gardant leurs contenus après la mort.", - "power.origins.natural_armor.name": "Peau robuste", - "power.origins.natural_armor.description": "Même sans armure, votre peau offre une protection naturelle.", - "power.origins.more_exhaustion.name": "Gros mangeur", - "power.origins.more_exhaustion.description": "Les tâches du quotidien vous affament plus rapidement que la moyenne.", - "power.origins.no_shield.name": "Malhabile", - "power.origins.no_shield.description": "La façon dont vos mains sont formées vous empêche de tenir un bouclier correctement.", - "power.origins.strong_arms.name": "Costaud", - "power.origins.strong_arms.description": "Vous avez suffisamment de force pour briser de la roche naturelle à main nue.", - "power.origins.translucent.name": "Translucent", - "power.origins.translucent.description": "Votre peau est translucente.", - "category.origins": "Origines", - "key.origins.primary_active": "Pouvoir actif", - "key.origins.view_origin": "Afficher l'origine", - "text.autoconfig.origins.title": "Configuration d'Origins", - "text.autoconfig.origins.option.xOffset": "Offset X de la barre de rechargement", - "text.autoconfig.origins.option.yOffset": "Offset Y de la barre de rechargement", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Force de l'overlay en forme Phantom", - "item.origins.orb_of_origin": "Orbe d'origine", - "enchantment.origins.water_protection": "Protection contre l'eau", - "origins.gui.select": "Choisir", - "origins.gui.close": "Fermer", - "origins.gui.choose_origin.title": "Choisir votre origine", - "origins.gui.view_origin.title": "Votre origine", - "origins.gui.impact.impact": "Impact", - "origins.gui.impact.none": "Aucun", - "origins.gui.impact.low": "Faible", - "origins.gui.impact.medium": "Moyen", - "origins.gui.impact.high": "Élevé", - "layer.origins.origin.name": "Origine", - "origin.origins.empty.name": "Manquante", - "origin.origins.empty.description": "Vous n'avez pas d'origine.", - "death.attack.no_water_for_gills": "%s n'a pas réussi à rester mouillé(e).", - "death.attack.hurt_by_water": "%s a pris son bain trop longtemps.", - "commands.origin.origin_not_found": "Origine inconnue: %s", - "commands.origin.set.success.single": "L'origine de %s a été définie à %s.", - "commands.origin.set.success.multiple": "Les origines de %s ont été définies à %s.", - "power.origins.end_spawn.name": "Habitant de l'End", - "power.origins.end_spawn.description": "Your journey begins in the End.", - "power.origins.master_of_webs.name": "Master of Webs", - "power.origins.master_of_webs.description": "You navigate cobweb perfectly, and are able to climb in them. When you hit an enemy in melee, they get stuck in cobweb for a while. Non-arthropods stuck in cobweb will be sensed by you. You are able to craft cobweb from string.", - "power.origins.lay_eggs.name": "Oviparous", - "power.origins.lay_eggs.description": "Whenever you wake up in the morning, you will lay an egg.", - "power.origins.phantomize.name": "Phantom Form", - "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", - "power.origins.like_air.name": "Like Air", - "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", - "power.origins.velvet_paws.name": "Velvet Paws", - "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", - "key.origins.secondary_active": "Active Power (Secondary)", - "component.item.origins.origin.layer": "Lets you choose a new %s.", - "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", - "container.shulker_inventory_power": "Shulker Inventory", - "origins.gui.choose": "Choose", - "origins.gui.view_origin.empty": "You can not have any Origins.", - "origins.gui.view_origin.not_installed": "The server does not have Origins installed.", - "origins.gui.version_mismatch": "This server is running a different version of Origins (v%1$s) which is incompatible with the one you have installed (v%2$s).", - "origins.gui.badge.active": "Active ability, use with %s.", - "origins.gui.badge.toggle": "Toggle with %s.", - "origins.gui.unbound_key": "§ounbound§r", - "origin.origins.random.name": "Random", - "origin.origins.random.description": "You'll be assigned one of the following:", - "death.attack.no_water_for_gills.player": "%1$s didn't manage to keep wet because they were fighting %2$s", - "death.attack.hurt_by_water.player": "%1$s was put underwater by %2$s", - "death.attack.genericDamageOverTime": "%1$s died to a damage over time effect", - "death.attack.genericDamageOverTime.player": "%1$s died to a damage over time effect whilst fighting %2$s", - "commands.origin.get.result": "%s has the following %s: %s (%s)", - "commands.origin.gui.all": "Opened the selection GUI for %s players.", - "commands.origin.gui.layer": "Opened the \"%2$s\" selection GUI for %1$s players.", - "origins.avian_sleep_fail": "You need fresh air to sleep", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/he_il.json b/origins/src/main/resources/assets/origins/lang/he_il.json deleted file mode 100644 index 16f66264a..000000000 --- a/origins/src/main/resources/assets/origins/lang/he_il.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "בן אדם", - "origin.origins.human.description": "איש רגיל, חווית המיינקראפט הרגילה שלך מחכה לך.", - "origin.origins.merling.name": "בת ים", - "origin.origins.merling.description": "תושבי האוקיינוס הנייטרלים האלה לא רגילים לחיות מחוץ למים ליתור מדי זמן.", - "origin.origins.arachnid.name": "עכבישאי", - "origin.origins.arachnid.description": "יכולות הטיפוס שלהם והיכולת לטפוס את אויביהם ברשתות הופכות אותם לצייד מעולים .", - "origin.origins.blazeborn.name": "בלייזבורן", - "origin.origins.blazeborn.description": "צאציאו המאוחרים של הבלייז, בלייזבורן חסינים באופן טיבעי לסכנותי של הנ'תר'.", - "origin.origins.avian.name": "עוף", - "origin.origins.avian.description": "העופות איבדו מזמן את יכולות התעופה שלהם. כעת ניתן לראות את יצורים שלווים אלה דואים ממקום למקום.", - "origin.origins.phantom.name": "פאנטום", - "origin.origins.phantom.description": "בתור חצי בן אנוש חצי פאנטום, היצורים האלה יכולים להחליף בין צורתם האנושית לצורת הרפאים שלהם.", - "origin.origins.feline.name": "חתול", - "origin.origins.feline.description": "עם צורת דמויית החתול שלהם החתולים מפחידים קריפרים. עם זריזות החתול שלהם הם תמיד בתוחים על הרגליים.", - "origin.origins.elytrian.name": "אלייטרן", - "origin.origins.elytrian.description": "לעיתים קרובות הם עפים ברוח, האלייטרנים מרגישים לא בנוח כשאין מעליהם מספיק אוויר.", - "origin.origins.enderian.name": "אנדריין", - "origin.origins.enderian.description": "נולדו כילד והילדה של האנדר דרגון, אנדרייאנים מסוגלים להשתגר ממקום למקום אבל יש להם חולשה למים.", - "origin.origins.shulk.name": "שאלק", - "origin.origins.shulk.description": "בדומה לשאלקרין, גופות השאלק מצוייד בעור דמוי מגן.", - "power.origins.water_breathing.name": "זימים", - "power.origins.water_breathing.description": "אתה יכול לנשום מתחת למים, אבל לא על היבשה.", - "power.origins.aqua_affinity.name": "חציבת מים", - "power.origins.aqua_affinity.description": "אתה יכול לחצוב בלוקים מתמחת למים, כמו שהיית עושה על הייבשה.", - "power.origins.water_vision.name": "עיינים רטובות", - "power.origins.water_vision.description": "הראייה שלך מתחת למים מושלמת.", - "power.origins.swim_speed.name": "סנפירים", - "power.origins.swim_speed.description": "מהירות השחייה שלך מוגברת.", - "power.origins.like_water.name": "כמו מים", - "power.origins.like_water.description": "כשאתה מתחת למים, אתה לא שוקע אלא עם אתה רוצה.", - "power.origins.fragile.name": "שביר", - "power.origins.fragile.description": "יש לך פחות 3 לבבות מאשר בני אדם.", - "power.origins.webbing.name": "קורי עכביש", - "power.origins.webbing.description": "כשאתה מכה במישהו עם נשק לתווח קרוב, הוא נתיקע ברשת.", - "power.origins.climbing.name": "טיפוס", - "power.origins.climbing.description": "אתה יכול לטפס על כל קיר, לא רק סולמות.", - "power.origins.carnivore.name": "בשרי", - "power.origins.carnivore.description": "התזונה שלך היא בשר בלבד, בלי ירקות.", - "power.origins.fire_immunity.name": "חסינות לאש", - "power.origins.fire_immunity.description": "אתה חסין לכל סוגי האש.", - "power.origins.nether_spawn.name": "תושבי נת'ר'", - "power.origins.nether_spawn.description": "אתה עושה ספאון בנת'ר'.", - "power.origins.burning_wrath.name": "שווה לבעור", - "power.origins.burning_wrath.description": "אתה עושה יותר דמאג' כשאתה עולה בלהבות'.", - "power.origins.hotblooded.name": "דם רותח", - "power.origins.hotblooded.description": "מפני גופך החם אתה חסין לאפכתים של רעל ושל רעב.", - "power.origins.water_vulnerability.name": "היידרופוביה", - "power.origins.water_vulnerability.description": "אתה מקבל דאמג' כשאתה נמצא במים.", - "power.origins.tailwind.name": "קל רגליים", - "power.origins.tailwind.description": "אתה קצת יותר מהיר ברגל מאחרים.", - "power.origins.slow_falling.name": "קל נוצה", - "power.origins.slow_falling.description": "אתה נופל למטה כמו שנוצה נופלת, אלא עם אתה מתכופף.", - "power.origins.vegetarian.name": "צמחוני", - "power.origins.vegetarian.description": "אתה לא יכול לאכול בשר.", - "power.origins.fresh_air.name": "אוויר צח", - "power.origins.fresh_air.description": "כשאתה ישן, המיתה שלך צריכה אוויר של לפחות 86 בלוקים, כדי שתוכל לנשום אוויר צח .", - "power.origins.phasing.name": "לפלס", - "power.origins.phasing.description": "כשאתה במצב פאנטוםפ, אתה יכול לעבור דרך חומר מוצק, חוץ מאובסידיאן.", - "power.origins.invisibility.name": "בלתי נראות", - "power.origins.invisibility.description": "כשאתה במצב פאנטום, אתה בלתי נראה.", - "power.origins.hunger_over_time.name": "חילוף חומרים", - "power.origins.hunger_over_time.description": "להיות מצב פאנטום גורם לך לרעוב מהר יותר.", - "power.origins.burn_in_daylight.name": "פוטו-אלרגי", - "power.origins.burn_in_daylight.description": "אתה נשרף באור יום אם אתה לא בלתי נראה.", - "power.origins.fall_immunity.name": "אקרובט", - "power.origins.fall_immunity.description": "אתה לא תקבל דמאג' מנפילה, לא משנה מאיזה גובה אתה נופל.", - "power.origins.sprint_jump.name": "רגליים חזקות", - "power.origins.sprint_jump.description": "אתה יכול לקפוץ גבוה יותר באמצעות קפיצה בזמן ריצה.", - "power.origins.nine_lives.name": "תשע נשמות", - "power.origins.nine_lives.description": "יש לך פחות לב 1 מאשר בני אדם רגילים.", - "power.origins.cat_vision.name": "לילי", - "power.origins.cat_vision.description": "אתה יכול לראות בחושך טפונת יותר טוב אם אתה לא במים.", - "power.origins.weak_arms.name": "ידיים חלשות", - "power.origins.weak_arms.description": "כאשר לא משפיע עליך שיקוי כח, אתה יכול לחצוב אבן רק אם יש לפחות 2 אבנים טבעיות הסמוכים עליה.", - "power.origins.scare_creepers.name": "צורת חתול", - "power.origins.scare_creepers.description": "קריפרים מפחדים ממך ולא יתפוצצו אלא עם אתה תוקף אותם קודם.", - "power.origins.launch_into_air.name": "מתנת הכנפיים", - "power.origins.launch_into_air.description": "כל 30 שניות אתה מסוגל לדחוף את עצמך 20 בלוקים לאוויר.", - "power.origins.elytra.name": "מכונף", - "power.origins.elytra.description": "יש לך אלייטרה בלי שתצתרך ללבוש אותם.", - "power.origins.light_armor.name": "צריך תזוזה", - "power.origins.light_armor.description": "אתה לא יכול ללבוש שום שריון כבד (שריון עם פרוטקשין חזק יותר משרשראות).", - "power.origins.claustrophobia.name": "קלאסטרופוביה", - "power.origins.claustrophobia.description": "להיות במקום עם תקרה נמוכה הופך אותך לאיטי יותר.", - "power.origins.more_kinetic_damage.name": "עצמות שבירות", - "power.origins.more_kinetic_damage.description": "אתה מקבל יותר דאמג' אם אתה עף לתוך בלוק'.", - "power.origins.aerial_combatant.name": "קרב אוויר", - "power.origins.aerial_combatant.description": "אתה מוריד יותר דאמג' כשאתה עף עם האלייטרה'.", - "power.origins.throw_ender_pearl.name": "טלפורטציה", - "power.origins.throw_ender_pearl.description": "מתי שאתה רוצה, אתה זורק אנדר-פירל שלא עושה דמאג' שמאפשר לך להשתגר '.", - "power.origins.pumpkin_hate.name": "מפחד מדלעות", - "power.origins.pumpkin_hate.description": "אתה מפחד מדלעות, מסיבה טובה.", - "power.origins.extra_reach.name": "גוף גבוה", - "power.origins.extra_reach.description": "אתה יכול להגיע לבלוקים ולמובים מהרבה יותר רחוק.", - "power.origins.shulker_inventory.name": "אוגר", - "power.origins.shulker_inventory.description": "יש לך גישה לעוד 9 מקומות אכסון, שהדברים שבתוכם ישארו לאחר המוות.", - "power.origins.natural_armor.name": "גוף קשיח", - "power.origins.natural_armor.description": "אפילו בלי שריון, לגוף שלך יש הגנה טבעית.", - "power.origins.more_exhaustion.name": "תיאבון גדול", - "power.origins.more_exhaustion.description": "אתה נרעב הרבה יותר מהר מאחרים, אז אתה צריך לאכול יותר.", - "power.origins.no_shield.name": "מגושם", - "power.origins.no_shield.description": "הדרך שבה היידים שלך בנוייות לא מאפשרות לך להחזיק מגן כמו שצריך.", - "power.origins.strong_arms.name": "זרועות חזקות", - "power.origins.strong_arms.description": "אתה מספיק חזק בדי לשבור אבן רגילה בלי מכוש.", - "power.origins.translucent.name": "שקוף למחצה", - "power.origins.translucent.description": "הגוף שלך שקוף.", - "power.origins.end_spawn.name": "תושב האנד", - "power.origins.end_spawn.description": "המסע שלך מתחיל באנד.", - "power.origins.master_of_webs.name": "מומכה בקורים", - "power.origins.master_of_webs.description": "אתה טווה את קורי העכביש שלך בצורה מושלמת ומסוגל לטפס איתם. כשאתה פוגע באויב עם נשק לתווך קרוב הם נתקעים ברשת לזמן מה. פרוקי רגליים לא יתקעו בקורים שלך. אתה מסוגל לבנות קורי עכביש באמצעות חוטים.", - "category.origins": "מקורות", - "key.origins.primary_active": "כח פעיל (ראשי)", - "key.origins.secondary_active": "כח פעיל (משני)", - "key.origins.view_origin": "צפה במקור", - "text.autoconfig.origins.title": "קונפיג מקורות", - "text.autoconfig.origins.option.xOffset": ",תצורת מד הטעינה X", - "text.autoconfig.origins.option.yOffset": "תצורת מד הטעינה Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "חוזק כיסוי פאנטום", - "item.origins.orb_of_origin": "ליבת המקור", - "enchantment.origins.water_protection": "חסינות למים", - "container.shulker_inventory_power": "שאלקר אינוונטורי", - "origins.gui.select": "לבחור", - "origins.gui.close": "לסגור", - "origins.gui.choose": "לבחור", - "origins.gui.choose_origin.title": "תבחר את האחוזים.", - "origins.gui.view_origin.title": "אלה האחוזים.", - "origins.gui.view_origin.empty": "אתה לא יכול לבחור במקור.", - "origins.gui.view_origin.not_installed": "לשרת אין מקורות מותקן.", - "origins.gui.impact.impact": "השפעה", - "origins.gui.impact.none": "ללא", - "origins.gui.impact.low": "נמוך", - "origins.gui.impact.medium": "בינוני", - "origins.gui.impact.high": "גבוה", - "origins.gui.version_mismatch": "השרת הזה מריץ גירסה אחרת של מקורות (v%1$s) שאינה תואמת לזו שהתקנת (v%2$s).", - "origin.origins.random.name": "אקראי", - "origin.origins.random.description": "יוקצה לך אחד מהבאים:", - "layer.origins.origin.name": "מקור", - "origin.origins.empty.name": "חסר", - "origin.origins.empty.description": "אין לך מקור.", - "death.attack.no_water_for_gills": "%1$s לא הצליח להישאר רטוב.", - "death.attack.no_water_for_gills.player": "%1$s לא הצליחו להשאר רטובים מפני שהם נלחמו ב-%2$s.", - "death.attack.hurt_by_water": "%1$s היה באמבט יותר מדי זמן.", - "death.attack.hurt_by_water.player": "%1$s הוכנס למים על ידי %2$s.", - "death.attack.genericDamageOverTime": "%1$s מת כתוצאה מנזק לאורך זמן.", - "death.attack.genericDamageOverTime.player": "%1$s מת מפגיעה לאורך זמן בזמן שנלכם ב-%2$s.", - "commands.origin.origin_not_found": "מקורות לא ידועים %s", - "commands.origin.set.success.single": "הגדר מקור של %s בשכבה של %s ל%s.", - "commands.origin.set.success.multiple": "הגדר מקום של %s מטרות בשכבה של %s ל-%s.", - "origins.avian_sleep_fail": "אתה צריך אוויר צח כדי לנשום", - "power.origins.lay_eggs.name": "Oviparous", - "power.origins.lay_eggs.description": "Whenever you wake up in the morning, you will lay an egg.", - "power.origins.phantomize.name": "Phantom Form", - "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", - "power.origins.like_air.name": "Like Air", - "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", - "power.origins.velvet_paws.name": "Velvet Paws", - "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", - "component.item.origins.origin.layer": "Lets you choose a new %s.", - "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", - "origins.gui.badge.active": "Active ability, use with %s.", - "origins.gui.badge.toggle": "Toggle with %s.", - "origins.gui.unbound_key": "§ounbound§r", - "commands.origin.get.result": "%s has the following %s: %s (%s)", - "commands.origin.gui.all": "Opened the selection GUI for %s players.", - "commands.origin.gui.layer": "Opened the \"%2$s\" selection GUI for %1$s players.", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/id_id.json b/origins/src/main/resources/assets/origins/lang/id_id.json deleted file mode 100644 index d597a4914..000000000 --- a/origins/src/main/resources/assets/origins/lang/id_id.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Manusia", - "origin.origins.human.description": "Hanya manusia biasa. Petualanganmu di Minecraft biasa aja.", - "origin.origins.merling.name": "Duyung", - "origin.origins.merling.description": "Penghuni laut alami ini tidak akan tahan lama berada di atas air.", - "origin.origins.arachnid.name": "Lelaba", - "origin.origins.arachnid.description": "Kekuatan memanjat dan menangkap dengan jaring membuat mereka menjadi pemburu yang sempurna.", - "origin.origins.blazeborn.name": "Merapi", - "origin.origins.blazeborn.description": "Keturunan lama dari Blaze, Merapi kebal dari rintangan-rintangan di Nether.", - "origin.origins.avian.name": "Unggas", - "origin.origins.avian.description": "Para Unggas sudah kehilangan kekuatan terbang mereka dahulu kala. Sekarang mahluk sentosa ini bisa dilihat berlayang dari tinggi ke rendah.", - "origin.origins.phantom.name": "Hantu", - "origin.origins.phantom.description": "Sebagai keturunan setengah manusia dan setengah phantom, mahluk ini bisa berubah dari hantu menjadi manusia normal.", - "origin.origins.feline.name": "Kucing", - "origin.origins.feline.description": "Dengan bentuk merupai kucing, mereka bisa membuat Creeper takut dari mereka. Dengan kelincahan kucing, mereka selalu mendarat dengan aman.", - "origin.origins.elytrian.name": "Elytria", - "origin.origins.elytrian.description": "Keseringan terlihat terbang dengan angin-angin, Elytria tidak nyaman ketika mereka berada dengan atap yang rendah.", - "origin.origins.enderian.name": "Enderia", - "origin.origins.enderian.description": "Lahir sebagai anak-anaknya Ender Dragon, Enderia bisa berpindah tempat cepat. Tetapi rentan dari air.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Terkait dengan Shulkers, tubuh para Shulk mempunyai kulit seperti tempurung.", - "power.origins.water_breathing.name": "Insang", - "power.origins.water_breathing.description": "Kamu bisa nafas dalam air, tidak di darat.", - "power.origins.aqua_affinity.name": "Daya Air", - "power.origins.aqua_affinity.description": "Kamu menghancurkan blok dalam air secepat yang lain di darat.", - "power.origins.water_vision.name": "Mata Basah", - "power.origins.water_vision.description": "Kamu bisa melihat dalam air dengan sempurna.", - "power.origins.swim_speed.name": "Sirip", - "power.origins.swim_speed.description": "Kamu berenang lebih cepat.", - "power.origins.like_water.name": "Seperti Air", - "power.origins.like_water.description": "Saat dalam air, kamu tidak tenggelam.", - "power.origins.fragile.name": "Rapuh", - "power.origins.fragile.description": "Darahmu 3 nyawa lebih sedikit dari manusia.", - "power.origins.webbing.name": "Jaring", - "power.origins.webbing.description": "Ketika kamu menyerang musuh, mereka akan nyangkut dalam jaring.", - "power.origins.climbing.name": "Memanjat", - "power.origins.climbing.description": "Kamu bisa memanjat dinding apapun, tidak hanya tangga.", - "power.origins.carnivore.name": "Karnivora", - "power.origins.carnivore.description": "Kamu hanya bisa makan daging, gak bisa makan sayur-sayuran.", - "power.origins.fire_immunity.name": "Kebal Api", - "power.origins.fire_immunity.description": "Kamu kebal dari segala kebakaran.", - "power.origins.nether_spawn.name": "Penghuni Nether", - "power.origins.nether_spawn.description": "Kamu muncul secara alami di Nether.", - "power.origins.burning_wrath.name": "Kebakaran Murka", - "power.origins.burning_wrath.description": "Saat terbakar, kamu mendpatkan tambahan pada seranganmu.", - "power.origins.hotblooded.name": "Berdarah Panas", - "power.origins.hotblooded.description": "Karena tubuh panasmu, racun-racun terbakar, membuatmu kebal dari racun dan efek makan.", - "power.origins.water_vulnerability.name": "Hydrophobia", - "power.origins.water_vulnerability.description": "Kamu bisa sakit ketika bersentuhan dengan air.", - "power.origins.tailwind.name": "Cepatnya", - "power.origins.tailwind.description": "Kamu berjalan lebih cepat dari yang lain.", - "power.origins.slow_falling.name": "Ringannya", - "power.origins.slow_falling.description": "Kamu jatuh dengan lembut seperti bulu, kecuali kau menunduk.", - "power.origins.vegetarian.name": "Vegetarian", - "power.origins.vegetarian.description": "Gabisa makan daging.", - "power.origins.fresh_air.name": "Udara Segar", - "power.origins.fresh_air.description": "Saat tidur, kamu harus berada di ketinggian 86 blok, supaya bisa menghirup udara segar.", - "power.origins.phasing.name": "Tembus", - "power.origins.phasing.description": "Saat menjadi hantu, kamu bisa berjalan tembus dinding kecuali obsidian.", - "power.origins.invisibility.name": "Limunan", - "power.origins.invisibility.description": "Saat kamu menjadi hantu, kau tak terlihat.", - "power.origins.hunger_over_time.name": "Metabolisme Tinggi", - "power.origins.hunger_over_time.description": "Menjadi hantu membuatmu lapar.", - "power.origins.burn_in_daylight.name": "Photoallergic", - "power.origins.burn_in_daylight.description": "Kamu terbakar ketika tidak limunan.", - "power.origins.fall_immunity.name": "Akrobat", - "power.origins.fall_immunity.description": "Kamu tidak bisa sakit saat jatuh, setinggi apapun.", - "power.origins.sprint_jump.name": "Kaki Pegas", - "power.origins.sprint_jump.description": "Kamu bisa lompat lebih tinggi dengan lompat sambil berlari.", - "power.origins.nine_lives.name": "Sembilan Nyawa", - "power.origins.nine_lives.description": "Kamu berkurang satu nyawa dari manusia.", - "power.origins.cat_vision.name": "Nokturnal", - "power.origins.cat_vision.description": "Kamu bisa melihat kegelapan saat tidak dalam air.", - "power.origins.weak_arms.name": "Tangan Lumpuh", - "power.origins.weak_arms.description": "Saat tidak dalam efek sebuah ramuan kekuatan, kamu hanya bisa tambang batu alami jika ada 2 batu alami lainnya menempelnya.", - "power.origins.scare_creepers.name": "Merupai Kucing", - "power.origins.scare_creepers.description": "Creepers takut darimu dan hanya meledak jika kau menyerangnya duluan.", - "power.origins.launch_into_air.name": "Hadiah dari Angin", - "power.origins.launch_into_air.description": "Setiap 30 detik, kau bisa meluncur 20 block ke atas langit.", - "power.origins.elytra.name": "Bersayap", - "power.origins.elytra.description": "Kamu mempunyai sayap Elytra tanpa perlu memakainya.", - "power.origins.light_armor.name": "Keperluan Bergerak", - "power.origins.light_armor.description": "Kamu tidak bisa memakai armor berat (armor yang lebih kuat dari chainmail).", - "power.origins.claustrophobia.name": "Claustrophobia", - "power.origins.claustrophobia.description": "Berada dibawah atap rendah bisa membuat mu lemah dan pelan.", - "power.origins.more_kinetic_damage.name": "Osteoporosis", - "power.origins.more_kinetic_damage.description": "Kamu lebih sakit saat jatuh dan terbang menabrak permukaan.", - "power.origins.aerial_combatant.name": "Pangeran Udara", - "power.origins.aerial_combatant.description": "Kamu menyerang lebih sakit saat terbang.", - "power.origins.throw_ender_pearl.name": "Teleportasi", - "power.origins.throw_ender_pearl.description": "Kapanpun saja, kau bisa melempar sebuah ender pearl yang tidak membuatmu sakit, dan membuatmu berpindah dengan cepat.", - "power.origins.pumpkin_hate.name": "Ketakutan Labu", - "power.origins.pumpkin_hate.description": "Kamu takut sama labu. Waspadalah.", - "power.origins.extra_reach.name": "Tubuh Ramping", - "power.origins.extra_reach.description": "Tanganmu panjang, jadi bisa menyampai lebih jauh.", - "power.origins.shulker_inventory.name": "Pengangkut", - "power.origins.shulker_inventory.description": "Kamu mempunyai 9 slot penyimpanan tambahan, yang tetap ada walaupun mati.", - "power.origins.natural_armor.name": "Kulit Kekar", - "power.origins.natural_armor.description": "Walaupun tanpa armor, kulitmu memberi pelindung alami.", - "power.origins.more_exhaustion.name": "Lapar Cepat", - "power.origins.more_exhaustion.description": "Kamu lebih cepat capek dari yang lain, membuatmu makan lebih banyak.", - "power.origins.no_shield.name": "Tak Berpakai", - "power.origins.no_shield.description": "Tangan mu tidak bisa memegang peresai dengan benar.", - "power.origins.strong_arms.name": "Tangan Kekar", - "power.origins.strong_arms.description": "Kamu kuat untuk menghancurkan batu alami tanpa beliung.", - "power.origins.translucent.name": "Translusi", - "power.origins.translucent.description": "Tubuhmu translusif.", - "power.origins.end_spawn.name": "Penghuni The End", - "power.origins.end_spawn.description": "Kamu berawal dari The End.", - "power.origins.master_of_webs.name": "Master Jaring", - "power.origins.master_of_webs.description": "Kamu berjalan dalam jaring biasa saja, dan bisa memanjatnya. Ketika kamu menyerang musuh, mereka akan nyangkut dalam jaring. Yang bukan spesies laba-laba bisa dirasakan kamu. Kamu bisa membuat jaring dari benang.", - "power.origins.lay_eggs.name": "Bertelur", - "power.origins.lay_eggs.description": "Saat bangun dari tidur, kamu bertelur.", - "category.origins": "Origins", - "key.origins.primary_active": "Kekuatan Aktif (Utama)", - "key.origins.secondary_active": "Kekuatan Aktif (Kedua)", - "key.origins.view_origin": "Lihat Origin", - "text.autoconfig.origins.title": "Konfigurasi Origins", - "text.autoconfig.origins.option.xOffset": "Bar Cooldown Offset X", - "text.autoconfig.origins.option.yOffset": "Bar Cooldown Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Kekuatan Overlay Menjadi Hantu ", - "item.origins.orb_of_origin": "Bola Origin", - "enchantment.origins.water_protection": "Pelindung Air", - "container.shulker_inventory_power": "Simpanan Shulker", - "origins.gui.select": "Pilih", - "origins.gui.close": "Tutup", - "origins.gui.choose": "Memilih", - "origins.gui.choose_origin.title": "Pilih %s mu.", - "origins.gui.view_origin.title": "Ini adalah %s mu.", - "origins.gui.view_origin.empty": "Kamu tidak bisa mempunyai Origin apapun.", - "origins.gui.view_origin.not_installed": "Server ini tidak mempunyai Origin terinstall.", - "origins.gui.impact.impact": "Pengaruh", - "origins.gui.impact.none": "Tak ada", - "origins.gui.impact.low": "Rendah", - "origins.gui.impact.medium": "Sedang", - "origins.gui.impact.high": "Tinggi", - "origins.gui.version_mismatch": "Server ini berjalan dengan versi Origin berbeda (v%1$s) yaitu bertentangan dengan yang kau telah install (v%2$s).", - "origin.origins.random.name": "Random", - "origin.origins.random.description": "Kamu telah ditetapkan sebagai salah satu ini:", - "layer.origins.origin.name": "Origin", - "origin.origins.empty.name": "Tidak berada", - "origin.origins.empty.description": "Kamu tidak mempunyai origin apapun.", - "death.attack.no_water_for_gills": "%1$s tidak bisa bertahan basah.", - "death.attack.no_water_for_gills.player": "%1$s tidak bisa bertahan basah karena dia berantem dengan %2$s.", - "death.attack.hurt_by_water": "%1$s mandi terlalu lama.", - "death.attack.hurt_by_water.player": "%1$s ditaruh dalam air oleh %2$s.", - "death.attack.genericDamageOverTime": "%1$s mati pada efek waktu ke waktu.", - "death.attack.genericDamageOverTime.player": "%1$s mati pada efek waktu ke waktu sambil berantem dengan %2$s.", - "commands.origin.origin_not_found": "origin tak ketahui: %s", - "commands.origin.set.success.single": "Set origin %s dalam layer %s ke %s.", - "commands.origin.set.success.multiple": "Set origin %s menargetkan dalam layer %s ke %s.", - "origins.avian_sleep_fail": "Kamu butuh udara segar untuk tidur", - "power.origins.phantomize.name": "Phantom Form", - "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", - "power.origins.like_air.name": "Like Air", - "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", - "power.origins.velvet_paws.name": "Velvet Paws", - "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", - "component.item.origins.origin.layer": "Lets you choose a new %s.", - "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", - "origins.gui.badge.active": "Active ability, use with %s.", - "origins.gui.badge.toggle": "Toggle with %s.", - "origins.gui.unbound_key": "§ounbound§r", - "commands.origin.get.result": "%s has the following %s: %s (%s)", - "commands.origin.gui.all": "Opened the selection GUI for %s players.", - "commands.origin.gui.layer": "Opened the \"%2$s\" selection GUI for %1$s players.", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/it_it.json b/origins/src/main/resources/assets/origins/lang/it_it.json deleted file mode 100644 index 181f90424..000000000 --- a/origins/src/main/resources/assets/origins/lang/it_it.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Umano", - "origin.origins.human.description": "Un umano normale. La tua normale esperienza di minecraft ti aspetta.", - "origin.origins.merling.name": "Merling", - "origin.origins.merling.description": "Questi naturali abitanti dell'oceano non sono fatti per stare fuori dall'acqua per troppo tempo.", - "origin.origins.arachnid.name": "Aracnide", - "origin.origins.arachnid.description": "La loro abilità di arrampicarsi e di intrappolare le loro prede nelle ragnatele fa degli aracnidi dei perfetti cacciatori.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "discendendi lontani dei blaze, i Blazeborn sono naturalmente immuni ai pericoli del Nether.", - "origin.origins.avian.name": "Avian", - "origin.origins.avian.description": "La razza degli Avian ha perso la loro abilità di volare molto tempo fa. Adesso queste creature pacifiche possono essere viste planare da un posto all'altro.", - "origin.origins.phantom.name": "Fantasma", - "origin.origins.phantom.description": "essendo per metà umani e per metà fantasmi, queste creature possono passare dalla forma di Fantasma a quella umana e viceversa.", - "origin.origins.feline.name": "Felino", - "origin.origins.feline.description": "Con la loro forma simile ad un gatto, i Felini spaventano i creeper. Con la destrezza dei gatti, atterano sempre tranquillamente sui loro piedi.", - "origin.origins.elytrian.name": "Elytrian", - "origin.origins.elytrian.description": "Volano spesso nel vento e per questo gli Elytrian sono scomodi quando non hanno abbastanza spazio sopra la loro testa.", - "origin.origins.enderian.name": "Enderian", - "origin.origins.enderian.description": "Nati come figli e figlie dell'Ender Dragon, Gli Enderian sono capaci di teletrasporstarsi ma sono vulnerabili all'acqua.", - "power.origins.water_breathing.name": "Branchie", - "power.origins.water_breathing.description": "Puoi respirare sott'acqua, ma non sualla terra.", - "power.origins.aqua_affinity.name": "Affinità Acquatica", - "power.origins.aqua_affinity.description": "Puoi rompere i blocchi sott'acqua come se fossi sulla terra.", - "power.origins.water_vision.name": "Occhi bagnati ", - "power.origins.water_vision.description": "La tua vista sott'acqua è perfetta.", - "power.origins.swim_speed.name": "Pinne", - "power.origins.swim_speed.description": "la tua velocità sott'acqua è aumentata.", - "power.origins.like_water.name": "Come l'Acqua", - "power.origins.like_water.description": "Quando sei sott'acqua, non affondi finchè non lo decidi tu.", - "power.origins.fragile.name": "Fragile", - "power.origins.fragile.description": "Hai solo 7 cuori di vita.", - "power.origins.webbing.name": "Tessitura", - "power.origins.webbing.description": "Quando colpisci un nemico corpo a corpo, rimane bloccato in una ragnatela.", - "power.origins.climbing.name": "Arrampicata", - "power.origins.climbing.description": "Puoi arrampicatri su qualsiasi tipo di muro, non solo sulle scale a pioli.", - "power.origins.carnivore.name": "Carnivoro", - "power.origins.carnivore.description": "Puoi mangiare solo carne.", - "power.origins.fire_immunity.name": "Immunità al Fuoco", - "power.origins.fire_immunity.description": "Sei immune ad ogni tipo di danno da fuoco.", - "power.origins.nether_spawn.name": "Abitante del Nether", - "power.origins.nether_spawn.description": "Il tuo spawn naturale è nel Nether.", - "power.origins.burning_wrath.name": "Ira Infuocata", - "power.origins.burning_wrath.description": "Quando vai a fuoco, i tuoi colpi fanno piu danno.", - "power.origins.hotblooded.name": "Sangue Bollente", - "power.origins.hotblooded.description": "A causa del tuo corpo bollente, i veleni bruciano, immunizzandoti dagli status di fame e veleno.", - "power.origins.water_vulnerability.name": "Idrofobia", - "power.origins.water_vulnerability.description": "Si subiscono danni nel tempo se si sta troppo in acqua.", - "power.origins.tailwind.name": "Vento di Coda", - "power.origins.tailwind.description": "Sei leggermente più veloce degli altri mentre cammini.", - "power.origins.slow_falling.name": "Peso Piuma", - "power.origins.slow_falling.description": "Cadi lentamente sul suolo per merito delle piume, finchè non ti abbassi.", - "power.origins.vegetarian.name": "Vegetariano", - "power.origins.vegetarian.description": "Non digerisci la carne.", - "power.origins.fresh_air.name": "Aria Fresca", - "power.origins.fresh_air.description": "Quando dormi, il tuo letto deve essere ad un'altitudine di almeno 86 blocchi, così puoi respirare aria fresca.", - "power.origins.phasing.name": "Phasing", - "power.origins.phasing.description": "Quando sei nella forma di Fantasma, puoi attraversare i blocchi solidi, tranne l'Ossidiana.", - "power.origins.invisibility.name": "Invisibilità", - "power.origins.invisibility.description": "Quando sei nella forma di Fantasma, sei invisibile.", - "power.origins.hunger_over_time.name": "Metabolismo Veloce", - "power.origins.hunger_over_time.description": "Quando sei nella forma di Fantasma ti viene fame più velocemente.", - "power.origins.burn_in_daylight.name": "Fotoallergico", - "power.origins.burn_in_daylight.description": "Bruci durante il giorno se non sei invisibile.", - "power.origins.fall_immunity.name": "Acrobatico", - "power.origins.fall_immunity.description": "Non prenderai mai danno da caduta, non importa da che altezza.", - "power.origins.sprint_jump.name": "Caviglie Forti", - "power.origins.sprint_jump.description": "Puoi saltare in alto se corri.", - "power.origins.nine_lives.name": "Nove Vite", - "power.origins.nine_lives.description": "Hai solo 9 cuori.", - "power.origins.cat_vision.name": "Notturno", - "power.origins.cat_vision.description": "Puoi vedere bene nel buio se non sei sott'acqua.", - "power.origins.weak_arms.name": "Braccia Deboli", - "power.origins.weak_arms.description": "Se non hai l'effetto di Forza, puoi minare la roccia naturale solo se è adiacente ad altre due rocce naturali.", - "power.origins.scare_creepers.name": "Aspetto da Gatto", - "power.origins.scare_creepers.description": "I Creeper sono spaventati da te ed esplodono solo se tu li attachi per primo.", - "power.origins.launch_into_air.name": "Dono dai Venti", - "power.origins.launch_into_air.description": "Ogni 30 secondi, sei capace di lanciarti a 20 blocchi verso l'alto.", - "power.origins.elytra.name": "Alato", - "power.origins.elytra.description": "Hai già le Elytra anche senza equipagiarle.", - "power.origins.light_armor.name": "Necessità di Mobilità", - "power.origins.light_armor.description": "Puoi solo indossare armature leggere (armature con protezione equivalenti o inferiori all'armatura di Chainmail).", - "power.origins.claustrophobia.name": "Claustrofobia", - "power.origins.claustrophobia.description": "Stare troppo tempo sotto un soffitto basso ti da lentezza.", - "power.origins.more_kinetic_damage.name": "Ossa Fragili", - "power.origins.more_kinetic_damage.description": "Ti fai più male quando cadi o sbatti contro un blocco mentre voli.", - "power.origins.aerial_combatant.name": "Combattente Aereo", - "power.origins.aerial_combatant.description": "Fai molto più danno mentre voli con l'Elytra.", - "power.origins.throw_ender_pearl.name": "Teletrasporto", - "power.origins.throw_ender_pearl.description": "Qando vuoi, puoi tirare le ender pearl senza farti del danno, Facendoti così teletrasportare.", - "power.origins.pumpkin_hate.name": "Paura delle Zucche", - "power.origins.pumpkin_hate.description": "Sei spaventato dalle zucche. Per una buona ragione.", - "power.origins.extra_reach.name": "Corpo Snello", - "power.origins.extra_reach.description": "Puoi raggiungere blocchi piuù lontani.", - "category.origins": "Origini", - "key.origins.primary_active": "Attiva Potere", - "key.origins.view_origin": "Mostra Origine", - "item.origins.orb_of_origin": "Globo delle Origini", - "enchantment.origins.water_protection": "Protezione dall'Acqua", - "origins.gui.select": "Seleziona", - "origins.gui.close": "Chiudi", - "origins.gui.choose_origin.title": "Scegli la tua Origine", - "origins.gui.view_origin.title": "Questa è la tua Origine", - "origins.gui.impact.impact": "Impatto", - "origins.gui.impact.none": "Nessuno", - "origins.gui.impact.low": "Basso", - "origins.gui.impact.medium": "Medio", - "origins.gui.impact.high": "Alto", - "death.attack.no_water_for_gills": "%s Ha dimenticato di restare bagnato.", - "death.attack.hurt_by_water": "%s Ha fatto un bagno per troppo tempo.", - "commands.origin.origin_not_found": "Origine Sconosciuta: %s", - "commands.origin.set.success.single": "Impostato l'origine di %s a %s.", - "commands.origin.set.success.multiple": "Impostato l'origine degli %s obbiettivi a %s.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Related to Shulkers, the bodies of the Shulk are outfitted with a protective shell-like skin.", - "power.origins.shulker_inventory.name": "Hoarder", - "power.origins.shulker_inventory.description": "You have access to an additional 9 slots of inventory, which keep the items on death.", - "power.origins.natural_armor.name": "Sturdy Skin", - "power.origins.natural_armor.description": "Even without wearing armor, your skin provides natural protection.", - "power.origins.more_exhaustion.name": "Large Appetite", - "power.origins.more_exhaustion.description": "You exhaust much quicker than others, thus requiring you to eat more.", - "power.origins.no_shield.name": "Unwieldy", - "power.origins.no_shield.description": "The way your hands are formed provide no way of holding a shield upright.", - "power.origins.strong_arms.name": "Strong Arms", - "power.origins.strong_arms.description": "You are strong enough to break natural stones without using a pickaxe.", - "power.origins.translucent.name": "Translucent", - "power.origins.translucent.description": "Your skin is translucent.", - "power.origins.end_spawn.name": "End Inhabitant", - "power.origins.end_spawn.description": "Your journey begins in the End.", - "power.origins.master_of_webs.name": "Master of Webs", - "power.origins.master_of_webs.description": "You navigate cobweb perfectly, and are able to climb in them. When you hit an enemy in melee, they get stuck in cobweb for a while. Non-arthropods stuck in cobweb will be sensed by you. You are able to craft cobweb from string.", - "power.origins.lay_eggs.name": "Oviparous", - "power.origins.lay_eggs.description": "Whenever you wake up in the morning, you will lay an egg.", - "power.origins.phantomize.name": "Phantom Form", - "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", - "power.origins.like_air.name": "Like Air", - "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", - "power.origins.velvet_paws.name": "Velvet Paws", - "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", - "key.origins.secondary_active": "Active Power (Secondary)", - "text.autoconfig.origins.title": "Origins Configuration", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "component.item.origins.origin.layer": "Lets you choose a new %s.", - "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", - "container.shulker_inventory_power": "Shulker Inventory", - "origins.gui.choose": "Choose", - "origins.gui.view_origin.empty": "You can not have any Origins.", - "origins.gui.view_origin.not_installed": "The server does not have Origins installed.", - "origins.gui.version_mismatch": "This server is running a different version of Origins (v%1$s) which is incompatible with the one you have installed (v%2$s).", - "origins.gui.badge.active": "Active ability, use with %s.", - "origins.gui.badge.toggle": "Toggle with %s.", - "origins.gui.unbound_key": "§ounbound§r", - "origin.origins.random.name": "Random", - "origin.origins.random.description": "You'll be assigned one of the following:", - "layer.origins.origin.name": "Origin", - "origin.origins.empty.name": "Missing", - "origin.origins.empty.description": "You do not have an Origin.", - "death.attack.no_water_for_gills.player": "%1$s didn't manage to keep wet because they were fighting %2$s", - "death.attack.hurt_by_water.player": "%1$s was put underwater by %2$s", - "death.attack.genericDamageOverTime": "%1$s died to a damage over time effect", - "death.attack.genericDamageOverTime.player": "%1$s died to a damage over time effect whilst fighting %2$s", - "commands.origin.get.result": "%s has the following %s: %s (%s)", - "commands.origin.gui.all": "Opened the selection GUI for %s players.", - "commands.origin.gui.layer": "Opened the \"%2$s\" selection GUI for %1$s players.", - "origins.avian_sleep_fail": "You need fresh air to sleep", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/ja_jp.json b/origins/src/main/resources/assets/origins/lang/ja_jp.json deleted file mode 100644 index 960623ac4..000000000 --- a/origins/src/main/resources/assets/origins/lang/ja_jp.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "人間", - "origin.origins.human.description": "特別な力を持たない普通の人間です。普通の人間として普通のMinecraftが遊べます。", - "origin.origins.merling.name": "マーメイド", - "origin.origins.merling.description": "昔から水中で暮らしてきたその種族は、エラ呼吸しか出来ないけれど、水中でなら誰にも負けません。", - "origin.origins.arachnid.name": "クモ人間", - "origin.origins.arachnid.description": "コッソリ壁を登って獲物をクモの巣に捕らえれば、後は…いただきます。", - "origin.origins.blazeborn.name": "ブレイズマン", - "origin.origins.blazeborn.description": "ブレイズの血族であるブレイズマンは、危険なネザーでは楽々暮らせます。でも水を飲むのはやめた方が良いかも…?", - "origin.origins.avian.name": "鳥人間", - "origin.origins.avian.description": "空は飛べないけれど、滑空なら出来ます。チキンだなんて呼ばないで!", - "origin.origins.phantom.name": "ファントム", - "origin.origins.phantom.description": "半人半霊を交互に切り替えて夜を賢く生きる…日焼け止めはちゃんと塗った?", - "origin.origins.feline.name": "ネコ娘", - "origin.origins.feline.description": "猫耳生やしてクリーパーを遠ざける可愛い仔。崖から飛び降りてもへっちゃら!", - "origin.origins.elytrian.name": "エリトリアン", - "origin.origins.elytrian.description": "風に乗って空をスイスイ。でも狭い所はお断り!太陽に向かって全速前進だ!", - "origin.origins.enderian.name": "エンダー", - "origin.origins.enderian.description": "エンダードラゴンの子供として生まれた彼らは、テレポーテーションの使い手。おっと、海にワープしない様に気を付けて!", - "origin.origins.shulk.name": "シュルク", - "origin.origins.shulk.description": "シュルカーの様な外殻で、相手の攻撃も痛くも痒くもありません。やっぱり痒みは少しあるかも…", - "power.origins.water_breathing.name": "エラ", - "power.origins.water_breathing.description": "水中での呼吸が可能になります。でも地上での呼吸は出来ません。", - "power.origins.aqua_affinity.name": "水中採掘", - "power.origins.aqua_affinity.description": "水中でも地上の速さでブロックを壊せます。", - "power.origins.water_vision.name": "海の目", - "power.origins.water_vision.description": "水中での視界がクリアになります。", - "power.origins.swim_speed.name": "ヒレ", - "power.origins.swim_speed.description": "水中での水泳速度が通常より速くなります。", - "power.origins.like_water.name": "泳ぎの達人", - "power.origins.like_water.description": "水中にいる間、勝手に底に沈みません。", - "power.origins.fragile.name": "脆弱", - "power.origins.fragile.description": "普通の人間に比べて体力がハート3つ分少ないです。", - "power.origins.webbing.name": "クモの糸", - "power.origins.webbing.description": "近距離攻撃をした場合、相手を少しの間クモの巣に閉じ込めます。", - "power.origins.climbing.name": "壁登り", - "power.origins.climbing.description": "ハシゴ以外のブロックも登ることが出来るようになります。", - "power.origins.carnivore.name": "肉食", - "power.origins.carnivore.description": "野菜は食べれず、肉しか食べることが出来なくなります。", - "power.origins.fire_immunity.name": "火炎耐性", - "power.origins.fire_immunity.description": "全ての火属性攻撃を無効化します。", - "power.origins.nether_spawn.name": "ネザー生まれ", - "power.origins.nether_spawn.description": "初期スポーン地点がネザーになります。", - "power.origins.burning_wrath.name": "火の力", - "power.origins.burning_wrath.description": "燃えている間、自分の与えるダメージが少し増えます。", - "power.origins.hotblooded.name": "アツアツな体", - "power.origins.hotblooded.description": "体内で毒が殺菌される為、毒と空腹になりません。", - "power.origins.water_vulnerability.name": "水恐怖症", - "power.origins.water_vulnerability.description": "水に触れている間ダメージを受けます。", - "power.origins.tailwind.name": "追い風", - "power.origins.tailwind.description": "地上での移動速度が通常より速くなります。", - "power.origins.slow_falling.name": "滞空", - "power.origins.slow_falling.description": "空中での落下速度が通常より遅くなります。(スニークをすると通常速度での落下が出来ます)", - "power.origins.vegetarian.name": "草食", - "power.origins.vegetarian.description": "肉は食べれず、野菜しか食べることが出来なくなります。", - "power.origins.fresh_air.name": "新鮮な空気", - "power.origins.fresh_air.description": "ベッドで眠る際、高度86ブロック以上の高さで眠る必要があります。", - "power.origins.phasing.name": "壁抜け", - "power.origins.phasing.description": "ファントム状態の間、黒曜石以外のブロックを通り抜けることが出来ます。", - "power.origins.invisibility.name": "透明化", - "power.origins.invisibility.description": "ファントム状態の間、姿が透明になります。", - "power.origins.hunger_over_time.name": "エネルギー消費", - "power.origins.hunger_over_time.description": "ファントム状態の間、満腹度の減りが早くなります。", - "power.origins.burn_in_daylight.name": "アンデッド", - "power.origins.burn_in_daylight.description": "透明でない間、日光に当たると燃えます。", - "power.origins.fall_immunity.name": "アクロバティック", - "power.origins.fall_immunity.description": "どんな高さから落ちても落下ダメージを食らいません。", - "power.origins.sprint_jump.name": "跳躍", - "power.origins.sprint_jump.description": "ダッシュしている間、ジャンプ力が通常より高くなります。", - "power.origins.nine_lives.name": "9つの命", - "power.origins.nine_lives.description": "普通の人間に比べて体力がハート1つ分少ないです。", - "power.origins.cat_vision.name": "夜行性", - "power.origins.cat_vision.description": "水中に居ない限り、暗闇が見やすくなります。", - "power.origins.weak_arms.name": "弱い腕", - "power.origins.weak_arms.description": "攻撃力上昇のポーション効果が付いていない場合、2つ以上の石と隣接している石が壊せなくなります。", - "power.origins.scare_creepers.name": "猫姿", - "power.origins.scare_creepers.description": "クリーパーは貴方に怯えるようになり、攻撃しない限り爆発しなくなります。", - "power.origins.launch_into_air.name": "翼のギフト", - "power.origins.launch_into_air.description": "30秒毎に、20ブロック高く飛ぶことが出来ます。", - "power.origins.elytra.name": "翼", - "power.origins.elytra.description": "装備しなくてもエリトラが使えます。", - "power.origins.light_armor.name": "軽量化", - "power.origins.light_armor.description": "重い防具は着る事が出来ません (チェーン防具と同等かそれ以下の防御力の防具のみ着ることが出来ます).", - "power.origins.claustrophobia.name": "閉所恐怖症", - "power.origins.claustrophobia.description": "天井の低い場所に長く滞在すると攻撃力が低くなり足が遅くなります。", - "power.origins.more_kinetic_damage.name": "脆い骨", - "power.origins.more_kinetic_damage.description": "落下ダメージや壁への衝突ダメージが増えます。", - "power.origins.aerial_combatant.name": "空中特化", - "power.origins.aerial_combatant.description": "エリトラで滑空している間、自分の与えるダメージが増加します。", - "power.origins.throw_ender_pearl.name": "テレポーテーション", - "power.origins.throw_ender_pearl.description": "いつでもダメージのないエンダーパールを投げることが出来ます。", - "power.origins.pumpkin_hate.name": "カボチャへの恐怖", - "power.origins.pumpkin_hate.description": "カボチャを恐れるようになります。いい意味で。", - "power.origins.extra_reach.name": "長い腕", - "power.origins.extra_reach.description": "通常より長いリーチで、遠くのエンティティやブロックにも手が届くようになります。", - "power.origins.shulker_inventory.name": "シュルカーインベントリ", - "power.origins.shulker_inventory.description": "死亡時にもロストしない9つの追加インベントリを使えます。", - "power.origins.natural_armor.name": "硬い皮膚", - "power.origins.natural_armor.description": "防具を着ていなくても、ある程度の防御力を持っています。", - "power.origins.more_exhaustion.name": "膨大な食糧", - "power.origins.more_exhaustion.description": "通常のプレイヤーより早く空腹になります。", - "power.origins.no_shield.name": "不器用", - "power.origins.no_shield.description": "盾が使用できなくなります。", - "power.origins.strong_arms.name": "強靭な腕", - "power.origins.strong_arms.description": "ピッケルなしで石を破壊することが出来ます。", - "power.origins.translucent.name": "半透明", - "power.origins.translucent.description": "体が半透明になります。", - "power.origins.end_spawn.name": "エンドの住民", - "power.origins.end_spawn.description": "開始地点がエンドになります。", - "power.origins.master_of_webs.name": "クモの巣の達人", - "power.origins.master_of_webs.description": "クモの巣の中を自由に動くことが出来、登ることも出来ます。近接攻撃をした場合、少しの間敵をクモの巣に閉じ込めます。クモの巣に引っ掛かったモブを認識することが出来ます。糸からクモの巣をクラフトできるようになります。", - "power.origins.lay_eggs.name": "産卵", - "power.origins.lay_eggs.description": "朝起きた時、新鮮な卵を産みます。", - "category.origins": "オリジンズ", - "key.origins.primary_active": "能力起動 (一つ目)", - "key.origins.secondary_active": "能力起動 (二つ目)", - "key.origins.view_origin": "オリジンの説明を見る", - "text.autoconfig.origins.title": "オリジンズの設定", - "text.autoconfig.origins.option.xOffset": "クールダウンバーの位置 X", - "text.autoconfig.origins.option.yOffset": "クールダウンバーの位置 Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "ファントム化中の視覚効果の強度", - "item.origins.orb_of_origin": "オリジンの宝玉", - "enchantment.origins.water_protection": "水耐性", - "container.shulker_inventory_power": "シュルカーインベントリ", - "origins.gui.select": "選択", - "origins.gui.close": "閉じる", - "origins.gui.choose": "決定", - "origins.gui.choose_origin.title": "あなたの %sを決めてください。", - "origins.gui.view_origin.title": "これがあなたの %sです。", - "origins.gui.view_origin.empty": "オリジンを持つことが出来ません。", - "origins.gui.view_origin.not_installed": "サーバーにOriginsがインストールされていません。", - "origins.gui.impact.impact": "変化率", - "origins.gui.impact.none": "なし", - "origins.gui.impact.low": "弱", - "origins.gui.impact.medium": "中", - "origins.gui.impact.high": "強", - "origins.gui.version_mismatch": "このサーバーは、インストールしたもの (v%1$s) と互換性のない異なるバージョンのOrigins (v%2$s)を使用しています。", - "origin.origins.random.name": "ランダム", - "origin.origins.random.description": "次のいずれかが割り当てられます:", - "layer.origins.origin.name": "オリジン", - "origin.origins.empty.name": "存在しません", - "origin.origins.empty.description": "あなたはオリジンを所持していません。", - "death.attack.no_water_for_gills": "%1$s は地上でも呼吸が出来ると思った", - "death.attack.no_water_for_gills.player": "%1$s は %2$s と戦うのに夢中で水に入るのを忘れてしまった", - "death.attack.hurt_by_water": "%1$s お風呂に入りすぎた", - "death.attack.hurt_by_water.player": "%1$s は %2$s に沈められた", - "death.attack.genericDamageOverTime": "%1$s 自分の能力のダメージで死んだ", - "death.attack.genericDamageOverTime.player": "%1$s は %2$sと戦いながら自分の能力のダメージで死んだ", - "commands.origin.origin_not_found": "不明なオリジン: %s", - "commands.origin.set.success.single": "%s のオリジンを %s にセットしました。 %s.", - "commands.origin.set.success.multiple": "%s のターゲットのオリジンを %s にセットしました。 %s.", - "commands.origin.get.result": "%s は以下の %s を所持しています: %s (%s)", - "origins.avian_sleep_fail": "寝るには新鮮な空気が必要です", - "power.origins.phantomize.name": "Phantom Form", - "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", - "power.origins.like_air.name": "Like Air", - "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", - "power.origins.velvet_paws.name": "Velvet Paws", - "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", - "component.item.origins.origin.layer": "Lets you choose a new %s.", - "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", - "origins.gui.badge.active": "Active ability, use with %s.", - "origins.gui.badge.toggle": "Toggle with %s.", - "origins.gui.unbound_key": "§ounbound§r", - "commands.origin.gui.all": "Opened the selection GUI for %s players.", - "commands.origin.gui.layer": "Opened the \"%2$s\" selection GUI for %1$s players.", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/ko_kr.json b/origins/src/main/resources/assets/origins/lang/ko_kr.json deleted file mode 100644 index 490017f19..000000000 --- a/origins/src/main/resources/assets/origins/lang/ko_kr.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "평범한 인간", - "origin.origins.human.description": "평범한 인간. 평범한 Minecraft에서의 경험이 기다리고 있습니다.", - "origin.origins.merling.name": "물고기 인간", - "origin.origins.merling.description": "이 바다의 원주민들은 너무 오랫동안 물 밖에 있는 데 익숙하지 않습니다.", - "origin.origins.arachnid.name": "거미 인간", - "origin.origins.arachnid.description": "그들의 등반 능력과 적을 거미줄에 가두는 능력은 거미 인간들을 완벽한 사냥꾼으로 만듭니다.", - "origin.origins.blazeborn.name": "블레이즈 인간", - "origin.origins.blazeborn.description": "블레이즈의 후손인 블레이즈 인간은 자연적으로 네더의 위험에 면역입니다.", - "origin.origins.avian.name": "조류 인간", - "origin.origins.avian.description": "조류 인간들은 오래 전에 비행 능력을 잃었습니다. 이제 이 평화로운 생물이 한 곳에서 다른 곳으로 활공하는 모습을 볼 수 있습니다.", - "origin.origins.phantom.name": "팬텀 인간", - "origin.origins.phantom.description": "반은 인간이고 반은 팬텀인 이 종족은 팬텀과 일반 인간 형태 사이를 전환할 수 있습니다.", - "origin.origins.feline.name": "고양이 인간", - "origin.origins.feline.description": "고양이 같은 외모로 그들은 크리퍼를 겁먹게 합니다. 고양이의 발재주로 항상 발로 안전하게 착지합니다.", - "origin.origins.elytrian.name": "나는 인간", - "origin.origins.elytrian.description": "종종 바람을 타고 날아다니는 나는 인간은 머리 위에 충분한 공간이 없을 때 매우 불편합니다.", - "origin.origins.enderian.name": "엔더 인간", - "origin.origins.enderian.description": "엔더 드래곤의 자식으로 태어난 엔더 인간은 순간이동이 가능하지만 물에 취약합니다.", - "origin.origins.shulk.name": "셜커 인간", - "origin.origins.shulk.description": "셜커 인간은 셜커의 몸에는 보호용 껍질과 같은 피부가 있습니다.", - "power.origins.water_breathing.name": "아가미", - "power.origins.water_breathing.description": "물속에는 자유롭게 숨을 쉴 수 있습니다! 하지만 지상에서는 그렇지 않죠.", - "power.origins.aqua_affinity.name": "인어 인간", - "power.origins.aqua_affinity.description": "평범한 사람들이 육지에서 하는 것처럼 수 중에서 블록을 부술 수 있습니다.", - "power.origins.water_vision.name": "젖은 눈", - "power.origins.water_vision.description": "당신의 물속에서의 시야는 완벽합니다.", - "power.origins.swim_speed.name": "지느러미", - "power.origins.swim_speed.description": "물속에서 속도가 증가합니다.", - "power.origins.like_water.name": "물 처럼", - "power.origins.like_water.description": "물속에서는 원하지 않는 한 땅에 가라앉지 않습니다.", - "power.origins.fragile.name": "파손 주의!", - "power.origins.fragile.description": "당신은 인간보다 체력이 3개 적습니다.", - "power.origins.webbing.name": "거미줄", - "power.origins.webbing.description": "당신이 주먹으로 적을 때렸을때, 적은 거미줄에 갇힙니다.", - "power.origins.climbing.name": "등반", - "power.origins.climbing.description": "사다리뿐만 아니라 모든 종류의 벽을 오를 수 있습니다.", - "power.origins.carnivore.name": "육식 동물", - "power.origins.carnivore.description": "식단은 고기로 제한되며 야채는 먹을 수 없습니다.", - "power.origins.fire_immunity.name": "내화성", - "power.origins.fire_immunity.description": "모든 종류의 화염 피해에 면역입니다.", - "power.origins.nether_spawn.name": "네더 원주민", - "power.origins.nether_spawn.description": "당신은 처음부터 네더에서 스폰됩니다.", - "power.origins.burning_wrath.name": "불타는 분노", - "power.origins.burning_wrath.description": "불이 붙으면 공격할때 추가 피해를 입힙니다.", - "power.origins.hotblooded.name": "끓는 피", - "power.origins.hotblooded.description": "뜨거운 몸으로 인해 독이 타서 독과 배고픔 상태 효과에 면역이 됩니다.", - "power.origins.water_vulnerability.name": "공수병", - "power.origins.water_vulnerability.description": "물과 접촉하는 동안 시간이 지남에 따라 피해를 입습니다.", - "power.origins.tailwind.name": "순풍", - "power.origins.tailwind.description": "당신은 남들보다 조금 더 빨리 걷는습니다.", - "power.origins.slow_falling.name": "깃털 같은 무게", - "power.origins.slow_falling.description": "웅크리며 않는 한 깃털처럼 부드럽게 땅에 떨어집니다.", - "power.origins.vegetarian.name": "채식주의자", - "power.origins.vegetarian.description": "당신은 고기를 소화할 수 없습니다.", - "power.origins.fresh_air.name": "상쾌한 공기", - "power.origins.fresh_air.description": "취침 시 침대는 최소 86블록의 Y 좌표에 있어야 신선한 공기를 마실 수 있습니다.", - "power.origins.phasing.name": "통과", - "power.origins.phasing.description": "팬텀 상태에서는 흑요석을 제외한 고체 물질을 통과할 수 있습니다.", - "power.origins.invisibility.name": "투명", - "power.origins.invisibility.description": "당신이 팬텀 상태인 동안 당신은 투명화됩니다.", - "power.origins.hunger_over_time.name": "빠른 허기", - "power.origins.hunger_over_time.description": "팬텀 상태가 되면 배가 고프게 됩니다.", - "power.origins.burn_in_daylight.name": "햇빛 알레르기", - "power.origins.burn_in_daylight.description": "만약 당신이 투명이라면 낮에 화상을 입습니다.", - "power.origins.fall_immunity.name": "아크로바틱", - "power.origins.fall_immunity.description": "어느 높이에서 떨어지더라도 낙하 피해를 받지 않습니다.", - "power.origins.sprint_jump.name": "강한 발목", - "power.origins.sprint_jump.description": "달리면서 점프하면 더 높이 뛸 수 있습니다.", - "power.origins.nine_lives.name": "아홉개의 생명", - "power.origins.nine_lives.description": "당신은 인간보다 체력이 1개 적습니다.", - "power.origins.cat_vision.name": "야행성", - "power.origins.cat_vision.description": "물속에 있지 않을 때 어둠 속에서 약간 볼 수 있습니다.", - "power.origins.weak_arms.name": "나약한 팔", - "power.origins.weak_arms.description": "힘의 물약의 효과를 받고 있지 않을 때, 인접한 다른 자연석 블록이 최대 2개인 경우에만 자연석을 채굴할 수 있습니다.", - "power.origins.scare_creepers.name": "고양이 같이", - "power.origins.scare_creepers.description": "크리퍼는 당신을 무서워하며 먼저 공격해야만 폭발합니다.", - "power.origins.launch_into_air.name": "바람의 선물", - "power.origins.launch_into_air.description": "30초마다 자신을 약 20개의 블록 위로 발사할 수 있습니다.", - "power.origins.elytra.name": "겉날개", - "power.origins.elytra.description": "겉날개를 착용하지 않고 겉날개를 사용할 수 있습니다.", - "power.origins.light_armor.name": "이동의 필요성", - "power.origins.light_armor.description": "무거운 갑옷(사슬 갑옷보다 보호 수치가 높은 갑옷)을 입을 수 없습니다.", - "power.origins.claustrophobia.name": "폐소공포증", - "power.origins.claustrophobia.description": "천장이 낮은 곳에 너무 오래 있으면 약해지고 느려집니다.", - "power.origins.more_kinetic_damage.name": "부서지기 쉬운 뼈", - "power.origins.more_kinetic_damage.description": "넘어지거나 블록으로 날아가면 더 많은 피해를 입습니다.", - "power.origins.aerial_combatant.name": "공중전", - "power.origins.aerial_combatant.description": "겉날개로 비행 중에는 훨씬 더 많은 피해를 입힐 수 있습니다.", - "power.origins.throw_ender_pearl.name": "순간 이동", - "power.origins.throw_ender_pearl.description": "언제든지 원할 때마다 피해를 입히지 않는 엔더 진주를 던져 순간이동할 수 있습니다.", - "power.origins.pumpkin_hate.name": "무서운 호박", - "power.origins.pumpkin_hate.description": "몇가지 좋은 이유로 당신은 호박을 두려워합니다.", - "power.origins.extra_reach.name": "슬렌더 몸", - "power.origins.extra_reach.description": "더 멀리 있는 블록과 엔티티에 도달할 수 있습니다.", - "power.origins.shulker_inventory.name": "사망 보험", - "power.origins.shulker_inventory.description": "아이템을 사망해도 유지하는 추가 인벤토리 슬롯 9개에 액세스할 수 있습니다.", - "power.origins.natural_armor.name": "단단한 피부", - "power.origins.natural_armor.description": "갑옷을 입지 않아도 피부는 자연스러운 보호 기능을 제공합니다.", - "power.origins.more_exhaustion.name": "식욕과다", - "power.origins.more_exhaustion.description": "당신은 다른 사람들보다 훨씬 더 빨리 지치므로 더 많이 먹어야 합니다.", - "power.origins.no_shield.name": "다루기 힘든 손", - "power.origins.no_shield.description": "당신의 손은 만들어 질때부터 방패를 들 수 없었습니다.", - "power.origins.strong_arms.name": "강한 팔", - "power.origins.strong_arms.description": "당신은 곡괭이를 사용하지 않고 돌을 깨뜨릴 만큼 강합니다.", - "power.origins.translucent.name": "반투명", - "power.origins.translucent.description": "당신의 피부는 반투명합니다.", - "power.origins.end_spawn.name": "디 엔드 주민", - "power.origins.end_spawn.description": "당신의 여정은 디 엔드에서 부터 시작됩니다.", - "power.origins.master_of_webs.name": "거미줄 마스터", - "power.origins.master_of_webs.description": "당신은 거미줄을 완벽하게 탐색하고 그 안으로 올라갈 수 있습니다. 근접전에서 적을 공격하면 한동안 거미줄에 갇히게 됩니다. 거미줄에 갇힌 비절지 동물은 감지됩니다. 끈으로 거미줄을 만들 수 있습니다.", - "power.origins.lay_eggs.name": "알 낳기", - "power.origins.lay_eggs.description": "아침에 일어날 때마다 알을 낳습니다.", - "power.origins.phantomize.name": "팬텀 상태", - "power.origins.phantomize.description": "마음대로 인간 상태와 팬텀 상태 사이를 전환할 수 있지만 달릴 수 있을 만큼 충분히 허기 상태일 때만 가능합니다.", - "power.origins.like_air.name": "공기 처럼", - "power.origins.like_air.description": "공중에 떠 있는 동안 조류 인간의 보행 속도도 적용됩니다.", - "power.origins.velvet_paws.name": "벨벳 발", - "power.origins.velvet_paws.description": "당신의 발걸음은 근처 엔티티에 의해 포착될 수 있는 진동을 일으키지 않습니다.", - "category.origins": "Orgins", - "key.origins.primary_active": "능력 사용 (기본)", - "key.origins.secondary_active": "능력 사용 (서브)", - "key.origins.view_origin": "종족 보기", - "text.autoconfig.origins.title": "Origins 구성", - "text.autoconfig.origins.option.xOffset": "오프셋 쿨다운 바 X", - "text.autoconfig.origins.option.yOffset": "오프셋 쿨다운 바 Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "팬텀 상태 오버레이 강도", - "item.origins.orb_of_origin": "종족 구슬", - "component.item.origins.origin.layer": "새 %s을(를) 선택할 수 있습니다", - "component.item.origins.origin.layer_and_origin": "%1$s을(를) \"%2$s\"(으)로 설정합니다.", - "enchantment.origins.water_protection": "물 보호", - "enchantment.origins.water_protection.desc": "공수병으로 인한 손상을 지연시킵니다.", - "container.shulker_inventory_power": "셜커 인벤토리", - "origins.gui.select": "선택", - "origins.gui.close": "닫기", - "origins.gui.choose": "선택", - "origins.gui.choose_origin.title": "당신의 %s을(를) 고르세요.", - "origins.gui.view_origin.title": "%s이(가) 당신의 종족입니다.", - "origins.gui.view_origin.empty": "당신은 아무 종족을 가지고 있지 않습니다.", - "origins.gui.view_origin.not_installed": "이 서버는 Origins 모드가 설치되어있지 않습니다.", - "origins.gui.impact.impact": "영향", - "origins.gui.impact.none": "없음", - "origins.gui.impact.low": "낮음", - "origins.gui.impact.medium": "중간", - "origins.gui.impact.high": "높음", - "origins.gui.version_mismatch": "이 서버는 설치한 버전(v%2$s)과 호환되지 않는 다른 버전의 Origins(v%1$s)를 실행하고 있습니다.", - "origins.gui.badge.active": "%s와 함께 능력을 사용하세요.", - "origins.gui.badge.toggle": "%s로 전환합니다.", - "origins.gui.badge.recipe.crafting.shaped": "제작 레시피 (모양):", - "origins.gui.badge.recipe.crafting.shapeless": "제작 레시피 (모양 없음):", - "origins.gui.unbound_key": "§o언 바운드§r", - "origin.origins.random.name": "랜덤", - "origin.origins.random.description": "다음중 한개의 종족이 할당됩니다.", - "layer.origins.origin.name": "종족", - "origin.origins.empty.name": "없음", - "origin.origins.empty.description": "당신은 아무 종족을 가지고 있지 않습니다.", - "death.attack.no_water_for_gills": "%1$s이(가) 젖은 상태를 유지하지 못했습니다.", - "death.attack.no_water_for_gills.player": "%1$s은(는) %2$s과(와) 싸우고 있었기 때문에 젖은 상태를 유지하지 못했습니다.", - "death.attack.hurt_by_water": "%1$s이(가)너무 오래 목욕했습니다.", - "death.attack.hurt_by_water.player": "%1$s은(는) %2$s에 의해 물속에 잠겼습니다.", - "death.attack.genericDamageOverTime": "%1$s은(는) 지속 피해 효과로 사망했습니다.", - "death.attack.genericDamageOverTime.player": "%1$s은(는) %2$s와(과) 싸우는 동안 지속 피해 효과로 사망했습니다.", - "commands.origin.origin_not_found": "알 수 없는 종족: %s", - "commands.origin.layer_not_found": "알 수 없는 레이어: %s", - "commands.origin.unregistered_in_layer": "종족 %1$s은(는) 레이어 %2$s에 등록되어 있지 않습니다!", - "commands.origin.get.result": "%s에는 다음 %s이(가) 있습니다 : %s(%s)", - "commands.origin.gui.all": "%s 플레이어를 위한 선택 GUI를 열었습니다", - "commands.origin.gui.layer": "%1$s 플레이어를 위한 \"%2$s\" 선택 GUI를 열었습니다.", - "commands.origin.random.all": "%2$s 레이어의 %1$s 대상에 무작위로 종족 할당", - "commands.origin.random.not_allowed": "%1$s 레이어는 랜덤의 종족을 허용하지 않습니다!", - "commands.origin.random.success.multiple": "%2$s 레이어의 %1$s 대상에 랜덤으로 종족 할당", - "commands.origin.random.success.single": "%3$s 레이어의 %1$s에 종족 %2$s을(를) 랜덤으로 할당했습니다.", - "commands.origin.set.success.multiple": "%s 레이어에 있는 %s 대상의 종족을 %s로 설정", - "commands.origin.set.success.single": "레이어 %s에 있는 %s의 종족을 %s(으)로 설정합니다.", - "origins.avian_sleep_fail": "잠을 자려면 상쾌한 공기가 필요합니다" -} diff --git a/origins/src/main/resources/assets/origins/lang/nl_nl.json b/origins/src/main/resources/assets/origins/lang/nl_nl.json deleted file mode 100644 index 0ad37b10c..000000000 --- a/origins/src/main/resources/assets/origins/lang/nl_nl.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "origin.origins.human.name": "Mens", - "origin.origins.human.description": "Een normaal mens. Je gebruikelijke Minecraft-ervaring wacht op je.", - "origin.origins.merling.name": "Meermin", - "origin.origins.merling.description": "Deze natuurlijke bewoners van de oceaan zijn niet gewend aan lang boven water te blijven.", - "origin.origins.arachnid.name": "Spinachtige", - "origin.origins.arachnid.description": "Hun klim-capaciteiten en de gave hun vijanden in webben vast te binden maken spinachtigen perfecte jagers.", - "origin.origins.blazeborn.name": "Blazegeboren", - "origin.origins.blazeborn.description": "Verre nakomelingen van de Blaze zijn de Blazegeboren van nature immuun voor de gevaren van de Nether.", - "origin.origins.avian.name": "Gevleugelde", - "origin.origins.avian.description": "Het Gevleugelde ras heeft zijn vaardigheid om te vliegen lang geleden verloren. Nu kunnen deze vredige gediertes al zwevend door de lucht gespot worden.", - "origin.origins.phantom.name": "Phantoom", - "origin.origins.phantom.description": "Als half-mens, half-phantoom kroost kunnen deze wezens wisselen tussen een normaal gestalte en een Phantoom-vorm.", - "origin.origins.feline.name": "Katachtige", - "origin.origins.feline.description": "Met hun kattig uiterlijk jagen de Katachtigen creepers ver weg. En soepeltjes als een kat komen ze altijd op hun pootjes terecht.", - "origin.origins.elytrian.name": "Elytriaan", - "origin.origins.elytrian.description": "Vaak rondvliegend in de wind zijn de Elytrianen oncomfortabel als ze eens niet zo veel hoofdruimte hebben.", - "origin.origins.enderian.name": "Enderiaan", - "origin.origins.enderian.description": "Geboren als zonen en dochters van de Enderdraak zijn Enderianen teleporteer-vaardig maar kwetsbaar voor water.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Verwant met Shulkers zijn de lichamen van de Shulk bedekt met een stevig soort schelp-achtig schild.", - "power.origins.water_breathing.name": "Kieuwen", - "power.origins.water_breathing.description": "Je kan onder water ademen, maar niet op het droge.", - "power.origins.aqua_affinity.name": "Aqua Affiniteit", - "power.origins.aqua_affinity.description": "Jij kan onderwater blokken net zo makkelijk breken als anderen op het land.", - "power.origins.water_vision.name": "Natte Ogen", - "power.origins.water_vision.description": "Jouw visie onder water is perfect.", - "power.origins.swim_speed.name": "Vinnen", - "power.origins.swim_speed.description": "Je onderwatersnelheid is verhoogd.", - "power.origins.like_water.name": "Als Water", - "power.origins.like_water.description": "Wanneer je onder water bent zink je niet tenzij je het zelf wilt.", - "power.origins.fragile.name": "Fragiel", - "power.origins.fragile.description": "Je hebt 3 levens minder dan mensen.", - "power.origins.webbing.name": "Webbend", - "power.origins.webbing.description": "Wanneer je een vijand in melee raakt, komen ze klem te zitten in spinnenwebben.", - "power.origins.climbing.name": "Klimmend", - "power.origins.climbing.description": "Je kan elke soort muur beklimmen, niet enkel ladders.", - "power.origins.carnivore.name": "Carnivoor", - "power.origins.carnivore.description": "Jouw dieet is beperkt tot vlees, je kan geen groenten eten.", - "power.origins.fire_immunity.name": "Vuurimmuniteit", - "power.origins.fire_immunity.description": "Je bent immuun tegen elke soort vuurschade.", - "power.origins.nether_spawn.name": "Nether Bewoner", - "power.origins.nether_spawn.description": "Jouw natuurlijke spawn zal in de Nether zijn.", - "power.origins.burning_wrath.name": "Kokende Woede", - "power.origins.burning_wrath.description": "Wanneer je zelf brand, doe je extra veel schade tegen vijanden.", - "power.origins.hotblooded.name": "Heetbloedig", - "power.origins.hotblooded.description": "Vanwege je hete lichaam verschrompeld gif, waardoor je immuun bent voor vergiftiging of honger effecten.", - "power.origins.water_vulnerability.name": "Hydrofobie", - "power.origins.water_vulnerability.description": "Als je in contact bent met water ontvang je langzaam schade.", - "power.origins.tailwind.name": "Wind in de Rug", - "power.origins.tailwind.description": "Je bent te voet net iets sneller dan anderen.", - "power.origins.slow_falling.name": "Licht als een Veertje", - "power.origins.slow_falling.description": "Je valt zo rustig als een veertje, tenzij je bukt.", - "power.origins.vegetarian.name": "Vegetariër", - "power.origins.vegetarian.description": "Je kan geen vlees verteren.", - "power.origins.fresh_air.name": "Frisse Lucht", - "power.origins.fresh_air.description": "Als je slaapt moet je bed op een hoogte van ten minste 86 blokken staan, zodat je de frisse lucht in kan ademen.", - "power.origins.phasing.name": "Geestig", - "power.origins.phasing.description": "Wanneer je gephantomiseerd bent kan je door vast materiaal lopen, behalve Obsidiaan.", - "power.origins.invisibility.name": "Onzichtbaarheid", - "power.origins.invisibility.description": "Wanneer je gephantomiseerd bent, ben je onzichtbaar.", - "power.origins.hunger_over_time.name": "Snelle Stofwisseling", - "power.origins.hunger_over_time.description": "Gephantomiseerd zijn zorgt ervoor dat je honger krijgt.", - "power.origins.burn_in_daylight.name": "Photoallergisch", - "power.origins.burn_in_daylight.description": "Je verbrandt in daglicht, tenzij je onzichtbaar bent.", - "power.origins.fall_immunity.name": "Acrobatiek", - "power.origins.fall_immunity.description": "Je krijgt nooit schade van een val, hoe ver je ook valt.", - "power.origins.sprint_jump.name": "Sterke Beenspieren", - "power.origins.sprint_jump.description": "Je kan extra hoog springen door te springen terwijl je aan het rennen bent.", - "power.origins.nine_lives.name": "Negen Levens", - "power.origins.nine_lives.description": "Je hebt 1 hartje minder dan de gemiddelde mens.", - "power.origins.cat_vision.name": "Nachtwezen", - "power.origins.cat_vision.description": "Je kan iets beter zien in het donker, boven water.", - "power.origins.weak_arms.name": "Zwakke Armen", - "power.origins.weak_arms.description": "Wanneer je niet onder het effect van een Kracht-drank bent, kan je natuurlijke steen alleen hakken als er niet meer dan 2 andere blokjes steen aan vast zitten.", - "power.origins.scare_creepers.name": "Kattig Uiterlijk", - "power.origins.scare_creepers.description": "Creepers zijn bang voor je en ontploffen alleen als jij hen eerst aanvalt.", - "power.origins.launch_into_air.name": "Gift van de Wind", - "power.origins.launch_into_air.description": "Iedere 30 seconden kan je jezelf zo'n 20 blokken de lucht in lanceren.", - "power.origins.elytra.name": "Gevleugeld", - "power.origins.elytra.description": "Je hebt Elytra vleugels zonder ze te hoeven equippen.", - "power.origins.light_armor.name": "Need for Mobility", - "power.origins.light_armor.description": "Je kan geen zware harnassen dragen (armor met meer bescherming dan maliën).", - "power.origins.claustrophobia.name": "Claustrofobisch", - "power.origins.claustrophobia.description": "Als je te lang ergens met een laag dak bent, verzwak en vertraag je.", - "power.origins.more_kinetic_damage.name": "Fragiele Botten", - "power.origins.more_kinetic_damage.description": "Je krijgt meer schade van het vallen en vliegen tegen blokken.", - "power.origins.aerial_combatant.name": "Luchtige Vechter", - "power.origins.aerial_combatant.description": "Je doet behoorlijk wat meer schade in een Elytra-vlucht.", - "power.origins.throw_ender_pearl.name": "Teleportatie", - "power.origins.throw_ender_pearl.description": "Wanneer je ook wilt, kan je een ender parel gooien die geen schade doet, waardoor je kan teleporteren.", - "power.origins.pumpkin_hate.name": "Vrees voor Kalebassen", - "power.origins.pumpkin_hate.description": "Je bent bang voor pompoenen. Voor een goede reden.", - "power.origins.extra_reach.name": "Lang Lichaam", - "power.origins.extra_reach.description": "Je kan van verder weg bij blokken en entiteiten.", - "power.origins.shulker_inventory.name": "Hamsteraar", - "power.origins.shulker_inventory.description": "Je hebt beschikking over 9 extra vakken voor je inventaris, die zelfs na de dood items blijven bewaren.", - "power.origins.natural_armor.name": "Stevige Huid", - "power.origins.natural_armor.description": "Zelfs zonder een harnas te dragen, biedt je huid natuurlijke bescherming.", - "power.origins.more_exhaustion.name": "Grote Trek", - "power.origins.more_exhaustion.description": "Je put jezelf sneller uit, waardoor je meer moet eten.", - "power.origins.no_shield.name": "Onhandig", - "power.origins.no_shield.description": "De manier waarop je handen gevormd zijn zorgen ervoor dat het onmogelijk is een schild rechtop te houden.", - "power.origins.strong_arms.name": "Sterke Armen", - "power.origins.strong_arms.description": "Je bent sterk genoeg natuurlijke steen te breken zonder een pikhouweel.", - "power.origins.translucent.name": "Doorschijnend", - "power.origins.translucent.description": "Jouw huid is doorschijnend.", - "category.origins": "Origins", - "key.origins.primary_active": "Actieve Kracht", - "key.origins.view_origin": "Zie Origin", - "text.autoconfig.origins.title": "Origins Configuratie", - "text.autoconfig.origins.option.xOffset": "Cooldown Balk X-Offset", - "text.autoconfig.origins.option.yOffset": "Cooldown Balk Y-Offset", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Gephantomiseerd Overlay Sterkte", - "item.origins.orb_of_origin": "Orb van Origin", - "enchantment.origins.water_protection": "Water Bescherming", - "container.shulker_inventory_power": "Shulker Inventaris", - "origins.gui.select": "Selecteer", - "origins.gui.close": "Sluit", - "origins.gui.choose_origin.title": "Kies jouw %s.", - "origins.gui.view_origin.title": "Dit is jouw %s.", - "origins.gui.impact.impact": "Impact", - "origins.gui.impact.none": "Geen", - "origins.gui.impact.low": "Laag", - "origins.gui.impact.medium": "Middel", - "origins.gui.impact.high": "Hoog", - "layer.origins.origin": "Origin", - "death.attack.no_water_for_gills": "%s was als een vis op het droge.", - "death.attack.hurt_by_water": "%s was iets te lekker aan het zwemmen.", - "commands.origin.origin_not_found": "Onbekende origin: %s", - "commands.origin.set.success.single": "Origin van %s naar %s gezet.", - "commands.origin.set.success.multiple": "Origin van %s targets naar %s gezet.", - "power.origins.end_spawn.name": "End Inhabitant", - "power.origins.end_spawn.description": "Your journey begins in the End.", - "power.origins.master_of_webs.name": "Master of Webs", - "power.origins.master_of_webs.description": "You navigate cobweb perfectly, and are able to climb in them. When you hit an enemy in melee, they get stuck in cobweb for a while. Non-arthropods stuck in cobweb will be sensed by you. You are able to craft cobweb from string.", - "power.origins.lay_eggs.name": "Oviparous", - "power.origins.lay_eggs.description": "Whenever you wake up in the morning, you will lay an egg.", - "power.origins.phantomize.name": "Phantom Form", - "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", - "power.origins.like_air.name": "Like Air", - "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", - "power.origins.velvet_paws.name": "Velvet Paws", - "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", - "key.origins.secondary_active": "Active Power (Secondary)", - "component.item.origins.origin.layer": "Lets you choose a new %s.", - "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", - "origins.gui.choose": "Choose", - "origins.gui.view_origin.empty": "You can not have any Origins.", - "origins.gui.view_origin.not_installed": "The server does not have Origins installed.", - "origins.gui.version_mismatch": "This server is running a different version of Origins (v%1$s) which is incompatible with the one you have installed (v%2$s).", - "origins.gui.badge.active": "Active ability, use with %s.", - "origins.gui.badge.toggle": "Toggle with %s.", - "origins.gui.unbound_key": "§ounbound§r", - "origin.origins.random.name": "Random", - "origin.origins.random.description": "You'll be assigned one of the following:", - "layer.origins.origin.name": "Origin", - "origin.origins.empty.name": "Missing", - "origin.origins.empty.description": "You do not have an Origin.", - "death.attack.no_water_for_gills.player": "%1$s didn't manage to keep wet because they were fighting %2$s", - "death.attack.hurt_by_water.player": "%1$s was put underwater by %2$s", - "death.attack.genericDamageOverTime": "%1$s died to a damage over time effect", - "death.attack.genericDamageOverTime.player": "%1$s died to a damage over time effect whilst fighting %2$s", - "commands.origin.get.result": "%s has the following %s: %s (%s)", - "commands.origin.gui.all": "Opened the selection GUI for %s players.", - "commands.origin.gui.layer": "Opened the \"%2$s\" selection GUI for %1$s players.", - "origins.avian_sleep_fail": "You need fresh air to sleep", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/pl_pl.json b/origins/src/main/resources/assets/origins/lang/pl_pl.json deleted file mode 100644 index 1f254b480..000000000 --- a/origins/src/main/resources/assets/origins/lang/pl_pl.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Człowiek", - "origin.origins.human.description": "Oto Twoje najzwyczajniejsze doświadczenie jakie Cię czeka w Minecraft. Powodzenia!", - "origin.origins.merling.name": "Rybołak", - "origin.origins.merling.description": "Życie pod wodą nie jest dla nich zbyt trudne, jednak brak narządów do oddychania poza wodą stanowi dla nich sporą przeszkodę na lądzie.", - "origin.origins.arachnid.name": "Pajęczak", - "origin.origins.arachnid.description": "Pajęczaki są idealnymi łowcami. Ich pajęcze sieci doskonale sprawdzają się jako pułapki i żadna ściana nie stanowi dla nich przeszkody dzięki ich zdolności do wspinania się po nich.", - "origin.origins.blazeborn.name": "Płomnik", - "origin.origins.blazeborn.description": "Późni potomkowie strażników fortec - płomyków, Płomniki są naturalnie przystosowani do życia w wymiarze zdominowanym przez wszechorganiający gorąc - Netherze.", - "origin.origins.avian.name": "Uskrzydlony", - "origin.origins.avian.description": "W dawnych czasach ta rasa umiała latać, dominując niebo za dnia i nocy, jednak z jakiegoś powodu utraciła tą zdolność. O ile nie potrafią już latać, można zaobserwować członków tej rasy jak szybują z miejsca do miejsca.", - "origin.origins.phantom.name": "Duch", - "origin.origins.phantom.description": "Jako potomek pół-człowieka i pół-fantoma, jesteś stworzeniem mogącym zmieniać swoją formę z ludzkiej na poł-materialną.", - "origin.origins.feline.name": "Kotołak", - "origin.origins.feline.description": "Creepery uciekają od ciebie z przerażenia na twój koci wygląd. Twoja rasa jest znana z nadludzkiej zwinności pozwalającej na niezwykłe akrobatyczne osiągniecia.", - "origin.origins.elytrian.name": "Elytrian", - "origin.origins.elytrian.description": "Elytrianie, często szybujący w powietrzu, czują się niekomfortowo, gdy nie mają wystarczająco dużo przestrzeni nad głową.", - "origin.origins.enderian.name": "Kreslud", - "origin.origins.enderian.description": "Urodzeni jako dzieci Smoka Kresu, Kresludzie posiadają niezwykłą zdolność do teleportacji która jest bardzo przydatna przy omijaniu wody która ich rani.", - "origin.origins.shulk.name": "Shulkownik", - "origin.origins.shulk.description": "Podobnie jak shulkery, ciała Shulkowników są pokryte idealnie dopasowaną naturalną zbroją-muszlą.", - "power.origins.water_breathing.name": "Skrzela", - "power.origins.water_breathing.description": "Możesz oddychać pod wodą, ale nie na lądzie.", - "power.origins.aqua_affinity.name": "Podwodne Pochodzenie", - "power.origins.aqua_affinity.description": "Możesz niszczyć bloki pod wodą, tak szybko, jak inni na lądzie.", - "power.origins.water_vision.name": "Morskie Oczy", - "power.origins.water_vision.description": "Doskonale widzisz pod wodą.", - "power.origins.swim_speed.name": "Płetwy", - "power.origins.swim_speed.description": "Twoja zdolność poruszania się w wodzie jest lepsza niż u ludzi.", - "power.origins.like_water.name": "Jak Woda", - "power.origins.like_water.description": "Pod wodą nie opadasz na dno, chyba że chcesz.", - "power.origins.fragile.name": "Delikatny", - "power.origins.fragile.description": "Masz 3 serca mniej niż ludzie.", - "power.origins.webbing.name": "Pajęczy Atak", - "power.origins.webbing.description": "Gdy udeżysz przeciwnika w walce wręcz, uwięzisz go w pajęczynie.", - "power.origins.climbing.name": "Wspinaczka", - "power.origins.climbing.description": "Możesz wspinać się po każdej ścianie, nie tylko po drabinie.", - "power.origins.carnivore.name": "Mięsożerca", - "power.origins.carnivore.description": "Nie trawisz warzyw i owoców.", - "power.origins.fire_immunity.name": "Ognioodpornosć", - "power.origins.fire_immunity.description": "Jesteś odporny na wszystkie rodzaje obrażeń od ognia.", - "power.origins.nether_spawn.name": "Mieszkaniec Nether'u", - "power.origins.nether_spawn.description": "Twoja przygoda zaczyna się w Netherze.", - "power.origins.burning_wrath.name": "Płonący Gniew", - "power.origins.burning_wrath.description": "Gdy płoniesz, twoje ataki zadają dodatkowe obrażenia.", - "power.origins.hotblooded.name": "Wrząca Krew", - "power.origins.hotblooded.description": "Twoje gorące ciało spala wszelkie trucizny, czyniąc cię odpornym na efekty głodu oraz zatrucia.", - "power.origins.water_vulnerability.name": "Wodowstręt", - "power.origins.water_vulnerability.description": "Z czasem otrzymujesz obrażenia przy kontakcie z wodą.", - "power.origins.tailwind.name": "Pędzić z wiatrem", - "power.origins.tailwind.description": "Chodzisz i biegasz nieco szybciej niż inni.", - "power.origins.slow_falling.name": "Lekki jak piórko", - "power.origins.slow_falling.description": "Upadasz na ziemię delikatnie jak piórko, o ile się nie skradasz.", - "power.origins.vegetarian.name": "Wegetarianin", - "power.origins.vegetarian.description": "Nie trawisz mięsa.", - "power.origins.fresh_air.name": "Świeże Powietrze", - "power.origins.fresh_air.description": "Łóżko musi znajdować się na wysokości co najmniej 86 bloków, abyś mógł oddychać świeżym powietrzem gdy śpisz.", - "power.origins.phasing.name": "Fazowanie", - "power.origins.phasing.description": "W swojej poł-materialnej formie możesz przechodzić przez stały materiał. Tylko materiał trwały jak Obsidian dalej stanowi dla Ciebie przeszkodę.", - "power.origins.invisibility.name": "Niewidzialność", - "power.origins.invisibility.description": "Jesteś niewidzialny gdy w poł-materialnej formie.", - "power.origins.hunger_over_time.name": "Szybki Metabolizm", - "power.origins.hunger_over_time.description": "Bycie w pół-materialnej formie bardzo Cię męczy i powoduje spotęgowany głów.", - "power.origins.burn_in_daylight.name": "Światłowstręt", - "power.origins.burn_in_daylight.description": "Zaczynasz płonąć w świetle dziennym, jeśli nie jesteś niewidzialny.", - "power.origins.fall_immunity.name": "Akrobatyka", - "power.origins.fall_immunity.description": "Upadek jest tobie niegroźny, bez względu na to jak wielki.", - "power.origins.sprint_jump.name": "Mocne kostki", - "power.origins.sprint_jump.description": "Możesz skakać wyżej skacząc podczas sprintu.", - "power.origins.nine_lives.name": "Dziewięć Żyć", - "power.origins.nine_lives.description": "Masz o 1 serce mniej niż ludzie.", - "power.origins.cat_vision.name": "Nocny Wzrok", - "power.origins.cat_vision.description": "Możesz lepiej widzieć w ciemności, gdy nie jesteś w wodzie.", - "power.origins.weak_arms.name": "Słabe Ramiona", - "power.origins.weak_arms.description": "Kiedy nie jesteś pod wpływem mikstury siły, możesz wydobywać naturalnie występujący kamień tylko wtedy, gdy sąsiadują obok niego co najwyżej 2 inne bloki kamienia naturalnego.", - "power.origins.scare_creepers.name": "Koci Wygląd", - "power.origins.scare_creepers.description": "Creepery się ciebie boją, wybuchną jedynie jeśli je zaatakujesz.", - "power.origins.launch_into_air.name": "Dar Wiatrów", - "power.origins.launch_into_air.description": "Co 30 sekund jesteś w stanie wystrzelić w powietrze na wysokość około 20 bloków.", - "power.origins.elytra.name": "Uskrzydlony", - "power.origins.elytra.description": "Skrzydła Elytry są częścią Ciebie, więc nie musisz ich zakładać by móc szybować.", - "power.origins.light_armor.name": "Potrzeba Ruchu", - "power.origins.light_armor.description": "Nie możesz nosić ciężkiej zbroi (o wartości ochrony większej niż kolczuga).", - "power.origins.claustrophobia.name": "Klaustrofobia", - "power.origins.claustrophobia.description": "Przebywanie w miejscu z niskim sufitem przez zbyt długi czas osłabi cię i spowolni.", - "power.origins.more_kinetic_damage.name": "Kruche Kości", - "power.origins.more_kinetic_damage.description": "Otrzymujesz więcej obrażeń od upadku i wlatywania w bloki.", - "power.origins.aerial_combatant.name": "Powietrzny Kombatant", - "power.origins.aerial_combatant.description": "Podczas lotu Elytrą zadajesz znacznie więcej obrażeń.", - "power.origins.throw_ender_pearl.name": "Teleportacja", - "power.origins.throw_ender_pearl.description": "Kiedy tylko zechcesz, możesz rzucić perłą kresu, która teleportuje cię bez zadawania obrażeń.", - "power.origins.pumpkin_hate.name": "Tylko Nie Tykwy", - "power.origins.pumpkin_hate.description": "Boisz się dyń. Nie bez powodu.", - "power.origins.extra_reach.name": "Smukłe Ciało", - "power.origins.extra_reach.description": "Możesz dosięgnąć bloków i mobów z większej odległości.", - "power.origins.shulker_inventory.name": "Zbieracz", - "power.origins.shulker_inventory.description": "Masz dostęp do dodatkowych 9 miejsc w ekwipunku, które zatrzymują przedmioty po śmierci.", - "power.origins.natural_armor.name": "Pancerz", - "power.origins.natural_armor.description": "Twoja skóra jest jak pancerz zapewniający ci naturalną ochronę, nawet gdy nie nosisz faktycznej zbroi.", - "power.origins.more_exhaustion.name": "Obżartuch", - "power.origins.more_exhaustion.description": "Wyczerpujesz się znacznie szybciej niż inni, przez co musisz jeść więcej.", - "power.origins.no_shield.name": "Niezręczny", - "power.origins.no_shield.description": "Sposób, w jaki zbudowane są twoje dłonie, nie pozwala na odpowiednie trzymanie tarczy. Nie możesz jej unieść by osłonić się przed atakami.", - "power.origins.strong_arms.name": "Silne Ramiona", - "power.origins.strong_arms.description": "Jesteś wystarczająco silny aby wydobywać naturalnie występujący kamień bez użycia kilofa.", - "power.origins.translucent.name": "Przeświecający", - "power.origins.translucent.description": "Twoja skóra jest przezroczysta.", - "power.origins.end_spawn.name": "Mieszkaniec End'u", - "power.origins.end_spawn.description": "Twoja przygoda zaczyna się w Kresie.", - "power.origins.master_of_webs.name": "Mistrz Pajęczyn", - "power.origins.master_of_webs.description": "Doskonale poruszasz się po pajęczynie i potrafisz się po niej wspinać. Kiedy uderzysz wroga w walce wręcz, utknie on na chwilę w pajęczynie. Nie-stawonogi, które utknęły w pajęczynie, zostaną przez Ciebie wykryte. Jesteś w stanie stworzyć pajęczynę z nici.", - "power.origins.lay_eggs.name": "Jajorodny", - "power.origins.lay_eggs.description": "Za każdym razem, gdy się budzisz, składasz jajko.", - "category.origins": "Origins", - "key.origins.primary_active": "Użyj umiejętności głównej", - "key.origins.secondary_active": "Użyj umiejętności dodatkowej", - "key.origins.view_origin": "Wyświetl Pochodzenie", - "text.autoconfig.origins.title": "Konfiguracja Origins", - "text.autoconfig.origins.option.xOffset": "Położenie Paska Ładowania Umiejętności na osi X", - "text.autoconfig.origins.option.yOffset": "Położenie Paska Ładowania Umiejętności na osi Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Widoczność nakładki przy byciu poł-materialnym", - "item.origins.orb_of_origin": "Kula Pochodzenia", - "enchantment.origins.water_protection": "Ochrona przed wodą", - "container.shulker_inventory_power": "Plecak Shulkownika", - "origins.gui.select": "Wybierz", - "origins.gui.close": "Zamknij", - "origins.gui.choose": "Wybierz", - "origins.gui.choose_origin.title": "Wybierz swoje %s.", - "origins.gui.view_origin.title": "Wybierz swoje %s.", - "origins.gui.view_origin.empty": "Nie możesz mieć żadnych Pochodzeń.", - "origins.gui.view_origin.not_installed": "Ten serwer nie ma zainstalowanego Origins.", - "origins.gui.impact.impact": "Wpływ", - "origins.gui.impact.none": "Żaden", - "origins.gui.impact.low": "Słaby", - "origins.gui.impact.medium": "Średni", - "origins.gui.impact.high": "Wysoki", - "origins.gui.version_mismatch": "Ten serwer działa pod inną wersją Origins (v%1$s), która jest niekompatybilna z tą, zainstalowaną u ciebie (v%2$s).", - "origin.origins.random.name": "Losowe", - "origin.origins.random.description": "Zostaniesz przydzielony do jednego z poniższych:", - "layer.origins.origin.name": "Pochodzenie ", - "origin.origins.empty.name": "Nieznane pochodzenie", - "origin.origins.empty.description": "Twoje pochodzenie jest nieznane. Kim jesteś?", - "death.attack.no_water_for_gills": "%1$s nie udało się pozostać mokrym.", - "death.attack.no_water_for_gills.player": "%1$s nie udało się pozostać mokrym, ponieważ walczył z %2$s.", - "death.attack.hurt_by_water": "%1$s brał kąpiel zbyt długo.", - "death.attack.hurt_by_water.player": "%1$s brał kąpiel zbyt długo przez %2$s.", - "death.attack.genericDamageOverTime": "%1$s zginął od przewlekłych obrażeń.", - "death.attack.genericDamageOverTime.player": "%1$s zginął od przewlekłych obrażeń w walce z %2$s.", - "commands.origin.origin_not_found": "Nieznane pochodzenie: %s", - "commands.origin.set.success.single": "Udało się ustawić pochodzenie %s w wastwie %s na %s.", - "commands.origin.set.success.multiple": "Udało się ustawić pochodzenie %s celów w wastwie %s na %s.", - "origins.avian_sleep_fail": "Potrzebujesz świeżego powietrza, aby spać", - "power.origins.phantomize.name": "Phantom Form", - "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", - "power.origins.like_air.name": "Like Air", - "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", - "power.origins.velvet_paws.name": "Velvet Paws", - "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", - "component.item.origins.origin.layer": "Lets you choose a new %s.", - "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", - "origins.gui.badge.active": "Active ability, use with %s.", - "origins.gui.badge.toggle": "Toggle with %s.", - "origins.gui.unbound_key": "§ounbound§r", - "commands.origin.get.result": "%s has the following %s: %s (%s)", - "commands.origin.gui.all": "Opened the selection GUI for %s players.", - "commands.origin.gui.layer": "Opened the \"%2$s\" selection GUI for %1$s players.", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/pt_br.json b/origins/src/main/resources/assets/origins/lang/pt_br.json deleted file mode 100644 index f34f04671..000000000 --- a/origins/src/main/resources/assets/origins/lang/pt_br.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Humano", - "origin.origins.human.description": "Um humano qualquer. Sua aventura qualquer te aguarda.", - "origin.origins.merling.name": "Oceânico", - "origin.origins.merling.description": "Estes habitantes naturais do oceano não estão acostumados a ficar fora d'água por muito tempo.", - "origin.origins.arachnid.name": "Aracnídeo", - "origin.origins.arachnid.description": "Suas habilidades de escalada e a habilidade de prender seus inimigos em uma teia de aranha faz dos Aracnídeos caçadores perfeitos.", - "origin.origins.blazeborn.name": "Incandescente", - "origin.origins.blazeborn.description": "Descendentes distantes dos Blazes, os Incandescentes são naturalmente imunes aos perigos do Nether.", - "origin.origins.avian.name": "Aviário", - "origin.origins.avian.description": "A raça Aviária perdeu sua habilidade de voar há muito tempo. Agora estas criaturas pacíficas podem ser vistas planando de um lugar ao outro.", - "origin.origins.phantom.name": "Vulto", - "origin.origins.phantom.description": "Como uma cria metade-humana e metade-fantasma, essas criaturas podem intercalar entre uma forma fantasma e uma normal.", - "origin.origins.feline.name": "Felino", - "origin.origins.feline.description": "Com sua aparência gatal, os Felinos assustam os creepers. Com a destreza dos gatos, eles sempre caem em pé sem qualquer arranhão.", - "origin.origins.elytrian.name": "Elitriano", - "origin.origins.elytrian.description": "Acostumados a voar pelos céus, Elitrianos ficam angustiados quando estão em ambientes fechados.", - "origin.origins.enderian.name": "Enderiano", - "origin.origins.enderian.description": "Nascidos do Dragão do End, Enderianos são capazes de teletransportar, mas são vulneráveis à água.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Parentes dos Shulkers, os corpos dos Shulks são protegidos por uma pele semelhante a um casco.", - "power.origins.water_breathing.name": "Guelras", - "power.origins.water_breathing.description": "Você respira debaixo d'água, mas não em terra firme.", - "power.origins.aqua_affinity.name": "Afinidade Aquática", - "power.origins.aqua_affinity.description": "Mesmo submerso, você pode quebrar blocos como se estivesse fora d'água.", - "power.origins.water_vision.name": "Olhos Úmidos", - "power.origins.water_vision.description": "Sua visão debaixo d'água é perfeita.", - "power.origins.swim_speed.name": "Barbatanas", - "power.origins.swim_speed.description": "Sua velocidade de nado é aumentada.", - "power.origins.like_water.name": "Como Água", - "power.origins.like_water.description": "Enquanto submerso, você não afunda (a menos que você queira).", - "power.origins.fragile.name": "Frágil", - "power.origins.fragile.description": "Você possui 3 corações a menos do que um Humano.", - "power.origins.webbing.name": "Tecejo de Fios", - "power.origins.webbing.description": "Quando você golpeia um inimigo, ele fica preso em uma teia de aranha.", - "power.origins.climbing.name": "Escalada", - "power.origins.climbing.description": "Você é capaz de escalar qualquer parede, não apenas escadas de mão.", - "power.origins.carnivore.name": "Carnívoro", - "power.origins.carnivore.description": "Sua dieta é restrita a carnes, você não pode comer vegetais.", - "power.origins.fire_immunity.name": "Imunidade ao Fogo", - "power.origins.fire_immunity.description": "Você é imune a todos os tipos de dano por fogo.", - "power.origins.nether_spawn.name": "Habitante do Nether", - "power.origins.nether_spawn.description": "Seu spawn natural será no Nether.", - "power.origins.burning_wrath.name": "Fúria Flamejante", - "power.origins.burning_wrath.description": "Quando estiver pegando fogo, seus ataques causam mais dano.", - "power.origins.hotblooded.name": "Sangue Quente", - "power.origins.hotblooded.description": "Devido às temperaturas de seu corpo, venenos evaporam, fazendo-te imune a qualquer tipo de efeito venenoso.", - "power.origins.water_vulnerability.name": "Hidrofobia", - "power.origins.water_vulnerability.description": "Você recebe dano enquanto em contato com a água.", - "power.origins.tailwind.name": "A Favor do Vento", - "power.origins.tailwind.description": "Você é um pouco mais rápido a pé do que os outros.", - "power.origins.slow_falling.name": "Peso Pena", - "power.origins.slow_falling.description": "Você cai gentilmente ao chão como uma pena, a menos que você agache.", - "power.origins.vegetarian.name": "Vegetariano", - "power.origins.vegetarian.description": "Você não consegue digerir carnes.", - "power.origins.fresh_air.name": "Ar fresco", - "power.origins.fresh_air.description": "Quando dormir, sua cama precisa estar no mínimo a 86 blocos de altura, para que você respire ar fresco.", - "power.origins.phasing.name": "Etéreo", - "power.origins.phasing.description": "Enquanto fantasma, você pode atravessar materiais sólidos, exceto Obsidiana.", - "power.origins.invisibility.name": "Invisibilidade", - "power.origins.invisibility.description": "Enquanto fantasma, você é invisível.", - "power.origins.hunger_over_time.name": "Metabolismo Rápido", - "power.origins.hunger_over_time.description": "Estar na forma fantasma aumenta gradativamente sua fome.", - "power.origins.burn_in_daylight.name": "Alérgico à Luz", - "power.origins.burn_in_daylight.description": "Você queima na luz do dia se não estiver invisível.", - "power.origins.fall_immunity.name": "Acrobacia", - "power.origins.fall_immunity.description": "Você nunca recebe dano por queda, independentemente da altura que você caiu.", - "power.origins.sprint_jump.name": "Tornozelos Fortes", - "power.origins.sprint_jump.description": "Você é apto a pular mais alto enquanto corre.", - "power.origins.nine_lives.name": "Nove Vidas", - "power.origins.nine_lives.description": "Você possui um coração a menos do que um Humano.", - "power.origins.cat_vision.name": "Noturno", - "power.origins.cat_vision.description": "Você pode levemente ver no escuro quando não estiver dentro d'água.", - "power.origins.weak_arms.name": "Braços Fracos", - "power.origins.weak_arms.description": "Quando não sob efeito de uma poção de força, você não pode minerar blocos de pedra ligados a mais de dois outros blocos de pedra.", - "power.origins.scare_creepers.name": "Aparência Gatal", - "power.origins.scare_creepers.description": "Creepers têm medo de você e só irão explodir se você atacá-los primeiro.", - "power.origins.launch_into_air.name": "Bênção do Vento", - "power.origins.launch_into_air.description": "A cada 30 segundos, você pode lançar-se 20 blocos ao ar.", - "power.origins.elytra.name": "Alado", - "power.origins.elytra.description": "Você possui asas de Élitros sem ter que equipar nada.", - "power.origins.light_armor.name": "Necessidade por Mobilidade", - "power.origins.light_armor.description": "Você não pode vestir armadura pesada (armadura com valores de proteção maiores do que malha).", - "power.origins.claustrophobia.name": "Claustrofobia", - "power.origins.claustrophobia.description": "Estando em lugares com tetos baixos por muito tempo irá enfraquecer você e te deixar lento.", - "power.origins.more_kinetic_damage.name": "Ossos de Vidro", - "power.origins.more_kinetic_damage.description": "Você recebe mais dano por queda e por \"acidentes aéreos\".", - "power.origins.aerial_combatant.name": "Combatente dos Ares", - "power.origins.aerial_combatant.description": "Você causa consideravelmente mais dano enquanto estiver voando.", - "power.origins.throw_ender_pearl.name": "Teletransporte", - "power.origins.throw_ender_pearl.description": "Quando quiser, você pode atirar uma pérola do ender que não te causa dano, possibilitanto você de teletransportar.", - "power.origins.pumpkin_hate.name": "Abóborofobia", - "power.origins.pumpkin_hate.description": "Você tem medo de abóboras. Por um bom motivo.", - "power.origins.extra_reach.name": "Corpo Esbelto", - "power.origins.extra_reach.description": "Você consegue alcançar blocos e entidades distantes.", - "power.origins.shulker_inventory.name": "Ganancioso", - "power.origins.shulker_inventory.description": "Você possui acesso a 9 espaços bônus em seu inventário, que mantêm os itens após a morte.", - "power.origins.natural_armor.name": "Pele Impenetrável", - "power.origins.natural_armor.description": "Mesmo sem estar vestindo armadura, sua pele possui proteção natural.", - "power.origins.more_exhaustion.name": "Bom de Boca", - "power.origins.more_exhaustion.description": "Você cansa mais rápido do que os outros, fazendo com que precise comer mais.", - "power.origins.no_shield.name": "Desajeitado", - "power.origins.no_shield.description": "A maneira com a qual suas mãos são formadas te impossibilita de utilizar escudos.", - "power.origins.strong_arms.name": "Braços Fortes", - "power.origins.strong_arms.description": "Você é forte o suficiente para quebrar pedras sem precisar de uma picareta.", - "power.origins.translucent.name": "Translucidez", - "power.origins.translucent.description": "Sua pele é translúcida.", - "power.origins.end_spawn.name": "Nascido no Fim", - "power.origins.end_spawn.description": "Sua aventura começa no fim.", - "power.origins.master_of_webs.name": "Mestre das Teias", - "power.origins.master_of_webs.description": "Você anda perfeitamente entre as teias, e é capaz de escalar elas. Em um combate corpo a corpo contra um inimigo, ele fica preso em uma teia por um tempo. Os que não são artrópodes e ficam presos em suas teias, você é capaz de detecta-los. Você é capaz de criar uma teia de aranha a partir de uma linha.", - "power.origins.lay_eggs.name": "Ovíparo", - "power.origins.lay_eggs.description": "Sempre que você acorda de manhã, você botara um ovo.", - "category.origins": "Origens", - "key.origins.primary_active": "Poder Ativo(Primario)", - "key.origins.secondary_active": "Poder Ativo(Secundario)", - "key.origins.view_origin": "Ver origem", - "text.autoconfig.origins.title": "Configuração do Origins", - "text.autoconfig.origins.option.xOffset": "Cooldown Bar Offset X", - "text.autoconfig.origins.option.yOffset": "Cooldown Bar Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Phantomized Overlay Strength", - "item.origins.orb_of_origin": "Orbe de Origem", - "enchantment.origins.water_protection": "Proteção contra a água", - "container.shulker_inventory_power": "Inventário Shulker", - "origins.gui.select": "Selecionar", - "origins.gui.close": "Fechar", - "origins.gui.choose": "Escolher", - "origins.gui.choose_origin.title": "Escolha sua %s.", - "origins.gui.view_origin.title": "Esta é sua %s.", - "origins.gui.view_origin.empty": "Você não pode ter nenhuma origem.", - "origins.gui.view_origin.not_installed": "O servidor não possui o mod Origins instalado.", - "origins.gui.impact.impact": "Impacto", - "origins.gui.impact.none": "Nenhum", - "origins.gui.impact.low": "Baixo", - "origins.gui.impact.medium": "Médio", - "origins.gui.impact.high": "Alto", - "origins.gui.version_mismatch": "Este servidor esta rodando uma versão diferente de Origins (v%1$s) que é incompativel com o que você tem instalado (v%2$s).", - "origin.origins.random.name": "Aleatório", - "origin.origins.random.description": "Aleatoriamente, pode cair uma das seguintes origens:", - "origin.origins.empty.name": "Faltando", - "origin.origins.empty.description": "Você não tem uma origem", - "death.attack.no_water_for_gills": "%1$s não conseguiu se manter molhado", - "death.attack.no_water_for_gills.player": "%1$s não conseguiu se manter molhado porque estava lutando com %2$s", - "death.attack.hurt_by_water": "%1$s demorou demais no banho", - "death.attack.hurt_by_water.player": "%1$s foi jogado na agua por %2$s", - "death.attack.genericDamageOverTime": "%1$s morreu por dano continuo", - "death.attack.genericDamageOverTime.player": "%1$s morreu por dano continuo enquanto lutava com %2$s", - "commands.origin.origin_not_found": "Origem desconhecida: %s", - "commands.origin.set.success.single": "Origem de %s definida para %s.", - "commands.origin.set.success.multiple": "Origens de %s alvos para %s.", - "origins.avian_sleep_fail": "Você precisa de ar fresco para dormir", - "power.origins.phantomize.name": "Forma Etéria", - "power.origins.phantomize.description": "Você pode mudar entre a forma humana e etéria quando quiser, enquanto estiver saturado o suficiente para correr", - "power.origins.like_air.name": "Como o Ar", - "power.origins.like_air.description": "Modificadores de velocidade de movimento também se aplicam no ar.", - "power.origins.velvet_paws.name": "Patas de Seda", - "power.origins.velvet_paws.description": "Seus passos não causam nenhuma vibração, que, caso contrário, poderiam ser percebidos por inimigos próximos.", - "component.item.origins.origin.layer": "Permite que selecione uma nova %s.", - "component.item.origins.origin.layer_and_origin": "Definie sua %1$s para \"%2$s\".", - "origins.gui.badge.active": "Habilidade ativa, use com %s.", - "origins.gui.badge.toggle": "Troque com %s.", - "origins.gui.unbound_key": "§ounbound§r", - "layer.origins.origin.name": "Origin", - "commands.origin.get.result": "%s tem o seguinte %s: %s (%s)", - "commands.origin.gui.all": "Abriu a seleção de GUI para %s jogadores.", - "commands.origin.gui.layer": "Abriu a GUI de seleção \"%2$s\" para %1$s jogadores.", - "enchantment.origins.water_protection.desc": "Atrasa o dano causado por hidrofobia.", - "origins.gui.badge.recipe.crafting.shaped": "Receita de criação (Com Forma) provida pelo poder:", - "origins.gui.badge.recipe.crafting.shapeless": "Receita de criação (Sem Forma) provida pelo poder:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/ro_ro.json b/origins/src/main/resources/assets/origins/lang/ro_ro.json deleted file mode 100644 index 7699fb406..000000000 --- a/origins/src/main/resources/assets/origins/lang/ro_ro.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Om", - "origin.origins.human.description": "Un om obișnuit. Experiența obișnuită de Minecraft vă așteaptă.", - "origin.origins.merling.name": "Merling", - "origin.origins.merling.description": "Acești locuitori naturali ai oceanului nu sunt obișnuiți să stea prea mult timp din apă.", - "origin.origins.arachnid.name": "Arachnid", - "origin.origins.arachnid.description": "Abilitățile lor de cățărat și abilitatea de a-și prinde dușmanii în pânză de păianjen îi fac pe Arachnid vânători perfecți.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "Descendenţii ai Blazeului, Blazeborn sunt în mod natural imuni la pericolele Netherului.", - "origin.origins.avian.name": "Avian", - "origin.origins.avian.description": "Rasa Avian și-a pierdut abilitatea de a zbura cu mult timp în urmă. Acum aceste creaturi pașnice pot fi văzute alunecând dintr-un loc în altul.", - "origin.origins.phantom.name": "Phantom", - "origin.origins.phantom.description": "Ca descendenți pe jumătate umani și pe jumătate fantomă, aceste creaturi pot comuta între o formă fantomă și o formă normală.", - "origin.origins.feline.name": "Feline", - "origin.origins.feline.description": "Cu aspectul lor asemănător unei pisici, felinii îi sperie pe Creeperi. Cu dexteritatea pisicilor, acestea aterizează întotdeauna în siguranță pe picioare.", - "origin.origins.elytrian.name": "Elytrian", - "origin.origins.elytrian.description": "De multe ori zboară în vânt, Elytriani sunt inconfortabili atunci când nu au suficient spațiu deasupra capului.", - "origin.origins.enderian.name": "Enderian", - "origin.origins.enderian.description": "Născuți ca fii și fiice ale Ender Dragonului, Enderianii sunt capabili să se teleporteze, dar sunt vulnerabili la apă.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "În legătură cu Shulkers, corpurile Shulk sunt echipate cu o piele de protecție asemănătoare coajei.", - "power.origins.water_breathing.name": "Branhii", - "power.origins.water_breathing.description": "Puteți respira sub apă, dar nu pe uscat.", - "power.origins.aqua_affinity.name": "Aqua Affinity", - "power.origins.aqua_affinity.description": "Puteți sparge blocuri sub apă, așa cum fac alții pe uscat.", - "power.origins.water_vision.name": "Ochii umezi", - "power.origins.water_vision.description": "Viziunea ta sub apă este perfectă.", - "power.origins.swim_speed.name": "Aripioare", - "power.origins.swim_speed.description": "Viteza ta subacvatică este crescută.", - "power.origins.like_water.name": "Ca apa", - "power.origins.like_water.description": "Când vă aflați sub apă, nu vă scufundați la pământ decât dacă doriți.", - "power.origins.fragile.name": "Fragil", - "power.origins.fragile.description": "Aveți 3 inimi mai puține decât oamenii.", - "power.origins.webbing.name": "Webbing", - "power.origins.webbing.description": "Când lovești un inamic în corp la corp, acesta se blochează în pânză de păianjen.", - "power.origins.climbing.name": "Alpinism", - "power.origins.climbing.description": "Ești capabil să urci pe orice fel de zid, nu doar pe scări.", - "power.origins.carnivore.name": "Carnivor", - "power.origins.carnivore.description": "Dieta ta este limitată la carne, nu poți mânca legume.", - "power.origins.fire_immunity.name": "Imunitatea la foc", - "power.origins.fire_immunity.description": "Sunteți imuni la toate tipurile de daune provocate de foc.", - "power.origins.nether_spawn.name": "Locuitor Nether", - "power.origins.nether_spawn.description": "Spawnul tău natural va fi în Nether.", - "power.origins.burning_wrath.name": "Mânie arzătoare", - "power.origins.burning_wrath.description": "Când sunteți în foc, provocați daune suplimentare cu atacurile.", - "power.origins.hotblooded.name": "înflăcărat", - "power.origins.hotblooded.description": "Datorită corpului tău fierbinte, veninurile se ard, făcându-te imun la otrăvire și la efectele stării de foame.", - "power.origins.water_vulnerability.name": "Hidrofobie", - "power.origins.water_vulnerability.description": "Veți primi daune cat sunteți în contact cu apa.", - "power.origins.tailwind.name": "Tailwind", - "power.origins.tailwind.description": "Ești puțin mai rapid pe jos decât alții.", - "power.origins.slow_falling.name": "Greutate de penă", - "power.origins.slow_falling.description": "Cazi la pământ la fel de blând ca o pană, dacă nu te strecori.", - "power.origins.vegetarian.name": "Vegetarian", - "power.origins.vegetarian.description": "Nu poți digera nicio carne.", - "power.origins.fresh_air.name": "Aer proaspat", - "power.origins.fresh_air.description": "Când dormiți, patul dvs. trebuie să fie la o altitudine de cel puțin 86 de blocuri, astfel încât să puteți respira aer curat.", - "power.origins.phasing.name": "Phasing", - "power.origins.phasing.description": "În timp ce sunteți fantomat, puteți merge prin material solid, cu excepția Obsidianului.", - "power.origins.invisibility.name": "Invizibilitate", - "power.origins.invisibility.description": "În timp ce sunteți fantomat, sunteți invizibil.", - "power.origins.hunger_over_time.name": "Metabolism rapid", - "power.origins.hunger_over_time.description": "A fi fantomat te face să îți fie foame.", - "power.origins.burn_in_daylight.name": "Photoallergic", - "power.origins.burn_in_daylight.description": "Începi să arzi în lumina zilei dacă nu ești invizibil.", - "power.origins.fall_immunity.name": "Acrobaţie", - "power.origins.fall_immunity.description": "Nu suferiți niciodată daune cauzate de cădere, indiferent de la ce înălțime cădeți.", - "power.origins.sprint_jump.name": "Glezne puternice", - "power.origins.sprint_jump.description": "Poți sări mai sus sărind în timp ce sprintezi.", - "power.origins.nine_lives.name": "Nouă vieți", - "power.origins.nine_lives.description": "Aveți 1 inimă mai puțin decât oamenii.", - "power.origins.cat_vision.name": "Nocturn", - "power.origins.cat_vision.description": "Puteți vedea ușor în întuneric atunci când nu vă aflați în apă.", - "power.origins.weak_arms.name": "Arme slabe", - "power.origins.weak_arms.description": "Când nu sunteți sub efectul unei poțiuni de rezistență, puteți mina piatra naturală numai dacă există cel mult alte 2 blocuri de piatră naturală adiacente acesteia.", - "power.origins.scare_creepers.name": "Aspect Catlike", - "power.origins.scare_creepers.description": "Creeperi sunt speriați de tine și vor exploda numai dacă îi vei ataca mai întâi.", - "power.origins.launch_into_air.name": "Darul Vânturilor", - "power.origins.launch_into_air.description": "La fiecare 30 de secunde, puteți sa va lansați în aer aproximativ 20 de blocuri.", - "power.origins.elytra.name": "Winged", - "power.origins.elytra.description": "Aveți aripi Elytra fără a fi nevoie să le echipați.", - "power.origins.light_armor.name": "Nevoia de mobilitate", - "power.origins.light_armor.description": "Nu puteți purta nicio armură grea (armură cu valori de protecție mai mari decât chainmail).", - "power.origins.claustrophobia.name": "Claustrofobie", - "power.origins.claustrophobia.description": "A fi undeva cu plafonul scăzut prea mult timp te va slăbi și te va face mai lent.", - "power.origins.more_kinetic_damage.name": "Oase fragile", - "power.origins.more_kinetic_damage.description": "Primiți mai multe daune din cădere și zborul în blocuri.", - "power.origins.aerial_combatant.name": "Combatent aerian", - "power.origins.aerial_combatant.description": "Provocați mult mai multe daune în timpul zborului Elytra.", - "power.origins.throw_ender_pearl.name": "Teleportarea", - "power.origins.throw_ender_pearl.description": "Ori de câte ori doriți, puteți arunca un ender pearl care nu provoacă daune, permițându-vă să vă teleportați.", - "power.origins.pumpkin_hate.name": "Speriat de Tărtăcuțe", - "power.origins.pumpkin_hate.description": "Ți-e frică de dovleci. Pentru un motiv întemeiat.", - "power.origins.extra_reach.name": "Corp subțire", - "power.origins.extra_reach.description": "Puteți ajunge la blocuri și entități mai departe.", - "power.origins.shulker_inventory.name": "Hoarder", - "power.origins.shulker_inventory.description": "Aveți acces la încă 9 spații de inventar, care păstrează obiectele la moarte.", - "power.origins.natural_armor.name": "Piele robustă", - "power.origins.natural_armor.description": "Chiar și fără a purta armuri, pielea ta oferă protecție naturală.", - "power.origins.more_exhaustion.name": "Apetit mare", - "power.origins.more_exhaustion.description": "Te epuizezi mult mai repede decât alții, necesitându-te astfel să mănânci mai mult.", - "power.origins.no_shield.name": "Unwieldy", - "power.origins.no_shield.description": "Modul în care sunt formate mâinile nu oferă nicio modalitate de a ține un scut în poziție verticală.", - "power.origins.strong_arms.name": "Brate puternice", - "power.origins.strong_arms.description": "Ești suficient de puternic pentru a sparge pietre naturale fără a folosi un târnăcop.", - "power.origins.translucent.name": "Translucid", - "power.origins.translucent.description": "Pielea ta este translucidă.", - "power.origins.end_spawn.name": "Locuitor End", - "power.origins.end_spawn.description": "Călătoria ta începe in The End.", - "power.origins.master_of_webs.name": "Master of Webs", - "power.origins.master_of_webs.description": "Navigați perfect pe pânză de păianjen și puteți urca în ele. Când lovești un inamic în corp la corp, aceștia rămân blocați în pânză de păianjen pentru o vreme. Non-artropodele înfipte în pânză de păianjen vor fi resimțite de tine. Ești capabil să creezi pânză de păianjen din șir.", - "power.origins.lay_eggs.name": "Ovipar", - "power.origins.lay_eggs.description": "Ori de câte ori te trezești dimineața, vei depune un ou.", - "category.origins": "Origini", - "key.origins.primary_active": "Puterea activă (primară)", - "key.origins.secondary_active": "Puterea activă (secundară)", - "key.origins.view_origin": "Vizualizați originea", - "text.autoconfig.origins.title": "Configurarea originilor", - "text.autoconfig.origins.option.xOffset": "Bara de reîncărcare Offset X", - "text.autoconfig.origins.option.yOffset": "Bara de reîncărcare Offset Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Puterea de suprapunere fantomată", - "item.origins.orb_of_origin": "Globul de origine", - "enchantment.origins.water_protection": "Protecția apei", - "container.shulker_inventory_power": "Inventarul Shulker", - "origins.gui.select": "Selectați", - "origins.gui.close": "Închide", - "origins.gui.choose": "Alege", - "origins.gui.choose_origin.title": "Alegeti %s.", - "origins.gui.view_origin.title": "Acesta este al tau %s.", - "origins.gui.view_origin.empty": "Nu puteți avea origini.", - "origins.gui.view_origin.not_installed": "Serverul nu are instalat modul Origins.", - "origins.gui.impact.impact": "Impact", - "origins.gui.impact.none": "Nimic", - "origins.gui.impact.low": "Mic", - "origins.gui.impact.medium": "Medium", - "origins.gui.impact.high": "Mare", - "origins.gui.version_mismatch": "Acest server rulează o versiune diferită de Origins (v%1$s) care este incompatibil cu cel pe care l-ați instalat (v%2$s).", - "origin.origins.random.name": "Random", - "origin.origins.random.description": "Vi se va atribui una dintre următoarele:", - "layer.origins.origin.name": "Origine", - "origin.origins.empty.name": "Absent", - "origin.origins.empty.description": "Nu aveți o origine.", - "death.attack.no_water_for_gills": "%1$s nu a reușit să se ude", - "death.attack.no_water_for_gills.player": "%1$s nu a reușit să se ude pentru că se luptau cu %2$s", - "death.attack.hurt_by_water": "%1$s a făcut o baie prea mult timp", - "death.attack.hurt_by_water.player": "%1$s a fost pus sub apă de %2$s", - "death.attack.genericDamageOverTime": "%1$s a murit în urma unui effect", - "death.attack.genericDamageOverTime.player": "%1$s a murit în urma unui effect în timp ce lupta %2$s", - "commands.origin.origin_not_found": "Origine necunoscută: %s", - "commands.origin.set.success.single": "Setați originea %s în stratul %s la %s.", - "commands.origin.set.success.multiple": "Setați originea țintelor %s din stratul %s la %s.", - "origins.avian_sleep_fail": "Ai nevoie de aer proaspăt pentru a dormi", - "power.origins.phantomize.name": "Phantom Form", - "power.origins.phantomize.description": "You can switch between human and phantom form at will, but only while you are saturated enough to sprint.", - "power.origins.like_air.name": "Like Air", - "power.origins.like_air.description": "Modifiers to your walking speed also apply while you're airborne.", - "power.origins.velvet_paws.name": "Velvet Paws", - "power.origins.velvet_paws.description": "Your footsteps don't cause any vibrations which could otherwise be picked up by nearby lifeforms.", - "component.item.origins.origin.layer": "Lets you choose a new %s.", - "component.item.origins.origin.layer_and_origin": "Sets your %1$s to \"%2$s\".", - "origins.gui.badge.active": "Active ability, use with %s.", - "origins.gui.badge.toggle": "Toggle with %s.", - "origins.gui.unbound_key": "§ounbound§r", - "commands.origin.get.result": "%s has the following %s: %s (%s)", - "commands.origin.gui.all": "Opened the selection GUI for %s players.", - "commands.origin.gui.layer": "Opened the \"%2$s\" selection GUI for %1$s players.", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/ru_ru.json b/origins/src/main/resources/assets/origins/lang/ru_ru.json deleted file mode 100644 index 11eafa794..000000000 --- a/origins/src/main/resources/assets/origins/lang/ru_ru.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Человек", - "origin.origins.human.description": "Обычный Человек. Ваша обычная игра в Майнкрафт ждет вас.", - "origin.origins.merling.name": "Мерлин", - "origin.origins.merling.description": "Эти естественные обитатели океана не привыкли слишком долго находиться на суше.", - "origin.origins.arachnid.name": "Арахнид", - "origin.origins.arachnid.description": "Их способности взбираться и ловить своих врагов в паутину делают Арахнидов идеальными охотниками.", - "origin.origins.blazeborn.name": "Огнерожденный", - "origin.origins.blazeborn.description": "Поздние потомки пламени, Огнерожденные, естественно, невосприимчивы к опасностям Нижнего Мира.", - "origin.origins.avian.name": "Авианы", - "origin.origins.avian.description": "Авианы уже давно потеряли способность летать. Теперь эти мирные существа могут быть замечены скользящими с одного места на другое.", - "origin.origins.phantom.name": "Фантом", - "origin.origins.phantom.description": "Будучи наполовину людьми и наполовину фантомами, эти существа могут переключаться между фантомом и нормальной формой.", - "origin.origins.feline.name": "Коточеловек", - "origin.origins.feline.description": "С их кошачьей внешностью, Котолюди отпугивают ползучих прочь. С кошачьей ловкостью они всегда благополучно приземляются на ноги.", - "origin.origins.elytrian.name": "Элитрианец", - "origin.origins.elytrian.description": "Часто летая по ветру, Элитрианцы чувствуют себя неуютно, когда им не хватает места над головой.", - "origin.origins.enderian.name": "Эндерианец", - "origin.origins.enderian.description": "Рожденные как сыновья и дочери Дракона Края, Эндерианцы способны к телепортации, но уязвимы для воды.", - "origin.origins.shulk.name": "Шалк", - "origin.origins.shulk.description": "Из-за родства с шалкерами, Шалки снабжены защитной оболочкой, похожий на панцирь.", - "power.origins.water_breathing.name": "Жабры", - "power.origins.water_breathing.description": "Ты можешь дышать под водой, но не на суше.", - "power.origins.aqua_affinity.name": "Родство с Водой", - "power.origins.aqua_affinity.description": "Ты можешь ломать блоки под водой так же быстро, как и на земле.", - "power.origins.water_vision.name": "Мокрые Глаза", - "power.origins.water_vision.description": "Твое зрение под водой идеально.", - "power.origins.swim_speed.name": "Ласты", - "power.origins.swim_speed.description": "Твоя подводная скорость увеличена.", - "power.origins.like_water.name": "Любовь к Воде", - "power.origins.like_water.description": "Находясь под водой, ты не опускаешься глубже, если не хочешь этого.", - "power.origins.fragile.name": "Хрупкость", - "power.origins.fragile.description": "У тебя на 3 сердца меньше здоровья, чем у людей.", - "power.origins.webbing.name": "Плетение", - "power.origins.webbing.description": "Когда ты поражаешь врага в ближнем бою, он застревает в паутине.", - "power.origins.climbing.name": "Карабканье", - "power.origins.climbing.description": "Ты можешь взобраться на любую стену, а не только по лестницам.", - "power.origins.carnivore.name": "Хищничество", - "power.origins.carnivore.description": "Твой рацион ограничен мясом, ты не можешь есть овощи.", - "power.origins.fire_immunity.name": "Иммунитет к Огню", - "power.origins.fire_immunity.description": "Ты невосприимчив ко всем видам повреждений от огня.", - "power.origins.nether_spawn.name": "Обитатель Нижнего Мира", - "power.origins.nether_spawn.description": "Твоя естественная точка появления будет в нижнем мире.", - "power.origins.burning_wrath.name": "Пылающий Гнев", - "power.origins.burning_wrath.description": "Когда ты в огне, ты наносишь дополнительный урон своими атаками.", - "power.origins.hotblooded.name": "Горячая Кровь", - "power.origins.hotblooded.description": "Из-за твоего горячего тела, яды сгорают, что делает тебя невосприимчивыми к воздействию яда и голода.", - "power.origins.water_vulnerability.name": "Гидрофобия", - "power.origins.water_vulnerability.description": "Ты получаешь повреждения с течением времени, находясь в контакте с водой.", - "power.origins.tailwind.name": "Попутный Ветер", - "power.origins.tailwind.description": "Ты немного быстрее идешь пешком, чем другие.", - "power.origins.slow_falling.name": "Легкий Вес", - "power.origins.slow_falling.description": "Ты падаешь на землю так же мягко, как перышко, если только не крадешься.", - "power.origins.vegetarian.name": "Вегетарианец", - "power.origins.vegetarian.description": "Ты не можешь есть мясо.", - "power.origins.fresh_air.name": "Свежий Воздух", - "power.origins.fresh_air.description": "Во время сна твоя кровать должна находиться на высоте не менее 86 блоков, чтобы ты мог дышать свежим воздухом.", - "power.origins.phasing.name": "Этапность", - "power.origins.phasing.description": "Будучи фантомизированным, ты можешь пройти сквозь твердый материал, за исключением обсидиана.", - "power.origins.invisibility.name": "Невидимость", - "power.origins.invisibility.description": "Во время фантомизации, ты невидим.", - "power.origins.hunger_over_time.name": "Быстрый Метаболизм", - "power.origins.hunger_over_time.description": "Во время фантомизации ты быстро голодаешь.", - "power.origins.burn_in_daylight.name": "Фотоаллергия", - "power.origins.burn_in_daylight.description": "Ты начинаешь гореть при дневном свете, если ты не невидим.", - "power.origins.fall_immunity.name": "Акробатика", - "power.origins.fall_immunity.description": "Ты никогда не получаешь урон от падения, независимо от того, с какой высоты ты падаешь.", - "power.origins.sprint_jump.name": "Сильные Лодыжки", - "power.origins.sprint_jump.description": "Ты можешь прыгать выше, подпрыгивая во время спринта.", - "power.origins.nine_lives.name": "У Кошки Девять Жизней", - "power.origins.nine_lives.description": "У тебя на 1 сердце меньше чем у людей.", - "power.origins.cat_vision.name": "Ноктурнал", - "power.origins.cat_vision.description": "Ты можешь немного видеть в темноте, когда не находишься в воде.", - "power.origins.weak_arms.name": "Слабые Руки", - "power.origins.weak_arms.description": "Когда ты не находишься под действием зелья силы, ты можешь добывать природный камень только в том случае, если рядом с ним есть не более 2 других природных каменных блоков.", - "power.origins.scare_creepers.name": "Кошачья Внешность", - "power.origins.scare_creepers.description": "Криперы боятся тебя и взорвутся только в том случае, если ты нападешь на них первыми.", - "power.origins.launch_into_air.name": "Дар Крыльев", - "power.origins.launch_into_air.description": "Каждые 30 секунд ты можешь подниматься на расстояние до 20 блоков в воздух.", - "power.origins.elytra.name": "Крылатый", - "power.origins.elytra.description": "У тебя есть крылья Элитр без необходимости их надевать.", - "power.origins.light_armor.name": "Нужда в Мобильности", - "power.origins.light_armor.description": "Ты не можешь носить тяжелую броню (броня с более высокими значениями защиты, чем кольчуга).", - "power.origins.claustrophobia.name": "Клаустрафобия", - "power.origins.claustrophobia.description": "Пребывание где-то с низким потолком слишком долго - ослабит тебя и сделает медленнее.", - "power.origins.more_kinetic_damage.name": "Хрустальные Кости", - "power.origins.more_kinetic_damage.description": "Ты получаешь больше урона от падения и/или полета в блоки.", - "power.origins.aerial_combatant.name": "Воздушный Боец", - "power.origins.aerial_combatant.description": "Ты наносишь значительно больше урона, находясь в полете на Элитрах.", - "power.origins.throw_ender_pearl.name": "Телепортация", - "power.origins.throw_ender_pearl.description": "Всякий раз, когда ты хочешь, ты можешь бросить жемчужину Эндера, которая не наносит никакого урона, позволяя тебе телепортироваться.", - "power.origins.pumpkin_hate.name": "Боязнь Тыкв", - "power.origins.pumpkin_hate.description": "Ты боишься тыкв. По понятной причине.", - "power.origins.extra_reach.name": "Длинное Тело", - "power.origins.extra_reach.description": "Вы можете дотянуться до далеко стоящих блоков и существ.", - "power.origins.shulker_inventory.name": "Хранитель", - "power.origins.shulker_inventory.description": "У вас есть доступ к дополнительным 9 ячейкам инвентаря, в которых хранятся предметы после смерти.", - "power.origins.natural_armor.name": "Прочная кожа", - "power.origins.natural_armor.description": "Даже без брони, ваша кожа обеспечивает естественную защиту.", - "power.origins.more_exhaustion.name": "Большой аппетит", - "power.origins.more_exhaustion.description": "Вы истощаетесь намного быстрее, чем другие, поэтому вам нужно есть больше.", - "power.origins.no_shield.name": "Громоздкий", - "power.origins.no_shield.description": "Из-за сложения рук, что присуще каждому Шалку, вы не можете держать щит вертикально.", - "power.origins.strong_arms.name": "Сильные руки", - "power.origins.strong_arms.description": "Вы достаточно сильны, чтобы разбивать природные камни без кирки.", - "power.origins.translucent.name": "Полупрозрачный", - "power.origins.translucent.description": "Ваша кожа полупрозрачная.", - "power.origins.end_spawn.name": "Житель Края", - "power.origins.end_spawn.description": "Твои приключения начинаются в Крае.", - "power.origins.master_of_webs.name": "Мастер паутин", - "power.origins.master_of_webs.description": "Ты отлично ориентируешься в паутине и умеешь по ней лазить. Когда ты бьёшь врага вблизи, он на время застревает в паутине. Ты можешь почувствовать, когда не членистоногие существа застревают в паутине. Ты можешь создавать паутину из нитки.", - "power.origins.lay_eggs.name": "Яйценосный", - "power.origins.lay_eggs.description": "Каждый раз, когда ты просыпаешся утром, ты откладываешь яйцо.", - "category.origins": "Origins", - "key.origins.primary_active": "Активная сила (Главная)", - "key.origins.secondary_active": "Активная сила (Второстепенная)", - "key.origins.view_origin": "Просмотр происхождения", - "text.autoconfig.origins.title": "Настройка Origins", - "text.autoconfig.origins.option.xOffset": "Позиция полосы восстановления по оси X", - "text.autoconfig.origins.option.yOffset": "Позиция полосы восстановления по оси Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Степень наложения фантомизации", - "item.origins.orb_of_origin": "Сфера происхождения", - "enchantment.origins.water_protection": "Защита от воды", - "container.shulker_inventory_power": "Шалкеровый инвентарь", - "origins.gui.select": "Выбрать", - "origins.gui.close": "Закрыть", - "origins.gui.choose": "Выберите", - "origins.gui.choose_origin.title": "Выберите ваше %s.", - "origins.gui.view_origin.title": "Это ваше %s.", - "origins.gui.view_origin.empty": "Вы не выбрали происхождение.", - "origins.gui.view_origin.not_installed": "На это сервере не установлен Origins.", - "origins.gui.impact.impact": "Влияние", - "origins.gui.impact.none": "Никакое", - "origins.gui.impact.low": "Низкое", - "origins.gui.impact.medium": "Среднее", - "origins.gui.impact.high": "Высокое", - "origins.gui.version_mismatch": "На это сервере установлена другая версия Origins (v%1$s), которая несовместима с той, что у вас (v%2$s).", - "origin.origins.random.name": "Случайный", - "origin.origins.random.description": "Вам будет назначен один из следующих:", - "layer.origins.origin.name": "Происхождение", - "origin.origins.empty.name": "Отсутствует", - "origin.origins.empty.description": "У вас нет происхождения.", - "death.attack.no_water_for_gills": "%1$s не успел погрузиться в воду.", - "death.attack.no_water_for_gills.player": "%1$s не успел погрузиться в воду из-за боя с %2$s.", - "death.attack.hurt_by_water": "%1$s принимал ванну слишком долго.", - "death.attack.hurt_by_water.player": "%1$s был утоплен под воду %2$s.", - "death.attack.genericDamageOverTime": "%1$s умер от временного эффекта урона.", - "death.attack.genericDamageOverTime.player": "%1$s умер от временного эффекта урона во время боя с %2$s.", - "commands.origin.origin_not_found": "Неизвестное происхождение: %s", - "commands.origin.set.success.single": "Выбрать происхождение %s в слое %s к %s.", - "commands.origin.set.success.multiple": "Выбрать происхождение %s целям в слое %s к %s.", - "origins.avian_sleep_fail": "Тебе нужен свежий воздух для сна.", - "power.origins.phantomize.name": "Призрачная форма", - "power.origins.phantomize.description": "Вы можете переключаться между человеческой и формой фантома по желанию, но только пока вы достаточно сыты.", - "power.origins.like_air.name": "Как Воздух", - "power.origins.like_air.description": "Изменение скорости вашей ходьбы также применяются, когда вы находитесь в воздухе.", - "power.origins.velvet_paws.name": "Бархатные Лапки", - "power.origins.velvet_paws.description": "Ваши шаги не вызывают никаких звуков, которые в противном случае могли бы быть услышаны близлежащими формами жизни.", - "component.item.origins.origin.layer": "Позволяет вам выбрать новый %s.", - "component.item.origins.origin.layer_and_origin": "Устанавливает для вашего % 1$s значение \"%2$s\".", - "origins.gui.badge.active": "Активная способность, использование с %s.", - "origins.gui.badge.toggle": "Переключаться с помощью %s.", - "origins.gui.unbound_key": "§§несвязанный§r", - "commands.origin.get.result": "%s имеет следующие %s: %s (%s)", - "commands.origin.gui.all": "Открыл графический интерфейс выбора для игроков %s.", - "commands.origin.gui.layer": "Открыл графический интерфейс выбора \"%2$s\" для игроков % 1$s.", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "origins.gui.badge.recipe.crafting.shaped": "Crafting recipe (Shaped) provided by the power:", - "origins.gui.badge.recipe.crafting.shapeless": "Crafting recipe (Shapeless) provided by the power:", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/lang/tr_tr.json b/origins/src/main/resources/assets/origins/lang/tr_tr.json deleted file mode 100644 index 429e1f0e6..000000000 --- a/origins/src/main/resources/assets/origins/lang/tr_tr.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "İnsan", - "origin.origins.human.description": "Sıradan bir insan. Sıradan Minecraft deneyimin seni bekliyor.", - "origin.origins.merling.name": "Merling", - "origin.origins.merling.description": "Okyanusun bu doğal yerlileri uzun süre sudan çıkmaya alışkın değiller.", - "origin.origins.arachnid.name": "Araknid", - "origin.origins.arachnid.description": "Tırmanma yetenekleri ve düşmanlarını örümcek ağına hapsedebilme yetenekleri, Araknid'i mükemmel avcılar yapar.", - "origin.origins.blazeborn.name": "Blazeborn", - "origin.origins.blazeborn.description": "Blaze'in son torunları olan Blazeborn, doğal olarak Nether'ın tehlikelerine karşı bağışıklığı vardır.", - "origin.origins.avian.name": "Aviyan", - "origin.origins.avian.description": "Aviyan ırkı uçma yeteneğini uzun zaman önce kaybetti. Şimdi bu barışçıl yaratıklar bir yerden diğerine süzülürken görülebilir.", - "origin.origins.phantom.name": "Fantom", - "origin.origins.phantom.description": "Yarı-insan ve yarı-fantom varlıklar olarak, bu yaratıklar fantom formu ve normal bir form arasında geçiş yapabilirler.", - "origin.origins.feline.name": "Kedigil", - "origin.origins.feline.description": "Kedi benzeri görünümleriyle Kedigil, creeperları korkutur. Kedilerin becerisiyle her zaman güvenle dört ayaklarının üzerine inerler", - "origin.origins.elytrian.name": "Elitriyan", - "origin.origins.elytrian.description": "Genellikle rüzgarla birlikte etrafta uçan Elitriyanlar başlarının üzerinde yeterince alan olmadığında rahatsız olurlar.", - "origin.origins.enderian.name": "Enderiyan", - "origin.origins.enderian.description": "Ender Ejderhasının çocukları olarak doğan Enderiyanlar ışınlanma yeteneğine sahipler ancak suya karşı hassaslar.", - "origin.origins.shulk.name": "Shulk", - "origin.origins.shulk.description": "Shulkerlarla kan bağları olan Shulk'ın vücutları koruyucu kabuk benzeri bir deri ile donatılmıştır.", - "power.origins.water_breathing.name": "Solungaçlar", - "power.origins.water_breathing.description": "Suyun altında nefes alabilirsin ama karada alamazsın.", - "power.origins.aqua_affinity.name": "Su Adaptasyonu", - "power.origins.aqua_affinity.description": "Diğerlerinin karada yaptığı gibi su altında blokları kırabilirsiniz.", - "power.origins.water_vision.name": "Islak Gözler", - "power.origins.water_vision.description": "Su altı görüşün mükemmel.", - "power.origins.swim_speed.name": "Yüzgeçler", - "power.origins.swim_speed.description": "Su altında daha hızlısın.", - "power.origins.like_water.name": "Su Gibi", - "power.origins.like_water.description": "Suyun altındayken istemediğiniz sürece dibe batmazsınız.", - "power.origins.fragile.name": "Narin", - "power.origins.fragile.description": "İnsanlardan 3 kalp daha az canınız var.", - "power.origins.webbing.name": "Ağlama", - "power.origins.webbing.description": "Yakın dövüşte bir düşmana vurduğunuzda, örümcek ağına takılırlar.", - "power.origins.climbing.name": "Tırmanma", - "power.origins.climbing.description": "Sadece merdivenlere değil, her türlü yere tırmanabilirsiniz.", - "power.origins.carnivore.name": "Etobur", - "power.origins.carnivore.description": "Diyetiniz etle sınırlıdır, sebze yiyemezsiniz.", - "power.origins.fire_immunity.name": "Ateş Bağışıklığı", - "power.origins.fire_immunity.description": "Her türlü ateş hasarına karşı bağışıksınız.", - "power.origins.nether_spawn.name": "Nether Yerlisi", - "power.origins.nether_spawn.description": "Doğal doğma noktanız Nether'dadır.", - "power.origins.burning_wrath.name": "Yanan Gazap", - "power.origins.burning_wrath.description": "Yanarken saldırılarınızla ek hasar verirsiniz.", - "power.origins.hotblooded.name": "Sıcakkanlı", - "power.origins.hotblooded.description": "Sıcak vücudunuz nedeniyle zehirler yanar, bu sizi zehirin ve açlığın etkilerine karşı sizi bağışık hale getirir.", - "power.origins.water_vulnerability.name": "Hidrofobi", - "power.origins.water_vulnerability.description": "Su ile temas halindeyken zamanla hasar alırsınız.", - "power.origins.tailwind.name": "Kuyruk Rüzgarı", - "power.origins.tailwind.description": "Diğerlerinden biraz daha hızlısın.", - "power.origins.slow_falling.name": "Tüy Gibi Hafif", - "power.origins.slow_falling.description": "Eğilmediğiniz sürece yere bir tüy kadar nazikçe düşersiniz.", - "power.origins.vegetarian.name": "Vejetaryen", - "power.origins.vegetarian.description": "Et yiyemezsin.", - "power.origins.fresh_air.name": "Temiz Hava", - "power.origins.fresh_air.description": "Yatarken temiz hava alabilmeniz için yatağınız rakımını en az 86 blok yüksekliğinde olması gerekir.", - "power.origins.phasing.name": "İçinden Geçme", - "power.origins.phasing.description": "Fantom formundayken Obsidiyen hariç katı maddelerin içinden geçebilirsiniz.", - "power.origins.invisibility.name": "Görünmezlik", - "power.origins.invisibility.description": "Fantom formundayken görünmezsiniz.", - "power.origins.hunger_over_time.name": "Hızlı Metabolizma", - "power.origins.hunger_over_time.description": "Fantom formunda olmak acıkmanıza sebep olur.", - "power.origins.burn_in_daylight.name": "Fotoalerjik", - "power.origins.burn_in_daylight.description": "Görünmez değilken gün ışığında yanmaya başlarsınız.", - "power.origins.fall_immunity.name": "Akrobasi", - "power.origins.fall_immunity.description": "Hangi yükseklikten düşerseniz düşün, asla düşme hasarı almazsınız.", - "power.origins.sprint_jump.name": "Güçlü Ayak Bilekleri", - "power.origins.sprint_jump.description": "Koşarken daha yükseğe zıplayabilirsiniz.", - "power.origins.nine_lives.name": "Dokuz Canlı", - "power.origins.nine_lives.description": "İnsanlardan 1 kalp daha az canınız var.", - "power.origins.cat_vision.name": "Noktürnal", - "power.origins.cat_vision.description": "Suyun altında değilken karanlıkta daha iyi görürsünüz.", - "power.origins.weak_arms.name": "Cılız Kollar", - "power.origins.weak_arms.description": "Bir güç iksirinin etkisi altında olmadığın sürece, yanında ikiden fazla doğal taş olan doğal taşları kıramazsınız.", - "power.origins.scare_creepers.name": "Kedi-Gibi Görünüm", - "power.origins.scare_creepers.description": "Creeperlar senden korkar ve sadece onlara ilk sen saldırırsan patlarlar.", - "power.origins.launch_into_air.name": "Rüzgarların Hediyesi", - "power.origins.launch_into_air.description": "Her 30 saniyede bir kendinizi yaklaşık havada 20 blok yükseğe fırlatabilirsiniz.", - "power.origins.elytra.name": "Kanatlı", - "power.origins.elytra.description": "Hiç giymenize gerek kalmadan Elitra kanatlarınız var.", - "power.origins.light_armor.name": "Hareketlilik İhtiyacı", - "power.origins.light_armor.description": "Herhangi bir ağır zırh (zincirden daha yüksek koruma değerlerine sahip zırh) giyemezsiniz.", - "power.origins.claustrophobia.name": "Klostrofobi", - "power.origins.claustrophobia.description": "Çok uzun süre alçak tavanlı bir yerde olmak sizi zayıflatır ve yavaşlatır.", - "power.origins.more_kinetic_damage.name": "Kırılgan Kemikler", - "power.origins.more_kinetic_damage.description": "Düşmekten ve bloklara uçarken çarpmaktan daha fazla hasar alırsınız.", - "power.origins.aerial_combatant.name": "Hava Savaşçısı", - "power.origins.aerial_combatant.description": "Elitra ile süzülürken önemli ölçüde daha fazla hasar verirsiniz.", - "power.origins.throw_ender_pearl.name": "Işınlanma", - "power.origins.throw_ender_pearl.description": "İstediğiniz zaman, hiçbir hasar vermeyen ve ışınlanmanıza izin veren bir ender incisi fırlatabilirsiniz.", - "power.origins.pumpkin_hate.name": "Bal Kabağı Korkusu", - "power.origins.pumpkin_hate.description": "Bal kabaklarından korkuyorsun. İyi bir sebebi var.", - "power.origins.extra_reach.name": "Uzun Vücut", - "power.origins.extra_reach.description": "Daha uzaktaki bloklara ve varlıklara erişebilirsiniz.", - "power.origins.shulker_inventory.name": "İstifçi", - "power.origins.shulker_inventory.description": "İçindeki eşyaları öldüğünüzde bile düşürmeyen fazladan 9 envanter yuvasına erişiminiz var.", - "power.origins.natural_armor.name": "Sağlam Cilt", - "power.origins.natural_armor.description": "Zırh giymeden bile cildiniz doğal koruma sağlar.", - "power.origins.more_exhaustion.name": "Büyük İştah", - "power.origins.more_exhaustion.description": "Diğerlerinden çok daha çabuk yorulursunuz, bu yüzden daha fazla yemenizi gerektirir.", - "power.origins.no_shield.name": "Kullanışsız", - "power.origins.no_shield.description": "Ellerinizin şeklinden dolayı kalkanları doğru düzgün tutamıyorsunuz.", - "power.origins.strong_arms.name": "Güçlü Kollar", - "power.origins.strong_arms.description": "Kazma kullanmadan doğal taşları kıracak kadar güçlüsünüz.", - "power.origins.translucent.name": "Yarı Saydam", - "power.origins.translucent.description": "Vücudunuz yarı saydamdır.", - "power.origins.end_spawn.name": "End Yerlisi", - "power.origins.end_spawn.description": "Yolculuğun End'de başlar.", - "power.origins.master_of_webs.name": "Ağların Ustası", - "power.origins.master_of_webs.description": "Ağların içinde hiç sorun olmadan hareket edebilir ve onlara tırmanabilirsiniz. Yakın dövüşte bir düşmana vurduğunuzda belli bir süreliğine ağda sıkışırlar. Ağda sıkışmış eklem bacaklı olmayan varlıkları sezebilirsiniz. İpten ağ üretebilirsin.", - "power.origins.lay_eggs.name": "Yumurtlayan", - "power.origins.lay_eggs.description": "Sabah uyandığında yumurtlarsın.", - "power.origins.phantomize.name": "Fantom Formu", - "power.origins.phantomize.description": "İstediğiniz zaman insan ve fantom formu arasında geçiş yapabilirsiniz, ama sadece tokluğunuz koşmanıza yetebiliyorken.", - "power.origins.like_air.name": "Hava Gibi", - "power.origins.like_air.description": "Yürüme hızınıza etki eden değişiklikler ayrıca siz havadayken de etki eder.", - "power.origins.velvet_paws.name": "Kadife Patiler", - "power.origins.velvet_paws.description": "Adımlarınız yakınınızdaki diğer yaşam formları tarafından algılanacak titreşimler oluşturmaz.", - "category.origins": "Kökenler", - "key.origins.primary_active": "Aktif Güç (Birincil)", - "key.origins.secondary_active": "Aktif Güç (İkincil)", - "key.origins.view_origin": "Kökenini Gör", - "text.autoconfig.origins.title": "Origins Konfigürasyon", - "text.autoconfig.origins.option.xOffset": "Bekleme Göstergesinin X doğrultusundaki yeri", - "text.autoconfig.origins.option.yOffset": "Bekleme Göstergesinin Y doğrultusundaki yeri", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Fantom Formu Arayüz Görünürlüğü", - "item.origins.orb_of_origin": "Köken Küresi", - "component.item.origins.origin.layer": "Yeni bir %s şeçmenizi sağlar.", - "component.item.origins.origin.layer_and_origin": "%1$s'nızı \"%2$s\"ye ayarlar.", - "enchantment.origins.water_protection": "Su Koruması", - "enchantment.origins.water_protection.desc": "Hidrofobi hasarını geciktirir.", - "container.shulker_inventory_power": "Shulker Envateri", - "origins.gui.select": "Seç", - "origins.gui.close": "Kapat", - "origins.gui.choose": "Seç", - "origins.gui.choose_origin.title": "Kendi %s'ini seç.", - "origins.gui.view_origin.title": "Bu senin %s'in.", - "origins.gui.view_origin.empty": "Herhangi bir Kökene sahip olamazsınız.", - "origins.gui.view_origin.not_installed": "Bu serverda Origins modu yok.", - "origins.gui.impact.impact": "Etki", - "origins.gui.impact.none": "Hiç", - "origins.gui.impact.low": "Düşük", - "origins.gui.impact.medium": "Orta", - "origins.gui.impact.high": "Yüksek", - "origins.gui.version_mismatch": "Bu server başka bir Origins sürümü kullanıyor (v%1$s). Bu sürüm senin yüklediğin sürümle (v%2$s) uyumlu değil.", - "origins.gui.badge.active": "Aktif özellik, %s ile kullan.", - "origins.gui.badge.toggle": "Özelliği %s ile aç kapa.", - "origins.gui.badge.recipe.crafting.shaped": "Tarif (şekilli):", - "origins.gui.badge.recipe.crafting.shapeless": "Tarif (şekilsiz):", - "origins.gui.unbound_key": "§oatanmamış§r", - "origin.origins.random.name": "Rastgele", - "origin.origins.random.description": "Aşağıdakilerden biri olacaksınız:", - "layer.origins.origin.name": "Köken", - "origin.origins.empty.name": "Eksik", - "origin.origins.empty.description": "Bir Kökenin yok.", - "death.attack.no_water_for_gills": "%1$s ıslak kalmayı başaramadı", - "death.attack.no_water_for_gills.player": "%1$s ıslak kalmayı başaramadı çünkü %2$s ile savaşıyordu.", - "death.attack.hurt_by_water": "%1$s çok uzun süre duş aldı", - "death.attack.hurt_by_water.player": "%1$s %2$s tarafından suya atıldı", - "death.attack.genericDamageOverTime": "%1$s zamanla hasar almadan ötürü öldü", - "death.attack.genericDamageOverTime.player": "%1$s %2$s ile savaşırken zamanla hasar almadan ötürü öldü", - "commands.origin.origin_not_found": "Bilinmeyen Köken: %s", - "commands.origin.layer_not_found": "Bilinmeyen katman: %s", - "commands.origin.unregistered_in_layer": "Köken %1$s, %2$s katmanında kayıtlı değil!", - "commands.origin.get.result": "%s şuna sahip %s: %s (%s)", - "commands.origin.gui.all": "%s oyuncu için şeçim GUI'si açıldı", - "commands.origin.gui.layer": "%1$s oyuncu için \"%2$s\" şeçim GUI'si açıldı", - "commands.origin.random.all": "%1$s hedef için %2$s katmandan rastgele bir köken atandı", - "commands.origin.random.not_allowed": "%1$s katmanı rastgele kökenlere izin vermiyor!", - "commands.origin.random.success.multiple": "%1$s hedef için %2$s katmanından rastgele bir köken atandı", - "commands.origin.random.success.single": "%3$s katmanından %2$s kökeni rastgele bir şekilde %1$s oyuncusuna atandı", - "commands.origin.set.success.multiple": "%s hedefin kökeni %s katmanından %s olarak ayarlandı", - "commands.origin.set.success.single": "%s oyuncusunun kökeni %s katmanından %s olarak ayarlandı", - "origins.avian_sleep_fail": "Uyumak için temiz havaya ihtiyacın var" -} diff --git a/origins/src/main/resources/assets/origins/lang/uk_ua.json b/origins/src/main/resources/assets/origins/lang/uk_ua.json deleted file mode 100644 index 1a360eb07..000000000 --- a/origins/src/main/resources/assets/origins/lang/uk_ua.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "Людина", - "origin.origins.human.description": "Звичайна людина. Вас очікує звичайне проходження Minecraft.", - "origin.origins.merling.name": "Водяник", - "origin.origins.merling.description": "Ці природні мешканці океану не звикли довго перебувати поза водою.", - "origin.origins.arachnid.name": "Павукоподібний", - "origin.origins.arachnid.description": "Їх здібності лазати та ловити ворогів в павутину робить Павукоподібних найкращими мисливцями.", - "origin.origins.blazeborn.name": "Полум'яник", - "origin.origins.blazeborn.description": "Останні нащадки Пломенів, Полум'яники, мають вроджений імунітет до небезпек Незеру.", - "origin.origins.avian.name": "Птахоподібний", - "origin.origins.avian.description": "Птахоподібні втратили можливість до польоту дуже давно. Зараз цих мирних створінь можна побачити паруючими з одного місця на інше.", - "origin.origins.phantom.name": "Фантом", - "origin.origins.phantom.description": "Будучи наполовину людиною, на половину фантомом, ці створіння можуть перемикатись між Фантомною та нормальною формою.", - "origin.origins.feline.name": "Кішкоподібний", - "origin.origins.feline.description": "З їх виглядом, схожим на котів, Кішкоподібні відлякують кріперів. Зі спритністю котів, вони завжди приземляються на лапи.", - "origin.origins.elytrian.name": "Елітрієць", - "origin.origins.elytrian.description": "Часто літаючи в поривах вітру, Елітрійці відчувають себе некомфортно коли їм не достатньо місця над головою.", - "origin.origins.enderian.name": "Ендерієць", - "origin.origins.enderian.description": "Народжені як діти Ендер Дракона, Ендерійці здатдні до телепортації але вразливі до води.", - "origin.origins.shulk.name": "Шалк", - "origin.origins.shulk.description": "Будучи пов'язаними до Шалкерів, тіло Шалків вкрито захисною панциро-подібною шкірою.", - "power.origins.water_breathing.name": "Зябри", - "power.origins.water_breathing.description": "Ви можете дихати під водою, але не на суші.", - "power.origins.aqua_affinity.name": "Рідність води", - "power.origins.aqua_affinity.description": "Ви можете ламати блоки під водою, так само як і на суші.", - "power.origins.water_vision.name": "Мокрі очі", - "power.origins.water_vision.description": "Ваш зір під водою став краще.", - "power.origins.swim_speed.name": "Плавці", - "power.origins.swim_speed.description": "Ваша швидкість під водою підвищена.", - "power.origins.like_water.name": "Наче вода", - "power.origins.like_water.description": "Коли під водою, ви не тонете на дно, доки не захочете.", - "power.origins.fragile.name": "Крихкий", - "power.origins.fragile.description": "У вас на 3 сердечка менше, ніж у звичайних людей.", - "power.origins.webbing.name": "Павутиномет", - "power.origins.webbing.description": "Коли ви б'єте ворога в ближньому бою, вони застрягають в павутині.", - "power.origins.climbing.name": "Лазання", - "power.origins.climbing.description": "Ви спроможні лазати по любому виду стін, не тільки по драбині.", - "power.origins.carnivore.name": "Хижак", - "power.origins.carnivore.description": "Ваша дієта обмежена м'ясом, ви не можете їсти овочі.", - "power.origins.fire_immunity.name": "Імунітет до вогню", - "power.origins.fire_immunity.description": "У вас є імунітет до любої шкоди від вогню.", - "power.origins.nether_spawn.name": "Мешканець Незеру", - "power.origins.nether_spawn.description": "Ваша точка відродження по замовчування знаходиться в Незері.", - "power.origins.burning_wrath.name": "Палаючий гнів", - "power.origins.burning_wrath.description": "Коли ви горите, ви наносите додаткову шкоду вашими атаками.", - "power.origins.hotblooded.name": "Теплокровний", - "power.origins.hotblooded.description": "Завдяки вашому гарячому тілу, отрути згорають, роблячи вас захищеними від ефектів отрути та голоду.", - "power.origins.water_vulnerability.name": "Гідрофобія", - "power.origins.water_vulnerability.description": "Ви отримуєте шкоду при любому контакті з водою.", - "power.origins.tailwind.name": "Попутний вітер", - "power.origins.tailwind.description": "Ви трохи швидші пішки ніж ішні.", - "power.origins.slow_falling.name": "Наче пір'їнка", - "power.origins.slow_falling.description": "Ви падаєте на землю так само обережно, як пір'їнка, тільки якщо ви не спішитеся.", - "power.origins.vegetarian.name": "Вегетаріанець", - "power.origins.vegetarian.description": "Ви не здатні їсти м'ясо.", - "power.origins.fresh_air.name": "Свіже повітря", - "power.origins.fresh_air.description": "Коли ви намагаєтесь поспати, ваше ліжко має бути щонайменше на 86 висоті, щоб ви могли дихати свіжим повітрям.", - "power.origins.phasing.name": "Фантомізація", - "power.origins.phasing.description": "Коли у формі фантома, ви можете проходити крізь блоки, окрім Обсидіана.", - "power.origins.invisibility.name": "Невидимість", - "power.origins.invisibility.description": "Коли у формі фантома, ви невидимі.", - "power.origins.hunger_over_time.name": "Швидкий метаболізм", - "power.origins.hunger_over_time.description": "Форма фантома змушує вас втрачати більше голоду.", - "power.origins.burn_in_daylight.name": "Чутливість до сонця", - "power.origins.burn_in_daylight.description": "Ви починаєте горіти на сонячному світлі, якщо ви не невидимі.", - "power.origins.fall_immunity.name": "Акробат", - "power.origins.fall_immunity.description": "Ви ніколи не отримуєте шкоди від падіння, не зважаючи на висоту з якої ви впали.", - "power.origins.sprint_jump.name": "Сильні ноги", - "power.origins.sprint_jump.description": "Ви можете стрибати вище якщо ви біжите.", - "power.origins.nine_lives.name": "Дев'ять життів", - "power.origins.nine_lives.description": "У вас на 1 сердечко менше ніж у звичайних людей.", - "power.origins.cat_vision.name": "Нічний спосіб життя", - "power.origins.cat_vision.description": "Ви можете бачити у темряві, коли не у воді.", - "power.origins.weak_arms.name": "Слабкі руки", - "power.origins.weak_arms.description": "Коли ви не перебуваєте під дією зілля сили, ви можете добувати камінь, лише якщо поруч з ним менше 2 інших блоків каменю.", - "power.origins.scare_creepers.name": "Котяча зовнішність", - "power.origins.scare_creepers.description": "Кріпери лякаються вас і будуть вибухати тільки якщо ви вдарите їх першими.", - "power.origins.launch_into_air.name": "Дарунок вітрів", - "power.origins.launch_into_air.description": "Кожні 30 секунд, ви здатні запустити себе у повітря на 20 блоків в висоту.", - "power.origins.elytra.name": "Окриляє!", - "power.origins.elytra.description": "У вас є Елітри без потреби їх одягання.", - "power.origins.light_armor.name": "Потреба у мобільності", - "power.origins.light_armor.description": "Ви не можете одягати тяжку броню (броня з рівнем захисту, вища за кольчужну).", - "power.origins.claustrophobia.name": "Клаустрафобія", - "power.origins.claustrophobia.description": "Перебування у місці з низькою стелею занадто довго послабить та заповільнить вас.", - "power.origins.more_kinetic_damage.name": "Крихкі кістки", - "power.origins.more_kinetic_damage.description": "Ви отримуєте більшу шкоду від падіння та від влітання у блоки.", - "power.origins.aerial_combatant.name": "Повітряні сили", - "power.origins.aerial_combatant.description": "Ви завдаєте суттєво більше шкоди при польоті на Елітрах.", - "power.origins.throw_ender_pearl.name": "Телепортація", - "power.origins.throw_ender_pearl.description": "Коли б ви не хотіли, ви можете жбурнути Перлину Енду, яка не завдає шкоди, дозволяючи вам телепортуватись.", - "power.origins.pumpkin_hate.name": "Гарбузофобія", - "power.origins.pumpkin_hate.description": "Ви боїтесь гарбузів. З поважних причин.", - "power.origins.extra_reach.name": "Довге тіло", - "power.origins.extra_reach.description": "Ви можете дістати до блоків та створінь набагато далі ніж інші.", - "power.origins.shulker_inventory.name": "Велика кишеня", - "power.origins.shulker_inventory.description": "У вас є доступ до 9 додаткових слотів в інвентарі, які зберігають предмети навіть після смерті.", - "power.origins.natural_armor.name": "Міцна шкіра", - "power.origins.natural_armor.description": "Навіть без броні, ваша шкіра забезпечує вам захист.", - "power.origins.more_exhaustion.name": "Ненажера", - "power.origins.more_exhaustion.description": "Ви виснагаєте набагато швидше ніж інші, це заставляє вас їсти більше.", - "power.origins.no_shield.name": "Громіздкий", - "power.origins.no_shield.description": "Форма ваших рук не дає вам можливості тримати щит для оборони.", - "power.origins.strong_arms.name": "Сильні руки", - "power.origins.strong_arms.description": "Ви достатньо сильні щоб ламати камінь без потреби використовувати кайло.", - "power.origins.translucent.name": "Напівпрозорий", - "power.origins.translucent.description": "Ваша шкіра напівпрозора.", - "power.origins.end_spawn.name": "Мешканець Енду", - "power.origins.end_spawn.description": "Ваша подорож починається у Енді.", - "power.origins.master_of_webs.name": "Майстер павутиння", - "power.origins.master_of_webs.description": "Ви відмінно орієнтуєтеся в павутині і вмієте в них лазити. Коли ви вдаряєте ворога в ближньому бою, він на деякий час застряє в павутині. Ви відчуваєте всіх не членистоногих істот, які застрягли в павутині. З ниток ви можете виготовити павутину.", - "power.origins.lay_eggs.name": "Яйце-Райце", - "power.origins.lay_eggs.description": "Кожен раз як ви прокидаєтесь у ліжку, ви відкладаєте яйце.", - "power.origins.phantomize.name": "Форма фантома", - "power.origins.phantomize.description": "Ви можете перемикатися між людською та фантомною формою за бажанням, але лише тоді, коли ви достатньо насичені, щоб бігти.", - "power.origins.like_air.name": "Наче повітря", - "power.origins.like_air.description": "Модифікатори вашої швидкості ходьби також застосовуються під час перебування в повітрі.", - "power.origins.velvet_paws.name": "Оксамитові лапки", - "power.origins.velvet_paws.description": "Ваші кроки не викликають вібрацій, які інші істоти могли б відчути.", - "category.origins": "Origins", - "key.origins.primary_active": "Активувати здібність (Перша)", - "key.origins.secondary_active": "Активувати здібність (Друга)", - "key.origins.view_origin": "Переглянути походження", - "text.autoconfig.origins.title": "Конфігурація Origins", - "text.autoconfig.origins.option.xOffset": "Зміщеняя Панелі Перезарядки По Осі X", - "text.autoconfig.origins.option.yOffset": "Зміщеняя Панелі Перезарядки По Осі Y", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "Сила Оверлею Фантомної форми", - "item.origins.orb_of_origin": "Сфера походження", - "component.item.origins.origin.layer": "Дозволяє вам обрати нове %s.", - "component.item.origins.origin.layer_and_origin": "Встановить вашу %1$s на \"%2$s\".", - "enchantment.origins.water_protection": "Водяний захист", - "enchantment.origins.water_protection.desc": "Знижує шкоду від гідрофобії.", - "container.shulker_inventory_power": "Кишеня Шалкера", - "origins.gui.select": "Вибрати", - "origins.gui.close": "Закрити", - "origins.gui.choose": "Обрати", - "origins.gui.choose_origin.title": "Оберіть ваше %s.", - "origins.gui.view_origin.title": "Це ваше %s.", - "origins.gui.view_origin.empty": "Ви не можете мати жодного Походження.", - "origins.gui.view_origin.not_installed": "На сервері не встановлено мод Origins.", - "origins.gui.impact.impact": "Внесок", - "origins.gui.impact.none": "Ніякий", - "origins.gui.impact.low": "Низький", - "origins.gui.impact.medium": "Середній", - "origins.gui.impact.high": "Високий", - "origins.gui.version_mismatch": "Цей сервер запущено на іншій версії мода Origins (v%1$s) яка не сумісна з вашою версією моду (v%2$s).", - "origins.gui.badge.active": "Активувати здібність, натисніть %s.", - "origins.gui.badge.toggle": "Увімкнути на %s.", - "origins.gui.badge.recipe.crafting.shaped": "Рецепт майстрування (сформований):", - "origins.gui.badge.recipe.crafting.shapeless": "Рецепт майстрування (безформний):", - "origins.gui.unbound_key": "§oвідв'язати§r", - "origin.origins.random.name": "Випадково", - "origin.origins.random.description": "Вам буде випадково призначено одне з:", - "layer.origins.origin.name": "Походження", - "origin.origins.empty.name": "Відсутнє", - "origin.origins.empty.description": "У вас немає Походження.", - "death.attack.no_water_for_gills": "%1$s не зміг забезпечити себе водою", - "death.attack.no_water_for_gills.player": "%1$s не зміг забезпечити себе водою через %2$s", - "death.attack.hurt_by_water": "%1$s занадто довго приймав ванну", - "death.attack.hurt_by_water.player": "%1$s був затягнут під воду %2$s", - "death.attack.genericDamageOverTime": "%1$s помер від тимчасового ефекту шкоди", - "death.attack.genericDamageOverTime.player": "%1$s помер від тимчасового ефекту шкоди під час бою з %2$s", - "commands.origin.origin_not_found": "Невідоме походження: %s", - "commands.origin.layer_not_found": "Невідомий шар: %s", - "commands.origin.unregistered_in_layer": "Походження %1$s не зареєстроване в шарі %2$s!", - "commands.origin.get.result": "%s має наступне %s: %s (%s)", - "commands.origin.gui.all": "Відкрито інтерфейс вибору для %s гравців", - "commands.origin.gui.layer": "Відкрито інтерфейс вибору \"%2$s\" для %1$s гравців", - "commands.origin.random.all": "Випадково назначено походження для %1$s цілей в %2$s шарах", - "commands.origin.random.not_allowed": "Шар %1$s не дозволений для випадкових походжень!", - "commands.origin.random.success.multiple": "Випадково назначено походження для %1$s цілей в шарі %2$s", - "commands.origin.random.success.single": "Випадково назначено походження %2$s для %1$s в шарі %3$s", - "commands.origin.set.success.multiple": "Встановлено походження %s цілей в шарі %s на %s", - "commands.origin.set.success.single": "Встановлено походження %s в шарі %s на %s.", - "origins.avian_sleep_fail": "Вам необхідне свіже повітря для сну" -} diff --git a/origins/src/main/resources/assets/origins/lang/zh_cn.json b/origins/src/main/resources/assets/origins/lang/zh_cn.json deleted file mode 100644 index 66a5f5ecd..000000000 --- a/origins/src/main/resources/assets/origins/lang/zh_cn.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "origin.origins.human.name": "人类", - "origin.origins.human.description": "普通的人类。普通的Minecraft体验等着你。", - "origin.origins.merling.name": "人鱼族", - "origin.origins.merling.description": "这些海洋的原住民并不习惯长时间地离开水体。", - "origin.origins.arachnid.name": "蛛形族", - "origin.origins.arachnid.description": "攀爬与用蛛网束缚敌人的能力使得蛛形族成为完美的猎手。", - "origin.origins.blazeborn.name": "烈焰族", - "origin.origins.blazeborn.description": "作为烈焰人的后裔,烈焰族天生得以免疫下界的各色险境。", - "origin.origins.avian.name": "羽人族", - "origin.origins.avian.description": "羽人族在很久以前就失去了飞行的能力。现在,有时可以观察到这些温和的生物从此方滑翔到彼方。", - "origin.origins.phantom.name": "幻影族", - "origin.origins.phantom.description": "作为人类与幻翼的混血种,这些生物可以幻化自如。", - "origin.origins.feline.name": "猫族", - "origin.origins.feline.description": "猫族的外表足以吓跑苦力怕。他们和猫一般灵活的动作使他们总能安全着陆。", - "origin.origins.elytrian.name": "翼人族", - "origin.origins.elytrian.description": "翼人族习惯随风飘泊,如果头顶的空间不够宽阔,他们会感到不舒服。", - "origin.origins.enderian.name": "末影族", - "origin.origins.enderian.description": "作为末影龙的子嗣,末影族能够随意传送,但会被水伤害。", - "origin.origins.shulk.name": "潜影族", - "origin.origins.shulk.description": "潜影贝的近亲, 体表覆盖着一层保护性的壳状皮肤。", - "power.origins.water_breathing.name": "鳃", - "power.origins.water_breathing.description": "你可以在水下呼吸,但在陆地则不能。", - "power.origins.aqua_affinity.name": "水下速掘", - "power.origins.aqua_affinity.description": "你在水下可以正常速度破坏方块。", - "power.origins.water_vision.name": "水下视野", - "power.origins.water_vision.description": "你的水下视力可谓完美。", - "power.origins.swim_speed.name": "鳍", - "power.origins.swim_speed.description": "你在水下的移动速度提升。", - "power.origins.like_water.name": "亲水", - "power.origins.like_water.description": "你不会在水中下沉,除非你刻意而为。", - "power.origins.fragile.name": "脆弱", - "power.origins.fragile.description": "你比人类少3颗心的生命上限。", - "power.origins.webbing.name": "网织", - "power.origins.webbing.description": "你以近战击中敌人时会把他们困在蛛网里。", - "power.origins.climbing.name": "攀爬", - "power.origins.climbing.description": "你可以攀上任何一面墙,而不仅仅是梯子。", - "power.origins.carnivore.name": "肉食性", - "power.origins.carnivore.description": "你只能吃肉,不吃蔬菜。", - "power.origins.fire_immunity.name": "火焰免疫", - "power.origins.fire_immunity.description": "你免疫所有类型的火焰伤害。", - "power.origins.nether_spawn.name": "下界住民", - "power.origins.nether_spawn.description": "你的初始出生点将位于下界。", - "power.origins.burning_wrath.name": "怒火", - "power.origins.burning_wrath.description": "着火时,你的攻击造成额外伤害。", - "power.origins.hotblooded.name": "炽血", - "power.origins.hotblooded.description": "你灼热的身体使毒液快速燃尽,因此你对中毒和饥饿状态效果免疫。", - "power.origins.water_vulnerability.name": "恐水", - "power.origins.water_vulnerability.description": "你在接触水时会持续受到伤害。", - "power.origins.tailwind.name": "顺风腿", - "power.origins.tailwind.description": "你的步伐比其他人要快一些。", - "power.origins.slow_falling.name": "轻如鸿毛", - "power.origins.slow_falling.description": "你会像羽毛一样轻轻地飘落到地上,除非你潜行。", - "power.origins.vegetarian.name": "草食性", - "power.origins.vegetarian.description": "你消化不了肉类。", - "power.origins.fresh_air.name": "新风需求", - "power.origins.fresh_air.description": "睡觉时,你的床必须处于至少86格的高度以供你呼吸新鲜空气。", - "power.origins.phasing.name": "相位变换", - "power.origins.phasing.description": "幻化时,你可以穿过黑曜石以外的任何固体。", - "power.origins.invisibility.name": "隐身", - "power.origins.invisibility.description": "幻化时,你是隐形的。", - "power.origins.hunger_over_time.name": "快速代谢", - "power.origins.hunger_over_time.description": "幻化会让你感到饥饿。", - "power.origins.burn_in_daylight.name": "光敏性", - "power.origins.burn_in_daylight.description": "不在隐形状态时,你会被阳光点燃。", - "power.origins.fall_immunity.name": "杂技高手", - "power.origins.fall_immunity.description": "你不会受到摔落伤害,无论从何处摔落。", - "power.origins.sprint_jump.name": "强健脚踝", - "power.origins.sprint_jump.description": "疾跑时你跳得更高。", - "power.origins.nine_lives.name": "九条“命”", - "power.origins.nine_lives.description": "你比人类少1颗心的生命上限。", - "power.origins.cat_vision.name": "夜行性", - "power.origins.cat_vision.description": "不在水中时,你的暗视力略有提升。", - "power.origins.weak_arms.name": "瘦弱手臂", - "power.origins.weak_arms.description": "如果没有力量药水相助,你只有在一个天然石头方块周围最多存在两个相邻的天然石头方块时才能开采它。", - "power.origins.scare_creepers.name": "猫脸", - "power.origins.scare_creepers.description": "苦力怕害怕你,它们只会在你先发动攻击的情况下爆炸。", - "power.origins.launch_into_air.name": "风之礼遇", - "power.origins.launch_into_air.description": "每隔30秒,你就能将自己抛向空中约20个方块高度。", - "power.origins.elytra.name": "有翼", - "power.origins.elytra.description": "你天生拥有鞘翅,无需装备。", - "power.origins.light_armor.name": "机动需求", - "power.origins.light_armor.description": "你不能穿任何重甲(保护值高于链甲的盔甲)。", - "power.origins.claustrophobia.name": "幽闭恐惧", - "power.origins.claustrophobia.description": "在天花板很低的地方逗留太久会使你感到虚弱,速度变慢。", - "power.origins.more_kinetic_damage.name": "骨质疏松", - "power.origins.more_kinetic_damage.description": "你会从坠落或撞击方块中受到更多的伤害。", - "power.origins.aerial_combatant.name": "空中作战", - "power.origins.aerial_combatant.description": "鞘翅滑翔时,你造成的伤害大幅提升。", - "power.origins.throw_ender_pearl.name": "传送", - "power.origins.throw_ender_pearl.description": "只要你愿意,你可以抛出一个无伤害的末影珍珠。", - "power.origins.pumpkin_hate.name": "南瓜恐惧", - "power.origins.pumpkin_hate.description": "你害怕南瓜,理由想必很充分。", - "power.origins.extra_reach.name": "瘦长身体", - "power.origins.extra_reach.description": "你可以触及更远的方块和实体。", - "power.origins.shulker_inventory.name": "贮藏家", - "power.origins.shulker_inventory.description": "你额外拥有9个死亡不掉落的物品栏槽位。", - "power.origins.natural_armor.name": "坚韧皮肤", - "power.origins.natural_armor.description": "即使不穿戴盔甲,你的皮肤也赋予你天生的保护。", - "power.origins.more_exhaustion.name": "食欲旺盛", - "power.origins.more_exhaustion.description": "你的精力消耗得快于常人,因此你吃得也多。", - "power.origins.no_shield.name": "持盾不能", - "power.origins.no_shield.description": "你双手的造型让你无法正常地手持盾牌。", - "power.origins.strong_arms.name": "健壮手腕", - "power.origins.strong_arms.description": "你的双手足够强大,使得你不需要镐子就可以开采天然石头。", - "power.origins.translucent.name": "半透明", - "power.origins.translucent.description": "你的皮肤是半透明的。", - "power.origins.end_spawn.name": "末地住民", - "power.origins.end_spawn.description": "你的旅程从末地开始。", - "power.origins.master_of_webs.name": "攀网高手", - "power.origins.master_of_webs.description": "你可以在蜘蛛网中穿行自如,随意攀爬。当你击中敌人的时候,他们会被蜘蛛网缠住一会儿。你能察觉到被蜘蛛网束缚住的非节肢生物。你可以用线合成蜘蛛网。", - "power.origins.lay_eggs.name": "卵生", - "power.origins.lay_eggs.description": "早晨醒来时,你会产下一枚蛋。", - "power.origins.phantomize.name": "幻影形态", - "power.origins.phantomize.description": "你可以在人类形态和幻影形态间自由切换,这仅限于当你的饥饿值足以疾跑时。", - "power.origins.like_air.name": "亲风", - "power.origins.like_air.description": "行走时的速度提升也对你的空中速度生效。", - "power.origins.velvet_paws.name": "柔软脚爪", - "power.origins.velvet_paws.description": "你的脚步不会产生任何会被其他生物捕获的振动。", - "category.origins": "起源", - "key.origins.primary_active": "主动能力(首要按键)", - "key.origins.secondary_active": "主动能力(备用按键)", - "key.origins.view_origin": "查看起源", - "text.autoconfig.origins.title": "起源 设置", - "text.autoconfig.origins.option.xOffset": "冷却条 X轴偏移量", - "text.autoconfig.origins.option.yOffset": "冷却条 Y轴偏移量", - "text.autoconfig.origins.option.phantomizedOverlayStrength": "幻化时叠加层视觉效果强度", - "item.origins.orb_of_origin": "起源之球", - "component.item.origins.origin.layer": "让你能够选择一个新的%s", - "component.item.origins.origin.layer_and_origin": "将你的%1$s设置为“%2$s”", - "enchantment.origins.water_protection": "防水", - "container.shulker_inventory_power": "潜影背包栏", - "origins.gui.select": "选择", - "origins.gui.close": "关闭", - "origins.gui.choose": "选择", - "origins.gui.choose_origin.title": "选择你的%s", - "origins.gui.view_origin.title": "这是你的%s", - "origins.gui.view_origin.empty": "你无法拥有任何起源。", - "origins.gui.view_origin.not_installed": "该服务器未安装 起源 模组。", - "origins.gui.impact.impact": "影响", - "origins.gui.impact.none": "无", - "origins.gui.impact.low": "低", - "origins.gui.impact.medium": "中", - "origins.gui.impact.high": "高", - "origins.gui.version_mismatch": "该服务器运行的起源版本(v%1$s)与你安装的(v%2$s)不兼容。", - "origins.gui.badge.active": "主动能力,按下%s键使用", - "origins.gui.badge.toggle": "使用%s键开关", - "origins.gui.badge.recipe.crafting.shaped": "能力提供的有序合成配方:", - "origins.gui.badge.recipe.crafting.shapeless": "能力提供的无序合成配方:", - "origins.gui.unbound_key": "§o未绑定§r", - "origin.origins.random.name": "随机", - "origin.origins.random.description": "你将在以下中被随机抽选一项:", - "layer.origins.origin.name": "起源", - "origin.origins.empty.name": "丢失", - "origin.origins.empty.description": "你没有任何起源。", - "death.attack.no_water_for_gills": "%1$s没能保持湿润", - "death.attack.no_water_for_gills.player": "%1$s在与%2$s战斗时没能保持湿润", - "death.attack.hurt_by_water": "%1$s洗澡的时间太长了", - "death.attack.hurt_by_water.player": "%1$s被%2$s沉入了水中", - "death.attack.genericDamageOverTime": "%1$s被持续性伤害效果杀死了", - "death.attack.genericDamageOverTime.player": "%1$s在与%2$s战斗时被持续性伤害效果杀死了", - "commands.origin.origin_not_found": "未知起源:%s", - "commands.origin.set.success.single": "已将%s的%s设置为:%s", - "commands.origin.set.success.multiple": "已将%s个目标的%s设置为:%s", - "commands.origin.get.result": "%s拥有以下%s:%s(%s)", - "commands.origin.gui.all": "为%s个玩家打开了选择GUI", - "commands.origin.gui.layer": "为%1$s个玩家打开了 %2$s 的选择GUI", - "origins.avian_sleep_fail": "你需要新鲜空气才能正常入睡", - "enchantment.origins.water_protection.desc": "Delays damage from hydrophobia.", - "commands.origin.layer_not_found": "Unknown layer: %s", - "commands.origin.unregistered_in_layer": "Origin %1$s is not registered in layer %2$s!", - "commands.origin.random.all": "Randomly assigned an origin to %1$s targets in %2$s layers", - "commands.origin.random.not_allowed": "The layer %1$s does not allow for random origins!", - "commands.origin.random.success.multiple": "Randomly assigned an origin to %1$s targets in layer %2$s", - "commands.origin.random.success.single": "Randomly assigned the origin %2$s to %1$s in layer %3$s" -} diff --git a/origins/src/main/resources/assets/origins/models/item/orb_of_origin.json b/origins/src/main/resources/assets/origins/models/item/orb_of_origin.json index f019384fe..b5051549d 100644 --- a/origins/src/main/resources/assets/origins/models/item/orb_of_origin.json +++ b/origins/src/main/resources/assets/origins/models/item/orb_of_origin.json @@ -1,6 +1,6 @@ { - "parent": "item/generated", - "textures": { - "layer0": "origins:item/orb_of_origin" - } + "parent": "item/generated", + "textures": { + "layer0": "origins:item/orb_of_origin" + } } diff --git a/origins/src/main/resources/assets/origins/textures/overlay/sprites/phantomize_overlay.png b/origins/src/main/resources/assets/origins/textures/overlay/sprites/phantomize_overlay.png new file mode 100644 index 000000000..95f7aa758 Binary files /dev/null and b/origins/src/main/resources/assets/origins/textures/overlay/sprites/phantomize_overlay.png differ diff --git a/origins/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json b/origins/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json new file mode 100644 index 000000000..ccf35ab31 --- /dev/null +++ b/origins/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "origins:no_water_for_gills", + "origins:hurt_by_water" + ] +} diff --git a/origins/src/main/resources/data/minecraft/tags/damage_type/bypasses_shield.json b/origins/src/main/resources/data/minecraft/tags/damage_type/bypasses_shield.json new file mode 100644 index 000000000..ccf35ab31 --- /dev/null +++ b/origins/src/main/resources/data/minecraft/tags/damage_type/bypasses_shield.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "origins:no_water_for_gills", + "origins:hurt_by_water" + ] +} diff --git a/origins/src/main/resources/data/minecraft/tags/damage_type/no_knockback.json b/origins/src/main/resources/data/minecraft/tags/damage_type/no_knockback.json new file mode 100644 index 000000000..2e1be9e0a --- /dev/null +++ b/origins/src/main/resources/data/minecraft/tags/damage_type/no_knockback.json @@ -0,0 +1,6 @@ +{ + "values": [ + "origins:hurt_by_water", + "origins:no_water_for_gills" + ] +} diff --git a/origins/src/main/resources/data/origins/badges/active.json b/origins/src/main/resources/data/origins/badges/active.json new file mode 100644 index 000000000..afcf3d3d2 --- /dev/null +++ b/origins/src/main/resources/data/origins/badges/active.json @@ -0,0 +1,4 @@ +{ + "sprite": "origins:textures/gui/badge/active.png", + "text": "origins.gui.badge.active" +} diff --git a/origins/src/main/resources/data/origins/badges/toggle.json b/origins/src/main/resources/data/origins/badges/toggle.json new file mode 100644 index 000000000..22296fb52 --- /dev/null +++ b/origins/src/main/resources/data/origins/badges/toggle.json @@ -0,0 +1,4 @@ +{ + "sprite": "origins:textures/gui/badge/toggle.png", + "text": "origins.gui.badge.toggle" +} diff --git a/origins/src/main/resources/data/origins/damage_type/hurt_by_water.json b/origins/src/main/resources/data/origins/damage_type/hurt_by_water.json new file mode 100644 index 000000000..dd81915d9 --- /dev/null +++ b/origins/src/main/resources/data/origins/damage_type/hurt_by_water.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "hurt_by_water", + "scaling": "never" +} diff --git a/origins/src/main/resources/data/origins/damage_type/no_water_for_gills.json b/origins/src/main/resources/data/origins/damage_type/no_water_for_gills.json new file mode 100644 index 000000000..1a7150fca --- /dev/null +++ b/origins/src/main/resources/data/origins/damage_type/no_water_for_gills.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "no_water_for_gills", + "scaling": "never" +} diff --git a/origins/src/main/resources/data/origins/enchantment/water_protection.json b/origins/src/main/resources/data/origins/enchantment/water_protection.json new file mode 100644 index 000000000..199c77fe4 --- /dev/null +++ b/origins/src/main/resources/data/origins/enchantment/water_protection.json @@ -0,0 +1,22 @@ +{ + "description": { + "text": "Water Protection" + }, + "exclusive_set": "#origins:exclusive_set/water_protection", + "supported_items": "#minecraft:enchantable/armor", + "primary_items": [], + "weight": 1, + "max_level": 4, + "min_cost": { + "base": 8, + "per_level_above_first": 4 + }, + "max_cost": { + "base": 32, + "per_level_above_first": 4 + }, + "anvil_cost": 4, + "slots": [ + "armor" + ] +} diff --git a/origins/src/main/resources/data/origins/origin_layers/origin.json b/origins/src/main/resources/data/origins/origin_layers/origin.json new file mode 100644 index 000000000..bf68905db --- /dev/null +++ b/origins/src/main/resources/data/origins/origin_layers/origin.json @@ -0,0 +1,23 @@ +{ + "replace": false, + "order": 0, + "enabled": true, + "origins": [ + "origins:arachnid", + "origins:avian", + "origins:blazeborn", + "origins:elytrian", + "origins:enderian", + "origins:feline", + "origins:human", + "origins:merling", + "origins:phantom", + "origins:shulk" + ], + "allow_random": true, + "exclude_random": [ + "origins:human" + ], + "allow_random_unchoosable": false, + "hidden": false +} diff --git a/origins/src/main/resources/data/origins/origins/arachnid.json b/origins/src/main/resources/data/origins/origins/arachnid.json new file mode 100644 index 000000000..6e818d9d2 --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/arachnid.json @@ -0,0 +1,14 @@ +{ + "powers": [ + "origins:climbing", + "origins:master_of_webs", + "origins:carnivore", + "origins:fragile", + "origins:arthropod" + ], + "icon": { + "id": "minecraft:cobweb" + }, + "order": 1, + "impact": 1 +} diff --git a/origins/src/main/resources/data/origins/origins/avian.json b/origins/src/main/resources/data/origins/origins/avian.json new file mode 100644 index 000000000..14c231999 --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/avian.json @@ -0,0 +1,15 @@ +{ + "powers": [ + "origins:slow_falling", + "origins:fresh_air", + "origins:like_air", + "origins:tailwind", + "origins:lay_eggs", + "origins:vegetarian" + ], + "icon": { + "id": "minecraft:feather" + }, + "order": 0, + "impact": 1 +} diff --git a/origins/src/main/resources/data/origins/origins/badges/active.json b/origins/src/main/resources/data/origins/origins/badges/active.json deleted file mode 100644 index ffb9a2ea4..000000000 --- a/origins/src/main/resources/data/origins/origins/badges/active.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "sprite": "origins:textures/gui/badge/active.png", - "text": "origins.gui.badge.active" -} diff --git a/origins/src/main/resources/data/origins/origins/badges/toggle.json b/origins/src/main/resources/data/origins/origins/badges/toggle.json deleted file mode 100644 index f6b18f611..000000000 --- a/origins/src/main/resources/data/origins/origins/badges/toggle.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "sprite": "origins:textures/gui/badge/toggle.png", - "text": "origins.gui.badge.toggle" -} diff --git a/origins/src/main/resources/data/origins/origins/blazeborn.json b/origins/src/main/resources/data/origins/origins/blazeborn.json new file mode 100644 index 000000000..a1eb330de --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/blazeborn.json @@ -0,0 +1,17 @@ +{ + "powers": [ + "origins:fire_immunity", + "origins:nether_spawn", + "origins:burning_wrath", + "origins:hotblooded", + "origins:water_vulnerability", + "origins:flame_particles", + "origins:damage_from_snowballs", + "origins:damage_from_potions" + ], + "icon": { + "id": "minecraft:blaze_powder" + }, + "order": 1, + "impact": 3 +} diff --git a/origins/src/main/resources/data/origins/origins/elytrian.json b/origins/src/main/resources/data/origins/origins/elytrian.json new file mode 100644 index 000000000..98859acc7 --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/elytrian.json @@ -0,0 +1,15 @@ +{ + "powers": [ + "origins:elytra", + "origins:launch_into_air", + "origins:aerial_combatant", + "origins:light_armor", + "origins:claustrophobia", + "origins:more_kinetic_damage" + ], + "icon": { + "id": "minecraft:elytra" + }, + "order": 3, + "impact": 1 +} diff --git a/origins/src/main/resources/data/origins/origins/enderian.json b/origins/src/main/resources/data/origins/origins/enderian.json new file mode 100644 index 000000000..0b4c34eb7 --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/enderian.json @@ -0,0 +1,15 @@ +{ + "powers": [ + "origins:throw_ender_pearl", + "origins:water_vulnerability", + "origins:pumpkin_hate", + "origins:extra_reach", + "origins:ender_particles", + "origins:damage_from_potions" + ], + "icon": { + "id": "minecraft:ender_pearl" + }, + "order": 1, + "impact": 2 +} diff --git a/origins/src/main/resources/data/origins/origins/feline.json b/origins/src/main/resources/data/origins/origins/feline.json new file mode 100644 index 000000000..049e47026 --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/feline.json @@ -0,0 +1,16 @@ +{ + "powers": [ + "origins:fall_immunity", + "origins:sprint_jump", + "origins:velvet_paws", + "origins:nine_lives", + "origins:weak_arms", + "origins:scare_creepers", + "origins:cat_vision" + ], + "icon": { + "id": "minecraft:orange_wool" + }, + "order": 0, + "impact": 2 +} diff --git a/origins/src/main/resources/data/origins/origins/human.json b/origins/src/main/resources/data/origins/origins/human.json new file mode 100644 index 000000000..73c43a04f --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/human.json @@ -0,0 +1,7 @@ +{ + "icon": { + "id": "minecraft:player_head" + }, + "order": 0, + "impact": 0 +} diff --git a/origins/src/main/resources/data/origins/origins/merling.json b/origins/src/main/resources/data/origins/origins/merling.json new file mode 100644 index 000000000..1bc2cde3e --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/merling.json @@ -0,0 +1,17 @@ +{ + "powers": [ + "origins:water_breathing", + "origins:water_vision", + "origins:aqua_affinity", + "origins:swim_speed", + "origins:like_water", + "origins:aquatic", + "origins:conduit_power_on_land", + "origins:air_from_potions" + ], + "icon": { + "id": "minecraft:cod" + }, + "order": 0, + "impact": 3 +} diff --git a/origins/src/main/resources/data/origins/origins/origin/arachnid.json b/origins/src/main/resources/data/origins/origins/origin/arachnid.json deleted file mode 100644 index 8905bcbc6..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/arachnid.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "powers": [ - "origins:climbing", - "origins:master_of_webs", - "origins:carnivore", - "origins:fragile", - "origins:arthropod" - ], - "icon": { - "id": "minecraft:cobweb" - }, - "order": 1, - "impact": 1 -} diff --git a/origins/src/main/resources/data/origins/origins/origin/avian.json b/origins/src/main/resources/data/origins/origins/origin/avian.json deleted file mode 100644 index d9427bf95..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/avian.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "powers": [ - "origins:slow_falling", - "origins:fresh_air", - "origins:like_air", - "origins:tailwind", - "origins:lay_eggs", - "origins:vegetarian" - ], - "icon": { - "id": "minecraft:feather" - }, - "order": 0, - "impact": 1 -} diff --git a/origins/src/main/resources/data/origins/origins/origin/blazeborn.json b/origins/src/main/resources/data/origins/origins/origin/blazeborn.json deleted file mode 100644 index d4ec667b5..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/blazeborn.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "powers": [ - "origins:fire_immunity", - "origins:nether_spawn", - "origins:burning_wrath", - "origins:hotblooded", - "origins:water_vulnerability", - "origins:flame_particles", - "origins:damage_from_snowballs", - "origins:damage_from_potions" - ], - "icon": { - "id": "minecraft:blaze_powder" - }, - "order": 1, - "impact": 3 -} diff --git a/origins/src/main/resources/data/origins/origins/origin/elytrian.json b/origins/src/main/resources/data/origins/origins/origin/elytrian.json deleted file mode 100644 index e61b41d26..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/elytrian.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "powers": [ - "origins:elytra", - "origins:launch_into_air", - "origins:aerial_combatant", - "origins:light_armor", - "origins:claustrophobia", - "origins:more_kinetic_damage" - ], - "icon": { - "id": "minecraft:elytra" - }, - "order": 3, - "impact": 1 -} diff --git a/origins/src/main/resources/data/origins/origins/origin/enderian.json b/origins/src/main/resources/data/origins/origins/origin/enderian.json deleted file mode 100644 index 49a192039..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/enderian.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "powers": [ - "origins:throw_ender_pearl", - "origins:water_vulnerability", - "origins:pumpkin_hate", - "origins:extra_reach", - "origins:ender_particles", - "origins:damage_from_potions" - ], - "icon": { - "id": "minecraft:ender_pearl" - }, - "order": 1, - "impact": 2 -} diff --git a/origins/src/main/resources/data/origins/origins/origin/feline.json b/origins/src/main/resources/data/origins/origins/origin/feline.json deleted file mode 100644 index a9294c2af..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/feline.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "powers": [ - "origins:fall_immunity", - "origins:sprint_jump", - "origins:velvet_paws", - "origins:nine_lives", - "origins:weak_arms", - "origins:scare_creepers", - "origins:cat_vision" - ], - "icon": { - "id": "minecraft:orange_wool" - }, - "order": 0, - "impact": 2 -} diff --git a/origins/src/main/resources/data/origins/origins/origin/human.json b/origins/src/main/resources/data/origins/origins/origin/human.json deleted file mode 100644 index 990cf74f0..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/human.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "icon": { - "id": "minecraft:player_head" - }, - "order": 0, - "impact": 0 -} diff --git a/origins/src/main/resources/data/origins/origins/origin/merling.json b/origins/src/main/resources/data/origins/origins/origin/merling.json deleted file mode 100644 index 03b5725af..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/merling.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "powers": [ - "origins:water_breathing", - "origins:water_vision", - "origins:aqua_affinity", - "origins:swim_speed", - "origins:like_water", - "origins:aquatic", - "origins:conduit_power_on_land", - "origins:air_from_potions" - ], - "icon": { - "id": "minecraft:cod" - }, - "order": 0, - "impact": 3 -} diff --git a/origins/src/main/resources/data/origins/origins/origin/phantom.json b/origins/src/main/resources/data/origins/origins/origin/phantom.json deleted file mode 100644 index d61fb093e..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/phantom.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "powers": [ - "origins:phantomize", - "origins:translucent", - "origins:phasing", - "origins:invisibility", - "origins:burn_in_daylight", - "origins:hunger_over_time", - "origins:fragile", - "origins:phantomize_overlay" - ], - "icon": { - "id": "minecraft:phantom_membrane" - }, - "order": 2, - "impact": 3 -} diff --git a/origins/src/main/resources/data/origins/origins/origin/shulk.json b/origins/src/main/resources/data/origins/origins/origin/shulk.json deleted file mode 100644 index 7539fa9db..000000000 --- a/origins/src/main/resources/data/origins/origins/origin/shulk.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "powers": [ - "origins:shulker_inventory", - "origins:natural_armor", - "origins:strong_arms", - "origins:strong_arms_break_speed", - "origins:no_shield", - "origins:more_exhaustion" - ], - "icon": { - "id": "minecraft:shulker_shell" - }, - "order": 4, - "impact": 1 -} diff --git a/origins/src/main/resources/data/origins/origins/origin_layer/origin.json b/origins/src/main/resources/data/origins/origins/origin_layer/origin.json deleted file mode 100644 index 1ad2c45b4..000000000 --- a/origins/src/main/resources/data/origins/origins/origin_layer/origin.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "replace": false, - "order": 0, - "enabled": true, - "origins": [ - "origins:arachnid", - "origins:avian", - "origins:blazeborn", - "origins:elytrian", - "origins:enderian", - "origins:feline", - "origins:human", - "origins:merling", - "origins:phantom", - "origins:shulk" - ], - "allow_random": true, - "exclude_random": [ - "origins:human" - ], - "allow_random_unchoosable": false, - "hidden": false -} diff --git a/origins/src/main/resources/data/origins/origins/phantom.json b/origins/src/main/resources/data/origins/origins/phantom.json new file mode 100644 index 000000000..33bf9e806 --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/phantom.json @@ -0,0 +1,18 @@ +{ + "powers": [ + "origins:phantomize", + "origins:translucent", + "origins:phasing", + "origins:invisibility", + "origins:burn_in_daylight", + "origins:hunger_over_time", + "origins:fragile", + "origins:phantomize_overlay", + "origins:phantomize_callback" + ], + "icon": { + "id": "minecraft:phantom_membrane" + }, + "order": 2, + "impact": 3 +} diff --git a/origins/src/main/resources/data/origins/origins/power/aerial_combatant.json b/origins/src/main/resources/data/origins/origins/power/aerial_combatant.json deleted file mode 100644 index 35a6ede81..000000000 --- a/origins/src/main/resources/data/origins/origins/power/aerial_combatant.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "origins:modify_damage_dealt", - "modifier": { - "id": "*:*", - "amount": 1, - "operation": "multiply_base_multiplicative" - }, - "condition": { - "type": "origins:fall_flying" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/air_from_potions.json b/origins/src/main/resources/data/origins/origins/power/air_from_potions.json deleted file mode 100644 index 6ceca8d0f..000000000 --- a/origins/src/main/resources/data/origins/origins/power/air_from_potions.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "origins:action_on_item_use", - "hidden": true, - "item_condition": { - "type": "origins:ingredient", - "ingredient": { - "item": "minecraft:potion" - } - }, - "entity_action": { - "type": "origins:gain_air", - "value": 60 - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/aqua_affinity.json b/origins/src/main/resources/data/origins/origins/power/aqua_affinity.json deleted file mode 100644 index 3e0b63b74..000000000 --- a/origins/src/main/resources/data/origins/origins/power/aqua_affinity.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "type": "origins:multiple", - "underwater": { - "type": "origins:modify_break_speed", - "modifier": { - "amount": 4, - "operation": "multiply_total_multiplicative" - }, - "condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:submerged_in", - "fluid": "minecraft:water" - }, - { - "type": "origins:enchantment", - "enchantment": "minecraft:aqua_affinity", - "comparison": "==", - "compare_to": 0 - } - ] - } - }, - "ungrounded": { - "type": "origins:modify_break_speed", - "modifier": { - "amount": 4, - "operation": "multiply_total_multiplicative" - }, - "condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:fluid_height", - "fluid": "minecraft:water", - "comparison": ">", - "compare_to": 0 - }, - { - "type": "origins:on_block", - "inverted": true - } - ] - } - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/aquatic.json b/origins/src/main/resources/data/origins/origins/power/aquatic.json deleted file mode 100644 index 0bc368fd1..000000000 --- a/origins/src/main/resources/data/origins/origins/power/aquatic.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "origins:modify_type_tag", - "tag": "minecraft:sensitive_to_impaling", - "hidden": true -} diff --git a/origins/src/main/resources/data/origins/origins/power/arcane_skin.json b/origins/src/main/resources/data/origins/origins/power/arcane_skin.json deleted file mode 100644 index b1200cba0..000000000 --- a/origins/src/main/resources/data/origins/origins/power/arcane_skin.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "origins:model_color", - "red": 0.5, - "green": 0.5, - "alpha": 0.7 -} diff --git a/origins/src/main/resources/data/origins/origins/power/arthropod.json b/origins/src/main/resources/data/origins/origins/power/arthropod.json deleted file mode 100644 index 1509e4634..000000000 --- a/origins/src/main/resources/data/origins/origins/power/arthropod.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "origins:modify_type_tag", - "tag": "minecraft:sensitive_to_bane_of_arthropods", - "hidden": true -} diff --git a/origins/src/main/resources/data/origins/origins/power/burn_in_daylight.json b/origins/src/main/resources/data/origins/origins/power/burn_in_daylight.json deleted file mode 100644 index 925c28cec..000000000 --- a/origins/src/main/resources/data/origins/origins/power/burn_in_daylight.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "origins:burn", - "interval": 20, - "burn_duration": 6, - "condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:exposed_to_sun" - }, - { - "type": "origins:invisible", - "inverted": true - } - ] - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/burning_wrath.json b/origins/src/main/resources/data/origins/origins/power/burning_wrath.json deleted file mode 100644 index 722234f6c..000000000 --- a/origins/src/main/resources/data/origins/origins/power/burning_wrath.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "type": "origins:modify_damage_dealt", - "condition": { - "type": "origins:on_fire" - }, - "modifier": { - "amount": 3, - "operation": "add_base_early" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/carnivore.json b/origins/src/main/resources/data/origins/origins/power/carnivore.json deleted file mode 100644 index 1ddec016e..000000000 --- a/origins/src/main/resources/data/origins/origins/power/carnivore.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "type": "origins:prevent_item_use", - "item_condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:ingredient", - "ingredient": { - "tag": "origins:ignore_diet" - }, - "inverted": true - }, - { - "type": "origins:ingredient", - "ingredient": { - "tag": "origins:meat" - }, - "inverted": true - }, - { - "type": "origins:food" - } - ] - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/cat_vision.json b/origins/src/main/resources/data/origins/origins/power/cat_vision.json deleted file mode 100644 index ab89ab6c7..000000000 --- a/origins/src/main/resources/data/origins/origins/power/cat_vision.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "origins:night_vision", - "strength": 0.4, - "condition": { - "type": "origins:submerged_in", - "fluid": "minecraft:water", - "inverted": true - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/claustrophobia.json b/origins/src/main/resources/data/origins/origins/power/claustrophobia.json deleted file mode 100644 index e6ed7b95d..000000000 --- a/origins/src/main/resources/data/origins/origins/power/claustrophobia.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "origins:stacking_status_effect", - "min_stacks": -20, - "max_stacks": 361, - "duration_per_stack": 10, - "effects": [ - { - "id": "minecraft:weakness", - "ambient": true, - "show_particles": false, - "show_icon": true - }, - { - "id": "minecraft:slowness", - "ambient": true, - "show_particles": false, - "show_icon": true - } - ], - "condition": { - "type": "origins:block_collision", - "offset_x": 0, - "offset_y": 1, - "offset_z": 0 - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/climbing.json b/origins/src/main/resources/data/origins/origins/power/climbing.json deleted file mode 100644 index 686df0cbd..000000000 --- a/origins/src/main/resources/data/origins/origins/power/climbing.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "type": "origins:multiple", - "toggle": { - "type": "origins:toggle", - "key": { - "key": "key.origins.primary_active", - "continuous": false - } - }, - "climbing": { - "type": "origins:climbing", - "condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:power_active", - "power": "*:*_toggle" - }, - { - "type": "origins:or", - "conditions": [ - { - "type": "origins:and", - "conditions": [ - { - "type": "origins:sneaking", - "inverted": true - } - ] - }, - { - "type": "origins:and", - "conditions": [ - { - "type": "origins:sneaking" - }, - { - "type": "origins:or", - "conditions": [ - { - "type": "origins:block_collision", - "offset_x": 0.01, - "offset_z": 0.01 - }, - { - "type": "origins:block_collision", - "offset_x": -0.01, - "offset_z": -0.01 - } - ] - } - ] - } - ] - } - ] - } - } -} \ No newline at end of file diff --git a/origins/src/main/resources/data/origins/origins/power/conduit_power_on_land.json b/origins/src/main/resources/data/origins/origins/power/conduit_power_on_land.json deleted file mode 100644 index 330b12264..000000000 --- a/origins/src/main/resources/data/origins/origins/power/conduit_power_on_land.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "origins:simple", - "hidden": true -} diff --git a/origins/src/main/resources/data/origins/origins/power/damage_from_potions.json b/origins/src/main/resources/data/origins/origins/power/damage_from_potions.json deleted file mode 100644 index 0afc1d617..000000000 --- a/origins/src/main/resources/data/origins/origins/power/damage_from_potions.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "type": "origins:action_on_item_use", - "hidden": true, - "item_condition": { - "type": "origins:ingredient", - "ingredient": { - "item": "minecraft:potion" - } - }, - "entity_action": { - "type": "origins:damage", - "amount": 2, - "damage_type": "origins:hurt_by_water" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/damage_from_snowballs.json b/origins/src/main/resources/data/origins/origins/power/damage_from_snowballs.json deleted file mode 100644 index d9333538d..000000000 --- a/origins/src/main/resources/data/origins/origins/power/damage_from_snowballs.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "origins:modify_damage_taken", - "modifier": { - "amount": 3, - "operation": "add_base_early" - }, - "damage_condition": { - "type": "origins:projectile", - "projectile": "minecraft:snowball" - }, - "hidden": true -} diff --git a/origins/src/main/resources/data/origins/origins/power/elytra.json b/origins/src/main/resources/data/origins/origins/power/elytra.json deleted file mode 100644 index dd9d00aa0..000000000 --- a/origins/src/main/resources/data/origins/origins/power/elytra.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "origins:elytra_flight", - "render_elytra": true -} diff --git a/origins/src/main/resources/data/origins/origins/power/end_spawn.json b/origins/src/main/resources/data/origins/origins/power/end_spawn.json deleted file mode 100644 index d4fea53b0..000000000 --- a/origins/src/main/resources/data/origins/origins/power/end_spawn.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "origins:modify_player_spawn", - "dimension": "the_end", - "spawn_strategy": "center" -} diff --git a/origins/src/main/resources/data/origins/origins/power/ender_particles.json b/origins/src/main/resources/data/origins/origins/power/ender_particles.json deleted file mode 100644 index ae6149642..000000000 --- a/origins/src/main/resources/data/origins/origins/power/ender_particles.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "origins:particle", - "particle": "minecraft:portal", - "frequency": 4, - "hidden": true -} diff --git a/origins/src/main/resources/data/origins/origins/power/extra_reach.json b/origins/src/main/resources/data/origins/origins/power/extra_reach.json deleted file mode 100644 index 013acbd45..000000000 --- a/origins/src/main/resources/data/origins/origins/power/extra_reach.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "origins:attribute", - "modifiers": [ - { - "id": "*:*", - "attribute": "minecraft:player.block_interaction_range", - "amount": 1.5, - "operation": "add_value" - }, - { - "id": "*:*", - "attribute": "minecraft:player.entity_interaction_range", - "amount": 1.5, - "operation": "add_value" - } - ] -} diff --git a/origins/src/main/resources/data/origins/origins/power/fall_immunity.json b/origins/src/main/resources/data/origins/origins/power/fall_immunity.json deleted file mode 100644 index d005191ef..000000000 --- a/origins/src/main/resources/data/origins/origins/power/fall_immunity.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "origins:invulnerability", - "damage_condition": { - "type": "origins:in_tag", - "tag": "minecraft:is_fall" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/fire_immunity.json b/origins/src/main/resources/data/origins/origins/power/fire_immunity.json deleted file mode 100644 index 373725bb6..000000000 --- a/origins/src/main/resources/data/origins/origins/power/fire_immunity.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "origins:invulnerability", - "damage_condition": { - "type": "origins:fire" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/flame_particles.json b/origins/src/main/resources/data/origins/origins/power/flame_particles.json deleted file mode 100644 index 2bccc8818..000000000 --- a/origins/src/main/resources/data/origins/origins/power/flame_particles.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "origins:particle", - "particle": "minecraft:flame", - "frequency": 4, - "hidden": true -} diff --git a/origins/src/main/resources/data/origins/origins/power/fragile.json b/origins/src/main/resources/data/origins/origins/power/fragile.json deleted file mode 100644 index cbcdae718..000000000 --- a/origins/src/main/resources/data/origins/origins/power/fragile.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "origins:attribute", - "modifier": { - "id": "*:*", - "attribute": "minecraft:generic.max_health", - "amount": -6.0, - "operation": "add_value" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/fresh_air.json b/origins/src/main/resources/data/origins/origins/power/fresh_air.json deleted file mode 100644 index ecb446fe0..000000000 --- a/origins/src/main/resources/data/origins/origins/power/fresh_air.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "origins:prevent_sleep", - "block_condition": { - "type": "origins:height", - "comparison": "<", - "compare_to": 86 - }, - "message": { - "text": "You need fresh air to sleep" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/hotblooded.json b/origins/src/main/resources/data/origins/origins/power/hotblooded.json deleted file mode 100644 index 30e3e2565..000000000 --- a/origins/src/main/resources/data/origins/origins/power/hotblooded.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "origins:effect_immunity", - "effects": [ - "minecraft:poison", - "minecraft:hunger" - ] -} diff --git a/origins/src/main/resources/data/origins/origins/power/hunger_over_time.json b/origins/src/main/resources/data/origins/origins/power/hunger_over_time.json deleted file mode 100644 index 54e0acd74..000000000 --- a/origins/src/main/resources/data/origins/origins/power/hunger_over_time.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "origins:exhaust", - "interval": 20, - "exhaustion": 0.812, - "condition": { - "type": "origins:power_active", - "power": "*:phantomize" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/invisibility.json b/origins/src/main/resources/data/origins/origins/power/invisibility.json deleted file mode 100644 index 7d8e87698..000000000 --- a/origins/src/main/resources/data/origins/origins/power/invisibility.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "origins:invisibility", - "render_armor": true, - "condition": { - "type": "origins:power_active", - "power": "*:phantomize" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/launch_into_air.json b/origins/src/main/resources/data/origins/origins/power/launch_into_air.json deleted file mode 100644 index 0e45fdb1a..000000000 --- a/origins/src/main/resources/data/origins/origins/power/launch_into_air.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "origins:launch", - "cooldown": 600, - "hud_render": { - "sprite_location": "origins:textures/gui/resource_bar.png", - "bar_index": 4 - }, - "sound": "minecraft:entity.parrot.fly", - "speed": 2, - "key": { - "key": "key.origins.primary_active", - "continuous": true - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/lay_eggs.json b/origins/src/main/resources/data/origins/origins/power/lay_eggs.json deleted file mode 100644 index f8cc30f45..000000000 --- a/origins/src/main/resources/data/origins/origins/power/lay_eggs.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "origins:action_on_wake_up", - "entity_action": { - "type": "origins:and", - "actions": [ - { - "type": "origins:give", - "stack": { - "id": "minecraft:egg" - } - }, - { - "type": "origins:play_sound", - "sound": "minecraft:entity.chicken.egg" - } - ] - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/light_armor.json b/origins/src/main/resources/data/origins/origins/power/light_armor.json deleted file mode 100644 index e8bc4ca7e..000000000 --- a/origins/src/main/resources/data/origins/origins/power/light_armor.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "type": "origins:restrict_armor", - "head": { - "type": "origins:armor_value", - "comparison": ">", - "compare_to": 2 - }, - "chest": { - "type": "origins:armor_value", - "comparison": ">", - "compare_to": 5 - }, - "legs": { - "type": "origins:armor_value", - "comparison": ">", - "compare_to": 4 - }, - "feet": { - "type": "origins:armor_value", - "comparison": ">", - "compare_to": 1 - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/like_air.json b/origins/src/main/resources/data/origins/origins/power/like_air.json deleted file mode 100644 index a41c2d639..000000000 --- a/origins/src/main/resources/data/origins/origins/power/like_air.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "origins:attribute_modify_transfer", - "class": "modify_air_speed", - "attribute": "minecraft:generic.movement_speed", - "multiplier": 1 -} diff --git a/origins/src/main/resources/data/origins/origins/power/like_water.json b/origins/src/main/resources/data/origins/origins/power/like_water.json deleted file mode 100644 index e6d71b338..000000000 --- a/origins/src/main/resources/data/origins/origins/power/like_water.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "origins:simple" -} diff --git a/origins/src/main/resources/data/origins/origins/power/master_of_webs.json b/origins/src/main/resources/data/origins/origins/power/master_of_webs.json deleted file mode 100644 index 9046d2e4d..000000000 --- a/origins/src/main/resources/data/origins/origins/power/master_of_webs.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "type": "origins:multiple", - "webbing": { - "type": "origins:target_action_on_hit", - "cooldown": 120, - "hud_render": { - "sprite_location": "origins:textures/gui/resource_bar.png", - "bar_index": 5 - }, - "entity_action": { - "type": "origins:block_action_at", - "block_action": { - "type": "origins:if_else", - "condition": { - "type": "origins:replaceable" - }, - "if_action": { - "type": "origins:set_block", - "block": "minecraft:cobweb" - } - } - }, - "condition": { - "type": "origins:sneaking", - "inverted": true - } - }, - "no_slowdown": { - "type": "origins:phasing", - "block_condition": { - "type": "origins:in_tag", - "tag": "origins:cobwebs" - }, - "render_type": "none" - }, - "climbing": { - "type": "origins:climbing", - "condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:in_block_anywhere", - "block_condition": { - "type": "origins:in_tag", - "tag": "origins:cobwebs" - } - }, - { - "type": "origins:power_active", - "power": "*:climbing_toggle" - } - ] - }, - "hold_condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:power_active", - "power": "*:*_climbing" - }, - { - "type": "origins:sneaking", - "inverted": true - } - ] - } - }, - "punch_through": { - "type": "origins:prevent_block_selection", - "block_condition": { - "type": "origins:in_tag", - "tag": "origins:cobwebs" - }, - "condition": { - "type": "origins:sneaking", - "inverted": true - } - }, - "sense": { - "type": "origins:entity_glow", - "entity_condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:in_block_anywhere", - "block_condition": { - "type": "origins:in_tag", - "tag": "origins:cobwebs" - } - }, - { - "type": "origins:in_tag", - "tag": "arthropod", - "inverted": true - } - ] - } - }, - "web_crafting": { - "type": "origins:recipe", - "recipe": { - "id": "origins:master_of_webs/web_crafting", - "type": "minecraft:crafting_shapeless", - "ingredients": [ - { - "item": "minecraft:string" - }, - { - "item": "minecraft:string" - } - ], - "result": { - "id": "minecraft:cobweb" - } - } - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/more_exhaustion.json b/origins/src/main/resources/data/origins/origins/power/more_exhaustion.json deleted file mode 100644 index a4ee9548d..000000000 --- a/origins/src/main/resources/data/origins/origins/power/more_exhaustion.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "origins:modify_exhaustion", - "modifier": { - "amount": 0.6, - "operation": "multiply_base_multiplicative" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/more_kinetic_damage.json b/origins/src/main/resources/data/origins/origins/power/more_kinetic_damage.json deleted file mode 100644 index 7b07ec9c2..000000000 --- a/origins/src/main/resources/data/origins/origins/power/more_kinetic_damage.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "origins:modify_damage_taken", - "modifier": { - "amount": 0.5, - "operation": "multiply_base_multiplicative" - }, - "damage_condition": { - "type": "origins:in_tag", - "tag": "*:kinetic" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/natural_armor.json b/origins/src/main/resources/data/origins/origins/power/natural_armor.json deleted file mode 100644 index f4eda47b3..000000000 --- a/origins/src/main/resources/data/origins/origins/power/natural_armor.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "origins:attribute", - "modifier": { - "id": "*:*", - "attribute": "minecraft:generic.armor", - "amount": 8.0, - "operation": "add_value" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/nether_spawn.json b/origins/src/main/resources/data/origins/origins/power/nether_spawn.json deleted file mode 100644 index f9f2680e7..000000000 --- a/origins/src/main/resources/data/origins/origins/power/nether_spawn.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "origins:modify_player_spawn", - "dimension": "the_nether", - "dimension_distance_multiplier": 0.125, - "spawn_strategy": "center" -} diff --git a/origins/src/main/resources/data/origins/origins/power/nine_lives.json b/origins/src/main/resources/data/origins/origins/power/nine_lives.json deleted file mode 100644 index b0aa53fff..000000000 --- a/origins/src/main/resources/data/origins/origins/power/nine_lives.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "origins:attribute", - "modifier": { - "id": "*:*", - "attribute": "minecraft:generic.max_health", - "amount": -2.0, - "operation": "add_value" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/no_cobweb_slowdown.json b/origins/src/main/resources/data/origins/origins/power/no_cobweb_slowdown.json deleted file mode 100644 index 1cbd2fd40..000000000 --- a/origins/src/main/resources/data/origins/origins/power/no_cobweb_slowdown.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "origins:phasing", - "block_condition": { - "type": "origins:in_tag", - "tag": "origins:cobwebs" - }, - "render_type": "none", - "hidden": true -} diff --git a/origins/src/main/resources/data/origins/origins/power/no_shield.json b/origins/src/main/resources/data/origins/origins/power/no_shield.json deleted file mode 100644 index 4a3b4e6e4..000000000 --- a/origins/src/main/resources/data/origins/origins/power/no_shield.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "origins:prevent_item_use", - "item_condition": { - "type": "origins:ingredient", - "ingredient": { - "tag": "origins:shields" - } - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/phantomize.json b/origins/src/main/resources/data/origins/origins/power/phantomize.json deleted file mode 100644 index 15a503771..000000000 --- a/origins/src/main/resources/data/origins/origins/power/phantomize.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "origins:toggle", - "key": { - "key": "key.origins.primary_active", - "continuous": false - }, - "retain_state": false, - "condition": { - "type": "apoli:food_level", - "comparison": ">", - "compare_to": 6 - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/phantomize_overlay.json b/origins/src/main/resources/data/origins/origins/power/phantomize_overlay.json deleted file mode 100644 index cdfd5417b..000000000 --- a/origins/src/main/resources/data/origins/origins/power/phantomize_overlay.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "apoli:multiple", - "hidden": true, - "red": { - "type": "apoli:overlay", - "hidden": true, - "texture": "minecraft:textures/misc/nausea.png", - "red": 0.4, - "green": 0.2, - "blue": 0.2, - "strength": 0.7, - "draw_mode": "nausea", - "draw_phase": "above_hud", - "visible_in_third_person": true, - "hide_with_hud": true, - "condition": { - "type": "apoli:and", - "conditions": [ - { - "type": "apoli:power_active", - "power": "origins:phantomize" - } - ] - } - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/phasing.json b/origins/src/main/resources/data/origins/origins/power/phasing.json deleted file mode 100644 index cb0511a21..000000000 --- a/origins/src/main/resources/data/origins/origins/power/phasing.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "type": "origins:phasing", - "blacklist": true, - "render_type": "blindness", - "view_distance": 10, - "block_condition": { - "type": "origins:in_tag", - "tag": "origins:unphasable" - }, - "phase_down_condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:sneaking" - }, - { - "type": "origins:on_block" - } - ] - }, - "condition": { - "type": "origins:power_active", - "power": "*:phantomize" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/pumpkin_hate.json b/origins/src/main/resources/data/origins/origins/power/pumpkin_hate.json deleted file mode 100644 index e25a12c6b..000000000 --- a/origins/src/main/resources/data/origins/origins/power/pumpkin_hate.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "origins:multiple", - "prevent_eating": { - "type": "origins:prevent_item_use", - "item_condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:food" - }, - { - "type": "origins:ingredient", - "ingredient": { - "tag": "*:pumpkin_like/food" - } - } - ] - }, - "name": "power.origins.pumpkin_hate.name" - }, - "prevent_seeing": { - "type": "origins:prevent_entity_render", - "bientity_condition": { - "type": "apoli:equal", - "inverted": true - }, - "entity_condition": { - "type": "origins:equipped_item", - "equipment_slot": "head", - "item_condition": { - "type": "origins:ingredient", - "ingredient": { - "tag": "*:pumpkin_like/equipment" - } - } - } - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/scare_creepers.json b/origins/src/main/resources/data/origins/origins/power/scare_creepers.json deleted file mode 100644 index e6d71b338..000000000 --- a/origins/src/main/resources/data/origins/origins/power/scare_creepers.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "origins:simple" -} diff --git a/origins/src/main/resources/data/origins/origins/power/shulker_inventory.json b/origins/src/main/resources/data/origins/origins/power/shulker_inventory.json deleted file mode 100644 index 32c61dba8..000000000 --- a/origins/src/main/resources/data/origins/origins/power/shulker_inventory.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "origins:inventory", - "title": "Shulker Inventory", - "drop_on_death": false, - "key": { - "key": "key.origins.primary_active", - "continuous": false - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/slow_falling.json b/origins/src/main/resources/data/origins/origins/power/slow_falling.json deleted file mode 100644 index d71f7a246..000000000 --- a/origins/src/main/resources/data/origins/origins/power/slow_falling.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "type": "apoli:modify_falling", - "velocity": 0.01, - "take_fall_damage": false, - "condition": { - "type": "origins:or", - "conditions": [ - { - "type": "origins:and", - "conditions": [ - { - "type": "origins:sneaking" - }, - { - "type": "origins:fall_flying" - } - ] - }, - { - "type": "origins:and", - "conditions": [ - { - "type": "origins:sneaking", - "inverted": true - }, - { - "type": "origins:fall_flying", - "inverted": true - } - ] - } - ] - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/sprint_jump.json b/origins/src/main/resources/data/origins/origins/power/sprint_jump.json deleted file mode 100644 index 4d75fd545..000000000 --- a/origins/src/main/resources/data/origins/origins/power/sprint_jump.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "type": "origins:modify_jump", - "modifier": { - "amount": 0.5, - "operation": "multiply_base_multiplicative" - }, - "condition": { - "type": "origins:sprinting" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/strong_arms.json b/origins/src/main/resources/data/origins/origins/power/strong_arms.json deleted file mode 100644 index 0444894c2..000000000 --- a/origins/src/main/resources/data/origins/origins/power/strong_arms.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "origins:modify_harvest", - "allow": true, - "block_condition": { - "type": "origins:in_tag", - "tag": "origins:natural_stone" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/strong_arms_break_speed.json b/origins/src/main/resources/data/origins/origins/power/strong_arms_break_speed.json deleted file mode 100644 index 028d6ff80..000000000 --- a/origins/src/main/resources/data/origins/origins/power/strong_arms_break_speed.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "type": "origins:modify_break_speed", - "block_condition": { - "type": "origins:in_tag", - "tag": "origins:natural_stone" - }, - "condition": { - "type": "origins:using_effective_tool", - "inverted": true - }, - "modifier": { - "amount": 0.06, - "operation": "add_base_early" - }, - "hidden": true -} diff --git a/origins/src/main/resources/data/origins/origins/power/swim_speed.json b/origins/src/main/resources/data/origins/origins/power/swim_speed.json deleted file mode 100644 index fed70607d..000000000 --- a/origins/src/main/resources/data/origins/origins/power/swim_speed.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "origins:modify_swim_speed", - "modifier": { - "operation": "addition", - "amount": 1.5 - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/tailwind.json b/origins/src/main/resources/data/origins/origins/power/tailwind.json deleted file mode 100644 index 5bc4421d8..000000000 --- a/origins/src/main/resources/data/origins/origins/power/tailwind.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "origins:attribute", - "modifier": { - "id": "*:*", - "attribute": "minecraft:generic.movement_speed", - "amount": 0.2, - "operation": "add_multiplied_base" - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/throw_ender_pearl.json b/origins/src/main/resources/data/origins/origins/power/throw_ender_pearl.json deleted file mode 100644 index 509562f54..000000000 --- a/origins/src/main/resources/data/origins/origins/power/throw_ender_pearl.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "type": "origins:fire_projectile", - "cooldown": 30, - "hud_render": { - "sprite_location": "origins:textures/gui/resource_bar.png", - "bar_index": 6 - }, - "entity_type": "origins:enderian_pearl", - "sound": "minecraft:entity.ender_pearl.throw", - "speed": 1.5, - "divergence": 1, - "key": { - "key": "key.origins.primary_active", - "continuous": false - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/translucent.json b/origins/src/main/resources/data/origins/origins/power/translucent.json deleted file mode 100644 index c250e46ff..000000000 --- a/origins/src/main/resources/data/origins/origins/power/translucent.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "origins:model_color", - "alpha": 0.5 -} diff --git a/origins/src/main/resources/data/origins/origins/power/vegetarian.json b/origins/src/main/resources/data/origins/origins/power/vegetarian.json deleted file mode 100644 index b98764ae0..000000000 --- a/origins/src/main/resources/data/origins/origins/power/vegetarian.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "type": "origins:prevent_item_use", - "item_condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:ingredient", - "ingredient": { - "tag": "origins:ignore_diet" - }, - "inverted": true - }, - { - "type": "origins:ingredient", - "ingredient": { - "tag": "origins:meat" - } - }, - { - "type": "origins:food" - } - ] - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/velvet_paws.json b/origins/src/main/resources/data/origins/origins/power/velvet_paws.json deleted file mode 100644 index 617636d2d..000000000 --- a/origins/src/main/resources/data/origins/origins/power/velvet_paws.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "origins:prevent_game_event", - "event": "minecraft:step" -} diff --git a/origins/src/main/resources/data/origins/origins/power/water_breathing.json b/origins/src/main/resources/data/origins/origins/power/water_breathing.json deleted file mode 100644 index e6d71b338..000000000 --- a/origins/src/main/resources/data/origins/origins/power/water_breathing.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "origins:simple" -} diff --git a/origins/src/main/resources/data/origins/origins/power/water_vision.json b/origins/src/main/resources/data/origins/origins/power/water_vision.json deleted file mode 100644 index 10dc7bdcf..000000000 --- a/origins/src/main/resources/data/origins/origins/power/water_vision.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "type": "origins:multiple", - "toggle": { - "type": "origins:toggle", - "active_by_default": true, - "key": { - "key": "key.origins.primary_active", - "continuous": false - } - }, - "night_vision": { - "type": "origins:night_vision", - "strength": 1.0, - "condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:power_active", - "power": "*:*_toggle" - }, - { - "type": "origins:submerged_in", - "fluid": "minecraft:water" - } - ] - } - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/water_vulnerability.json b/origins/src/main/resources/data/origins/origins/power/water_vulnerability.json deleted file mode 100644 index cec807bce..000000000 --- a/origins/src/main/resources/data/origins/origins/power/water_vulnerability.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "type": "origins:damage_over_time", - "interval": 20, - "onset_delay": 1, - "damage": 2, - "damage_easy": 1, - "damage_type": "origins:hurt_by_water", - "protection_enchantment": "origins:water_protection", - "protection_effectiveness": 1.0, - "condition": { - "type": "origins:or", - "conditions": [ - { - "type": "origins:fluid_height", - "fluid": "minecraft:water", - "comparison": ">", - "compare_to": 0.0 - }, - { - "type": "origins:in_rain" - } - ] - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/weak_arms.json b/origins/src/main/resources/data/origins/origins/power/weak_arms.json deleted file mode 100644 index 73b13d9e4..000000000 --- a/origins/src/main/resources/data/origins/origins/power/weak_arms.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "origins:modify_break_speed", - "modifier": { - "amount": -1, - "operation": "multiply_total_multiplicative" - }, - "block_condition": { - "type": "origins:and", - "conditions": [ - { - "type": "origins:in_tag", - "tag": "origins:natural_stone" - }, - { - "type": "origins:adjacent", - "adjacent_condition": { - "type": "origins:in_tag", - "tag": "origins:natural_stone" - }, - "comparison": ">", - "compare_to": 2 - } - ] - }, - "condition": { - "type": "origins:status_effect", - "effect": "minecraft:strength", - "inverted": true - } -} diff --git a/origins/src/main/resources/data/origins/origins/power/webbing.json b/origins/src/main/resources/data/origins/origins/power/webbing.json deleted file mode 100644 index a51a81a9f..000000000 --- a/origins/src/main/resources/data/origins/origins/power/webbing.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "origins:cooldown", - "cooldown": 120, - "hud_render": { - "sprite_location": "origins:textures/gui/resource_bar.png", - "bar_index": 5 - } -} diff --git a/origins/src/main/resources/data/origins/origins/shulk.json b/origins/src/main/resources/data/origins/origins/shulk.json new file mode 100644 index 000000000..61b628a72 --- /dev/null +++ b/origins/src/main/resources/data/origins/origins/shulk.json @@ -0,0 +1,15 @@ +{ + "powers": [ + "origins:shulker_inventory", + "origins:natural_armor", + "origins:strong_arms", + "origins:strong_arms_break_speed", + "origins:no_shield", + "origins:more_exhaustion" + ], + "icon": { + "id": "minecraft:shulker_shell" + }, + "order": 4, + "impact": 1 +} diff --git a/origins/src/main/resources/data/origins/powers/aerial_combatant.json b/origins/src/main/resources/data/origins/powers/aerial_combatant.json new file mode 100644 index 000000000..500d5d1b3 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/aerial_combatant.json @@ -0,0 +1,11 @@ +{ + "type": "origins:modify_damage_dealt", + "modifier": { + "id": "*:*", + "amount": 1, + "operation": "multiply_base_multiplicative" + }, + "condition": { + "type": "origins:fall_flying" + } +} diff --git a/origins/src/main/resources/data/origins/powers/air_from_potions.json b/origins/src/main/resources/data/origins/powers/air_from_potions.json new file mode 100644 index 000000000..b5e770ece --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/air_from_potions.json @@ -0,0 +1,14 @@ +{ + "type": "origins:action_on_item_use", + "hidden": true, + "item_condition": { + "type": "origins:ingredient", + "ingredient": { + "item": "minecraft:potion" + } + }, + "entity_action": { + "type": "origins:gain_air", + "value": 60 + } +} diff --git a/origins/src/main/resources/data/origins/powers/aqua_affinity.json b/origins/src/main/resources/data/origins/powers/aqua_affinity.json new file mode 100644 index 000000000..a1a6621d3 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/aqua_affinity.json @@ -0,0 +1,47 @@ +{ + "type": "origins:multiple", + "underwater": { + "type": "origins:modify_break_speed", + "modifier": { + "amount": 4, + "operation": "multiply_total_multiplicative" + }, + "condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:submerged_in", + "fluid": "minecraft:water" + }, + { + "type": "origins:enchantment", + "enchantment": "minecraft:aqua_affinity", + "comparison": "==", + "compare_to": 0 + } + ] + } + }, + "ungrounded": { + "type": "origins:modify_break_speed", + "modifier": { + "amount": 4, + "operation": "multiply_total_multiplicative" + }, + "condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:fluid_height", + "fluid": "minecraft:water", + "comparison": ">", + "compare_to": 0 + }, + { + "type": "origins:on_block", + "inverted": true + } + ] + } + } +} diff --git a/origins/src/main/resources/data/origins/powers/aquatic.json b/origins/src/main/resources/data/origins/powers/aquatic.json new file mode 100644 index 000000000..d82dbd4af --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/aquatic.json @@ -0,0 +1,5 @@ +{ + "type": "origins:modify_type_tag", + "tag": "minecraft:aquatic", + "hidden": true +} diff --git a/origins/src/main/resources/data/origins/powers/arcane_skin.json b/origins/src/main/resources/data/origins/powers/arcane_skin.json new file mode 100644 index 000000000..fa33c689c --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/arcane_skin.json @@ -0,0 +1,6 @@ +{ + "type": "origins:model_color", + "red": 0.5, + "green": 0.5, + "alpha": 0.7 +} diff --git a/origins/src/main/resources/data/origins/powers/arthropod.json b/origins/src/main/resources/data/origins/powers/arthropod.json new file mode 100644 index 000000000..73acee99b --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/arthropod.json @@ -0,0 +1,5 @@ +{ + "type": "origins:modify_type_tag", + "tag": "minecraft:arthropod", + "hidden": true +} diff --git a/origins/src/main/resources/data/origins/powers/burn_in_daylight.json b/origins/src/main/resources/data/origins/powers/burn_in_daylight.json new file mode 100644 index 000000000..b9f3afd03 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/burn_in_daylight.json @@ -0,0 +1,17 @@ +{ + "type": "origins:burn", + "interval": 20, + "burn_duration": 6, + "condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:exposed_to_sun" + }, + { + "type": "origins:invisible", + "inverted": true + } + ] + } +} diff --git a/origins/src/main/resources/data/origins/powers/burning_wrath.json b/origins/src/main/resources/data/origins/powers/burning_wrath.json new file mode 100644 index 000000000..2c05bb549 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/burning_wrath.json @@ -0,0 +1,10 @@ +{ + "type": "origins:modify_damage_dealt", + "condition": { + "type": "origins:on_fire" + }, + "modifier": { + "amount": 3, + "operation": "add_base_early" + } +} diff --git a/origins/src/main/resources/data/origins/powers/carnivore.json b/origins/src/main/resources/data/origins/powers/carnivore.json new file mode 100644 index 000000000..a892c987e --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/carnivore.json @@ -0,0 +1,25 @@ +{ + "type": "origins:prevent_item_use", + "item_condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:ingredient", + "ingredient": { + "tag": "origins:ignore_diet" + }, + "inverted": true + }, + { + "type": "origins:ingredient", + "ingredient": { + "tag": "origins:meat" + }, + "inverted": true + }, + { + "type": "origins:food" + } + ] + } +} diff --git a/origins/src/main/resources/data/origins/powers/cat_vision.json b/origins/src/main/resources/data/origins/powers/cat_vision.json new file mode 100644 index 000000000..ac9867185 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/cat_vision.json @@ -0,0 +1,9 @@ +{ + "type": "origins:night_vision", + "strength": 0.4, + "condition": { + "type": "origins:submerged_in", + "fluid": "minecraft:water", + "inverted": true + } +} diff --git a/origins/src/main/resources/data/origins/powers/claustrophobia.json b/origins/src/main/resources/data/origins/powers/claustrophobia.json new file mode 100644 index 000000000..6dd48ec2d --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/claustrophobia.json @@ -0,0 +1,26 @@ +{ + "type": "origins:stacking_status_effect", + "min_stacks": -20, + "max_stacks": 361, + "duration_per_stack": 10, + "effects": [ + { + "id": "minecraft:weakness", + "ambient": true, + "show_particles": false, + "show_icon": true + }, + { + "id": "minecraft:slowness", + "ambient": true, + "show_particles": false, + "show_icon": true + } + ], + "condition": { + "type": "origins:block_collision", + "offset_x": 0, + "offset_y": 1, + "offset_z": 0 + } +} diff --git a/origins/src/main/resources/data/origins/powers/climbing.json b/origins/src/main/resources/data/origins/powers/climbing.json new file mode 100644 index 000000000..13c1b00ac --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/climbing.json @@ -0,0 +1,54 @@ +{ + "type": "origins:multiple", + "toggle": { + "type": "origins:toggle", + "key": { + "key": "key.origins.primary_active", + "continuous": false + } + }, + "climbing": { + "type": "origins:climbing", + "condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:power_active", + "power": "*:*_toggle" + }, + { + "type": "origins:or", + "conditions": [ + { + "type": "origins:sneaking", + "inverted": true + }, + { + "type": "origins:and", + "conditions": [ + { + "type": "origins:sneaking" + }, + { + "type": "origins:or", + "conditions": [ + { + "type": "origins:block_collision", + "offset_x": 0.01, + "offset_z": 0.01 + }, + { + "type": "origins:block_collision", + "offset_x": -0.01, + "offset_z": -0.01 + } + ] + } + ] + } + ] + } + ] + } + } +} diff --git a/origins/src/main/resources/data/origins/powers/conduit_power_on_land.json b/origins/src/main/resources/data/origins/powers/conduit_power_on_land.json new file mode 100644 index 000000000..928cfd107 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/conduit_power_on_land.json @@ -0,0 +1,4 @@ +{ + "type": "origins:simple", + "hidden": true +} diff --git a/origins/src/main/resources/data/origins/powers/damage_from_potions.json b/origins/src/main/resources/data/origins/powers/damage_from_potions.json new file mode 100644 index 000000000..d8f8851ba --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/damage_from_potions.json @@ -0,0 +1,15 @@ +{ + "type": "origins:action_on_item_use", + "hidden": true, + "item_condition": { + "type": "origins:ingredient", + "ingredient": { + "item": "minecraft:potion" + } + }, + "entity_action": { + "type": "origins:damage", + "amount": 2, + "damage_type": "origins:hurt_by_water" + } +} diff --git a/origins/src/main/resources/data/origins/powers/damage_from_snowballs.json b/origins/src/main/resources/data/origins/powers/damage_from_snowballs.json new file mode 100644 index 000000000..f1e2f58ee --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/damage_from_snowballs.json @@ -0,0 +1,12 @@ +{ + "type": "origins:modify_damage_taken", + "modifier": { + "amount": 3, + "operation": "add_base_early" + }, + "damage_condition": { + "type": "origins:projectile", + "projectile": "minecraft:snowball" + }, + "hidden": true +} diff --git a/origins/src/main/resources/data/origins/powers/elytra.json b/origins/src/main/resources/data/origins/powers/elytra.json new file mode 100644 index 000000000..cd5372dd8 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/elytra.json @@ -0,0 +1,4 @@ +{ + "type": "origins:elytra_flight", + "render_elytra": true +} diff --git a/origins/src/main/resources/data/origins/powers/end_spawn.json b/origins/src/main/resources/data/origins/powers/end_spawn.json new file mode 100644 index 000000000..503079432 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/end_spawn.json @@ -0,0 +1,5 @@ +{ + "type": "origins:modify_player_spawn", + "dimension": "the_end", + "spawn_strategy": "center" +} diff --git a/origins/src/main/resources/data/origins/powers/ender_particles.json b/origins/src/main/resources/data/origins/powers/ender_particles.json new file mode 100644 index 000000000..0346fa68d --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/ender_particles.json @@ -0,0 +1,6 @@ +{ + "type": "origins:particle", + "particle": "minecraft:portal", + "frequency": 4, + "hidden": true +} diff --git a/origins/src/main/resources/data/origins/powers/extra_reach.json b/origins/src/main/resources/data/origins/powers/extra_reach.json new file mode 100644 index 000000000..612227064 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/extra_reach.json @@ -0,0 +1,17 @@ +{ + "type": "origins:attribute", + "modifiers": [ + { + "id": "*:*", + "attribute": "minecraft:player.block_interaction_range", + "amount": 1.5, + "operation": "add_value" + }, + { + "id": "*:*", + "attribute": "minecraft:player.entity_interaction_range", + "amount": 1.5, + "operation": "add_value" + } + ] +} diff --git a/origins/src/main/resources/data/origins/powers/fall_immunity.json b/origins/src/main/resources/data/origins/powers/fall_immunity.json new file mode 100644 index 000000000..1f813d993 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/fall_immunity.json @@ -0,0 +1,7 @@ +{ + "type": "origins:invulnerability", + "damage_condition": { + "type": "origins:in_tag", + "tag": "minecraft:is_fall" + } +} diff --git a/origins/src/main/resources/data/origins/powers/fire_immunity.json b/origins/src/main/resources/data/origins/powers/fire_immunity.json new file mode 100644 index 000000000..09a8067c2 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/fire_immunity.json @@ -0,0 +1,6 @@ +{ + "type": "origins:invulnerability", + "damage_condition": { + "type": "origins:fire" + } +} diff --git a/origins/src/main/resources/data/origins/powers/flame_particles.json b/origins/src/main/resources/data/origins/powers/flame_particles.json new file mode 100644 index 000000000..e88dbb52d --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/flame_particles.json @@ -0,0 +1,6 @@ +{ + "type": "origins:particle", + "particle": "minecraft:flame", + "frequency": 4, + "hidden": true +} diff --git a/origins/src/main/resources/data/origins/powers/fragile.json b/origins/src/main/resources/data/origins/powers/fragile.json new file mode 100644 index 000000000..bf4599371 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/fragile.json @@ -0,0 +1,9 @@ +{ + "type": "origins:attribute", + "modifier": { + "id": "*:*", + "attribute": "minecraft:generic.max_health", + "amount": -6.0, + "operation": "add_value" + } +} diff --git a/origins/src/main/resources/data/origins/powers/fresh_air.json b/origins/src/main/resources/data/origins/powers/fresh_air.json new file mode 100644 index 000000000..331fcd2dd --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/fresh_air.json @@ -0,0 +1,11 @@ +{ + "type": "origins:prevent_sleep", + "block_condition": { + "type": "origins:height", + "comparison": "<", + "compare_to": 86 + }, + "message": { + "translate": "origins.avian_sleep_fail" + } +} diff --git a/origins/src/main/resources/data/origins/powers/hotblooded.json b/origins/src/main/resources/data/origins/powers/hotblooded.json new file mode 100644 index 000000000..e8ca9ef6c --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/hotblooded.json @@ -0,0 +1,7 @@ +{ + "type": "origins:effect_immunity", + "effects": [ + "minecraft:poison", + "minecraft:hunger" + ] +} diff --git a/origins/src/main/resources/data/origins/powers/hunger_over_time.json b/origins/src/main/resources/data/origins/powers/hunger_over_time.json new file mode 100644 index 000000000..9fe3d93b0 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/hunger_over_time.json @@ -0,0 +1,9 @@ +{ + "type": "origins:exhaust", + "interval": 20, + "exhaustion": 0.812, + "condition": { + "type": "origins:power_active", + "power": "*:phantomize" + } +} diff --git a/origins/src/main/resources/data/origins/powers/invisibility.json b/origins/src/main/resources/data/origins/powers/invisibility.json new file mode 100644 index 000000000..db5378876 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/invisibility.json @@ -0,0 +1,8 @@ +{ + "type": "origins:invisibility", + "render_armor": true, + "condition": { + "type": "origins:power_active", + "power": "*:phantomize" + } +} diff --git a/origins/src/main/resources/data/origins/powers/launch_into_air.json b/origins/src/main/resources/data/origins/powers/launch_into_air.json new file mode 100644 index 000000000..584b7d395 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/launch_into_air.json @@ -0,0 +1,14 @@ +{ + "type": "origins:launch", + "cooldown": 600, + "hud_render": { + "sprite_location": "origins:textures/gui/resource_bar.png", + "bar_index": 4 + }, + "sound": "minecraft:entity.parrot.fly", + "speed": 2, + "key": { + "key": "key.origins.primary_active", + "continuous": true + } +} diff --git a/origins/src/main/resources/data/origins/powers/lay_eggs.json b/origins/src/main/resources/data/origins/powers/lay_eggs.json new file mode 100644 index 000000000..b3500430f --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/lay_eggs.json @@ -0,0 +1,18 @@ +{ + "type": "origins:action_on_wake_up", + "entity_action": { + "type": "origins:and", + "actions": [ + { + "type": "origins:give", + "stack": { + "id": "minecraft:egg" + } + }, + { + "type": "origins:play_sound", + "sound": "minecraft:entity.chicken.egg" + } + ] + } +} diff --git a/origins/src/main/resources/data/origins/powers/light_armor.json b/origins/src/main/resources/data/origins/powers/light_armor.json new file mode 100644 index 000000000..3dc2abab5 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/light_armor.json @@ -0,0 +1,23 @@ +{ + "type": "origins:restrict_armor", + "head": { + "type": "origins:armor_value", + "comparison": ">", + "compare_to": 2 + }, + "chest": { + "type": "origins:armor_value", + "comparison": ">", + "compare_to": 5 + }, + "legs": { + "type": "origins:armor_value", + "comparison": ">", + "compare_to": 4 + }, + "feet": { + "type": "origins:armor_value", + "comparison": ">", + "compare_to": 1 + } +} diff --git a/origins/src/main/resources/data/origins/powers/like_air.json b/origins/src/main/resources/data/origins/powers/like_air.json new file mode 100644 index 000000000..e85383cab --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/like_air.json @@ -0,0 +1,6 @@ +{ + "type": "origins:attribute_modify_transfer", + "class": "modify_air_speed", + "attribute": "minecraft:generic.movement_speed", + "multiplier": 1 +} diff --git a/origins/src/main/resources/data/origins/powers/like_water.json b/origins/src/main/resources/data/origins/powers/like_water.json new file mode 100644 index 000000000..ace52e07c --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/like_water.json @@ -0,0 +1,3 @@ +{ + "type": "origins:simple" +} diff --git a/origins/src/main/resources/data/origins/powers/master_of_webs.json b/origins/src/main/resources/data/origins/powers/master_of_webs.json new file mode 100644 index 000000000..21150237c --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/master_of_webs.json @@ -0,0 +1,117 @@ +{ + "type": "origins:multiple", + "webbing": { + "type": "origins:target_action_on_hit", + "cooldown": 120, + "hud_render": { + "sprite_location": "origins:textures/gui/resource_bar.png", + "bar_index": 5 + }, + "entity_action": { + "type": "origins:block_action_at", + "block_action": { + "type": "origins:if_else", + "condition": { + "type": "origins:replaceable" + }, + "if_action": { + "type": "origins:set_block", + "block": "minecraft:cobweb" + } + } + }, + "condition": { + "type": "origins:sneaking", + "inverted": true + } + }, + "no_slowdown": { + "type": "origins:phasing", + "block_condition": { + "type": "origins:in_tag", + "tag": "origins:cobwebs" + }, + "render_type": "none" + }, + "climbing": { + "type": "origins:climbing", + "condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:in_block_anywhere", + "block_condition": { + "type": "origins:in_tag", + "tag": "origins:cobwebs" + } + }, + { + "type": "origins:power_active", + "power": "*:climbing_toggle" + } + ] + }, + "hold_condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:power_active", + "power": "*:*_climbing" + }, + { + "type": "origins:sneaking", + "inverted": true + } + ] + } + }, + "punch_through": { + "type": "origins:prevent_block_selection", + "block_condition": { + "type": "origins:in_tag", + "tag": "origins:cobwebs" + }, + "condition": { + "type": "origins:sneaking", + "inverted": true + } + }, + "sense": { + "type": "origins:entity_glow", + "entity_condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:in_block_anywhere", + "block_condition": { + "type": "origins:in_tag", + "tag": "origins:cobwebs" + } + }, + { + "type": "origins:in_tag", + "tag": "arthropod", + "inverted": true + } + ] + } + }, + "web_crafting": { + "type": "origins:recipe", + "recipe": { + "id": "origins:master_of_webs/web_crafting", + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "minecraft:string" + }, + { + "item": "minecraft:string" + } + ], + "result": { + "id": "minecraft:cobweb" + } + } + } +} diff --git a/origins/src/main/resources/data/origins/powers/more_exhaustion.json b/origins/src/main/resources/data/origins/powers/more_exhaustion.json new file mode 100644 index 000000000..feed568f0 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/more_exhaustion.json @@ -0,0 +1,7 @@ +{ + "type": "origins:modify_exhaustion", + "modifier": { + "amount": 0.6, + "operation": "multiply_base_multiplicative" + } +} diff --git a/origins/src/main/resources/data/origins/powers/more_kinetic_damage.json b/origins/src/main/resources/data/origins/powers/more_kinetic_damage.json new file mode 100644 index 000000000..ec13f35bf --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/more_kinetic_damage.json @@ -0,0 +1,11 @@ +{ + "type": "origins:modify_damage_taken", + "modifier": { + "amount": 0.5, + "operation": "multiply_base_multiplicative" + }, + "damage_condition": { + "type": "origins:in_tag", + "tag": "*:kinetic" + } +} diff --git a/origins/src/main/resources/data/origins/powers/natural_armor.json b/origins/src/main/resources/data/origins/powers/natural_armor.json new file mode 100644 index 000000000..5713faced --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/natural_armor.json @@ -0,0 +1,9 @@ +{ + "type": "origins:attribute", + "modifier": { + "id": "*:*", + "attribute": "minecraft:generic.armor", + "amount": 8.0, + "operation": "add_value" + } +} diff --git a/origins/src/main/resources/data/origins/powers/nether_spawn.json b/origins/src/main/resources/data/origins/powers/nether_spawn.json new file mode 100644 index 000000000..be8a0e2b9 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/nether_spawn.json @@ -0,0 +1,6 @@ +{ + "type": "origins:modify_player_spawn", + "dimension": "the_nether", + "dimension_distance_multiplier": 0.125, + "spawn_strategy": "center" +} diff --git a/origins/src/main/resources/data/origins/powers/nine_lives.json b/origins/src/main/resources/data/origins/powers/nine_lives.json new file mode 100644 index 000000000..38f892ba0 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/nine_lives.json @@ -0,0 +1,9 @@ +{ + "type": "origins:attribute", + "modifier": { + "id": "*:*", + "attribute": "minecraft:generic.max_health", + "amount": -2.0, + "operation": "add_value" + } +} diff --git a/origins/src/main/resources/data/origins/powers/no_cobweb_slowdown.json b/origins/src/main/resources/data/origins/powers/no_cobweb_slowdown.json new file mode 100644 index 000000000..e2979e777 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/no_cobweb_slowdown.json @@ -0,0 +1,9 @@ +{ + "type": "origins:phasing", + "block_condition": { + "type": "origins:in_tag", + "tag": "origins:cobwebs" + }, + "render_type": "none", + "hidden": true +} diff --git a/origins/src/main/resources/data/origins/powers/no_shield.json b/origins/src/main/resources/data/origins/powers/no_shield.json new file mode 100644 index 000000000..be7b45e1f --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/no_shield.json @@ -0,0 +1,9 @@ +{ + "type": "origins:prevent_item_use", + "item_condition": { + "type": "origins:ingredient", + "ingredient": { + "tag": "origins:shields" + } + } +} diff --git a/origins/src/main/resources/data/origins/powers/phantomize.json b/origins/src/main/resources/data/origins/powers/phantomize.json new file mode 100644 index 000000000..c91bb74ca --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/phantomize.json @@ -0,0 +1,13 @@ +{ + "type": "origins:toggle", + "key": { + "key": "key.origins.primary_active", + "continuous": false + }, + "retain_state": false, + "condition": { + "type": "apoli:food_level", + "comparison": ">", + "compare_to": 6 + } +} diff --git a/origins/src/main/resources/data/origins/powers/phantomize_callback.json b/origins/src/main/resources/data/origins/powers/phantomize_callback.json new file mode 100644 index 000000000..3a800d352 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/phantomize_callback.json @@ -0,0 +1,16 @@ +{ + "type": "origins:action_on_callback", + "entity_action_respawned": { + "type": "origins:if_else", + "condition": { + "type": "origins:power_active", + "power": "origins:phantomize", + "inverted": true + }, + "if_action": { + "type": "origins:toggle", + "power": "origins:phantomize" + } + }, + "hidden": true +} diff --git a/origins/src/main/resources/data/origins/powers/phantomize_overlay.json b/origins/src/main/resources/data/origins/powers/phantomize_overlay.json new file mode 100644 index 000000000..5df913895 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/phantomize_overlay.json @@ -0,0 +1,17 @@ +{ + "type": "apoli:overlay", + "hidden": true, + "sprite": "*:*", + "red": 0.4, + "green": 0.2, + "blue": 0.2, + "strength": 0.7, + "draw_mode": "nausea", + "draw_phase": "above_hud", + "visible_in_third_person": true, + "hide_with_hud": true, + "condition": { + "type": "apoli:power_active", + "power": "origins:phantomize" + } +} diff --git a/origins/src/main/resources/data/origins/powers/phasing.json b/origins/src/main/resources/data/origins/powers/phasing.json new file mode 100644 index 000000000..c2f17f39d --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/phasing.json @@ -0,0 +1,25 @@ +{ + "type": "origins:phasing", + "blacklist": true, + "render_type": "blindness", + "view_distance": 10, + "block_condition": { + "type": "origins:in_tag", + "tag": "origins:unphasable" + }, + "phase_down_condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:sneaking" + }, + { + "type": "origins:on_block" + } + ] + }, + "condition": { + "type": "origins:power_active", + "power": "*:phantomize" + } +} diff --git a/origins/src/main/resources/data/origins/powers/pumpkin_hate.json b/origins/src/main/resources/data/origins/powers/pumpkin_hate.json new file mode 100644 index 000000000..1341debf4 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/pumpkin_hate.json @@ -0,0 +1,38 @@ +{ + "type": "origins:multiple", + "prevent_eating": { + "type": "origins:prevent_item_use", + "item_condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:food" + }, + { + "type": "origins:ingredient", + "ingredient": { + "tag": "*:pumpkin_like/food" + } + } + ] + }, + "name": "power.origins.pumpkin_hate.name" + }, + "prevent_seeing": { + "type": "origins:prevent_entity_render", + "bientity_condition": { + "type": "apoli:equal", + "inverted": true + }, + "entity_condition": { + "type": "origins:equipped_item", + "equipment_slot": "head", + "item_condition": { + "type": "origins:ingredient", + "ingredient": { + "tag": "*:pumpkin_like/equipment" + } + } + } + } +} diff --git a/origins/src/main/resources/data/origins/powers/scare_creepers.json b/origins/src/main/resources/data/origins/powers/scare_creepers.json new file mode 100644 index 000000000..ace52e07c --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/scare_creepers.json @@ -0,0 +1,3 @@ +{ + "type": "origins:simple" +} diff --git a/origins/src/main/resources/data/origins/powers/shulker_inventory.json b/origins/src/main/resources/data/origins/powers/shulker_inventory.json new file mode 100644 index 000000000..f24ec2889 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/shulker_inventory.json @@ -0,0 +1,9 @@ +{ + "type": "origins:inventory", + "title": "container.shulker_inventory_power", + "drop_on_death": false, + "key": { + "key": "key.origins.primary_active", + "continuous": false + } +} diff --git a/origins/src/main/resources/data/origins/powers/slow_falling.json b/origins/src/main/resources/data/origins/powers/slow_falling.json new file mode 100644 index 000000000..31d7592a0 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/slow_falling.json @@ -0,0 +1,34 @@ +{ + "type": "apoli:modify_falling", + "velocity": 0.01, + "take_fall_damage": false, + "condition": { + "type": "origins:or", + "conditions": [ + { + "type": "origins:and", + "conditions": [ + { + "type": "origins:sneaking" + }, + { + "type": "origins:fall_flying" + } + ] + }, + { + "type": "origins:and", + "conditions": [ + { + "type": "origins:sneaking", + "inverted": true + }, + { + "type": "origins:fall_flying", + "inverted": true + } + ] + } + ] + } +} diff --git a/origins/src/main/resources/data/origins/powers/sprint_jump.json b/origins/src/main/resources/data/origins/powers/sprint_jump.json new file mode 100644 index 000000000..86cc7a798 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/sprint_jump.json @@ -0,0 +1,10 @@ +{ + "type": "origins:modify_jump", + "modifier": { + "amount": 0.5, + "operation": "multiply_base_multiplicative" + }, + "condition": { + "type": "origins:sprinting" + } +} diff --git a/origins/src/main/resources/data/origins/powers/strong_arms.json b/origins/src/main/resources/data/origins/powers/strong_arms.json new file mode 100644 index 000000000..737a1fcb5 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/strong_arms.json @@ -0,0 +1,8 @@ +{ + "type": "origins:modify_harvest", + "allow": true, + "block_condition": { + "type": "origins:in_tag", + "tag": "origins:natural_stone" + } +} diff --git a/origins/src/main/resources/data/origins/powers/strong_arms_break_speed.json b/origins/src/main/resources/data/origins/powers/strong_arms_break_speed.json new file mode 100644 index 000000000..be20f5266 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/strong_arms_break_speed.json @@ -0,0 +1,16 @@ +{ + "type": "origins:modify_break_speed", + "block_condition": { + "type": "origins:in_tag", + "tag": "origins:natural_stone" + }, + "condition": { + "type": "origins:using_effective_tool", + "inverted": true + }, + "modifier": { + "amount": 0.06, + "operation": "add_base_early" + }, + "hidden": true +} diff --git a/origins/src/main/resources/data/origins/powers/swim_speed.json b/origins/src/main/resources/data/origins/powers/swim_speed.json new file mode 100644 index 000000000..206f0efc1 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/swim_speed.json @@ -0,0 +1,7 @@ +{ + "type": "origins:modify_swim_speed", + "modifier": { + "operation": "addition", + "amount": 1.5 + } +} \ No newline at end of file diff --git a/origins/src/main/resources/data/origins/powers/tailwind.json b/origins/src/main/resources/data/origins/powers/tailwind.json new file mode 100644 index 000000000..511d0e8f0 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/tailwind.json @@ -0,0 +1,9 @@ +{ + "type": "origins:attribute", + "modifier": { + "id": "*:*", + "attribute": "minecraft:generic.movement_speed", + "amount": 0.2, + "operation": "add_multiplied_base" + } +} diff --git a/origins/src/main/resources/data/origins/powers/throw_ender_pearl.json b/origins/src/main/resources/data/origins/powers/throw_ender_pearl.json new file mode 100644 index 000000000..f6a8d148f --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/throw_ender_pearl.json @@ -0,0 +1,16 @@ +{ + "type": "origins:fire_projectile", + "cooldown": 30, + "hud_render": { + "sprite_location": "origins:textures/gui/resource_bar.png", + "bar_index": 6 + }, + "entity_type": "origins:enderian_pearl", + "sound": "minecraft:entity.ender_pearl.throw", + "speed": 1.5, + "divergence": 1, + "key": { + "key": "key.origins.primary_active", + "continuous": false + } +} diff --git a/origins/src/main/resources/data/origins/powers/translucent.json b/origins/src/main/resources/data/origins/powers/translucent.json new file mode 100644 index 000000000..c4969b01c --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/translucent.json @@ -0,0 +1,4 @@ +{ + "type": "origins:model_color", + "alpha": 0.5 +} diff --git a/origins/src/main/resources/data/origins/powers/vegetarian.json b/origins/src/main/resources/data/origins/powers/vegetarian.json new file mode 100644 index 000000000..97c01023d --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/vegetarian.json @@ -0,0 +1,24 @@ +{ + "type": "origins:prevent_item_use", + "item_condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:ingredient", + "ingredient": { + "tag": "origins:ignore_diet" + }, + "inverted": true + }, + { + "type": "origins:ingredient", + "ingredient": { + "tag": "origins:meat" + } + }, + { + "type": "origins:food" + } + ] + } +} diff --git a/origins/src/main/resources/data/origins/powers/velvet_paws.json b/origins/src/main/resources/data/origins/powers/velvet_paws.json new file mode 100644 index 000000000..5fd4ea4d5 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/velvet_paws.json @@ -0,0 +1,4 @@ +{ + "type": "origins:prevent_game_event", + "event": "minecraft:step" +} diff --git a/origins/src/main/resources/data/origins/powers/water_breathing.json b/origins/src/main/resources/data/origins/powers/water_breathing.json new file mode 100644 index 000000000..ace52e07c --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/water_breathing.json @@ -0,0 +1,3 @@ +{ + "type": "origins:simple" +} diff --git a/origins/src/main/resources/data/origins/powers/water_vision.json b/origins/src/main/resources/data/origins/powers/water_vision.json new file mode 100644 index 000000000..c9bfe341c --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/water_vision.json @@ -0,0 +1,28 @@ +{ + "type": "origins:multiple", + "toggle": { + "type": "origins:toggle", + "active_by_default": true, + "key": { + "key": "key.origins.primary_active", + "continuous": false + } + }, + "night_vision": { + "type": "origins:night_vision", + "strength": 1.0, + "condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:power_active", + "power": "*:*_toggle" + }, + { + "type": "origins:submerged_in", + "fluid": "minecraft:water" + } + ] + } + } +} diff --git a/origins/src/main/resources/data/origins/powers/water_vulnerability.json b/origins/src/main/resources/data/origins/powers/water_vulnerability.json new file mode 100644 index 000000000..85eb06351 --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/water_vulnerability.json @@ -0,0 +1,24 @@ +{ + "type": "origins:damage_over_time", + "interval": 20, + "onset_delay": 1, + "damage": 2, + "damage_easy": 1, + "damage_type": "origins:hurt_by_water", + "protection_enchantment": "origins:water_protection", + "protection_effectiveness": 1.0, + "condition": { + "type": "origins:or", + "conditions": [ + { + "type": "origins:fluid_height", + "fluid": "minecraft:water", + "comparison": ">", + "compare_to": 0.0 + }, + { + "type": "origins:in_rain" + } + ] + } +} diff --git a/origins/src/main/resources/data/origins/powers/weak_arms.json b/origins/src/main/resources/data/origins/powers/weak_arms.json new file mode 100644 index 000000000..5c125e30e --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/weak_arms.json @@ -0,0 +1,30 @@ +{ + "type": "origins:modify_break_speed", + "modifier": { + "amount": -1, + "operation": "multiply_total_multiplicative" + }, + "block_condition": { + "type": "origins:and", + "conditions": [ + { + "type": "origins:in_tag", + "tag": "origins:natural_stone" + }, + { + "type": "origins:adjacent", + "adjacent_condition": { + "type": "origins:in_tag", + "tag": "origins:natural_stone" + }, + "comparison": ">", + "compare_to": 2 + } + ] + }, + "condition": { + "type": "origins:status_effect", + "effect": "minecraft:strength", + "inverted": true + } +} diff --git a/origins/src/main/resources/data/origins/powers/webbing.json b/origins/src/main/resources/data/origins/powers/webbing.json new file mode 100644 index 000000000..90bae92cc --- /dev/null +++ b/origins/src/main/resources/data/origins/powers/webbing.json @@ -0,0 +1,8 @@ +{ + "type": "origins:cooldown", + "cooldown": 120, + "hud_render": { + "sprite_location": "origins:textures/gui/resource_bar.png", + "bar_index": 5 + } +} diff --git a/origins/src/main/resources/data/origins/tags/block/cobwebs.json b/origins/src/main/resources/data/origins/tags/block/cobwebs.json new file mode 100644 index 000000000..f27e53ed7 --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/block/cobwebs.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "minecraft:cobweb" + ] +} diff --git a/origins/src/main/resources/data/origins/tags/block/natural_stone.json b/origins/src/main/resources/data/origins/tags/block/natural_stone.json new file mode 100644 index 000000000..cf0574f7f --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/block/natural_stone.json @@ -0,0 +1,11 @@ +{ + "replace": false, + "values": [ + "#minecraft:base_stone_overworld", + "#minecraft:base_stone_nether", + "minecraft:sandstone", + "minecraft:smooth_sandstone", + "minecraft:red_sandstone", + "minecraft:smooth_red_sandstone" + ] +} diff --git a/origins/src/main/resources/data/origins/tags/block/unphasable.json b/origins/src/main/resources/data/origins/tags/block/unphasable.json new file mode 100644 index 000000000..c94e00c81 --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/block/unphasable.json @@ -0,0 +1,9 @@ +{ + "replace": false, + "values": [ + "minecraft:barrier", + "minecraft:bedrock", + "minecraft:crying_obsidian", + "minecraft:obsidian" + ] +} diff --git a/origins/src/main/resources/data/origins/tags/damage_type/kinetic.json b/origins/src/main/resources/data/origins/tags/damage_type/kinetic.json new file mode 100644 index 000000000..281b5403c --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/damage_type/kinetic.json @@ -0,0 +1,6 @@ +{ + "values": [ + "#minecraft:is_fall", + "minecraft:fly_into_wall" + ] +} diff --git a/origins/src/main/resources/data/origins/tags/enchantment/exclusive_set/water_protection.json b/origins/src/main/resources/data/origins/tags/enchantment/exclusive_set/water_protection.json new file mode 100644 index 000000000..f8e7f79f1 --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/enchantment/exclusive_set/water_protection.json @@ -0,0 +1,9 @@ +{ + "values": [ + "origins:water_protection", + "minecraft:blast_protection", + "minecraft:fire_protection", + "minecraft:projectile_protection", + "minecraft:protection" + ] +} diff --git a/origins/src/main/resources/data/origins/tags/item/ignore_diet.json b/origins/src/main/resources/data/origins/tags/item/ignore_diet.json new file mode 100644 index 000000000..c79708b8c --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/item/ignore_diet.json @@ -0,0 +1,4 @@ +{ + "replace": false, + "values": [] +} diff --git a/origins/src/main/resources/data/origins/tags/item/meat.json b/origins/src/main/resources/data/origins/tags/item/meat.json new file mode 100644 index 000000000..ba8b36e89 --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/item/meat.json @@ -0,0 +1,14 @@ +{ + "replace": false, + "values": [ + "#minecraft:meat", + "minecraft:cod", + "minecraft:tropical_fish", + "minecraft:pufferfish", + "minecraft:salmon", + "minecraft:rabbit_stew", + "minecraft:cooked_cod", + "minecraft:cooked_salmon", + "minecraft:spider_eye" + ] +} diff --git a/origins/src/main/resources/data/origins/tags/item/pumpkin_like/equipment.json b/origins/src/main/resources/data/origins/tags/item/pumpkin_like/equipment.json new file mode 100644 index 000000000..e74b59e53 --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/item/pumpkin_like/equipment.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:carved_pumpkin" + ] +} diff --git a/origins/src/main/resources/data/origins/tags/item/pumpkin_like/food.json b/origins/src/main/resources/data/origins/tags/item/pumpkin_like/food.json new file mode 100644 index 000000000..5578cd989 --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/item/pumpkin_like/food.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:pumpkin_pie" + ] +} diff --git a/origins/src/main/resources/data/origins/tags/item/ranged_weapons.json b/origins/src/main/resources/data/origins/tags/item/ranged_weapons.json new file mode 100644 index 000000000..c2a7e65a7 --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/item/ranged_weapons.json @@ -0,0 +1,8 @@ +{ + "replace": false, + "values": [ + "minecraft:bow", + "minecraft:crossbow", + "minecraft:trident" + ] +} diff --git a/origins/src/main/resources/data/origins/tags/item/shields.json b/origins/src/main/resources/data/origins/tags/item/shields.json new file mode 100644 index 000000000..6a785f004 --- /dev/null +++ b/origins/src/main/resources/data/origins/tags/item/shields.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "minecraft:shield" + ] +} diff --git a/origins/src/main/resources/minecraft/datapack/data/minecraft/tags/damage_type/bypasses_armor.json b/origins/src/main/resources/minecraft/datapack/data/minecraft/tags/damage_type/bypasses_armor.json deleted file mode 100644 index 7ec1ac2df..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/minecraft/tags/damage_type/bypasses_armor.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "replace": false, - "values": [ - "origins:no_water_for_gills", - "origins:hurt_by_water" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/minecraft/tags/damage_type/bypasses_shield.json b/origins/src/main/resources/minecraft/datapack/data/minecraft/tags/damage_type/bypasses_shield.json deleted file mode 100644 index 7ec1ac2df..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/minecraft/tags/damage_type/bypasses_shield.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "replace": false, - "values": [ - "origins:no_water_for_gills", - "origins:hurt_by_water" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/minecraft/tags/damage_type/no_knockback.json b/origins/src/main/resources/minecraft/datapack/data/minecraft/tags/damage_type/no_knockback.json deleted file mode 100644 index 68501a01c..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/minecraft/tags/damage_type/no_knockback.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "values": [ - "origins:hurt_by_water", - "origins:no_water_for_gills" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/damage_type/hurt_by_water.json b/origins/src/main/resources/minecraft/datapack/data/origins/damage_type/hurt_by_water.json deleted file mode 100644 index f1a326e73..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/damage_type/hurt_by_water.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "exhaustion": 0.1, - "message_id": "hurt_by_water", - "scaling": "never" -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/damage_type/no_water_for_gills.json b/origins/src/main/resources/minecraft/datapack/data/origins/damage_type/no_water_for_gills.json deleted file mode 100644 index 697da8a72..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/damage_type/no_water_for_gills.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "exhaustion": 0.1, - "message_id": "no_water_for_gills", - "scaling": "never" -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/enchantment/water_protection.json b/origins/src/main/resources/minecraft/datapack/data/origins/enchantment/water_protection.json deleted file mode 100644 index 4959ed760..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/enchantment/water_protection.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "description": { - "text": "Water Protection" - }, - "exclusive_set": "#origins:exclusive_set/water_protection", - "supported_items": "#minecraft:enchantable/armor", - "primary_items": [], - "weight": 1, - "max_level": 4, - "min_cost": { - "base": 8, - "per_level_above_first": 4 - }, - "max_cost": { - "base": 32, - "per_level_above_first": 4 - }, - "anvil_cost": 4, - "slots": [ - "armor" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/block/cobwebs.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/block/cobwebs.json deleted file mode 100644 index cdc1c9164..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/block/cobwebs.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:cobweb" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/block/natural_stone.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/block/natural_stone.json deleted file mode 100644 index 51db763f4..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/block/natural_stone.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "replace": false, - "values": [ - "#minecraft:base_stone_overworld", - "#minecraft:base_stone_nether", - "minecraft:sandstone", - "minecraft:smooth_sandstone", - "minecraft:red_sandstone", - "minecraft:smooth_red_sandstone" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/block/unphasable.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/block/unphasable.json deleted file mode 100644 index b985cfd96..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/block/unphasable.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:barrier", - "minecraft:bedrock", - "minecraft:crying_obsidian", - "minecraft:obsidian" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/damage_type/kinetic.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/damage_type/kinetic.json deleted file mode 100644 index c1a2bae30..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/damage_type/kinetic.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "values": [ - "#minecraft:is_fall", - "minecraft:fly_into_wall" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/enchantment/exclusive_set/water_protection.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/enchantment/exclusive_set/water_protection.json deleted file mode 100644 index 223c736a4..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/enchantment/exclusive_set/water_protection.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "values": [ - "origins:water_protection", - "minecraft:blast_protection", - "minecraft:fire_protection", - "minecraft:projectile_protection", - "minecraft:protection" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/ignore_diet.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/ignore_diet.json deleted file mode 100644 index 5d341ba24..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/ignore_diet.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "replace": false, - "values": [] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/meat.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/meat.json deleted file mode 100644 index 78c15199e..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/meat.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "replace": false, - "values": [ - "#minecraft:meat", - "minecraft:cod", - "minecraft:tropical_fish", - "minecraft:pufferfish", - "minecraft:salmon", - "minecraft:rabbit_stew", - "minecraft:cooked_cod", - "minecraft:cooked_salmon", - "minecraft:spider_eye" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/pumpkin_like/equipment.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/pumpkin_like/equipment.json deleted file mode 100644 index bd9a3fa2b..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/pumpkin_like/equipment.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "values": [ - "minecraft:carved_pumpkin" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/pumpkin_like/food.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/pumpkin_like/food.json deleted file mode 100644 index 5956ae9db..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/pumpkin_like/food.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "values": [ - "minecraft:pumpkin_pie" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/ranged_weapons.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/ranged_weapons.json deleted file mode 100644 index b471f3527..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/ranged_weapons.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:bow", - "minecraft:crossbow", - "minecraft:trident" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/shields.json b/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/shields.json deleted file mode 100644 index 4e0d88479..000000000 --- a/origins/src/main/resources/minecraft/datapack/data/origins/tags/item/shields.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:shield" - ] -} diff --git a/origins/src/main/resources/minecraft/datapack/pack.mcmeta b/origins/src/main/resources/minecraft/datapack/pack.mcmeta deleted file mode 100644 index be5df4083..000000000 --- a/origins/src/main/resources/minecraft/datapack/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "pack_format": 18, - "description": "OriginsPaper - Custom Origins for PaperMC" - } -} diff --git a/origins/src/main/resources/paper-plugin.yml b/origins/src/main/resources/paper-plugin.yml index fc4e5c036..1b3661cc7 100644 --- a/origins/src/main/resources/paper-plugin.yml +++ b/origins/src/main/resources/paper-plugin.yml @@ -2,9 +2,7 @@ bootstrapper: "io.github.dueris.originspaper.Bootstrap" loader: "io.github.dueris.originspaper.DependencyLoader" load: POSTWORLD name: "OriginsPaper" -version: "${fullVer}" -main: "io.github.dueris.originspaper.OriginsPaper" -api-version: "${apiVer}" +main: "io.github.dueris.originspaper.plugin.OriginsPlugin" authors: [ Dueris ] folia-supported: false description: "A port of the Origins mod to PaperMC servers with Custom Origins support" @@ -15,5 +13,10 @@ dependencies: load: BEFORE required: false -supportedVersions: ${supportedVersions} +supported: ${supported} +minecraft: ${mcVer} +plugin: ${pluginVer} +api-version: ${apiVer} +version: ${fullVer} +apoli: ${apoli} default-language: "en_us" \ No newline at end of file