Skip to content

Commit

Permalink
add convenience tag item.potion_base_type
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 30, 2020
1 parent 396eccc commit cd44382
Showing 1 changed file with 16 additions and 2 deletions.
Expand Up @@ -41,7 +41,7 @@ public static ItemPotion getFrom(ObjectTag _item) {
}

public static final String[] handledTags = new String[] {
"potion_base", "has_potion_effect", "potion_effect"
"potion_base_type", "potion_base", "has_potion_effect", "potion_effect"
};

public static final String[] handledMechs = new String[] {
Expand Down Expand Up @@ -134,6 +134,20 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
boolean has = item.getItemStack().hasItemMeta() && item.getItemStack().getItemMeta() instanceof PotionMeta
&& ((PotionMeta) item.getItemStack().getItemMeta()).hasCustomEffects();

// <--[tag]
// @attribute <ItemTag.potion_base_type>
// @returns ElementTag
// @mechanism ItemTag.potion_effects
// @group properties
// @description
// Returns the base potion type name for this potion item.
// The type will be from <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionType.html>.
// -->
if (attribute.startsWith("potion_base_type") && item.getItemStack().hasItemMeta() && item.getItemStack().getItemMeta() instanceof PotionMeta) {
PotionMeta meta = ((PotionMeta) item.getItemStack().getItemMeta());
return new ElementTag(meta.getBasePotionData().getType().name()).getObjectAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <ItemTag.potion_base>
// @returns ElementTag
Expand All @@ -149,7 +163,7 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
return new ElementTag(meta.getBasePotionData().getType().name() + "," + (meta.getBasePotionData().isUpgraded() ? 2 : 1)
+ "," + meta.getBasePotionData().isExtended() + "," + (item.getItemStack().getType() == Material.SPLASH_POTION)
+ (meta.hasColor() ? "," + new ColorTag(meta.getColor()).identify() : "")
).getObjectAttribute(attribute.fulfill(1));
).getObjectAttribute(attribute.fulfill(1));
}

// <--[tag]
Expand Down

0 comments on commit cd44382

Please sign in to comment.