From cc7d27cb4aab13706ad875ca755066ebf23e6449 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 12 Aug 2023 16:22:19 +1000 Subject: [PATCH] SPIGOT-7458: Exception when Entity CommandSender executes Vanilla command By: md_5 --- .../command/VanillaCommandWrapper.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java index b89882705a..cab4a66d0d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java @@ -20,9 +20,9 @@ import org.bukkit.command.ProxiedCommandSender; import org.bukkit.command.RemoteConsoleCommandSender; import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftMinecartCommand; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.entity.Player; +import org.bukkit.entity.Entity; import org.bukkit.entity.minecart.CommandMinecart; public final class VanillaCommandWrapper extends BukkitCommand { @@ -64,15 +64,16 @@ public final class VanillaCommandWrapper extends BukkitCommand { } public static CommandListenerWrapper getListener(CommandSender sender) { - if (sender instanceof Player) { - return ((CraftPlayer) sender).getHandle().createCommandSourceStack(); + 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 CommandMinecart) { - return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock().createCommandSourceStack(); - } if (sender instanceof RemoteConsoleCommandSender) { return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource.createCommandSourceStack(); }