-
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathPlayerLeavePlotScriptEvent.java
More file actions
73 lines (64 loc) · 2.24 KB
/
PlayerLeavePlotScriptEvent.java
File metadata and controls
73 lines (64 loc) · 2.24 KB
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
package com.denizenscript.depenizen.bukkit.events.plotsquared;
import com.denizenscript.depenizen.bukkit.objects.plotsquared.PlotSquaredPlotTag;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class PlayerLeavePlotScriptEvent extends BukkitScriptEvent implements Listener {
// <--[event]
// @Events
// plotsquared player leaves|exits <'plotsquaredplot'>
//
// @Triggers when a player leaves a plot.
//
// @Context
// <context.plot> returns the plot the player left.
//
// @Plugin Depenizen, PlotSquared
//
// @Player Always.
//
// @Group Depenizen
//
// -->
public PlayerLeavePlotScriptEvent() {
registerCouldMatcher("plotsquared player leaves|exits <'plotsquaredplot'>");
}
public PlayerLeavePlotEvent event;
public PlayerTag player;
public PlotSquaredPlotTag plot;
@Override
public boolean matches(ScriptPath path) {
String plotName = path.eventArgLowerAt(3);
if (!plotName.equals("plotsquaredplot") && !plot.equals(PlotSquaredPlotTag.valueOf(plotName, getTagContext(path)))) {
return false;
}
return super.matches(path);
}
@Override
public ScriptEntryData getScriptEntryData() {
return new BukkitScriptEntryData(player, null);
}
@Override
public ObjectTag getContext(String name) {
if (name.equals("plot")) {
return plot;
}
return super.getContext(name);
}
@EventHandler
public void onPlotLeave(PlayerLeavePlotEvent event) {
if (EntityTag.isNPC(event.getPlayer())) {
return;
}
player = PlayerTag.mirrorBukkitPlayer(event.getPlayer());
plot = new PlotSquaredPlotTag(event.getPlot());
this.event = event;
fire(event);
}
}