Java Code Examples for cn.nukkit.Player#getDisplayName()
The following examples show how to use
cn.nukkit.Player#getDisplayName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListCommand.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } String online = ""; int onlineCount = 0; for (Player player : sender.getServer().getOnlinePlayers().values()) { if (player.isOnline() && (!(sender instanceof Player) || ((Player) sender).canSee(player))) { online += player.getDisplayName() + ", "; ++onlineCount; } } if (online.length() > 0) { online = online.substring(0, online.length() - 2); } sender.sendMessage(new TranslationContainer("commands.players.list", String.valueOf(onlineCount), String.valueOf(sender.getServer().getMaxPlayers()))); sender.sendMessage(online); return true; }
Example 2
Source File: ListCommand.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } String online = ""; int onlineCount = 0; for (Player player : sender.getServer().getOnlinePlayers().values()) { if (player.isOnline() && (!(sender instanceof Player) || ((Player) sender).canSee(player))) { online += player.getDisplayName() + ", "; ++onlineCount; } } if (online.length() > 0) { online = online.substring(0, online.length() - 2); } sender.sendMessage(new TranslationContainer("commands.players.list", new String[]{String.valueOf(onlineCount), String.valueOf(sender.getServer().getMaxPlayers())})); sender.sendMessage(online); return true; }
Example 3
Source File: ChatListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private void actOnChatEvent(PlayerChatEvent event) { long time = System.currentTimeMillis(); Player player = event.getPlayer(); UUID uuid = player.getUniqueId(); String displayName = player.getDisplayName(); dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction( uuid, new Nickname(displayName, time, serverInfo.getServerUUID()), (playerUUID, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false) )); }
Example 4
Source File: PlayerOnlineListener.java From Plan with GNU Lesser General Public License v3.0 | 4 votes |
private void actOnJoinEvent(PlayerJoinEvent event) { Player player = event.getPlayer(); UUID playerUUID = player.getUniqueId(); UUID serverUUID = serverInfo.getServerUUID(); long time = System.currentTimeMillis(); JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); NukkitAFKListener.AFK_TRACKER.performedAction(playerUUID, time); String world = player.getLevel().getName(); String gm = GMTimes.magicNumberToGMName(player.getGamemode()); Database database = dbSystem.getDatabase(); database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world)); String address = player.getAddress(); String playerName = player.getName(); String displayName = player.getDisplayName(); boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS); if (gatheringGeolocations) { database.executeTransaction( new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry) ); } long registerDate = TimeUnit.SECONDS.toMillis(player.getFirstPlayed()); database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> registerDate, playerName, serverUUID)); Session session = new Session(playerUUID, serverUUID, time, world, gm); session.putRawData(SessionKeys.NAME, playerName); session.putRawData(SessionKeys.SERVER_NAME, serverInfo.getServer().getIdentifiableName()); sessionCache.cacheSession(playerUUID, session) .ifPresent(previousSession -> database.executeTransaction(new SessionEndTransaction(previousSession))); database.executeTransaction(new NicknameStoreTransaction( playerUUID, new Nickname(displayName, time, serverUUID), (uuid, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false) )); processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN)); if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName)); } }