-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
PVPArenaStartsScriptEvent.java
91 lines (79 loc) · 2.63 KB
/
PVPArenaStartsScriptEvent.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
package com.denizenscript.depenizen.bukkit.events.pvparena;
import com.denizenscript.depenizen.bukkit.objects.pvparena.PVPArenaArenaTag;
import com.denizenscript.denizen.BukkitScriptEntryData;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizencore.objects.core.ListTag;
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 net.slipcor.pvparena.arena.ArenaPlayer;
import net.slipcor.pvparena.events.PAStartEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class PVPArenaStartsScriptEvent extends BukkitScriptEvent implements Listener {
// <--[event]
// @Events
// pvparena starts
//
// @Regex ^on pvparena starts$
//
// @Cancellable true
//
// @Triggers when a pvparena starts.
//
// @Context
// <context.fighters> returns a list of all fighters in the arena.
//
// @Plugin Depenizen, PVPArena
//
// -->
public static PVPArenaStartsScriptEvent instance;
public PAStartEvent event;
public ListTag fighters;
public PVPArenaArenaTag arena;
public PVPArenaStartsScriptEvent() {
instance = this;
}
@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
return CoreUtilities.toLowerCase(s).startsWith("pvparena starts");
}
@Override
public boolean matches(ScriptPath path) {
return true;
}
@Override
public String getName() {
return "PVPArenaStarts";
}
@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("fighters")) {
return fighters;
}
else if (name.equals("arena")) {
return arena;
}
return super.getContext(name);
}
@EventHandler
public void onPVPArenaStart(PAStartEvent event) {
fighters = new ListTag();
for (ArenaPlayer p : event.getArena().getFighters()) {
fighters.add(new PlayerTag(p.get()).identify());
}
arena = new PVPArenaArenaTag(event.getArena());
this.event = event;
fire(event);
}
}