diff --git a/src/main/java/de/diddiz/LogBlock/Consumer.java b/src/main/java/de/diddiz/LogBlock/Consumer.java index 23f0424..7e1dbd9 100644 --- a/src/main/java/de/diddiz/LogBlock/Consumer.java +++ b/src/main/java/de/diddiz/LogBlock/Consumer.java @@ -36,8 +36,6 @@ import org.bukkit.World; import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Waterlogged; -import org.bukkit.block.data.type.Sign; -import org.bukkit.block.data.type.WallSign; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -346,7 +344,7 @@ public class Consumer extends Thread { * The four lines on the sign. */ public void queueSignChange(Actor actor, Location loc, BlockData type, String[] lines) { - if ((!(type instanceof Sign) && !(type instanceof WallSign)) || lines == null || lines.length != 4) { + if (!BukkitUtils.getAllSignMaterials().contains(type.getMaterial())) { return; } queueBlock(actor, loc, type, type, null, BlockStateCodecSign.serialize(lines), null); diff --git a/src/main/java/de/diddiz/LogBlock/blockstate/BlockStateCodecSign.java b/src/main/java/de/diddiz/LogBlock/blockstate/BlockStateCodecSign.java index e60c2a8..fb566a9 100644 --- a/src/main/java/de/diddiz/LogBlock/blockstate/BlockStateCodecSign.java +++ b/src/main/java/de/diddiz/LogBlock/blockstate/BlockStateCodecSign.java @@ -13,7 +13,7 @@ import org.bukkit.configuration.file.YamlConfiguration; public class BlockStateCodecSign implements BlockStateCodec { @Override public Material[] getApplicableMaterials() { - return BukkitUtils.getAllSignsArray(); + return BukkitUtils.getAllSignMaterials().toArray(new Material[BukkitUtils.getAllSignMaterials().size()]); } @Override @@ -54,7 +54,9 @@ public class BlockStateCodecSign implements BlockStateCodec { */ public static YamlConfiguration serialize(String[] lines) { YamlConfiguration conf = new YamlConfiguration(); - conf.set("lines", Arrays.asList(lines)); + if (lines != null) { + conf.set("lines", Arrays.asList(lines)); + } return conf; } diff --git a/src/main/java/de/diddiz/LogBlock/listeners/InteractLogging.java b/src/main/java/de/diddiz/LogBlock/listeners/InteractLogging.java index e0ade55..0eac455 100644 --- a/src/main/java/de/diddiz/LogBlock/listeners/InteractLogging.java +++ b/src/main/java/de/diddiz/LogBlock/listeners/InteractLogging.java @@ -66,224 +66,165 @@ public class InteractLogging extends LoggingListener { lastInteractionBlockData = blockData; lastInteractionLocation = loc; - switch (type) { - case OAK_FENCE_GATE: - case SPRUCE_FENCE_GATE: - case BIRCH_FENCE_GATE: - case JUNGLE_FENCE_GATE: - case ACACIA_FENCE_GATE: - case DARK_OAK_FENCE_GATE: - case WARPED_FENCE_GATE: - case CRIMSON_FENCE_GATE: - case OAK_TRAPDOOR: - case SPRUCE_TRAPDOOR: - case BIRCH_TRAPDOOR: - case JUNGLE_TRAPDOOR: - case ACACIA_TRAPDOOR: - case DARK_OAK_TRAPDOOR: - case WARPED_TRAPDOOR: - case CRIMSON_TRAPDOOR: - if (wcfg.isLogging(Logging.DOORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { - Openable newBlockData = (Openable) blockData.clone(); - newBlockData.setOpen(!newBlockData.isOpen()); - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); + if (BukkitUtils.isFenceGate(type) || BukkitUtils.isWoodenTrapdoor(type)) { + if (wcfg.isLogging(Logging.DOORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { + Openable newBlockData = (Openable) blockData.clone(); + newBlockData.setOpen(!newBlockData.isOpen()); + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); + } + } else if (BukkitUtils.isPressurePlate(type)) { + if (wcfg.isLogging(Logging.PRESUREPLATEINTERACT) && event.getAction() == Action.PHYSICAL) { + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, blockData); + } + } else if (BukkitUtils.isWoodenDoor(type)) { + if (wcfg.isLogging(Logging.DOORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { + Door newBlockData = (Door) blockData.clone(); + newBlockData.setOpen(!newBlockData.isOpen()); + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); + } + } else if (BukkitUtils.isButton(type) || type == Material.LEVER) { + if (wcfg.isLogging(Logging.SWITCHINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { + Switch newBlockData = (Switch) blockData.clone(); + if (!newBlockData.isPowered() || type == Material.LEVER) { + newBlockData.setPowered(!newBlockData.isPowered()); } - break; - case CAKE: - if (event.hasItem() && BukkitUtils.isCandle(event.getItem().getType()) && event.useItemInHand() != Result.DENY) { - BlockData newBlockData = Material.valueOf(event.getItem().getType().name() + "_CAKE").createBlockData(); - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); - } else if (wcfg.isLogging(Logging.CAKEEAT) && event.getAction() == Action.RIGHT_CLICK_BLOCK && player.getFoodLevel() < 20) { - Cake newBlockData = (Cake) blockData.clone(); - if (newBlockData.getBites() < 6) { - newBlockData.setBites(newBlockData.getBites() + 1); - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); - } else { - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, Material.AIR.createBlockData()); - } - } - break; - case NOTE_BLOCK: - if (wcfg.isLogging(Logging.NOTEBLOCKINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { - NoteBlock newBlockData = (NoteBlock) blockData.clone(); - if (newBlockData.getNote().getOctave() == 2) { - newBlockData.setNote(new Note(0, Tone.F, true)); - } else { - newBlockData.setNote(newBlockData.getNote().sharped()); - } - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); - } - break; - case REPEATER: - if (wcfg.isLogging(Logging.DIODEINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { - Repeater newBlockData = (Repeater) blockData.clone(); - newBlockData.setDelay((newBlockData.getDelay() % 4) + 1); - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); - } - break; - case COMPARATOR: - if (wcfg.isLogging(Logging.COMPARATORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { - Comparator newBlockData = (Comparator) blockData.clone(); - newBlockData.setMode(newBlockData.getMode() == Mode.COMPARE ? Mode.SUBTRACT : Mode.COMPARE); - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); - } - break; - case DAYLIGHT_DETECTOR: - if (wcfg.isLogging(Logging.DAYLIGHTDETECTORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { - DaylightDetector newBlockData = (DaylightDetector) blockData.clone(); - newBlockData.setInverted(!newBlockData.isInverted()); - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); - } - break; - case OAK_PRESSURE_PLATE: - case SPRUCE_PRESSURE_PLATE: - case BIRCH_PRESSURE_PLATE: - case JUNGLE_PRESSURE_PLATE: - case ACACIA_PRESSURE_PLATE: - case DARK_OAK_PRESSURE_PLATE: - case WARPED_PRESSURE_PLATE: - case CRIMSON_PRESSURE_PLATE: - case STONE_PRESSURE_PLATE: - case HEAVY_WEIGHTED_PRESSURE_PLATE: - case LIGHT_WEIGHTED_PRESSURE_PLATE: - if (wcfg.isLogging(Logging.PRESUREPLATEINTERACT) && event.getAction() == Action.PHYSICAL) { - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, blockData); - } - break; - case TRIPWIRE: - if (wcfg.isLogging(Logging.TRIPWIREINTERACT) && event.getAction() == Action.PHYSICAL) { - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, blockData); - } - break; - case FARMLAND: - if (wcfg.isLogging(Logging.CROPTRAMPLE) && event.getAction() == Action.PHYSICAL) { - // 3 = Dirt ID - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, Material.DIRT.createBlockData()); - // Log the crop on top as being broken - Block trampledCrop = clicked.getRelative(BlockFace.UP); - if (BukkitUtils.getCropBlocks().contains(trampledCrop.getType())) { - consumer.queueBlockBreak(Actor.actorFromEntity(player), trampledCrop.getState()); - } - } - break; - case TURTLE_EGG: - if (wcfg.isLogging(Logging.BLOCKBREAK) && event.getAction() == Action.PHYSICAL) { - TurtleEgg turtleEggData = (TurtleEgg) blockData; - int eggs = turtleEggData.getEggs(); - if (eggs > 1) { - TurtleEgg turtleEggData2 = (TurtleEgg) turtleEggData.clone(); - turtleEggData2.setEggs(eggs - 1); - consumer.queueBlock(Actor.actorFromEntity(player), loc, turtleEggData, turtleEggData2); - } else { - consumer.queueBlock(Actor.actorFromEntity(player), loc, turtleEggData, Material.AIR.createBlockData()); - } - } - break; - case PUMPKIN: - if ((wcfg.isLogging(Logging.BLOCKBREAK) || wcfg.isLogging(Logging.BLOCKPLACE)) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { - ItemStack inHand = event.getItem(); - if (inHand != null && inHand.getType() == Material.SHEARS) { - BlockFace clickedFace = event.getBlockFace(); - Directional newBlockData = (Directional) Material.CARVED_PUMPKIN.createBlockData(); - if (clickedFace == BlockFace.NORTH || clickedFace == BlockFace.SOUTH || clickedFace == BlockFace.EAST || clickedFace == BlockFace.WEST) { - newBlockData.setFacing(clickedFace); + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); + } + } else if (BukkitUtils.isSign(type)) { + if (wcfg.isLogging(Logging.SIGNTEXT) && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getItem() != null) { + Material itemType = event.getItem().getType(); + if (BukkitUtils.isDye(itemType) || itemType == Material.GLOW_INK_SAC || itemType == Material.INK_SAC) { + final BlockState before = event.getClickedBlock().getState(); + if (before instanceof Sign) { + if (itemType == Material.GLOW_INK_SAC) { + Sign signBefore = (Sign) before; + if (!signBefore.isGlowingText()) { + final Sign signAfter = (Sign) event.getClickedBlock().getState(); + signAfter.setGlowingText(true); + consumer.queueBlockReplace(Actor.actorFromEntity(player), signBefore, signAfter); + } + } else if (itemType == Material.INK_SAC) { + Sign signBefore = (Sign) before; + if (signBefore.isGlowingText()) { + final Sign signAfter = (Sign) event.getClickedBlock().getState(); + signAfter.setGlowingText(false); + consumer.queueBlockReplace(Actor.actorFromEntity(player), signBefore, signAfter); + } } else { - // use player distance to calculate the facing - Location playerLoc = player.getLocation(); - playerLoc.subtract(0.5, 0, 0.5); - double dx = playerLoc.getX() - loc.getX(); - double dz = playerLoc.getZ() - loc.getZ(); - if (Math.abs(dx) > Math.abs(dz)) { - newBlockData.setFacing(dx > 0 ? BlockFace.EAST : BlockFace.WEST); - } else { - newBlockData.setFacing(dz > 0 ? BlockFace.SOUTH : BlockFace.NORTH); + DyeColor newColor = BukkitUtils.dyeToDyeColor(itemType); + Sign signBefore = (Sign) before; + if (newColor != null && signBefore.getColor() != newColor) { + final Sign signAfter = (Sign) event.getClickedBlock().getState(); + signAfter.setColor(newColor); + consumer.queueBlockReplace(Actor.actorFromEntity(player), signBefore, signAfter); } } + } + } + } + } else { + switch (type) { + case CAKE: + if (event.hasItem() && BukkitUtils.isCandle(event.getItem().getType()) && event.useItemInHand() != Result.DENY) { + BlockData newBlockData = Material.valueOf(event.getItem().getType().name() + "_CAKE").createBlockData(); + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); + } else if (wcfg.isLogging(Logging.CAKEEAT) && event.getAction() == Action.RIGHT_CLICK_BLOCK && player.getFoodLevel() < 20) { + Cake newBlockData = (Cake) blockData.clone(); + if (newBlockData.getBites() < 6) { + newBlockData.setBites(newBlockData.getBites() + 1); + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); + } else { + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, Material.AIR.createBlockData()); + } + } + break; + case NOTE_BLOCK: + if (wcfg.isLogging(Logging.NOTEBLOCKINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { + NoteBlock newBlockData = (NoteBlock) blockData.clone(); + if (newBlockData.getNote().getOctave() == 2) { + newBlockData.setNote(new Note(0, Tone.F, true)); + } else { + newBlockData.setNote(newBlockData.getNote().sharped()); + } consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); } - } - break; - case OAK_DOOR: - case SPRUCE_DOOR: - case BIRCH_DOOR: - case JUNGLE_DOOR: - case ACACIA_DOOR: - case DARK_OAK_DOOR: - case WARPED_DOOR: - case CRIMSON_DOOR: - if (wcfg.isLogging(Logging.DOORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { - Door newBlockData = (Door) blockData.clone(); - newBlockData.setOpen(!newBlockData.isOpen()); - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); - } - break; - case STONE_BUTTON: - case OAK_BUTTON: - case SPRUCE_BUTTON: - case BIRCH_BUTTON: - case JUNGLE_BUTTON: - case ACACIA_BUTTON: - case DARK_OAK_BUTTON: - case WARPED_BUTTON: - case CRIMSON_BUTTON: - case LEVER: - if (wcfg.isLogging(Logging.SWITCHINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { - Switch newBlockData = (Switch) blockData.clone(); - if (!newBlockData.isPowered() || type == Material.LEVER) { - newBlockData.setPowered(!newBlockData.isPowered()); + break; + case REPEATER: + if (wcfg.isLogging(Logging.DIODEINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { + Repeater newBlockData = (Repeater) blockData.clone(); + newBlockData.setDelay((newBlockData.getDelay() % 4) + 1); + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); } - consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); - } - break; - case OAK_SIGN: - case SPRUCE_SIGN: - case BIRCH_SIGN: - case JUNGLE_SIGN: - case ACACIA_SIGN: - case DARK_OAK_SIGN: - case WARPED_SIGN: - case CRIMSON_SIGN: - case OAK_WALL_SIGN: - case SPRUCE_WALL_SIGN: - case BIRCH_WALL_SIGN: - case JUNGLE_WALL_SIGN: - case ACACIA_WALL_SIGN: - case DARK_OAK_WALL_SIGN: - case WARPED_WALL_SIGN: - case CRIMSON_WALL_SIGN: - if (wcfg.isLogging(Logging.SIGNTEXT) && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getItem() != null) { - Material itemType = event.getItem().getType(); - if (BukkitUtils.isDye(itemType) || itemType == Material.GLOW_INK_SAC || itemType == Material.INK_SAC) { - final BlockState before = event.getClickedBlock().getState(); - if (before instanceof Sign) { - if (itemType == Material.GLOW_INK_SAC) { - Sign signBefore = (Sign) before; - if (!signBefore.isGlowingText()) { - final Sign signAfter = (Sign) event.getClickedBlock().getState(); - signAfter.setGlowingText(true); - consumer.queueBlockReplace(Actor.actorFromEntity(player), signBefore, signAfter); - } - } else if (itemType == Material.INK_SAC) { - Sign signBefore = (Sign) before; - if (signBefore.isGlowingText()) { - final Sign signAfter = (Sign) event.getClickedBlock().getState(); - signAfter.setGlowingText(false); - consumer.queueBlockReplace(Actor.actorFromEntity(player), signBefore, signAfter); - } - } else { - DyeColor newColor = BukkitUtils.dyeToDyeColor(itemType); - Sign signBefore = (Sign) before; - if (newColor != null && signBefore.getColor() != newColor) { - final Sign signAfter = (Sign) event.getClickedBlock().getState(); - signAfter.setColor(newColor); - consumer.queueBlockReplace(Actor.actorFromEntity(player), signBefore, signAfter); - } - } + break; + case COMPARATOR: + if (wcfg.isLogging(Logging.COMPARATORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { + Comparator newBlockData = (Comparator) blockData.clone(); + newBlockData.setMode(newBlockData.getMode() == Mode.COMPARE ? Mode.SUBTRACT : Mode.COMPARE); + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); + } + break; + case DAYLIGHT_DETECTOR: + if (wcfg.isLogging(Logging.DAYLIGHTDETECTORINTERACT) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { + DaylightDetector newBlockData = (DaylightDetector) blockData.clone(); + newBlockData.setInverted(!newBlockData.isInverted()); + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); + } + break; + case TRIPWIRE: + if (wcfg.isLogging(Logging.TRIPWIREINTERACT) && event.getAction() == Action.PHYSICAL) { + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, blockData); + } + break; + case FARMLAND: + if (wcfg.isLogging(Logging.CROPTRAMPLE) && event.getAction() == Action.PHYSICAL) { + // 3 = Dirt ID + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, Material.DIRT.createBlockData()); + // Log the crop on top as being broken + Block trampledCrop = clicked.getRelative(BlockFace.UP); + if (BukkitUtils.getCropBlocks().contains(trampledCrop.getType())) { + consumer.queueBlockBreak(Actor.actorFromEntity(player), trampledCrop.getState()); } } - } - break; - default: + break; + case TURTLE_EGG: + if (wcfg.isLogging(Logging.BLOCKBREAK) && event.getAction() == Action.PHYSICAL) { + TurtleEgg turtleEggData = (TurtleEgg) blockData; + int eggs = turtleEggData.getEggs(); + if (eggs > 1) { + TurtleEgg turtleEggData2 = (TurtleEgg) turtleEggData.clone(); + turtleEggData2.setEggs(eggs - 1); + consumer.queueBlock(Actor.actorFromEntity(player), loc, turtleEggData, turtleEggData2); + } else { + consumer.queueBlock(Actor.actorFromEntity(player), loc, turtleEggData, Material.AIR.createBlockData()); + } + } + break; + case PUMPKIN: + if ((wcfg.isLogging(Logging.BLOCKBREAK) || wcfg.isLogging(Logging.BLOCKPLACE)) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { + ItemStack inHand = event.getItem(); + if (inHand != null && inHand.getType() == Material.SHEARS) { + BlockFace clickedFace = event.getBlockFace(); + Directional newBlockData = (Directional) Material.CARVED_PUMPKIN.createBlockData(); + if (clickedFace == BlockFace.NORTH || clickedFace == BlockFace.SOUTH || clickedFace == BlockFace.EAST || clickedFace == BlockFace.WEST) { + newBlockData.setFacing(clickedFace); + } else { + // use player distance to calculate the facing + Location playerLoc = player.getLocation(); + playerLoc.subtract(0.5, 0, 0.5); + double dx = playerLoc.getX() - loc.getX(); + double dz = playerLoc.getZ() - loc.getZ(); + if (Math.abs(dx) > Math.abs(dz)) { + newBlockData.setFacing(dx > 0 ? BlockFace.EAST : BlockFace.WEST); + } else { + newBlockData.setFacing(dz > 0 ? BlockFace.SOUTH : BlockFace.NORTH); + } + } + consumer.queueBlock(Actor.actorFromEntity(player), loc, blockData, newBlockData); + } + } + break; + default: + } } } } diff --git a/src/main/java/de/diddiz/LogBlock/util/BukkitUtils.java b/src/main/java/de/diddiz/LogBlock/util/BukkitUtils.java index d083fcc..4b647eb 100644 --- a/src/main/java/de/diddiz/LogBlock/util/BukkitUtils.java +++ b/src/main/java/de/diddiz/LogBlock/util/BukkitUtils.java @@ -7,6 +7,7 @@ import java.io.File; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.EnumMap; import java.util.EnumSet; import java.util.HashMap; @@ -70,7 +71,10 @@ public class BukkitUtils { private static final Map projectileItems; private static final EnumSet signs; private static final EnumSet wallSigns; + private static final EnumSet hangingSigns; + private static final EnumSet hangingWallSigns; private static final EnumSet allSigns; + private static final Set unmodifiableSigns; private static final EnumSet buttons; private static final EnumSet pressurePlates; private static final EnumSet woodenDoors; @@ -80,8 +84,34 @@ public class BukkitUtils { private static final EnumSet alwaysWaterlogged; private static final EnumSet candles; private static final EnumSet candleCakes; + private static final EnumSet fenceGates; + private static final EnumSet woodenTrapdoors; static { + fenceGates = EnumSet.noneOf(Material.class); + fenceGates.add(Material.OAK_FENCE_GATE); + fenceGates.add(Material.SPRUCE_FENCE_GATE); + fenceGates.add(Material.BIRCH_FENCE_GATE); + fenceGates.add(Material.JUNGLE_FENCE_GATE); + fenceGates.add(Material.ACACIA_FENCE_GATE); + fenceGates.add(Material.DARK_OAK_FENCE_GATE); + fenceGates.add(Material.WARPED_FENCE_GATE); + fenceGates.add(Material.CRIMSON_FENCE_GATE); + fenceGates.add(Material.MANGROVE_FENCE_GATE); + fenceGates.add(Material.BAMBOO_FENCE_GATE); + + woodenTrapdoors = EnumSet.noneOf(Material.class); + woodenTrapdoors.add(Material.OAK_TRAPDOOR); + woodenTrapdoors.add(Material.SPRUCE_TRAPDOOR); + woodenTrapdoors.add(Material.BIRCH_TRAPDOOR); + woodenTrapdoors.add(Material.JUNGLE_TRAPDOOR); + woodenTrapdoors.add(Material.ACACIA_TRAPDOOR); + woodenTrapdoors.add(Material.DARK_OAK_TRAPDOOR); + woodenTrapdoors.add(Material.WARPED_TRAPDOOR); + woodenTrapdoors.add(Material.CRIMSON_TRAPDOOR); + woodenTrapdoors.add(Material.MANGROVE_TRAPDOOR); + woodenTrapdoors.add(Material.BAMBOO_TRAPDOOR); + pressurePlates = EnumSet.noneOf(Material.class); pressurePlates.add(Material.OAK_PRESSURE_PLATE); pressurePlates.add(Material.SPRUCE_PRESSURE_PLATE); @@ -207,9 +237,36 @@ public class BukkitUtils { wallSigns.add(Material.MANGROVE_WALL_SIGN); wallSigns.add(Material.BAMBOO_WALL_SIGN); + hangingSigns = EnumSet.noneOf(Material.class); + hangingSigns.add(Material.OAK_HANGING_SIGN); + hangingSigns.add(Material.SPRUCE_HANGING_SIGN); + hangingSigns.add(Material.BIRCH_HANGING_SIGN); + hangingSigns.add(Material.JUNGLE_HANGING_SIGN); + hangingSigns.add(Material.DARK_OAK_HANGING_SIGN); + hangingSigns.add(Material.ACACIA_HANGING_SIGN); + hangingSigns.add(Material.WARPED_HANGING_SIGN); + hangingSigns.add(Material.CRIMSON_HANGING_SIGN); + hangingSigns.add(Material.MANGROVE_HANGING_SIGN); + hangingSigns.add(Material.BAMBOO_HANGING_SIGN); + + hangingWallSigns = EnumSet.noneOf(Material.class); + hangingWallSigns.add(Material.OAK_WALL_HANGING_SIGN); + hangingWallSigns.add(Material.SPRUCE_WALL_HANGING_SIGN); + hangingWallSigns.add(Material.BIRCH_WALL_HANGING_SIGN); + hangingWallSigns.add(Material.JUNGLE_WALL_HANGING_SIGN); + hangingWallSigns.add(Material.DARK_OAK_WALL_HANGING_SIGN); + hangingWallSigns.add(Material.ACACIA_WALL_HANGING_SIGN); + hangingWallSigns.add(Material.WARPED_WALL_HANGING_SIGN); + hangingWallSigns.add(Material.CRIMSON_WALL_HANGING_SIGN); + hangingWallSigns.add(Material.MANGROVE_WALL_HANGING_SIGN); + hangingWallSigns.add(Material.BAMBOO_WALL_HANGING_SIGN); + allSigns = EnumSet.noneOf(Material.class); allSigns.addAll(signs); allSigns.addAll(wallSigns); + allSigns.addAll(hangingSigns); + allSigns.addAll(hangingWallSigns); + unmodifiableSigns = Collections.unmodifiableSet(allSigns); singleBlockPlants = EnumSet.noneOf(Material.class); singleBlockPlants.add(Material.GRASS); @@ -1131,8 +1188,8 @@ public class BukkitUtils { return false; } - public static Material[] getAllSignsArray() { - return allSigns.toArray(new Material[allSigns.size()]); + public static Set getAllSignMaterials() { + return unmodifiableSigns; } public static boolean isAlwaysWaterlogged(Material m) { @@ -1146,4 +1203,24 @@ public class BukkitUtils { public static boolean isCandleCake(Material m) { return candleCakes.contains(m); } + + public static boolean isHangingSign(Material m) { + return hangingSigns.contains(m); + } + + public static boolean isFenceGate(Material m) { + return fenceGates.contains(m); + } + + public static boolean isWoodenTrapdoor(Material m) { + return woodenTrapdoors.contains(m); + } + + public static boolean isPressurePlate(Material m) { + return pressurePlates.contains(m); + } + + public static boolean isSign(Material m) { + return allSigns.contains(m); + } } diff --git a/src/main/java/de/diddiz/LogBlock/util/LoggingUtil.java b/src/main/java/de/diddiz/LogBlock/util/LoggingUtil.java index 2c8ede7..5235d94 100644 --- a/src/main/java/de/diddiz/LogBlock/util/LoggingUtil.java +++ b/src/main/java/de/diddiz/LogBlock/util/LoggingUtil.java @@ -228,6 +228,8 @@ public class LoggingUtil { if (lantern.isHanging()) { consumer.queueBlockBreak(actor, checkBlock.getState()); } + } else if (BukkitUtils.isHangingSign(typeBelow)) { + consumer.queueBlockBreak(actor, checkBlock.getState()); } else if (typeBelow == Material.BELL) { Bell bell = (Bell) checkBlock.getBlockData(); if (bell.getAttachment() == Attachment.CEILING) {