diff options
author | Luck <git@lucko.me> | 2024-07-20 20:58:36 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2024-07-20 20:58:36 +0100 |
commit | 635800af986351f08dba33aa2e8ec5dd691bbffb (patch) | |
tree | fe5512d62e0c45df64a11ac79347010534d90bc4 /spark-api/src/main | |
parent | c0ffb19c40b2397d099b960aa0545dafd4b2525d (diff) | |
download | spark-635800af986351f08dba33aa2e8ec5dd691bbffb.tar.gz spark-635800af986351f08dba33aa2e8ec5dd691bbffb.tar.bz2 spark-635800af986351f08dba33aa2e8ec5dd691bbffb.zip |
Add placeholder resolver API
Diffstat (limited to 'spark-api/src/main')
-rw-r--r-- | spark-api/src/main/java/me/lucko/spark/api/Spark.java | 9 | ||||
-rw-r--r-- | spark-api/src/main/java/me/lucko/spark/api/placeholder/PlaceholderResolver.java | 54 |
2 files changed, 63 insertions, 0 deletions
diff --git a/spark-api/src/main/java/me/lucko/spark/api/Spark.java b/spark-api/src/main/java/me/lucko/spark/api/Spark.java index af71ab6..a5f20d6 100644 --- a/spark-api/src/main/java/me/lucko/spark/api/Spark.java +++ b/spark-api/src/main/java/me/lucko/spark/api/Spark.java @@ -26,6 +26,7 @@ package me.lucko.spark.api; import me.lucko.spark.api.gc.GarbageCollector; +import me.lucko.spark.api.placeholder.PlaceholderResolver; import me.lucko.spark.api.statistic.misc.DoubleAverageInfo; import me.lucko.spark.api.statistic.types.DoubleStatistic; import me.lucko.spark.api.statistic.types.GenericStatistic; @@ -83,4 +84,12 @@ public interface Spark { */ @NonNull @Unmodifiable Map<String, GarbageCollector> gc(); + /** + * Gets a placeholder resolver. + * + * @return a placeholder resolver + */ + @NonNull + PlaceholderResolver placeholders(); + } diff --git a/spark-api/src/main/java/me/lucko/spark/api/placeholder/PlaceholderResolver.java b/spark-api/src/main/java/me/lucko/spark/api/placeholder/PlaceholderResolver.java new file mode 100644 index 0000000..20834cb --- /dev/null +++ b/spark-api/src/main/java/me/lucko/spark/api/placeholder/PlaceholderResolver.java @@ -0,0 +1,54 @@ +/* + * This file is part of spark, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) <luck@lucko.me> + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.spark.api.placeholder; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + +/** + * Resolves spark placeholders. + * + * <p>See <a href="https://spark.lucko.me/docs/misc/Placeholders">spark docs</a> for more info.</p> + */ +public interface PlaceholderResolver { + + /** + * Resolves the given placeholder to a legacy formatted string. + * + * @param placeholder the placeholder to resolve + * @return the resolved placeholder + */ + @Nullable String resolveLegacyFormatting(@NonNull String placeholder); + + /** + * Resolves the given placeholder to a text component serialised to json. + * + * @param placeholder the placeholder to resolve + * @return the resolved placeholder + */ + @Nullable String resolveComponentJson(@NonNull String placeholder); + +} |