Java Code Examples for com.destroystokyo.paper.profile.PlayerProfile#getName()
The following examples show how to use
com.destroystokyo.paper.profile.PlayerProfile#getName() .
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: StandardPaperServerListPingEventImpl.java From Kettle with GNU General Public License v3.0 | 6 votes |
private GameProfile[] getPlayerSampleHandle() { if (this.originalSample != null) { return this.originalSample; } List<PlayerProfile> entries = super.getPlayerSample(); if (entries.isEmpty()) { return EMPTY_PROFILES; } GameProfile[] profiles = new GameProfile[entries.size()]; for (int i = 0; i < profiles.length; i++) { /* * Avoid null UUIDs/names since that will make the response invalid * on the client. * Instead, fall back to a fake/empty UUID and an empty string as name. * This can be used to create custom lines in the player list that do not * refer to a specific player. */ PlayerProfile profile = entries.get(i); if (profile.getId() != null && profile.getName() != null) { profiles[i] = CraftPlayerProfile.asAuthlib(profile); } else { profiles[i] = new GameProfile(MoreObjects.firstNonNull(profile.getId(), FAKE_UUID), Strings.nullToEmpty(profile.getName())); } } return profiles; }
Example 2
Source File: PaperPlayerInfo.java From AntiVPN with MIT License | 6 votes |
private static String nameExpensive(UUID uuid) throws IOException { // Currently-online lookup Player player = Bukkit.getPlayer(uuid); if (player != null) { nameCache.put(player.getName(), uuid); return player.getName(); } // Cached profile lookup PlayerProfile profile = Bukkit.createProfile(uuid); if ((profile.isComplete() || profile.completeFromCache()) && profile.getName() != null && profile.getId() != null) { nameCache.put(profile.getName(), profile.getId()); return profile.getName(); } // Network lookup if (profile.complete(false) && profile.getName() != null && profile.getId() != null) { nameCache.put(profile.getName(), profile.getId()); return profile.getName(); } // Sorry, nada throw new IOException("Could not load player data from Mojang (rate-limited?)"); }
Example 3
Source File: PaperPlayerInfo.java From AntiVPN with MIT License | 6 votes |
private static UUID uuidExpensive(String name) throws IOException { // Currently-online lookup Player player = Bukkit.getPlayer(name); if (player != null) { uuidCache.put(player.getUniqueId(), name); return player.getUniqueId(); } // Cached profile lookup PlayerProfile profile = Bukkit.createProfile(name); if ((profile.isComplete() || profile.completeFromCache()) && profile.getName() != null && profile.getId() != null) { uuidCache.put(profile.getId(), profile.getName()); return profile.getId(); } // Network lookup if (profile.complete(false) && profile.getName() != null && profile.getId() != null) { uuidCache.put(profile.getId(), profile.getName()); return profile.getId(); } // Sorry, nada throw new IOException("Could not load player data from Mojang (rate-limited?)"); }
Example 4
Source File: TextureCache.java From VoxelGamesLibv2 with MIT License | 6 votes |
private PlayerProfile checkForPrefix(PlayerProfile playerProfile) { if (playerProfile.getName() != null) { if (playerProfile.getName().contains(":")) { String[] args = playerProfile.getName().split(":"); Optional<Skin> skin = textureHandler.getSkin(args[1].charAt(0)); if (skin.isPresent()) { log.finer("Found prefix marker, return " + skin.get().name); return textureHandler.getPlayerProfile(skin.get()); } else { log.warning("Requested prefix marker, but is missing skin! " + playerProfile.getName()); return textureHandler.getErrorProfile(); } } } return null; }
Example 5
Source File: TextureCache.java From VoxelGamesLibv2 with MIT License | 5 votes |
private boolean checkForPlaceholders(PlayerProfile playerProfile) { if (playerProfile.getName() != null) { for (Map.Entry<String, SkullPlaceHolder> entry : skullPlaceHolders.getPlaceHolders().entrySet()) { if (playerProfile.getName().startsWith(entry.getKey())) { PlayerProfile errorProfile = textureHandler.getErrorProfile(); playerProfile.setProperties(errorProfile.getProperties()); log.finer("Found placeholder trying to be filled, fill with error profile for now"); return true; } } } return false; }