/
_templateCommand.java
64 lines (49 loc) · 1.98 KB
/
_templateCommand.java
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
package net.aufdemrand.denizencore.scripts.commands.core;
import net.aufdemrand.denizencore.exceptions.CommandExecutionException;
import net.aufdemrand.denizencore.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.aH;
import net.aufdemrand.denizencore.scripts.ScriptEntry;
import net.aufdemrand.denizencore.scripts.commands.AbstractCommand;
import net.aufdemrand.denizencore.utilities.debugging.dB;
/**
* Your command!
* This class is a template for a Command in Denizen.
* <p/>
* If loading externally, implement dExternal and its load() method.
*
* @author Jeremy Schroeder, mcmonkey
*/
public class _templateCommand extends AbstractCommand {
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {
// Interpret arguments
for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
if (!scriptEntry.hasObject("required_integer")
&& arg.matchesPrimitive(aH.PrimitiveType.Integer)) {
scriptEntry.addObject("required_integer", arg.asElement());
}
// else if (...)
else {
arg.reportUnhandled();
}
}
// Check for required information
if (!scriptEntry.hasObject("required_object")) {
throw new InvalidArgumentsException("Must have required object!");
}
}
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
// Fetch required objects
Element required_integer = scriptEntry.getElement("required_integer");
// dObject object = scriptEntry.getdObject("required_object");
// Debug the execution
dB.report(scriptEntry, getName(), required_integer.debug());
// Do the execution
// INSERT
// YOUR
// CODE
// HERE :)
}
}