-
-
Notifications
You must be signed in to change notification settings - Fork 109
support color to filled map item #2504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
86e0b7c
4274ed5
cf1f6f6
012726e
5fc27b7
2925c54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,15 +20,16 @@ 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 | ||
|| mat == Material.LEATHER_LEGGINGS | ||
|| 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))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i thought it was correct because i follow on this line.... but, i realize and didn't get how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this whole file is weird and needs cleaning up, but not really required for your PR to fix pre-existing issues (it'd be really handy if you did tho! - check #2355 if you're interested in helping cleanup the codebase) |
||
} | ||
if (mat == Material.FILLED_MAP){ | ||
pobab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
MapMeta mapMeta = (MapMeta) item.getItemMeta(); | ||
if (!mapMeta.hasColor()){ | ||
return BukkitColorExtensions.fromColor(Color.WHITE).getObjectAttribute(attribute.fulfill(1)); | ||
|
||
} | ||
return BukkitColorExtensions.fromColor((mapMeta.getColor())).getObjectAttribute(attribute.fulfill(1)); | ||
|
||
} | ||
return BukkitColorExtensions.fromColor(((LeatherArmorMeta) item.getItemMeta()).getColor()).getObjectAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
|
@@ -113,7 +122,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 | ||
// <ItemTag.color> | ||
// --> | ||
|
@@ -127,6 +136,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); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing comma:
potions,