-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
SimpleClansPlayerExtension.java
194 lines (172 loc) · 7.18 KB
/
SimpleClansPlayerExtension.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package com.denizenscript.depenizen.bukkit.extensions.simpleclans;
import com.denizenscript.depenizen.bukkit.extensions.dObjectExtension;
import com.denizenscript.depenizen.bukkit.objects.dClan;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
public class SimpleClansPlayerExtension extends dObjectExtension {
public static boolean describes(dObject object) {
return object instanceof dPlayer;
}
public static SimpleClansPlayerExtension getFrom(dObject object) {
if (!describes(object)) {
return null;
}
else {
return new SimpleClansPlayerExtension((dPlayer) object);
}
}
public static final String[] handledTags = new String[] {
"simpleclans"
};
public static final String[] handledMechs = new String[] {
}; // None
private SimpleClansPlayerExtension(dPlayer player) {
this.player = player;
this.cplayer = new ClanPlayer(player.getOfflinePlayer().getUniqueId());
}
dPlayer player;
ClanPlayer cplayer;
@Override
public String getAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
if (attribute.startsWith("simpleclans")) {
attribute = attribute.fulfill(1);
// <--[tag]
// @attribute <p@player.simpleclans.clan>
// @returns dClan
// @description
// Returns the clan the player is in, if any.
// @Plugin Depenizen, SimpleClans
// -->
if (attribute.startsWith("clan")) {
dClan clan = dClan.forPlayer(player);
if (clan == null) {
return null;
}
return clan.getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <p@player.simpleclans.has_clan>
// @returns dClan
// @description
// Returns whether the player is in a clan.
// @Plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("has_clan")) {
return new Element(dClan.forPlayer(player) != null).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <p@player.simpleclans.kill_death_ratio>
// @returns Element(Decimal)
// @description
// Returns the player's kill-death ratio.
// @Plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("kill_death_ratio")) {
return new Element(cplayer.getKDR()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <p@player.simpleclans.deaths>
// @returns Element(Number)
// @description
// Returns the number of deaths the player has.
// @Plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("deaths")) {
return new Element(cplayer.getDeaths()).getAttribute(attribute.fulfill(1));
}
else if (attribute.startsWith("kills")) {
attribute = attribute.fulfill(1);
// <--[tag]
// @attribute <p@player.simpleclans.kills.civilian>
// @returns Element(Number)
// @description
// Returns the total number of civilian kills the player has.
// @Plugin Depenizen, SimpleClans
// -->
if (attribute.startsWith("civilian")) {
return new Element(cplayer.getCivilianKills()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <p@player.simpleclans.kills.rivals>
// @returns Element(Number)
// @description
// Returns the total number of rival kills the player has.
// @Plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("rivals")) {
return new Element(cplayer.getRivalKills()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <p@player.simpleclans.kills.neutral>
// @returns Element(Number)
// @description
// Returns the total number of neutral kills the player has.
// @Plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("neutral")) {
return new Element(cplayer.getNeutralKills()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <p@player.simpleclans.kills.total>
// @returns Element(Number)
// @description
// Returns the total number of kills the player has.
// @Plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("total")) {
return new Element(cplayer.getCivilianKills()
+ cplayer.getRivalKills()
+ cplayer.getNeutralKills()).getAttribute(attribute.fulfill(1));
}
return null;
}
// <--[tag]
// @attribute <p@player.simpleclans.rank>
// @returns Element
// @description
// Returns the player's rank within the clan.
// @Plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("rank")) {
String rank = cplayer.getRank();
if (rank == null) {
return null;
}
return new Element(rank).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <p@player.simpleclans.is_trusted>
// @returns Element(Boolean)
// @description
// Returns whether the player has trusted status in the clan.
// @Plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("is_trusted")) {
return new Element(cplayer.isTrusted()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <p@player.simpleclans.past_clans>
// @returns dList(Element)
// @description
// Returns a list of the player's past clan names.
// NOTE: Due to a limitation of SimpleClans, we can only get names.
// @Plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("past_clans")) {
dList past = new dList();
for (String cl : cplayer.getPastClans()) {
past.add(new Element(cl).identify());
}
return past.getAttribute(attribute.fulfill(1));
}
}
return null;
}
}