Updated Smart Logging for 1.7.2 and resolved a bug with door logging

This commit is contained in:
Dark Arc
2013-12-06 01:19:04 -05:00
parent cb5741dd73
commit 3cffeccedb
3 changed files with 48 additions and 9 deletions

View File

@ -42,7 +42,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.6.1-R0.1-SNAPSHOT</version>
<version>1.7.2-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>

View File

@ -60,7 +60,7 @@ public class BukkitUtils
relativeBreakable.add(Material.COCOA);
// Blocks that break when they are on top of a block
relativeTopBreakable = new HashSet<Material>(32);
relativeTopBreakable = new HashSet<Material>(33);
relativeTopBreakable.add(Material.SAPLING);
relativeTopBreakable.add(Material.LONG_GRASS);
relativeTopBreakable.add(Material.DEAD_BUSH);
@ -91,8 +91,9 @@ public class BukkitUtils
relativeTopBreakable.add(Material.REDSTONE_COMPARATOR_ON);
relativeTopBreakable.add(Material.REDSTONE_COMPARATOR_OFF);
relativeTopBreakable.add(Material.WOODEN_DOOR);
relativeTopBreakable.add(Material.IRON_DOOR);
relativeTopBreakable.add(Material.IRON_DOOR_BLOCK);
relativeTopBreakable.add(Material.CARPET);
relativeTopBreakable.add(Material.DOUBLE_PLANT);
// Blocks that fall
relativeTopFallables = new HashSet<Material>(4);
@ -179,6 +180,19 @@ public class BukkitUtils
return blocks;
}
public static boolean isTop(Material mat, byte data) {
switch (mat) {
case DOUBLE_PLANT:
return data > 5;
case IRON_DOOR_BLOCK:
case WOODEN_DOOR:
return data == 8 || data == 9;
default:
return false;
}
}
public static int getInventoryHolderType(InventoryHolder holder) {
if (holder instanceof DoubleChest) {
return ((DoubleChest)holder).getLocation().getBlock().getTypeId();

View File

@ -73,18 +73,30 @@ public class LoggingUtil {
if (BukkitUtils.getRelativeTopBreakabls().contains(checkBlock.getType())) {
if (wcfg.isLogging(Logging.SIGNTEXT) && checkBlock.getType() == Material.SIGN_POST) {
consumer.queueSignBreak(playerName, (Sign) checkBlock.getState());
} else if (checkBlock.getType() == Material.IRON_DOOR || checkBlock.getType() == Material.WOOD_DOOR) {
} else if (checkBlock.getType() == Material.IRON_DOOR_BLOCK || checkBlock.getType() == Material.WOODEN_DOOR) {
Block doorBlock = checkBlock;
// If the doorBlock is the top half a door the player simply punched a door
// this will be handled later.
if (doorBlock.getData() != 8 && doorBlock.getData() != 9) {
if (!BukkitUtils.isTop(doorBlock.getType(), doorBlock.getData())) {
doorBlock = doorBlock.getRelative(BlockFace.UP);
// Fall back check just in case the top half wasn't a door
if (doorBlock.getType() == Material.IRON_DOOR || doorBlock.getType() == Material.WOOD_DOOR) {
if (doorBlock.getType() == Material.IRON_DOOR_BLOCK || doorBlock.getType() == Material.WOODEN_DOOR) {
consumer.queueBlockBreak(playerName, doorBlock.getState());
}
consumer.queueBlockBreak(playerName, checkBlock.getState());
}
} else if (checkBlock.getType() == Material.DOUBLE_PLANT) {
Block plantBlock = checkBlock;
// If the plantBlock is the top half of a double plant the player simply
// punched the plant this will be handled later.
if (!BukkitUtils.isTop(plantBlock.getType(), plantBlock.getData())) {
plantBlock = plantBlock.getRelative(BlockFace.UP);
// Fall back check just in case the top half wasn't a plant
if (plantBlock.getType() == Material.DOUBLE_PLANT) {
consumer.queueBlockBreak(playerName, plantBlock.getState());
}
consumer.queueBlockBreak(playerName, checkBlock.getState());
}
} else {
consumer.queueBlockBreak(playerName, checkBlock.getState());
}
@ -156,19 +168,32 @@ public class LoggingUtil {
}
// Special door check
if (origin.getType() == Material.IRON_DOOR || origin.getType() == Material.WOOD_DOOR) {
if (origin.getType() == Material.IRON_DOOR_BLOCK || origin.getType() == Material.WOODEN_DOOR) {
Block doorBlock = origin;
// Up or down?
if (origin.getData() != 8 && origin.getData() != 9) {
if (!BukkitUtils.isTop(doorBlock.getType(), doorBlock.getData())) {
doorBlock = doorBlock.getRelative(BlockFace.UP);
} else {
doorBlock = doorBlock.getRelative(BlockFace.DOWN);
}
if (doorBlock.getType() == Material.IRON_DOOR || doorBlock.getType() == Material.WOOD_DOOR) {
if (doorBlock.getType() == Material.IRON_DOOR_BLOCK || doorBlock.getType() == Material.WOODEN_DOOR) {
consumer.queueBlockBreak(playerName, doorBlock.getState());
}
} else if (origin.getType() == Material.DOUBLE_PLANT) { // Special double plant check
Block plantBlock = origin;
// Up or down?
if (!BukkitUtils.isTop(origin.getType(), origin.getData())) {
plantBlock = plantBlock.getRelative(BlockFace.UP);
} else {
plantBlock = plantBlock.getRelative(BlockFace.DOWN);
}
if (plantBlock.getType() == Material.DOUBLE_PLANT) {
consumer.queueBlockBreak(playerName, plantBlock.getState());
}
}
// Do this down here so that the block is added after blocks sitting on it