Updated to MiniPlaceholders 3.0 (#302)
Some checks failed
CI Tests & Publish / build (push) Failing after 2m27s

* Updated to MiniPlaceholders 3.0

* Updated workflows from Java 17 to 21
This commit is contained in:
Filip Znachor 2025-09-05 22:12:50 +02:00 committed by GitHub
parent 973af9c62a
commit e4ad2c5097
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 14 additions and 23 deletions

View File

@ -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
java: 21

View File

@ -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

View File

@ -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
java: 21

View File

@ -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")
}
}
}

View File

@ -1,4 +1,4 @@
javaVersion=17
javaVersion=21
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.daemon=true

View File

@ -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());
}
}