mirror of
https://github.com/WiIIiam278/Velocitab.git
synced 2025-11-18 07:14:23 +01:00
Updated to MiniPlaceholders 3.0 (#302)
Some checks failed
CI Tests & Publish / build (push) Failing after 2m27s
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:
parent
973af9c62a
commit
e4ad2c5097
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -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
|
||||
4
.github/workflows/pr_tests.yml
vendored
4
.github/workflows/pr_tests.yml
vendored
@ -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
|
||||
|
||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -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
|
||||
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
javaVersion=17
|
||||
javaVersion=21
|
||||
|
||||
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
|
||||
org.gradle.daemon=true
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user