Solved Cancel original events

Discussion in 'Spigot Plugin Development' started by Mr_Animatik_rus, Jun 23, 2021.

  1. Hello. I'm trying to make a plugin for creating drinks. The cauldron in which components are put in changes the water level to show how many components inside. To get a drink user needs to click RMB with an empty bottle to the cauldron. After that plugin changes the water level to 0 (the cauldron is empty), but when we click on the cauldron with an empty bottle we triggered the original CauldronLevelChangeEvent which change the water level to the previous level.
    I tried to override the event, but the plugins events run first, and after that original CLCE runs and changes the level.

    Code (Java):
    public void CancelDraing(CauldronLevelChangeEvent e){
            if (e.getReason() == CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL && CoctailLocations.GetMixer(e.getBlock().getLocation())!= null){
                ListenerTouchCauldrone.CancelFill(e);  // change the water level to 0

    How can I cancel the original event or run the plugin event lately?
  2. The CauldronLevelChangeEvent event cant be canceled.
    • Funny Funny x 3
    • Creative Creative x 1
  3. Can you show your full code? The CauldronLevelChangeEvent implements the Cancellable interface, so you should be able to cancel it just fine.
    • Like Like x 1
  4. Try setting a new cauldron when the event in triggered.
  5. Why do you always keep posting wrong information?

    • Agree Agree x 1
    • Informative Informative x 1
  6. I couldn't check the page properly because I was viewing the page on mobile
  7. Thanks a lot :) My problem is that I don't read the documentation :)
    I thought the Cancellable interface cancel plugin trigger, not the original, so I was wrong.
    I added in that function, which I typed earlier
    Code (Java):
    and problem fixed
  8. If you can't confirm your information, why share it?
    • Agree Agree x 3