-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
RaidStopsScriptEvent.java
57 lines (50 loc) · 1.62 KB
/
RaidStopsScriptEvent.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
package com.denizenscript.denizen.events.world;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.raid.RaidStopEvent;
public class RaidStopsScriptEvent extends RaidScriptEvent<RaidStopEvent> implements Listener {
// <--[event]
// @Events
// raid stops
//
// @Group World
//
// @Location true
//
// @Switch reason:<reason> to only process the event if the raid stopped for a certain reason.
//
// @Triggers when a village raid stops for any reason.
//
// @Context
// <context.raid> returns the raid data. See <@link language Raid Event Data>.
// <context.reason> returns the reason for stopping. See <@link url https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/raid/RaidStopEvent.Reason.html>.
//
// -->
public RaidStopsScriptEvent() {
super(true);
registerCouldMatcher("raid stops");
registerSwitches("reason");
}
@Override
public boolean matches(ScriptPath path) {
if (!runGenericSwitchCheck(path, "reason", event.getReason().name())) {
return false;
}
return super.matches(path);
}
@Override
public ObjectTag getContext(String name) {
switch (name) {
case "reason":
return new ElementTag(event.getReason());
}
return super.getContext(name);
}
@EventHandler
public void onRaidStops(RaidStopEvent event) {
this.event = event;
fire(event);
}
}