Added support for slabs in 1.13+
This commit is contained in:
parent
53cdc27880
commit
78158f9f38
4 changed files with 45 additions and 12 deletions
|
@ -23,6 +23,7 @@ public class LiftBlock implements Comparable<LiftBlock> {
|
|||
@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<LiftBlock> {
|
|||
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<LiftBlock> {
|
|||
this.data = 0;
|
||||
this.signLines = null;
|
||||
this.floor = null;
|
||||
this.bisected = bisected;
|
||||
this.slabtype = slabtype;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue