mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 12:05:53 +01:00
Catch plugins setting null Material or BlockData to blocks
This commit is contained in:
parent
8ab46ff7c6
commit
e7ced970d2
@ -134,6 +134,7 @@ public class CraftBlock implements Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setType(Material type, boolean applyPhysics) {
|
public void setType(Material type, boolean applyPhysics) {
|
||||||
|
Preconditions.checkArgument(type != null, "Material cannot be null");
|
||||||
setBlockData(type.createBlockData(), applyPhysics);
|
setBlockData(type.createBlockData(), applyPhysics);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +145,7 @@ public class CraftBlock implements Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockData(BlockData data, boolean applyPhysics) {
|
public void setBlockData(BlockData data, boolean applyPhysics) {
|
||||||
|
Preconditions.checkArgument(data != null, "BlockData cannot be null");
|
||||||
setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
|
setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import net.minecraft.server.BlockPosition;
|
import net.minecraft.server.BlockPosition;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -98,6 +99,7 @@ public class CraftBlockState implements BlockState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockData(BlockData data) {
|
public void setBlockData(BlockData data) {
|
||||||
|
Preconditions.checkArgument(data != null, "BlockData cannot be null");
|
||||||
this.data = ((CraftBlockData) data).getState();
|
this.data = ((CraftBlockData) data).getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +123,7 @@ public class CraftBlockState implements BlockState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setType(final Material type) {
|
public void setType(final Material type) {
|
||||||
|
Preconditions.checkArgument(type != null, "Material cannot be null");
|
||||||
if (this.getType() != type) {
|
if (this.getType() != type) {
|
||||||
this.data = CraftMagicNumbers.getBlock(type).getBlockData();
|
this.data = CraftMagicNumbers.getBlock(type).getBlockData();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user