Compare commits

...
Author SHA1 Message Date
renovate[bot] 4a6a616211 chore(deps): update dependency io.papermc.paperweight.userdev to v1.7.1 2024-05-11 23:18:37 +00:00
Adrian 3808fc9d89 Add LegacyUtils methods to check if a string contains legacy characters (#191)
* feat: Add LegacyUtils methods to check if a string contains legacy characters

* chore: Rename to #mapLegacyOrElse
2024-03-03 15:48:43 -05:00
renovate[bot] a7cc73fe7d fix(deps): update dependency net.kyori:adventure-platform-fabric to v5.12.0 (#189)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-28 22:27:16 -05:00
renovate[bot] 8ac0c398d7 chore(deps): update plugin fabric-loom to v1.5.8 (#190)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-28 22:27:07 -05:00
renovate[bot] 25618c0d42 fix(deps): update dependency net.fabricmc.fabric-api:fabric-api to v0.96.4+1.20.5 (#187)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-28 22:27:00 -05:00
renovate[bot] 9b61e8efa0 fix(deps): update dependency net.fabricmc.fabric-api:fabric-api to v0.96.2+1.20.5 (#177)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-17 09:37:01 -05:00
renovate[bot] ad95e239bc fix(deps): update dependency net.fabricmc:fabric-loader to v0.15.7 (#184)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-15 12:14:09 -05:00
powercas_gamer d18ff640d2 feat(api): expansion metadata (#185)
* feat(api): expansion metadata

* more

* actually expose it

* javadoc

* oopsie whoopsie import

* change javadoc version
2024-02-15 12:13:47 -05:00
Adrian 7536d32055 Merge pull request #182 from MiniPlaceholders/renovate/runtask
chore(deps): update dependency xyz.jpenilla.run-velocity to v2.2.3
2024-02-04 15:14:01 -05:00
Adrian 5dffb9c251 Merge pull request #183 from MiniPlaceholders/renovate/junit5-monorepo
fix(deps): update dependency org.junit:junit-bom to v5.10.2
2024-02-04 15:13:54 -05:00
renovate[bot] e75baceb77 fix(deps): update dependency org.junit:junit-bom to v5.10.2 2024-02-04 11:23:07 +00:00
Adrian f2c6aa08f4 release: Version 2.2.4 2024-02-03 22:06:57 -05:00
Adrian 7727dca940 misc: Removed old Krypton module sources 2024-02-03 21:57:41 -05:00
Adrian 151b2dc2a4 misc: Deprecated TagsUtils#staticTag 2024-02-03 21:57:06 -05:00
renovate[bot] 16e3d09204 chore(deps): update runtask to v2.2.3 2024-02-04 02:55:42 +00:00
Adrian 62c11dd84a Merge pull request #176 from MiniPlaceholders/renovate/fabric.loader
fix(deps): update dependency net.fabricmc:fabric-loader to v0.15.6
2024-02-03 21:54:18 -05:00
Adrian 77913be0fa Merge pull request #178 from MiniPlaceholders/renovate/fabric-loom-1.x
chore(deps): update plugin fabric-loom to v1.5.7
2024-02-03 21:54:03 -05:00
Adrian 685f67146d Merge pull request #179 from MiniPlaceholders/renovate/adventurefabric
fix(deps): update dependency net.kyori:adventure-platform-fabric to v5.11.0
2024-02-03 21:53:56 -05:00
Adrian 6f524b056a Merge pull request #180 from MiniPlaceholders/renovate/nick-invision-retry-3.x
chore(deps): update nick-invision/retry action to v3
2024-02-03 21:53:50 -05:00
Adrian 36f1cce813 Merge pull request #181 from MiniPlaceholders/renovate/gradle-8.x
chore(deps): update dependency gradle to v8.6
2024-02-03 21:53:43 -05:00
renovate[bot] 4061c8acbe chore(deps): update dependency gradle to v8.6 2024-02-02 18:22:06 +00:00
renovate[bot] 319731cef0 chore(deps): update nick-invision/retry action to v3 2024-01-31 18:53:24 +00:00
renovate[bot] 9e29afa9c5 chore(deps): update plugin fabric-loom to v1.5.7 2024-01-25 09:35:54 +00:00
renovate[bot] 9655509c2f fix(deps): update dependency net.kyori:adventure-platform-fabric to v5.11.0 2024-01-21 07:40:06 +00:00
renovate[bot] 26f1042d17 fix(deps): update dependency net.fabricmc:fabric-loader to v0.15.6 2024-01-18 03:44:36 +00:00
Adrian 84c39e9205 Merge pull request #171 from MiniPlaceholders/renovate/fabric-loom-1.x
chore(deps): update plugin fabric-loom to v1.5.5
2024-01-15 21:25:24 -05:00
Adrian 77327661f3 Merge pull request #172 from MiniPlaceholders/renovate/fabric.api
fix(deps): update dependency net.fabricmc.fabric-api:fabric-api to v0.93.1+1.20.5
2024-01-15 21:25:17 -05:00
Adrian b725fd2bae Merge pull request #173 from MiniPlaceholders/renovate/org.gradle.toolchains.foojay-resolver-convention-0.x
chore(deps): update plugin org.gradle.toolchains.foojay-resolver-convention to v0.8.0
2024-01-15 21:25:10 -05:00
renovate[bot] f9a5acaaaf chore(deps): update plugin fabric-loom to v1.5.5 2024-01-13 11:05:36 +00:00
renovate[bot] fe613ce82d chore(deps): update plugin org.gradle.toolchains.foojay-resolver-convention to v0.8.0 2024-01-12 16:49:57 +00:00
renovate[bot] 21839e1e37 fix(deps): update dependency net.fabricmc.fabric-api:fabric-api to v0.93.1+1.20.5 2024-01-12 14:14:32 +00:00
Adrian 25d1588032 Merge pull request #167 from MiniPlaceholders/renovate/fabric.api
fix(deps): update dependency net.fabricmc.fabric-api:fabric-api to v0.92.0+1.20.5
2023-12-29 19:45:03 -05:00
renovate[bot] 92583013db fix(deps): update dependency net.fabricmc.fabric-api:fabric-api to v0.92.0+1.20.5 2023-12-29 15:38:27 +00:00
Adrian 89a7bdb208 Merge pull request #165 from MiniPlaceholders/renovate/fabric.loader
fix(deps): update dependency net.fabricmc:fabric-loader to v0.15.3
2023-12-29 10:37:41 -05:00
Adrian 0e7d4cb6dd Merge pull request #169 from MiniPlaceholders/renovate/kotlin-monorepo
fix(deps): update kotlin monorepo to v1.9.22
2023-12-29 10:37:23 -05:00
renovate[bot] 159b96579f fix(deps): update kotlin monorepo to v1.9.22 2023-12-21 17:01:40 +00:00
renovate[bot] efb155a171 fix(deps): update dependency net.fabricmc:fabric-loader to v0.15.3 2023-12-18 18:01:40 +00:00
Adrian 71ad7fb399 Merge pull request #168 from MiniPlaceholders/renovate/adventure
fix(deps): update adventure to v4.15.0
2023-12-18 07:04:22 -05:00
renovate[bot] 8b219fd553 fix(deps): update adventure to v4.15.0 2023-12-18 10:44:32 +00:00
Adrian 9899f0bab4 Merge pull request #166 from MiniPlaceholders/renovate/actions-upload-artifact-4.x
chore(deps): update actions/upload-artifact action to v4
2023-12-14 18:29:38 -05:00
renovate[bot] 7044e43483 chore(deps): update actions/upload-artifact action to v4 2023-12-14 20:59:42 +00:00
Adrian 36f1739704 Merge pull request #162 from MiniPlaceholders/renovate/actions-setup-java-4.x
chore(deps): update actions/setup-java action to v4
2023-12-12 18:11:11 -05:00
Adrian d173de4250 Merge pull request #163 from MiniPlaceholders/renovate/userdev
chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.11
2023-12-12 18:10:25 -05:00
Adrian 410fe06117 Merge pull request #164 from MiniPlaceholders/renovate/fabric-loom-1.x
chore(deps): update plugin fabric-loom to v1.4.5
2023-12-12 18:10:08 -05:00
Adrian e198769698 Merge pull request #161 from MiniPlaceholders/renovate/fabric.loader
fix(deps): update dependency net.fabricmc:fabric-loader to v0.15.1
2023-12-12 12:59:04 -05:00
renovate[bot] 41ff8c1e12 fix(deps): update dependency net.fabricmc:fabric-loader to v0.15.1 2023-12-11 16:06:24 +00:00
Adrian 344af47d19 Merge pull request #144 from MiniPlaceholders/renovate/fabric.api
fix(deps): update dependency net.fabricmc.fabric-api:fabric-api to v0.91.2+1.20.4
2023-12-11 11:06:00 -05:00
Adrian 756b1e9b43 Merge pull request #160 from MiniPlaceholders/renovate/gradle-8.x
chore(deps): update dependency gradle to v8.5
2023-12-11 11:05:48 -05:00
renovate[bot] 85b7a24770 chore(deps): update plugin fabric-loom to v1.4.5 2023-12-10 01:26:49 +00:00
renovate[bot] 7f484f33f0 fix(deps): update dependency net.fabricmc.fabric-api:fabric-api to v0.91.2+1.20.4 2023-12-09 01:44:53 +00:00
renovate[bot] 5d21522fa7 chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.11 2023-12-08 18:53:59 +00:00
renovate[bot] 176266c9d5 chore(deps): update actions/setup-java action to v4 2023-11-29 16:22:40 +00:00
renovate[bot] c5bf073888 chore(deps): update dependency gradle to v8.5 2023-11-29 14:51:10 +00:00
Adrian f2cbd1db75 Merge pull request #159 from MiniPlaceholders/renovate/fabric.loader
fix(deps): update dependency net.fabricmc:fabric-loader to v0.14.25
2023-11-29 09:46:01 -05:00
renovate[bot] e995e5441e fix(deps): update dependency net.fabricmc:fabric-loader to v0.14.25 2023-11-28 12:37:22 +00:00
Adrian f776f8ae61 Merge pull request #157 from MiniPlaceholders/renovate/org.jetbrains.kotlin.jvm-1.x
chore(deps): update plugin org.jetbrains.kotlin.jvm to v1.9.21
2023-11-27 17:04:38 -05:00
Adrian a26f92e75c Merge pull request #158 from MiniPlaceholders/renovate/kotlin-monorepo
fix(deps): update dependency org.jetbrains.kotlin:kotlin-gradle-plugin to v1.9.21
2023-11-27 17:04:30 -05:00
renovate[bot] b030f02aac fix(deps): update dependency org.jetbrains.kotlin:kotlin-gradle-plugin to v1.9.21 2023-11-24 07:39:15 +00:00
renovate[bot] 4336746bf3 chore(deps): update plugin org.jetbrains.kotlin.jvm to v1.9.21 2023-11-23 16:49:59 +00:00
Adrian e7e87a72dd Merge pull request #156 from MiniPlaceholders/renovate/userdev
chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.10
2023-11-21 19:11:24 -05:00
renovate[bot] 0dce995222 chore(deps): update dependency io.papermc.paperweight.userdev to v1.5.10 2023-11-21 22:38:10 +00:00
Adrian a280cf16cb release: Version 2.2.3 2023-11-17 23:14:59 -05:00
Adrian b37fad9611 fix: Fixed native expansions placeholders nesting 2023-11-17 11:29:58 -05:00
20 changed files with 196 additions and 173 deletions

No files matched your search

+3 -3
View File
@@ -11,21 +11,21 @@ jobs:
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'gradle'
- name: Build with Gradle
uses: nick-invision/retry@v2
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 2
command: gradle build
- name: Upload Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: MiniPlaceholders
path: jar/MiniPlaceholders-*.jar
@@ -43,6 +43,20 @@ public sealed interface Expansion permits ExpansionImpl {
*/
@NotNull String name();
/**
* Get the author of this expansion
* @return the author or null
* @since 2.3.0
*/
@Nullable String author();
/**
* Get the version of this expansion
* @return the version or null
* @since 2.3.0
*/
@Nullable String version();
/**
* Get the {@link TagResolver} of the desired {@link Audience}
* @param audience the audience
@@ -217,5 +231,25 @@ public sealed interface Expansion permits ExpansionImpl {
*/
@Contract("_ -> this")
@NotNull Builder filter(final @Nullable Predicate<@NotNull Audience> predicate);
/**
* Sets the author of this expansion
*
* @param author the author of this expansion
* @return the {@link Builder} itself
* @since 2.3.0
*/
@Contract("_ -> this")
@NotNull Builder author(final @Nullable String author);
/**
* Sets the version of this expansion
*
* @param version the version of this expansion
* @return the {@link Builder} itself
* @since 2.3.0
*/
@Contract("_ -> this")
@NotNull Builder version(final @Nullable String version);
}
}
@@ -27,6 +27,8 @@ final class ExpansionImpl implements Expansion {
private final TagResolver globalPlaceholders;
private final Class<? extends Audience> filterClass;
private final Predicate<Audience> predicateFilter;
private final String author;
private final String version;
ExpansionImpl(
@NotNull final String expansionName,
@@ -34,7 +36,10 @@ final class ExpansionImpl implements Expansion {
@Nullable final Collection<Tags.Relational> relationalPlaceholders,
@Nullable final TagResolver globalPlaceholders,
@Nullable final Class<? extends Audience> filterClass,
@Nullable final Predicate<Audience> predicateFilter){
@Nullable final Predicate<Audience> predicateFilter,
@Nullable final String author,
@Nullable final String version
) {
this.name = expansionName+"-";
this.audiencePlaceholders = audiencePlaceholders != null
? audiencePlaceholders.toArray(EMPTY_SINGLE_AUDIENCE)
@@ -45,6 +50,8 @@ final class ExpansionImpl implements Expansion {
this.globalPlaceholders = globalPlaceholders;
this.filterClass = filterClass;
this.predicateFilter = predicateFilter;
this.author = author;
this.version = version;
}
@Override
@@ -52,6 +59,16 @@ final class ExpansionImpl implements Expansion {
return this.name;
}
@Override
public @Nullable String author(){
return this.author;
}
@Override
public @Nullable String version(){
return this.version;
}
@Override
public @NotNull TagResolver audiencePlaceholders(@NotNull Audience audience) {
if (audiencePlaceholders.length == 0) return TagResolver.empty();
@@ -136,6 +153,8 @@ final class ExpansionImpl implements Expansion {
private TagResolver.Builder globalPlaceholders;
private Class<? extends Audience> filterClass;
private Predicate<Audience> predicateFilter;
private String author;
private String version;
Builder(@NotNull final String name){
this.expansionName = nonNullOrEmptyString(name, "Expansion name")
@@ -198,6 +217,18 @@ final class ExpansionImpl implements Expansion {
return this;
}
@Override
public Expansion.@NotNull Builder author(@Nullable final String author) {
this.author = author;
return this;
}
@Override
public Expansion.@NotNull Builder version(@Nullable final String version) {
this.version = version;
return this;
}
@Override
public @NotNull Expansion build(){
return new ExpansionImpl(
@@ -206,7 +237,9 @@ final class ExpansionImpl implements Expansion {
this.relationalPlaceholders,
this.globalPlaceholders != null ? this.globalPlaceholders.build() : TagResolver.empty(),
this.filterClass,
this.predicateFilter
this.predicateFilter,
this.version,
this.author
);
}
}
@@ -7,6 +7,9 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.Function;
import static java.util.Objects.requireNonNull;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
/**
@@ -68,7 +71,10 @@ public final class LegacyUtils {
* @return a parsed string
* @since 2.2.1
*/
public static @NotNull Component parsePossibleLegacy(@Nullable String string, @NotNull final Context context) {
public static @NotNull Component parsePossibleLegacy(
@Nullable String string,
final @NotNull Context context
) {
if (string == null || string.isEmpty()) return Component.empty();
if (string.indexOf(LegacyComponentSerializer.SECTION_CHAR) != -1) {
string = string.replace(LegacyComponentSerializer.SECTION_CHAR, LegacyComponentSerializer.AMPERSAND_CHAR);
@@ -97,7 +103,10 @@ public final class LegacyUtils {
* @return a parsed string
* @since 2.2.1
*/
public static @NotNull Component parsePossibleLegacy(@Nullable String string, @NotNull final TagResolver resolver) {
public static @NotNull Component parsePossibleLegacy(
@Nullable String string,
final @NotNull TagResolver resolver
) {
if (string == null || string.isEmpty()) return Component.empty();
if (string.indexOf(LegacyComponentSerializer.SECTION_CHAR) != -1) {
string = string.replace(LegacyComponentSerializer.SECTION_CHAR, LegacyComponentSerializer.AMPERSAND_CHAR);
@@ -112,4 +121,47 @@ public final class LegacyUtils {
resolver
);
}
/**
* Checks if the provided string contains legacy formatting.
*
* @param string the string input
* @return whether the string has legacy content
* @see LegacyComponentSerializer#AMPERSAND_CHAR
* @see LegacyComponentSerializer#SECTION_CHAR
* @since 2.3.0
*/
public static boolean hasLegacyFormat(final String string) {
requireNonNull(string, "string");
return string.indexOf(LegacyComponentSerializer.SECTION_CHAR) != -1
|| string.indexOf(LegacyComponentSerializer.AMPERSAND_CHAR) != -1;
}
/**
* Maps the input to a type depending on whether it contains legacy formatting or not.
*
* @param string the string input
* @param legacyMapping the mapping function in case the string contains legacy formatting
* @param modernMapping the mapping function in case the string does not contain any legacy character type,
* being safe to use with MiniMessage
* @return the mapped result
* @param <R> the result type
* @see LegacyComponentSerializer#AMPERSAND_CHAR
* @see LegacyComponentSerializer#SECTION_CHAR
* @see #hasLegacyFormat(String)
* @since 2.3.0
*/
public static <R> R mapLegacyOrElse(
final @NotNull String string,
final @NotNull Function<String, R> legacyMapping,
final @NotNull Function<String, R> modernMapping
) {
requireNonNull(legacyMapping, "legacyMapping");
requireNonNull(modernMapping, "modernInput");
if (hasLegacyFormat(string)) {
return legacyMapping.apply(string);
} else {
return modernMapping.apply(string);
}
}
}
@@ -41,6 +41,7 @@ public final class TagsUtils {
* @return a new basic self closing Tag of a string
* @since 1.1.0
*/
@Deprecated
public static @NotNull Tag staticTag(@NotNull String string) {
return Tag.selfClosingInserting(Component.text(string));
}
@@ -51,6 +52,7 @@ public final class TagsUtils {
* @return a new basic self closing Tag of a component
* @since 1.1.0
*/
@Deprecated
public static @NotNull Tag staticTag(@NotNull Component component) {
return Tag.selfClosingInserting(component);
}
@@ -2,10 +2,13 @@ package io.github.miniplaceholders.test;
import io.github.miniplaceholders.api.utils.LegacyUtils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Inserting;
import net.kyori.adventure.text.minimessage.tag.PreProcess;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
class LegacyTest {
@Test
@@ -17,4 +20,23 @@ class LegacyTest {
assertEquals(expected, result);
}
@Test
void testMapLegacyOrElse() {
final String legacyInput = "&fhi <red>aaaa";
Tag legacyProcessedTag = LegacyUtils.mapLegacyOrElse(
legacyInput,
legacy -> Tag.inserting(LegacyUtils.parsePossibleLegacy(legacy)),
Tag::preProcessParsed
);
assertInstanceOf(Inserting.class, legacyProcessedTag);
final String modernInput = "<rainbow>aaaaaaaaaaaaa";
Tag modernProcessedTag = LegacyUtils.mapLegacyOrElse(
modernInput,
__ -> fail(),
Tag::preProcessParsed
);
assertInstanceOf(PreProcess.class, modernProcessedTag);
}
}
+1 -1
View File
@@ -15,5 +15,5 @@ dependencyResolutionManagement {
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") version "1.9.20" apply false
kotlin("jvm") version "1.9.22" apply false
}
tasks {
@@ -47,15 +47,15 @@ public class FabricMod implements ModInitializer, PlaceholdersPlugin {
@Override
public void loadDefaultExpansions() {
Expansion.builder("server")
.globalPlaceholder("name", Tag.selfClosingInserting(Component.text(this.minecraftServer.getServerModName())))
.globalPlaceholder("name", Tag.preProcessParsed(this.minecraftServer.getServerModName()))
.globalPlaceholder("online", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.minecraftServer.getPlayerCount())))
.globalPlaceholder("version", (ctx, queue) -> Tag.selfClosingInserting(Component.text(this.minecraftServer.getServerVersion())))
.globalPlaceholder("max_players", (ctx, queue) -> Tag.selfClosingInserting(Component.text(this.minecraftServer.getMaxPlayers())))
.globalPlaceholder("version", (ctx, queue) -> Tag.preProcessParsed(this.minecraftServer.getServerVersion()))
.globalPlaceholder("max_players", (ctx, queue) -> Tag.preProcessParsed(Integer.toString(this.minecraftServer.getMaxPlayers())))
.globalPlaceholder("unique_joins", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.minecraftServer.getProfileCache().load().size())))
.globalPlaceholder("tps_1m", (ctx, queue) -> Tag.preProcessParsed(tickManager.getTps1m().formattedAverage()))
.globalPlaceholder("tps_5m", (ctx, queue) -> Tag.preProcessParsed(tickManager.getTps5m().formattedAverage()))
//.globalPlaceholder("tps_15m", (ctx, queue) -> Tag.preProcessParsed(tickManager.getTps15m().formattedAverage()))
.globalPlaceholder("tick_count", (queue, ctx) -> Tag.selfClosingInserting(Component.text(this.minecraftServer.getTickCount())))
.globalPlaceholder("tick_count", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.minecraftServer.getTickCount())))
.globalPlaceholder("has_whitelist", (queue, ctx) -> Tag.preProcessParsed(Boolean.toString(this.minecraftServer.getPlayerList().isUsingWhitelist())))
.globalPlaceholder("total_chunks", (queue, ctx) -> {
int chunks = 0;
+1 -1
View File
@@ -23,7 +23,7 @@
"fabricloader": ">=0.14.19",
"fabric": "*",
"java": ">=17",
"minecraft": ">=1.19.4",
"minecraft": ">=1.20.2",
"fabric-permissions-api-v0": "*"
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
group = io.github.miniplaceholders
version = 2.2.2
version = 2.3.0-SNAPSHOT
description = MiniMessage Component-based Placeholders for Paper, Fabric, Sponge, Folia and Velocity platforms
org.gradle.jvmargs=-Xmx2G
+8 -12
View File
@@ -4,12 +4,11 @@ metadata.format.version = "1.1"
velocity = "3.2.0-SNAPSHOT"
paper = "1.20.2-R0.1-SNAPSHOT"
krypton = "7796647145"
minecraft = "1.20.2"
runtask = "2.2.2"
runtask = "2.2.3"
pluginyml = "0.6.0"
userdev = "1.5.9"
userdev = "1.7.1"
blossom = "2.1.0"
indra = "3.1.3"
shadow = "8.1.1"
@@ -17,13 +16,13 @@ jmh = "0.7.2"
dokka = "1.9.10"
cloud = "1.8.4"
adventure = "4.14.0"
adventurefabric = "5.10.1"
adventure = "4.15.0"
adventurefabric = "5.12.0"
brigadier = "1.0.500"
kotlin="1.9.20"
kotlin="1.9.22"
fabric-api = "0.90.1+1.20.3"
fabric-loader = "0.14.24"
fabric-api = "0.96.4+1.20.5"
fabric-loader = "0.15.7"
desertwell = "2.0.4"
@@ -31,7 +30,6 @@ desertwell = "2.0.4"
velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
krypton-server = { group = "org.kryptonmc", name = "krypton-server", version.ref = "krypton" }
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
@@ -54,8 +52,6 @@ cloud-extras = { group = "cloud.commandframework", name = "cloud-minecraft-extra
brigadier = { group = "com.mojang", name = "brigadier", version.ref = "brigadier" }
krypton-annotation = { group = "org.kryptonmc", name = "krypton-annotation-processor", version.ref = "krypton" }
plugin-shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow" }
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
plugin-indra-common = { module = "net.kyori:indra-common", version.ref = "indra" }
@@ -64,7 +60,7 @@ plugin-dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.9.10"
desertwell = { group = "net.william278", name = "DesertWell", version.ref = "desertwell" }
junit-bom = "org.junit:junit-bom:5.10.1"
junit-bom = "org.junit:junit-bom:5.10.2"
[plugins]
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
-27
View File
@@ -1,27 +0,0 @@
plugins {
kotlin("jvm")
kotlin("kapt")
alias(libs.plugins.shadow)
}
repositories {
maven("https://repo.kryptonmc.org/releases")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://repo.kryptonmc.org/snapshots")
}
dependencies {
compileOnly(libs.krypton.server)
compileOnly(kotlin("stdlib"))
kapt(libs.krypton.annotation)
implementation(projects.miniplaceholdersCommon)
implementation(projects.miniplaceholdersApi)
implementation(projects.miniplaceholdersConnect)
implementation(projects.miniplaceholdersKotlinExt)
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
@@ -1,85 +0,0 @@
package io.github.miniplaceholders.krypton
import com.google.inject.Inject
import io.github.miniplaceholders.api.utils.TagsUtils
import io.github.miniplaceholders.common.PlaceholdersCommand
import io.github.miniplaceholders.common.PlaceholdersPlugin
import io.github.miniplaceholders.common.PluginConstants
import io.github.miniplaceholders.connect.InternalPlatform
import io.github.miniplaceholders.kotlin.asClosingTag
import io.github.miniplaceholders.kotlin.expansion
import net.kyori.adventure.text.Component
import org.apache.logging.log4j.Logger
import org.kryptonmc.api.command.BrigadierCommand
import org.kryptonmc.api.command.CommandExecutionContext
import org.kryptonmc.api.event.Listener
import org.kryptonmc.api.event.server.ServerStartEvent
import org.kryptonmc.api.plugin.annotation.Plugin
import org.kryptonmc.krypton.KryptonServer
import org.kryptonmc.krypton.command.KryptonCommandMeta
@Plugin(
name = "MiniPlaceholders",
id = "miniplaceholders",
version = PluginConstants.VERSION,
authors = ["4drian3d"]
)
class KotlinKryptonPlugin @Inject constructor(
private val server: KryptonServer,
private val logger: Logger
) : PlaceholdersPlugin {
init {
InternalPlatform.platform(InternalPlatform.KRYPTON)
}
@Listener
@Suppress("UNUSED")
fun onServerStart(event: ServerStartEvent) {
logger.info("Starting MiniPlaceholders Krypton")
this.loadDefaultExpansions()
this.registerPlatformCommand()
}
override fun loadDefaultExpansions() {
expansion("server") {
globalPlaceholder("total_entities") { _, _ ->
var entityCount = 0
for ((_, value) in server.worldManager.worlds) {
entityCount += value.entities.size
}
Component.text(entityCount).asClosingTag()
}
globalPlaceholder("total_chunks") { _, _ ->
var chunkCount = 0
for ((_, value) in server.worldManager.worlds) {
chunkCount += value.chunks.size
}
Component.text(chunkCount).asClosingTag()
}
globalPlaceholder("name", TagsUtils.staticTag(server.platform.name))
globalPlaceholder("online") { queue, _ ->
if (queue.hasNext()) {
val worldName = queue.pop().value()
val players = server.players.filter { it.world.name == worldName }
return@globalPlaceholder Component.text(players.joinToString(", ")).asClosingTag()
}
Component.text(server.players.size).asClosingTag()
}
globalPlaceholder("version", TagsUtils.staticTag(server.platform.version))
globalPlaceholder("max_players", Component.text(server.config.maxPlayers).asClosingTag())
}.register()
}
override fun registerPlatformCommand() {
/*val command = PlaceholdersCommand.builder<CommandExecutionContext>()
.fromSourceToAudience { it.sender }
.playerSuggestions { server.players.map { it.name } }
.toAudience { server.getPlayer(it) }
.build()
val brigadierCMD = BrigadierCommand.of(command.asNode("miniplaceholders"))
val meta = KryptonCommandMeta.Builder("miniplaceholders").build()
server.commandManager.register(brigadierCMD, meta)*/
}
}
@@ -3,7 +3,6 @@ package io.github.miniplaceholders.paper;
import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator;
import cloud.commandframework.paper.PaperCommandManager;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.utils.TagsUtils;
import io.github.miniplaceholders.common.PlaceholdersCommand;
import io.github.miniplaceholders.common.PlaceholdersPlugin;
import io.github.miniplaceholders.connect.InternalPlatform;
@@ -44,38 +43,38 @@ public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin
@Override
public void loadDefaultExpansions() {
Expansion.builder("server")
.globalPlaceholder("name", TagsUtils.staticTag(Component.text(this.getServer().getName())))
.globalPlaceholder("online", (queue, ctx) -> TagsUtils.staticTag(Component.text(this.getServer().getOnlinePlayers().size())))
.globalPlaceholder("version", TagsUtils.staticTag(this.getServer().getVersion()))
.globalPlaceholder("max_players", (queue, ctx) -> TagsUtils.staticTag(Component.text(this.getServer().getMaxPlayers())))
.globalPlaceholder("unique_joins", (queue, ctx) -> TagsUtils.staticTag(Component.text(this.getServer().getOfflinePlayers().length)))
.globalPlaceholder("tps_1", (queue, ctx) -> TagsUtils.staticTag(TPS_FORMAT.format(this.getServer().getTPS()[0])))
.globalPlaceholder("tps_5", (queue, ctx) -> TagsUtils.staticTag(TPS_FORMAT.format(this.getServer().getTPS()[1])))
.globalPlaceholder("tps_15", (queue, ctx) -> TagsUtils.staticTag(TPS_FORMAT.format(this.getServer().getTPS()[2])))
.globalPlaceholder("has_whitelist", (queue, ctx) -> TagsUtils.staticTag(Component.text(this.getServer().hasWhitelist())))
.globalPlaceholder("name", Tag.preProcessParsed(this.getServer().getName()))
.globalPlaceholder("online", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.getServer().getOnlinePlayers().size())))
.globalPlaceholder("version", Tag.preProcessParsed(this.getServer().getVersion()))
.globalPlaceholder("max_players", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.getServer().getMaxPlayers())))
.globalPlaceholder("unique_joins", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.getServer().getOfflinePlayers().length)))
.globalPlaceholder("tps_1", (queue, ctx) -> Tag.preProcessParsed(TPS_FORMAT.format(this.getServer().getTPS()[0])))
.globalPlaceholder("tps_5", (queue, ctx) -> Tag.preProcessParsed(TPS_FORMAT.format(this.getServer().getTPS()[1])))
.globalPlaceholder("tps_15", (queue, ctx) -> Tag.preProcessParsed(TPS_FORMAT.format(this.getServer().getTPS()[2])))
.globalPlaceholder("has_whitelist", (queue, ctx) -> Tag.preProcessParsed(Boolean.toString(this.getServer().hasWhitelist())))
.globalPlaceholder("total_chunks", (queue, ctx) -> {
int chunkCount = 0;
for (World world : this.getServer().getWorlds()){
chunkCount += world.getLoadedChunks().length;
}
return TagsUtils.staticTag(Component.text(chunkCount));
return Tag.preProcessParsed(Integer.toString(chunkCount));
})
.globalPlaceholder("total_entities", (queue, ctx) -> {
int entityCount = 0;
for (World world : this.getServer().getWorlds()){
entityCount += world.getEntityCount();
}
return TagsUtils.staticTag(Component.text(entityCount));
return Tag.preProcessParsed(Integer.toString(entityCount));
})
.globalPlaceholder("mspt", (queue, ctx) -> TagsUtils.staticTag(MSPT_FORMAT.format(this.getServer().getAverageTickTime())))
.globalPlaceholder("mspt", (queue, ctx) -> Tag.preProcessParsed(MSPT_FORMAT.format(this.getServer().getAverageTickTime())))
.globalPlaceholder("datapack_list", (queue, ctx) -> {
final TextComponent.Builder builder = Component.text();
for (Datapack datapack : this.getServer().getDatapackManager().getEnabledPacks()){
for (final Datapack datapack : this.getServer().getDatapackManager().getEnabledPacks()) {
builder.append(Component.text("[").append(Component.text(datapack.getName()).append(Component.text("] "))));
}
return Tag.selfClosingInserting(builder.build());
})
.globalPlaceholder("datapack_count", (queue, ctx) -> Tag.selfClosingInserting(Component.text(this.getServer().getDatapackManager().getEnabledPacks().size())))
.globalPlaceholder("datapack_count", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.getServer().getDatapackManager().getEnabledPacks().size())))
.build()
.register();
}
+2 -2
View File
@@ -30,9 +30,9 @@ dependencyResolutionManagement {
}
plugins {
id("fabric-loom") version "1.4.4"
id("fabric-loom") version "1.5.8"
id("org.spongepowered.gradle.plugin") version "2.2.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
arrayOf(
@@ -4,13 +4,12 @@ import cloud.commandframework.execution.CommandExecutionCoordinator;
import cloud.commandframework.sponge.SpongeCommandManager;
import com.google.inject.Inject;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.utils.TagsUtils;
import io.github.miniplaceholders.common.PlaceholdersCommand;
import io.github.miniplaceholders.common.PlaceholdersPlugin;
import io.github.miniplaceholders.connect.InternalPlatform;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.ForwardingAudience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.api.Server;
@@ -59,26 +58,26 @@ public class SpongePlugin implements PlaceholdersPlugin {
@Override
public void loadDefaultExpansions() {
Expansion.builder("server")
.globalPlaceholder("name", TagsUtils.staticTag("Sponge"))
.globalPlaceholder("online", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.onlinePlayers().size())))
.globalPlaceholder("max_players", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.maxPlayers())))
.globalPlaceholder("unique_joins", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.userManager().streamAll().count())))
.globalPlaceholder("has_whitelist", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.isWhitelistEnabled())))
.globalPlaceholder("name", Tag.preProcessParsed("Sponge"))
.globalPlaceholder("online", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(server.onlinePlayers().size())))
.globalPlaceholder("max_players", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(server.maxPlayers())))
.globalPlaceholder("unique_joins", (queue, ctx) -> Tag.preProcessParsed(Long.toString(server.userManager().streamAll().count())))
.globalPlaceholder("has_whitelist", (queue, ctx) -> Tag.preProcessParsed(Boolean.toString(server.isWhitelistEnabled())))
.globalPlaceholder("total_chunks", (queue, ctx) -> {
int chunkCount = 0;
for (ServerWorld world : server.worldManager().worlds()){
chunkCount += world.entities().size();
}
return TagsUtils.staticTag(Component.text(chunkCount));
return Tag.preProcessParsed(Integer.toString(chunkCount));
})
.globalPlaceholder("total_entities", (queue, ctx) -> {
int entityCount = 0;
for (ServerWorld world : server.worldManager().worlds()){
entityCount += world.entities().size();
}
return TagsUtils.staticTag(Component.text(entityCount));
return Tag.preProcessParsed(Integer.toString(entityCount));
})
.globalPlaceholder("mspt", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.averageTickTime())))
.globalPlaceholder("mspt", (queue, ctx) -> Tag.preProcessParsed(Double.toString(server.averageTickTime())))
.build()
.register();
@@ -15,12 +15,10 @@ import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import io.github.miniplaceholders.api.Expansion;
import io.github.miniplaceholders.api.utils.Components;
import io.github.miniplaceholders.api.utils.TagsUtils;
import io.github.miniplaceholders.common.PlaceholdersCommand;
import io.github.miniplaceholders.common.PlaceholdersPlugin;
import io.github.miniplaceholders.common.PluginConstants;
import io.github.miniplaceholders.connect.InternalPlatform;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import org.slf4j.Logger;
@@ -67,14 +65,14 @@ public final class VelocityPlugin implements PlaceholdersPlugin {
.map(size -> Integer.toString(size))
.orElse("0"));
}
return Tag.selfClosingInserting(Component.text(proxy.getPlayerCount()));
return Tag.preProcessParsed(Integer.toString(proxy.getPlayerCount()));
})
.globalPlaceholder("server_count", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(proxy.getAllServers().size())))
.globalPlaceholder("is_player_online", (queue, ctx) -> {
String playerName = queue.popOr(() -> "you need to introduce an argument").value();
return TagsUtils.staticTag(proxy.getPlayer(playerName).isPresent() ? Components.YES_COMPONENT : Components.NO_COMPONENT);
return Tag.selfClosingInserting(proxy.getPlayer(playerName).isPresent() ? Components.YES_COMPONENT : Components.NO_COMPONENT);
})
.globalPlaceholder("version", TagsUtils.staticTag(proxy.getVersion().getVersion()))
.globalPlaceholder("version", Tag.preProcessParsed(proxy.getVersion().getVersion()))
.build()
.register();
}