PaperMC / PaperMC/Paper

Unable to execute commands in console before worlds are loaded

Open
#13,580 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: accepted upstream: vanilla version: 1.21.11
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Commands.java around executeCommandInContext and the console input path in DedicatedServer.handleConsoleInputs, using the provided stack trace to follow why CommandSourceStack.getLevel() is null during startup. Reproduce by issuing a command while worlds and plugins are loading. Done means console commands no longer produce this exception before loading completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.