org.bukkit.Server.getPlayerExact()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(234)

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

Server.getPlayerExact介绍

[英]Gets the player with the exact given name, case insensitive.
[中]获取具有确切给定名称的播放机,不区分大小写。

代码示例

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

/**
 * @see Server#getPlayerExact(String name)
 */
@Deprecated
public static Player getPlayerExact(String name) {
  return server.getPlayerExact(name);
}

代码示例来源:origin: EngineHub/WorldEdit

@Nullable
@Override
public Player matchPlayer(Player player) {
  if (player instanceof BukkitPlayer) {
    return player;
  } else {
    org.bukkit.entity.Player bukkitPlayer = server.getPlayerExact(player.getName());
    return bukkitPlayer != null ? new BukkitPlayer(plugin, bukkitPlayer) : null;
  }
}

代码示例来源:origin: EngineHub/WorldEdit

@Override
@SuppressWarnings("static-access")
public boolean hasPermission(String name, String permission) {
  try {
    Player player = server.getPlayerExact(name);
    if (player == null) return false;
    try {
      return api.getHandler().has(player, permission);
    } catch (Throwable t) {
      return api.Security.permission(player, permission);
    }
  } catch (Throwable t) {
    log.log(Level.WARNING, "Failed to check permissions", t);
    return false;
  }
}

代码示例来源:origin: EngineHub/WorldEdit

@Override
public boolean hasPermission(String worldName, String name, String permission) {
  try {
    try {
      return api.getHandler().has(worldName, name, permission);
    } catch (Throwable t) {
      return api.getHandler().has(server.getPlayerExact(name), permission);
    }
  } catch (Throwable t) {
    log.log(Level.WARNING, "Failed to check permissions", t);
    return false;
  }
}

代码示例来源:origin: EngineHub/WorldEdit

@Override
@SuppressWarnings("static-access")
public boolean inGroup(String name, String group) {
  try {
    Player player = server.getPlayerExact(name);
    if (player == null) return false;
    try {
      return api.getHandler().inGroup(player.getWorld().getName(), name, group);
    } catch (Throwable t) {
      return api.Security.inGroup(name, group);
    }
  } catch (Throwable t) {
    log.log(Level.WARNING, "Failed to check groups", t);
    return false;
  }
}

代码示例来源:origin: EngineHub/WorldEdit

@Override
@SuppressWarnings("static-access")
public String[] getGroups(String name) {
  try {
    Player player = server.getPlayerExact(name);
    if (player == null) return new String[0];
    String[] groups = null;
    try {
      groups = api.getHandler().getGroups(player.getWorld().getName(), player.getName());
    } catch (Throwable t) {
      String group = api.Security.getGroup(player.getWorld().getName(), player.getName());
      if (group != null) groups = new String[] { group };
    }
    if (groups == null) {
      return new String[0];
    } else {
      return groups;
    }
  } catch (Throwable t) {
    log.log(Level.WARNING, "Failed to get groups", t);
    return new String[0];
  }
}

代码示例来源:origin: webbukkit/dynmap

@Override
public DynmapPlayer getPlayer(String name) {
  Player p = getServer().getPlayerExact(name);
  if(p != null) {
    return new BukkitPlayer(p);
  }
  return null;
}
@Override

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#getPlayerExact(String name)
 */
public static Player getPlayerExact(String name) {
  return server.getPlayerExact(name);
}

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

/**
 * Gets a player by username.
 *
 * @param username the players username
 * @return the player, or null
 */
@Nullable
public static Player getNullable(String username) {
  //noinspection deprecation
  return Helper.server().getPlayerExact(username);
}

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

/**
 * Gets a player by username.
 *
 * @param username the players username
 * @return the player, or null
 */
@Nullable
public static Player getNullable(String username) {
  //noinspection deprecation
  return Helper.server().getPlayerExact(username);
}

代码示例来源:origin: mcMMO-Dev/mcMMO

private Player getPlayerFromFurnace(Block furnaceBlock) {
    List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);

    if (metadata.isEmpty()) {
      return null;
    }

    return plugin.getServer().getPlayerExact(metadata.get(0).asString());
  }
}

代码示例来源:origin: mcMMO-Dev/mcMMO

private Player getPlayerFromFurnace(Block furnaceBlock) {
  List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
  if (metadata.isEmpty()) {
    return null;
  }
  return plugin.getServer().getPlayerExact(metadata.get(0).asString());
}

代码示例来源:origin: aadnk/ProtocolLib

@Override
public Player getPlayer() {
  try {
    // Try to get the real player underneath
    return Bukkit.getServer().getPlayerExact(name);
  } catch (Exception e) {
    return getProxyPlayer();
  }
}

代码示例来源:origin: mcMMO-Dev/mcMMO

private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) {
  Player player = mcMMO.p.getServer().getPlayerExact(playerName);
  if (player == null) {
    if (!offlineValid) {
      mcMMO.p.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + ".");
    }
    return null;
  }
  return getPlayer(player);
}

代码示例来源:origin: mcMMO-Dev/mcMMO

public boolean isBoardShown() {
  Player player = mcMMO.p.getServer().getPlayerExact(playerName);
  if (player == null) {
    ScoreboardManager.cleanup(this);
    return false;
  }
  return player.getScoreboard() == scoreboard;
}

代码示例来源:origin: mcMMO-Dev/mcMMO

public void showBoardWithNoRevert() {
  Player player = mcMMO.p.getServer().getPlayerExact(playerName);
  if (player == null) {
    ScoreboardManager.cleanup(this);
    return;
  }
  if (revertTask != null) {
    revertTask.cancel();
  }
  player.setScoreboard(scoreboard);
  revertTask = null;
}

代码示例来源:origin: mcMMO-Dev/mcMMO

public static void profileCleanup(String playerName) {
  Player player = mcMMO.p.getServer().getPlayerExact(playerName);
  if (player != null) {
    UserManager.remove(player);
    new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
  }
}

代码示例来源:origin: com.greatmancode/tools

@Override
public boolean checkPermission(String playerName, String perm) {
  boolean result;
  Player p = ((BukkitLoader) getCaller().getLoader()).getServer().getPlayerExact(playerName);
  if (p != null) {
    result = p.isOp() || p.hasPermission(perm);
  } else {
    // It's the console
    result = true;
  }
  return result;
}

代码示例来源:origin: com.greatmancode/tools

@Override
public String getPlayerWorld(String playerName) {
  Player p = ((BukkitLoader) getCaller().getLoader()).getServer().getPlayerExact(playerName);
  return p != null ? p.getWorld().getName() : "";
}

代码示例来源:origin: com.greatmancode/tools

@Override
public void sendMessage(String playerName, String message) {
  Player p = ((BukkitLoader) getCaller().getLoader()).getServer().getPlayerExact(playerName);
  if (p != null) {
    p.sendMessage(getCaller().addColor(getCaller().getCommandPrefix() + message));
  } else {
    ((BukkitLoader) getCaller().getLoader()).getServer().getConsoleSender().sendMessage(getCaller().addColor(getCaller().getCommandPrefix() + message));
  }
}

相关文章

Server类方法