diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/item/ItemColor.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/item/ItemColor.java index 5a08bba992..2d2b9386fd 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/item/ItemColor.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/item/ItemColor.java @@ -10,6 +10,7 @@ import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.inventory.meta.MapMeta; import org.bukkit.inventory.meta.PotionMeta; public class ItemColor implements Property { @@ -19,7 +20,7 @@ public static boolean describes(ObjectTag item) { return false; } Material mat = ((ItemTag) item).getBukkitMaterial(); - // Leather armor and potions + // Leather armor, potions, and filled map return mat == Material.LEATHER_BOOTS || mat == Material.LEATHER_CHESTPLATE || mat == Material.LEATHER_HELMET @@ -27,7 +28,8 @@ public static boolean describes(ObjectTag item) { || mat == Material.LEATHER_HORSE_ARMOR || mat == Material.POTION || mat == Material.SPLASH_POTION - || mat == Material.LINGERING_POTION; + || mat == Material.LINGERING_POTION + || mat == Material.FILLED_MAP; } public static ItemColor getFrom(ObjectTag _item) { @@ -66,7 +68,7 @@ public ObjectTag getObjectAttribute(Attribute attribute) { // @mechanism ItemTag.color // @group properties // @description - // Returns the color of the leather armor item or potion item. + // Returns the color of the leather armor item, potion item, or filled map item. // --> if (attribute.startsWith("color") || attribute.startsWith("dye_color")) { Material mat = item.getBukkitMaterial(); @@ -79,6 +81,13 @@ public ObjectTag getObjectAttribute(Attribute attribute) { } return BukkitColorExtensions.fromColor(pm.getColor()).getObjectAttribute(attribute.fulfill((1))); } + if (mat == Material.FILLED_MAP) { + MapMeta mapMeta = (MapMeta) item.getItemMeta(); + if (!mapMeta.hasColor()) { + return null; + } + return BukkitColorExtensions.fromColor(mapMeta.getColor()).getObjectAttribute(attribute.fulfill(1)); + } return BukkitColorExtensions.fromColor(((LeatherArmorMeta) item.getItemMeta()).getColor()).getObjectAttribute(attribute.fulfill(1)); } @@ -97,6 +106,13 @@ public String getPropertyString() { } return BukkitColorExtensions.fromColor(pm.getColor()).identify(); } + if (mat == Material.FILLED_MAP) { + MapMeta mapMeta = (MapMeta) item.getItemMeta(); + if (!mapMeta.hasColor()) { + return null; + } + return BukkitColorExtensions.fromColor(mapMeta.getColor()).identify(); + } return BukkitColorExtensions.fromColor(((LeatherArmorMeta) item.getItemMeta()).getColor()).identify(); } @@ -113,7 +129,7 @@ public void adjust(Mechanism mechanism) { // @name color // @input ColorTag // @description - // Sets the leather armor item's dye color or the potion item's color. + // Sets the leather armor item's dye color, potion item's color, or filled map item's color. // @tags // // --> @@ -127,6 +143,12 @@ public void adjust(Mechanism mechanism) { item.setItemMeta(meta); return; } + if (mat == Material.FILLED_MAP) { + MapMeta meta = (MapMeta) item.getItemMeta(); + meta.setColor(BukkitColorExtensions.getColor(color)); + item.setItemMeta(meta); + return; + } LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta(); meta.setColor(BukkitColorExtensions.getColor(color)); item.setItemMeta(meta);