Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions patches/server/1051-verify-returned-suggestion-type.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Isaac - The456 <the456@the456gamer.dev>
Date: Mon, 19 Aug 2024 12:14:38 +0100
Subject: [PATCH] verify returned suggestion type

since generic types get erased at runtime, java doesn't actually know what is in the returned. List
convert it to a String array, which only accepts the one type, which throws the ArrayStoreException when failed. additionally, since this occurs in BukkitCommandNode, the plugin/commands class is not in the stacktrace.

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
index 0c3c82b28e581286b798ee58ca4193efc2faff4a..b7ff65d4ad8cedf2bac3f038b07afeb5de4a4baf 100644
--- a/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java
+++ b/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java
@@ -116,9 +116,10 @@ public class BukkitCommandNode extends LiteralCommandNode<CommandSourceStack> {
Location pos = context.getSource().getLocation();
try {
results = this.command.tabComplete(sender, this.literal, args, pos.clone());
- } catch (CommandException ex) {
+ results.toArray(new String[0]);
+ } catch (CommandException | ArrayStoreException ex) {
sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
- Bukkit.getServer().getLogger().log(Level.SEVERE, "Exception when " + sender.getName() + " attempted to tab complete " + builder.getRemaining(), ex);
+ Bukkit.getServer().getLogger().log(Level.SEVERE, "Exception when " + sender.getName() + " attempted to tab complete " + builder.getRemaining() + " from command " + this.command.getClass(), ex);
}

if (sender instanceof final Player player) {