Beispiel #1
0
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onPistonRetract(BlockPistonRetractEvent event) {
    World world = event.getBlock().getWorld();
    WorldConfig worldConfig = plugin.getConfig(world);

    if (plugin.isEnabled(world) && worldConfig.FEATURE_DUNGEONS_PROTECTED.getValue()) {
      if (this.isProtected(event.getRetractLocation())) {
        event.setCancelled(true);
      }
    }
  }
Beispiel #2
0
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlock();
    World world = block.getWorld();
    WorldConfig worldConfig = plugin.getConfig(world);

    List<Material> allowed = Arrays.asList(Material.TORCH);

    if (plugin.isEnabled(world)
        && worldConfig.FEATURE_DUNGEONS_PROTECTED.getValue()
        && !allowed.contains(block.getType())
        && this.isProtected(block.getLocation())) {
      event.setCancelled(true);
    }
  }
Beispiel #3
0
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onEntityExplode(EntityExplodeEvent event) {
    List<Block> blocks = event.blockList();

    if (!blocks.isEmpty()) {
      World world = blocks.get(0).getWorld();
      WorldConfig worldConfig = plugin.getConfig(world);

      if (plugin.isEnabled(world) && worldConfig.FEATURE_DUNGEONS_PROTECTED.getValue()) {
        Iterator<Block> iterator = blocks.iterator();

        while (iterator.hasNext()) {
          Block block = iterator.next();

          if (this.isProtected(block.getLocation())) {
            iterator.remove();
          }
        }
      }
    }
  }