aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/bscv/commands/AbstractCommand.java
blob: 9568237c6011a44a22a574a7af5d721c7db95853 (plain) (blame)
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
package ftbsc.bscv.commands;

import java.util.Collections;
import java.util.List;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;

import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.ICommand;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;

public abstract class AbstractCommand implements ICommand, ICommons {

   public String getName() {
      return this.getClass().getSimpleName();
   }

   public CommandDispatcher<CommandSource> getDispatcher() {
      return Boscovicino.modManager.getDispatcher();
   }

   public List<LiteralArgumentBuilder<CommandSource>> subcommands() {
      return Collections.emptyList();
   }

   abstract LiteralArgumentBuilder<CommandSource> register(LiteralArgumentBuilder<CommandSource> builder);

   public AbstractCommand() {
      LiteralArgumentBuilder<CommandSource> builder = Commands.literal(this.getName().toLowerCase());
      this.getDispatcher().register(this.register(builder));
   }
}