forked from LogBlock/LogBlock
Fixed door logging
This commit is contained in:
@@ -3,9 +3,12 @@ package de.diddiz.LogBlock;
|
|||||||
import static de.diddiz.util.MaterialName.materialName;
|
import static de.diddiz.util.MaterialName.materialName;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import de.diddiz.util.BukkitUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import de.diddiz.LogBlock.config.Config;
|
import de.diddiz.LogBlock.config.Config;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
public class BlockChange implements LookupCacheElement
|
public class BlockChange implements LookupCacheElement
|
||||||
{
|
{
|
||||||
@@ -64,10 +67,19 @@ public class BlockChange implements LookupCacheElement
|
|||||||
msg.append("took ").append(-ca.itemAmount).append("x ").append(materialName(ca.itemType, ca.itemData));
|
msg.append("took ").append(-ca.itemAmount).append("x ").append(materialName(ca.itemType, ca.itemData));
|
||||||
else
|
else
|
||||||
msg.append("put in ").append(ca.itemAmount).append("x ").append(materialName(ca.itemType, ca.itemData));
|
msg.append("put in ").append(ca.itemAmount).append("x ").append(materialName(ca.itemType, ca.itemData));
|
||||||
} else if (type == 23 || type == 54 || type == 61 || type == 62)
|
} else if (BukkitUtils.getContainerBlocks().contains(Material.getMaterial(type)))
|
||||||
msg.append("opened ").append(materialName(type));
|
msg.append("opened ").append(materialName(type));
|
||||||
else if (type == 64 || type == 71 || type == 96 || type == 107)
|
else if (type == 64 || type == 71)
|
||||||
msg.append(data == 0 ? "opened" : "closed").append(" ").append(materialName(type));
|
// This is a problem that will have to be addressed in LB 2,
|
||||||
|
// there is no way to tell from the top half of the block if
|
||||||
|
// the door is opened or closed.
|
||||||
|
msg.append("moved ").append(materialName(type));
|
||||||
|
// Trapdoor
|
||||||
|
else if (type == 96)
|
||||||
|
msg.append((data < 8 || data > 11) ? "opened" : "closed").append(" ").append(materialName(type));
|
||||||
|
// Fence gate
|
||||||
|
else if (type == 107)
|
||||||
|
msg.append(data > 3 ? "opened" : "closed").append(" ").append(materialName(type));
|
||||||
else if (type == 69)
|
else if (type == 69)
|
||||||
msg.append("switched ").append(materialName(type));
|
msg.append("switched ").append(materialName(type));
|
||||||
else if (type == 77 || type == 143)
|
else if (type == 77 || type == 143)
|
||||||
|
@@ -209,11 +209,6 @@ public class WorldEditor implements Runnable
|
|||||||
final Block secBlock = bed.isHeadOfBed() ? block.getRelative(bed.getFacing().getOppositeFace()) : block.getRelative(bed.getFacing());
|
final Block secBlock = bed.isHeadOfBed() ? block.getRelative(bed.getFacing().getOppositeFace()) : block.getRelative(bed.getFacing());
|
||||||
if (secBlock.getTypeId() == 0 && !secBlock.setTypeIdAndData(26, (byte)(bed.getData() | 8), true))
|
if (secBlock.getTypeId() == 0 && !secBlock.setTypeIdAndData(26, (byte)(bed.getData() | 8), true))
|
||||||
throw new WorldEditorException(secBlock.getTypeId(), 26, secBlock.getLocation());
|
throw new WorldEditorException(secBlock.getTypeId(), 26, secBlock.getLocation());
|
||||||
} else if (curtype == 64 || curtype == 71) {
|
|
||||||
final byte blockData = block.getData();
|
|
||||||
final Block secBlock = (blockData & 8) == 8 ? block.getRelative(BlockFace.DOWN) : block.getRelative(BlockFace.UP);
|
|
||||||
if (secBlock.getTypeId() == 0 && !secBlock.setTypeIdAndData(curtype, (byte)(blockData | 8), true))
|
|
||||||
throw new WorldEditorException(secBlock.getTypeId(), curtype, secBlock.getLocation());
|
|
||||||
} else if ((curtype == 29 || curtype == 33) && (block.getData() & 8) > 0) {
|
} else if ((curtype == 29 || curtype == 33) && (block.getData() & 8) > 0) {
|
||||||
final PistonBaseMaterial piston = (PistonBaseMaterial)block.getState().getData();
|
final PistonBaseMaterial piston = (PistonBaseMaterial)block.getState().getData();
|
||||||
final Block secBlock = block.getRelative(piston.getFacing());
|
final Block secBlock = block.getRelative(piston.getFacing());
|
||||||
|
@@ -31,13 +31,14 @@ public class BlockBreakLogging extends LoggingListener
|
|||||||
|
|
||||||
final String playerName = event.getPlayer().getName();
|
final String playerName = event.getPlayer().getName();
|
||||||
final Block origin = event.getBlock();
|
final Block origin = event.getBlock();
|
||||||
final int type = origin.getTypeId();
|
final int typeId = origin.getTypeId();
|
||||||
|
final Material type = origin.getType();
|
||||||
|
|
||||||
if (wcfg.isLogging(Logging.SIGNTEXT) && (type == 63 || type == 68)) {
|
if (wcfg.isLogging(Logging.SIGNTEXT) && (typeId == 63 || typeId == 68)) {
|
||||||
consumer.queueSignBreak(playerName, (Sign) origin.getState());
|
consumer.queueSignBreak(playerName, (Sign) origin.getState());
|
||||||
} else if (wcfg.isLogging(Logging.CHESTACCESS) && (type == 23 || type == 54 || type == 61)) {
|
} else if (wcfg.isLogging(Logging.CHESTACCESS) && BukkitUtils.getContainerBlocks().contains(type)) {
|
||||||
consumer.queueContainerBreak(playerName, origin.getState());
|
consumer.queueContainerBreak(playerName, origin.getState());
|
||||||
} else if (origin.getType() == Material.ICE) {
|
} else if (type == Material.ICE) {
|
||||||
// When in creative mode ice doesn't form water
|
// When in creative mode ice doesn't form water
|
||||||
if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
|
if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
|
||||||
consumer.queueBlockBreak(playerName, origin.getState());
|
consumer.queueBlockBreak(playerName, origin.getState());
|
||||||
|
@@ -33,6 +33,7 @@ public class BukkitUtils
|
|||||||
private static final Set<Material> fallingEntityKillers;
|
private static final Set<Material> fallingEntityKillers;
|
||||||
|
|
||||||
private static final Set<Material> cropBlocks;
|
private static final Set<Material> cropBlocks;
|
||||||
|
private static final Set<Material> containerBlocks;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
blockEquivalents = new HashSet<Set<Integer>>(7);
|
blockEquivalents = new HashSet<Set<Integer>>(7);
|
||||||
@@ -140,6 +141,17 @@ public class BukkitUtils
|
|||||||
cropBlocks.add(Material.PUMPKIN_STEM);
|
cropBlocks.add(Material.PUMPKIN_STEM);
|
||||||
cropBlocks.add(Material.CARROT);
|
cropBlocks.add(Material.CARROT);
|
||||||
cropBlocks.add(Material.POTATO);
|
cropBlocks.add(Material.POTATO);
|
||||||
|
|
||||||
|
// Container Blocks
|
||||||
|
containerBlocks = new HashSet<Material>(6);
|
||||||
|
containerBlocks.add(Material.CHEST);
|
||||||
|
containerBlocks.add(Material.TRAPPED_CHEST);
|
||||||
|
containerBlocks.add(Material.DISPENSER);
|
||||||
|
containerBlocks.add(Material.DROPPER);
|
||||||
|
containerBlocks.add(Material.HOPPER);
|
||||||
|
containerBlocks.add(Material.BREWING_STAND);
|
||||||
|
// Doesn't actually have a block inventory
|
||||||
|
// containerBlocks.add(Material.ENDER_CHEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final BlockFace[] relativeBlockFaces = new BlockFace[] {
|
private static final BlockFace[] relativeBlockFaces = new BlockFace[] {
|
||||||
@@ -278,6 +290,10 @@ public class BukkitUtils
|
|||||||
return cropBlocks;
|
return cropBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Set<Material> getContainerBlocks() {
|
||||||
|
return containerBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
public static String entityName(Entity entity) {
|
public static String entityName(Entity entity) {
|
||||||
if (entity instanceof Player)
|
if (entity instanceof Player)
|
||||||
return ((Player)entity).getName();
|
return ((Player)entity).getName();
|
||||||
|
@@ -73,6 +73,18 @@ public class LoggingUtil {
|
|||||||
if (BukkitUtils.getRelativeTopBreakabls().contains(checkBlock.getType())) {
|
if (BukkitUtils.getRelativeTopBreakabls().contains(checkBlock.getType())) {
|
||||||
if (wcfg.isLogging(Logging.SIGNTEXT) && checkBlock.getType() == Material.SIGN_POST) {
|
if (wcfg.isLogging(Logging.SIGNTEXT) && checkBlock.getType() == Material.SIGN_POST) {
|
||||||
consumer.queueSignBreak(playerName, (Sign) checkBlock.getState());
|
consumer.queueSignBreak(playerName, (Sign) checkBlock.getState());
|
||||||
|
} else if (checkBlock.getType() == Material.IRON_DOOR || checkBlock.getType() == Material.WOOD_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) {
|
||||||
|
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) {
|
||||||
|
consumer.queueBlockBreak(playerName, doorBlock.getState());
|
||||||
|
}
|
||||||
|
consumer.queueBlockBreak(playerName, checkBlock.getState());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
consumer.queueBlockBreak(playerName, checkBlock.getState());
|
consumer.queueBlockBreak(playerName, checkBlock.getState());
|
||||||
}
|
}
|
||||||
@@ -142,6 +154,23 @@ public class LoggingUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special door check
|
||||||
|
if (origin.getType() == Material.IRON_DOOR || origin.getType() == Material.WOOD_DOOR) {
|
||||||
|
Block doorBlock = origin;
|
||||||
|
|
||||||
|
// Up or down?
|
||||||
|
if (origin.getData() != 8 && origin.getData() != 9) {
|
||||||
|
doorBlock = doorBlock.getRelative(BlockFace.UP);
|
||||||
|
} else {
|
||||||
|
doorBlock = doorBlock.getRelative(BlockFace.DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doorBlock.getType() == Material.IRON_DOOR || doorBlock.getType() == Material.WOOD_DOOR) {
|
||||||
|
consumer.queueBlockBreak(playerName, doorBlock.getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do this down here so that the block is added after blocks sitting on it
|
// Do this down here so that the block is added after blocks sitting on it
|
||||||
consumer.queueBlockBreak(playerName, origin.getState());
|
consumer.queueBlockBreak(playerName, origin.getState());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user