-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
PlayerLeavesPVPArenaScriptEvent.java
70 lines (60 loc) · 2.08 KB
/
PlayerLeavesPVPArenaScriptEvent.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
package com.denizenscript.depenizen.bukkit.events.pvparena;
import com.denizenscript.depenizen.bukkit.objects.pvparena.PVPArenaArenaTag;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.PlayerTag;
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.events.PALeaveEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class PlayerLeavesPVPArenaScriptEvent extends BukkitScriptEvent implements Listener {
// <--[event]
// @Events
// pvparena player leaves
//
// @Regex ^on pvparena player leaves$
//
// @Triggers when a player leaves a pvparena.
//
// @Context
// <context.arena> returns the arena denizen object.
//
// @Plugin Depenizen, PVPArena
//
// -->
public static PlayerLeavesPVPArenaScriptEvent instance;
public PALeaveEvent event;
public PVPArenaArenaTag arena;
public PlayerLeavesPVPArenaScriptEvent() {
instance = this;
}
@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
return CoreUtilities.toLowerCase(s).startsWith("pvparena player leaves");
}
@Override
public String getName() {
return "PlayerLeavesPVPArena";
}
@Override
public ScriptEntryData getScriptEntryData() {
return new BukkitScriptEntryData(new PlayerTag(event.getPlayer()), null);
}
@Override
public ObjectTag getContext(String name) {
if (name.equals("arena")) {
return arena;
}
return super.getContext(name);
}
@EventHandler
public void onPlayerLeavesPVPArena(PALeaveEvent event) {
arena = new PVPArenaArenaTag(event.getArena());
cancelled = false;
this.event = event;
fire(event);
}
}