use of com.github.games647.changeskin.core.model.UserPreference 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.UserPreference in project ChangeSkin by games647.
the class SkinApplier method run.
@Override
public void run() {
if (!isConnected()) {
return;
}
// uuid was successful resolved, we could now make a cooldown check
if (invoker instanceof Player && core != null) {
UUID uniqueId = ((Player) invoker).getUniqueId();
core.getCooldownService().trackPlayer(uniqueId);
}
if (plugin.getStorage() != null) {
UserPreference preferences = plugin.getStorage().getPreferences(receiver.getUniqueId());
save(preferences);
}
applySkin();
}
Aggregations