use of com.github.games647.changeskin.core.model.skin.SkinModel in project ChangeSkin by games647.
the class LoginListener method onPreLogin.
// we are making an blocking request it might be better to ignore it if normal priority events cancelled it
@EventHandler(priority = EventPriority.HIGHEST)
public void onPreLogin(AsyncPlayerPreLoginEvent preLoginEvent) {
if (preLoginEvent.getLoginResult() != Result.ALLOWED) {
// in this event isCancelled option in the annotation doesn't work
return;
}
UUID playerUuid = preLoginEvent.getUniqueId();
String playerName = preLoginEvent.getName();
UserPreference preferences = core.getStorage().getPreferences(playerUuid);
if (preferences == null) {
return;
}
plugin.startSession(playerUuid, preferences);
Optional<SkinModel> optSkin = preferences.getTargetSkin();
if (optSkin.isPresent()) {
SkinModel targetSkin = optSkin.get();
if (!preferences.isKeepSkin()) {
targetSkin = core.checkAutoUpdate(targetSkin);
}
preferences.setTargetSkin(targetSkin);
save(preferences);
} else if (core.getConfig().getBoolean("restoreSkins")) {
refetchSkin(playerName, preferences);
}
if (!preferences.getTargetSkin().isPresent()) {
getRandomSkin().ifPresent(preferences::setTargetSkin);
}
}
use of com.github.games647.changeskin.core.model.skin.SkinModel in project ChangeSkin by games647.
the class BungeeSkinAPI method setPersistentSkin.
@Override
public void setPersistentSkin(ProxiedPlayer player, UUID targetSkinId, boolean applyNow) {
SkinModel newSkin = plugin.getStorage().getSkin(targetSkinId);
if (newSkin == null) {
Optional<SkinModel> downloadSkin = plugin.getCore().getSkinApi().downloadSkin(targetSkinId);
if (downloadSkin.isPresent()) {
newSkin = downloadSkin.get();
}
}
setPersistentSkin(player, newSkin, applyNow);
}
Aggregations