1.17.1 Trying to change the player's skin with a command in 1.17.1

Discussion in 'Spigot Plugin Development' started by Rjthedude15, Nov 25, 2021.

  1. I'm trying to make a command that changes the player executing the command's skin to any skin that the player wants, (like /skin <playername>). First though I need to test if the plugin can fetch specific skins by getting signatures generated by https://mineskin.org/gallery. I tried repeating some of the code in CodedRed's video however the nms code is outdated in 1.16.3. How would I make this work? It currently does not work with the code I have changed from CodedRed's video.

    Code (Text):
    public class SkinGrabber {

        public static void changeSkin(Player p) {
            GameProfile profile = ((CraftPlayer) p).getHandle().getProfile();

            PlayerConnection connection = ((CraftPlayer) p).getHandle().b;

            connection.sendPacket(new PacketPlayOutPlayerInfo(
                    PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, ((CraftPlayer) p).getHandle())); // remove player is e
            profile.getProperties().removeAll("textures");
            profile.getProperties().put("textures", getSkin());
            connection.sendPacket(new PacketPlayOutPlayerInfo(
                    PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a, ((CraftPlayer) p).getHandle())); // add player is a
        }
        private static Property getSkin() {
            return new Property("textures", "PpjPEa4c7n57ci/ReofqzzusiDJ/u/p2XpP1MlgwiUjaOmnNrf2xN4+bfg3rmeoXntyxtt57QWByVwKwulLtLvnFeJSZjuYCo+AxcX7y5E1xexwy0kcQ8ChSgZ/E5HP86AuLPY9tlaNVqBaF4Moejp3NZEpoi9Vus9o80HGrX91pvnf5s5X3Y7iFW/vGfl/fHfwQ17zHutPTBsvlP7T/jgoJQT0wKKovgA0vu6iQK1ZTCjL/aNp2eQpdE/Bh8q5TLc3kn3KNmvpoawjSsHxkdj2zo7wWIke208+7wcrzBc8K/rXZFiTgXvt3ktWWrOZHDDqRUJ+tfD1zLfD1bESrQ2+tW98w13Wgqwsox33HCvUGkgixsbvVcbliwqB6L+7AtD08rK4fK+BwFsVu+ILI8q5TGgQEQ45uwhJvO4qifXr3Hq+GeTDojoSWyGk6UsM6yo+lPcHt0XY2OWMzUZhyfW0R+slNtS1GZNYEesx8PPP7NwtX7/Nvoe+GeG6yJR+zR4H6Jkd/Ug+tZQBH4qahB3F7qbNz0Jp2QHMBWz2AwuK57CWceFavimE46APdjaC3OWAgJOVNwwHWoJg6T1+IKAVDu91XhPPNLKCWF5HlyX1WutX9tMOSkgc/lsK36Jzjk4FFKxUyE9PTqwvEsOqJUmaYyXAZl+/gBUh/aNK8UU8=");

        }
    }