Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing comma: potions,

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) {
Expand Down Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing comma

// -->
if (attribute.startsWith("color") || attribute.startsWith("dye_color")) {
Material mat = item.getBukkitMaterial();
Expand All @@ -79,6 +81,13 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
}
return BukkitColorExtensions.fromColor(pm.getColor()).getObjectAttribute(attribute.fulfill((1)));
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 getObjectAttribute work. should i change this line too?

Copy link
Member

Choose a reason for hiding this comment

The 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){
MapMeta mapMeta = (MapMeta) item.getItemMeta();
if (!mapMeta.hasColor()){
return BukkitColorExtensions.fromColor(Color.WHITE).getObjectAttribute(attribute.fulfill(1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is returning WHITE here correct? Seems like it should probably be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh... i dont know which default color of filled_map 😅, that why i put white color. i'll change it asap, thanks for remind me to using null

}
return BukkitColorExtensions.fromColor((mapMeta.getColor())).getObjectAttribute(attribute.fulfill(1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor format - too many parens here

}
return BukkitColorExtensions.fromColor(((LeatherArmorMeta) item.getItemMeta()).getColor()).getObjectAttribute(attribute.fulfill(1));
}

Expand Down Expand Up @@ -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>
// -->
Expand All @@ -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);
Expand Down