-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathEntityUnleashEvent.java
More file actions
111 lines (96 loc) · 2.66 KB
/
EntityUnleashEvent.java
File metadata and controls
111 lines (96 loc) · 2.66 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
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* Called immediately prior to an entity being unleashed.
* <p>
* Cancelling this event when either:
* <ul>
* <li>the leashed entity dies,</li>
* <li>the entity changes dimension, or</li>
* <li>the client has disconnected the leash</li>
* </ul>
* will have no effect.
*/
public class EntityUnleashEvent extends EntityEvent implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final UnleashReason reason;
private boolean dropLeash;
private boolean cancelled;
@ApiStatus.Internal
@Deprecated(forRemoval = true)
public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason) {
this(entity, reason, false);
}
@ApiStatus.Internal
public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason, boolean dropLeash) {
super(entity);
this.reason = reason;
this.dropLeash = dropLeash;
}
/**
* Returns the reason for the unleashing.
*
* @return The reason
*/
@NotNull
public UnleashReason getReason() {
return this.reason;
}
/**
* Returns whether a leash item will be dropped.
*
* @return Whether the leash item will be dropped
*/
public boolean isDropLeash() {
return this.dropLeash;
}
/**
* Sets whether a leash item should be dropped.
*
* @param dropLeash Whether the leash item should be dropped
*/
public void setDropLeash(boolean dropLeash) {
this.dropLeash = dropLeash;
}
@Override
public boolean isCancelled() {
return this.cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}
@NotNull
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
public enum UnleashReason {
/**
* When the entity's leashholder has died or logged out, and so is
* unleashed
*/
HOLDER_GONE,
/**
* When the entity's leashholder attempts to unleash it
*/
PLAYER_UNLEASH,
/**
* When the entity's leashholder is more than 10 blocks away
*/
DISTANCE,
/**
* When the leashed entity is removed from the game
*/
LEASHED_GONE,
UNKNOWN;
}
}