From 886fb67dbdd829979a7a343dd9ab3def4e24a90f Mon Sep 17 00:00:00 2001 From: Spongecade Date: Mon, 2 Oct 2023 09:08:31 -0500 Subject: [PATCH 01/19] Update Minecraft wiki links to new domain (#6078) --- src/main/java/ch/njol/skript/classes/data/BukkitClasses.java | 4 ++-- src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java | 2 +- src/main/java/ch/njol/skript/effects/EffExplosion.java | 2 +- src/main/java/ch/njol/skript/expressions/ExprAge.java | 2 +- .../java/ch/njol/skript/expressions/ExprExplosionYield.java | 2 +- .../java/ch/njol/skript/expressions/ExprExplosiveYield.java | 2 +- .../java/ch/njol/skript/expressions/ExprGlidingState.java | 2 +- .../java/ch/njol/skript/expressions/ExprScoreboardTags.java | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java b/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java index ccf12240d29..d674a18890d 100644 --- a/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java +++ b/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java @@ -1410,7 +1410,7 @@ public String toVariableNameString(FireworkEffect effect) { .user("(panda )?genes?") .name("Gene") .description("Represents a Panda's main or hidden gene. " + - "See genetics for more info.") + "See genetics for more info.") .since("2.4") .requiredPlugins("Minecraft 1.14 or newer")); } @@ -1486,7 +1486,7 @@ public String toVariableNameString(EnchantmentOffer eo) { .user("attribute ?types?") .name("Attribute Type") .description("Represents the type of an attribute. Note that this type does not contain any numerical values." - + "See attribute types for more info.") + + "See attribute types for more info.") .since("2.5")); Classes.registerClass(new EnumClassInfo<>(Environment.class, "environment", "environments") diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java b/src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java index 71dbbea2dcc..1b71258482b 100755 --- a/src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java @@ -35,7 +35,7 @@ @Name("Is Slime Chunk") @Description({"Tests whether a chunk is a so-called slime chunk.", "Slimes can generally spawn in the swamp biome and in slime chunks.", - "For more info, see the Minecraft wiki."}) + "For more info, see the Minecraft wiki."}) @Examples({"command /slimey:", "\ttrigger:", "\t\tif chunk at player is a slime chunk:", diff --git a/src/main/java/ch/njol/skript/effects/EffExplosion.java b/src/main/java/ch/njol/skript/effects/EffExplosion.java index 4f0de85dd86..192119a54d6 100644 --- a/src/main/java/ch/njol/skript/effects/EffExplosion.java +++ b/src/main/java/ch/njol/skript/effects/EffExplosion.java @@ -37,7 +37,7 @@ * @author Peter Güttinger */ @Name("Explosion") -@Description({"Creates an explosion of a given force. The Minecraft Wiki has an article on explosions " + +@Description({"Creates an explosion of a given force. The Minecraft Wiki has an article on explosions " + "which lists the explosion forces of TNT, creepers, etc.", "Hint: use a force of 0 to create a fake explosion that does no damage whatsoever, or use the explosion effect introduced in Skript 2.0.", "Starting with Bukkit 1.4.5 and Skript 2.0 you can use safe explosions which will damage entities but won't destroy any blocks."}) diff --git a/src/main/java/ch/njol/skript/expressions/ExprAge.java b/src/main/java/ch/njol/skript/expressions/ExprAge.java index 2a29300beb0..1be159daf08 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAge.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAge.java @@ -119,7 +119,7 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) { setAge(obj, newValue); break; case RESET: - // baby animals takes 20 minutes to grow up - ref: https://minecraft.fandom.com/wiki/Breeding + // baby animals takes 20 minutes to grow up - ref: https://minecraft.wiki/w/Breeding if (obj instanceof org.bukkit.entity.Ageable) // it might change later on so removing entity age reset would be better unless // bukkit adds a method returning the default age diff --git a/src/main/java/ch/njol/skript/expressions/ExprExplosionYield.java b/src/main/java/ch/njol/skript/expressions/ExprExplosionYield.java index eea0c5fdd0a..cb0227ec419 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprExplosionYield.java +++ b/src/main/java/ch/njol/skript/expressions/ExprExplosionYield.java @@ -40,7 +40,7 @@ @Name("Explosion Yield") @Description({"The yield of the explosion in an explosion prime event. This is how big the explosion is.", " When changing the yield, values less than 0 will be ignored.", - " Read this wiki page for more information"}) + " Read this wiki page for more information"}) @Examples({"on explosion prime:", "\tset the yield of the explosion to 10"}) @Events("explosion prime") diff --git a/src/main/java/ch/njol/skript/expressions/ExprExplosiveYield.java b/src/main/java/ch/njol/skript/expressions/ExprExplosiveYield.java index b66b2f4e60d..3fa35bc76c7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprExplosiveYield.java +++ b/src/main/java/ch/njol/skript/expressions/ExprExplosiveYield.java @@ -36,7 +36,7 @@ @Name("Explosive Yield") @Description({"The yield of an explosive (creeper, primed tnt, fireball, etc.). This is how big of an explosion is caused by the entity.", - "Read this wiki page for more information"}) + "Read this wiki page for more information"}) @Examples({"on spawn of a creeper:", "\tset the explosive yield of the event-entity to 10"}) @RequiredPlugins("Minecraft 1.12 or newer for creepers") diff --git a/src/main/java/ch/njol/skript/expressions/ExprGlidingState.java b/src/main/java/ch/njol/skript/expressions/ExprGlidingState.java index 6334e1af835..901ff127079 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprGlidingState.java +++ b/src/main/java/ch/njol/skript/expressions/ExprGlidingState.java @@ -31,7 +31,7 @@ import ch.njol.skript.expressions.base.SimplePropertyExpression; @Name("Gliding State") -@Description("Sets of gets gliding state of player. It allows you to set gliding state of entity even if they do not have an Elytra equipped.") +@Description("Sets of gets gliding state of player. It allows you to set gliding state of entity even if they do not have an Elytra equipped.") @Examples({"set gliding of player to off"}) @Since("2.2-dev21") public class ExprGlidingState extends SimplePropertyExpression { diff --git a/src/main/java/ch/njol/skript/expressions/ExprScoreboardTags.java b/src/main/java/ch/njol/skript/expressions/ExprScoreboardTags.java index 14da4e073ca..47f4f4e5712 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprScoreboardTags.java +++ b/src/main/java/ch/njol/skript/expressions/ExprScoreboardTags.java @@ -41,7 +41,7 @@ @Name("Scoreboard Tags") @Description({"Scoreboard tags are simple list of texts stored directly in the data of an entity.", "So this is a Minecraft related thing, not Bukkit, so the tags will not get removed when the server stops. " + - "You can visit visit Minecraft Wiki for more info.", + "You can visit visit Minecraft Wiki for more info.", "This is changeable and valid for any type of entity. " + "Also you can use use the Has Scoreboard Tag condition to check whether an entity has the given tags.", "", From 1789a95925a5291166b8a645544d74fd655ba127 Mon Sep 17 00:00:00 2001 From: Ayham Al Ali <20037329+AyhamAl-Ali@users.noreply.github.com> Date: Tue, 3 Oct 2023 10:10:26 +0300 Subject: [PATCH 02/19] =?UTF-8?q?=E2=9A=92=20Fix=20fake=20player=20count?= =?UTF-8?q?=20paper=20check=20error=20(#6090)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../expressions/ExprOnlinePlayersCount.java | 38 ++++++++++--------- 1 file changed, 20 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..5fd03a7e9d8 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java +++ b/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java @@ -18,18 +18,12 @@ */ 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; 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; @@ -37,23 +31,31 @@ 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 player count + 1)" +}) +@RequiredPlugins("Paper (fake count)") @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 +66,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 +148,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 b774cafc88dac177df042fea550813c4f0a56a62 Mon Sep 17 00:00:00 2001 From: _tud Date: Tue, 3 Oct 2023 11:42:47 +0300 Subject: [PATCH 03/19] Fix Command Help (#6080) Fix issues and cleanup CommandHelp class Co-authored-by: Moderocky --- .../ch/njol/skript/command/CommandHelp.java | 152 +++++++++--------- 1 file changed, 77 insertions(+), 75 deletions(-) diff --git a/src/main/java/ch/njol/skript/command/CommandHelp.java b/src/main/java/ch/njol/skript/command/CommandHelp.java index 8fcf6f0a3b4..4732ba2cde5 100644 --- a/src/main/java/ch/njol/skript/command/CommandHelp.java +++ b/src/main/java/ch/njol/skript/command/CommandHelp.java @@ -23,6 +23,7 @@ import java.util.LinkedHashMap; import java.util.Locale; +import java.util.Map; import java.util.Map.Entry; import org.bukkit.command.CommandSender; @@ -33,118 +34,119 @@ import ch.njol.skript.localization.Message; import ch.njol.skript.util.SkriptColor; -/** - * @author Peter Güttinger - */ public class CommandHelp { - + private final static String DEFAULTENTRY = "description"; - + private final static ArgsMessage m_invalid_argument = new ArgsMessage("commands.invalid argument"); private final static Message m_usage = new Message("skript command.usage"); - + + private final String actualCommand, actualNode, argsColor; private String command; + private String langNode; @Nullable - private Message description = null; - private final String argsColor; - - @Nullable - private String langNode = null; - - private final LinkedHashMap arguments = new LinkedHashMap<>(); - + private Message description; + + private final Map arguments = new LinkedHashMap<>(); + @Nullable - private Message wildcardArg = null; - - public CommandHelp(final String command, final SkriptColor argsColor, final String langNode) { - this.command = command; - this.argsColor = "" + argsColor.getFormattedChat(); - this.langNode = langNode; - description = new Message(langNode + "." + DEFAULTENTRY); + private ArgumentHolder wildcardArg = null; + + public CommandHelp(String command, SkriptColor argsColor, String langNode) { + this(command, argsColor.getFormattedChat(), langNode, new Message(langNode + "." + DEFAULTENTRY)); } - - public CommandHelp(final String command, final SkriptColor argsColor) { - this.command = command; - this.argsColor = "" + argsColor.getFormattedChat(); + + public CommandHelp(String command, SkriptColor argsColor) { + this(command, argsColor.getFormattedChat(), command, null); } - - public CommandHelp add(final String argument) { - if (langNode == null) { - if (argument.startsWith("<") && argument.endsWith(">")) { - final String carg = GRAY + "<" + argsColor + argument.substring(1, argument.length() - 1) + GRAY + ">"; - arguments.put(carg, argument); - } else { - arguments.put(argument, null); - } - } else { - if (argument.startsWith("<") && argument.endsWith(">")) { - final String carg = GRAY + "<" + argsColor + argument.substring(1, argument.length() - 1) + GRAY + ">"; - wildcardArg = new Message(langNode + "." + argument); - arguments.put(carg, wildcardArg); - } else { - arguments.put(argument, new Message(langNode + "." + argument)); - } + + private CommandHelp(String command, String argsColor, String node, @Nullable Message description) { + this.actualCommand = this.command = command; + this.actualNode = this.langNode = node; + this.argsColor = argsColor; + this.description = description; + } + + public CommandHelp add(String argument) { + ArgumentHolder holder = new ArgumentHolder(argument); + if (argument.startsWith("<") && argument.endsWith(">")) { + argument = GRAY + "<" + argsColor + argument.substring(1, argument.length() - 1) + GRAY + ">"; + wildcardArg = holder; } + arguments.put(argument, holder); return this; } - - public CommandHelp add(final CommandHelp help) { + + public CommandHelp add(CommandHelp help) { arguments.put(help.command, help); help.onAdd(this); return this; } - - protected void onAdd(final CommandHelp parent) { - langNode = parent.langNode + "." + command; + + protected void onAdd(CommandHelp parent) { + langNode = parent.langNode + "." + actualNode; description = new Message(langNode + "." + DEFAULTENTRY); - command = parent.command + " " + parent.argsColor + command; - for (final Entry e : arguments.entrySet()) { - if (e.getValue() instanceof CommandHelp) { - ((CommandHelp) e.getValue()).onAdd(this); - } else { - if (e.getValue() != null) { // wildcard arg - wildcardArg = new Message(langNode + "." + e.getValue()); - e.setValue(wildcardArg); - } else { - e.setValue(new Message(langNode + "." + e.getKey())); - } + command = parent.command + " " + parent.argsColor + actualCommand; + for (Entry entry : arguments.entrySet()) { + if (entry.getValue() instanceof CommandHelp) { + ((CommandHelp) entry.getValue()).onAdd(this); + continue; } + ((ArgumentHolder) entry.getValue()).update(); } } - - public boolean test(final CommandSender sender, final String[] args) { + + public boolean test(CommandSender sender, String[] args) { return test(sender, args, 0); } - - private boolean test(final CommandSender sender, final String[] args, final int index) { + + private boolean test(CommandSender sender, String[] args, int index) { if (index >= args.length) { showHelp(sender); return false; } - final Object help = arguments.get(args[index].toLowerCase(Locale.ENGLISH)); + Object help = arguments.get(args[index].toLowerCase(Locale.ENGLISH)); if (help == null && wildcardArg == null) { showHelp(sender, m_invalid_argument.toString(argsColor + args[index])); return false; } - if (help instanceof CommandHelp) - return ((CommandHelp) help).test(sender, args, index + 1); - return true; + return !(help instanceof CommandHelp) || ((CommandHelp) help).test(sender, args, index + 1); } - - public void showHelp(final CommandSender sender) { + + public void showHelp(CommandSender sender) { showHelp(sender, m_usage.toString()); } - - private void showHelp(final CommandSender sender, final String pre) { + + private void showHelp(CommandSender sender, String pre) { Skript.message(sender, pre + " " + command + " " + argsColor + "..."); - for (final Entry e : arguments.entrySet()) { - Skript.message(sender, " " + argsColor + e.getKey() + " " + GRAY + "-" + RESET + " " + e.getValue()); - } + for (Entry entry : arguments.entrySet()) + Skript.message(sender, " " + argsColor + entry.getKey() + " " + GRAY + "-" + RESET + " " + entry.getValue()); } - + @Override public String toString() { return "" + description; } - + + private class ArgumentHolder { + + private final String argument; + private Message description; + + private ArgumentHolder(String argument) { + this.argument = argument; + this.description = new Message(langNode + "." + argument); + } + + private void update() { + description = new Message(langNode + "." + argument); + } + + @Override + public String toString() { + return description.toString(); + } + + } + } From 71b05eb4588bcec387074edf14e19476e25648bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 17:18:58 -0600 Subject: [PATCH 04/19] Bump net.kyori:adventure-text-serializer-bungeecord from 4.3.0 to 4.3.1 (#6084) Bumps [net.kyori:adventure-text-serializer-bungeecord](https://github.com/KyoriPowered/adventure-platform) from 4.3.0 to 4.3.1. - [Release notes](https://github.com/KyoriPowered/adventure-platform/releases) - [Commits](https://github.com/KyoriPowered/adventure-platform/compare/v4.3.0...v4.3.1) --- updated-dependencies: - dependency-name: net.kyori:adventure-text-serializer-bungeecord dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ayham Al Ali <20037329+AyhamAl-Ali@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7ce7614c3b0..761244001d9 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ allprojects { dependencies { shadow group: 'io.papermc', name: 'paperlib', version: '1.0.8' shadow group: 'org.bstats', name: 'bstats-bukkit', version: '3.0.2' - shadow group: 'net.kyori', name: 'adventure-text-serializer-bungeecord', version: '4.3.0' + shadow group: 'net.kyori', name: 'adventure-text-serializer-bungeecord', version: '4.3.1' implementation group: 'io.papermc.paper', name: 'paper-api', version: '1.20.2-R0.1-SNAPSHOT' implementation group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.annotation', version: '2.2.700' From da97d3eebd7eea94cdbf3f781b8196d54d5d4dc1 Mon Sep 17 00:00:00 2001 From: Moderocky Date: Sun, 8 Oct 2023 11:09:38 +0100 Subject: [PATCH 05/19] Fix unloading/reloading a directory in the scripts effect (#6106) * Moved unloading to a common method. * Accidental double space :grimacing: --- .../ch/njol/skript/effects/EffScriptFile.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/njol/skript/effects/EffScriptFile.java b/src/main/java/ch/njol/skript/effects/EffScriptFile.java index 0a38111c5ce..ed15f625d2f 100644 --- a/src/main/java/ch/njol/skript/effects/EffScriptFile.java +++ b/src/main/java/ch/njol/skript/effects/EffScriptFile.java @@ -37,6 +37,7 @@ import java.io.File; import java.io.IOException; +import java.util.Set; @Name("Enable/Disable/Reload Script File") @Description("Enables, disables, or reloads a script file.") @@ -102,10 +103,8 @@ protected void execute(Event e) { case RELOAD: { if (ScriptLoader.getDisabledScriptsFilter().accept(scriptFile)) return; - - Script script = ScriptLoader.getScript(scriptFile); - if (script != null) - ScriptLoader.unloadScript(script); + + this.unloadScripts(scriptFile); ScriptLoader.loadScripts(scriptFile, OpenCloseable.EMPTY); break; @@ -114,9 +113,7 @@ protected void execute(Event e) { if (ScriptLoader.getDisabledScriptsFilter().accept(scriptFile)) return; - Script script = ScriptLoader.getScript(scriptFile); - if (script != null) - ScriptLoader.unloadScript(script); + this.unloadScripts(scriptFile); try { FileUtils.move( @@ -135,6 +132,19 @@ protected void execute(Event e) { assert false; } } + + private void unloadScripts(File file) { + if (file.isDirectory()) { + Set