Solved Detecting if event was cancelled by another plugin

Discussion in 'Plugin Development' started by iSexyChocobo, Jun 23, 2015.

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

    iSexyChocobo

    So I'm trying to override a plugin's event. Needless to say I am failing.

    PLUGIN A

    Code:
        @EventHandler (priority = EventPriority.HIGHEST)
        public void onPlayerInteract(PlayerInteractEvent e) {
          if (!WGDenyPlugin.this.wgPlugin.getGlobalRegionManager().allows(WGDenylugin.this.DENY_MODDED_CONTAINERS_FLAG, e.getPlayer().getLocation(), WGDenyPlugin.this.wgPlugin.wrapPlayer(e.getPlayer()))) {         
    Player p = e.getPlayer();
    e.setCancelled(true);
    p.sendMessage("Hello");
    
    PLUGIN B
    Code:
            @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
            public void onPlayerInteractEvent(PlayerInteractEvent e) {
            if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    p.sendMessage("Nope");

    Now I want plugin A to completely override plugin B so if plugin A is active - plugin B is not. However, my code is not doing what I want it to do, and plugin A and B seem to both run.

    (ex. What is happening now
    *right clicks block*
    Hello
    Nope

    What should happen
    *right clicks block*
    Hello
    )

    The WGDenyPlugin part is to make sure "Hello" only appears in certain areas.

    Please let me know what I'm doing wrong, thanks.
     
  2. Offline

    1Rogue

    lowest priority is called first, if you want it to not run when cancelled, then set it to a higher priority than what's cancelling it.
     
    iSexyChocobo likes this.
  3. Offline

    MCMatters

  4. Offline

    1Rogue

    Then it wouldn't skip the listener if it's cancelled, which is the opposite of what OP wants
     
  5. Offline

    iSexyChocobo

    Thank you ^-^ Problem solved.
     
Thread Status:
Not open for further replies.

Share This Page