本文整理汇总了Java中org.bukkit.entity.Player.getDisplayName方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getDisplayName方法的具体用法?Java Player.getDisplayName怎么用?Java Player.getDisplayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.getDisplayName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void run() {
for (Player player : this.plugin.getServer().getOnlinePlayers()) {
String currentName;
if (plugin.getConfig().getBoolean("tablist.show-real-name")) {
currentName = player.getName();
} else {
currentName = player.getDisplayName();
}
String prefix = plugin.getConfig().getString("tablist.prefix");
if (!prefix.equals("")) {
player.setPlayerListName(ChatColor.translateAlternateColorCodes('&',
prefix.replace("%ping%", "" + PingUtil.getPing(player))) + " " + currentName);
}
String suffix = plugin.getConfig().getString("tablist.suffix");
if (!suffix.equals("")) {
player.setPlayerListName(currentName + " " + ChatColor.translateAlternateColorCodes('&',
suffix.replace("%ping%", "" + PingUtil.getPing(player))));
}
}
}
示例2: sendSpectatorMessage
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void sendSpectatorMessage(Player player, String message) {
GamePlayer sender = SkyWarsReloaded.getPC().getPlayer(player.getUniqueId());
int score = sender.getScore();
String sValue;
if (score < 0) {
sValue = ChatColor.RED + "(-" + score + ")";
} else {
sValue = ChatColor.GREEN + "(+" + score + ")";
}
String name = player.getDisplayName();
for (GamePlayer gPlayer: getSpectators()) {
if (gPlayer.getP() != null) {
gPlayer.getP().sendMessage(new Messaging.MessageFormatter()
.setVariable("score", sValue)
.setVariable("player", name)
.setVariable("message", message)
.format("spectatorchat"));
}
}
}
示例3: getDisplayName
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static String getDisplayName(@Nullable PlayerId target, CommandSender viewer) {
if(target == null) {
return CONSOLE_DISPLAY_NAME;
} else {
Player targetPlayer = Bukkit.getPlayerExact(target.username(), viewer);
if(targetPlayer == null) {
return ChatColor.DARK_AQUA + target.username();
} else {
return targetPlayer.getDisplayName(viewer);
}
}
}
示例4: onCommand
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String list = "";
for (Player p : Utils.getPlayers()) {
list += "&f" + p.getDisplayName() + "&f, ";
}
list = list.substring(0, list.length() - 2);
Chat.simple(sender, "&6Currently &c" + Utils.getPlayers().length + "/" + Bukkit.getMaxPlayers() + " &6players online:");
Chat.simple(sender, "&6Player List: " + list);
return true;
}
示例5: onCommand
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Chat.player(sender, "&6Currently &c" + Bukkit.getOnlinePlayers().length + "/" + Bukkit.getMaxPlayers() + " &6players online:");
String players = "";
for (Player p : Bukkit.getOnlinePlayers()) {
Gamer g = Gamer.get(p);
players += g.getPrefix() + "&7" + p.getDisplayName() + "&f, ";
}
if (players.length() > 4)
players = players.substring(0, players.length() - 4);
Chat.player(sender, "&6Player List: " + players);
return true;
}
示例6: executeCommandsSync
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Execute la liste des commandes immédiatement. A faire uniquement en synchrone !
* @param name Le pseudo du joueur
*/
public void executeCommandsSync(final String name) {
@SuppressWarnings("deprecation")
final Player player = this.plugin.getServer().getPlayerExact(name);
if (player == null) {
this.plugin.debug( name + " not found.");
return;
}
if (player.hasPermission(BukkitSayNoToMcLeaks.PERMISSION_BYPASS)) {
this.plugin.debug("The player " + name + " is an alt account but he has bypass permission.");
return;
}
final String uuid = player.getUniqueId().toString();
final String displayname = player.getDisplayName();
final String ip = player.getAddress().getAddress().getHostAddress();
for (String command : this.commands) {
this.plugin.getServer().dispatchCommand(this.plugin.getServer().getConsoleSender(), command
.replaceAll("<player>", name)
.replaceAll("<uuid>", uuid)
.replaceAll("<displayname>", displayname)
.replaceAll("<ip>", ip));
}
this.plugin.debug("The player " + name + " is an alt account.");
}
示例7: KvantumPlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Construct a Kvantum player from a Bukkit player
*
* @param bukkitPlayer Bukkit player
*/
public KvantumPlayer(@NonNull final Player bukkitPlayer)
{
this.username = bukkitPlayer.getDisplayName();
this.uuid = bukkitPlayer.getUniqueId().toString();
this.world = bukkitPlayer.getWorld().getName();
this.complete = true;
this.online = true;
}
示例8: onShear
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onShear(PlayerShearEntityEvent event) {
Entity entity = event.getEntity();
String username = webPlayerBridge.entityId2Username.get(entity.getEntityId());
if (username == null) {
return;
}
Player player = event.getPlayer();
String playerName = player.getDisplayName();
webPlayerBridge.notifySheared(username, playerName);
}
示例9: resolve
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public String resolve(Player player, String id) {
return player.getDisplayName();
}
示例10: formatStaffChatMessage
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static String formatStaffChatMessage(Player from, String message) {
return ChatColor.RED + "" + ChatColor.BOLD + "[STAFF] " + ChatColor.BOLD + from.getDisplayName() + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " >> " + ChatColor.WHITE + message;
}
示例11: formatStaffChatReply
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static String formatStaffChatReply(Player from, Player to, String message) {
return ChatColor.RED + "" + ChatColor.BOLD + "[STAFF] " + ChatColor.BOLD + from.getDisplayName() + ChatColor.GRAY + " -> " + ChatColor.BOLD + to.getDisplayName() + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " >> " + ChatColor.WHITE + message;
}
示例12: formatAdminChatMessage
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static String formatAdminChatMessage(Player from, String message) {
return ChatColor.DARK_RED + "" + ChatColor.BOLD + "[ADMIN] " + ChatColor.BOLD + from.getDisplayName() + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " >> " + ChatColor.WHITE + message;
}
示例13: formatAdminChatReply
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static String formatAdminChatReply(Player from, Player to, String message) {
return ChatColor.DARK_RED + "" + ChatColor.BOLD + "[ADMIN] " + ChatColor.BOLD + from.getDisplayName() + ChatColor.GRAY + " -> " + ChatColor.BOLD + to.getDisplayName() + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " >> " + ChatColor.WHITE + message;
}
示例14: sendMessageToViewer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void sendMessageToViewer(Player sender, CommandSender viewer, String sanitizedMessage, ChannelMessageEvent event, boolean offensive, int violationsAttached, PlayerViolationManager violationManager, boolean forceNoSend) {
boolean senderPresent = sender != null;
String senderName = senderPresent ? sender.getName(viewer) : "Console";
String senderDisplayName = senderPresent ? sender.getDisplayName(viewer) : ChatColor.GOLD + "*" + ChatColor.AQUA + "Console";
String message = MessageFormat.format(
this.getFormat(),
senderName,
senderDisplayName,
event.getMessage(),
sanitizedMessage
);
boolean allowSend = true;
if (viewer instanceof Player) {
switch (PlayerSettings.getManager((Player) viewer).getValue(Settings.FILTER_SETTING, FilterOptions.class)) {
case NONE:
allowSend = true;
break;
case OFFENSIVE:
allowSend = !offensive;
break;
case ALL:
allowSend = violationsAttached == 0;
break;
}
}
boolean isSender = viewer.equals(event.getSender());
StringBuilder builder = new StringBuilder();
if (isSender) {
if (offensive || violationsAttached != 0) {
if (violationManager.getScore() * this.partial < this.scoreThreshold) {
builder.append(ChatColor.GOLD);
} else {
builder.append(ChatColor.RED);
}
builder.append(ChatColor.BOLD).append(WARNING_SYMBOL).append(ChatColor.RESET);
}
builder.append(this.underlineViolations(violationManager, message, event));
viewer.sendMessage(builder.toString());
} else if (allowSend && !forceNoSend) {
this.sendMessageToViewer(sender, viewer, sanitizedMessage, event);
}
}