Solved isCancelled() not working

Discussion in 'Plugin Development' started by Unica, Oct 28, 2014.

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

    Unica

    Hi,

    I want to check if the damage is already cancelled (WorldGuard), so my listener won't add players to the combatLogger I made. I tried using isCancelled(), that didn't work.

    Code:java
    1. @EventHandler
    2. public void onDamage(EntityDamageByEntityEvent e) {
    3. if (e.getEntity() instanceof Player) {
    4. Player p = (Player) e.getEntity();
    5. if(e.getDamager() instanceof Player){
    6. if(e.isCancelled()){
    7. System.out.println("Cancelled!"); //Doesn't fire in worldGuard region.
    8. }
    9. Player damager = (Player) e.getDamager();
    10. if (m.cdown.isInCooldown(p)) {
    11. m.cdown.addTimeToCooldown(p);
    12. } else{
    13. p.sendMessage(DARK_RED.toString() + BOLD + "✘ " + RED
    14. + "You are now in a battle! Do not Chicken Out!"
    15. + DARK_RED.toString() + BOLD + " ✘");
    16. m.cdown.addToCooldown(p);
     
  2. Offline

    mrCookieSlime

    Unica
    Set the priority to MONITOR.
     
  3. Offline

    Unica

Thread Status:
Not open for further replies.

Share This Page