diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/API/Objects/LiftBlock.java b/src/main/lombok/nl/SBDeveloper/V10Lift/API/Objects/LiftBlock.java index 9d1a107..407410d 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/API/Objects/LiftBlock.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/API/Objects/LiftBlock.java @@ -23,6 +23,7 @@ public class LiftBlock implements Comparable { @Getter private byte data; @Getter private BlockFace face; @Getter private String bisected; + @Getter private String slabtype; @Getter private String[] signLines; //Only used for inputs! @@ -134,8 +135,8 @@ public class LiftBlock implements Comparable { this.bisected = null; } - /* 1.13 liftblock (no dir but bisec) */ - public LiftBlock(String world, int x, int y, int z, Material mat, String bisected) { + /* 1.13 liftblock (slab) */ + public LiftBlock(String world, int x, int y, int z, Material mat, String slabtype) { this.world = world; this.x = x; this.y = y; @@ -145,7 +146,7 @@ public class LiftBlock implements Comparable { this.data = 0; this.signLines = null; this.floor = null; - this.bisected = bisected; + this.slabtype = slabtype; } @Override diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/API/Runnables/MoveLift.java b/src/main/lombok/nl/SBDeveloper/V10Lift/API/Runnables/MoveLift.java index 5a21545..b7e3269 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/API/Runnables/MoveLift.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/API/Runnables/MoveLift.java @@ -207,6 +207,7 @@ public class MoveLift implements Runnable { if (XMaterial.isNewVersion()) { DirectionUtil.setDirection(block, lib.getFace()); DirectionUtil.setBisected(block, lib.getBisected()); + DirectionUtil.setSlabType(block, lib.getSlabtype()); } lb = lift.getBlocks().first(); for (Entity ent : Objects.requireNonNull(Bukkit.getWorld(lib.getWorld()), "World is null at MoveLift").getBlockAt(lib.getX(), lib.getY(), lib.getZ()).getChunk().getEntities()) { @@ -252,6 +253,7 @@ public class MoveLift implements Runnable { if (XMaterial.isNewVersion()) { DirectionUtil.setDirection(block, lib.getFace()); DirectionUtil.setBisected(block, lib.getBisected()); + DirectionUtil.setSlabType(block, lib.getSlabtype()); } lift.getBlocks().add(lib); if (lib.getSignLines() != null) { @@ -342,6 +344,7 @@ public class MoveLift implements Runnable { if (XMaterial.isNewVersion()) { DirectionUtil.setDirection(block, lib.getFace()); DirectionUtil.setBisected(block, lib.getBisected()); + DirectionUtil.setSlabType(block, lib.getSlabtype()); } } veiter = lift.getToMove().iterator(); @@ -367,6 +370,7 @@ public class MoveLift implements Runnable { if (XMaterial.isNewVersion()) { DirectionUtil.setDirection(block, lib.getFace()); DirectionUtil.setBisected(block, lib.getBisected()); + DirectionUtil.setSlabType(block, lib.getSlabtype()); } lift.getBlocks().add(lib); if (lib.getSignLines() != null) { diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/API/V10LiftAPI.java b/src/main/lombok/nl/SBDeveloper/V10Lift/API/V10LiftAPI.java index 3896a83..5561cc9 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/API/V10LiftAPI.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/API/V10LiftAPI.java @@ -207,9 +207,9 @@ public class V10LiftAPI { } else if (block.getBlockData() instanceof org.bukkit.block.data.Directional) { Bukkit.getLogger().info("Block instanceof Dir 1.13"); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block)); - } else if (block.getBlockData() instanceof org.bukkit.block.data.Bisected) { - Bukkit.getLogger().info("Block not instanceof Dir 1.13 but instanceof bisected"); - lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), DirectionUtil.getBisected(block)); + } else if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) { + Bukkit.getLogger().info("Block instanceof Slab 1.13"); + lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), DirectionUtil.getSlabType(block)); } else { Bukkit.getLogger().info("Block not instanceof Dir 1.13"); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type); @@ -264,9 +264,9 @@ public class V10LiftAPI { } else if (block.getBlockData() instanceof org.bukkit.block.data.Directional) { Bukkit.getLogger().info("Block instanceof Dir 1.13"); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block)); - } else if (block.getBlockData() instanceof org.bukkit.block.data.Bisected) { - Bukkit.getLogger().info("Block not instanceof Dir 1.13 but instanceof bisected"); - lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), DirectionUtil.getBisected(block)); + } else if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) { + Bukkit.getLogger().info("Block instanceof Slab 1.13"); + lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), DirectionUtil.getSlabType(block)); } else { Bukkit.getLogger().info("Block not instanceof Dir 1.13"); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type); @@ -321,9 +321,9 @@ public class V10LiftAPI { } else if (block.getBlockData() instanceof org.bukkit.block.data.Directional) { Bukkit.getLogger().info("Block instanceof Dir 1.13"); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block)); - } else if (block.getBlockData() instanceof org.bukkit.block.data.Bisected) { - Bukkit.getLogger().info("Block not instanceof Dir 1.13 but instanceof bisected"); - lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), DirectionUtil.getBisected(block)); + } else if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) { + Bukkit.getLogger().info("Block instanceof Slab 1.13"); + lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), DirectionUtil.getSlabType(block)); } else { Bukkit.getLogger().info("Block not instanceof Dir 1.13"); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type); diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/Utils/DirectionUtil.java b/src/main/lombok/nl/SBDeveloper/V10Lift/Utils/DirectionUtil.java index 34d2ebf..5ee6979 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/Utils/DirectionUtil.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/Utils/DirectionUtil.java @@ -55,4 +55,32 @@ public class DirectionUtil { block.setBlockData(bd); } } + + @Nullable + public static String getSlabType(@Nonnull Block block) { + if (!XMaterial.isNewVersion()) return null; + if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) { + org.bukkit.block.data.type.Slab slab = (org.bukkit.block.data.type.Slab) block.getBlockData(); + return slab.getType().toString(); + } + return null; + } + + public static void setSlabType(@Nonnull Block block, String slabtype) { + if (!XMaterial.isNewVersion()) return; + if (slabtype != null && block.getBlockData() instanceof org.bukkit.block.data.type.Slab) { + + org.bukkit.block.data.type.Slab.Type type; + try { + type = org.bukkit.block.data.type.Slab.Type.valueOf(slabtype); + } catch (IllegalArgumentException e) { + return; + } + + org.bukkit.block.data.BlockData bd = block.getBlockData(); + org.bukkit.block.data.type.Slab slab = (org.bukkit.block.data.type.Slab) bd; + slab.setType(type); + block.setBlockData(bd); + } + } }