Paper/patches/api/0264-add-DragonEggFormEvent.patch
Nassim Jahnke 928bcc8d3a
Updated Upstream (Bukkit/CraftBukkit) (#8430)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
09943450 Update SnakeYAML version
5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc
6f82b381 PR-788: Add getHand() to all relevant events

CraftBukkit Changes:
aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe
5329dd6fd PR-1107: Add getHand() to all relevant events
93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
2022-10-02 09:56:36 +02:00

76 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Trigary <trigary0@gmail.com>
Date: Mon, 25 Jan 2021 14:53:49 +0100
Subject: [PATCH] add DragonEggFormEvent
diff --git a/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java b/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..5495b87330518363498e1ac5d8f0a832be35fefb
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java
@@ -0,0 +1,63 @@
+package io.papermc.paper.event.block;
+
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockState;
+import org.bukkit.boss.DragonBattle;
+import org.bukkit.entity.EnderDragon;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockFormEvent;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when the {@link EnderDragon} is defeated (killed) in a {@link DragonBattle},
+ * causing a {@link Material#DRAGON_EGG} (more formally: {@link #getNewState()})
+ * to possibly appear depending on {@link #isCancelled()}.
+ * <b>This event might be cancelled by default depending on
+ * eg. {@link DragonBattle#hasBeenPreviouslyKilled()} and server configuration.</b>
+ */
+public class DragonEggFormEvent extends BlockFormEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final DragonBattle dragonBattle;
+ private boolean cancelled;
+
+ public DragonEggFormEvent(@NotNull Block block, @NotNull BlockState newState,
+ @NotNull DragonBattle dragonBattle) {
+ super(block, newState);
+ this.dragonBattle = dragonBattle;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+
+ /**
+ * Gets the {@link DragonBattle} associated with this event.
+ * Keep in mind that the {@link EnderDragon} is already dead
+ * when this event is called.
+ *
+ * @return the dragon battle
+ */
+ @NotNull
+ public DragonBattle getDragonBattle() {
+ return dragonBattle;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}