#3439: Add GetPlayerServer bungee plugin message subchannel

This commit is contained in:
Janmm14 2023-06-10 10:00:33 +02:00 committed by GitHub
parent a96a2e80a1
commit 9a71358dfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,7 @@ import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.ServerConnectEvent; import net.md_5.bungee.api.event.ServerConnectEvent;
import net.md_5.bungee.api.event.ServerDisconnectEvent; import net.md_5.bungee.api.event.ServerDisconnectEvent;
@ -401,6 +402,27 @@ public class DownstreamBridge extends PacketHandler
} }
break; break;
} }
case "GetPlayerServer":
{
String name = in.readUTF();
ProxiedPlayer player = bungee.getPlayer( name );
out.writeUTF( "GetPlayerServer" );
out.writeUTF( name );
if ( player == null )
{
out.writeUTF( "" );
break;
}
Server srv = player.getServer();
if ( srv == null )
{
out.writeUTF( "" );
} else
{
out.writeUTF( srv.getInfo().getName() );
}
break;
}
case "IP": case "IP":
out.writeUTF( "IP" ); out.writeUTF( "IP" );
if ( con.getSocketAddress() instanceof InetSocketAddress ) if ( con.getSocketAddress() instanceof InetSocketAddress )