Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7945

`Bukkit#dispatchCommand` throws `UnsupportedOperationException` for players

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • >version [13:11:35] [Server thread/INFO]: This server is running CraftBukkit version 4369-Spigot-e65d67a-285df6e (MC: 1.21.3) (Implementing API version 1.21.3-R0.1-SNAPSHOT) [13:11:35] [Server thread/INFO]: Checking version, please wait... [13:11:35] [Th
    • Yes

      Based on https://github.com/PaperMC/Paper/issues/11562

       

      What I did:

      Registered a listener that runs a command as a player when they join the server:

      public final class BukkitTestPlugin extends JavaPlugin {
          @Override
          public void onEnable() {
              Bukkit.getPluginManager().registerEvents(new Listener() {
                  @EventHandler
                  public void onPlayerJoin(final PlayerJoinEvent event) {
                      final Player player = event.getPlayer();
      
                      Bukkit.dispatchCommand(player, "say Hello World!");
                  }
              }, this);
          }
      } 

       

      Excepted result:{}

      On 1.21.1, the command runs as expected:

      [13:07:59] [User Authenticator #1/INFO]: UUID of player willkroboth is efff2855-758f-45d6-8a35-8d6fdde5c78c
      [13:08:00] [Server thread/INFO]: [Not Secure] [willkroboth] Hello World!
      [13:08:00] [Server thread/INFO]: willkroboth joined the game
      [13:08:00] [Server thread/INFO]: willkroboth[/127.0.0.1:50752] logged in with entity id 52 at ([world]-29.5, 71.0, 60.5)
      >version
      [13:08:06] [Server thread/INFO]: This server is running CraftBukkit version 4344-Spigot-a759b62-19bf846 (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
      [13:08:06] [Server thread/INFO]: Checking version, please wait...
      [13:08:06] [Thread-8/INFO]: You are 28 version(s) behind 

      Actual result:

      On 1.21.3, an error occurs:

      [13:10:49] [User Authenticator #1/INFO]: UUID of player willkroboth is efff2855-758f-45d6-8a35-8d6fdde5c78c
      [13:10:50] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to BukkitTestPlugin v1.0-SNAPSHOT
      org.bukkit.event.EventException: null
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:601) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:588) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              at net.minecraft.server.players.PlayerList.a(PlayerList.java:299) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.network.ServerConfigurationPacketListenerImpl.a(ServerConfigurationPacketListenerImpl.java:168) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.a(SourceFile:22) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.a(SourceFile:8) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$0(PlayerConnectionUtils.java:35) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:164) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1319) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:210) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.util.thread.IAsyncTaskHandler.B(SourceFile:138) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.MinecraftServer.bv(MinecraftServer.java:1298) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.MinecraftServer.B(MinecraftServer.java:1291) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.util.thread.IAsyncTaskHandler.b(SourceFile:147) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1248) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.MinecraftServer.x_(MinecraftServer.java:1258) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1101) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:329) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
      Caused by: org.bukkit.command.CommandException: Unhandled exception executing 'say Hello World!' in org.bukkit.craftbukkit.v1_21_R2.command.VanillaCommandWrapper(say)
              at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:157) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.craftbukkit.v1_21_R2.CraftServer.dispatchCommand(CraftServer.java:925) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at org.bukkit.Bukkit.dispatchCommand(Bukkit.java:921) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              at me.willkroboth.bukkitTestPlugin.BukkitTestPlugin$1.onPlayerJoin(BukkitTestPlugin.java:18) ~[?:?]
              at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
              at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              ... 22 more
      Caused by: java.lang.UnsupportedOperationException: Not supported yet.
              at net.minecraft.commands.ICommandListener$1.getBukkitSender(ICommandListener.java:29) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.commands.CommandListenerWrapper.getBukkitSender(CommandListenerWrapper.java:423) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.commands.CommandListenerWrapper.hasPermission(CommandListenerWrapper.java:190) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.commands.CommandListenerWrapper.c(CommandListenerWrapper.java:180) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at net.minecraft.server.commands.CommandSay.a(SourceFile:18) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at com.mojang.brigadier.tree.CommandNode.canUse(CommandNode.java:79) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:302) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:?]
              at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:292) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:?]
              at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:260) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:?]
              at net.minecraft.commands.CommandDispatcher.performPrefixedCommand(CommandDispatcher.java:323) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at org.bukkit.craftbukkit.v1_21_R2.command.VanillaCommandWrapper.execute(VanillaCommandWrapper.java:43) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:150) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.craftbukkit.v1_21_R2.CraftServer.dispatchCommand(CraftServer.java:925) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:4369-Spigot-e65d67a-285df6e]
              at org.bukkit.Bukkit.dispatchCommand(Bukkit.java:921) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              at me.willkroboth.bukkitTestPlugin.BukkitTestPlugin$1.onPlayerJoin(BukkitTestPlugin.java:18) ~[?:?]
              at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
              at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
              ... 22 more
      [13:10:50] [Server thread/INFO]: willkroboth joined the game
      [13:10:50] [Server thread/INFO]: willkroboth[/127.0.0.1:47944] logged in with entity id 107 at ([world]-29.5, 71.0, 60.5)
      >version
      [13:11:35] [Server thread/INFO]: This server is running CraftBukkit version 4369-Spigot-e65d67a-285df6e (MC: 1.21.3) (Implementing API version 1.21.3-R0.1-SNAPSHOT)
      [13:11:35] [Server thread/INFO]: Checking version, please wait...
      [13:11:35] [Thread-9/INFO]: You are running the latest version 

      The same error occurs using `Player#performCommand` (which is the method used in the Paper issue), which makes sense since it looks like it just calls `dispatchCommand`.

            Unassigned Unassigned
            WillKroboth Will Kroboth
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: