net.minestom.server.event.trait.EntityInstanceEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
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.
*
* 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();
assert instance != null : "EntityInstanceEvent is only supported on events where the entity's instance is non-null!";
return instance;
}
}