summaryrefslogtreecommitdiff
path: root/dicore3/command/src/main/java/io/dico/dicore/command/predef/SyntaxCommand.java
blob: 853258457f84a8440b374256f41f0329f8b6a3e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package io.dico.dicore.command.predef;

import io.dico.dicore.command.*;
import org.bukkit.command.CommandSender;

/**
 * The syntax command
 */
public class SyntaxCommand extends PredefinedCommand<SyntaxCommand> {
    public static final SyntaxCommand INSTANCE = new SyntaxCommand(false);

    private SyntaxCommand(boolean modifiable) {
        super(modifiable);
        setDescription("Describes how to use the command");
    }

    @Override
    protected SyntaxCommand newModifiableInstance() {
        return new SyntaxCommand(true);
    }

    @Override
    public String execute(CommandSender sender, ExecutionContext context) throws CommandException {
        context.getAddress().getChatHandler().sendSyntaxMessage(sender, context, context.getAddress().getParent());
        return null;
    }

    public static void registerAsChild(ICommandAddress address) {
        registerAsChild(address, "syntax");
    }

    public static void registerAsChild(ICommandAddress address, String main, String... aliases) {
        ((ModifiableCommandAddress) address).addChild(new ChildCommandAddress(INSTANCE, main, aliases));
    }

}