-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
JobsSupport.java
73 lines (60 loc) · 2.58 KB
/
JobsSupport.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
69
70
71
72
73
package com.denizenscript.depenizen.bukkit.support.plugins;
import com.denizenscript.depenizen.bukkit.objects.jobs.properties.JobPlayer;
import com.denizenscript.depenizen.bukkit.support.Support;
import com.denizenscript.depenizen.bukkit.commands.JobsCommands;
import com.denizenscript.depenizen.bukkit.objects.jobs.JobsJob;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.Job;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.tags.Attribute;
import com.denizenscript.depenizen.bukkit.extensions.jobs.JobsPlayerExtension;
public class JobsSupport extends Support {
public JobsSupport() {
registerObjects(JobsJob.class);
registerProperty(JobPlayer.class, JobsJob.class);
registerProperty(JobsPlayerExtension.class, dPlayer.class);
registerAdditionalTags("jobs");
new JobsCommands().activate().as("jobs").withOptions("See Documentation.", 2);
}
@Override
public String additionalTags(Attribute attribute, TagContext tagContext) {
if (attribute.startsWith("jobs")) {
// JobsTags require a... dJob!
JobsJob j = null;
// Job tag may specify a new job in the <jobs[context]...> portion of the tag.
// Check if this is a valid player and update the dPlayer object reference.
if (attribute.hasContext(1)) {
if (JobsJob.matches(attribute.getContext(1))) {
j = JobsJob.valueOf(attribute.getContext(1));
}
else {
dB.echoError("Could not match '" + attribute.getContext(1) + "' to a valid job!");
return null;
}
}
else {
// <--[tag]
// @attribute <jobs>
// @returns dList
// @description
// Returns a list of all known dJobs.
// @Plugin DepenizenBukkit, Jobs
// -->
dList jobList = new dList();
for (Job jb : Jobs.getJobs()) {
jobList.add(new JobsJob(jb).identify());
}
return jobList.getAttribute(attribute.fulfill(1));
}
if (j == null) {
dB.echoError("Invalid or missing job!");
return null;
}
return j.getAttribute(attribute.fulfill(1));
}
return null;
}
}