From 2e1b7676ebf4a9cdfd5e629b83519284b0f7a149 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 11 Apr 2019 02:17:45 +1000 Subject: [PATCH] Just use instanceof --- .../java/com/boydti/fawe/object/FawePlayer.java | 15 ++++----------- .../worldedit/extension/platform/PlayerProxy.java | 4 ++++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java index b1c74813f..6db804e91 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java @@ -74,17 +74,10 @@ public abstract class FawePlayer extends Metadatable { } if (obj instanceof Player) { Player actor = LocationMaskedPlayerWrapper.unwrap((Player) obj); - if (obj.getClass().getName().endsWith("PlayerProxy")) { - try { - Field fieldBasePlayer = actor.getClass().getDeclaredField("basePlayer"); - fieldBasePlayer.setAccessible(true); - Player player = (Player) fieldBasePlayer.get(actor); - FawePlayer result = wrap(player); - return (FawePlayer) (result == null ? wrap(player.getName()) : result); - } catch (Throwable e) { - MainUtil.handleError(e); - return Fawe.imp().wrap(actor.getName()); - } + if (obj instanceof PlayerProxy) { + Player player = ((PlayerProxy) obj).getBasePlayer(); + FawePlayer result = wrap(player); + return (FawePlayer) (result == null ? wrap(player.getName()) : result); } else if (obj instanceof PlayerWrapper) { return wrap(((PlayerWrapper) obj).getParent()); } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java index 61aebf909..8d8db170b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java @@ -189,5 +189,9 @@ public class PlayerProxy extends AbstractPlayerActor { public > void sendFakeBlock(BlockVector3 pos, B block) { basePlayer.sendFakeBlock(pos, block); } + + public Player getBasePlayer() { + return basePlayer; + } }