From 2a9363277c642cec3634dee61ad10add7a006029 Mon Sep 17 00:00:00 2001 From: TheLimeGlass Date: Thu, 31 Jul 2025 17:51:38 -0600 Subject: [PATCH 01/12] Adds tablisted view players --- .../skript/expressions/ExprListedPlayers.java | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java diff --git a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java new file mode 100644 index 00000000000..bca5cd919a7 --- /dev/null +++ b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java @@ -0,0 +1,109 @@ +package ch.njol.skript.expressions; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.jetbrains.annotations.Nullable; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.RequiredPlugins; +import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.ExpressionType; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.lang.util.SimpleExpression; +import ch.njol.util.Kleenean; +import ch.njol.util.coll.CollectionUtils; + +@Name("Listed Players") +@Description("The displayed players in the tablist for selected players.") +@Examples("tablist players of player") +@Since("INSERT VERSION") +@RequiredPlugins("Paper 1.20.1+") +public class ExprListedPlayers extends SimpleExpression { + + static { + if (Skript.methodExists(Player.class, "isListed", Player.class)) { + Skript.registerExpression(ExprListedPlayers.class, Player.class, ExpressionType.SIMPLE, "[tab]list[ed] players of %players%"); + } + } + + private Expression viewers; + + @Override + @SuppressWarnings("unchecked") + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + viewers = (Expression) exprs[0]; + return true; + } + + @Override + protected Player[] get(Event event) { + return Bukkit.getOnlinePlayers().stream() + .filter(player -> viewers.check(event, viewer -> viewer.isListed(player))) + .toArray(Player[]::new); + } + + @Override + public Class[] acceptChange(ChangeMode mode) { + return CollectionUtils.array(Player[].class); + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + Player[] recipients = (Player[]) delta; + Player[] viewers = this.viewers.getArray(event); + switch (mode) { + case REMOVE: + for (Player viewer : viewers) { + for (Player player : recipients) { + viewer.unlistPlayer(player); + } + } + break; + case ADD: + assert recipients != null; + for (Player viewer : viewers) { + for (Player player : recipients) { + viewer.listPlayer(player); + } + } + break; + case SET: + change(event, delta, ChangeMode.DELETE); + change(event, delta, ChangeMode.ADD); + break; + case REMOVE_ALL: + case RESET: + case DELETE: + for (Player viewer : viewers) { + Bukkit.getOnlinePlayers().forEach(player -> { + if (!viewer.isListed(player)) { + viewer.listPlayer(player); + } + }); + } + break; + } + } + + @Override + public boolean isSingle() { + return false; + } + + @Override + public Class getReturnType() { + return Player.class; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return "tablisted players of " + viewers.toString(event, debug); + } + +} From 87ed44e1d380aea2c01df9b99848497ff7a8398a Mon Sep 17 00:00:00 2001 From: TheLimeGlass Date: Thu, 31 Jul 2025 18:19:43 -0600 Subject: [PATCH 02/12] Add the to the syntax because of 2.12 conflictions --- src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java index bca5cd919a7..e23c7bf006a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java @@ -28,7 +28,7 @@ public class ExprListedPlayers extends SimpleExpression { static { if (Skript.methodExists(Player.class, "isListed", Player.class)) { - Skript.registerExpression(ExprListedPlayers.class, Player.class, ExpressionType.SIMPLE, "[tab]list[ed] players of %players%"); + Skript.registerExpression(ExprListedPlayers.class, Player.class, ExpressionType.SIMPLE, "[the] [tab]list[ed] players of %players%"); } } From 344f49c495fea5ba321052f9d22e9bf411ebdae1 Mon Sep 17 00:00:00 2001 From: TheLimeGlass Date: Thu, 31 Jul 2025 18:38:37 -0600 Subject: [PATCH 03/12] requested changes --- .../skript/expressions/ExprListedPlayers.java | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java index e23c7bf006a..c20c59bd31c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java @@ -1,5 +1,7 @@ package ch.njol.skript.expressions; +import java.util.Arrays; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.Event; @@ -12,39 +14,30 @@ import ch.njol.skript.doc.Name; import ch.njol.skript.doc.RequiredPlugins; import ch.njol.skript.doc.Since; -import ch.njol.skript.lang.Expression; -import ch.njol.skript.lang.ExpressionType; -import ch.njol.skript.lang.SkriptParser.ParseResult; -import ch.njol.skript.lang.util.SimpleExpression; -import ch.njol.util.Kleenean; +import ch.njol.skript.expressions.base.SimplePropertyExpression; import ch.njol.util.coll.CollectionUtils; @Name("Listed Players") -@Description("The displayed players in the tablist for selected players.") +@Description({ + "The displayed players in the tablist for selected players.", + "Delete changer will remove all the online players.", + "Reset changer will reset the tablist to a default state viewing all the players again." +}) @Examples("tablist players of player") @Since("INSERT VERSION") @RequiredPlugins("Paper 1.20.1+") -public class ExprListedPlayers extends SimpleExpression { +public class ExprListedPlayers extends SimplePropertyExpression { static { if (Skript.methodExists(Player.class, "isListed", Player.class)) { - Skript.registerExpression(ExprListedPlayers.class, Player.class, ExpressionType.SIMPLE, "[the] [tab]list[ed] players of %players%"); + registerDefault(ExprListedPlayers.class, Player[].class, "[the] [tab]list[ed] players", "players"); } } - private Expression viewers; - - @Override - @SuppressWarnings("unchecked") - public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { - viewers = (Expression) exprs[0]; - return true; - } - @Override - protected Player[] get(Event event) { + public Player[] convert(Player viewer) { return Bukkit.getOnlinePlayers().stream() - .filter(player -> viewers.check(event, viewer -> viewer.isListed(player))) + .filter(player -> viewer.isListed(player)) .toArray(Player[]::new); } @@ -56,8 +49,11 @@ public Class[] acceptChange(ChangeMode mode) { @Override public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { Player[] recipients = (Player[]) delta; - Player[] viewers = this.viewers.getArray(event); + Player[] viewers = getExpr().getArray(event); switch (mode) { + case DELETE: + recipients = Bukkit.getOnlinePlayers().toArray(Player[]::new); + // $fallthrough case REMOVE: for (Player viewer : viewers) { for (Player player : recipients) { @@ -65,6 +61,16 @@ public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { } } break; + case SET: + for (Player viewer : viewers) { + for (Player player : Bukkit.getOnlinePlayers()) { + if (Arrays.stream(recipients).noneMatch(recipient -> recipient.equals(player))) { + // If the player is not in the recipients, unlist them + viewer.unlistPlayer(player); + } + } + } + // $fallthrough case ADD: assert recipients != null; for (Player viewer : viewers) { @@ -73,21 +79,17 @@ public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { } } break; - case SET: - change(event, delta, ChangeMode.DELETE); - change(event, delta, ChangeMode.ADD); - break; - case REMOVE_ALL: case RESET: - case DELETE: for (Player viewer : viewers) { - Bukkit.getOnlinePlayers().forEach(player -> { + for (Player player : Bukkit.getOnlinePlayers()) { if (!viewer.isListed(player)) { viewer.listPlayer(player); } - }); + } } break; + default: + break; } } @@ -97,13 +99,13 @@ public boolean isSingle() { } @Override - public Class getReturnType() { - return Player.class; + public Class getReturnType() { + return Player[].class; } @Override - public String toString(@Nullable Event event, boolean debug) { - return "tablisted players of " + viewers.toString(event, debug); + protected String getPropertyName() { + return "tablisted players"; } } From beaf294fa932f9af3d9e7fe5d05fa100de21744c Mon Sep 17 00:00:00 2001 From: TheLimeGlass Date: Thu, 31 Jul 2025 18:41:33 -0600 Subject: [PATCH 04/12] Add keywords --- .../java/ch/njol/skript/expressions/ExprListedPlayers.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java index c20c59bd31c..643dccb5ac2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java @@ -11,21 +11,23 @@ import ch.njol.skript.classes.Changer.ChangeMode; import ch.njol.skript.doc.Description; import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Keywords; import ch.njol.skript.doc.Name; import ch.njol.skript.doc.RequiredPlugins; import ch.njol.skript.doc.Since; import ch.njol.skript.expressions.base.SimplePropertyExpression; import ch.njol.util.coll.CollectionUtils; -@Name("Listed Players") +@Name("Tablisted Players") @Description({ "The displayed players in the tablist for selected players.", "Delete changer will remove all the online players.", "Reset changer will reset the tablist to a default state viewing all the players again." }) @Examples("tablist players of player") -@Since("INSERT VERSION") @RequiredPlugins("Paper 1.20.1+") +@Since("INSERT VERSION") +@Keywords("tablist") public class ExprListedPlayers extends SimplePropertyExpression { static { From aed2ce51b2826bf1141cfa62f69de68f6d010645 Mon Sep 17 00:00:00 2001 From: TheLimeGlass Date: Thu, 31 Jul 2025 23:00:26 -0600 Subject: [PATCH 05/12] requested changes --- .../ch/njol/skript/expressions/ExprListedPlayers.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java index 643dccb5ac2..65c7e4a09a7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java @@ -32,7 +32,7 @@ public class ExprListedPlayers extends SimplePropertyExpression Date: Fri, 1 Aug 2025 03:29:09 -0600 Subject: [PATCH 06/12] requested changes --- .../skript/expressions/ExprListedPlayers.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java index 65c7e4a09a7..946b3b3c2df 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java @@ -15,7 +15,10 @@ import ch.njol.skript.doc.Name; import ch.njol.skript.doc.RequiredPlugins; import ch.njol.skript.doc.Since; -import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.skript.expressions.base.PropertyExpression; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; import ch.njol.util.coll.CollectionUtils; @Name("Tablisted Players") @@ -28,18 +31,25 @@ @RequiredPlugins("Paper 1.20.1+") @Since("INSERT VERSION") @Keywords("tablist") -public class ExprListedPlayers extends SimplePropertyExpression { +public class ExprListedPlayers extends PropertyExpression { static { if (Skript.methodExists(Player.class, "isListed", Player.class)) { - registerDefault(ExprListedPlayers.class, Player[].class, "[the] (tablist[ed]|listed) players", "players"); + registerDefault(ExprListedPlayers.class, Player.class, "[the] (tablist[ed]|listed) players", "players"); } } @Override - public Player[] convert(Player viewer) { - return Bukkit.getOnlinePlayers().stream() - .filter(player -> viewer.isListed(player)) + @SuppressWarnings("unchecked") + public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + setExpr((Expression) expressions[0]); + return true; + } + + @Override + protected Player[] get(Event event, Player[] source) { + return Arrays.stream(source) + .flatMap(viewer -> Bukkit.getOnlinePlayers().stream().filter(viewer::isListed)) .toArray(Player[]::new); } @@ -103,13 +113,13 @@ public boolean isSingle() { } @Override - public Class getReturnType() { - return Player[].class; + public Class getReturnType() { + return Player.class; } @Override - protected String getPropertyName() { - return "tablisted players"; + public String toString(@Nullable Event event, boolean debug) { + return "tablisted players of " + getExpr().toString(event, debug); } } From 46e22b5c507a1f0af97d0975e8060312216e37c4 Mon Sep 17 00:00:00 2001 From: TheLimeGlass Date: Fri, 1 Aug 2025 05:20:10 -0600 Subject: [PATCH 07/12] Remove 1.19.4 method checks --- .../{ExprListedPlayers.java => ExprTablistedPlayers.java} | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename src/main/java/ch/njol/skript/expressions/{ExprListedPlayers.java => ExprTablistedPlayers.java} (91%) diff --git a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java similarity index 91% rename from src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java rename to src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java index 946b3b3c2df..6984336c379 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprListedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java @@ -28,15 +28,12 @@ "Reset changer will reset the tablist to a default state viewing all the players again." }) @Examples("tablist players of player") -@RequiredPlugins("Paper 1.20.1+") @Since("INSERT VERSION") @Keywords("tablist") -public class ExprListedPlayers extends PropertyExpression { +public class ExprTablistedPlayers extends PropertyExpression { static { - if (Skript.methodExists(Player.class, "isListed", Player.class)) { - registerDefault(ExprListedPlayers.class, Player.class, "[the] (tablist[ed]|listed) players", "players"); - } + registerDefault(ExprTablistedPlayers.class, Player.class, "[the] (tablist[ed]|listed) players", "players"); } @Override From 60d11de17c7b24ec02b255783369bf1f8e7ada17 Mon Sep 17 00:00:00 2001 From: TheLimeGlass Date: Fri, 1 Aug 2025 05:20:47 -0600 Subject: [PATCH 08/12] Remove 1.19.4 method checks --- .../java/ch/njol/skript/expressions/ExprTablistedPlayers.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java index 6984336c379..a00325120d6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java @@ -7,13 +7,11 @@ import org.bukkit.event.Event; import org.jetbrains.annotations.Nullable; -import ch.njol.skript.Skript; import ch.njol.skript.classes.Changer.ChangeMode; import ch.njol.skript.doc.Description; import ch.njol.skript.doc.Examples; import ch.njol.skript.doc.Keywords; import ch.njol.skript.doc.Name; -import ch.njol.skript.doc.RequiredPlugins; import ch.njol.skript.doc.Since; import ch.njol.skript.expressions.base.PropertyExpression; import ch.njol.skript.lang.Expression; From 4e1388bb7915b880c370d41cbbc7f3f498d1c709 Mon Sep 17 00:00:00 2001 From: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com> Date: Fri, 1 Aug 2025 12:02:08 -0600 Subject: [PATCH 09/12] Update src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> --- .../java/ch/njol/skript/expressions/ExprTablistedPlayers.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java index a00325120d6..0598cb961b1 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java @@ -45,6 +45,7 @@ public boolean init(Expression[] expressions, int matchedPattern, Kleenean is protected Player[] get(Event event, Player[] source) { return Arrays.stream(source) .flatMap(viewer -> Bukkit.getOnlinePlayers().stream().filter(viewer::isListed)) + .distinct() .toArray(Player[]::new); } From 6f181343fb1280169f4892863138e67268a23118 Mon Sep 17 00:00:00 2001 From: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com> Date: Mon, 4 Aug 2025 06:34:00 -0600 Subject: [PATCH 10/12] Update src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com> --- .../java/ch/njol/skript/expressions/ExprTablistedPlayers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java index 0598cb961b1..5bdc80b94e3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java @@ -25,7 +25,7 @@ "Delete changer will remove all the online players.", "Reset changer will reset the tablist to a default state viewing all the players again." }) -@Examples("tablist players of player") +@Example("tablist players of player") @Since("INSERT VERSION") @Keywords("tablist") public class ExprTablistedPlayers extends PropertyExpression { From 6fa987ea3b88f7747b4e42ca9e8f38823a0fdd23 Mon Sep 17 00:00:00 2001 From: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com> Date: Mon, 4 Aug 2025 06:34:13 -0600 Subject: [PATCH 11/12] Update src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com> --- .../ch/njol/skript/expressions/ExprTablistedPlayers.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java index 5bdc80b94e3..a779018204a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java @@ -21,9 +21,9 @@ @Name("Tablisted Players") @Description({ - "The displayed players in the tablist for selected players.", - "Delete changer will remove all the online players.", - "Reset changer will reset the tablist to a default state viewing all the players again." + "The players shown in the tab lists of the specified players.", + "`delete` will remove all the online players from the tab list.", + "`reset` will reset the tab list to the default state, which makes all players visible again." }) @Example("tablist players of player") @Since("INSERT VERSION") From 533171631519230dfabf88bfc88e1afd4a5e146c Mon Sep 17 00:00:00 2001 From: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com> Date: Mon, 4 Aug 2025 06:38:47 -0600 Subject: [PATCH 12/12] Update src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java --- .../java/ch/njol/skript/expressions/ExprTablistedPlayers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java index a779018204a..6b8010f3a13 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTablistedPlayers.java @@ -9,7 +9,7 @@ import ch.njol.skript.classes.Changer.ChangeMode; import ch.njol.skript.doc.Description; -import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Example; import ch.njol.skript.doc.Keywords; import ch.njol.skript.doc.Name; import ch.njol.skript.doc.Since;