-
Notifications
You must be signed in to change notification settings - Fork 658
Expand file tree
/
Copy pathWaypointCreateEvent.java
More file actions
122 lines (102 loc) · 3.17 KB
/
Copy pathWaypointCreateEvent.java
File metadata and controls
122 lines (102 loc) · 3.17 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import com.google.common.base.Preconditions;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork;
import io.github.thebusybiscuit.slimefun4.api.gps.TeleportationManager;
import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint;
/**
* A {@link WaypointCreateEvent} is called when a {@link Player} creates a new waypoint.
* Either manually or through dying with an emergency transmitter.
*
* @author TheBusyBiscuit
*
* @see GPSNetwork
* @see TeleportationManager
* @see Waypoint
*
*/
public class WaypointCreateEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private Location location;
private String name;
private final boolean deathpoint;
private boolean cancelled;
public WaypointCreateEvent(@Nonnull Player player, @Nonnull String name, @Nonnull Location location) {
super(player);
Preconditions.checkNotNull(location, "Location must not be null!");
Preconditions.checkNotNull(name, "Name must not be null!");
this.location = location;
this.name = name;
this.deathpoint = name.startsWith("player:death ");
}
/**
* This returns the {@link Location} of the waypoint that should be created.
*
* @return The {@link Location} of this waypoint
*/
@Nonnull
public Location getLocation() {
return location;
}
/**
* This sets the {@link Location} of the waypoint.
* The {@link Location} may never be null!
*
* @param loc
* The {@link Location} to set
*/
public void setLocation(@Nonnull Location loc) {
Preconditions.checkNotNull(loc, "Cannot set the Location to null!");
this.location = loc;
}
/**
* This returns the name of the waypoint.
*
* @return The name of this waypoint
*/
@Nonnull
public String getName() {
return name;
}
/**
* This sets the name of the waypoint to the given argument.
*
* @param name
* The name for this waypoint
*/
public void setName(@Nonnull String name) {
Preconditions.checkArgument(name != null && !name.isEmpty(), "The name of a waypoint must not be empty!");
this.name = name;
}
/**
* This method returns whether this waypoint was created by an Emergency Transmitter.
* This should mean that our {@link Player} has died.
*
* @return Whether this is a deathpoint
*/
public boolean isDeathpoint() {
return deathpoint;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Nonnull
public static HandlerList getHandlerList() {
return handlers;
}
@Nonnull
@Override
public HandlerList getHandlers() {
return getHandlerList();
}
}