/
AreaShopPlayerExtension.java
72 lines (59 loc) · 2.21 KB
/
AreaShopPlayerExtension.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
66
67
68
69
70
71
72
package com.denizenscript.depenizen.bukkit.extensions.areashop;
import com.denizenscript.depenizen.bukkit.objects.areashop.dAreaShop;
import me.wiefferink.areashop.AreaShop;
import me.wiefferink.areashop.regions.GeneralRegion;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
import com.denizenscript.depenizen.bukkit.extensions.dObjectExtension;
import java.util.UUID;
public class AreaShopPlayerExtension extends dObjectExtension {
public static boolean describes(dObject object) {
return object instanceof dPlayer;
}
public static AreaShopPlayerExtension getFrom(dObject object) {
if (!describes(object)) {
return null;
}
else {
return new AreaShopPlayerExtension((dPlayer) object);
}
}
public static final String[] handledTags = new String[] {
"areashop"
};
public static final String[] handledMechs = new String[] {
}; // None
private AreaShopPlayerExtension(dPlayer player) {
this.player = player;
}
dPlayer player = null;
@Override
public String getAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
if (attribute.startsWith("areashop")) {
attribute = attribute.fulfill(1);
// <--[tag]
// @attribute <p@player.areashop.owned>
// @returns dList(AreaShop)
// @description
// Returns a list of AreaShops the player owns.
// @Plugin DepenizenBukkit, AreaShop
// -->
if (attribute.startsWith("owned")) {
dList list = new dList();
UUID uuid = player.getOfflinePlayer().getUniqueId();
for (GeneralRegion region : AreaShop.getInstance().getFileManager().getRegions()) {
if (uuid.equals(region.getOwner())) {
list.add(new dAreaShop(region).identify());
}
}
return list.getAttribute(attribute.fulfill(1));
}
}
return null;
}
}