/
RequirementsContext.java
68 lines (53 loc) · 1.71 KB
/
RequirementsContext.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
65
66
67
68
package net.aufdemrand.denizen.scripts.requirements;
import net.aufdemrand.denizen.objects.dNPC;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class RequirementsContext {
protected RequirementsMode mode;
protected List<String> list;
private Map<String, Object> objects = new HashMap<String, Object>();
protected dPlayer player = null;
protected dNPC npc = null;
protected ScriptContainer container;
public RequirementsContext(RequirementsMode mode, List<String> list, ScriptContainer scriptContainer) {
this.mode = mode;
this.list = list;
this.container = scriptContainer;
}
public RequirementsContext attachPlayer(dPlayer player) {
this.player = player;
return this;
}
public RequirementsContext attachNPC(dNPC npc) {
this.npc = npc;
return this;
}
public dNPC getNPC() {
return npc;
}
public dPlayer getPlayer() {
return player;
}
public ScriptContainer getScriptContainer() {
return container;
}
public RequirementsContext addObject(String key, Object obj) {
key = key.toUpperCase();
objects.put(key, obj);
return this;
}
public boolean hasObject(String key) {
key = key.toUpperCase();
return objects.containsKey(key);
}
public Object getObject(String key) {
key = key.toUpperCase();
if (objects.containsKey(key)) {
return objects.get(key);
}
return null;
}
}