13
0
geforkt von Mirrors/Paper

Catch plugins setting null Material or BlockData to blocks

Dieser Commit ist enthalten in:
md_5 2018-10-13 09:43:05 +11:00
Ursprung 8ab46ff7c6
Commit e7ced970d2
2 geänderte Dateien mit 5 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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();
}