Update EntityChangeBlockEvent to new BlockData API

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2018-07-20 10:29:27 +10:00
parent ab51d58f44
commit e1107a65b2
2 changed files with 7 additions and 19 deletions

View file

@ -12,7 +12,7 @@ import org.bukkit.entity.LivingEntity;
*/
public class EntityBreakDoorEvent extends EntityChangeBlockEvent {
public EntityBreakDoorEvent(final LivingEntity entity, final Block targetBlock) {
super(entity, targetBlock, Material.AIR, (byte) 0);
super(entity, targetBlock, Material.AIR.createBlockData());
}
@Override

View file

@ -2,6 +2,7 @@ package org.bukkit.event.entity;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@ -13,24 +14,13 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Block block;
private boolean cancel;
private final Material to;
private final byte data;
private final BlockData to;
/**
*
* @param what the Entity causing the change
* @param block the block (before the change)
* @param to the future material being changed to
* @param data the future block data
* @deprecated Magic value
*/
@Deprecated
public EntityChangeBlockEvent(final Entity what, final Block block, final Material to, final byte data) {
public EntityChangeBlockEvent(final Entity what, final Block block, final BlockData to) {
super(what);
this.block = block;
this.cancel = false;
this.to = to;
this.data = data;
}
/**
@ -56,18 +46,16 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
* @return the material that the block is changing into
*/
public Material getTo() {
return to;
return to.getMaterial();
}
/**
* Gets the data for the block that would be changed into
*
* @return the data for the block that would be changed into
* @deprecated Magic value
*/
@Deprecated
public byte getData() {
return data;
public BlockData getBlockData() {
return to;
}
@Override