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 c965e135..88d3e773 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeMisc.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeMisc.java @@ -15,63 +15,63 @@ import org.bukkit.entity.Projectile; * */ public class BridgeMisc { - - /** - * Return a shooter of a projectile if we get an entity, null otherwise. - */ - public static Player getShooterPlayer(Projectile projectile) { - 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 { - return null; - } - } - - /** - * Retrieve a player from projectiles or cast to player, if possible. - * @param damager - * @return - */ - public static Player getAttackingPlayer(Entity damager) { - if (damager instanceof Player) { - return (Player) damager; - } else if (damager instanceof Projectile) { - return getShooterPlayer((Projectile) damager); - } else { - return null; - } - } - - /** - * Get online players as an array (convenience for reducing IDE markers :p). - * @return - */ - public static Player[] getOnlinePlayers() { - Object obj = Bukkit.getOnlinePlayers(); - if (obj instanceof Collection) { - @SuppressWarnings("unchecked") + + /** + * Return a shooter of a projectile if we get an entity, null otherwise. + */ + public static Player getShooterPlayer(Projectile projectile) { + 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 { + return null; + } + } + + /** + * Retrieve a player from projectiles or cast to player, if possible. + * @param damager + * @return + */ + public static Player getAttackingPlayer(Entity damager) { + if (damager instanceof Player) { + return (Player) damager; + } else if (damager instanceof Projectile) { + return getShooterPlayer((Projectile) damager); + } else { + return null; + } + } + + /** + * Get online players as an array (convenience for reducing IDE markers :p). + * @return + */ + public static Player[] getOnlinePlayers() { + Object obj = Bukkit.getOnlinePlayers(); + if (obj instanceof Collection) { + @SuppressWarnings("unchecked") Collection players = (Collection) obj; - return players.toArray(new Player[players.size()]); - } - else if (obj instanceof Player[]) { - return (Player[]) obj; - } else { - return new Player[0]; - } - } - + return players.toArray(new Player[players.size()]); + } + else if (obj instanceof Player[]) { + return (Player[]) obj; + } else { + return new Player[0]; + } + } + }