Question Why cant i use advancedCommandRoot

Cabbage

New member
Apr 5, 2025
3
0
1
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
309
18
61
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