Search in sources :

Example 1 with SkinStorage

use of com.github.games647.changeskin.core.SkinStorage in project ChangeSkin by games647.

the class LoginListener method onPlayerPreLogin.

@Listener
public void onPlayerPreLogin(ClientConnectionEvent.Auth preLoginEvent) {
    SkinStorage storage = core.getStorage();
    GameProfile profile = preLoginEvent.getProfile();
    UUID playerUUID = profile.getUniqueId();
    UserPreference preferences = storage.getPreferences(playerUUID);
    Optional<SkinModel> optSkin = preferences.getTargetSkin();
    if (optSkin.isPresent()) {
        SkinModel targetSkin = optSkin.get();
        if (!preferences.isKeepSkin()) {
            targetSkin = core.checkAutoUpdate(targetSkin);
        }
        plugin.getApi().applyProperties(profile, targetSkin);
        save(preferences);
    } else {
        String playerName = profile.getName().get();
        if (!core.getConfig().getBoolean("restoreSkins") || !refetchSkin(playerName, preferences)) {
            setDefaultSkin(preferences, profile);
        }
    }
}
Also used : GameProfile(org.spongepowered.api.profile.GameProfile) UserPreference(com.github.games647.changeskin.core.model.UserPreference) UUID(java.util.UUID) SkinStorage(com.github.games647.changeskin.core.SkinStorage) SkinModel(com.github.games647.changeskin.core.model.skin.SkinModel) Listener(org.spongepowered.api.event.Listener) SharedListener(com.github.games647.changeskin.core.shared.SharedListener)

Aggregations

SkinStorage (com.github.games647.changeskin.core.SkinStorage)1 UserPreference (com.github.games647.changeskin.core.model.UserPreference)1 SkinModel (com.github.games647.changeskin.core.model.skin.SkinModel)1 SharedListener (com.github.games647.changeskin.core.shared.SharedListener)1 UUID (java.util.UUID)1 Listener (org.spongepowered.api.event.Listener)1 GameProfile (org.spongepowered.api.profile.GameProfile)1