Java Code Examples for protocolsupport.api.ProtocolSupportAPI#getConnections()

The following examples show how to use protocolsupport.api.ProtocolSupportAPI#getConnections() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandHandler.java    From ProtocolSupportBungee with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void execute(CommandSender sender, String[] args) {
	if ((args.length == 1) || (args.length == 2)) {
		if (args[0].equalsIgnoreCase("list")) {
			sender.sendMessage(new TextComponent(ChatColor.GREEN + "ProtocolSupport Players:"));
			for (ProtocolVersion version : ProtocolVersion.getAllSupported()) {
				List<String> players = ProxyServer.getInstance().getPlayers().stream()
				.filter(player -> ProtocolSupportAPI.getProtocolVersion(player) == version)
				.map(player -> player.getName())
				.collect(Collectors.toList());
				if (!players.isEmpty() || ((args.length == 2) && (args[1].equalsIgnoreCase("v") || args[1].equalsIgnoreCase("verbose")))) {
					sender.sendMessage(new TextComponent(ChatColor.GOLD + "[" + version.getName() + "]: " + ChatColor.GREEN + String.join(", ", players)));
				}
			}
			if ((args.length == 1) || !(args[1].equalsIgnoreCase("v") || args[1].equalsIgnoreCase("verbose"))) {
				sender.sendMessage(new TextComponent(ChatColor.GOLD + "List all compatible versions using " + ChatColor.GREEN + "/psb list verbose"));
			}
		} else if (args[0].equalsIgnoreCase("connections")) {
			for (Connection connection : ProtocolSupportAPI.getConnections()) {
				sender.sendMessage(new TextComponent(ChatColor.GREEN + connection.toString()));
			}
		}
	}
}
 
Example 2
Source File: ConnectionsListSubCommand.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean handle(CommandSender sender, String[] args) {
	for (Connection connection : ProtocolSupportAPI.getConnections()) {
		sender.sendMessage(ChatColor.YELLOW + connection.toString());
	}
	return true;
}