@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onPistonExtend(BlockPistonExtendEvent event) {
   ZoneManager manager = m_plugin.getZoneManager();
   if (!manager.zoneExists(event.getBlock().getLocation())) {
     for (Block b : event.getBlocks()) {
       if (manager.zoneExists(b.getLocation())) {
         event.setCancelled(true);
         return;
       } else if (manager.zoneExists(b.getRelative(event.getDirection()).getLocation())) {
         event.setCancelled(true);
         return;
       }
     }
   } else {
     Zone zone = manager.getZone(event.getBlock().getLocation());
     for (Block b : event.getBlocks()) {
       if (manager.zoneExists(b.getLocation())) {
         if (!zone.getName().equals(manager.getZone(b.getLocation()).getName())) {
           event.setCancelled(true);
           return;
         }
       }
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onBlockBreak(BlockBreakEvent event) {
    ZoneManager manager = m_plugin.getZoneManager();
    Zone zone = manager.getZone(event.getBlock().getLocation());

    if (zone == null) {
      return;
    }

    if (!zone.canPlayerUse(event.getPlayer(), event.getBlock())) {
      sendMessageNoSpam(event.getPlayer(), UI.getMessage("NoBuild"));
      event.setCancelled(true);
      if (shouldBurn(event.getBlock())) {
        event.getPlayer().setFireTicks(100);
      }
    }
  }
 /*
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onPlayerUseBukkit(PlayerBucketEvent event) {
     ZoneManager manager = m_plugin.getZoneManager();
     Zone zone = manager.getZone(event.getBlockClicked().getLocation());
     if (zone != null) {
         if (!zone.canPlayerUse(event.getPlayer(), event.getBlockClicked())) {
             event.setCancelled(true);
             sendMessageNoSpam(event.getPlayer(), UI.getMessage("NoBuild"));
         }
     }
 }
 */
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onPlayerInteractEvent(PlayerInteractEvent event) {
   ZoneManager manager = m_plugin.getZoneManager();
   Zone zone = manager.getZone(event.getClickedBlock().getLocation());
   if (zone != null) {
     if (!zone.canPlayerUse(event.getPlayer(), event.getClickedBlock())) {
       if (event.getAction() == Action.PHYSICAL
           || (event.getAction() == Action.RIGHT_CLICK_BLOCK && !event.isBlockInHand())) {
         if (event.getAction() == Action.PHYSICAL) {
           return;
         }
         event.setUseInteractedBlock(Event.Result.DENY);
         sendMessageNoSpam(event.getPlayer(), UI.getMessage("NoBuild"));
       }
     }
   }
 }
 /** Use a customPrefix */
 public void sendZonePrefix(CommandSender sender, Zone zone, String message) {
   sender.sendMessage("[\u00A7c" + zone.getName() + "\u00A7r] " + message);
 }
  /** Handle teleport messages */
  @EventHandler(ignoreCancelled = true)
  private void onPlayerTeleport(PlayerTeleportEvent event) {
    ZoneManager manager = m_plugin.getZoneManager();
    Zone fromZone = manager.getZone(event.getFrom());
    Zone toZone = manager.getZone(event.getTo());
    if (toZone != null) {
      if (!toZone.canPlayerMove(event.getPlayer())) {
        event.setCancelled(true);
        sendMessageNoSpam(event.getPlayer(), UI.getMessage("NoMove"));
        return;
      }
    }

    if (event.getTo().equals(event.getFrom())) {
      return;
    }

    if ((fromZone == null && toZone != null)
        || (fromZone != null && toZone != null && !fromZone.getName().equals(toZone.getName()))) {
      event.getPlayer().sendMessage(toZone.getEnterMessage());
    } else if ((toZone == null && fromZone != null)
        || (fromZone != null && toZone != null && !toZone.getName().equals(fromZone.getName()))) {
      event.getPlayer().sendMessage(fromZone.getExitMessage());
    }

    if (toZone != null && fromZone != null) {
      if (toZone.getName() == fromZone.getName()) {
        Plot toPlot = toZone.getPlot(event.getTo());
        Plot fromPlot = fromZone.getPlot(event.getFrom());

        if ((fromPlot == null && toPlot != null)
            || (fromPlot != null
                && toPlot != null
                && !fromPlot.getName().equals(toPlot.getName()))) {
          sendZonePrefix(
              event.getPlayer(), toZone, "\u00A7bNow entering plot \u00A7c" + toPlot.getName());
        } else if ((toPlot == null && fromPlot != null)
            || (fromPlot != null
                && toPlot != null
                && !toPlot.getName().equals(fromPlot.getName()))) {
          sendZonePrefix(
              event.getPlayer(), toZone, "\u00A7bNow leaving plot \u00A7c" + fromPlot.getName());
        }
      }
    }
  }
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onPlayerMove(PlayerMoveEvent event) {
    ZoneManager manager = m_plugin.getZoneManager();
    Zone fromZone = manager.getZone(event.getFrom());
    Zone toZone = manager.getZone(event.getTo());
    if (toZone != null) {
      if (!toZone.canPlayerMove(event.getPlayer())) {
        Vector direction =
            event.getFrom().toVector().subtract(event.getTo().toVector()).normalize();
        event.getPlayer().setVelocity(direction.multiply(2));
        sendMessageNoSpam(event.getPlayer(), UI.getMessage("NoMove"));
        return;
      }
    }

    if (event.getTo().equals(event.getFrom())) {
      return;
    }

    if ((fromZone == null && toZone != null)
        || (fromZone != null && toZone != null && !fromZone.getName().equals(toZone.getName()))) {
      event.getPlayer().sendMessage(toZone.getEnterMessage());
    } else if ((toZone == null && fromZone != null)
        || (fromZone != null && toZone != null && !toZone.getName().equals(fromZone.getName()))) {
      event.getPlayer().sendMessage(fromZone.getExitMessage());
    }

    if (toZone != null && fromZone != null) {
      if (toZone.getName() == fromZone.getName()) {
        Plot toPlot = toZone.getPlot(event.getTo());
        Plot fromPlot = fromZone.getPlot(event.getFrom());

        if ((fromPlot == null && toPlot != null)
            || (fromPlot != null
                && toPlot != null
                && !fromPlot.getName().equals(toPlot.getName()))) {
          sendZonePrefix(
              event.getPlayer(), toZone, "\u00A7bNow entering plot \u00A7c" + toPlot.getName());
        } else if ((toPlot == null && fromPlot != null)
            || (fromPlot != null
                && toPlot != null
                && !toPlot.getName().equals(fromPlot.getName()))) {
          sendZonePrefix(
              event.getPlayer(), toZone, "\u00A7bNow leaving plot \u00A7c" + fromPlot.getName());
        }
      }
    }
  }