From 1f83319c8f1f41d96936faa22b3ea5cb09835f50 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 8 Jan 2017 23:52:44 +1100 Subject: [PATCH] Fix FakePlayer error (API usage) --- .../main/java/com/boydti/fawe/wrappers/FakePlayer.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java b/core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java index 19b6b25a..4d8cd041 100644 --- a/core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java +++ b/core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java @@ -13,9 +13,11 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.CommandManager; +import com.sk89q.worldedit.extension.platform.NoCapablePlatformException; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.NullWorld; import com.sk89q.worldedit.world.World; import java.util.UUID; import javax.annotation.Nullable; @@ -46,7 +48,7 @@ public class FakePlayer extends LocalPlayer { private Location pos; public static FakePlayer wrap(String name, UUID uuid, Actor parent) { - if (parent.getUniqueId().toString().equals("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be")) { + if (parent != null && parent.getUniqueId().toString().equals("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be")) { return getConsole(); } return new FakePlayer(name, uuid, parent); @@ -55,7 +57,11 @@ public class FakePlayer extends LocalPlayer { public FakePlayer(String name, UUID uuid, Actor parent) { this.name = name; this.uuid = uuid == null ? UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)) : uuid; - this.world = WorldEdit.getInstance().getServer().getWorlds().get(0); + try { + this.world = WorldEdit.getInstance().getServer().getWorlds().get(0); + } catch (NoCapablePlatformException e) { + this.world = NullWorld.getInstance(); + } this.pos = new Location(world, 0, 0, 0); this.parent = parent; }