/
ItemColor.java
57 lines (38 loc) · 1.16 KB
/
ItemColor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package net.aufdemrand.denizen.objects.properties;
import net.aufdemrand.denizen.objects.dColor;
import net.aufdemrand.denizen.objects.dItem;
import net.aufdemrand.denizen.tags.Attribute;
import org.bukkit.Color;
import org.bukkit.material.Colorable;
public class ItemColor implements Property {
public static boolean describes(dItem item) {
if (item.getItemStack() instanceof Colorable)
return true;
else return false;
}
public static ItemColor getFrom(dItem item) {
if (!describes(item)) return null;
else return new ItemColor(item);
}
private ItemColor(dItem item) {
colorable = item;
}
dItem colorable;
dColor color;
public dColor getColor() {
return new dColor(Color.RED);
}
@Override
public String getAttributes(Attribute attribute) {
if (attribute == null) return "null";
return color.getAttribute(attribute.fulfill(1));
}
@Override
public String getPropertyString() {
return getPropertyId() + '=' + color.identify() + ';';
}
@Override
public String getPropertyId() {
return "color";
}
}