From 42f0afaa5718e29ef308d542eb364931f46031ac Mon Sep 17 00:00:00 2001 From: MarkusTieger Date: Tue, 30 Apr 2024 19:06:08 +0200 Subject: [PATCH] Added Minimessage to signs --- ext/adventure-helper/build.gradle.kts | 1 + .../ext/component/MinimessageUtils.java | 33 +++++++++++++++++++ .../modules/bridge/BridgeServiceHelper.java | 2 ++ .../configuration/SignConfigurationEntry.java | 30 +++++++++++++---- .../modules/signs/platform/PlatformSign.java | 5 +-- .../platform/bukkit/BukkitPlatformSign.java | 4 +-- .../minestom/MinestomPlatformSign.java | 4 +-- .../platform/nukkit/NukkitPlatformSign.java | 4 +-- .../platform/sponge/SpongePlatformSign.java | 3 +- .../modules/signs/util/LayoutUtil.java | 10 ++++-- modules/syncproxy/build.gradle.kts | 1 - .../config/SyncProxyConfiguration.java | 28 ++-------------- .../platform/PlatformSyncProxyManagement.java | 3 +- .../bungee/BungeeCordSyncProxyListener.java | 3 ++ .../bungee/BungeeCordSyncProxyManagement.java | 3 +- .../velocity/VelocitySyncProxyManagement.java | 17 +++------- .../WaterDogPESyncProxyManagement.java | 3 +- 17 files changed, 93 insertions(+), 61 deletions(-) create mode 100644 ext/adventure-helper/src/main/java/eu/cloudnetservice/ext/component/MinimessageUtils.java diff --git a/ext/adventure-helper/build.gradle.kts b/ext/adventure-helper/build.gradle.kts index 72b8132f82..0ea5693f31 100644 --- a/ext/adventure-helper/build.gradle.kts +++ b/ext/adventure-helper/build.gradle.kts @@ -18,6 +18,7 @@ dependencies { "compileOnly"(libs.adventureApi) "compileOnly"(libs.adventureSerializerLegacy) "compileOnly"(libs.bungeecordChat) + "api"(libs.adventureMinimessage) } configurations { diff --git a/ext/adventure-helper/src/main/java/eu/cloudnetservice/ext/component/MinimessageUtils.java b/ext/adventure-helper/src/main/java/eu/cloudnetservice/ext/component/MinimessageUtils.java new file mode 100644 index 0000000000..019746f1c3 --- /dev/null +++ b/ext/adventure-helper/src/main/java/eu/cloudnetservice/ext/component/MinimessageUtils.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019-2024 CloudNetService team & contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package eu.cloudnetservice.ext.component; + +import java.util.Map; +import lombok.NonNull; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; +import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; + +public class MinimessageUtils { + + public static TagResolver[] tagsFromMap(@NonNull Map placeholders) { + return placeholders.entrySet() + .stream() + .map((entry) -> Placeholder.unparsed(entry.getKey(), entry.getValue())) + .toArray((size) -> new TagResolver[size]); + } + +} diff --git a/modules/bridge/src/main/java/eu/cloudnetservice/modules/bridge/BridgeServiceHelper.java b/modules/bridge/src/main/java/eu/cloudnetservice/modules/bridge/BridgeServiceHelper.java index ef43b333fc..e93dc02430 100644 --- a/modules/bridge/src/main/java/eu/cloudnetservice/modules/bridge/BridgeServiceHelper.java +++ b/modules/bridge/src/main/java/eu/cloudnetservice/modules/bridge/BridgeServiceHelper.java @@ -125,7 +125,9 @@ public BridgeServiceHelper( * @param service the service to use as source for the placeholder values. * @return the String with the placeholders replaced. * @throws NullPointerException if the given input string is null. + * @deprecated Use {@link #fillCommonPlaceholders(Map, String, ServiceInfoSnapshot)} instead */ + @Deprecated public static @NonNull String fillCommonPlaceholders( @NonNull String value, @Nullable String group, diff --git a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/configuration/SignConfigurationEntry.java b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/configuration/SignConfigurationEntry.java index 7026711c0a..89c77340dc 100644 --- a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/configuration/SignConfigurationEntry.java +++ b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/configuration/SignConfigurationEntry.java @@ -46,30 +46,48 @@ public record SignConfigurationEntry( .groupConfigurations(List.of(SignGroupConfiguration.builder() .targetGroup("TARGET_GROUP") .emptyLayout(SignLayoutsHolder.singleLayout(SignLayout.builder() - .lines("&7%task% &0- &7%task_id%", "&8[&7EMPTY&8]", "%online_players% / %max_players%", "%motd%") + .lines(" - ", + "[EMPTY]", + " / ", + "") .blockMaterial(onlineBlockType) .build())) .onlineLayout(SignLayoutsHolder.singleLayout(SignLayout.builder() - .lines("&6%task% &0- &6%task_id%", "&8[&6LOBBY&8]", "%online_players% / %max_players%", "%motd%") + .lines(" - ", + "[LOBBY]", + " / ", + "") .blockMaterial(onlineBlockType) .build())) .fullLayout(SignLayoutsHolder.singleLayout(SignLayout.builder() - .lines("&5%task% &0- &5%task_id%", "&8[&5FULL&8]", "%online_players% / %max_players%", "%motd%") + .lines(" - ", + "[FULL]", + " / ", + "") .blockMaterial(fullBlockType) .build())) .build())) .searchingLayout(defaultLayout("Waiting", searchingBlock)) .startingLayout(defaultLayout("Starting", startingBlock)) .emptyLayout(SignLayoutsHolder.singleLayout(SignLayout.builder() - .lines("&7%task% &0- &7%task_id%", "&8[&7EMPTY&8]", "%online_players% / %max_players%", "%motd%") + .lines(" - ", + "[EMPTY]", + " / ", + "") .blockMaterial(onlineBlockType) .build())) .onlineLayout(SignLayoutsHolder.singleLayout(SignLayout.builder() - .lines("&6%task% &0- &6%task_id%", "&8[&6LOBBY&8]", "%online_players% / %max_players%", "%motd%") + .lines(" - ", + "[LOBBY]", + " / ", + "") .blockMaterial(onlineBlockType) .build())) .fullLayout(SignLayoutsHolder.singleLayout(SignLayout.builder() - .lines("&5%task% &0- &5%task_id%", "&8[&5FULL&8]", "%online_players% / %max_players%", "%motd%") + .lines(" - ", + "[FULL]", + " / ", + "") .blockMaterial(fullBlockType) .build())) .build(); diff --git a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/PlatformSign.java b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/PlatformSign.java index 2cb2fe25c7..7b14f7b0c6 100644 --- a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/PlatformSign.java +++ b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/PlatformSign.java @@ -28,19 +28,20 @@ import java.util.function.BiConsumer; import java.util.function.Function; import lombok.NonNull; +import net.kyori.adventure.text.Component; import org.jetbrains.annotations.Nullable; public abstract class PlatformSign implements Comparable> { protected final Sign base; protected final PlayerManager playerManager; - protected final Function lineMapper; + protected final Function lineMapper; protected volatile ServiceInfoSnapshot target; public PlatformSign( @NonNull Sign base, @NonNull PlayerManager playerManager, - @NonNull Function lineMapper + @NonNull Function lineMapper ) { this.base = base; this.playerManager = playerManager; diff --git a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/bukkit/BukkitPlatformSign.java b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/bukkit/BukkitPlatformSign.java index e0c524cf7d..7542f471ea 100644 --- a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/bukkit/BukkitPlatformSign.java +++ b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/bukkit/BukkitPlatformSign.java @@ -24,7 +24,7 @@ import eu.cloudnetservice.modules.signs.platform.PlatformSign; import eu.cloudnetservice.modules.signs.platform.bukkit.event.BukkitCloudSignInteractEvent; import lombok.NonNull; -import org.bukkit.ChatColor; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Server; @@ -46,7 +46,7 @@ public BukkitPlatformSign( @NonNull PluginManager pluginManager, @NonNull PlayerManager playerManager ) { - super(base, playerManager, input -> ChatColor.translateAlternateColorCodes('&', input)); + super(base, playerManager, input -> LegacyComponentSerializer.legacySection().serialize(input)); this.server = server; this.pluginManager = pluginManager; diff --git a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/minestom/MinestomPlatformSign.java b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/minestom/MinestomPlatformSign.java index 06cec354ea..1ab54ba17f 100644 --- a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/minestom/MinestomPlatformSign.java +++ b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/minestom/MinestomPlatformSign.java @@ -19,7 +19,6 @@ import eu.cloudnetservice.common.tuple.Tuple2; import eu.cloudnetservice.driver.service.ServiceInfoSnapshot; import eu.cloudnetservice.ext.adventure.AdventureTextFormatLookup; -import eu.cloudnetservice.ext.component.ComponentFormats; import eu.cloudnetservice.modules.bridge.player.PlayerManager; import eu.cloudnetservice.modules.signs.Sign; import eu.cloudnetservice.modules.signs.configuration.SignLayout; @@ -51,8 +50,7 @@ public MinestomPlatformSign( @NonNull InstanceManager instanceManager ) { super(base, playerManager, input -> { - var coloredComponent = ComponentFormats.BUNGEE_TO_ADVENTURE.convert(input); - return GsonComponentSerializer.gson().serialize(coloredComponent); + return GsonComponentSerializer.gson().serialize(input); }); this.eventHandler = eventHandler; diff --git a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/nukkit/NukkitPlatformSign.java b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/nukkit/NukkitPlatformSign.java index d03ed9164e..8f021c6166 100644 --- a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/nukkit/NukkitPlatformSign.java +++ b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/nukkit/NukkitPlatformSign.java @@ -25,7 +25,6 @@ import cn.nukkit.math.BlockFace; import cn.nukkit.plugin.PluginManager; import cn.nukkit.utils.Faceable; -import cn.nukkit.utils.TextFormat; import com.google.common.primitives.Ints; import eu.cloudnetservice.driver.service.ServiceInfoSnapshot; import eu.cloudnetservice.modules.bridge.player.PlayerManager; @@ -35,6 +34,7 @@ import eu.cloudnetservice.modules.signs.platform.nukkit.event.NukkitCloudSignInteractEvent; import java.util.Arrays; import lombok.NonNull; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.jetbrains.annotations.Nullable; public class NukkitPlatformSign extends PlatformSign { @@ -52,7 +52,7 @@ public NukkitPlatformSign( @NonNull PluginManager pluginManager, @NonNull PlayerManager playerManager ) { - super(base, playerManager, input -> TextFormat.colorize('&', input)); + super(base, playerManager, input -> LegacyComponentSerializer.legacySection().serialize(input)); this.server = server; this.pluginManager = pluginManager; diff --git a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/sponge/SpongePlatformSign.java b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/sponge/SpongePlatformSign.java index b93bb17602..10f2eb1499 100644 --- a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/sponge/SpongePlatformSign.java +++ b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/platform/sponge/SpongePlatformSign.java @@ -17,7 +17,6 @@ package eu.cloudnetservice.modules.signs.platform.sponge; import eu.cloudnetservice.driver.service.ServiceInfoSnapshot; -import eu.cloudnetservice.ext.component.ComponentFormats; import eu.cloudnetservice.modules.bridge.player.PlayerManager; import eu.cloudnetservice.modules.signs.Sign; import eu.cloudnetservice.modules.signs.configuration.SignLayout; @@ -54,7 +53,7 @@ public SpongePlatformSign( @NonNull WorldManager worldManager, @NonNull PlayerManager playerManager ) { - super(base, playerManager, ComponentFormats.BUNGEE_TO_ADVENTURE::convert); + super(base, playerManager, input -> input); this.game = game; this.eventManager = eventManager; diff --git a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/util/LayoutUtil.java b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/util/LayoutUtil.java index b5a238cb1a..a340c6d591 100644 --- a/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/util/LayoutUtil.java +++ b/modules/signs/src/main/java/eu/cloudnetservice/modules/signs/util/LayoutUtil.java @@ -19,15 +19,19 @@ import static eu.cloudnetservice.modules.bridge.BridgeServiceHelper.fillCommonPlaceholders; import eu.cloudnetservice.driver.service.ServiceInfoSnapshot; +import eu.cloudnetservice.ext.component.MinimessageUtils; import eu.cloudnetservice.modules.bridge.BridgeServiceHelper; import eu.cloudnetservice.modules.signs.Sign; import eu.cloudnetservice.modules.signs.configuration.SignConfigurationEntry; import eu.cloudnetservice.modules.signs.configuration.SignGroupConfiguration; import eu.cloudnetservice.modules.signs.configuration.SignLayout; import eu.cloudnetservice.modules.signs.configuration.SignLayoutsHolder; +import java.util.HashMap; import java.util.function.BiConsumer; import java.util.function.Function; import lombok.NonNull; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; import org.jetbrains.annotations.Nullable; /** @@ -107,12 +111,14 @@ public static void updateSignLines( @NonNull SignLayout layout, @NonNull String signTargetGroup, @Nullable ServiceInfoSnapshot target, - @NonNull Function lineMapper, + @NonNull Function lineMapper, @NonNull BiConsumer lineSetter ) { + var placeholders = new HashMap(); + fillCommonPlaceholders(placeholders, signTargetGroup, target); var lines = layout.lines(); for (var i = 0; i < Math.min(4, lines.size()); i++) { - var converted = lineMapper.apply(fillCommonPlaceholders(lines.get(i), signTargetGroup, target)); + var converted = lineMapper.apply(MiniMessage.miniMessage().deserialize(lines.get(i), MinimessageUtils.tagsFromMap(placeholders))); lineSetter.accept(i, converted); } } diff --git a/modules/syncproxy/build.gradle.kts b/modules/syncproxy/build.gradle.kts index 906e48927b..e179459d46 100644 --- a/modules/syncproxy/build.gradle.kts +++ b/modules/syncproxy/build.gradle.kts @@ -37,7 +37,6 @@ dependencies { "annotationProcessor"(libs.aerogelAuto) "implementation"(projects.ext.adventureHelper) - "api"(libs.adventureMinimessage) } moduleJson { diff --git a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/config/SyncProxyConfiguration.java b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/config/SyncProxyConfiguration.java index 6794e92eec..6afabd10e8 100644 --- a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/config/SyncProxyConfiguration.java +++ b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/config/SyncProxyConfiguration.java @@ -20,9 +20,9 @@ import eu.cloudnetservice.driver.channel.ChannelMessage; import eu.cloudnetservice.driver.network.buffer.DataBuf; import eu.cloudnetservice.driver.service.ServiceInfoSnapshot; +import eu.cloudnetservice.ext.component.MinimessageUtils; import eu.cloudnetservice.modules.bridge.BridgeServiceHelper; import eu.cloudnetservice.modules.syncproxy.SyncProxyConstants; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -31,7 +31,6 @@ import lombok.NonNull; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.UnknownNullability; @@ -50,25 +49,6 @@ public record SyncProxyConfiguration( "service-start", "The service is starting on node ...", "service-stop", "The service is stopping on node ..."); - public static @Nullable String fillCommonPlaceholders( - @NonNull ServiceInfoSnapshot serviceInfoSnapshot, - @Nullable String input, - int onlinePlayers, - int maxPlayers - ) { - if (input == null) { - return null; - } - - var placeholders = new HashMap(); - fillCommonPlaceholders(placeholders, serviceInfoSnapshot, onlinePlayers, maxPlayers); - for (var placeholder : placeholders.entrySet()) { - input = input.replace("%" + placeholder.getKey() + "%", placeholder.getValue()); - } - - return input; - } - public static void fillCommonPlaceholders( @NonNull Map map, @NonNull ServiceInfoSnapshot serviceInfoSnapshot, @@ -85,13 +65,9 @@ public static TagResolver[] adventurePlaceholders( int onlinePlayers, int maxPlayers ) { - var resolvers = new ArrayList(); var placeholders = new HashMap(); fillCommonPlaceholders(placeholders, serviceInfoSnapshot, onlinePlayers, maxPlayers); - for (var placeholder : placeholders.entrySet()) { - resolvers.add(Placeholder.unparsed(placeholder.getKey(), placeholder.getValue())); - } - return resolvers.toArray(new TagResolver[0]); + return MinimessageUtils.tagsFromMap(placeholders); } public static @NonNull Builder builder() { diff --git a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/PlatformSyncProxyManagement.java b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/PlatformSyncProxyManagement.java index 4df36dfbf5..ed898f544a 100644 --- a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/PlatformSyncProxyManagement.java +++ b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/PlatformSyncProxyManagement.java @@ -273,7 +273,8 @@ public boolean checkPlayerMaintenance(@NonNull P player) { public abstract @NonNull UUID playerUniqueId(@NonNull P player); - public abstract void playerTabList(@NonNull P player, @NonNull Map placeholders, @Nullable String header, @Nullable String footer); + public abstract void playerTabList(@NonNull P player, @NonNull Map placeholders, + @Nullable String header, @Nullable String footer); public abstract void disconnectPlayer(@NonNull P player, @NonNull Component message); diff --git a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/bungee/BungeeCordSyncProxyListener.java b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/bungee/BungeeCordSyncProxyListener.java index d2806635cc..e92cdac8ff 100644 --- a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/bungee/BungeeCordSyncProxyListener.java +++ b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/bungee/BungeeCordSyncProxyListener.java @@ -22,6 +22,7 @@ import jakarta.inject.Inject; import jakarta.inject.Singleton; import java.util.Arrays; +import java.util.HashMap; import java.util.Objects; import java.util.UUID; import lombok.NonNull; @@ -85,6 +86,8 @@ public void handleProxyPing(@NonNull ProxyPingEvent event) { var protocolText = motd.protocolText(); // check if there is a protocol text in the config if (protocolText != null) { + var placeholders = new HashMap(); + SyncProxyConfiguration.fillCommonPlaceholders(placeholders, serviceInfo, onlinePlayers, maxPlayers); response.setVersion(new Protocol( LegacyComponentSerializer.legacySection().serialize( MiniMessage.miniMessage().deserialize( diff --git a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/bungee/BungeeCordSyncProxyManagement.java b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/bungee/BungeeCordSyncProxyManagement.java index f7e0b8524e..11773b6085 100644 --- a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/bungee/BungeeCordSyncProxyManagement.java +++ b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/bungee/BungeeCordSyncProxyManagement.java @@ -101,7 +101,8 @@ public void registerService(@NonNull ServiceRegistry registry) { } @Override - public void playerTabList(@NonNull ProxiedPlayer player, @NonNull Map placeholders, @Nullable String header, @Nullable String footer) { + public void playerTabList(@NonNull ProxiedPlayer player, @NonNull Map placeholders, + @Nullable String header, @Nullable String footer) { placeholders.put("ping", String.valueOf(player.getPing())); placeholders.put("server", player.getServer() == null ? "UNAVAILABLE" : player.getServer().getInfo().getName()); diff --git a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/velocity/VelocitySyncProxyManagement.java b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/velocity/VelocitySyncProxyManagement.java index f7bb89e420..1ce141e052 100644 --- a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/velocity/VelocitySyncProxyManagement.java +++ b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/velocity/VelocitySyncProxyManagement.java @@ -24,7 +24,7 @@ import eu.cloudnetservice.driver.permission.PermissionManagement; import eu.cloudnetservice.driver.provider.CloudServiceProvider; import eu.cloudnetservice.driver.registry.ServiceRegistry; -import eu.cloudnetservice.ext.component.ComponentFormats; +import eu.cloudnetservice.ext.component.MinimessageUtils; import eu.cloudnetservice.modules.syncproxy.platform.PlatformSyncProxyManagement; import eu.cloudnetservice.wrapper.configuration.WrapperConfiguration; import eu.cloudnetservice.wrapper.holder.ServiceInfoHolder; @@ -38,8 +38,6 @@ import lombok.NonNull; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; import org.jetbrains.annotations.Nullable; @Singleton @@ -94,7 +92,8 @@ public void registerService(@NonNull ServiceRegistry registry) { } @Override - public void playerTabList(@NonNull Player player, @NonNull Map placeholders, @Nullable String header, @Nullable String footer) { + public void playerTabList(@NonNull Player player, @NonNull Map placeholders, + @Nullable String header, @Nullable String footer) { if (header == null || footer == null) { player.getTabList().clearHeaderAndFooter(); } else { @@ -106,17 +105,11 @@ public void playerTabList(@NonNull Player player, @NonNull Map p player.sendPlayerListHeaderAndFooter( MiniMessage.miniMessage().deserialize( header, - placeholders.entrySet() - .stream() - .map((entry) -> Placeholder.unparsed(entry.getKey(), entry.getValue())) - .toArray((size) -> new TagResolver[size]) + MinimessageUtils.tagsFromMap(placeholders) ), MiniMessage.miniMessage().deserialize( footer, - placeholders.entrySet() - .stream() - .map((entry) -> Placeholder.unparsed(entry.getKey(), entry.getValue())) - .toArray((size) -> new TagResolver[size]) + MinimessageUtils.tagsFromMap(placeholders) )); } } diff --git a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/waterdog/WaterDogPESyncProxyManagement.java b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/waterdog/WaterDogPESyncProxyManagement.java index a90b27e48b..1635614481 100644 --- a/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/waterdog/WaterDogPESyncProxyManagement.java +++ b/modules/syncproxy/src/main/java/eu/cloudnetservice/modules/syncproxy/platform/waterdog/WaterDogPESyncProxyManagement.java @@ -94,7 +94,8 @@ public void registerService(@NonNull ServiceRegistry registry) { } @Override - public void playerTabList(@NonNull ProxiedPlayer player, @NonNull Map placeholders, @Nullable String header, @Nullable String footer) { + public void playerTabList(@NonNull ProxiedPlayer player, @NonNull Map placeholders, + @Nullable String header, @Nullable String footer) { // there is no support for header and footer }