Skip to content

Unable to execute commands in console before worlds are loaded #13580

Open

Description

@molor

Expected behavior

All commands executed w/o issues after the server is done loading.

Observed/Actual behavior

Command exception: /version
java.lang.NullPointerException: Cannot invoke "net.minecraft.server.level.ServerLevel.getGameRules()" because the return value of "net.minecraft.commands.CommandSourceStack.getLevel()" is null
        at net.minecraft.commands.Commands.executeCommandInContext(Commands.java:462) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.commands.Commands.performCommand(Commands.java:374) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.commands.Commands.performCommand(Commands.java:362) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.commands.Commands.performPrefixedCommand(Commands.java:353) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.server.dedicated.DedicatedServer.handleConsoleInputs(DedicatedServer.java:594) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.server.dedicated.DedicatedServer.tickConnection(DedicatedServer.java:550) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1838) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1616) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.server.dedicated.DedicatedServer.tickServer(DedicatedServer.java:427) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.server.MinecraftServer.processPacketsAndTick(MinecraftServer.java:1672) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1340) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:388) ~[paper-1.21.11.jar:1.21.11-90-4b35f5c]
        at java.base/java.lang.Thread.run(Thread.java:1474) ~[?:?]
An unexpected error occurred trying to execute that command

Steps/models to reproduce

1. Install Windows Server 2025
2. Install Java 25
3. Download Paper from https://papermc.io/downloads/paper
4. Create a start script using https://docs.papermc.io/misc/tools/start-script-gen/
5. Run the server using generated script
6. Accept Mojang EULA

7. Download some plugins (at least 10) so that it takes some time to start the server
8. Run the server using the script again
9. During loading of the server, execute any command (i.e. version)
10. Wait for the server to finish loading & enabling plugins
11. Meet the exception

Plugin and Datapack List

As I understand it, list of plugins doesn't matter.

There are 3 data pack(s) enabled: [vanilla (built-in)], [paper (built-in)], [file/Bukkit (world)]]
There are no more data packs available

Paper version

This server is running Paper version 1.21.11-90-main@4b35f5c (2026-01-09T18:48:48Z) (Implementing API version 1.21.11-R0.1-SNAPSHOT)
You are 9 version(s) behind

Other

No response

Activity

  1. added theissue type on Jan 24, 2026
  2. added
    status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.
    and removed on Jan 26, 2026
  3. Doc94 commented on Jan 26, 2026

    @Doc94
    SponsorMember

    Confirmed in https://mojira.dev/MC-305939 its a Vanilla Bug.

  4. changed the title [-]An unexpected error occurred[/-] [+]Unable to execute commands in console before worlds are loaded[/+] on Jan 26, 2026
  5. Magicrafter13 commented on Jul 13, 2026

    @Magicrafter13

    Could we create a temporary workaround by not opening the stdin reader until the world is loaded, perhaps?

  6. wangzhizhou commented on Oct 2, 2026

    @wangzhizhou

    Confirming this is still present on Paper 26.2 (reported on 26.2-126; reproduced on 26.2-129) and — importantly — it reproduces with zero plugins, so it is definitely unrelated to any plugin:

    Minimal repro (no plugins, only built-in datapacks):

    1. Start the server.
    2. Before Done (…) appears, type a vanilla command in the console, e.g. list.
    3. Let startup finish → Command exception: /list + the same NPE.
    java.lang.NullPointerException: Cannot invoke "net.minecraft.server.level.ServerLevel.getGameRules()" because the return value of "net.minecraft.commands.CommandSourceStack.getLevel()" is null
    	at net.minecraft.commands.Commands.executeCommandInContext(Commands.java:463) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.commands.Commands.performCommand(Commands.java:378) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.commands.Commands.performCommand(Commands.java:366) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.commands.Commands.performPrefixedCommand(Commands.java:357) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.server.dedicated.DedicatedServer.handleConsoleInputs(DedicatedServer.java:574) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.server.dedicated.DedicatedServer.tickConnection(DedicatedServer.java:530) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1837) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1620) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.server.dedicated.DedicatedServer.tickServer(DedicatedServer.java:404) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.server.MinecraftServer.processPacketsAndTick(MinecraftServer.java:1678) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1348) ~[paper-26.2.jar:26.2-129-9240f58]
    	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:303) ~[?:?]
    	at java.base/java.lang.Thread.run(Thread.java:1474) ~[?:?]
    

    The exact same command issued after Done (…) succeeds, and running the server without any plugins changes nothing — so plugin list is indeed irrelevant.

    Consistent with the upstream: vanilla label: a console line entered before the overworld is loaded is queued as a ConsoleInput carrying the CommandSourceStack built at that moment by MinecraftServer#createCommandSourceStack(), whose level is findRespawnDimension() → overworld() (null while worlds are loading). When the queue is drained, Commands#executeCommandInContext builds the ExecutionContext with an unconditional getLevel().getGameRules(...) (verified by disassembly of net.minecraft.commands.Commands).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.upstream: vanillaIssue exists in vanilla Minecraft.version: 1.21.11Game version 1.21.11version: 26.3Game version 26.3

    Type

    Fields

    MC Issue

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions