Java Code Examples for com.destroystokyo.paper.event.server.PaperServerListPingEvent#setServerIcon()
The following examples show how to use
com.destroystokyo.paper.event.server.PaperServerListPingEvent#setServerIcon() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExprServerIcon.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("null") @Override public void change(Event e, @Nullable Object[] delta, ChangeMode mode) { PaperServerListPingEvent event = (PaperServerListPingEvent) e; switch (mode) { case SET: event.setServerIcon((CachedServerIcon) delta[0]); break; case RESET: event.setServerIcon(Bukkit.getServerIcon()); } }
Example 2
Source File: PaperEventHandler.java From ServerListPlus with GNU General Public License v3.0 | 4 votes |
private void handlePaperServerListPing(final PaperServerListPingEvent event) { if (bukkit.getCore() == null) return; // Too early, we haven't finished initializing yet StatusRequest request = bukkit.getCore().createRequest(event.getAddress()); request.setProtocolVersion(event.getClient().getProtocolVersion()); InetSocketAddress host = event.getClient().getVirtualHost(); if (host != null) { request.setTarget(host); } StatusResponse response = request.createResponse(bukkit.getCore().getStatus(), // Return unknown player counts if it has been hidden new ResponseFetcher() { @Override public Integer getOnlinePlayers() { return event.shouldHidePlayers() ? null : event.getNumPlayers(); } @Override public Integer getMaxPlayers() { return event.shouldHidePlayers() ? null : event.getMaxPlayers(); } @Override public int getProtocolVersion() { return event.getProtocolVersion(); } } ); // Description String message = response.getDescription(); if (message != null) event.setMotd(message); // Version name message = response.getVersion(); if (message != null) event.setVersion(message); // Protocol version Integer protocol = response.getProtocolVersion(); if (protocol != null) event.setProtocolVersion(protocol); if (response.hidePlayers()) { event.setHidePlayers(true); } else { // Online players Integer count = response.getOnlinePlayers(); if (count != null) event.setNumPlayers(count); // Max players count = response.getMaxPlayers(); if (count != null) event.setMaxPlayers(count); // Player hover message = response.getPlayerHover(); if (message != null) { List<PlayerProfile> profiles = event.getPlayerSample(); profiles.clear(); if (!message.isEmpty()) { if (response.useMultipleSamples()) { count = response.getDynamicSamples(); List<String> lines = count != null ? Helper.splitLinesCached(message, count) : Helper.splitLinesCached(message); for (String line : lines) { profiles.add(bukkit.getServer().createProfile(line)); } } else { profiles.add(bukkit.getServer().createProfile(message)); } } } } // Favicon FaviconSource favicon = response.getFavicon(); if (favicon != null) { CachedServerIcon icon = bukkit.getFavicon(favicon); if (icon != null) try { event.setServerIcon(icon); } catch (UnsupportedOperationException ignored) {} } }