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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
package me.Danker.commands.warp;
import net.minecraftforge.client.ClientCommandHandler;
import java.util.ArrayList;
import java.util.List;
public class WarpCommandHandler {
private List<WarpCommand> commands;
/**
* Constructor of the WarpCommandHandler, it will register all commands when it is created
*/
public WarpCommandHandler() {
this.commands = new ArrayList<WarpCommand>();
registerCommands();
}
/**
* @return List of all registered commands
*/
public List<WarpCommand> getCommands() {
return this.commands;
}
/**
* Registers a command to the handler
* @param warpCommand WarpCommand to register
*/
public void registerCommand(WarpCommand warpCommand) {
this.commands.add(warpCommand);
ClientCommandHandler.instance.registerCommand(warpCommand);
}
/**
* Get a command by its name
* @param name Name of the command
* @return WarpCommand with the given name
*/
public WarpCommand getCommand(String name) {
for (WarpCommand command : this.commands) {
if (command.getCommandName().equalsIgnoreCase(name)) {
return command;
}
}
return null;
}
/**
* Get a command by the class it extends from
* @param clazz Class to get the command from
* @return WarpCommand with the given class
*/
public WarpCommand getCommand(Class<? extends WarpCommand> clazz) {
for (WarpCommand command : this.commands) {
if (command.getClass() == clazz) {
return command;
}
}
return null;
}
/**
* Register all commands
*/
private void registerCommands() {
registerCommand(new WarpCommand("deep", "deep"));
registerCommand(new WarpCommand("nether", "nether"));
registerCommand(new WarpCommand("isle", "isle"));
registerCommand(new WarpCommand("crimson", "crimson"));
registerCommand(new WarpCommand("mines", "mines"));
registerCommand(new WarpCommand("forge", "forge"));
registerCommand(new WarpCommand("crystals", "crystals"));
registerCommand(new WarpCommand("gold", "gold"));
registerCommand(new WarpCommand("desert", "desert"));
registerCommand(new WarpCommand("spider", "spider"));
registerCommand(new WarpCommand("barn", "barn"));
registerCommand(new WarpCommand("end", "end"));
registerCommand(new WarpCommand("park", "park"));
registerCommand(new WarpCommand("castle", "castle"));
registerCommand(new WarpCommand("museum", "museum"));
registerCommand(new WarpCommand("da", "da"));
registerCommand(new WarpCommand("crypt", "crypt"));
registerCommand(new WarpCommand("nest", "nest"));
registerCommand(new WarpCommand("void", "void"));
registerCommand(new WarpCommand("drag", "dragon"));
registerCommand(new WarpCommand("jungle", "jungle"));
registerCommand(new WarpCommand("howl", "howl"));
registerCommand(new WarpCommand("dun", "dungeon_hub"));
}
}
|