-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
ShopKeepersEntityExtension.java
65 lines (54 loc) · 1.94 KB
/
ShopKeepersEntityExtension.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
58
59
60
61
62
63
64
65
package com.morphanone.depenizenbukkit.extensions.shopkeepers;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
import com.morphanone.depenizenbukkit.extensions.dObjectExtension;
import com.morphanone.depenizenbukkit.objects.shopkeepers.ShopKeeper;
public class ShopKeepersEntityExtension extends dObjectExtension {
public static boolean describes(dObject object) {
return object instanceof dEntity;
}
public static ShopKeepersEntityExtension getFrom(dObject object) {
if (!describes(object)) {
return null;
}
else {
return new ShopKeepersEntityExtension((dEntity) object);
}
}
public ShopKeepersEntityExtension(dEntity entity) {
this.entity = entity;
this.isShopKeeper = ShopKeeper.isShopKeeper(entity);
}
dEntity entity;
boolean isShopKeeper = false;
@Override
public String getAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
// <--[tag]
// @attribute <e@entity.is_shopkeeper>
// @returns Element(Boolean)
// @description
// Returns whether the entity is a Shopkeeper.
// @plugin Depenizen, ShopKeepers
// -->
if (attribute.startsWith("is_shopkeeper")) {
return new Element(isShopKeeper)
.getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <e@entity.shopkeeper>
// @returns ShopKeeper
// @description
// Returns the ShopKeeper for this entity.
// @plugin Depenizen, ShopKeepers
// -->
else if (attribute.startsWith("shopkeeper") && isShopKeeper) {
return ShopKeeper.fromEntity(entity).getAttribute(attribute.fulfill(1));
}
return null;
}
}