Search in sources :

Example 1 with WhitelistConfig

use of org.lanternpowered.server.config.user.WhitelistConfig in project LanternServer by LanternPowered.

the class LanternUserStorageService method getFromWhitelistService.

/**
 * Attempts to get a {@link User} from the {@link WhitelistService}.
 *
 * @param uniqueId The unique id
 * @return The user
 */
@Nullable
private ProxyUser getFromWhitelistService(UUID uniqueId) {
    final LanternGameProfile gameProfile;
    final WhitelistService whitelistService = this.whitelistService.get();
    if (whitelistService instanceof WhitelistConfig) {
        gameProfile = ((WhitelistConfig) whitelistService).getEntryByUUID(uniqueId).map(UserEntry::getProfile).orElse(null);
    } else {
        gameProfile = (LanternGameProfile) whitelistService.getWhitelistedProfiles().stream().filter(profile -> profile.getUniqueId().equals(uniqueId)).findFirst().orElse(null);
    }
    return gameProfile == null ? null : new ProxyUser(gameProfile);
}
Also used : WhitelistService(org.spongepowered.api.service.whitelist.WhitelistService) WhitelistConfig(org.lanternpowered.server.config.user.WhitelistConfig) LanternGameProfile(org.lanternpowered.server.profile.LanternGameProfile) UserEntry(org.lanternpowered.server.config.user.UserEntry) ProxyUser(org.lanternpowered.server.entity.living.player.ProxyUser) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)1 UserEntry (org.lanternpowered.server.config.user.UserEntry)1 WhitelistConfig (org.lanternpowered.server.config.user.WhitelistConfig)1 ProxyUser (org.lanternpowered.server.entity.living.player.ProxyUser)1 LanternGameProfile (org.lanternpowered.server.profile.LanternGameProfile)1 WhitelistService (org.spongepowered.api.service.whitelist.WhitelistService)1