Search in sources :

Example 1 with MapProfileLookupCallback

use of org.spongepowered.common.profile.callback.MapProfileLookupCallback in project SpongeCommon by SpongePowered.

the class MixinPlayerProfileCache method lookupByNames.

@Override
public Map<String, Optional<GameProfile>> lookupByNames(Iterable<String> names) {
    checkNotNull(names, "names");
    Map<String, Optional<GameProfile>> result = Maps.newHashMap();
    SpongeImpl.getServer().getGameProfileRepository().findProfilesByNames(Iterables.toArray(names, String.class), Agent.MINECRAFT, new MapProfileLookupCallback(result));
    if (!result.isEmpty()) {
        for (Optional<GameProfile> entry : result.values()) {
            if (entry.isPresent()) {
                this.addEntry((com.mojang.authlib.GameProfile) entry.get(), null);
            }
        }
        return ImmutableMap.copyOf(result);
    }
    return ImmutableMap.of();
}
Also used : Optional(java.util.Optional) GameProfile(org.spongepowered.api.profile.GameProfile) MapProfileLookupCallback(org.spongepowered.common.profile.callback.MapProfileLookupCallback)

Aggregations

Optional (java.util.Optional)1 GameProfile (org.spongepowered.api.profile.GameProfile)1 MapProfileLookupCallback (org.spongepowered.common.profile.callback.MapProfileLookupCallback)1