Bukkit将播放器皮肤从服务器更改为png(无效签名)

时间:2017-08-23 15:13:22

标签: java minecraft bukkit

我正在编写一个bukkit插件,该插件应该能够向玩家发送GameProfile更新以更改玩家的皮肤。但是在游戏机中,它表示皮肤签名无效。如何获得有效的皮肤签名?

/**
 * Sets the skin of a player
 * @param p The player
 * @param fn The file name on the server
 */
public void setSkin(Player p, String fn){
    GameProfile gp = ((CraftPlayer)p).getProfile();
    String skin = new String(Base64.encodeBase64(("{\"timestamp\":1503497691710,\"profileId\":\"b4be22fdb7004478839c787357d78cbe\",\"profileName\":\"Colinus999\",\"signatureRequired\":false,\"textures\":{\"SKIN\":{\"url\":\"http://colintimbarndt.de/skin/"+fn+"\"}}}").getBytes()));
    String sig = "kVWGmfZuMbHc0KhDjX0FrdNA4KK/JTFiSDUQu5O1Jw76/Y+ozfsxZUNkljzCke3cEhpTCdgZuy0nEaBI7WhdunacxBcm7r//a1W/Z5MBJKt3KZM8lySzHlUaM1cSIwRZIrGz5PDcqbgxm/GmOEiewehn6M5vEIBOoYwmCBNpYswVkIG/2qmcHsXUG3zzvzoYdTuKZuBHdGhWHr14TI19deW/Mqru2Bmc+bK1FrGrnT0urUiDIsDbjWXGdOYkci7vMPutlFHDHbFu0+HDalIpeRjI3IiVnwHPim9zu+fkYN92pAyAQeTa2AwmHTMO6/JY/o539HAvYbDcovMzXXZxzPWlozhw3ib+z+OwvsOuBcwPCeN1zhiUYQJFm5lR8d2IvwbNe2y40NWQm0oBI71rneNw2h5TH54muqLRJ297Sli35Ufs0z79I3gn5XTtfiSLFTicZzQ61Nq8CmcXKi4Q/eytHpPkmoNibPsr6BUJd6BI2XDg2YQzdBvpQcjd6azkuQL95arOdlk1UaBMIZwU5/yHaNfiG0Q7+fHTbIXchIHtdr668ly6S0CqOKmvztmcHYlUqV73WBB7GmoZS0tKz8cmMc1hmlvkh+DZ8BQ+EGBu6pYZE6NQ8x+Vv69XIeLUCR3c/JIQ69uGIUwPWa6ainNp//aSUVULsxVS6g3Iwi8=";
    gp.getProperties().clear();
    gp.getProperties().put("textures", new Property("textures", skin, sig));
    gp.getProperties().put("Colinus999", new Property("textures", skin, sig));
    // Update the player
    for(Player p1 : lobby.getWorld().getPlayers()){
        p1.hidePlayer(p);
    }
    Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.plugin, new Runnable() {
        public void run(){
            for(Player p1 : lobby.getWorld().getPlayers()){
                p1.showPlayer(p);
            }
        }
    }, 5);
}

我通过打开以下链接获得了签名和其他数据: https://sessionserver.mojang.com/session/minecraft/profile/b4be22fdb7004478839c787357d78cbe?unsigned=false

有关玩家皮肤的更多信息:https://minecraft.gamepedia.com/Player.dat_format#Player_Heads

我知道这是可能的,因为有服务器改变了玩家的皮肤甚至编辑它。

1 个答案:

答案 0 :(得分:1)

我修好了!

我必须为每个皮肤保存json! (至少签名和皮肤数据) 你不需要任何服务器等。