summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-10-13 09:43:05 +1100
committermd_5 <git@md-5.net>2018-10-13 09:43:05 +1100
commite7ced970d291b283a6fe01462d2222bf673b4cd3 (patch)
tree88f6b8efb69be1b70ae6f4b6572228b8cb378c57
parent8ab46ff7c68434c9be24f191ce0126b656a86a0d (diff)
downloadcraftbukkit-e7ced970d291b283a6fe01462d2222bf673b4cd3.tar
craftbukkit-e7ced970d291b283a6fe01462d2222bf673b4cd3.tar.gz
craftbukkit-e7ced970d291b283a6fe01462d2222bf673b4cd3.tar.lz
craftbukkit-e7ced970d291b283a6fe01462d2222bf673b4cd3.tar.xz
craftbukkit-e7ced970d291b283a6fe01462d2222bf673b4cd3.zip
Catch plugins setting null Material or BlockData to blocks
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java3
2 files changed, 5 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 92226644..f19df71f 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -134,6 +134,7 @@ public class CraftBlock implements Block {
@Override
public void setType(Material type, boolean applyPhysics) {
+ Preconditions.checkArgument(type != null, "Material cannot be null");
setBlockData(type.createBlockData(), applyPhysics);
}
@@ -144,6 +145,7 @@ public class CraftBlock implements Block {
@Override
public void setBlockData(BlockData data, boolean applyPhysics) {
+ Preconditions.checkArgument(data != null, "BlockData cannot be null");
setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
index 5cf595e2..13ac9bf2 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block;
+import com.google.common.base.Preconditions;
import net.minecraft.server.BlockPosition;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -98,6 +99,7 @@ public class CraftBlockState implements BlockState {
@Override
public void setBlockData(BlockData data) {
+ Preconditions.checkArgument(data != null, "BlockData cannot be null");
this.data = ((CraftBlockData) data).getState();
}
@@ -121,6 +123,7 @@ public class CraftBlockState implements BlockState {
}
public void setType(final Material type) {
+ Preconditions.checkArgument(type != null, "Material cannot be null");
if (this.getType() != type) {
this.data = CraftMagicNumbers.getBlock(type).getBlockData();
}