Skip to content

Commit

Permalink
Update CommandList.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Outfluencer authored Feb 11, 2024
1 parent d0fa62d commit 69e2f0b
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.md_5.bungee.module.cmd.list;
package net.md_5.bungee.command;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -7,6 +7,10 @@
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
Expand All @@ -27,6 +31,7 @@ public CommandList()
public void execute(CommandSender sender, String[] args)
{
boolean hideEmptyServers = ( args.length == 0 ) || !args[0].equalsIgnoreCase( "all" );
boolean moduleLoaded = ProxyServer.getInstance().getPluginManager().getPlugin( "cmd_server" ) != null;

for ( ServerInfo server : ProxyServer.getInstance().getServers().values() )
{
Expand All @@ -48,7 +53,18 @@ public void execute(CommandSender sender, String[] args)
}
Collections.sort( players, String.CASE_INSENSITIVE_ORDER );

sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_list", server.getName(), players.size(), String.join( ChatColor.RESET + ", ", players ) ) );
BaseComponent baseComponent = new ComponentBuilder().appendLegacy( ProxyServer.getInstance().getTranslation( "command_list", server.getName(), players.size(), String.join( ChatColor.RESET + ", ", players ) ) ).build();

if ( moduleLoaded )
{
baseComponent.setHoverEvent( new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new ComponentBuilder().appendLegacy( ProxyServer.getInstance().getTranslation( "click_to_connect" ) ).create() )
);
baseComponent.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) );
}

sender.sendMessage( baseComponent );
}

sender.sendMessage( ProxyServer.getInstance().getTranslation( "total_players", ProxyServer.getInstance().getOnlineCount() ) );
Expand Down

0 comments on commit 69e2f0b

Please sign in to comment.