Fixed carpet duping (closes #68) and fixed small issue in Openable block ropes

This commit is contained in:
Stijn Bannink 2023-08-13 17:31:08 +02:00
parent f022ee907d
commit 4ffd4a45eb
4 changed files with 35 additions and 47 deletions

View file

@ -34,8 +34,8 @@ public class LiftRope {
* Construct a new liftrope
*
* @param block The block
* @param minY The starting x-pos
* @param maxY The stopping x-pos
* @param minY The starting y-pos
* @param maxY The stopping y-pos
*/
public LiftRope(Block block, int minY, int maxY) {
this.type = block.getType();
@ -44,7 +44,7 @@ public class LiftRope {
this.minY = minY;
this.maxY = maxY;
this.z = block.getZ();
this.currently = block.getY();
this.currently = minY;
if (block.getBlockData() instanceof org.bukkit.block.data.Directional) {
this.face = ((org.bukkit.block.data.Directional) block.getBlockData()).getFacing();
}

View file

@ -41,7 +41,8 @@ public class V10LiftTabCompleter implements TabCompleter {
return StringUtil.copyPartialMatches(args[1], SUBRENAME, new ArrayList<>());
} else if (args[0].equalsIgnoreCase("input")
|| args[0].equalsIgnoreCase("offline")
|| args[0].equalsIgnoreCase("whitelist")) {
|| args[0].equalsIgnoreCase("whitelist")
|| args[0].equalsIgnoreCase("rope")) {
return StringUtil.copyPartialMatches(args[1], SUB, new ArrayList<>());
}
} else if (args.length == 3) {

View file

@ -61,6 +61,24 @@ public class AntiCopyBlockManager {
antiCopy.add(XMaterial.ACTIVATOR_RAIL);
antiCopy.add(XMaterial.LADDER);
/* Causes duping */
antiCopy.add(XMaterial.WHITE_CARPET);
antiCopy.add(XMaterial.ORANGE_CARPET);
antiCopy.add(XMaterial.MAGENTA_CARPET);
antiCopy.add(XMaterial.LIGHT_BLUE_CARPET);
antiCopy.add(XMaterial.YELLOW_CARPET);
antiCopy.add(XMaterial.LIME_CARPET);
antiCopy.add(XMaterial.PINK_CARPET);
antiCopy.add(XMaterial.GRAY_CARPET);
antiCopy.add(XMaterial.LIGHT_GRAY_CARPET);
antiCopy.add(XMaterial.CYAN_CARPET);
antiCopy.add(XMaterial.PURPLE_CARPET);
antiCopy.add(XMaterial.BLUE_CARPET);
antiCopy.add(XMaterial.BROWN_CARPET);
antiCopy.add(XMaterial.GREEN_CARPET);
antiCopy.add(XMaterial.RED_CARPET);
antiCopy.add(XMaterial.BLACK_CARPET);
/* Because of datatypes */
antiCopy.add(XMaterial.BEEHIVE);
antiCopy.add(XMaterial.BELL);

View file

@ -4,19 +4,10 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockStateUtil {
@Nullable
public static BlockFace getDirection(@Nonnull Block block) {
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;
}
public static void setDirection(@Nonnull Block block, @Nonnull BlockFace blockFace) {
public static void setDirection(@Nonnull Block block, BlockFace blockFace) {
if (blockFace == null) return;
if (block.getBlockData() instanceof org.bukkit.block.data.Directional) {
org.bukkit.block.data.BlockData bd = block.getBlockData();
org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) bd;
@ -25,17 +16,9 @@ public class BlockStateUtil {
}
}
@Nullable
public static String getBisected(@Nonnull Block block) {
if (block.getBlockData() instanceof org.bukkit.block.data.Bisected) {
org.bukkit.block.data.Bisected bis = (org.bukkit.block.data.Bisected) block.getBlockData();
return bis.getHalf().toString();
}
return null;
}
public static void setBisected(@Nonnull Block block, String bisected) {
if (bisected != null && block.getBlockData() instanceof org.bukkit.block.data.Bisected) {
if (bisected == null) return;
if (block.getBlockData() instanceof org.bukkit.block.data.Bisected) {
org.bukkit.block.data.Bisected.Half half;
try {
half = org.bukkit.block.data.Bisected.Half.valueOf(bisected);
@ -51,16 +34,8 @@ public class BlockStateUtil {
}
}
@Nullable
public static String getSlabType(@Nonnull Block block) {
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, @Nonnull String slabtype) {
public static void setSlabType(@Nonnull Block block, String slabtype) {
if (slabtype == null) return;
if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) {
org.bukkit.block.data.type.Slab.Type type;
try {
@ -77,19 +52,13 @@ public class BlockStateUtil {
}
}
@Nullable
public static Boolean isOpen(@Nonnull Block block) {
public static void setOpen(@Nonnull Block block, Boolean state) {
if (state == null) return;
if (block.getBlockData() instanceof org.bukkit.block.data.Openable) {
org.bukkit.block.data.Openable trapdoor = (org.bukkit.block.data.Openable) block.getBlockData();
return trapdoor.isOpen();
}
return null;
}
public static void setOpen(@Nonnull Block block, boolean state) {
if (block.getBlockData() instanceof org.bukkit.block.data.Openable) {
org.bukkit.block.data.Openable trapdoor = (org.bukkit.block.data.Openable) block.getBlockData();
trapdoor.setOpen(state);
org.bukkit.block.data.BlockData bd = block.getBlockData();
org.bukkit.block.data.Openable openable = (org.bukkit.block.data.Openable) bd;
openable.setOpen(state);
block.setBlockData(bd);
}
}
}