use of net.minecraft.server.v1_8_R1.PacketStatusOutServerInfo in project TheAPI by TheDevTec.
the class v1_13_R2 method processServerListPing.
@Override
public boolean processServerListPing(String player, Object channel, Object packet) {
PacketStatusOutServerInfo status = (PacketStatusOutServerInfo) packet;
ServerPing ping;
try {
ping = (ServerPing) 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.d(), ((InetSocketAddress) ((Channel) channel).remoteAddress()).getAddress(), ping.getServerData().a(), ping.getServerData().getProtocolVersion());
HandlerList.callEvent(event);
if (event.isCancelled())
return true;
ServerPingPlayerSample playerSample = new ServerPingPlayerSample(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.a(profiles);
} else
playerSample.a(new GameProfile[0]);
ping.setPlayerSample(playerSample);
if (event.getMotd() != null)
ping.setMOTD((IChatBaseComponent) toIChatBaseComponent(ComponentAPI.toComponent(event.getMotd(), true)));
else
ping.setMOTD((IChatBaseComponent) BukkitLoader.getNmsProvider().chatBase("{\"text\":\"\"}"));
if (event.getVersion() != null)
ping.setServerInfo(new ServerData(event.getVersion(), event.getProtocol()));
if (event.getFalvicon() != null)
ping.setFavicon(event.getFalvicon());
return false;
}
use of net.minecraft.server.v1_8_R1.PacketStatusOutServerInfo in project TheAPI by TheDevTec.
the class v1_15_R1 method processServerListPing.
@Override
public boolean processServerListPing(String player, Object channel, Object packet) {
PacketStatusOutServerInfo status = (PacketStatusOutServerInfo) packet;
ServerPing ping;
try {
ping = (ServerPing) 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.d(), ((InetSocketAddress) ((Channel) channel).remoteAddress()).getAddress(), ping.getServerData().a(), ping.getServerData().getProtocolVersion());
HandlerList.callEvent(event);
if (event.isCancelled())
return true;
ServerPingPlayerSample playerSample = new ServerPingPlayerSample(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.a(profiles);
} else
playerSample.a(new GameProfile[0]);
ping.setPlayerSample(playerSample);
if (event.getMotd() != null)
ping.setMOTD((IChatBaseComponent) toIChatBaseComponent(ComponentAPI.toComponent(event.getMotd(), true)));
else
ping.setMOTD((IChatBaseComponent) BukkitLoader.getNmsProvider().chatBase("{\"text\":\"\"}"));
if (event.getVersion() != null)
ping.setServerInfo(new ServerData(event.getVersion(), event.getProtocol()));
if (event.getFalvicon() != null)
ping.setFavicon(event.getFalvicon());
return false;
}
use of net.minecraft.server.v1_8_R1.PacketStatusOutServerInfo in project TheAPI by TheDevTec.
the class v1_8_R2 method processServerListPing.
@Override
public boolean processServerListPing(String player, Object channel, Object packet) {
PacketStatusOutServerInfo status = (PacketStatusOutServerInfo) packet;
ServerPing ping;
try {
ping = (ServerPing) 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.d(), ((InetSocketAddress) ((Channel) channel).remoteAddress()).getAddress(), ping.c().a(), ping.c().b());
HandlerList.callEvent(event);
if (event.isCancelled())
return true;
ServerPingPlayerSample playerSample = new ServerPingPlayerSample(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.a(profiles);
} else
playerSample.a(new GameProfile[0]);
ping.setPlayerSample(playerSample);
if (event.getMotd() != null)
ping.setMOTD((IChatBaseComponent) toIChatBaseComponent(ComponentAPI.toComponent(event.getMotd(), true)));
else
ping.setMOTD((IChatBaseComponent) BukkitLoader.getNmsProvider().chatBase("{\"text\":\"\"}"));
if (event.getVersion() != null)
ping.setServerInfo(new ServerData(event.getVersion(), event.getProtocol()));
if (event.getFalvicon() != null)
ping.setFavicon(event.getFalvicon());
return false;
}
use of net.minecraft.server.v1_8_R1.PacketStatusOutServerInfo in project TheAPI by TheDevTec.
the class v1_8_R1 method processServerListPing.
@Override
public boolean processServerListPing(String player, Object channel, Object packet) {
PacketStatusOutServerInfo status = (PacketStatusOutServerInfo) packet;
ServerPing ping;
try {
ping = (ServerPing) 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.d(), ((InetSocketAddress) ((Channel) channel).remoteAddress()).getAddress(), ping.c().a(), ping.c().b());
HandlerList.callEvent(event);
if (event.isCancelled())
return true;
ServerPingPlayerSample playerSample = new ServerPingPlayerSample(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.a(profiles);
} else
playerSample.a(new GameProfile[0]);
ping.setPlayerSample(playerSample);
if (event.getMotd() != null)
ping.setMOTD((IChatBaseComponent) toIChatBaseComponent(ComponentAPI.toComponent(event.getMotd(), true)));
else
ping.setMOTD((IChatBaseComponent) BukkitLoader.getNmsProvider().chatBase("{\"text\":\"\"}"));
if (event.getVersion() != null)
ping.setServerInfo(new ServerPingServerData(event.getVersion(), event.getProtocol()));
if (event.getFalvicon() != null)
ping.setFavicon(event.getFalvicon());
return false;
}
use of net.minecraft.server.v1_8_R1.PacketStatusOutServerInfo in project TheAPI by TheDevTec.
the class v1_16_R3 method processServerListPing.
@Override
public boolean processServerListPing(String player, Object channel, Object packet) {
PacketStatusOutServerInfo status = (PacketStatusOutServerInfo) packet;
ServerPing ping;
try {
ping = (ServerPing) 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.d(), ((InetSocketAddress) ((Channel) channel).remoteAddress()).getAddress(), ping.getServerData().a(), ping.getServerData().getProtocolVersion());
HandlerList.callEvent(event);
if (event.isCancelled())
return true;
ServerPingPlayerSample playerSample = new ServerPingPlayerSample(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.a(profiles);
} else
playerSample.a(new GameProfile[0]);
ping.setPlayerSample(playerSample);
if (event.getMotd() != null)
ping.setMOTD((IChatBaseComponent) toIChatBaseComponent(ComponentAPI.toComponent(event.getMotd(), true)));
else
ping.setMOTD((IChatBaseComponent) BukkitLoader.getNmsProvider().chatBase("{\"text\":\"\"}"));
if (event.getVersion() != null)
ping.setServerInfo(new ServerData(event.getVersion(), event.getProtocol()));
if (event.getFalvicon() != null)
ping.setFavicon(event.getFalvicon());
return false;
}
Aggregations