Question Why cant i use advancedCommandRoot

  • After careful consideration and due to limited usage, we’ve made the decision to discontinue the PaperMC forums. Moving forward, we recommend using Hangar for plugin uploads, and for all other community discussions and support, please join us on Discord.

Cabbage

New member
Apr 5, 2025
3
1
3
when i try to use the exmaple that the paper docs give it gives me an error that
C:\Users\Cabbage\IdeaProjects\untitled1\src\main\java\com\cabbage\testplugin\coolcommand.java:9: error: <identifier> expected
advancedCommandRoot.then(killall);
^
C:\Users\Cabbage\IdeaProjects\untitled1\src\main\java\com\cabbage\testplugin\coolcommand.java:9: error: <identifier> expected
advancedCommandRoot.then(killall);

and also that advancedCommandRoot is not used
^

package com.cabbage.testplugin;

import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import io.papermc.paper.command.brigadier.Commands;

public class coolcommand {
LiteralArgumentBuilder<CommandSourceStack> advancedCommandRoot = Commands.literal("advanced");
advancedCommandRoot.then(killall);
advancedCommandRoot.then(eat);
}
 

electronicboy

Administrator
Staff member
Dec 11, 2021
321
18
68
28
You can’t have actual code inside of the class body, you’d want to place that inside of a method, generally a static method called register is the canonical way to separate that stuff up into classes