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);
}
}
}
Aggregations