use of me.devtec.theapi.bukkit.events.ServerListPingEvent in project TheAPI by TheDevTec.
the class v1_13_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 me.devtec.theapi.bukkit.events.ServerListPingEvent in project TheAPI by TheDevTec.
the class v1_12_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 me.devtec.theapi.bukkit.events.ServerListPingEvent in project TheAPI by TheDevTec.
the class v1_9_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 me.devtec.theapi.bukkit.events.ServerListPingEvent in project TheAPI by TheDevTec.
the class v1_18_R1 method processServerListPing.
@Override
public boolean processServerListPing(String player, Object channel, Object packet) {
PacketStatusOutServerInfo status = (PacketStatusOutServerInfo) packet;
ServerPing ping = status.b();
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.a(playerSample);
if (event.getMotd() != null)
ping.a((IChatBaseComponent) toIChatBaseComponent(ComponentAPI.toComponent(event.getMotd(), true)));
else
ping.a((IChatBaseComponent) BukkitLoader.getNmsProvider().chatBase("{\"text\":\"\"}"));
if (event.getVersion() != null)
ping.a(new ServerData(event.getVersion(), event.getProtocol()));
if (event.getFalvicon() != null)
ping.a(event.getFalvicon());
return false;
}
use of me.devtec.theapi.bukkit.events.ServerListPingEvent in project TheAPI by TheDevTec.
the class v1_17_R1 method processServerListPing.
@Override
public boolean processServerListPing(String player, Object channel, Object packet) {
PacketStatusOutServerInfo status = (PacketStatusOutServerInfo) packet;
ServerPing ping = status.b();
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