Example #1
0
 @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;
         }
       }
     }
   }
 }
Example #2
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onBlockFromTo(BlockFromToEvent event) {
   ZoneManager manager = m_plugin.getZoneManager();
   if (manager.zoneExists(event.getBlock().getLocation())) {
     event.setCancelled(true);
   }
 }
Example #3
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onPistonRetract(BlockPistonRetractEvent event) {
   ZoneManager manager = m_plugin.getZoneManager();
   if (!manager.zoneExists(event.getBlock().getLocation())) {
     if (manager.zoneExists(event.getRetractLocation())) {
       event.setCancelled(true);
       return;
     }
   } else if (!manager
       .getZone(event.getBlock().getLocation())
       .getName()
       .equals(manager.getZone(event.getRetractLocation()).getName())) {
     event.setCancelled(true);
     return;
   }
 }
Example #4
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onBreakDoor(EntityBreakDoorEvent event) {
   ZoneManager manager = m_plugin.getZoneManager();
   if (manager.zoneExists(event.getBlock().getLocation())) {
     if (!(event.getEntity() instanceof Player)) {
       event.setCancelled(true);
     }
   }
 }
Example #5
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onCreatureSpawn(CreatureSpawnEvent event) {
   ZoneManager manager = m_plugin.getZoneManager();
   if (manager.zoneExists(event.getLocation())) {
     if (!manager.getZone(event.getLocation()).canMobsSpawn()) {
       if (event.getEntity() instanceof Monster || event.getEntity() instanceof Slime) {
         event.setCancelled(true);
       }
     }
   }
 }
Example #6
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onBlockIgnite(BlockIgniteEvent event) {
   ZoneManager manager = m_plugin.getZoneManager();
   if (manager.zoneExists(event.getBlock().getLocation())) {
     if (!manager
         .getZone(event.getBlock().getLocation())
         .canPlayerUse(event.getPlayer(), event.getBlock())) {
       event.setCancelled(true);
       sendMessageNoSpam(event.getPlayer(), UI.getMessage("NoBuild"));
     }
   }
 }
Example #7
0
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onDamageByEntity(EntityDamageByEntityEvent event) {
   if (event.getDamager() instanceof Player) {
     if (event.getEntity() instanceof Player) {
       ZoneManager manager = m_plugin.getZoneManager();
       if (manager.zoneExists(event.getDamager().getLocation())) {
         if (!manager.getZone(event.getDamager().getLocation()).canPVP()) {
           event.setCancelled(true);
         }
       } else {
         if (manager.zoneExists(event.getEntity().getLocation())) {
           if (!manager.getZone(event.getEntity().getLocation()).canPVP()) {
             event.setCancelled(true);
           }
         } else {
           event.setCancelled(true);
         }
       }
     }
   } else if (event.getDamager() instanceof Arrow) {
     if (event.getEntity() instanceof Player) {
       ZoneManager manager = m_plugin.getZoneManager();
       if (manager.zoneExists(event.getDamager().getLocation())) {
         if (!manager.getZone(event.getDamager().getLocation()).canPVP()) {
           event.setCancelled(true);
         }
       } else {
         if (manager.zoneExists(event.getEntity().getLocation())) {
           if (!manager.getZone(event.getEntity().getLocation()).canPVP()) {
             event.setCancelled(true);
           }
         } else {
           event.setCancelled(true);
         }
       }
     }
   }
 }
Example #8
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onExplode(EntityExplodeEvent event) {
    ZoneManager manager = m_plugin.getZoneManager();

    List<Block> saveList = new ArrayList<Block>();

    for (Block b : event.blockList()) {
      if (manager.zoneExists(b.getLocation())) {
        saveList.add(b);
      }
    }

    for (Block b : saveList) {
      event.blockList().remove(b);
    }
  }