-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
MobArenaWaveChangesScriptEvent.java
94 lines (82 loc) · 2.96 KB
/
MobArenaWaveChangesScriptEvent.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
package com.denizenscript.depenizen.bukkit.events.mobarena;
import com.denizenscript.depenizen.bukkit.objects.mobarena.MobArenaArena;
import com.garbagemule.MobArena.events.NewWaveEvent;
import com.denizenscript.denizen.BukkitScriptEntryData;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.denizenscript.denizencore.scripts.containers.ScriptContainer;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class MobArenaWaveChangesScriptEvent extends BukkitScriptEvent implements Listener {
// <--[event]
// @Events
// mobarena arena wave changes
// mobarena <arena> wave changes
//
// @Regex ^on mobarena [^\s]+ wave changes$
//
// @Cancellable false
//
// @Triggers when a wave changes in a MobArena.
//
// @Context
// <context.arena> Returns the arena in which the wave change occured.
// <context.wave> Returns the number of the new wave.
//
// @Plugin Depenizen, MobArena
//
// -->
public MobArenaWaveChangesScriptEvent() {
instance = this;
}
public static MobArenaWaveChangesScriptEvent instance;
public NewWaveEvent event;
public MobArenaArena arena;
public ElementTag wave;
@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
return s.startsWith("mobarena")
&& CoreUtilities.xthArgEquals(2, lower, "wave")
&& CoreUtilities.xthArgEquals(3, lower, "changes");
}
@Override
public boolean matches(ScriptPath path) {
String arenaname = path.eventArgLowerAt(2).replace("mobarena@", "");
MobArenaArena a = MobArenaArena.valueOf(arenaname);
return (arenaname.equals("arena") || (a != null && a.getArena() == event.getArena()))
&& event.getWave() != null;
}
@Override
public String getName() {
return "MobArenaWaveChanges";
}
@Override
public boolean applyDetermination(ScriptContainer container, String determination) {
return super.applyDetermination(container, determination);
}
@Override
public ScriptEntryData getScriptEntryData() {
return new BukkitScriptEntryData(null, null);
}
@Override
public ObjectTag getContext(String name) {
if (name.equals("arena")) {
return arena;
}
else if (name.equals("wave")) {
return wave;
}
return super.getContext(name);
}
@EventHandler
public void onMobArenaWaveChanges(NewWaveEvent event) {
arena = new MobArenaArena(event.getArena());
wave = new ElementTag(event.getWaveNumber());
this.event = event;
fire(event);
}
}