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 byte data;
|
||||||
@Getter private BlockFace face;
|
@Getter private BlockFace face;
|
||||||
@Getter private String bisected;
|
@Getter private String bisected;
|
||||||
|
@Getter private String slabtype;
|
||||||
@Getter private String[] signLines;
|
@Getter private String[] signLines;
|
||||||
|
|
||||||
//Only used for inputs!
|
//Only used for inputs!
|
||||||
|
@ -134,8 +135,8 @@ public class LiftBlock implements Comparable<LiftBlock> {
|
||||||
this.bisected = null;
|
this.bisected = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 1.13 liftblock (no dir but bisec) */
|
/* 1.13 liftblock (slab) */
|
||||||
public LiftBlock(String world, int x, int y, int z, Material mat, String bisected) {
|
public LiftBlock(String world, int x, int y, int z, Material mat, String slabtype) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
@ -145,7 +146,7 @@ public class LiftBlock implements Comparable<LiftBlock> {
|
||||||
this.data = 0;
|
this.data = 0;
|
||||||
this.signLines = null;
|
this.signLines = null;
|
||||||
this.floor = null;
|
this.floor = null;
|
||||||
this.bisected = bisected;
|
this.slabtype = slabtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -207,6 +207,7 @@ public class MoveLift implements Runnable {
|
||||||
if (XMaterial.isNewVersion()) {
|
if (XMaterial.isNewVersion()) {
|
||||||
DirectionUtil.setDirection(block, lib.getFace());
|
DirectionUtil.setDirection(block, lib.getFace());
|
||||||
DirectionUtil.setBisected(block, lib.getBisected());
|
DirectionUtil.setBisected(block, lib.getBisected());
|
||||||
|
DirectionUtil.setSlabType(block, lib.getSlabtype());
|
||||||
}
|
}
|
||||||
lb = lift.getBlocks().first();
|
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()) {
|
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()) {
|
if (XMaterial.isNewVersion()) {
|
||||||
DirectionUtil.setDirection(block, lib.getFace());
|
DirectionUtil.setDirection(block, lib.getFace());
|
||||||
DirectionUtil.setBisected(block, lib.getBisected());
|
DirectionUtil.setBisected(block, lib.getBisected());
|
||||||
|
DirectionUtil.setSlabType(block, lib.getSlabtype());
|
||||||
}
|
}
|
||||||
lift.getBlocks().add(lib);
|
lift.getBlocks().add(lib);
|
||||||
if (lib.getSignLines() != null) {
|
if (lib.getSignLines() != null) {
|
||||||
|
@ -342,6 +344,7 @@ public class MoveLift implements Runnable {
|
||||||
if (XMaterial.isNewVersion()) {
|
if (XMaterial.isNewVersion()) {
|
||||||
DirectionUtil.setDirection(block, lib.getFace());
|
DirectionUtil.setDirection(block, lib.getFace());
|
||||||
DirectionUtil.setBisected(block, lib.getBisected());
|
DirectionUtil.setBisected(block, lib.getBisected());
|
||||||
|
DirectionUtil.setSlabType(block, lib.getSlabtype());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
veiter = lift.getToMove().iterator();
|
veiter = lift.getToMove().iterator();
|
||||||
|
@ -367,6 +370,7 @@ public class MoveLift implements Runnable {
|
||||||
if (XMaterial.isNewVersion()) {
|
if (XMaterial.isNewVersion()) {
|
||||||
DirectionUtil.setDirection(block, lib.getFace());
|
DirectionUtil.setDirection(block, lib.getFace());
|
||||||
DirectionUtil.setBisected(block, lib.getBisected());
|
DirectionUtil.setBisected(block, lib.getBisected());
|
||||||
|
DirectionUtil.setSlabType(block, lib.getSlabtype());
|
||||||
}
|
}
|
||||||
lift.getBlocks().add(lib);
|
lift.getBlocks().add(lib);
|
||||||
if (lib.getSignLines() != null) {
|
if (lib.getSignLines() != null) {
|
||||||
|
|
|
@ -207,9 +207,9 @@ public class V10LiftAPI {
|
||||||
} else if (block.getBlockData() instanceof org.bukkit.block.data.Directional) {
|
} else if (block.getBlockData() instanceof org.bukkit.block.data.Directional) {
|
||||||
Bukkit.getLogger().info("Block instanceof Dir 1.13");
|
Bukkit.getLogger().info("Block instanceof Dir 1.13");
|
||||||
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block));
|
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) {
|
} else if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) {
|
||||||
Bukkit.getLogger().info("Block not instanceof Dir 1.13 but instanceof bisected");
|
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.getBisected(block));
|
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), DirectionUtil.getSlabType(block));
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().info("Block not instanceof Dir 1.13");
|
Bukkit.getLogger().info("Block not instanceof Dir 1.13");
|
||||||
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
|
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) {
|
} else if (block.getBlockData() instanceof org.bukkit.block.data.Directional) {
|
||||||
Bukkit.getLogger().info("Block instanceof Dir 1.13");
|
Bukkit.getLogger().info("Block instanceof Dir 1.13");
|
||||||
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block));
|
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) {
|
} else if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) {
|
||||||
Bukkit.getLogger().info("Block not instanceof Dir 1.13 but instanceof bisected");
|
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.getBisected(block));
|
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), DirectionUtil.getSlabType(block));
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().info("Block not instanceof Dir 1.13");
|
Bukkit.getLogger().info("Block not instanceof Dir 1.13");
|
||||||
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
|
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) {
|
} else if (block.getBlockData() instanceof org.bukkit.block.data.Directional) {
|
||||||
Bukkit.getLogger().info("Block instanceof Dir 1.13");
|
Bukkit.getLogger().info("Block instanceof Dir 1.13");
|
||||||
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block));
|
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) {
|
} else if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) {
|
||||||
Bukkit.getLogger().info("Block not instanceof Dir 1.13 but instanceof bisected");
|
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.getBisected(block));
|
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), DirectionUtil.getSlabType(block));
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().info("Block not instanceof Dir 1.13");
|
Bukkit.getLogger().info("Block not instanceof Dir 1.13");
|
||||||
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
|
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type);
|
||||||
|
|
|
@ -55,4 +55,32 @@ public class DirectionUtil {
|
||||||
block.setBlockData(bd);
|
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