diff options
author | Jake Potrebic <[email protected]> | 2024-05-31 08:46:42 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2024-05-31 17:46:42 +0200 |
commit | 0513374b1f3410c2dd630f169a0cdf64a349500e (patch) | |
tree | 808be93a66e92a118effa01d9a10bec7c8ff6c65 | |
parent | 3181470ad7d372d2a799c3dcdb61e9392969abe4 (diff) | |
download | Paper-0513374b1f3410c2dd630f169a0cdf64a349500e.tar.gz Paper-0513374b1f3410c2dd630f169a0cdf64a349500e.zip |
Fire TabCompleteEvent for legacy commands (#10834)
-rw-r--r-- | patches/api/0476-Brigadier-based-command-API.patch | 13 | ||||
-rw-r--r-- | patches/server/1043-Brigadier-based-command-API.patch | 17 |
2 files changed, 28 insertions, 2 deletions
diff --git a/patches/api/0476-Brigadier-based-command-API.patch b/patches/api/0476-Brigadier-based-command-API.patch index d30453ef37..ee5957433e 100644 --- a/patches/api/0476-Brigadier-based-command-API.patch +++ b/patches/api/0476-Brigadier-based-command-API.patch @@ -1974,3 +1974,16 @@ index 3ec32b46264cfff857b50129b5e0fa5584943ec6..bdfe68b386b5ca2878475e548d3c9a38 Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete."); return true; +diff --git a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java +index b43c3cb5c88eada186d6f81712c244aaa18fb53e..ea26cb90d988d693f26e37229fbdee975c0b11f4 100644 +--- a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java ++++ b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java +@@ -18,6 +18,8 @@ import org.jetbrains.annotations.NotNull; + * themselves. Plugins wishing to remove commands from tab completion are + * advised to ensure the client does not have permission for the relevant + * commands, or use {@link PlayerCommandSendEvent}. ++ * @apiNote Only called for bukkit API commands {@link org.bukkit.command.Command} and ++ * {@link org.bukkit.command.CommandExecutor} and not for brigadier commands ({@link io.papermc.paper.command.brigadier.Commands}). + */ + public class TabCompleteEvent extends Event implements Cancellable { + diff --git a/patches/server/1043-Brigadier-based-command-API.patch b/patches/server/1043-Brigadier-based-command-API.patch index a318e2e061..8af5976374 100644 --- a/patches/server/1043-Brigadier-based-command-API.patch +++ b/patches/server/1043-Brigadier-based-command-API.patch @@ -1829,10 +1829,10 @@ index 0000000000000000000000000000000000000000..f0cc27640bb3db275295a298d608c9d9 +} diff --git a/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java b/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java new file mode 100644 -index 0000000000000000000000000000000000000000..10a113b057b0a4d27cce3bae975e1108aaa7b517 +index 0000000000000000000000000000000000000000..0c3c82b28e581286b798ee58ca4193efc2faff4a --- /dev/null +++ b/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java -@@ -0,0 +1,135 @@ +@@ -0,0 +1,148 @@ +package io.papermc.paper.command.brigadier.bukkit; + +import co.aikar.timings.Timing; @@ -1845,6 +1845,8 @@ index 0000000000000000000000000000000000000000..10a113b057b0a4d27cce3bae975e1108 +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import com.mojang.brigadier.tree.LiteralCommandNode; +import io.papermc.paper.command.brigadier.CommandSourceStack; ++import java.util.ArrayList; ++import java.util.Collections; +import net.minecraft.commands.CommandSource; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; @@ -1857,6 +1859,9 @@ index 0000000000000000000000000000000000000000..10a113b057b0a4d27cce3bae975e1108 +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.logging.Level; ++import org.bukkit.entity.Entity; ++import org.bukkit.entity.Player; ++import org.bukkit.event.server.TabCompleteEvent; + +public class BukkitCommandNode extends LiteralCommandNode<CommandSourceStack> { + @@ -1951,6 +1956,14 @@ index 0000000000000000000000000000000000000000..10a113b057b0a4d27cce3bae975e1108 + Bukkit.getServer().getLogger().log(Level.SEVERE, "Exception when " + sender.getName() + " attempted to tab complete " + builder.getRemaining(), ex); + } + ++ if (sender instanceof final Player player) { ++ TabCompleteEvent tabEvent = new org.bukkit.event.server.TabCompleteEvent(player, builder.getInput(), results != null ? results : new ArrayList<>(), true, pos); // Paper - AsyncTabCompleteEvent ++ if (!tabEvent.callEvent()) { ++ results = null; ++ } else { ++ results = tabEvent.getCompletions(); ++ } ++ } + // Paper end + if (results == null) { + return builder.buildFuture(); |