Fixed 1.12.2 blockdata issues, closes #17

This commit is contained in:
stijnb1234 2020-02-08 19:16:19 +01:00
parent 9d5de9c0e7
commit 8f9a825935
5 changed files with 8 additions and 18 deletions

View file

@ -9,7 +9,6 @@ import org.bukkit.block.BlockFace;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
@NoArgsConstructor
public class LiftBlock implements Comparable<LiftBlock> {
@ -31,7 +30,7 @@ public class LiftBlock implements Comparable<LiftBlock> {
@Getter @Setter private boolean active = false;
//Only used for chests
public Map[] serializedItemStacks = null;
public Map<String, Object>[] serializedItemStacks = null;
/* Floor based liftblock, no material */
public LiftBlock(String world, int x, int y, int z, String floor) {

View file

@ -4,8 +4,6 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Objects;
@Getter @Setter @NoArgsConstructor
public class LiftSign {
private String world;

View file

@ -413,9 +413,7 @@ public class MoveLift implements Runnable {
block = world.getBlockAt(rope.getX(), rope.getCurrently(), rope.getZ());
block.setType(rope.getType());
if (XMaterial.isNewVersion()) {
org.bukkit.block.data.Directional data = (org.bukkit.block.data.Directional) block.getBlockData();
data.setFacing(rope.getFace());
block.setBlockData(data);
DirectionUtil.setDirection(block, rope.getFace());
} else {
BlockState state = block.getState();
org.bukkit.material.Ladder ladder = new org.bukkit.material.Ladder(rope.getType());
@ -430,9 +428,7 @@ public class MoveLift implements Runnable {
block = world.getBlockAt(rope.getX(), rope.getCurrently(), rope.getZ());
block.setType(rope.getType());
if (XMaterial.isNewVersion()) {
org.bukkit.block.data.Directional data = (org.bukkit.block.data.Directional) block.getBlockData();
data.setFacing(rope.getFace());
block.setBlockData(data);
DirectionUtil.setDirection(block, rope.getFace());
} else {
BlockState state = block.getState();
org.bukkit.material.Ladder ladder = new org.bukkit.material.Ladder(rope.getType());

View file

@ -857,9 +857,7 @@ public class V10LiftAPI {
BlockFace face;
if (XMaterial.isNewVersion()) {
org.bukkit.block.data.type.Ladder ladder = (org.bukkit.block.data.type.Ladder) block.getBlockData();
Bukkit.getLogger().info(ladder.getFacing().toString());
face = ladder.getFacing();
face = DirectionUtil.getDirection(block);
} else {
BlockState state = block.getState();
org.bukkit.material.Ladder ladder = (org.bukkit.material.Ladder) state.getData();

View file

@ -2,7 +2,6 @@ package nl.SBDeveloper.V10Lift.Utils;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Directional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -12,8 +11,8 @@ public class DirectionUtil {
@Nullable
public static BlockFace getDirection(@Nonnull Block block) {
if (!XMaterial.isNewVersion()) return null;
if (block.getBlockData() instanceof Directional) {
Directional dir = (Directional) block.getBlockData();
if (block.getBlockData() instanceof org.bukkit.block.data.Directional) {
org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) block.getBlockData();
return dir.getFacing();
}
return null;
@ -21,9 +20,9 @@ public class DirectionUtil {
public static void setDirection(@Nonnull Block block, BlockFace blockFace) {
if (!XMaterial.isNewVersion()) return;
if (blockFace != null && block.getBlockData() instanceof Directional) {
if (blockFace != null && block.getBlockData() instanceof org.bukkit.block.data.Directional) {
org.bukkit.block.data.BlockData bd = block.getBlockData();
Directional dir = (Directional) bd;
org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) bd;
dir.setFacing(blockFace);
block.setBlockData(bd);
}