blob: 5b27cc552994450485c7d1a750a3fe28f8e03a16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
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
index 0000000000000000000000000000000000000000..03f91644189e2d1c615f0a22ab0a7c38c803f6c4
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java
@@ -0,0 +1,58 @@
+package io.papermc.paper.event.block;
+
+import org.bukkit.block.Block;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when a block tries to dispense an item, but its inventory is empty.
+ */
+@NullMarked
+public class BlockFailedDispenseEvent extends BlockEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean shouldPlayEffect = true;
+
+ @ApiStatus.Internal
+ public BlockFailedDispenseEvent(final Block theBlock) {
+ 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
+ */
+ public void shouldPlayEffect(final boolean playEffect) {
+ this.shouldPlayEffect = playEffect;
+ }
+
+ /**
+ * @return {@link #shouldPlayEffect()}
+ */
+ @Override
+ public boolean callEvent() {
+ super.callEvent();
+ return this.shouldPlayEffect();
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}
|