-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
TownyLocationTags.java
77 lines (60 loc) · 2.03 KB
/
TownyLocationTags.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 net.gnomeffinway.depenizen.extensions.towny;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import net.aufdemrand.denizen.objects.Mechanism;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dObject;
import net.aufdemrand.denizen.objects.properties.Property;
import net.aufdemrand.denizen.tags.Attribute;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.gnomeffinway.depenizen.objects.dTown;
public class TownyLocationTags implements Property {
public static boolean describes(dObject loc) {
return loc instanceof dLocation;
}
public static TownyLocationTags getFrom(dObject loc) {
if (!describes(loc)) return null;
else return new TownyLocationTags((dLocation) loc);
}
///////////////////
// Instance Fields and Methods
/////////////
private TownyLocationTags(dLocation loc) {
location = loc;
}
dLocation location = null;
/////////
// Property Methods
///////
@Override
public String getPropertyString() {
return null;
}
@Override
public String getPropertyId() {
return "TownyLocationTags";
}
@Override
public String getAttribute(Attribute attribute) {
// <--[tag]
// @attribute <l@location.town>
// @returns dTown
// @description
// Returns the town at the specified location.
// @plugin Towny
// -->
if (attribute.startsWith("town")) {
try {
return new dTown(TownyUniverse.getDataSource().getTown(TownyUniverse.getTownName(location)))
.getAttribute(attribute.fulfill(1));
}
catch (NotRegisteredException ex) {
dB.echoError(location.identifySimple() + " is not registered to a town!");
return "null";
}
}
return null;
}
@Override
public void adjust(Mechanism mechanism) {}
}