Skip to content

Commit

Permalink
add tag player.magicspells.known_spells, for #306
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 2, 2020
1 parent 943e41d commit 3040ee7
Showing 1 changed file with 22 additions and 0 deletions.
@@ -1,8 +1,11 @@
package com.denizenscript.depenizen.bukkit.properties.magicspells;

import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.objects.properties.Property;
import com.denizenscript.denizencore.objects.Mechanism;
import com.nisovin.magicspells.MagicSpells;
import com.nisovin.magicspells.Spell;
import com.nisovin.magicspells.Spellbook;
import com.nisovin.magicspells.mana.ManaHandler;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
Expand Down Expand Up @@ -90,6 +93,25 @@ public String getAttribute(Attribute attribute) {
return new ElementTag(mH.getMaxMana(player.getPlayerEntity()))
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <PlayerTag.magicspells.known_spells>
// @returns ListTag
// @plugin Depenizen, MagicSpells
// @description
// Returns a list of spells the player knows, by internal name.
// -->
if (attribute.startsWith("known_spells")) {
Spellbook book = MagicSpells.getSpellbook(player.getPlayerEntity());
if (book == null) {
return null;
}
ListTag result = new ListTag();
for (Spell spell : book.getSpells()) {
result.add(spell.getInternalName());
}
return result.getAttribute(attribute.fulfill(1));
}
}

return null;
Expand Down

0 comments on commit 3040ee7

Please sign in to comment.