|
2 | 2 |
|
3 | 3 | import com.jaimemartz.playerbalancer.settings.props.features.BalancerProps; |
4 | 4 | import net.md_5.bungee.BungeeServerInfo; |
| 5 | +import net.md_5.bungee.api.Callback; |
| 6 | +import net.md_5.bungee.api.ProxyServer; |
| 7 | +import net.md_5.bungee.api.ServerPing; |
| 8 | +import net.md_5.bungee.api.chat.ComponentBuilder; |
| 9 | +import net.md_5.bungee.api.chat.TextComponent; |
5 | 10 | import net.md_5.bungee.api.config.ServerInfo; |
6 | 11 | import net.md_5.bungee.api.connection.ProxiedPlayer; |
7 | 12 |
|
| 13 | +import javax.xml.soap.Text; |
| 14 | +import java.awt.*; |
8 | 15 | import java.net.InetSocketAddress; |
9 | 16 | import java.util.Collection; |
10 | 17 | import java.util.Collections; |
| 18 | +import java.util.Queue; |
| 19 | +import java.util.function.IntFunction; |
11 | 20 | import java.util.stream.Collectors; |
12 | 21 |
|
13 | 22 | public class SectionServer extends BungeeServerInfo { |
@@ -35,4 +44,45 @@ public Collection<ProxiedPlayer> getPlayers() { |
35 | 44 | .collect(Collectors.toList()); |
36 | 45 | } else return Collections.emptyList(); |
37 | 46 | } |
| 47 | + |
| 48 | + @Override |
| 49 | + public void sendData(String channel, byte[] data) { |
| 50 | + this.sendData(channel, data, true); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public boolean sendData(String channel, byte[] data, boolean queue) { |
| 55 | + //Nothing to do |
| 56 | + return true; |
| 57 | + } |
| 58 | + |
| 59 | + @Override |
| 60 | + public void ping(Callback<ServerPing> callback) { |
| 61 | + this.ping(callback, ProxyServer.getInstance().getProtocolVersion()); |
| 62 | + } |
| 63 | + |
| 64 | + @Override |
| 65 | + public void ping(Callback<ServerPing> callback, int protocolVersion) { |
| 66 | + ServerPing ping = new ServerPing(); |
| 67 | + |
| 68 | + ping.setDescriptionComponent(new TextComponent( |
| 69 | + TextComponent.fromLegacyText(this.getMotd()) |
| 70 | + )); |
| 71 | + |
| 72 | + ping.setVersion(new ServerPing.Protocol( |
| 73 | + ProxyServer.getInstance().getName(), |
| 74 | + protocolVersion |
| 75 | + )); |
| 76 | + |
| 77 | + Collection<ProxiedPlayer> players = getPlayers(); |
| 78 | + ping.setPlayers(new ServerPing.Players( |
| 79 | + Integer.MAX_VALUE, |
| 80 | + players.size(), |
| 81 | + players.stream().map( |
| 82 | + player -> new ServerPing.PlayerInfo(player.getName(), player.getUniqueId()) |
| 83 | + ).toArray(ServerPing.PlayerInfo[]::new) |
| 84 | + )); |
| 85 | + |
| 86 | + callback.done(ping, null); |
| 87 | + } |
38 | 88 | } |
0 commit comments