Skip to content

Commit

Permalink
Wrap createEntity in BukkitWorld to detect corrupt entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Aug 5, 2018
1 parent 3341433 commit 88fc177
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,19 @@ public List<com.sk89q.worldedit.entity.Entity> getEntities() {
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 {
Expand Down

0 comments on commit 88fc177

Please sign in to comment.