Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Plugin Server Software Commands(ex. /restart) do not work in functions.

Open Bowswa opened this issue 4 years ago • 10 comments

Expected behavior

Expected behavior is that when i use the /restart command inside of a function the server restarts just fine.

Observed/Actual behavior

When using the /restart command in a function it produces this error: [ERROR] Failed to load function sched_restart:restart/paper

java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Whilst parsing command on line 1: Unknown or incomplete command, see below for error at position 0: <--[HERE] **Where the restart command is.

at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) ~[?:?]

at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) [?:?]

at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) [?:?]

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]

at java.lang.Thread.run(Unknown Source) [?:?]

Caused by: java.lang.IllegalArgumentException: Whilst parsing command on line 1: Unknown or incomplete command, see below for error at position 0: <--[HERE]

at net.minecraft.commands.CustomFunction.a(CustomFunction.java:68) ~[patched_1.17.1.jar:git-Paper-196]

at net.minecraft.server.CustomFunctionManager.lambda$reload$3(CustomFunctionManager.java:86) ~[patched_1.17.1.jar:git-Paper-196]

... 4 more

Steps/models to reproduce

https://github.com/Razboy20/version-proxy-mc-datapack Auto Restart Message v1.0.0.zip Use these datapacks on a paper server.

This will produce the error on startup.

Plugin list

None

Paper version

This server is running Paper version git-Paper-196 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) (Git: 59d449d)

You are running the latest version

Agreements

  • [X] I am running the latest version of Paper available from https://papermc.io/downloads.
  • [X] I have searched for and ensured there isn't already an open issue regarding this.
  • [X] My version of Minecraft is supported by Paper.

Other

No response

Bowswa avatar Aug 20 '21 00:08 Bowswa

Fairly sure this affects upstream as well. This is also kind of a related issue to plugin (and spigot/paper commands) not working when part of the /execute command.

Machine-Maker avatar Aug 20 '21 01:08 Machine-Maker

is this an issue with functions loading well before plugins and such or a command system issue, i wonder

electronicboy avatar Aug 20 '21 01:08 electronicboy

I don't think so, last I checked the commands aren't "parsed" until the function is actually ran, just saved as a list of strings that are sent to the brig command system.

Machine-Maker avatar Aug 20 '21 01:08 Machine-Maker

nms.Main#178 That call is what loads the datapacks

The big issue here is that this stuff is loaded weeeeelll before plugins and such are loaded

electronicboy avatar Aug 20 '21 01:08 electronicboy

Yeah I knew they were loaded well before, but I thought they were just stored as strings until they ran, but there is parsing done (CommandFunction line L42). I guess either it didnt use to do that, or I just had that wrong. My PR (https://github.com/PaperMC/Paper/pull/5527) would actually fix that, by product of adding custom advancement triggers.

Machine-Maker avatar Aug 20 '21 01:08 Machine-Maker

The big issue here is that this stuff is loaded weeeeelll before plugins and such are loaded

Yeah, so even if you enable the datapack after the plugins are already loaded, like you do /datapack enable it still comes out with the same error.

Yeah, this issue is really because of bukkit's whole CommandMap thing taking over command dispatching. The server's CommandDispatcher doesn't know about any plugin, bukkit, spigot, or paper commands. If that was fixed, then you'd run into the Unknown command thing cause stuff wasn't loaded. Only that second part would be fixed by that linked PR.

Machine-Maker avatar Aug 20 '21 03:08 Machine-Maker

so i guess do i need to report to bukkit? or will it still be fixed here

Bowswa avatar Aug 23 '21 01:08 Bowswa

You can go ahead an open an issue on spigot's JIRA if you want, but this doesn't strike me as a "simple" fix. PRs are welcome for sure though.

Machine-Maker avatar Aug 23 '21 22:08 Machine-Maker

but if you plan to work on this, please come to our discord and discuss your idea for a solution first, before potentially spending time going on a path we don't see viable.

MiniDigger avatar Aug 24 '21 07:08 MiniDigger

@MiniDigger whoops, see the linked PR for a solution that does fix this, but might break something else depending on how much I don’t know about how Bukkit took over commands.

Machine-Maker avatar Aug 24 '21 15:08 Machine-Maker