-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
PlotMeLocationExtension.java
67 lines (53 loc) · 1.98 KB
/
PlotMeLocationExtension.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
package com.denizenscript.depenizen.bukkit.extensions.plotme;
import com.denizenscript.depenizen.bukkit.extensions.dObjectExtension;
import com.denizenscript.depenizen.bukkit.objects.dPlot;
import com.worldcretornica.plotme_core.PlotMeCoreManager;
import com.worldcretornica.plotme_core.api.Location;
import com.worldcretornica.plotme_core.bukkit.api.BukkitWorld;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizencore.objects.Mechanism;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
public class PlotMeLocationExtension extends dObjectExtension {
public static boolean describes(dObject object) {
return object instanceof dLocation;
}
public static PlotMeLocationExtension getFrom(dObject object) {
if (!describes(object)) {
return null;
}
else {
return new PlotMeLocationExtension((dLocation) object);
}
}
///////////////////
// Instance Fields and Methods
/////////////
public static final String[] handledTags = new String[] {
"plot"
};
public static final String[] handledMechs = new String[] {
}; // None
private PlotMeLocationExtension(dLocation location) {
this.location = location;
}
dLocation location;
@Override
public String getAttribute(Attribute attribute) {
// <--[tag]
// @attribute <l@location.plot>
// @returns dPlot
// @description
// Returns the plot contained by this location.
// @Plugin DepenizenBukkit, PlotMe
// -->
if (attribute.startsWith("plot")) {
Location l = new Location(new BukkitWorld(location.getWorld()), location.getX(), location.getY(), location.getZ());
return new dPlot(PlotMeCoreManager.getInstance().getPlot(l)).getAttribute(attribute.fulfill(1));
}
return null;
}
@Override
public void adjust(Mechanism mechanism) {
}
}