Solved Trying to change the Unknown command but i get a error

Discussion in 'Plugin Development' started by DerpyLV, Jan 16, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    DerpyLV

    Hello, I am trying to change the unknown command message I export the plugin successfully but i get a error in the console
    [​IMG]
    Code:
    [21:04:22 ERROR]: [Ping] Unhandled exception occured in onPacketSending(PacketEvent) for Ping
    com.comphenix.protocol.reflect.FieldAccessException: No field with type java.lang.String exists in class PacketPlayOutChat.
            at com.comphenix.protocol.reflect.StructureModifier.readInternal(StructureModifier.java:218) ~[ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:197) ~[ProtocolLib.jar:3.6.5-b222]
            at me.weedlvz.nullanticheat.Main$1.onPacketSending(Main.java:28) ~[Ping.jar:?]
            at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:637) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:613) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.compat.netty.independent.NettyProtocolInjector.packetQueued(NettyProtocolInjector.java:318) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.compat.netty.independent.NettyProtocolInjector.onPacketSending(NettyProtocolInjector.java:278) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.compat.netty.independent.NettyChannelInjector.processSending(NettyChannelInjector.java:401) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.compat.netty.independent.NettyChannelInjector.access$500(NettyChannelInjector.java:82) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.compat.netty.independent.NettyChannelInjector$5.handleScheduled(NettyChannelInjector.java:367) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.compat.netty.independent.NettyChannelInjector$5.onMessageScheduled(NettyChannelInjector.java:335) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.compat.netty.independent.NettyChannelProxy$2.schedulingRunnable(NettyChannelProxy.java:127) [ProtocolLib.jar:3.6.5-b222]
            at com.comphenix.protocol.compat.netty.independent.NettyEventLoopProxy.execute(NettyEventLoopProxy.java:95) [ProtocolLib.jar:3.6.5-b222]
            at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:183) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.NetworkManager.handle(NetworkManager.java:132) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.sendPacket(PlayerConnection.java:876) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerList.sendAll(PlayerList.java:856) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerList.sendMessage(PlayerList.java:1180) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerList.sendMessage(PlayerList.java:1185) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityPlayer.die(EntityPlayer.java:408) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityLiving.damageEntity(EntityLiving.java:802) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityHuman.damageEntity(EntityHuman.java:794) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityPlayer.damageEntity(EntityPlayer.java:481) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityLiving.e(EntityLiving.java:929) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityHuman.e(EntityHuman.java:1434) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.Block.fallOn(Block.java:636) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.Entity.a(Entity.java:794) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityLiving.a(EntityLiving.java:151) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityPlayer.a(EntityPlayer.java:606) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:441) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_112]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_112]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit.jar:git-Bukkit-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_112]
    [21:04:22 ERROR]: Parameters:
      net.minecraft.server.v1_8_R3.PacketPlayOutChat@6f9fd729[
        a=TranslatableComponent{key='death.fell.accident.generic', args=[TextComponent{text='WeedLVz', siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=ClickEvent{action=SUGGEST_COMMAND, value='/msg WeedLVz '}, hoverEvent=HoverEvent{action=SHOW_ENTITY, value='TextComponent{text='{name:"WeedLVz",id:"dfe2c08f-5f0d-33a9-ba29-dba58f36077c"}', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}'}, insertion=WeedLVz}}], siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}
        b=1
      ]
    
    I have protocollib in my plugins and added in build path for eclipse
     
  2. @DerpyLV
    I see that you have been looking at this thread. Sadly that thread is a bit outdated, the packet format has been changed from using a string to using a chatcomponent. The code would look something like this:
    Code:java
    1. // This is actually the JSON of the chat message.
    2. String message = event.getPacket().getChatComponents().read(0).getJson();
    3. // The extra backslashes are because of JSON escapes.
    4. if (message.contains("Unknown command. Type \\\"/help\\\" for help.")) {
    5. // And then overwrite the ChatComponent with a new one created from a String.
    6. event.getPacket().getChatComponents().write(0, WrappedChatComponent.fromText("My new unkown command message!"));
    7. }
    This however isn't quite the perfect method to do it, as it doesn't account for the console/command blocks. If you're using Spigot, there is a config option (which can also be edited programmatically), but if you're using CraftBukkit, you're stuck with this. You could also add a logging filter if you really wanted to change the message in console.
     
  3. Offline

    Zombie_Striker

    @DerpyLV
    First, why are you using 1.8? That came out over two years ago.

    You can do what @AlvinB suggested, or you can just update your server to 1.11.2. I would recommend updating, since there is no reason to stay on older updates of MC.
     
  4. Offline

    DerpyLV

    Would i need to update my plugin code?
     
  5. @DerpyLV
    As long as you're not using any NMS or craftbukkit, no, your code will work just fine if you update to 1.11 (although you will get quite a few extra features to code with).
     
Thread Status:
Not open for further replies.

Share This Page