-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
BattleNightSupport.java
71 lines (58 loc) · 2.52 KB
/
BattleNightSupport.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
package net.gnomeffinway.depenizen.support.plugins;
import me.limebyte.battlenight.api.BattleNightAPI;
import me.limebyte.battlenight.core.BattleNight;
import net.aufdemrand.denizen.objects.*;
import net.aufdemrand.denizen.tags.Attribute;
import net.gnomeffinway.depenizen.commands.BattleNightCommands;
import net.gnomeffinway.depenizen.support.Support;
import net.gnomeffinway.depenizen.extensions.battlenight.BNPlayerExtension;
public class BattleNightSupport extends Support {
public BattleNightSupport() {
registerProperty(BNPlayerExtension.class, dPlayer.class);
registerAdditionalTags("battle");
new BattleNightCommands().activate().as("BN").withOptions("see documentation", 1);
}
@Override
public String additionalTags(Attribute attribute) {
BattleNightAPI api = BattleNight.instance.getAPI();
if (attribute.startsWith("battle")) {
attribute = attribute.fulfill(1);
// <--[tag]
// @attribute <battle.arena>
// @returns Element
// @description
// Returns the battle's arena name.
// @plugin BattleNight
// -->
if (attribute.startsWith("arena")) {
if (BattleNight.instance.getAPI().getBattle().isInProgress())
return new Element(api.getBattle().getArena().getName())
.getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <battle.in_progress>
// @returns Element
// @description
// Returns true if a battle is in progress.
// @plugin BattleNight
// -->
else if (attribute.startsWith("inprogress") || attribute.startsWith("in_progress")) {
return new Element(api.getBattle().isInProgress())
.getAttribute(attribute.fulfill(1));
}
// <--[tag]
// @attribute <battle.time_remaining>
// @returns Duration
// @description
// Returns the amount of time the battle has left.
// @plugin BattleNight
// -->
else if (attribute.startsWith("timeremaining") || attribute.startsWith("time_remaining")) {
if (api.getBattle().isInProgress())
return new Duration(BattleNight.instance.getAPI().getBattle().getTimer().getTimeRemaining())
.getAttribute(attribute.fulfill(1));
}
}
return null;
}
}