JorelAli / CommandAPI

A Bukkit/Spigot API for the command UI introduced in Minecraft 1.13

Home Page:https://commandapi.jorel.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Executing commands via RCON throws an exception

Sytm opened this issue · comments

CommandAPI version

9.2.0

Minecraft version

1.20.2

Are you shading the CommandAPI?

Yes

What I did

Executed a command that has been registered with CommandAPI over the rcon protocol.

What actually happened

An exception has been thrown that says that the RemoteConsoleCommandSender cannot be wrapped

Unexpected exception while parsing console command "execute in minecraft:overworld run wps temporaryWaypoint Sytm 0 100 0"
org.bukkit.command.CommandException: Unhandled exception executing 'execute in minecraft:overworld run wps temporaryWaypoint Sytm 0 100 0' in org.bukkit.craftbukkit.v1_20_R2.command.VanillaCommandWrapper(execute)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:165) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R2.CraftServer.dispatchCommand(CraftServer.java:989) ~[paper-1.20.2.jar:git-Paper-222]
        at org.bukkit.craftbukkit.v1_20_R2.CraftServer.dispatchServerCommand(CraftServer.java:974) ~[paper-1.20.2.jar:git-Paper-222]
        at net.minecraft.server.dedicated.DedicatedServer.lambda$runCommand$4(DedicatedServer.java:788) ~[paper-1.20.2.jar:git-Paper-222]
        at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.2.jar:git-Paper-222]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1324) ~[paper-1.20.2.jar:git-Paper-222]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:193) ~[paper-1.20.2.jar:git-Paper-222]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1301) ~[paper-1.20.2.jar:git-Paper-222]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1294) ~[paper-1.20.2.jar:git-Paper-222]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1272) ~[paper-1.20.2.jar:git-Paper-222]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1160) ~[paper-1.20.2.jar:git-Paper-222]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.20.2.jar:git-Paper-222]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.RuntimeException: Failed to wrap CommandSender org.bukkit.craftbukkit.v1_20_R2.command.CraftRemoteConsoleCommandSender@4d4f2a11 to a CommandAPI-compatible BukkitCommandSender
        at dev.jorel.commandapi.CommandAPIBukkit.wrapCommandSender(CommandAPIBukkit.java:433) ~[?:?]
        at dev.jorel.commandapi.nms.NMS_Common.getCommandSenderFromCommandSource(NMS_Common.java:396) ~[?:?]
        at dev.jorel.commandapi.nms.NMS_Common.getCommandSenderFromCommandSource(NMS_Common.java:97) ~[?:?]
        at dev.jorel.commandapi.CommandAPIHandler.lambda$generatePermissions$1(CommandAPIHandler.java:362) ~[?:?]
        at com.mojang.brigadier.tree.CommandNode.canUse(CommandNode.java:79) ~[paper-1.20.2.jar:git-Paper-222]
        at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:360) ~[paper-1.20.2.jar:?]
        at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:390) ~[paper-1.20.2.jar:?]
        at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:390) ~[paper-1.20.2.jar:?]
        at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:394) ~[paper-1.20.2.jar:?]
        at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:394) ~[paper-1.20.2.jar:?]
        at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:350) ~[paper-1.20.2.jar:?]
        at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:318) ~[paper-1.20.2.jar:?]
        at net.minecraft.commands.Commands.performPrefixedCommand(Commands.java:309) ~[?:?]
        at org.bukkit.craftbukkit.v1_20_R2.command.VanillaCommandWrapper.execute(VanillaCommandWrapper.java:45) ~[paper-1.20.2.jar:git-Paper-222]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
        ... 18 more

What should have happened

The command should be executed with similar behaviour to the normal console

Server logs and CommandAPI config

No response

Other

The issue I described here happended when I tried to reproduce the issue a user of my plugin encountered below
image
Although I think this issue occurred on 9.0.3 when using RCON

I made a commit (07defff) that should add support for such command senders.
I am being honest, I have no idea how to set this up which is why I want to ask you if you could test that commit yourself?
It is on the dev/remote-console-command-sender branch :D

@DerEchtePilz Testing rcon is fairly simple:

  • Download an rcon client. I used rcon-cli and added the binary to my path

  • In your server's server.properties, enable rcon and set a password (for illustrative purposes, I used password):

    rcon.port=25575
    enable-rcon=true
    rcon.password=password
  • Run your server with the CommandAPI and a CommandAPI registered command

  • In a terminal, run the command with rcon:

    $ rcon -a localhost:25575 -p password "mycommand hello"

I've tested this feature myself and I can confirm it works! 🎉

Implemented in CommandAPI 9.3.0.