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 };
}
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();
}
});
}
Aggregations