Avoid duplicate wrapping

This commit is contained in:
Jesse Boyd 2016-05-20 18:16:26 +10:00
parent 6c14c13ceb
commit 37f2ef9765
2 changed files with 9 additions and 2 deletions

View File

@ -37,7 +37,14 @@ public class WorldWrapper extends AbstractWorld {
private final AbstractWorld parent;
public WorldWrapper(AbstractWorld parent) {
public static WorldWrapper wrap(AbstractWorld world) {
if (world instanceof WorldWrapper) {
return (WorldWrapper) world;
}
return new WorldWrapper(world);
}
private WorldWrapper(AbstractWorld parent) {
this.parent = parent;
}

View File

@ -239,7 +239,7 @@ public class EditSession implements Extent {
}
// Wrap the world
this.world = (world instanceof WorldWrapper) ? world : (world = new WorldWrapper((AbstractWorld) world));
this.world = (world = WorldWrapper.wrap((AbstractWorld) world));
// Delegate some methods to an implementation specific class
this.wrapper = Fawe.imp().getEditSessionWrapper(this);