Skip to content

Commit

Permalink
add tag player.current_jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 3, 2020
1 parent 6d1cfab commit 516826f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Expand Up @@ -52,10 +52,10 @@ public void tagEvent(ReplaceableTagEvent event) {
else {
// <--[tag]
// @attribute <jobs[(<name>)]>
// @returns ListTag(dJob)/dJob
// @returns ListTag(JobsJobTag)/JobsJobTag
// @plugin Depenizen, Jobs
// @description
// Returns a list of all known dJobs, or the job by the given input name if one is given.
// Returns a list of all known jobs, or the job by the given input name if one is given.
// -->
ListTag jobList = new ListTag();
for (Job jb : Jobs.getJobs()) {
Expand Down
@@ -1,5 +1,6 @@
package com.denizenscript.depenizen.bukkit.properties.jobs;

import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.objects.properties.Property;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.depenizen.bukkit.objects.jobs.JobsJobTag;
Expand Down Expand Up @@ -42,7 +43,7 @@ public static JobsPlayerProperties getFrom(ObjectTag object) {
}

public static final String[] handledTags = new String[] {
"jobs"
"job", "jobs", "current_jobs"
};

public static final String[] handledMechs = new String[] {
Expand All @@ -58,13 +59,30 @@ private JobsPlayerProperties(PlayerTag player) {
public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <PlayerTag.jobs[<job>]>
// @attribute <PlayerTag.current_jobs>
// @returns ListTag(JobsJobTag)
// @plugin Depenizen, Jobs
// @description
// Returns a list of all jobs that the player is in.
// -->
if (attribute.startsWith("current_jobs")) {
ListTag jobList = new ListTag();
for (Job jb : Jobs.getJobs()) {
if (player.isInJob(jb)) {
jobList.addObject(new JobsJobTag(jb, player));
}
}
return jobList.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <PlayerTag.job[<job>]>
// @returns JobsJobTag
// @plugin Depenizen, Jobs
// @description
// Returns the job specified with the player's information attached.
// -->
if (attribute.startsWith("jobs")) {
if (attribute.startsWith("job") || attribute.startsWith("jobs")) {
Job job = null;
if (attribute.hasContext(1)) {
job = Jobs.getJob(attribute.getContext(1));
Expand Down

0 comments on commit 516826f

Please sign in to comment.