-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
SkyBlockResetScriptEvent.java
87 lines (75 loc) · 2.49 KB
/
SkyBlockResetScriptEvent.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
package com.denizenscript.depenizen.bukkit.events.askyblock;
import com.wasteofplastic.askyblock.events.IslandResetEvent;
import com.denizenscript.denizen.BukkitScriptEntryData;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.LocationTag;
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 org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class SkyBlockResetScriptEvent extends BukkitScriptEvent implements Listener {
// <--[event]
// @Events
// skyblock island reset
//
// @Regex ^on skyblock island reset$
//
// @Cancellable false
//
// @Triggers when a new skyblock is reset.
//
// @Context
// <context.owner> Returns the owner of the island.
// <context.location> Returns the location of the island.
//
// @Plugin Depenizen, A SkyBlock
//
// -->
public static SkyBlockResetScriptEvent instance;
public IslandResetEvent event;
public LocationTag location;
public PlayerTag owner;
public SkyBlockResetScriptEvent() {
instance = this;
}
@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
return CoreUtilities.toLowerCase(s).startsWith("skyblock island reset");
}
@Override
public boolean matches(ScriptPath path) {
return true;
}
@Override
public String getName() {
return "SkyBlockReset";
}
@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("owner")) {
return owner;
}
else if (name.equals("location")) {
return location;
}
return super.getContext(name);
}
@EventHandler
public void onSkyBlockReset(IslandResetEvent event) {
location = new LocationTag(event.getLocation());
owner = PlayerTag.mirrorBukkitPlayer(event.getPlayer());
this.event = event;
fire(event);
}
}