Search in sources :

Example 26 with SkinModel

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);
    }
}
Also used : UserPreference(com.github.games647.changeskin.core.model.UserPreference) UUID(java.util.UUID) SkinModel(com.github.games647.changeskin.core.model.skin.SkinModel) EventHandler(org.bukkit.event.EventHandler)

Example 27 with SkinModel

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);
}
Also used : SkinModel(com.github.games647.changeskin.core.model.skin.SkinModel)

Aggregations

SkinModel (com.github.games647.changeskin.core.model.skin.SkinModel)21 UUID (java.util.UUID)9 UserPreference (com.github.games647.changeskin.core.model.UserPreference)8 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)3 SkinProperty (com.github.games647.changeskin.core.model.skin.SkinProperty)2 TextureModel (com.github.games647.changeskin.core.model.skin.TextureModel)2 TextureType (com.github.games647.changeskin.core.model.skin.TextureType)2 ChangeSkinBungee (com.github.games647.changeskin.bungee.ChangeSkinBungee)1 ChangeSkinCore (com.github.games647.changeskin.core.ChangeSkinCore)1 NotPremiumException (com.github.games647.changeskin.core.NotPremiumException)1 RateLimitException (com.github.games647.changeskin.core.RateLimitException)1 SkinStorage (com.github.games647.changeskin.core.SkinStorage)1 CheckPermMessage (com.github.games647.changeskin.core.message.CheckPermMessage)1 PermResultMessage (com.github.games647.changeskin.core.message.PermResultMessage)1 SkinUpdateMessage (com.github.games647.changeskin.core.message.SkinUpdateMessage)1 GameProfile (com.github.games647.changeskin.core.model.GameProfile)1