How to get rid of the "Level up" sound when reaching an interval of 5

Discussion in 'Plugin Development' started by redside100, May 18, 2014.

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

    redside100

    Hi there, for a part of my plugin, I use the player's exp bar as energy. I made it so every second, the recieve around 10 levels. The thing is, it makes a really annoying sound when they get the levels. Is there any way to remove that sound?
     
  2. Offline

    ChazSchmidt

    You could always use Protocol
    Lib to intercept that sound packet and cancel it
     
  3. Offline

    redside100

    Is there any other way?
     
  4. Offline

    Code0

    Yes redside, code ProtolLib by yourself :).

    (No, packet editing is the only way)
     
  5. Offline

    redside100

    Well, I have no idea how to do that... I've read the protocol lib page, but I'm not sure what to do. Do I just use the API and just add the code to my plugin?
     
  6. Offline

    rsod

    You can write your own function of levelling up. It should block default levelling up, and you should manually set level of player each time he should level up. Then the sound won't appear. But it is much easier to use ProtocolLib. There is nothing wrong with using a library, it's common in programming.
     
  7. Offline

    redside100

    Alright, so I got ProtocolLib working, but what do I do to remove a specific sound effect, such as the LEVEL_UP sound?

    Here's my code:
    Code:
        @Override
        public void onEnable()
        {
            protocolManager.addPacketListener( new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
                @Override
                public void onPacketSending(PacketEvent event) {
                    if (event.getPacketType() ==
                            PacketType.Play.Server.NAMED_SOUND_EFFECT) {
                        event.setCancelled(true);
                    }
                }
            });
     
Thread Status:
Not open for further replies.

Share This Page