blob: 57ef3168afa10ee18519488fd9fbb72f8db8f95f (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package com.thatgravyboat.skyblockhud.commands;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.BlockPos;
/**
@author Moulberry
**/
public class SimpleCommand extends CommandBase {
private String commandName;
private ProcessCommandRunnable runnable;
private TabCompleteRunnable tabRunnable;
public SimpleCommand(String commandName, ProcessCommandRunnable runnable) {
this.commandName = commandName;
this.runnable = runnable;
}
public SimpleCommand(String commandName, ProcessCommandRunnable runnable, TabCompleteRunnable tabRunnable) {
this.commandName = commandName;
this.runnable = runnable;
this.tabRunnable = tabRunnable;
}
public abstract static class ProcessCommandRunnable {
public abstract void processCommand(ICommandSender sender, String[] args);
}
public abstract static class TabCompleteRunnable {
public abstract List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos);
}
public boolean canCommandSenderUseCommand(ICommandSender sender) {
return true;
}
public String getCommandName() {
return commandName;
}
public String getCommandUsage(ICommandSender sender) {
return "/" + commandName;
}
@Override
public void processCommand(ICommandSender sender, String[] args) {
runnable.processCommand(sender, args);
}
@Override
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
if (tabRunnable != null) return tabRunnable.tabComplete(sender, args, pos);
return null;
}
}
|