Bottle disappearing after drinking?

Discussion in 'Plugin Development' started by Prophettt, Mar 8, 2013.

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



    I have no idea how to do this but I'm assuming it's easy.
    If you drink a potion you get a empty bottle.

    I want that after you drink the potion, the bottle automatically disappears,
    Please help me.
  2. There is no easy way of knowing when you drank a potion currently... the ConsumeItemEvent will come on the next Bukkit version I guess, I've seen it being added.

    You could use PlayerInteractEvent if you want to make potions drinkable instantly and then remove the bottle.
  3. Fancy solution with ProtocolLib:
    1. protocolManager.addPacketListener(new PacketAdapter(this, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, 0x26) {
    3. @Override
    4. public void onPacketSending(PacketEvent event){
    5. switch(event.getPacketID()){
    6. case 0x26:
    7. PacketContainer packet = event.getPacket();
    8. try {
    9. if(packet.getModifier().read(1).equals((byte)9)){
    10. event.getPlayer().sendMessage("You have consumed one " + event.getPlayer().getItemInHand().getType().name().toLowerCase());
    11. }
    12. } catch (FieldAccessException ex) {
    13. }
    14. }
    15. }
    17. });
  4. Offline


    Where exactly do I put that in my code?
  5. In my example I use ProtocolLib, you have to add a dependency and put that after
    1. protocolManager = ProtocolLibrary.getProtocolManager();

    in your onEnable() {} function.
Thread Status:
Not open for further replies.

Share This Page