mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-25 10:07:38 +01:00
Add player list and player count channels.
This commit is contained in:
parent
4c07fbf953
commit
8f090b6692
@ -382,11 +382,13 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
|
|||||||
|
|
||||||
if (message.tag.equals("BungeeCord"))
|
if (message.tag.equals("BungeeCord"))
|
||||||
{
|
{
|
||||||
switch (in.readUTF())
|
String subChannel = in.readUTF();
|
||||||
|
if (subChannel.equals("Disconnect"))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (subChannel.equals("Forward"))
|
||||||
{
|
{
|
||||||
case "Disconnect":
|
|
||||||
break outer;
|
|
||||||
case "Forward":
|
|
||||||
String target = in.readUTF();
|
String target = in.readUTF();
|
||||||
String channel = in.readUTF();
|
String channel = in.readUTF();
|
||||||
short len = in.readShort();
|
short len = in.readShort();
|
||||||
@ -403,26 +405,63 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
Server server = BungeeCord.getInstance().getServer(target);
|
Server server = BungeeCord.getInstance().getServer(target);
|
||||||
|
if (server != null)
|
||||||
|
{
|
||||||
server.sendData(channel, data);
|
server.sendData(channel, data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
}
|
||||||
case "Connect":
|
if (subChannel.equals("Connect"))
|
||||||
|
{
|
||||||
ServerInfo server = BungeeCord.getInstance().config.getServers().get(in.readUTF());
|
ServerInfo server = BungeeCord.getInstance().config.getServers().get(in.readUTF());
|
||||||
if (server != null)
|
if (server != null)
|
||||||
{
|
{
|
||||||
connect(server);
|
connect(server);
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case "IP":
|
if (subChannel.equals("IP"))
|
||||||
|
{
|
||||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||||
DataOutputStream out = new DataOutputStream(b);
|
DataOutputStream out = new DataOutputStream(b);
|
||||||
out.writeUTF("IP");
|
out.writeUTF("IP");
|
||||||
out.writeUTF(getAddress().getHostString());
|
out.writeUTF(getAddress().getHostString());
|
||||||
out.writeInt(getAddress().getPort());
|
out.writeInt(getAddress().getPort());
|
||||||
getServer().sendData("BungeeCord", b.toByteArray());
|
getServer().sendData("BungeeCord", b.toByteArray());
|
||||||
break;
|
}
|
||||||
|
if (subChannel.equals("PlayerCount"))
|
||||||
|
{
|
||||||
|
ServerInfo server = BungeeCord.getInstance().config.getServers().get(in.readUTF());
|
||||||
|
if (server != null)
|
||||||
|
{
|
||||||
|
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream out = new DataOutputStream(b);
|
||||||
|
out.writeUTF("PlayerCount");
|
||||||
|
out.writeUTF(server.getName());
|
||||||
|
out.writeInt(server.getPlayers().size());
|
||||||
|
getServer().sendData("BungeeCord", b.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (subChannel.equals("PlayerList"))
|
||||||
|
{
|
||||||
|
ServerInfo server = BungeeCord.getInstance().config.getServers().get(in.readUTF());
|
||||||
|
if (server != null)
|
||||||
|
{
|
||||||
|
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream out = new DataOutputStream(b);
|
||||||
|
out.writeUTF("PlayerList");
|
||||||
|
out.writeUTF(server.getName());
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (ProxiedPlayer p : server.getPlayers())
|
||||||
|
{
|
||||||
|
sb.append(p.getName());
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
out.writeUTF(sb.substring(0, sb.length() - 1));
|
||||||
|
|
||||||
|
getServer().sendData("BungeeCord", b.toByteArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user