Search in sources :

Example 1 with Property

use of net.md_5.bungee.connection.LoginResult.Property in project ChangeSkin by games647.

the class BungeeSkinAPI method toProperties.

private Property[] toProperties(SkinModel targetSkin) {
    if (targetSkin == null) {
        return emptyProperties;
    }
    String encodedValue = targetSkin.getEncodedValue();
    String signature = targetSkin.getSignature();
    Property prop = new Property(SkinProperty.SKIN_KEY, encodedValue, signature);
    return new Property[] { prop };
}
Also used : SkinProperty(com.github.games647.changeskin.core.model.skin.SkinProperty) Property(net.md_5.bungee.connection.LoginResult.Property)

Example 2 with Property

use of net.md_5.bungee.connection.LoginResult.Property in project SkinsRestorerX by DoNotSpamPls.

the class SkinApplier method applySkin.

public static void applySkin(final ProxiedPlayer p) {
    ProxyServer.getInstance().getScheduler().runAsync(SkinsRestorer.getInstance(), () -> {
        try {
            Property textures = (Property) SkinStorage.getOrCreateSkinForPlayer(p.getName());
            InitialHandler handler = (InitialHandler) p.getPendingConnection();
            if (handler.isOnlineMode()) {
                sendUpdateRequest(p, textures);
                return;
            }
            LoginResult profile;
            try {
                // NEW BUNGEECORD
                profile = (net.md_5.bungee.connection.LoginResult) ReflectionUtil.invokeConstructor(LoginResult, new Class<?>[] { String.class, String.class, Property[].class }, p.getUniqueId().toString(), p.getName(), new Property[] { textures });
            } catch (Exception e) {
                // FALL BACK TO OLD
                profile = (net.md_5.bungee.connection.LoginResult) ReflectionUtil.invokeConstructor(LoginResult, new Class<?>[] { String.class, Property[].class }, p.getUniqueId().toString(), new Property[] { textures });
            }
            Property[] present = profile.getProperties();
            Property[] newprops = new Property[present.length + 1];
            System.arraycopy(present, 0, newprops, 0, present.length);
            newprops[present.length] = textures;
            profile.getProperties()[0].setName(newprops[0].getName());
            profile.getProperties()[0].setValue(newprops[0].getValue());
            profile.getProperties()[0].setSignature(newprops[0].getSignature());
            ReflectionUtil.setObject(InitialHandler.class, handler, "loginProfile", profile);
            if (SkinsRestorer.getInstance().isMultiBungee())
                sendUpdateRequest(p, textures);
            else
                sendUpdateRequest(p, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    });
}
Also used : LoginResult(net.md_5.bungee.connection.LoginResult) Property(net.md_5.bungee.connection.LoginResult.Property) IOException(java.io.IOException) InitialHandler(net.md_5.bungee.connection.InitialHandler)

Aggregations

Property (net.md_5.bungee.connection.LoginResult.Property)2 SkinProperty (com.github.games647.changeskin.core.model.skin.SkinProperty)1 IOException (java.io.IOException)1 InitialHandler (net.md_5.bungee.connection.InitialHandler)1 LoginResult (net.md_5.bungee.connection.LoginResult)1