Fixed building

This commit is contained in:
Stijn Bannink 2023-08-13 16:03:50 +02:00
parent 2620543e97
commit c12af96b9a
5 changed files with 24 additions and 24 deletions

View file

@ -2,7 +2,7 @@ package tech.sbdevelopment.v10lift.api;
import com.cryptomorin.xseries.XMaterial; import com.cryptomorin.xseries.XMaterial;
import tech.sbdevelopment.v10lift.V10LiftPlugin; import tech.sbdevelopment.v10lift.V10LiftPlugin;
import nl.SBDeveloper.V10Lift.api.objects.*; import tech.sbdevelopment.v10lift.api.objects.*;
import tech.sbdevelopment.v10lift.api.runnables.DoorCloser; import tech.sbdevelopment.v10lift.api.runnables.DoorCloser;
import tech.sbdevelopment.v10lift.api.runnables.MoveLift; import tech.sbdevelopment.v10lift.api.runnables.MoveLift;
import tech.sbdevelopment.v10lift.managers.DataManager; import tech.sbdevelopment.v10lift.managers.DataManager;
@ -180,7 +180,7 @@ public class V10LiftAPI {
public int addBlockToLift(Set<LiftBlock> blocks, @Nonnull Block block) { public int addBlockToLift(Set<LiftBlock> blocks, @Nonnull Block block) {
Material type = block.getType(); Material type = block.getType();
LiftBlock lb; LiftBlock lb;
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
if (type.toString().contains("SIGN")) { if (type.toString().contains("SIGN")) {
Bukkit.getLogger().info("Block instanceof Dir 1.13 & is sign"); Bukkit.getLogger().info("Block instanceof Dir 1.13 & is sign");
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), ((Sign) block.getState()).getLines()); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), ((Sign) block.getState()).getLines());
@ -237,7 +237,7 @@ public class V10LiftAPI {
Lift lift = DataManager.getLift(liftName); Lift lift = DataManager.getLift(liftName);
Material type = block.getType(); Material type = block.getType();
LiftBlock lb; LiftBlock lb;
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
if (type.toString().contains("SIGN")) { if (type.toString().contains("SIGN")) {
Bukkit.getLogger().info("Block instanceof Dir 1.13 & is sign"); Bukkit.getLogger().info("Block instanceof Dir 1.13 & is sign");
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), ((Sign) block.getState()).getLines()); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), ((Sign) block.getState()).getLines());
@ -294,7 +294,7 @@ public class V10LiftAPI {
Material type = block.getType(); Material type = block.getType();
if (ForbiddenBlockManager.isForbidden(type)) return -2; if (ForbiddenBlockManager.isForbidden(type)) return -2;
LiftBlock lb; LiftBlock lb;
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
if (type.toString().contains("SIGN")) { if (type.toString().contains("SIGN")) {
Bukkit.getLogger().info("Block instanceof Dir 1.13 & is sign"); Bukkit.getLogger().info("Block instanceof Dir 1.13 & is sign");
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), ((Sign) block.getState()).getLines()); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), type, DirectionUtil.getDirection(block), ((Sign) block.getState()).getLines());
@ -467,7 +467,7 @@ public class V10LiftAPI {
Block block = Objects.requireNonNull(Bukkit.getWorld(lb.getWorld()), "World is null at closeDoor").getBlockAt(lb.getX(), lb.getY(), lb.getZ()); Block block = Objects.requireNonNull(Bukkit.getWorld(lb.getWorld()), "World is null at closeDoor").getBlockAt(lb.getX(), lb.getY(), lb.getZ());
BlockState state = block.getState(); BlockState state = block.getState();
state.setType(lb.getMat()); state.setType(lb.getMat());
if (!XMaterial.isNewVersion()) { if (!XMaterial.supports(13)) {
state.setRawData(lb.getData()); state.setRawData(lb.getData());
} }
state.update(true); state.update(true);
@ -897,7 +897,7 @@ public class V10LiftAPI {
} }
BlockFace face; BlockFace face;
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
face = DirectionUtil.getDirection(block); face = DirectionUtil.getDirection(block);
} else { } else {
BlockState state = block.getState(); BlockState state = block.getState();

View file

@ -5,7 +5,7 @@ import com.cryptomorin.xseries.XSound;
import tech.sbdevelopment.v10lift.V10LiftPlugin; import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.V10LiftAPI; import tech.sbdevelopment.v10lift.api.V10LiftAPI;
import tech.sbdevelopment.v10lift.api.enums.LiftDirection; import tech.sbdevelopment.v10lift.api.enums.LiftDirection;
import nl.SBDeveloper.V10Lift.api.objects.*; import tech.sbdevelopment.v10lift.api.objects.*;
import tech.sbdevelopment.v10lift.managers.AntiCopyBlockManager; import tech.sbdevelopment.v10lift.managers.AntiCopyBlockManager;
import tech.sbdevelopment.v10lift.managers.DataManager; import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.sbutils.LocationSerializer; import tech.sbdevelopment.v10lift.sbutils.LocationSerializer;
@ -213,12 +213,12 @@ public class MoveLift implements Runnable {
BlockState state = nextBlock.getState(); BlockState state = nextBlock.getState();
state.setType(lib.getMat()); state.setType(lib.getMat());
if (!XMaterial.isNewVersion()) { if (!XMaterial.supports(13)) {
state.setRawData(lib.getData()); state.setRawData(lib.getData());
} }
state.update(true); state.update(true);
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
DirectionUtil.setDirection(nextBlock, lib.getFace()); DirectionUtil.setDirection(nextBlock, lib.getFace());
DirectionUtil.setBisected(nextBlock, lib.getBisected()); DirectionUtil.setBisected(nextBlock, lib.getBisected());
DirectionUtil.setSlabType(nextBlock, lib.getSlabtype()); DirectionUtil.setSlabType(nextBlock, lib.getSlabtype());
@ -264,12 +264,12 @@ public class MoveLift implements Runnable {
BlockState state = block.getState(); BlockState state = block.getState();
state.setType(lib.getMat()); state.setType(lib.getMat());
if (!XMaterial.isNewVersion()) { if (!XMaterial.supports(13)) {
state.setRawData(lib.getData()); state.setRawData(lib.getData());
} }
state.update(true); state.update(true);
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
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()); DirectionUtil.setSlabType(block, lib.getSlabtype());
@ -343,7 +343,7 @@ public class MoveLift implements Runnable {
if (rope.getType() == null) rope.setType(Material.AIR); if (rope.getType() == null) rope.setType(Material.AIR);
block.setType(rope.getType()); block.setType(rope.getType());
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
DirectionUtil.setDirection(block, rope.getFace()); DirectionUtil.setDirection(block, rope.getFace());
} else { } else {
BlockState state = block.getState(); BlockState state = block.getState();

View file

@ -283,7 +283,7 @@ public class PlayerInteractListener implements Listener {
return; return;
} }
LiftBlock lb; LiftBlock lb;
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), block.getType()); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), block.getType());
} else { } else {
lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), block.getType(), block.getState().getRawData()); lb = new LiftBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), block.getType(), block.getState().getRawData());

View file

@ -11,7 +11,7 @@ public class DirectionUtil {
@Nullable @Nullable
public static BlockFace getDirection(@Nonnull Block block) { public static BlockFace getDirection(@Nonnull Block block) {
if (!XMaterial.isNewVersion()) return null; if (!XMaterial.supports(13)) return null;
if (block.getBlockData() instanceof org.bukkit.block.data.Directional) { if (block.getBlockData() instanceof org.bukkit.block.data.Directional) {
org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) block.getBlockData(); org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) block.getBlockData();
return dir.getFacing(); return dir.getFacing();
@ -20,7 +20,7 @@ public class DirectionUtil {
} }
public static void setDirection(@Nonnull Block block, BlockFace blockFace) { public static void setDirection(@Nonnull Block block, BlockFace blockFace) {
if (!XMaterial.isNewVersion()) return; if (!XMaterial.supports(13)) return;
if (blockFace != null && block.getBlockData() instanceof org.bukkit.block.data.Directional) { if (blockFace != null && block.getBlockData() instanceof org.bukkit.block.data.Directional) {
org.bukkit.block.data.BlockData bd = block.getBlockData(); org.bukkit.block.data.BlockData bd = block.getBlockData();
org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) bd; org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) bd;
@ -31,7 +31,7 @@ public class DirectionUtil {
@Nullable @Nullable
public static String getBisected(@Nonnull Block block) { public static String getBisected(@Nonnull Block block) {
if (!XMaterial.isNewVersion()) return null; if (!XMaterial.supports(13)) return null;
if (block.getBlockData() instanceof org.bukkit.block.data.Bisected) { if (block.getBlockData() instanceof org.bukkit.block.data.Bisected) {
org.bukkit.block.data.Bisected bis = (org.bukkit.block.data.Bisected) block.getBlockData(); org.bukkit.block.data.Bisected bis = (org.bukkit.block.data.Bisected) block.getBlockData();
return bis.getHalf().toString(); return bis.getHalf().toString();
@ -40,7 +40,7 @@ public class DirectionUtil {
} }
public static void setBisected(@Nonnull Block block, String bisected) { public static void setBisected(@Nonnull Block block, String bisected) {
if (!XMaterial.isNewVersion()) return; if (!XMaterial.supports(13)) return;
if (bisected != null && block.getBlockData() instanceof org.bukkit.block.data.Bisected) { if (bisected != null && block.getBlockData() instanceof org.bukkit.block.data.Bisected) {
org.bukkit.block.data.Bisected.Half half; org.bukkit.block.data.Bisected.Half half;
@ -60,7 +60,7 @@ public class DirectionUtil {
@Nullable @Nullable
public static String getSlabType(@Nonnull Block block) { public static String getSlabType(@Nonnull Block block) {
if (!XMaterial.isNewVersion()) return null; if (!XMaterial.supports(13)) return null;
if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) { 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(); org.bukkit.block.data.type.Slab slab = (org.bukkit.block.data.type.Slab) block.getBlockData();
return slab.getType().toString(); return slab.getType().toString();
@ -69,7 +69,7 @@ public class DirectionUtil {
} }
public static void setSlabType(@Nonnull Block block, String slabtype) { public static void setSlabType(@Nonnull Block block, String slabtype) {
if (!XMaterial.isNewVersion()) return; if (!XMaterial.supports(13)) return;
if (slabtype != null && block.getBlockData() instanceof org.bukkit.block.data.type.Slab) { if (slabtype != null && block.getBlockData() instanceof org.bukkit.block.data.type.Slab) {
org.bukkit.block.data.type.Slab.Type type; org.bukkit.block.data.type.Slab.Type type;

View file

@ -21,7 +21,7 @@ public class DoorUtil {
if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_OPEN.play(b.getLocation()); if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_OPEN.play(b.getLocation());
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_OPEN.play(b.getLocation()); if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_OPEN.play(b.getLocation());
if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_OPEN.play(b.getLocation()); if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_OPEN.play(b.getLocation());
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
//1.13+ //1.13+
org.bukkit.block.data.BlockData blockData = b.getBlockData(); org.bukkit.block.data.BlockData blockData = b.getBlockData();
if (isOpenable(b)) { if (isOpenable(b)) {
@ -59,7 +59,7 @@ public class DoorUtil {
if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_CLOSE.play(b.getLocation()); if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_CLOSE.play(b.getLocation());
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_CLOSE.play(b.getLocation()); if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_CLOSE.play(b.getLocation());
if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_CLOSE.play(b.getLocation()); if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_CLOSE.play(b.getLocation());
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
//1.13+ //1.13+
org.bukkit.block.data.BlockData blockData = b.getBlockData(); org.bukkit.block.data.BlockData blockData = b.getBlockData();
if (isOpenable(b)) { if (isOpenable(b)) {
@ -98,7 +98,7 @@ public class DoorUtil {
if (b == null) { if (b == null) {
return false; return false;
} }
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
//1.13+ //1.13+
return b.getBlockData() instanceof org.bukkit.block.data.Openable; return b.getBlockData() instanceof org.bukkit.block.data.Openable;
} else { } else {
@ -116,7 +116,7 @@ public class DoorUtil {
public static Location getLowerLocationOfDoor(@Nonnull Block block) { public static Location getLowerLocationOfDoor(@Nonnull Block block) {
if (!isDoor(block)) return block.getLocation(); if (!isDoor(block)) return block.getLocation();
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
//1.13+ //1.13+
org.bukkit.block.data.type.Door door = (org.bukkit.block.data.type.Door) block.getBlockData(); org.bukkit.block.data.type.Door door = (org.bukkit.block.data.type.Door) block.getBlockData();
Location lower; Location lower;
@ -161,7 +161,7 @@ public class DoorUtil {
if (b == null) { if (b == null) {
return false; return false;
} }
if (XMaterial.isNewVersion()) { if (XMaterial.supports(13)) {
//1.13+ //1.13+
return b.getBlockData() instanceof org.bukkit.block.data.type.Door; return b.getBlockData() instanceof org.bukkit.block.data.type.Door;
} else { } else {