示例#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 findPlayerExact(String name) {
   if (name == null) return null;
   Player lastPlayer = Bukkit.getPlayerExact(name);
   if (lastPlayer != null) return lastPlayer;
   if (Defaults.DEBUG_VIRTUAL) {
     return VirtualPlayers.getPlayer(name);
   }
   return null;
 }
示例#3
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();
    }
  }