Skip to content

Commit 9bf1e3d

Browse files
committed
fix(event): add handlers list for each event
1 parent 05ff7c9 commit 9bf1e3d

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

src/main/java/com/xzavier0722/mc/plugin/slimefuncomplib/event/CancellableEvent.java

-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import javax.annotation.Nonnull;
88

99
public abstract class CancellableEvent extends Event implements Cancellable {
10-
private static final HandlerList handlers = new HandlerList();
1110
private boolean cancelled;
1211

1312
@Override
@@ -20,14 +19,4 @@ public void setCancelled(boolean cancelled) {
2019
this.cancelled = cancelled;
2120
}
2221

23-
@Override
24-
@Nonnull
25-
public HandlerList getHandlers() {
26-
return handlers;
27-
}
28-
29-
@Nonnull
30-
public static HandlerList getHandlerList() {
31-
return handlers;
32-
}
3322
}

src/main/java/com/xzavier0722/mc/plugin/slimefuncomplib/event/cargo/CargoInsertEvent.java

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ public class CargoInsertEvent extends CargoOperationEvent {
1212
public CargoInsertEvent(Block node, Block target, Inventory inv) {
1313
super(node, target, inv);
1414
}
15+
1516
}

src/main/java/com/xzavier0722/mc/plugin/slimefuncomplib/event/cargo/CargoOperationEvent.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import com.xzavier0722.mc.plugin.slimefuncomplib.event.CancellableEvent;
44
import org.bukkit.block.Block;
5+
import org.bukkit.event.HandlerList;
56
import org.bukkit.inventory.Inventory;
67

78
import javax.annotation.Nonnull;
89
import javax.annotation.ParametersAreNonnullByDefault;
910

10-
public class CargoOperationEvent extends CancellableEvent {
11+
public abstract class CargoOperationEvent extends CancellableEvent {
12+
private static final HandlerList handlers = new HandlerList();
1113
private final Block node;
1214
private final Block target;
1315
private final Inventory inv;
@@ -40,4 +42,15 @@ public Block getTarget() {
4042
return target;
4143
}
4244

45+
@Nonnull
46+
public static HandlerList getHandlerList() {
47+
return handlers;
48+
}
49+
50+
@Override
51+
@Nonnull
52+
public HandlerList getHandlers() {
53+
return handlers;
54+
}
55+
4356
}

src/main/java/com/xzavier0722/mc/plugin/slimefuncomplib/event/cargo/CargoTickEvent.java

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.xzavier0722.mc.plugin.slimefuncomplib.event.CancellableEvent;
44
import org.bukkit.Location;
5+
import org.bukkit.event.HandlerList;
56

67
import javax.annotation.Nonnull;
78
import javax.annotation.Nullable;
@@ -11,6 +12,7 @@
1112
import java.util.Optional;
1213

1314
public class CargoTickEvent extends CancellableEvent {
15+
private static final HandlerList handlers = new HandlerList();
1416
private final Map<Location, Integer> inputs;
1517
private final Map<Integer, List<Location>> outputs;
1618
private String hologramMsg;
@@ -51,4 +53,15 @@ public Optional<String> getHologramMsg() {
5153
public void setHologramMsg(@Nullable String msg) {
5254
this.hologramMsg = msg;
5355
}
56+
57+
@Nonnull
58+
public static HandlerList getHandlerList() {
59+
return handlers;
60+
}
61+
62+
@Override
63+
@Nonnull
64+
public HandlerList getHandlers() {
65+
return handlers;
66+
}
5467
}

src/main/java/com/xzavier0722/mc/plugin/slimefuncomplib/event/cargo/CargoWithdrawEvent.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import org.bukkit.inventory.Inventory;
55

66
public class CargoWithdrawEvent extends CargoOperationEvent {
7-
87
/**
98
* @param node : cargo node
109
* @param target : target container
@@ -13,4 +12,5 @@ public class CargoWithdrawEvent extends CargoOperationEvent {
1312
public CargoWithdrawEvent(Block node, Block target, Inventory inv) {
1413
super(node, target, inv);
1514
}
15+
1616
}

0 commit comments

Comments
 (0)