mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
These patches were implemented upstream
This commit is contained in:
@@ -1,132 +0,0 @@
|
||||
From 46a1c768adda232530d684c5ac49b69b6271cd04 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 19 Oct 2019 03:27:55 -0500
|
||||
Subject: [PATCH] Add ThrownEggHatchEvent
|
||||
|
||||
---
|
||||
.../event/entity/ThrownEggHatchEvent.java | 113 ++++++++++++++++++
|
||||
1 file changed, 113 insertions(+)
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/event/entity/ThrownEggHatchEvent.java
|
||||
|
||||
diff --git a/src/main/java/net/pl3x/purpur/event/entity/ThrownEggHatchEvent.java b/src/main/java/net/pl3x/purpur/event/entity/ThrownEggHatchEvent.java
|
||||
new file mode 100644
|
||||
index 000000000..815e871d0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/pl3x/purpur/event/entity/ThrownEggHatchEvent.java
|
||||
@@ -0,0 +1,113 @@
|
||||
+package net.pl3x.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Egg;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a thrown egg might hatch
|
||||
+ */
|
||||
+public class ThrownEggHatchEvent extends Event {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private final Egg egg;
|
||||
+ private boolean hatching;
|
||||
+ private EntityType hatchType;
|
||||
+ private byte numHatches;
|
||||
+
|
||||
+ public ThrownEggHatchEvent(@NotNull final Egg egg, final boolean hatching, final byte numHatches, @NotNull final EntityType hatchingType) {
|
||||
+ this.egg = egg;
|
||||
+ this.hatching = hatching;
|
||||
+ this.numHatches = numHatches;
|
||||
+ this.hatchType = hatchingType;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the egg involved in this event.
|
||||
+ *
|
||||
+ * @return the egg involved in this event
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Egg getEgg() {
|
||||
+ return egg;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether the egg is hatching or not. Will be what the server
|
||||
+ * would've done without interaction.
|
||||
+ *
|
||||
+ * @return boolean Whether the egg is going to hatch or not
|
||||
+ */
|
||||
+ public boolean isHatching() {
|
||||
+ return hatching;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether the egg will hatch or not.
|
||||
+ *
|
||||
+ * @param hatching true if you want the egg to hatch, false if you want it not to
|
||||
+ */
|
||||
+ public void setHatching(boolean hatching) {
|
||||
+ this.hatching = hatching;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the type of the mob being hatched (EntityType.CHICKEN by default)
|
||||
+ *
|
||||
+ * @return The type of the mob being hatched by the egg
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public EntityType getHatchingType() {
|
||||
+ return hatchType;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Change the type of mob being hatched by the egg
|
||||
+ *
|
||||
+ * @param hatchType The type of the mob being hatched by the egg
|
||||
+ */
|
||||
+ public void setHatchingType(@NotNull EntityType hatchType) {
|
||||
+ if (!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!");
|
||||
+ this.hatchType = hatchType;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the number of mob hatches from the egg. By default the number will
|
||||
+ * be the number the server would've done
|
||||
+ * <ul>
|
||||
+ * <li>7/8 chance of being 0
|
||||
+ * <li>31/256 ~= 1/8 chance to be 1
|
||||
+ * <li>1/256 chance to be 4
|
||||
+ * </ul>
|
||||
+ *
|
||||
+ * @return The number of mobs going to be hatched by the egg
|
||||
+ */
|
||||
+ public byte getNumHatches() {
|
||||
+ return numHatches;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Change the number of mobs coming out of the hatched egg
|
||||
+ * <p>
|
||||
+ * The boolean hatching will override this number. Ie. If hatching =
|
||||
+ * false, this number will not matter
|
||||
+ *
|
||||
+ * @param numHatches The number of mobs coming out of the egg
|
||||
+ */
|
||||
+ public void setNumHatches(byte numHatches) {
|
||||
+ this.numHatches = numHatches;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.26.2
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
From 520632fdade49977988e20c07bd90d360f86418a Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Thu, 18 Jun 2020 23:29:43 -0500
|
||||
Subject: [PATCH] Add PrepareGrindstoneEvent
|
||||
|
||||
---
|
||||
.../inventory/PrepareGrindstoneEvent.java | 54 +++++++++++++++++++
|
||||
1 file changed, 54 insertions(+)
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/event/inventory/PrepareGrindstoneEvent.java
|
||||
|
||||
diff --git a/src/main/java/net/pl3x/purpur/event/inventory/PrepareGrindstoneEvent.java b/src/main/java/net/pl3x/purpur/event/inventory/PrepareGrindstoneEvent.java
|
||||
new file mode 100644
|
||||
index 000000000..d0670bb72
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/pl3x/purpur/event/inventory/PrepareGrindstoneEvent.java
|
||||
@@ -0,0 +1,54 @@
|
||||
+package net.pl3x.purpur.event.inventory;
|
||||
+
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.inventory.InventoryEvent;
|
||||
+import org.bukkit.inventory.GrindstoneInventory;
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when an item is put in a grindstone slot.
|
||||
+ */
|
||||
+public class PrepareGrindstoneEvent extends InventoryEvent {
|
||||
+
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private ItemStack result;
|
||||
+
|
||||
+ public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
|
||||
+ super(inventory);
|
||||
+ this.result = result;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public GrindstoneInventory getInventory() {
|
||||
+ return (GrindstoneInventory) super.getInventory();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get result item, may be null.
|
||||
+ *
|
||||
+ * @return result item
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public ItemStack getResult() {
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ public void setResult(@Nullable ItemStack result) {
|
||||
+ this.result = result;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.26.2
|
||||
|
||||
Reference in New Issue
Block a user