From f2245afacb1eeee10e273dc49ebf3e18c97c9441 Mon Sep 17 00:00:00 2001 From: MCSamuel <187220916+MC-Samuel@users.noreply.github.com> Date: Wed, 1 Jul 2026 22:24:53 -0700 Subject: [PATCH 1/3] fixes to ServerListPingScriptEventPaperImpl --- .../paper/events/ServerListPingScriptEventPaperImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java b/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java index 6ea097a13d..d5a5a1cabd 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java @@ -40,7 +40,9 @@ public ServerListPingScriptEventPaperImpl() { this.registerDetermination("exclude_players", ListTag.class, (evt, context, list) -> { HashSet exclusions = new HashSet<>(); for (PlayerTag player : list.filter(PlayerTag.class, context)) { - exclusions.add(player.getUUID()); + if (player.isOnline()) { + exclusions.add(player.getUUID()); + } } if (NMSHandler.getVersion().isAtMost(NMSVersion.v1_19)) { Iterator players = evt.getEvent().iterator(); @@ -87,6 +89,7 @@ public static void setListedPlayerInfo(PaperServerListPingEvent event, List exclude) { event.getListedPlayers().removeIf(listedPlayerInfo -> exclude.contains(listedPlayerInfo.id())); + event.setNumPlayers(event.getNumPlayers() - exclude.size()); } } From e3eab34dfbf21d17a1104e1614da5fa72088783e Mon Sep 17 00:00:00 2001 From: MCSamuel <187220916+MC-Samuel@users.noreply.github.com> Date: Thu, 9 Jul 2026 03:29:52 -0700 Subject: [PATCH 2/3] changed excluded player calculation --- .../ServerListPingScriptEventPaperImpl.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java b/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java index d5a5a1cabd..d7df0db99e 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java @@ -15,6 +15,7 @@ import com.destroystokyo.paper.profile.PlayerProfile; import com.destroystokyo.paper.profile.ProfileProperty; import net.md_5.bungee.api.ChatColor; +import org.apache.commons.lang3.mutable.MutableInt; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.profile.PlayerTextures; @@ -40,9 +41,7 @@ public ServerListPingScriptEventPaperImpl() { this.registerDetermination("exclude_players", ListTag.class, (evt, context, list) -> { HashSet exclusions = new HashSet<>(); for (PlayerTag player : list.filter(PlayerTag.class, context)) { - if (player.isOnline()) { - exclusions.add(player.getUUID()); - } + exclusions.add(player.getUUID()); } if (NMSHandler.getVersion().isAtMost(NMSVersion.v1_19)) { Iterator players = evt.getEvent().iterator(); @@ -88,8 +87,15 @@ public static void setListedPlayerInfo(PaperServerListPingEvent event, List exclude) { - event.getListedPlayers().removeIf(listedPlayerInfo -> exclude.contains(listedPlayerInfo.id())); - event.setNumPlayers(event.getNumPlayers() - exclude.size()); + MutableInt counter = new MutableInt(0); + event.getListedPlayers().removeIf(listedPlayerInfo -> { + if (exclude.contains(listedPlayerInfo.id())) { + counter.increment(); + return true; + } + return false; + }); + event.setNumPlayers(event.getNumPlayers() - counter.intValue()); } } From 0ed6f7adfc4d2886c1d32d0920262403a35f858e Mon Sep 17 00:00:00 2001 From: MCSamuel <187220916+MC-Samuel@users.noreply.github.com> Date: Sun, 12 Jul 2026 13:44:08 -0700 Subject: [PATCH 3/3] moved to a separate determination --- .../ServerListPingScriptEventPaperImpl.java | 22 ++++++++++--------- .../events/server/ListPingScriptEvent.java | 3 ++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java b/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java index d7df0db99e..577e2e2de3 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/events/ServerListPingScriptEventPaperImpl.java @@ -15,7 +15,6 @@ import com.destroystokyo.paper.profile.PlayerProfile; import com.destroystokyo.paper.profile.ProfileProperty; import net.md_5.bungee.api.ChatColor; -import org.apache.commons.lang3.mutable.MutableInt; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.profile.PlayerTextures; @@ -71,6 +70,17 @@ public ServerListPingScriptEventPaperImpl() { ListedPlayersEditor.setListedPlayerInfo(evt.getEvent(), text); return true; }); + this.registerOptionalDetermination("player_count", ElementTag.class, (evt, context, input) -> { + if (!CoreConfiguration.allowRestrictedActions) { + Debug.echoError("Cannot use 'player_count' in list ping event: 'Allow restricted actions' is disabled in Denizen config.yml."); + return false; + } + if (input.isInt()) { + evt.getEvent().setNumPlayers(input.asInt()); + return true; + } + return false; + }); } public PaperServerListPingEvent getEvent() { @@ -87,15 +97,7 @@ public static void setListedPlayerInfo(PaperServerListPingEvent event, List exclude) { - MutableInt counter = new MutableInt(0); - event.getListedPlayers().removeIf(listedPlayerInfo -> { - if (exclude.contains(listedPlayerInfo.id())) { - counter.increment(); - return true; - } - return false; - }); - event.setNumPlayers(event.getNumPlayers() - counter.intValue()); + event.getListedPlayers().removeIf(listedPlayerInfo -> exclude.contains(listedPlayerInfo.id())); } } diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/server/ListPingScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/server/ListPingScriptEvent.java index 0e8e554d2c..f7da4ef31a 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/server/ListPingScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/server/ListPingScriptEvent.java @@ -46,8 +46,9 @@ public class ListPingScriptEvent extends BukkitScriptEvent implements Listener { // "ICON:" of a file path to an icon image, to change the icon that will display. // "PROTOCOL_VERSION:" to change the protocol ID number of the server's version (only on Paper). // "VERSION_NAME:" to change the server's version name (only on Paper). - // "EXCLUDE_PLAYERS:" to exclude a set of players from showing in the player count or preview of online players (only on Paper). + // "EXCLUDE_PLAYERS:" to exclude a set of players from showing in the preview of online players (only on Paper). // "ALTERNATE_PLAYER_TEXT:" to set custom text for the player list section of the server status (only on Paper). (Requires "Allow restricted actions" in Denizen/config.yml). Usage of this to present lines that look like player names (but aren't) is forbidden. + // "PLAYER_COUNT:" to set the amount of players that are online (only on Paper). (Requires "Allow restricted actions" in Denizen/config.yml). Usage of this to display a higher number of players than are actually connected is forbidden. // "MOTD:" to change the MOTD that will show. // // -->