Skip to content

Commit

Permalink
Add <hero@hero.in_combat> and <hero@hero.list_combatants>, fixes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Mar 7, 2015
1 parent d582034 commit 96920d4
Showing 1 changed file with 28 additions and 1 deletion.
Expand Up @@ -2,6 +2,7 @@

import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dNPC;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.utilities.debugging.dB;
Expand All @@ -16,6 +17,7 @@
import net.citizensnpcs.api.npc.NPC;
import net.gnomeffinway.depenizen.support.Support;
import net.gnomeffinway.depenizen.support.plugins.HeroesSupport;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

import java.util.regex.Matcher;
Expand Down Expand Up @@ -164,6 +166,17 @@ public String getAttribute(Attribute attribute) {
dB.echoError("Specified Hero is null! Are they online/spawned?");
}

// <--[tag]
// @attribute <hero@hero.in_combat[<entity>]>
// @returns Element(Boolean)
// @description
// Returns whether the hero is currently in combat.
// @plugin Depenizen, Heroes
// -->
else if (attribute.startsWith("in_combat")) {
return new Element(hero.isInCombat()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <hero@hero.level[<class>]>
// @returns Element(Number)
Expand All @@ -185,6 +198,21 @@ else if(attribute.startsWith("level")) {
return new Element(hero.getLevel()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <hero@hero.list_combatants>
// @returns dList(dEntity)
// @description
// Returns the list of entities the hero is currently in combat with.
// @plugin Depenizen, Heroes
// -->
else if (attribute.startsWith("list_combatants")) {
dList list = new dList();
for (Entity entity : hero.getCombatants().keySet()) {
list.add(new dEntity(entity).identify());
}
return list.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <hero@hero.party.leader>
// @returns dPlayer
Expand Down Expand Up @@ -247,6 +275,5 @@ else if(attribute.startsWith("level")) {
}

return new Element(identify()).getAttribute(attribute);

}
}

0 comments on commit 96920d4

Please sign in to comment.