Cannot change player skins

Discussion in 'Plugin Development' started by TheEnderCrafter9, Jul 6, 2020.

Thread Status:
Not open for further replies.
  1. I am trying to change the skin of players for a minigame I have. However, the code does not return any errors, but It also doesn't function.

    Code:
        public boolean setSkin(UUID uuid) {
            try {
                HttpsURLConnection connection = (HttpsURLConnection) new URL(String.format("https://sessionserver.mojang.com/session/minecraft/profile/%s?unsigned=false", UUIDTypeAdapter.fromUUID(uuid))).openConnection();
                if (connection.getResponseCode() == HttpsURLConnection.HTTP_OK) {
    
                    String[] values = new BufferedReader(new InputStreamReader(connection.getInputStream())).lines().filter(x -> (x.contains("value") || x.contains("signature"))).collect(Collectors.toList()).toString().split("\"");
    
                    ((CraftPlayer) player).getHandle().getProfile().getProperties().put("textures", new Property("textures", values[3], values[7]));
                    return true;
                } else {
                    System.out.println("Connection could not be opened (Response code " + connection.getResponseCode() + ", " + connection.getResponseMessage() + ")");
                    return false;
                }
            } catch (IOException e) {
                e.printStackTrace();
                return false;
            }
        }
    When debugging, I made sure that values[3] and values[7] corresponded to the correct values, or in other words the texture value & the signature. The boolean returns true.

    I am running the server on bukkit 1.8.3. Is there anything I am missing from this block of code?

    UPDATE:

    Code:
    [16:21:02 WARN]: An exception was thrown by a user handler's exceptionCaught() method while handling the following exception:
    java.lang.NullPointerException
            at net.minecraft.server.v1_8_R3.NetworkManager.close(NetworkManager.java:245) ~[server.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.NetworkManager.channelInactive(NetworkManager.java:105) ~[server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:233) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:219) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:228) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:233) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:219) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:228) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:233) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:219) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:233) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:219) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.handler.timeout.ReadTimeoutHandler.channelInactive(ReadTimeoutHandler.java:144) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:233) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:219) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:769) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.AbstractChannel$AbstractUnsafe$5.run(AbstractChannel.java:567) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) [server.jar:git-Spigot-db6de12-18fbb24]
            at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [server.jar:git-Spigot-db6de12-18fbb24]
            at java.base/java.lang.Thread.run(Thread.java:832) [?:?]
    
    This error is thrown after I attempt to change my skin a couple of times, then log off. When I try to connect back, I get immediately disconnected, and the server does not show up as online on my list.
     
    Last edited: Jul 6, 2020
Thread Status:
Not open for further replies.

Share This Page