/** * Retrieve a deep copy of the current wrapper object. * @return The current object. */ public WrappedServerPing deepClone() { WrappedServerPing copy = new WrappedServerPing(); WrappedChatComponent motd = getMotD(); copy.setPlayers(getPlayers()); copy.setFavicon(getFavicon()); copy.setMotD(motd != null ? motd.deepClone() : null); copy.setVersionName(getVersionName()); copy.setVersionProtocol(getVersionProtocol()); if (isPlayersVisible()) { copy.setPlayersMaximum(getPlayersMaximum()); copy.setPlayersOnline(getPlayersOnline()); } else { copy.setPlayersVisible(false); } return copy; }
/** * Set whether or not the player count and player maximum is visible. * <p> * Note that this may set the current player count and maximum to their respective real values. * @param visible - TRUE if it should be visible, FALSE otherwise. */ public void setPlayersVisible(boolean visible) { if (isPlayersVisible() != visible) { if (visible) { // Recreate the count and maximum Server server = Bukkit.getServer(); setPlayersMaximum(server.getMaxPlayers()); setPlayersOnline(Util.getOnlinePlayers().size()); } else { PLAYERS.set(handle, players = null); } } }
/** * Construct a wrapped server ping from a native NMS object. * @param handle - the native object. * @return The wrapped server ping object. */ public static WrappedServerPing fromHandle(Object handle) { return new WrappedServerPing(handle); }
/** * Construct a wrapper server ping from an encoded JSON string. * @param json - the JSON string. * @return The wrapped server ping. */ public static WrappedServerPing fromJson(String json) { return fromHandle(GSON_FROM_JSON.invoke(PING_GSON.get(null), json, SERVER_PING)); }