diff --git a/src/main/java/de/diddiz/LogBlock/CommandsHandler.java b/src/main/java/de/diddiz/LogBlock/CommandsHandler.java index 6f09c53..b3c8039 100755 --- a/src/main/java/de/diddiz/LogBlock/CommandsHandler.java +++ b/src/main/java/de/diddiz/LogBlock/CommandsHandler.java @@ -406,7 +406,7 @@ public class CommandsHandler implements CommandExecutor params.needPlayer = true; if (params.types.isEmpty() || Block.inList(params.types, 63) || Block.inList(params.types, 68)) params.needSignText = true; - if (params.bct == BlockChangeType.CHESTACCESS || params.types.isEmpty() || Block.inList(params.types, 23) || Block.inList(params.types, 54) || Block.inList(params.types, 61) || Block.inList(params.types, 62)) + if (params.bct == BlockChangeType.CHESTACCESS || params.bct == BlockChangeType.ALL) params.needChestAccess = true; } conn = logblock.getConnection(); @@ -466,7 +466,7 @@ public class CommandsHandler implements CommandExecutor params.needPlayer = true; if (params.types.isEmpty() || Block.inList(params.types, 63) || Block.inList(params.types, 68)) params.needSignText = true; - if (params.types.isEmpty() || Block.inList(params.types, 23) || Block.inList(params.types, 54) || Block.inList(params.types, 61) || Block.inList(params.types, 62)) + if (params.bct == BlockChangeType.CHESTACCESS || params.bct == BlockChangeType.ALL) params.needChestAccess = true; } conn = logblock.getConnection(); @@ -538,9 +538,8 @@ public class CommandsHandler implements CommandExecutor public void run() { try { params.needCoords = true; - if (params.bct == BlockChangeType.CHESTACCESS || params.types.isEmpty() || Block.inList(params.types, 23) || Block.inList(params.types, 54) || Block.inList(params.types, 61) || Block.inList(params.types, 62)) { + if (params.bct == BlockChangeType.CHESTACCESS || params.bct == BlockChangeType.ALL) params.needChestAccess = true; - } params.limit = 1; params.sum = SummarizationMode.NONE; conn = logblock.getConnection(); diff --git a/src/main/java/de/diddiz/LogBlock/Consumer.java b/src/main/java/de/diddiz/LogBlock/Consumer.java index e1fb205..5938ce7 100644 --- a/src/main/java/de/diddiz/LogBlock/Consumer.java +++ b/src/main/java/de/diddiz/LogBlock/Consumer.java @@ -120,7 +120,7 @@ public class Consumer extends TimerTask /** * @param container - * The respective container. Must be an instance of Chest, Dispencer or Furnace. + * The respective container. Must be an instance of an InventoryHolder. */ public void queueChestAccess(String playerName, BlockState container, short itemType, short itemAmount, byte itemData) { if (!(container instanceof InventoryHolder)) @@ -130,7 +130,7 @@ public class Consumer extends TimerTask /** * @param type - * Type id of the container. Must be 63 or 68. + * Type id of the container. */ public void queueChestAccess(String playerName, Location loc, int type, short itemType, short itemAmount, byte itemData) { queueBlock(playerName, loc, type, type, (byte)0, null, new ChestAccess(itemType, itemAmount, itemData)); @@ -140,7 +140,7 @@ public class Consumer extends TimerTask * Logs a container block break. The block type before is assumed to be o (air). All content is assumed to be taken. * * @param container - * Must be instanceof InventoryHolder + * Must be an instance of InventoryHolder */ public void queueContainerBreak(String playerName, BlockState container) { if (!(container instanceof InventoryHolder)) diff --git a/src/main/java/de/diddiz/LogBlock/QueryParams.java b/src/main/java/de/diddiz/LogBlock/QueryParams.java index 964aa3e..01f0b56 100755 --- a/src/main/java/de/diddiz/LogBlock/QueryParams.java +++ b/src/main/java/de/diddiz/LogBlock/QueryParams.java @@ -141,7 +141,12 @@ public final class QueryParams implements Cloneable if (needSignText) from += "LEFT JOIN `" + getTable() + "-sign` USING (id) "; if (needChestAccess) - from += "LEFT JOIN `" + getTable() + "-chest` USING (id) "; + // If BlockChangeType is CHESTACCESS, we can use more efficient query + if (bct == BlockChangeType.CHESTACCESS) { + from += "RIGHT JOIN `" + getTable() + "-chest` USING (id) "; + } else { + from += "LEFT JOIN `" + getTable() + "-chest` USING (id) "; + } return select + " " + from + getWhere() + "ORDER BY date " + order + ", id " + order + " " + getLimit(); } else if (sum == SummarizationMode.TYPES) return "SELECT type, SUM(created) AS created, SUM(destroyed) AS destroyed FROM ((SELECT type, count(*) AS created, 0 AS destroyed FROM `" + getTable() + "` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.CREATED) + "GROUP BY type) UNION (SELECT replaced AS type, 0 AS created, count(*) AS destroyed FROM `" + getTable() + "` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.DESTROYED) + "GROUP BY replaced)) AS t GROUP BY type ORDER BY SUM(created) + SUM(destroyed) " + order + " " + getLimit(); @@ -367,7 +372,6 @@ public final class QueryParams implements Cloneable where.append("type != replaced AND "); break; case CHESTACCESS: - where.append("(type = 23 OR type = 54 OR type = 61 OR type = 62) AND type = replaced AND "); if (!types.isEmpty()) { where.append('('); for (final Block block : types) { diff --git a/src/main/java/de/diddiz/util/BukkitUtils.java b/src/main/java/de/diddiz/util/BukkitUtils.java index b3c7041..59f45a7 100644 --- a/src/main/java/de/diddiz/util/BukkitUtils.java +++ b/src/main/java/de/diddiz/util/BukkitUtils.java @@ -152,6 +152,8 @@ public class BukkitUtils containerBlocks.add(Material.DROPPER); containerBlocks.add(Material.HOPPER); containerBlocks.add(Material.BREWING_STAND); + containerBlocks.add(Material.FURNACE); + containerBlocks.add(Material.BEACON); // Doesn't actually have a block inventory // containerBlocks.add(Material.ENDER_CHEST); }