Search in sources :

Example 21 with GameProfile

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;
}
Also used : GameProfile(org.spongepowered.api.profile.GameProfile)

Example 22 with GameProfile

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));
}
Also used : GameProfile(org.spongepowered.api.profile.GameProfile) UserListBans(net.minecraft.server.management.UserListBans)

Example 23 with GameProfile

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));
}
Also used : GameProfile(org.spongepowered.api.profile.GameProfile) UserListWhitelist(net.minecraft.server.management.UserListWhitelist)

Example 24 with GameProfile

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();
}
Also used : GameProfile(org.spongepowered.api.profile.GameProfile)

Example 25 with GameProfile

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);
}
Also used : GameProfile(org.spongepowered.api.profile.GameProfile) ProfileNotFoundException(org.spongepowered.api.profile.ProfileNotFoundException)

Aggregations

GameProfile (org.spongepowered.api.profile.GameProfile)44 Optional (java.util.Optional)12 UUID (java.util.UUID)12 Text (org.spongepowered.api.text.Text)9 User (org.spongepowered.api.entity.living.player.User)8 IOException (java.io.IOException)7 List (java.util.List)6 Sponge (org.spongepowered.api.Sponge)6 Cause (org.spongepowered.api.event.cause.Cause)6 World (org.spongepowered.api.world.World)6 Vector3d (com.flowpowered.math.vector.Vector3d)5 Collectors (java.util.stream.Collectors)5 Keys (org.spongepowered.api.data.key.Keys)5 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)4 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)4 ImmutableList (com.google.common.collect.ImmutableList)4 Lists (com.google.common.collect.Lists)4 Collection (java.util.Collection)4 Iterator (java.util.Iterator)4 Set (java.util.Set)4