10
10
import org .bukkit .Color ;
11
11
import org .bukkit .Material ;
12
12
import org .bukkit .inventory .meta .LeatherArmorMeta ;
13
+ import org .bukkit .inventory .meta .MapMeta ;
13
14
import org .bukkit .inventory .meta .PotionMeta ;
14
15
15
16
public class ItemColor implements Property {
@@ -19,15 +20,16 @@ public static boolean describes(ObjectTag item) {
19
20
return false ;
20
21
}
21
22
Material mat = ((ItemTag ) item ).getBukkitMaterial ();
22
- // Leather armor and potions
23
+ // Leather armor, potions, and filled map
23
24
return mat == Material .LEATHER_BOOTS
24
25
|| mat == Material .LEATHER_CHESTPLATE
25
26
|| mat == Material .LEATHER_HELMET
26
27
|| mat == Material .LEATHER_LEGGINGS
27
28
|| mat == Material .LEATHER_HORSE_ARMOR
28
29
|| mat == Material .POTION
29
30
|| mat == Material .SPLASH_POTION
30
- || mat == Material .LINGERING_POTION ;
31
+ || mat == Material .LINGERING_POTION
32
+ || mat == Material .FILLED_MAP ;
31
33
}
32
34
33
35
public static ItemColor getFrom (ObjectTag _item ) {
@@ -66,7 +68,7 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
66
68
// @mechanism ItemTag.color
67
69
// @group properties
68
70
// @description
69
- // Returns the color of the leather armor item or potion item.
71
+ // Returns the color of the leather armor item, potion item, or filled map item.
70
72
// -->
71
73
if (attribute .startsWith ("color" ) || attribute .startsWith ("dye_color" )) {
72
74
Material mat = item .getBukkitMaterial ();
@@ -79,6 +81,13 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
79
81
}
80
82
return BukkitColorExtensions .fromColor (pm .getColor ()).getObjectAttribute (attribute .fulfill ((1 )));
81
83
}
84
+ if (mat == Material .FILLED_MAP ) {
85
+ MapMeta mapMeta = (MapMeta ) item .getItemMeta ();
86
+ if (!mapMeta .hasColor ()) {
87
+ return null ;
88
+ }
89
+ return BukkitColorExtensions .fromColor (mapMeta .getColor ()).getObjectAttribute (attribute .fulfill (1 ));
90
+ }
82
91
return BukkitColorExtensions .fromColor (((LeatherArmorMeta ) item .getItemMeta ()).getColor ()).getObjectAttribute (attribute .fulfill (1 ));
83
92
}
84
93
@@ -97,6 +106,13 @@ public String getPropertyString() {
97
106
}
98
107
return BukkitColorExtensions .fromColor (pm .getColor ()).identify ();
99
108
}
109
+ if (mat == Material .FILLED_MAP ) {
110
+ MapMeta mapMeta = (MapMeta ) item .getItemMeta ();
111
+ if (!mapMeta .hasColor ()) {
112
+ return null ;
113
+ }
114
+ return BukkitColorExtensions .fromColor (mapMeta .getColor ()).identify ();
115
+ }
100
116
return BukkitColorExtensions .fromColor (((LeatherArmorMeta ) item .getItemMeta ()).getColor ()).identify ();
101
117
}
102
118
@@ -113,7 +129,7 @@ public void adjust(Mechanism mechanism) {
113
129
// @name color
114
130
// @input ColorTag
115
131
// @description
116
- // Sets the leather armor item's dye color or the potion item's color.
132
+ // Sets the leather armor item's dye color, potion item's color, or filled map item's color.
117
133
// @tags
118
134
// <ItemTag.color>
119
135
// -->
@@ -127,6 +143,12 @@ public void adjust(Mechanism mechanism) {
127
143
item .setItemMeta (meta );
128
144
return ;
129
145
}
146
+ if (mat == Material .FILLED_MAP ) {
147
+ MapMeta meta = (MapMeta ) item .getItemMeta ();
148
+ meta .setColor (BukkitColorExtensions .getColor (color ));
149
+ item .setItemMeta (meta );
150
+ return ;
151
+ }
130
152
LeatherArmorMeta meta = (LeatherArmorMeta ) item .getItemMeta ();
131
153
meta .setColor (BukkitColorExtensions .getColor (color ));
132
154
item .setItemMeta (meta );
0 commit comments