use of org.spongepowered.api.profile.GameProfile in project SpongeCommon by SpongePowered.
the class SkullUtils method setProfile.
public static boolean setProfile(TileEntitySkull tileEntitySkull, @Nullable GameProfile profile) {
if (getSkullType(tileEntitySkull).equals(SkullTypes.PLAYER)) {
final GameProfile newProfile = SpongeRepresentedPlayerData.NULL_PROFILE.equals(profile) ? null : resolveProfileIfNecessary(profile);
tileEntitySkull.setPlayerProfile((com.mojang.authlib.GameProfile) newProfile);
tileEntitySkull.markDirty();
tileEntitySkull.getWorld().notifyBlockUpdate(tileEntitySkull.getPos(), tileEntitySkull.getWorld().getBlockState(tileEntitySkull.getPos()), tileEntitySkull.getWorld().getBlockState(tileEntitySkull.getPos()), 3);
return true;
}
return false;
}
use of org.spongepowered.api.profile.GameProfile in project SpongeCommon by SpongePowered.
the class SpongeBanService method isBanned.
@Override
public boolean isBanned(GameProfile profile) {
UserListBans bans = this.getUserBanList();
bans.removeExpired();
return bans.values.containsKey(bans.getObjectKey((com.mojang.authlib.GameProfile) profile));
}
use of org.spongepowered.api.profile.GameProfile in project SpongeCommon by SpongePowered.
the class SpongeWhitelistService method isWhitelisted.
@Override
public boolean isWhitelisted(GameProfile profile) {
UserListWhitelist whitelist = getWhitelist();
whitelist.removeExpired();
return whitelist.getValues().containsKey(whitelist.getObjectKey((com.mojang.authlib.GameProfile) profile));
}
use of org.spongepowered.api.profile.GameProfile in project SpongeCommon by SpongePowered.
the class MixinChunk_Tracker method getUserFromId.
private Optional<User> getUserFromId(UUID uuid) {
// check username cache
String username = SpongeUsernameCache.getLastKnownUsername(uuid);
if (username != null) {
return this.userStorageService.get(GameProfile.of(uuid, username));
}
// check mojang cache
GameProfile profile = this.spongeProfileManager.getCache().getById(uuid).orElse(null);
if (profile != null) {
return this.userStorageService.get(profile);
}
// If we reach this point, queue UUID for async lookup and return empty
this.spongeProfileManager.lookupUserAsync(uuid);
return Optional.empty();
}
use of org.spongepowered.api.profile.GameProfile in project SpongeCommon by SpongePowered.
the class Query method fillProfile.
protected GameProfile fillProfile(GameProfile profile, boolean signed) throws ProfileNotFoundException {
if (this.useCache) {
Optional<GameProfile> result = this.cache.getById(profile.getUniqueId());
if (result.isPresent() && result.get().isFilled() && !result.get().getPropertyMap().isEmpty()) {
return result.get();
}
}
Optional<GameProfile> result = this.cache.fillProfile(profile, signed);
if (result.isPresent() && result.get().isFilled()) {
GameProfile filled = result.get();
this.cache.add(filled, true, (Instant) null);
return filled;
}
throw new ProfileNotFoundException("Profile: " + profile);
}
Aggregations