From 88fc1771b56e84eab6e6995bc7e623e14020c4d1 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 5 Aug 2018 14:24:09 +1000 Subject: [PATCH] Wrap createEntity in BukkitWorld to detect corrupt entities. --- .../com/sk89q/worldedit/bukkit/BukkitWorld.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 81ef4af75..25a82b242 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 @@ -111,10 +111,19 @@ public class BukkitWorld extends AbstractWorld { public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { - Entity createdEntity = adapter.createEntity(BukkitAdapter.adapt(getWorld(), location), entity); - if (createdEntity != null) { - return new BukkitEntity(createdEntity); - } else { + try { + Entity createdEntity = adapter.createEntity(BukkitAdapter.adapt(getWorld(), location), entity); + if (createdEntity != null) { + return new BukkitEntity(createdEntity); + } else { + return null; + } + } catch (Exception e) { + logger.warning("Corrupt entity found when creating: " + entity.getType().getId()); + if (entity.getNbtData() != null) { + logger.warning(entity.getNbtData().toString()); + } + e.printStackTrace(); return null; } } else {