-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
ASkyBlockLocationExtension.java
77 lines (64 loc) · 2.45 KB
/
ASkyBlockLocationExtension.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
73
74
75
76
77
package com.denizenscript.depenizen.bukkit.extensions.askyblock;
import com.denizenscript.depenizen.bukkit.extensions.dObjectExtension;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import com.wasteofplastic.askyblock.Island;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
public class ASkyBlockLocationExtension extends dObjectExtension {
public static boolean describes(dObject pl) {
return pl instanceof dLocation;
}
public static ASkyBlockLocationExtension getFrom(dObject object) {
if (!describes(object)) {
return null;
}
return new ASkyBlockLocationExtension((dLocation) object);
}
public static final String[] handledTags = new String[] {
"skyblock"
};
public static final String[] handledMechs = new String[] {
}; // None
public ASkyBlockLocationExtension(dLocation location) {
this.location = location;
}
dLocation location;
ASkyBlockAPI api = ASkyBlockAPI.getInstance();
@Override
public String getAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
if (attribute.startsWith("skyblock")) {
attribute = attribute.fulfill(1);
// <--[tag]
// @attribute <l@location.skyblock.has_skyblock>
// @returns Element(Boolean)
// @description
// Returns whether the location has a skyblock.
// @Plugin Depenizen, A SkyBlock
// -->
if (attribute.startsWith("has_skyblock")) {
return new Element(api.getIslandAt(location) != null).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <l@location.skyblock.get_owner>
// @returns dPlayer
// @description
// Returns whether the owner of the skyblock at the location.
// @Plugin Depenizen, A SkyBlock
// -->
else if (attribute.startsWith("get_owner")) {
Island i = api.getIslandAt(location);
if (i == null) {
return null;
}
return new dPlayer(i.getOwner()).getAttribute(attribute.fulfill(1));
}
}
return null;
}
}