use of net.minecraft.network.ServerStatusResponse.Players in project TheAPI by TheDevTec.
the class v1_16_R3_Mohist method processServerListPing.
@Override
public boolean processServerListPing(String player, Object channel, Object packet) {
SServerInfoPacket status = (SServerInfoPacket) packet;
ServerStatusResponse ping;
try {
ping = (ServerStatusResponse) field.get(status);
} catch (Exception e) {
return false;
}
List<PlayerProfile> players = new ArrayList<>();
for (Player p : Bukkit.getOnlinePlayers()) players.add(new PlayerProfile(p.getName(), p.getUniqueId()));
ServerListPingEvent event = new ServerListPingEvent(Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers(), players, Bukkit.getMotd(), ping.func_151316_d(), ((InetSocketAddress) ((Channel) channel).remoteAddress()).getAddress(), ping.func_151322_c().func_151303_a(), ping.func_151322_c().func_151304_b());
HandlerList.callEvent(event);
if (event.isCancelled())
return true;
Players playerSample = new Players(event.getMaxPlayers(), event.getOnlinePlayers());
if (event.getPlayersText() != null) {
GameProfile[] profiles = new GameProfile[event.getPlayersText().size()];
int i = -1;
for (PlayerProfile s : event.getPlayersText()) profiles[++i] = new GameProfile(s.getUUID(), s.getName());
playerSample.func_151330_a(profiles);
} else
playerSample.func_151330_a(new GameProfile[0]);
ping.func_151319_a(playerSample);
if (event.getMotd() != null)
ping.func_151315_a((ITextComponent) toIChatBaseComponent(ComponentAPI.toComponent(event.getMotd(), true)));
else
ping.func_151315_a((ITextComponent) BukkitLoader.getNmsProvider().chatBase("{\"text\":\"\"}"));
if (event.getVersion() != null)
ping.func_151321_a(new Version(event.getVersion(), event.getProtocol()));
if (event.getFalvicon() != null)
ping.func_151320_a(event.getFalvicon());
return false;
}
Aggregations