2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: TheViperShow <29604693+TheViperShow@users.noreply.github.com>
|
|
|
|
Date: Wed, 22 Apr 2020 09:40:23 +0200
|
|
|
|
Subject: [PATCH] Add BlockFailedDispenseEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java b/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java
|
|
|
|
new file mode 100644
|
2024-09-29 21:52:13 +02:00
|
|
|
index 0000000000000000000000000000000000000000..03f91644189e2d1c615f0a22ab0a7c38c803f6c4
|
2021-06-11 14:02:28 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java
|
2024-09-29 21:52:13 +02:00
|
|
|
@@ -0,0 +1,58 @@
|
2021-06-11 14:02:28 +02:00
|
|
|
+package io.papermc.paper.event.block;
|
|
|
|
+
|
|
|
|
+import org.bukkit.block.Block;
|
|
|
|
+import org.bukkit.event.HandlerList;
|
|
|
|
+import org.bukkit.event.block.BlockEvent;
|
2024-09-29 21:52:13 +02:00
|
|
|
+import org.checkerframework.checker.nullness.qual.NonNull;
|
2024-02-01 10:15:57 +01:00
|
|
|
+import org.jetbrains.annotations.ApiStatus;
|
2024-09-29 21:52:13 +02:00
|
|
|
+import org.jspecify.annotations.NullMarked;
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Called when a block tries to dispense an item, but its inventory is empty.
|
|
|
|
+ */
|
2024-09-29 21:52:13 +02:00
|
|
|
+@NullMarked
|
2021-06-11 14:02:28 +02:00
|
|
|
+public class BlockFailedDispenseEvent extends BlockEvent {
|
2024-02-01 10:15:57 +01:00
|
|
|
+
|
|
|
|
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
+ private boolean shouldPlayEffect = true;
|
|
|
|
+
|
2024-02-01 10:15:57 +01:00
|
|
|
+ @ApiStatus.Internal
|
2024-09-29 21:52:13 +02:00
|
|
|
+ public BlockFailedDispenseEvent(final Block theBlock) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ super(theBlock);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return if the effect should be played
|
|
|
|
+ */
|
|
|
|
+ public boolean shouldPlayEffect() {
|
|
|
|
+ return this.shouldPlayEffect;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets if the effect for empty dispensers should be played
|
|
|
|
+ *
|
|
|
|
+ * @param playEffect if the effect should be played
|
|
|
|
+ */
|
2024-09-29 21:52:13 +02:00
|
|
|
+ public void shouldPlayEffect(final boolean playEffect) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.shouldPlayEffect = playEffect;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return {@link #shouldPlayEffect()}
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public boolean callEvent() {
|
|
|
|
+ super.callEvent();
|
|
|
|
+ return this.shouldPlayEffect();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2024-09-29 21:52:13 +02:00
|
|
|
+ public HandlerList getHandlers() {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ return HANDLER_LIST;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
2024-09-29 21:52:13 +02:00
|
|
|
+ public static HandlerList getHandlerList() {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ return HANDLER_LIST;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+}
|