-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Bukkit#createCommandSender #488
Comments
Is this just going to be a case of adding support for |
In my personal case, adding support for As for generic |
I don't think supporting generic
public static CommandListenerWrapper getListener(CommandSender sender) {
if (sender instanceof Entity) {
if (sender instanceof CommandMinecart) {
return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock().createCommandSourceStack();
}
return ((CraftEntity) sender).getHandle().createCommandSourceStack();
}
if (sender instanceof BlockCommandSender) {
return ((CraftBlockCommandSender) sender).getWrapper();
}
if (sender instanceof RemoteConsoleCommandSender) {
return ((CraftRemoteConsoleCommandSender) sender).getListener().createCommandSourceStack();
}
if (sender instanceof ConsoleCommandSender) {
return ((CraftServer) sender.getServer()).getServer().createCommandSourceStack();
}
if (sender instanceof ProxiedCommandSender) {
return ((ProxiedNativeCommandSender) sender).getHandle();
}
throw new IllegalArgumentException("Cannot make " + sender + " a vanilla command listener");
} This method only succeeds if the The issue here only occurs because Paper added special logic to make their diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
index 45e85f252acd72800956cc2a120564256d2de797..c3742b6c4abea173b38307048091fc56bd5051d7 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
@@ -83,6 +83,11 @@ public final class VanillaCommandWrapper extends BukkitCommand {
if (sender instanceof ProxiedCommandSender) {
return ((ProxiedNativeCommandSender) sender).getHandle();
}
+ // Paper start
+ if (sender instanceof io.papermc.paper.commands.FeedbackForwardingSender feedback) {
+ return feedback.asVanilla();
+ }
+ // Paper end
throw new IllegalArgumentException("Cannot make " + sender + " a vanilla command listener");
} So yeah, this should just be a case of adding support for |
@willkroboth Thanks for the insight. Let's go ahead with adding support for |
Implemented for 9.2.0's release. I haven't been able to write an automatic test for this, however was able to verify it works with a manual test:
|
Implemented in 9.2.0. |
CommandAPI version
9.1.0
Minecraft version
1.20.1
Are you shading the CommandAPI?
Yes
What I did
I encountered an issue when trying to use
Bukkit#createCommandSender
in combination withBukkit#dispatchCommand
.What actually happened
Executing commands from custom senders generated by
Bukkit#createCommandSender
results in aNullPointerException
(see below) due to incorrect handling by the CommandAPI.What should have happened
The CommandAPI should support the special
CommandSender
returned byBukkit#createCommandSender
.Server logs and CommandAPI config
Other
Given this method, the CommandAPI assumes that
CommandSender
will only be the types provided by Spigot. However, on Paper,Bukkit#createCommandSender
returnsio.papermc.paper.commands.FeedbackForwardingSender
, which extendsCommandSender
.The text was updated successfully, but these errors were encountered: