-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
McMMOSupport.java
56 lines (44 loc) · 1.94 KB
/
McMMOSupport.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
package net.gnomeffinway.depenizen.support.plugins;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.party.PartyManager;
import net.aufdemrand.denizen.objects.Element;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.tags.Attribute;
import net.gnomeffinway.depenizen.commands.McMMOCommands;
import net.gnomeffinway.depenizen.extensions.mcmmo.McMMOPlayerExtension;
import net.gnomeffinway.depenizen.support.Support;
public class McMMOSupport extends Support {
public McMMOSupport() {
registerAdditionalTags("party");
registerProperty(McMMOPlayerExtension.class, dPlayer.class);
new McMMOCommands().activate().as("MCMMO").withOptions("see documentation", 1);
}
@Override
public String additionalTags(Attribute attribute) {
if (attribute.startsWith("party")) {
if (!attribute.hasContext(1) || PartyManager.getParty(attribute.getContext(1)) == null)
return null;
Party party = PartyManager.getParty(attribute.getContext(1));
attribute = attribute.fulfill(1);
// <--[tag]
// @attribute <party[<party>].leader>
// @returns dPlayer
// @description
// Returns the leader of the party.
// @plugin mcMMO
// -->
if (attribute.startsWith("leader"))
return dPlayer.valueOf(party.getLeader()).getAttribute(attribute.fulfill(1));
// <--[tag]
// @attribute <party[<party>].player_count>
// @returns Element(Integer)
// @description
// Returns the number of players in the party.
// @plugin mcMMO
// -->
else if (attribute.startsWith("playercount") || attribute.startsWith("player_count"))
return new Element(party.getMembers().size()).getAttribute(attribute.fulfill(1));
}
return null;
}
}