Skip to content

NPE when accessing CommandSourceStack#getLocation() #13387

Description

@TBlueF

Stack trace

[Server thread/ERROR]: Error executing task on Server
java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.Level.getWorld()" because "level" is null
	at io.papermc.paper.command.brigadier.PaperCommandSourceStack.getLocation(PaperCommandSourceStack.java:25) ~[paper-1.21.11.jar:?]
	at bluemap-5.14-paper.jar//de.bluecolored.bluemap.bukkit.BukkitCommandSource.getWorld(BukkitCommandSource.java:69) ~[?:?]
	at bluemap-5.14-paper.jar//de.bluecolored.bluemap.common.commands.Commands.lambda$create$7(Commands.java:82) ~[?:?]
	at bluemap-5.14-paper.jar//de.bluecolored.bluecommands.BlueCommands.checkContext(BlueCommands.java:259) ~[?:?]
	at bluemap-5.14-paper.jar//de.bluecolored.bluecommands.MethodCommandExecutable.isValid(MethodCommandExecutable.java:99) ~[?:?]
	at bluemap-5.14-paper.jar//de.bluecolored.bluecommands.Command.checkValid(Command.java:149) ~[?:?]
	at bluemap-5.14-paper.jar//de.bluecolored.bluecommands.Command.isValid(Command.java:141) ~[?:?]
	at bluemap-5.14-paper.jar//de.bluecolored.bluecommands.brigadier.BrigadierBridge.lambda$createCommandNodes$1(BrigadierBridge.java:86) ~[?:?]
	at net.minecraft.commands.Commands$1.isRestricted(Commands.java:185) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.network.protocol.game.ClientboundCommandsPacket.createEntry(ClientboundCommandsPacket.java:157) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.network.protocol.game.ClientboundCommandsPacket.createEntries(ClientboundCommandsPacket.java:106) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.network.protocol.game.ClientboundCommandsPacket.<init>(ClientboundCommandsPacket.java:48) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.commands.Commands.runSync(Commands.java:535) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.commands.Commands.lambda$sendAsync$7(Commands.java:518) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:177) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1527) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:188) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:151) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.server.MinecraftServer.runAllTasksAtTickStart(MinecraftServer.java:1179) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.server.MinecraftServer.processPacketsAndTick(MinecraftServer.java:1668) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1337) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:388) ~[paper-1.21.11.jar:1.21.11-38-4446f17]
	at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]

Full log: https://mclo.gs/A1izzfx

Plugin and Datapack List

BlueMap 5.14

Actions to reproduce (if known)

Register a command using Commands#register(LiteralCommandNode) and inside the commands ArgumentBuilder#requires() check, try to access the command-sources location.

Then join the server with a player with full permissions (op).

For this test i set-up a fresh paper-server, installed BlueMap, gave myself op-permissions and joined the server:
The error is then thrown here
(commands are registered here).

Paper version

> version
[11:00:34 INFO]: Checking version, please wait...
[11:00:34 INFO]: This server is running Paper version 1.21.11-38-main@4446f17 (2025-12-09T22:51:57Z) (Implementing API version 1.21.11-R0.1-SNAPSHOT)
You are running the latest version

Other

The same scenario/code works fine in any 1.21.10 paper version.

Activity

  1. added theissue type on Dec 11, 2025
  2. Doc94 commented on Dec 11, 2025

    @Doc94
    SponsorMember

    Add a simple code who throws the error.

        @Override
        public void onEnable() {
            this.getServer().getPluginManager().registerEvents(this, this);
    
            final LifecycleEventManager<Plugin> lifecycleManager = this.getLifecycleManager();
            lifecycleManager.registerEventHandler(LifecycleEvents.COMMANDS, event -> {
                final Commands commands = event.registrar();
                commands.register(Commands.literal("test")
                    .requires(sender -> {
                        return sender.getLocation() != null; // marked with not null but need for trigger
                    })
                    .executes(ctx -> {
                        ctx.getSource().getSender().sendPlainMessage(ctx.getSource().getLocation().toString());
                        return Command.SINGLE_SUCCESS;
                    }).build()
                );
            });
        }
  3. added
    status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.
    and removed on Dec 11, 2025
  4. added 2 commits that reference this issue on Dec 17, 2025
    4267784
    f191496
  5. creekorful commented on Jan 4, 2026

    @creekorful

    Hello everyone,

    Fresh update from MC 1.21.9 to 1.21.11 and I am facing the same issue, this make all autocompletion of command impossible.
    Will this be looking at?

    Many thanks and happy new year!

    Cheers

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.version: 1.21.11Game version 1.21.11

    Type

    Fields

    MC Issue

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions