From 526aa6cf490310d8cc0a3becdf1c962d8755b25e Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Mon, 6 Aug 2018 18:29:07 +1000 Subject: [PATCH] If we fail to set NBT Data, try it without the adapter/NBT Data --- .../com/sk89q/worldedit/bukkit/BukkitWorld.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 25a82b242..db20f6ac3 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -418,7 +418,18 @@ public class BukkitWorld extends AbstractWorld { public boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { - return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight); + try { + return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight); + } catch (Exception e) { + if (block instanceof BaseBlock && ((BaseBlock) block).getNbtData() != null) { + logger.warning("Tried to set a corrupt tile entity at " + position.toString()); + logger.warning(((BaseBlock) block).getNbtData().toString()); + } + e.printStackTrace(); + Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); + bukkitBlock.setBlockData(BukkitAdapter.adapt(block), notifyAndLight); + return true; + } } else { Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); bukkitBlock.setBlockData(BukkitAdapter.adapt(block), notifyAndLight);