From 3ed2628aa9ab288189efcb6f0b0c202accf8d52d Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 26 Jun 2020 11:12:21 +1000 Subject: [PATCH] SPIGOT-5735: Add EntityEnterLoveModeEvent By: DiamondDagger590 --- .../entity/EntityEnterLoveModeEvent.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java new file mode 100644 index 0000000000..59aab10c2d --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java @@ -0,0 +1,90 @@ +package org.bukkit.event.entity; + +import org.bukkit.entity.Animals; +import org.bukkit.entity.HumanEntity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Called when an entity enters love mode. + *
+ * This can be cancelled but the item will still be consumed that was used to + * make the entity enter into love mode. + */ +public class EntityEnterLoveModeEvent extends EntityEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancel; + private final HumanEntity humanEntity; + private int ticksInLove; + + public EntityEnterLoveModeEvent(@NotNull Animals animalInLove, @Nullable HumanEntity humanEntity, int ticksInLove) { + super(animalInLove); + this.humanEntity = humanEntity; + this.ticksInLove = ticksInLove; + } + + /** + * Gets the animal that is entering love mode. + * + * @return The animal that is entering love mode + */ + @NotNull + @Override + public Animals getEntity() { + return (Animals) entity; + } + + /** + * Gets the Human Entity that caused the animal to enter love mode. + * + * @return The Human entity that caused the animal to enter love mode, or + * null if there wasn't one. + */ + @Nullable + public HumanEntity getHumanEntity() { + return humanEntity; + } + + /** + * Gets the amount of ticks that the animal will fall in love for. + * + * @return The amount of ticks that the animal will fall in love for + */ + public int getTicksInLove() { + return ticksInLove; + } + + /** + * Sets the amount of ticks that the animal will fall in love for. + * + * @param ticksInLove The amount of ticks that the animal will fall in love + * for + */ + public void setTicksInLove(int ticksInLove) { + this.ticksInLove = ticksInLove; + } + + @Override + public boolean isCancelled() { + return cancel; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +}