-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
dClan.java
337 lines (299 loc) · 10.6 KB
/
dClan.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
package net.gnomeffinway.depenizen.objects;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.Fetchable;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import org.bukkit.Location;
public class dClan implements dObject {
public static dClan valueOf(String tag) {
return dClan.valueOf(tag, null);
}
@Fetchable("clan")
public static dClan valueOf(String tag, TagContext context) {
if (tag == null) {
return null;
}
////////
// Match clan name
tag = tag.replace("clan@", "");
Clan cl = SimpleClans.getInstance().getClanManager().getClan(tag);
if (cl == null) {
return null;
}
return new dClan(cl);
}
public static dClan forPlayer(dPlayer pl) {
Clan cl = SimpleClans.getInstance().getClanManager().getClanByPlayerUniqueId(pl.getOfflinePlayer().getUniqueId());
if (cl == null) {
return null;
}
return new dClan(cl);
}
public static boolean matches(String tag) {
tag = tag.replace("clan@", "");
return SimpleClans.getInstance().getClanManager().isClan(tag);
}
public dClan(Clan c) {
if (c != null) {
clan = c;
}
else {
dB.echoError("Clan referenced is null");
}
}
Clan clan = null;
private String prefix = "Clan";
@Override
public String getPrefix() {
return prefix;
}
@Override
public String debug() {
return prefix + "='<A>" + identify() + "<G>' ";
}
@Override
public boolean isUnique() {
return true;
}
@Override
public String getObjectType() {
return "Clan";
}
@Override
public String identify() {
return "clan@" + clan.getTag();
}
@Override
public String identifySimple() {
return identify();
}
@Override
public dObject setPrefix(String s) {
this.prefix = s;
return this;
}
public Clan getClan() {
return clan;
}
@Override
public String getAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
// <--[tag]
// @attribute <clan@clan.leaders>
// @returns dList(dPlayer)
// @description
// Returns the leaders of the clan.
// @plugin Depenizen, SimpleClans
// -->
if (attribute.startsWith("leaders")) {
dList leaders = new dList();
for (ClanPlayer p : clan.getLeaders()) {
leaders.add(new dPlayer(p.getUniqueId()).identify());
}
return leaders.getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.members>
// @returns dList(dPlayer)
// @description
// Returns all the members of the clan (including leaders).
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("members")) {
dList members = new dList();
for (ClanPlayer p : clan.getMembers()) {
members.add(new dPlayer(p.toPlayer()).identify());
}
return members.getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.is_verified>
// @returns Element(Boolean)
// @description
// Returns the whether the clan is verified.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("is_verified")) {
return new Element(clan.isVerified()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.allies>
// @returns dList(dClan)
// @description
// Returns the ally clans of the clan.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("allies")) {
dList allies = new dList();
for (String c : clan.getAllies()) {
allies.add(dClan.valueOf(c).identify());
}
return allies.getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.rivals>
// @returns dList(dClan)
// @description
// Returns the rival clans of the clan.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("rivals")) {
dList rivals = new dList();
for (String c : clan.getRivals()) {
rivals.add(dClan.valueOf(c).identify());
}
return rivals.getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.deaths>
// @returns Element(Number)
// @description
// Returns the total number of deaths the clan has.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("deaths")) {
return new Element(clan.getTotalDeaths()).getAttribute(attribute.fulfill(1));
}
else if (attribute.startsWith("kills")) {
attribute = attribute.fulfill(1);
// <--[tag]
// @attribute <clan@clan.kills.civilian>
// @returns Element(Number)
// @description
// Returns the total number of civilian kills the clan has.
// @plugin Depenizen, SimpleClans
// -->
if (attribute.startsWith("civilian")) {
return new Element(clan.getTotalCivilian()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.kills.rivals>
// @returns Element(Number)
// @description
// Returns the total number of rival kills the clan has.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("rivals")) {
return new Element(clan.getTotalRival()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.kills.neutral>
// @returns Element(Number)
// @description
// Returns the total number of neutral kills the clan has.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("neutral")) {
return new Element(clan.getTotalNeutral()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.kills.total>
// @returns Element(Number)
// @description
// Returns the total number of kills the clan has.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("total")) {
return new Element(clan.getTotalCivilian()
+ clan.getTotalRival()
+ clan.getTotalNeutral()).getAttribute(attribute.fulfill(1));
}
else {
return null;
}
}
// <--[tag]
// @attribute <clan@clan.kill_death_ratio>
// @returns Element(Decimal)
// @description
// Returns the kill death ratio of the clan.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("kill_death_ratio")) {
return new Element(clan.getTotalKDR()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.home_location>
// @returns dLocation
// @description
// Returns the clans home location if it has one.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("home_location")) {
Location home = clan.getHomeLocation();
if (home == null) {
return null;
}
return new dLocation(home).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.name>
// @returns Element
// @description
// Returns the clan's name.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("name")) {
return new Element(clan.getName()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.tag>
// @returns Element
// @description
// Returns the clan's tag.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("tag")) {
return new Element(clan.getTag()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.warring_with[<clan>]>
// @returns Element(Boolean)
// @description
// Returns whether the clan is at war with another clan.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("warring_with") && attribute.hasContext(1)) {
dClan opponent = dClan.valueOf(attribute.getContext(1));
if (opponent == null) {
return null;
}
return new Element(clan.isWarring(opponent.getClan())).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.friendly_fire>
// @returns Element(Boolean)
// @description
// Returns whether the clan has friendly fire enabled.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("friendly_fire")) {
return new Element(clan.isFriendlyFire()).getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <clan@clan.bulletin_board>
// @returns dList(Element)
// @description
// Returns a list of all bulletin board messages for the clan.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("bulletin_board")) {
dList board = new dList();
for (String m : clan.getBb()) {
board.add(new Element(m).identify());
}
return board.getAttribute(attribute.fulfill(1));
}
return new Element(identify()).getAttribute(attribute);
}
}