Repository navigation
Expand file tree
/
Copy pathPlayerCommandHandler.java
More file actions
67 lines (53 loc) · 1.82 KB
/
Copy pathPlayerCommandHandler.java
File metadata and controls
67 lines (53 loc) · 1.82 KB
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
61
62
63
64
65
66
67
package com.bencodez.simpleapi.command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class PlayerCommandHandler extends CommandHandler {
private int playerArg = -1;
public PlayerCommandHandler(JavaPlugin plugin) {
super(plugin);
figureOutPlayerArg();
}
public PlayerCommandHandler(JavaPlugin plugin, String[] args, String perm) {
super(plugin, args, perm);
figureOutPlayerArg();
}
public PlayerCommandHandler(JavaPlugin plugin, String[] args, String perm, String helpMessage) {
super(plugin, args, perm, helpMessage);
figureOutPlayerArg();
}
public PlayerCommandHandler(JavaPlugin plugin, String[] args, String perm, String helpMessage,
boolean allowConsole) {
super(plugin, args, perm, helpMessage, allowConsole);
figureOutPlayerArg();
}
public PlayerCommandHandler(JavaPlugin plugin, String[] args, String perm, String helpMessage, boolean allowConsole,
boolean forceConsole) {
super(plugin, args, perm, helpMessage, allowConsole, forceConsole);
figureOutPlayerArg();
}
@Override
public void execute(CommandSender sender, String[] args) {
if (playerArg >= 0) {
if (args[playerArg].equalsIgnoreCase("all")) {
executeAll(sender, args);
}
}
executeSinglePlayer(sender, args);
}
public abstract void executeAll(CommandSender sender, String[] args);
public abstract void executeSinglePlayer(CommandSender sender, String[] args);
private void figureOutPlayerArg() {
for (int i = 0; i < getArgs().length; i++) {
if (getArgs()[i].equalsIgnoreCase("(player)")) {
playerArg = i;
return;
}
}
debug("Failed to figure out player arg number for: " + getArgs());
}
@Override
public void setArgs(String[] args) {
super.setArgs(args);
figureOutPlayerArg();
}
}