From 8fb9f29ab73d017cb8e2884f9eadc50870642225 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 14 May 2020 12:57:26 +0100 Subject: [PATCH] Fixes #2827 If existing blocks are an instance of container, clear the inventory. --- .../java/com/plotsquared/bukkit/queue/BukkitLocalQueue.java | 6 ++++++ .../java/com/plotsquared/bukkit/schematic/StateWrapper.java | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitLocalQueue.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitLocalQueue.java index 26b303f69..3f93ebb63 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitLocalQueue.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitLocalQueue.java @@ -48,7 +48,9 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; +import org.bukkit.block.Container; import org.bukkit.block.data.BlockData; +import org.bukkit.inventory.BlockInventoryHolder; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; @@ -146,6 +148,10 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue { continue; } + if (existing.getState() instanceof Container) { + ((Container) existing.getState()).getInventory().clear(); + } + existing.setType(BukkitAdapter.adapt(block.getBlockType()), false); existing.setBlockData(blockData, false); if (block.hasNbtData()) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java index e68bcfca4..3467c4435 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java @@ -214,10 +214,8 @@ public class StateWrapper { if (mat != null) { ItemStack item = new ItemStack(mat, (int) amounts[i]); inv.setItem(slots[i], item); - PlotSquared.log(mat.name() + " " + slots[i]); } } - PlotSquared.log(inv.getStorageContents()); container.update(true, true); return true; }