From 40ff1e7778328d4b2a8a09c532fe8c3753d40bfb Mon Sep 17 00:00:00 2001 From: Intelli Date: Sun, 25 Jul 2021 21:15:53 -0600 Subject: [PATCH] Additional cleanup in ChestTool --- .../java/net/coreprotect/utility/ChestTool.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/coreprotect/utility/ChestTool.java b/src/main/java/net/coreprotect/utility/ChestTool.java index f5de7f2..99263de 100644 --- a/src/main/java/net/coreprotect/utility/ChestTool.java +++ b/src/main/java/net/coreprotect/utility/ChestTool.java @@ -17,7 +17,6 @@ public class ChestTool { } public static void updateDoubleChest(Block block, BlockData blockData, boolean forceValidation) { - // modifying container, trigger physics update on both sides of double chest if (!(blockData instanceof Chest) || ((Chest) blockData).getType() == Type.SINGLE) { return; } @@ -64,16 +63,18 @@ public class ChestTool { } } - if (newFace == null) { - return; - } + if (newFace != null) { + Type newType = (chestType == Type.LEFT) ? Type.RIGHT : Type.LEFT; + Block relativeBlock = block.getRelative(newFace); + if (!forceValidation && (relativeBlock.getBlockData() instanceof Chest) && ((Chest) relativeBlock.getBlockData()).getType() == newType) { + return; + } - Type newType = (chestType == Type.LEFT) ? Type.RIGHT : Type.LEFT; - Block relativeBlock = block.getRelative(newFace); - if (!forceValidation && (relativeBlock.getBlockData() instanceof Chest) && ((Chest) relativeBlock.getBlockData()).getType() == newType) { - return; + validateContainer(blockData, newType, block, relativeBlock); } + } + private static void validateContainer(BlockData blockData, Type newType, Block block, Block relativeBlock) { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> { try { BlockData relativeBlockData = relativeBlock.getBlockData();