Leashable API

This commit is contained in:
Lulu13022002 2024-06-22 21:11:58 +02:00
parent d4da32994f
commit 4641e233e7
3 changed files with 39 additions and 2 deletions

View file

@ -0,0 +1,37 @@
package io.papermc.paper.entity;
import org.bukkit.entity.Entity;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
* Represents an entity that can be leashed.
*/
@NullMarked
public interface Leashable extends Entity {
/**
* Returns whether the entity is currently leashed.
*
* @return whether the entity is leashed
*/
boolean isLeashed();
/**
* Gets the entity that is currently leading this entity.
*
* @return the entity holding the leash
* @throws IllegalStateException if not currently leashed
*/
Entity getLeashHolder() throws IllegalStateException;
/**
* Sets the leash on this entity to be held by the supplied entity.
* <p>
* This method has no effect on players.
*
* @param holder the entity to leash this entity to, or {@code null} to unleash
* @return whether the operation was successful
*/
boolean setLeashHolder(@Nullable Entity holder);
}

View file

@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a boat entity.
*/
public interface Boat extends Vehicle {
public interface Boat extends Vehicle, io.papermc.paper.entity.Leashable { // Paper - Leashable API
/**
* Gets the wood type of the boat.

View file

@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a Mob. Mobs are living entities with simple AI.
*/
public interface Mob extends LivingEntity, Lootable {
public interface Mob extends LivingEntity, Lootable, io.papermc.paper.entity.Leashable { // Paper - Leashable API
// Paper start
@Override