Clone mutable types in events when changes are discarded (#10333)

This commit is contained in:
Jake Potrebic 2024-03-20 13:42:29 -07:00 committed by GitHub
parent 05fe15e0fc
commit de620b8480
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 175 additions and 25 deletions

View file

@ -12,10 +12,10 @@ This can replace many uses of BlockPhysicsEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..d0421a4cbcb672cc06b40ad41fc06a67f6d2dbbb
index 0000000000000000000000000000000000000000..c0742b58ca2c098c27394915b624889ece1a9168
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java
@@ -0,0 +1,123 @@
@@ -0,0 +1,122 @@
+package com.destroystokyo.paper.event.block;
+
+import org.bukkit.block.Block;
@ -79,9 +79,8 @@ index 0000000000000000000000000000000000000000..d0421a4cbcb672cc06b40ad41fc06a67
+ /**
+ * @return The new state of this block (Air, or a Fluid type)
+ */
+ @NotNull
+ public BlockData getNewState() {
+ return this.newState;
+ public @NotNull BlockData getNewState() {
+ return this.newState.clone();
+ }
+
+ /**