From a1fee720b9a223b0b87edc8868a45d3d5311e3c1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 25 Mar 2023 11:00:14 +1100 Subject: [PATCH] Deprecate string join --- api/src/main/java/net/md_5/bungee/Util.java | 10 ++++++++++ .../net/md_5/bungee/module/cmd/list/CommandList.java | 3 +-- proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/Util.java b/api/src/main/java/net/md_5/bungee/Util.java index 1457d4c8..6352951c 100644 --- a/api/src/main/java/net/md_5/bungee/Util.java +++ b/api/src/main/java/net/md_5/bungee/Util.java @@ -113,6 +113,16 @@ public class Util return format( objects, ", " ); } + /** + * Returns a string of objects, each separated by a separator. + * + * @param objects the objects to join + * @param separators the separator + * @return joined string + * @see String#join(java.lang.CharSequence, java.lang.Iterable) + * @deprecated use {@link String} join methods + */ + @Deprecated public static String format(Iterable objects, String separators) { return Joiner.on( separators ).join( objects ); diff --git a/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java b/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java index c4ac9173..79d0bb21 100644 --- a/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java +++ b/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; -import net.md_5.bungee.Util; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; @@ -49,7 +48,7 @@ public class CommandList extends Command implements TabExecutor } Collections.sort( players, String.CASE_INSENSITIVE_ORDER ); - sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_list", server.getName(), players.size(), Util.format( players, ChatColor.RESET + ", " ) ) ); + sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_list", server.getName(), players.size(), String.join( ChatColor.RESET + ", ", players ) ) ); } sender.sendMessage( ProxyServer.getInstance().getTranslation( "total_players", ProxyServer.getInstance().getOnlineCount() ) ); diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index c2fe9a40..061ff175 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -687,10 +687,10 @@ public class BungeeCord extends ProxyServer { if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) { - return new PluginMessage( "minecraft:register", Util.format( Iterables.transform( pluginChannels, PluginMessage.MODERNISE ), "\00" ).getBytes( Charsets.UTF_8 ), false ); + return new PluginMessage( "minecraft:register", String.join( "\00", Iterables.transform( pluginChannels, PluginMessage.MODERNISE ) ).getBytes( Charsets.UTF_8 ), false ); } - return new PluginMessage( "REGISTER", Util.format( pluginChannels, "\00" ).getBytes( Charsets.UTF_8 ), false ); + return new PluginMessage( "REGISTER", String.join( "\00", pluginChannels ).getBytes( Charsets.UTF_8 ), false ); } @Override