forked from Minestom/Minestom
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathEntityInstanceEvent.java
More file actions
22 lines (20 loc) · 811 Bytes
/
EntityInstanceEvent.java
File metadata and controls
22 lines (20 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package net.minestom.server.event.trait;
import net.minestom.server.entity.Entity;
import net.minestom.server.instance.Instance;
import org.jetbrains.annotations.NotNull;
/**
* Represents an {@link EntityEvent} which happen in {@link Entity#getInstance()}.
* Useful if you need to listen to entity events happening in its instance.
* <p>
* Be aware that the entity's instance must be non-null.
*/
public interface EntityInstanceEvent extends EntityEvent, InstanceEvent {
@Override
default @NotNull Instance getInstance() {
final Instance instance = getEntity().getInstance();
if (instance == null) {
throw new IllegalStateException("EntityInstanceEvent is only supported on events where the entity's instance is non-null!");
}
return instance;
}
}