blob: e664cef00ee9a88bdf8d22ddddda81ca5cbe6169 (
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
|
package io.dico.dicore.command.predef;
import io.dico.dicore.command.CommandException;
import io.dico.dicore.command.ExecutionContext;
import io.dico.dicore.command.IContextFilter;
import org.bukkit.command.CommandSender;
public class DefaultGroupCommand extends PredefinedCommand<DefaultGroupCommand> {
private static final DefaultGroupCommand instance;
private static final IContextFilter noArgumentFilter;
public static DefaultGroupCommand getInstance() {
return instance;
}
private DefaultGroupCommand(boolean modifiable) {
addContextFilter(IContextFilter.INHERIT_PERMISSIONS);
addContextFilter(noArgumentFilter);
this.modifiable = modifiable;
}
public DefaultGroupCommand() {
this(true);
}
@Override
protected DefaultGroupCommand newModifiableInstance() {
return new DefaultGroupCommand(true);
}
@Override
public String execute(CommandSender sender, ExecutionContext context) throws CommandException {
context.getAddress().getChatHandler().sendHelpMessage(sender, context, context.getAddress(), 1);
return null;
}
static {
noArgumentFilter = new IContextFilter() {
@Override
public void filterContext(ExecutionContext context) throws CommandException {
if (context.getBuffer().hasNext()) {
throw new CommandException("No such command: /" + context.getAddress().getAddress()
+ " " + context.getBuffer().next());
}
}
@Override
public Priority getPriority() {
return Priority.EARLY;
}
};
instance = new DefaultGroupCommand(false);
}
}
|