From 86b694fbd2d2f24b6a1b612d2bdd1d2857098af9 Mon Sep 17 00:00:00 2001 From: Ayham Al-Ali <20037329+AyhamAl-Ali@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:21:53 +0300 Subject: [PATCH 1/3] Fix fake player count error --- .../expressions/ExprOnlinePlayersCount.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java b/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java index ad4a6055125..0d6829862a6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java +++ b/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java @@ -18,14 +18,7 @@ */ package ch.njol.skript.expressions; -import org.bukkit.Bukkit; -import org.bukkit.event.Event; -import org.bukkit.event.server.ServerListPingEvent; -import org.eclipse.jdt.annotation.Nullable; - -import com.destroystokyo.paper.event.server.PaperServerListPingEvent; import ch.njol.skript.Skript; -import ch.njol.skript.bukkitutil.PlayerUtils; import ch.njol.skript.classes.Changer.ChangeMode; import ch.njol.skript.doc.Description; import ch.njol.skript.doc.Examples; @@ -37,23 +30,30 @@ import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import ch.njol.util.coll.CollectionUtils; +import com.destroystokyo.paper.event.server.PaperServerListPingEvent; +import org.bukkit.Bukkit; +import org.bukkit.event.Event; +import org.bukkit.event.server.ServerListPingEvent; +import org.eclipse.jdt.annotation.Nullable; @Name("Online Player Count") -@Description({"The amount of online players. This can be changed in a", +@Description({ + "The amount of online players. This can be changed in a " + "server list ping event only to show fake online player amount.", - "'real online player count' always returns the real count of online players and can't be changed.", - "", - "Fake online player count requires PaperSpigot 1.12.2+."}) -@Examples({"on server list ping:", - " # This will make the max players count 5 if there are 4 players online.", - " set the fake max players count to (online players count + 1)"}) + "real online player count always return the real count of online players and can't be changed." +}) +@Examples({ + "on server list ping:", + "\t# This will make the max players count 5 if there are 4 players online.", + "\tset the fake max players count to (online players count + 1)" +}) @Since("2.3") public class ExprOnlinePlayersCount extends SimpleExpression { static { Skript.registerExpression(ExprOnlinePlayersCount.class, Long.class, ExpressionType.PROPERTY, - "[the] [(1¦(real|default)|2¦(fake|shown|displayed))] [online] player (count|amount|number)", - "[the] [(1¦(real|default)|2¦(fake|shown|displayed))] (count|amount|number|size) of online players"); + "[the] [(1:(real|default)|2:(fake|shown|displayed))] [online] player (count|amount|number)", + "[the] [(1:(real|default)|2:(fake|shown|displayed))] (count|amount|number|size) of online players"); } private static final boolean PAPER_EVENT_EXISTS = Skript.classExists("com.destroystokyo.paper.event.server.PaperServerListPingEvent"); @@ -64,7 +64,7 @@ public class ExprOnlinePlayersCount extends SimpleExpression { public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { boolean isPaperEvent = PAPER_EVENT_EXISTS && getParser().isCurrentEvent(PaperServerListPingEvent.class); if (parseResult.mark == 2) { - if (getParser().isCurrentEvent(ServerListPingEvent.class)) { + if (!PAPER_EVENT_EXISTS && getParser().isCurrentEvent(ServerListPingEvent.class)) { Skript.error("The 'fake' online players count expression requires Paper 1.12.2 or newer"); return false; } else if (!isPaperEvent) { @@ -146,4 +146,4 @@ public String toString(@Nullable Event e, boolean debug) { return "the count of " + (isReal ? "real max players" : "max players"); } -} \ No newline at end of file +} From 40cd3c1689bb3e2520a7839f9fcab46a7d9a01e2 Mon Sep 17 00:00:00 2001 From: Ayham Al-Ali <20037329+AyhamAl-Ali@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:28:39 +0300 Subject: [PATCH 2/3] Add required plugins --- .../java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java b/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java index 0d6829862a6..3b9bd9e0db8 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java +++ b/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java @@ -23,6 +23,7 @@ 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; @@ -47,6 +48,7 @@ "\t# This will make the max players count 5 if there are 4 players online.", "\tset the fake max players count to (online players count + 1)" }) +@RequiredPlugins("Paper (fake count)") @Since("2.3") public class ExprOnlinePlayersCount extends SimpleExpression { From bd638b4279234c86225ff47172e6bb9bb5b9a7fc Mon Sep 17 00:00:00 2001 From: Ayham Al Ali <20037329+AyhamAl-Ali@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:14:59 -0700 Subject: [PATCH 3/3] Update src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java --- .../java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java b/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java index 3b9bd9e0db8..5fd03a7e9d8 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java +++ b/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java @@ -46,7 +46,7 @@ @Examples({ "on server list ping:", "\t# This will make the max players count 5 if there are 4 players online.", - "\tset the fake max players count to (online players count + 1)" + "\tset the fake max players count to (online player count + 1)" }) @RequiredPlugins("Paper (fake count)") @Since("2.3")