From e4ad2c50974ca97f0607954d1dbfc1ac681757eb Mon Sep 17 00:00:00 2001 From: Filip Znachor Date: Fri, 5 Sep 2025 22:12:50 +0200 Subject: [PATCH] Updated to MiniPlaceholders 3.0 (#302) * Updated to MiniPlaceholders 3.0 * Updated workflows from Java 17 to 21 --- .github/workflows/ci.yml | 6 +++--- .github/workflows/pr_tests.yml | 4 ++-- .github/workflows/release.yml | 6 +++--- build.gradle | 4 ++-- gradle.properties | 2 +- .../velocitab/hook/MiniPlaceholdersHook.java | 15 +++------------ 6 files changed, 14 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c6a5f8..72b5172 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,10 +19,10 @@ jobs: steps: - name: 'Checkout for CI 🛎️' uses: actions/checkout@v4 - - name: 'Set up JDK 17 📦' + - name: 'Set up JDK 21 📦' uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' - name: 'Build with Gradle 🏗️' uses: gradle/gradle-build-action@v3 @@ -130,4 +130,4 @@ jobs: 1.21.5 1.21.6 1.21.7 - java: 17 \ No newline at end of file + java: 21 \ No newline at end of file diff --git a/.github/workflows/pr_tests.yml b/.github/workflows/pr_tests.yml index 82898a4..ab808cb 100644 --- a/.github/workflows/pr_tests.yml +++ b/.github/workflows/pr_tests.yml @@ -14,10 +14,10 @@ jobs: steps: - name: 'Checkout for CI 🛎' uses: actions/checkout@v4 - - name: 'Set up JDK 17 📦' + - name: 'Set up JDK 21 📦' uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' - name: 'Build with Gradle 🏗️' uses: gradle/gradle-build-action@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64aaf2e..6ee1709 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,10 +15,10 @@ jobs: steps: - name: 'Checkout for CI 🛎️' uses: actions/checkout@v4 - - name: 'Set up JDK 17 📦' + - name: 'Set up JDK 21 📦' uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' - name: 'Build with Gradle 🏗️' uses: gradle/gradle-build-action@v3 @@ -119,4 +119,4 @@ jobs: 1.21.5 1.21.6 1.21.7 - java: 17 \ No newline at end of file + java: 21 \ No newline at end of file diff --git a/build.gradle b/build.gradle index d37a8a5..2ac4906 100644 --- a/build.gradle +++ b/build.gradle @@ -41,7 +41,7 @@ dependencies { compileOnly 'io.netty:netty-codec-http:4.2.2.Final' compileOnly 'org.projectlombok:lombok:1.18.38' compileOnly 'net.luckperms:api:5.5' - compileOnly 'io.github.miniplaceholders:miniplaceholders-api:2.2.3' + compileOnly 'io.github.miniplaceholders:miniplaceholders-api:3.0.1' compileOnly 'it.unimi.dsi:fastutil:8.5.16' compileOnly 'net.kyori:adventure-nbt:4.23.0' @@ -177,7 +177,7 @@ tasks { downloadPlugins { // github ("WiIIiam278", "PAPIProxyBridge", "1.7.1", "PAPIProxyBridge-Velocity-1.7.1.jar") - modrinth ("miniplaceholders", "2.2.4") + modrinth ("miniplaceholders", "3.0.1") } } } diff --git a/gradle.properties b/gradle.properties index d770f19..8bf5cb6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -javaVersion=17 +javaVersion=21 org.gradle.jvmargs='-Dfile.encoding=UTF-8' org.gradle.daemon=true diff --git a/src/main/java/net/william278/velocitab/hook/MiniPlaceholdersHook.java b/src/main/java/net/william278/velocitab/hook/MiniPlaceholdersHook.java index c76668c..7e1e0c5 100644 --- a/src/main/java/net/william278/velocitab/hook/MiniPlaceholdersHook.java +++ b/src/main/java/net/william278/velocitab/hook/MiniPlaceholdersHook.java @@ -21,6 +21,7 @@ package net.william278.velocitab.hook; import com.velocitypowered.api.proxy.Player; import io.github.miniplaceholders.api.MiniPlaceholders; +import io.github.miniplaceholders.api.types.RelationalAudience; import net.jodah.expiringmap.ExpiringMap; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; @@ -44,23 +45,13 @@ public class MiniPlaceholdersHook extends Hook { .build(); } - @NotNull - private TagResolver getResolver(@NotNull Player player, @Nullable Player viewer) { - if (viewer == null) { - return cache.computeIfAbsent(player.getUniqueId(), u -> MiniPlaceholders.getAudienceGlobalPlaceholders(player)); - } - - final UUID merged = new UUID(player.getUniqueId().getMostSignificantBits(), viewer.getUniqueId().getMostSignificantBits()); - return cache.computeIfAbsent(merged, u -> MiniPlaceholders.getRelationalGlobalPlaceholders(player, viewer)); - } - @NotNull public Component format(@NotNull String text, @NotNull Player player, @Nullable Player viewer) { if (viewer == null) { - return MiniMessage.miniMessage().deserialize(text, getResolver(player, null)); + return MiniMessage.miniMessage().deserialize(text, player, MiniPlaceholders.audienceGlobalPlaceholders()); } - return MiniMessage.miniMessage().deserialize(text, getResolver(player, viewer)); + return MiniMessage.miniMessage().deserialize(text, new RelationalAudience<>(player, viewer), MiniPlaceholders.relationalGlobalPlaceholders()); } }