mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 09:27:43 +01:00
Block and Fluid Tick Events
This commit is contained in:
167
patches/api/0012-Block-and-Fluid-Tick-Events.patch
Normal file
167
patches/api/0012-Block-and-Fluid-Tick-Events.patch
Normal file
@@ -0,0 +1,167 @@
|
||||
From f1b7acbe7eaaa5f94fbe5fbf2bf8b907885dfecf Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Thu, 6 Jun 2019 23:23:45 -0500
|
||||
Subject: [PATCH] Block and Fluid Tick Events
|
||||
|
||||
---
|
||||
.../purpur/event/block/BlockTickEvent.java | 49 +++++++++++++++++++
|
||||
.../purpur/event/block/FluidTickEvent.java | 49 +++++++++++++++++++
|
||||
src/main/java/org/bukkit/World.java | 30 ++++++++++++
|
||||
3 files changed, 128 insertions(+)
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/event/block/BlockTickEvent.java
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/event/block/FluidTickEvent.java
|
||||
|
||||
diff --git a/src/main/java/net/pl3x/purpur/event/block/BlockTickEvent.java b/src/main/java/net/pl3x/purpur/event/block/BlockTickEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..5325e0c0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/pl3x/purpur/event/block/BlockTickEvent.java
|
||||
@@ -0,0 +1,49 @@
|
||||
+package net.pl3x.purpur.event.block;
|
||||
+
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.block.BlockEvent;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a block is ticked by the server.
|
||||
+ */
|
||||
+public class BlockTickEvent extends BlockEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final boolean isRandomTick;
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ public BlockTickEvent(World world, int x, int y, int z) {
|
||||
+ this(world, x, y, z, false);
|
||||
+ }
|
||||
+
|
||||
+ public BlockTickEvent(World world, int x, int y, int z, boolean isRandomTick) {
|
||||
+ super(world.getBlockAt(x, y, z));
|
||||
+ this.isRandomTick = isRandomTick;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if this is a random tick
|
||||
+ *
|
||||
+ * @return True if random
|
||||
+ */
|
||||
+ public boolean isRandomTick() {
|
||||
+ return isRandomTick;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/pl3x/purpur/event/block/FluidTickEvent.java b/src/main/java/net/pl3x/purpur/event/block/FluidTickEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..77d18fb8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/pl3x/purpur/event/block/FluidTickEvent.java
|
||||
@@ -0,0 +1,49 @@
|
||||
+package net.pl3x.purpur.event.block;
|
||||
+
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.block.BlockEvent;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a fluid is ticked by the server.
|
||||
+ */
|
||||
+public class FluidTickEvent extends BlockEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final boolean isRandomTick;
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ public FluidTickEvent(World world, int x, int y, int z) {
|
||||
+ this(world, x, y, z, false);
|
||||
+ }
|
||||
+
|
||||
+ public FluidTickEvent(World world, int x, int y, int z, boolean isRandomTick) {
|
||||
+ super(world.getBlockAt(x, y, z));
|
||||
+ this.isRandomTick = isRandomTick;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if this is a random tick
|
||||
+ *
|
||||
+ * @return True if random
|
||||
+ */
|
||||
+ public boolean isRandomTick() {
|
||||
+ return isRandomTick;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index 65dc8022..c99e4291 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -2811,6 +2811,36 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
@Nullable
|
||||
public Location locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored);
|
||||
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Get if {@link net.pl3x.purpur.event.block.BlockTickEvent} is enabled for this world
|
||||
+ *
|
||||
+ * @return True if enabled
|
||||
+ */
|
||||
+ boolean isBlockTickEventEnabled();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if {@link net.pl3x.purpur.event.block.BlockTickEvent} is enabled for this world
|
||||
+ *
|
||||
+ * @param enabled True to enable
|
||||
+ */
|
||||
+ void setBlockTickEventEnabled(boolean enabled);
|
||||
+
|
||||
+ /**
|
||||
+ * Get if {@link net.pl3x.purpur.event.block.FluidTickEvent} is enabled for this world
|
||||
+ *
|
||||
+ * @return True if enabled
|
||||
+ */
|
||||
+ boolean isFluidTickEventEnabled();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if {@link net.pl3x.purpur.event.block.FluidTickEvent} is enabled for this world
|
||||
+ *
|
||||
+ * @param enabled True to enable
|
||||
+ */
|
||||
+ void setFluidTickEventEnabled(boolean enabled);
|
||||
+ // Purpur end
|
||||
+
|
||||
// Spigot start
|
||||
public class Spigot
|
||||
{
|
||||
--
|
||||
2.20.1
|
||||
|
||||
Reference in New Issue
Block a user