diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java index f3981c152..2d0e8cb7c 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java @@ -12,10 +12,10 @@ import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; +import org.bukkit.block.*; import org.bukkit.block.Sign; +import org.bukkit.block.data.Rotatable; +import org.bukkit.block.data.type.WallSign; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -275,18 +275,17 @@ import java.util.*; // block.setType(Material.AIR); final Material type = block.getType(); if (type != Material.SIGN && type != Material.WALL_SIGN) { - int data = 2; + BlockFace facing = BlockFace.EAST; if (world.getBlockAt(x, y, z + 1).getType().isSolid()) - data = 2; + facing = BlockFace.NORTH; else if (world.getBlockAt(x + 1, y, z).getType().isSolid()) - data = 4; + facing = BlockFace.WEST; else if (world.getBlockAt(x, y, z - 1).getType().isSolid()) - data = 3; - else if (world.getBlockAt(x - 1, y, z).getType().isSolid()) - data = 5; + facing = BlockFace.SOUTH; block.setType(Material.WALL_SIGN, false); - final Sign sign = (Sign) block.getBlockData(); - sign.setRawData((byte) data); + final WallSign sign = (WallSign) block.getBlockData(); + sign.setFacing(facing); + block.setBlockData(sign, false); } final BlockState blockstate = block.getState(); if (blockstate instanceof Sign) { @@ -403,7 +402,7 @@ import java.util.*; try { final Material material = getMaterial(block); if (material.isBlock() && material.isSolid() && !material.hasGravity()) { - Class data = material.getData(); + Class data = material.data; if (data.equals(MaterialData.class) && !material.isTransparent() && material .isOccluding() || data.equals(Tree.class) || data.equals(Sandstone.class) || data.equals(Wool.class) || data.equals(Step.class) || data @@ -419,6 +418,7 @@ import java.util.*; } return false; } catch (Exception ignored) { + ignored.printStackTrace(); return false; } } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/BukkitLocalQueue.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/BukkitLocalQueue.java index 30f853573..3fe127051 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/BukkitLocalQueue.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/BukkitLocalQueue.java @@ -113,21 +113,27 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue { } private void setMaterial(@NonNull final PlotBlock plotBlock, @NonNull final Block block) { + final Material material; if (plotBlock instanceof StringPlotBlock) { - final Material material = Material - .getMaterial(((StringPlotBlock) plotBlock).getItemId().toLowerCase(Locale.ENGLISH)); + material = Material + .getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH)); if (material == null) { - throw new IllegalStateException( - String.format("Could not find material that matches %s", block.toString())); + throw new IllegalStateException(String + .format("Could not find material that matches %s", + ((StringPlotBlock) plotBlock).getItemId())); } - block.setType(material, false); } else { final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock; - block.setType(Material.getMaterial(PlotSquared.get().IMP.getLegacyMappings() - .fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData()) - .toString())); - // block.setTypeIdAndData(legacyPlotBlock.getId(), legacyPlotBlock.getData(), false); + material = PlotSquared.get().IMP.getLegacyMappings() + .fromLegacyToString(legacyPlotBlock.getId()).to(Material.class); + if (material == null) { + throw new IllegalStateException(String + .format("Could not find material that matches %s", + PlotSquared.get().IMP.getLegacyMappings() + .fromLegacyToString(legacyPlotBlock.getId()))); + } } + block.setType(material, false); } private boolean equals(@NonNull final PlotBlock plotBlock, @NonNull final Block block) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java index 6a2796f2b..0b700610a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java @@ -34,7 +34,11 @@ public class StringPlotBlock extends PlotBlock { this.itemId = parts[1].toLowerCase(Locale.ENGLISH); } else { this.nameSpace = "minecraft"; - this.itemId = itemId.toLowerCase(Locale.ENGLISH); + if (itemId.isEmpty()) { + this.itemId = "air"; + } else { + this.itemId = itemId.toLowerCase(Locale.ENGLISH); + } } this.determineForeign(); }