示例#1
0
  @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);
      }
    }
  }
示例#2
0
 /*
 @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"));
       }
     }
   }
 }