Llama API

This commit is contained in:
William Blake Galbreath
2025-01-04 19:21:35 -08:00
committed by granny
parent 3f0b653764
commit c5902528c1
10 changed files with 203 additions and 235 deletions

View File

@@ -0,0 +1,60 @@
package org.purpurmc.purpur.event.entity;
import org.bukkit.entity.Llama;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Called when a Llama tries to join a caravan.
* <p>
* Cancelling the event will not let the Llama join. To prevent future attempts
* at joining a caravan use {@link Llama#setShouldJoinCaravan(boolean)}.
*/
@NullMarked
public class LlamaJoinCaravanEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean canceled;
private final Llama head;
@ApiStatus.Internal
public LlamaJoinCaravanEvent(Llama llama, Llama head) {
super(llama);
this.head = head;
}
@Override
public Llama getEntity() {
return (Llama) entity;
}
/**
* Get the Llama that this Llama is about to follow
*
* @return Llama about to be followed
*/
public Llama getHead() {
return head;
}
@Override
public boolean isCancelled() {
return canceled;
}
@Override
public void setCancelled(boolean cancel) {
canceled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,34 @@
package org.purpurmc.purpur.event.entity;
import org.bukkit.entity.Llama;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Called when a Llama leaves a caravan
*/
@NullMarked
public class LlamaLeaveCaravanEvent extends EntityEvent {
private static final HandlerList handlers = new HandlerList();
@ApiStatus.Internal
public LlamaLeaveCaravanEvent(Llama llama) {
super(llama);
}
@Override
public Llama getEntity() {
return (Llama) entity;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}