From 95420740ee3d1d8e94e6c9456122a93cc7b5199b Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 9 Feb 2014 13:00:06 +0100 Subject: [PATCH] [BLIND] Relay to reflection to avoid issues with return types. --- .../nocheatplus/compat/BridgeMisc.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeMisc.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeMisc.java index 2a12a0f0..cab980e2 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeMisc.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeMisc.java @@ -1,5 +1,7 @@ package fr.neatmonster.nocheatplus.compat; +import java.lang.reflect.InvocationTargetException; + import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -16,7 +18,20 @@ public class BridgeMisc { * Return a shooter of a projectile if we get an entity, null otherwise. */ public static Player getShooterPlayer(Projectile projectile) { - Object source = projectile.getShooter(); + Object source; + try { + source = projectile.getClass().getMethod("getShooter").invoke(projectile); + } catch (IllegalArgumentException e) { + return null; + } catch (SecurityException e) { + return null; + } catch (IllegalAccessException e) { + return null; + } catch (InvocationTargetException e) { + return null; + } catch (NoSuchMethodException e) { + return null; + } if (source instanceof Player) { return (Player) source; } else {