Search in sources :

Example 1 with SkinUpdateMessage

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

the class BungeeSkinAPI method applySkin.

@Override
public void applySkin(ProxiedPlayer player, SkinModel targetSkin) {
    plugin.getLog().debug("Applying skin for {}", player.getName());
    InitialHandler initialHandler = (InitialHandler) player.getPendingConnection();
    LoginResult loginProfile = initialHandler.getLoginProfile();
    // this is null in offline mode
    if (loginProfile == null) {
        String mojangUUID = UUIDTypeAdapter.toMojangId(player.getUniqueId());
        if (profileSetter != null) {
            try {
                LoginResult loginResult = new LoginResult(mojangUUID, player.getName(), toProperties(targetSkin));
                profileSetter.invokeExact(initialHandler, loginResult);
            } catch (Error error) {
                // rethrow errors we shouldn't silence them like OutOfMemoryError
                throw error;
            } catch (Throwable throwable) {
                plugin.getLog().error("Error applying skin: {} for {}", targetSkin, player, throwable);
            }
        }
    } else {
        applyProperties(loginProfile, targetSkin);
    }
    // send plugin channel update request
    plugin.sendPluginMessage(player.getServer(), new SkinUpdateMessage(player.getName()));
}
Also used : SkinUpdateMessage(com.github.games647.changeskin.core.message.SkinUpdateMessage) LoginResult(net.md_5.bungee.connection.LoginResult) InitialHandler(net.md_5.bungee.connection.InitialHandler)

Example 2 with SkinUpdateMessage

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

the class SharedBungeeListener method updateSkin.

private void updateSkin(ByteArrayDataInput dataInput) throws IllegalArgumentException {
    SkinUpdateMessage message = new SkinUpdateMessage();
    message.readFrom(dataInput);
    String playerName = message.getPlayerName();
    P receiver = getPlayerExact(playerName);
    plugin.getLog().info("Instant update for {}", playerName);
    runUpdater(receiver);
}
Also used : SkinUpdateMessage(com.github.games647.changeskin.core.message.SkinUpdateMessage)

Aggregations

SkinUpdateMessage (com.github.games647.changeskin.core.message.SkinUpdateMessage)2 InitialHandler (net.md_5.bungee.connection.InitialHandler)1 LoginResult (net.md_5.bungee.connection.LoginResult)1