Solved Get value/signature of skin from file

Discussion in 'Spigot Plugin Development' started by RedHeadEmile, Aug 16, 2019.

  1. Hello, I have to get the value and the signature of a skin from from.
    (file example attached)
     

    Attached Files:

  2. Not possible. The signature is obtained from the mojang servers. You got to upload it to a user, than over the user fetch the skins signature and save it. Now you can change your skin back. Save the signature into a config/storage file.
     
  3. You can get custom base64 texture from no-mojang URLs, signed or no. So I think it's possible to do the same thing with a File
     
  4. Well, we don't need the signature, property can be created by
    new Property("textures", value, signature);
    and new Property("textures", value);
    So, if it is possible to get the value, it can be a good beginning.
    But I think I'm going to it to a random account then get the value and the signature
     
  5. Well, that work
    Code (Java):
    package net.redheademile.skingetter;

    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    import com.mojang.authlib.GameProfile;
    import com.mojang.authlib.properties.Property;

    public class SkinGetter extends JavaPlugin
    {
        @Override
        public void onEnable()
        {
            saveDefaultConfig();
            reloadConfig();
         
            Bukkit.getPluginManager().registerEvents(new Listener()
            {
                @EventHandler
                public void onJoin(PlayerJoinEvent e)
                {
                    try
                    {
                        Player p = e.getPlayer();
                        Property prop = ((GameProfile) p.getClass().getDeclaredMethod("getProfile").invoke(p)).getProperties().get("textures").iterator().next();
                        getConfig().set(p.getUniqueId().toString() + ".name", p.getName());
                        getConfig().set(p.getUniqueId().toString() + ".value", prop.getValue());
                        getConfig().set(p.getUniqueId().toString() + ".signature", prop.getSignature());
                        saveConfig();
                    }
                    catch(Exception ex) { ex.printStackTrace(); }
                }
            }, this);
        }
    }