mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-07 03:02:11 +01:00
[BLIND] Relay to reflection to avoid issues with return types.
This commit is contained in:
parent
719c3ac31b
commit
95420740ee
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user