Solved ProtocolLib - Disable a sound.

Discussion in 'Plugin Development' started by VinexAx789, Oct 12, 2016.

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

    VinexAx789

    Problem is I can still here the sound play.

    CODE:
    Code:
    ProtocolLibrary.getProtocolManager().addPacketListener(
      new PacketAdapter(this, ListenerPriority.NORMAL,
              PacketType.Play.Server.NAMED_SOUND_EFFECT) {
                        @Override
                        public void onPacketSending(PacketEvent event) {
                            PacketContainer packet = event.getPacket();
                            String soundName = packet.getStrings().read(0);
                            if (ProtocolLibrary.getProtocolManager().getProtocolVersion(event.getPlayer()) <= 47) {
                                if (soundName.equalsIgnoreCase("random.levelup")) {
                                    event.setCancelled(true);
                                } else if (ProtocolLibrary.getProtocolManager()
                                        .getProtocolVersion(event.getPlayer()) >= 107) {
                                    if (soundName.equalsIgnoreCase("entity.player.levelup")) {
                                        event.setCancelled(true);
                                    }
                                }
                            }
                        }
                    });

    ERROR LOG:
    Code:
    [21:54:34] [Server thread/ERROR]: [VenomKits] Unhandled exception occured in onPacketSending(PacketEvent) for VenomKits
    com.comphenix.protocol.reflect.FieldAccessException: No field with type java.lang.String exists in class PacketPlayOutNamedSoundEffect.
        at com.comphenix.protocol.reflect.StructureModifier.readInternal(StructureModifier.java:219) ~[ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:198) ~[ProtocolLib.jar:4.1.0-b325]
        at com.me.sly.kits.main.Corrupted$1.onPacketSending(Corrupted.java:372) ~[VenomKits.jar:?]
        at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:608) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:584) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.netty.ProtocolInjector.packetQueued(ProtocolInjector.java:309) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.netty.ProtocolInjector.onPacketSending(ProtocolInjector.java:269) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.netty.ChannelInjector.processSending(ChannelInjector.java:396) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.netty.ChannelInjector.access$500(ChannelInjector.java:77) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.netty.ChannelInjector$5.handleScheduled(ChannelInjector.java:362) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.netty.ChannelInjector$5.onMessageScheduled(ChannelInjector.java:330) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.netty.ChannelProxy$2.schedulingRunnable(ChannelProxy.java:127) [ProtocolLib.jar:4.1.0-b325]
        at com.comphenix.protocol.injector.netty.EventLoopProxy.execute(EventLoopProxy.java:95) [ProtocolLib.jar:4.1.0-b325]
        at net.minecraft.server.v1_10_R1.NetworkManager.a(NetworkManager.java:194) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.NetworkManager.sendPacket(NetworkManager.java:143) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.PlayerConnection.sendPacket(PlayerConnection.java:1105) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.PlayerList.sendPacketNearby(PlayerList.java:1178) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.WorldManager.a(WorldManager.java:37) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.World.a(World.java:1004) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.EntityHuman.levelDown(EntityHuman.java:1634) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.EntityPlayer.levelDown(EntityPlayer.java:175) [patched_1.10.2.jar:git-Paper-818]
        at org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer.giveExpLevels(CraftPlayer.java:897) [patched_1.10.2.jar:git-Paper-818]
        at com.me.sly.kits.main.Corrupted.addEnergy(Corrupted.java:1183) [VenomKits.jar:?]
        at com.me.sly.kits.main.Corrupted$3.run(Corrupted.java:439) [VenomKits.jar:?]
        at org.bukkit.craftbukkit.v1_10_R1.scheduler.CraftTask.run(CraftTask.java:58) [patched_1.10.2.jar:git-Paper-818]
        at org.bukkit.craftbukkit.v1_10_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:352) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:781) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:404) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:725) [patched_1.10.2.jar:git-Paper-818]
        at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:624) [patched_1.10.2.jar:git-Paper-818]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45]
    [21:54:34] [Server thread/ERROR]: Parameters:
      [email protected]448e[
        [email protected]
        b=PLAYERS
        c=-3052
        d=312
        e=1925
        f=0.75
        g=1.0
      ]
    Checking what version the client is on then if they are less than or equal to 47 then they are either on 1.8, 1.7 or below but I have it only 1.7 - 1.10.2. Then checked if they were greater than or equal to 107 if so then the sound name was 1.9 - 1.10.2+.

    If you could help me out that'd be much appreciated.
     
  2. Offline

    Zombie_Striker

    This says there are no strings for the packet.
    This is what is causing the error.

    Before 1.8, you could only play existing sounds. That means that there was a static set of values for each sound. I would recommend using an older server version/P.L and test out what the old parameters were.
     
  3. Offline

    VinexAx789

    @Zombie_Striker in ProtoclLib it's getSoundEffects my issue is solved.
     
Thread Status:
Not open for further replies.

Share This Page