-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
ResidenceLocationProperties.java
91 lines (76 loc) · 2.72 KB
/
ResidenceLocationProperties.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.denizenscript.depenizen.bukkit.properties.residence;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.Mechanism;
import com.denizenscript.depenizen.bukkit.objects.residence.dResidence;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
public class ResidenceLocationProperties implements Property {
@Override
public String getPropertyString() {
return null;
}
@Override
public String getPropertyId() {
return "ResidenceLocation";
}
public static boolean describes(dObject object) {
return object instanceof dLocation;
}
public static ResidenceLocationProperties getFrom(dObject object) {
if (!describes(object)) {
return null;
}
else {
return new ResidenceLocationProperties((dLocation) object);
}
}
///////////////////
// Instance Fields and Methods
/////////////
public static final String[] handledTags = new String[] {
"has_residence", "residence"
};
public static final String[] handledMechs = new String[] {
}; // None
private ResidenceLocationProperties(dLocation location) {
this.location = location;
}
dLocation location;
@Override
public String getAttribute(Attribute attribute) {
// <--[tag]
// @attribute <l@location.has_residence>
// @returns Element(Boolean)
// @description
// Returns if the location has a residence.
// @Plugin Depenizen, Residence
// -->
if (attribute.startsWith("has_residence")) {
ClaimedResidence res = Residence.getInstance().getResidenceManager().getByLoc(location);
return new Element(res != null).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <l@location.residence>
// @returns dResidence
// @description
// Returns the residence contained by this location.
// @Plugin Depenizen, Residence
// -->
if (attribute.startsWith("residence")) {
ClaimedResidence res = Residence.getInstance().getResidenceManager().getByLoc(location);
if (res != null) {
return new dResidence(res).getAttribute(attribute.fulfill(1));
}
return null;
}
return null;
}
@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();
}
}