/** * Creates a {@link GameProfile} from the provided ID and name. * * @param uniqueId The unique id * @param name The name * @return The created profile */ static GameProfile of(UUID uniqueId, @Nullable String name) { return Sponge.getServer().getGameProfileManager().createProfile(uniqueId, name); }
/** * Creates a new signed property. * * <p>Depending on the property name, if the signature is provided it must * originate from Mojang.</p> * * @param name The name for the property * @param value The value of the property * @param signature The signature of the property * @return The new property */ static ProfileProperty of(String name, String value, @Nullable String signature) { return Sponge.getServer().getGameProfileManager().createProfileProperty(name, value, signature); }
public GameProfileManager getResolver() { if (this.resolver == null) { this.resolver = this.game.getServer().getGameProfileManager(); } return this.resolver; }
/** * Creates a {@link GameProfile} from the provided ID and name. * * @param uniqueId The unique ID * @param name The name * @return The created profile */ static GameProfile of(UUID uniqueId, @Nullable String name) { return Sponge.getServer().getGameProfileManager().createProfile(uniqueId, name); }
/** * Creates a new signed property. * * <p>Depending on the property name, if the signature is provided it must * originate from Mojang.</p> * * @param name The name for the property * @param value The value of the property * @param signature The signature of the property */ static ProfileProperty of(String name, String value, @Nullable String signature) { return Sponge.getServer().getGameProfileManager().createProfileProperty(name, value, signature); }
@Override public Optional<CompletableFuture<?>> process(QuerySession session, String parameter, String value, Query query) { CompletableFuture<GameProfile> future = Sponge.getServer().getGameProfileManager().get(value, true); future.thenAccept(profile -> query.addCondition(FieldCondition.of(DataQueries.Player, MatchRule.EQUALS, profile.getUniqueId().toString()))); return Optional.of(future); } }
/** * Helper method to translate Player UUIDs to names. * * @param results List of results * @param uuidsPendingLookup Lists of UUIDs pending lookup * @return CompletableFuture */ public static CompletableFuture<List<Result>> translateUuidsToNames(List<Result> results, List<UUID> uuidsPendingLookup) { CompletableFuture<List<Result>> future = new CompletableFuture<>(); CompletableFuture<Collection<GameProfile>> futures = Sponge.getServer().getGameProfileManager().getAllById(uuidsPendingLookup, true); futures.thenAccept((profiles) -> { for (GameProfile profile : profiles) { for (Result r : results) { Optional<Object> cause = r.data.get(DataQueries.Cause); if (cause.isPresent() && cause.get().equals(profile.getUniqueId().toString())) { r.data.set(DataQueries.Cause, profile.getName().orElse("unknown")); } } } future.complete(results); }); return future; } }
@Override public Optional<String> getAliasForName(String input) { try { UUID.fromString(input); } catch (IllegalArgumentException ex) { Optional<Player> player = plugin.getGame().getServer().getPlayer(input); if (player.isPresent()) { return Optional.of(player.get().getUniqueId().toString()); } else { GameProfileCache res = plugin.getGame().getServer().getGameProfileManager().getCache(); for (GameProfile profile : res.match(input)) { if (profile.getName().isPresent() && profile.getName().get().equalsIgnoreCase(input)) { return Optional.of(profile.getUniqueId().toString()); } } } } return Optional.empty(); }
@Override public void applyProperties(GameProfile profile, SkinModel targetSkin) { //remove existing skins profile.getPropertyMap().clear(); if (targetSkin != null) { GameProfileManager profileManager = Sponge.getServer().getGameProfileManager(); ProfileProperty profileProperty = profileManager.createProfileProperty(SkinProperty.SKIN_KEY , targetSkin.getEncodedValue(), targetSkin.getSignature()); profile.getPropertyMap().put(SkinProperty.SKIN_KEY, profileProperty); } }
CompletableFuture<Collection<GameProfile>> future = Sponge.getServer().getGameProfileManager().getAllByName(usernames, true); future.whenComplete((result, throwable) -> { if (throwable != null) {
public boolean cache(Runnable whenDone) { for (GameProfile profile : SpongeMain.THIS.getServer().getGameProfileManager().getCache().getProfiles()) { String name = profile.getName().orElse(null); if (name != null) { add(new StringWrapper(name), profile.getUniqueId()); } } return true; }