org.bukkit.Bukkit.getOfflinePlayers()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.bukkit.Bukkit.getOfflinePlayers()方法的一些代码示例,展示了Bukkit.getOfflinePlayers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bukkit.getOfflinePlayers()方法的具体详情如下:
包路径:org.bukkit.Bukkit
类名称:Bukkit
方法名:getOfflinePlayers

Bukkit.getOfflinePlayers介绍

暂无

代码示例

代码示例来源:origin: Bukkit/Bukkit

if (args[0].equalsIgnoreCase("add")) {
  List<String> completions = new ArrayList<String>();
  for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
    String name = player.getName();
    if (StringUtil.startsWithIgnoreCase(name, args[1]) && !player.isWhitelisted()) {

代码示例来源:origin: me.lucko/helper

public static void forEachOffline(Consumer<OfflinePlayer> consumer) {
  for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
    consumer.accept(player);
  }
}

代码示例来源:origin: lucko/helper

public static void forEachOffline(Consumer<OfflinePlayer> consumer) {
  for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
    consumer.accept(player);
  }
}

代码示例来源:origin: me.lucko/helper

public static Collection<OfflinePlayer> allOffline() {
  return ImmutableList.copyOf(Bukkit.getOfflinePlayers());
}

代码示例来源:origin: me.lucko/helper

public static Stream<OfflinePlayer> streamOffline() {
  return Arrays.stream(Bukkit.getOfflinePlayers());
}

代码示例来源:origin: lucko/helper

public static Stream<OfflinePlayer> streamOffline() {
  return Arrays.stream(Bukkit.getOfflinePlayers());
}

代码示例来源:origin: lucko/helper

public static Collection<OfflinePlayer> allOffline() {
  return ImmutableList.copyOf(Bukkit.getOfflinePlayers());
}

代码示例来源:origin: Rsl1122/Plan-PlayerAnalytics

@Override
  public List<UserImportData> getUserImportData() {
    List<UserImportData> dataList = new ArrayList<>();

    Set<OfflinePlayer> operators = Bukkit.getOperators();
    Set<OfflinePlayer> banned = Bukkit.getBannedPlayers();

    Arrays.stream(Bukkit.getOfflinePlayers()).parallel().forEach(player -> {
      UserImportData.UserImportDataBuilder builder = UserImportData.builder(serverUUID.get());
      builder.name(player.getName())
          .uuid(player.getUniqueId())
          .registered(player.getFirstPlayed());

      if (operators.contains(player)) {
        builder.op();
      }

      if (banned.contains(player)) {
        builder.banned();
      }

      dataList.add(builder.build());
    });

    return dataList;
  }
}

代码示例来源:origin: MinecraftWars/Gringotts

@Override
public AccountHolder getAccountHolder(String uuidOrName) {
  if (uuidOrName == null) {
    return null;
  }
  OfflinePlayer player;
  try {
    UUID playerId = UUID.fromString(uuidOrName);
    player = Bukkit.getOfflinePlayer(playerId);
  } catch (IllegalArgumentException ignored) {
    // don't use getOfflinePlayer(String) because that will do a blocking web request
    // rather iterate this array, should be quick enough
    for (OfflinePlayer p : Bukkit.getOfflinePlayers()) {
      if (uuidOrName.equals(p.getName())) return new PlayerAccountHolder(p);
    }
    return null;
  }
  // if this player has ever played on the server, they are a legit account holder
  if (player.isOnline() || player.hasPlayedBefore()) {
    return new PlayerAccountHolder(player);
  } else {
    return null;
  }
}

相关文章