예제 #1
0
  public static Player findPlayer(String name) {
    if (name == null) return null;
    Player lastPlayer = Bukkit.getPlayer(name);
    if (lastPlayer != null) return lastPlayer;

    Player[] online = Bukkit.getOnlinePlayers();
    if (Defaults.DEBUG_VIRTUAL) {
      online = VirtualPlayers.getOnlinePlayers();
    }

    for (Player player : online) {
      String playerName = player.getName();

      if (playerName.equalsIgnoreCase(name)) {
        lastPlayer = player;
        break;
      }

      if (playerName.toLowerCase().indexOf(name.toLowerCase()) != -1) {
        if (lastPlayer != null) {
          return null;
        }

        lastPlayer = player;
      }
    }

    return lastPlayer;
  }
예제 #2
0
  public static Player[] getOnlinePlayers() {

    if (Defaults.DEBUG_VIRTUAL) {
      Player[] online = VirtualPlayers.getOnlinePlayers();
      Player[] realonline = Bukkit.getOnlinePlayers();
      return ArrayUtils.addAll(online, realonline);
    } else {
      return Bukkit.getOnlinePlayers();
    }
  }