/*
   * Called when block physics occurs.
   */
  @EventHandler(ignoreCancelled = true)
  public void onBlockPhysics(BlockPhysicsEvent event) {
    ConfigurationManager cfg = plugin.getGlobalStateManager();
    WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());

    if (cfg.activityHaltToggle) {
      event.setCancelled(true);
      return;
    }

    int id = event.getChangedTypeId();

    if (id == 13 && wcfg.noPhysicsGravel) {
      event.setCancelled(true);
      return;
    }

    if (id == 12 && wcfg.noPhysicsSand) {
      event.setCancelled(true);
      return;
    }

    if (id == 90 && wcfg.allowPortalAnywhere) {
      event.setCancelled(true);
      return;
    }

    if (wcfg.ropeLadders && event.getBlock().getType() == Material.LADDER) {
      if (event.getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
        event.setCancelled(true);
        return;
      }
    }
  }
  /**
   * Called when block physics occurs
   *
   * @param event Relevant event details
   */
  @Override
  public void onBlockPhysics(BlockPhysicsEvent event) {

    if (event.isCancelled()) {
      return;
    }

    ConfigurationManager cfg = plugin.getGlobalConfiguration();
    WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());

    int id = event.getChangedTypeId();

    if (id == 13 && wcfg.noPhysicsGravel) {
      event.setCancelled(true);
      return;
    }

    if (id == 12 && wcfg.noPhysicsSand) {
      event.setCancelled(true);
      return;
    }

    if (id == 90 && wcfg.allowPortalAnywhere) {
      event.setCancelled(true);
      return;
    }
  }
 @EventHandler(priority = EventPriority.HIGH)
 public void onBlockPhysics(BlockPhysicsEvent event) {
   if (event.getBlock().getType() == Material.PORTAL) {
     if (DPortal.get(event.getBlock()) != null) {
       event.setCancelled(true);
     }
   }
 }
 @EventHandler(ignoreCancelled = true)
 public void onBlockPhysics(BlockPhysicsEvent event) {
   Block block = event.getBlock();
   if (LotteryManager.isSignRegistered(block) || !checkBlockBroken(block)) {
     event.setCancelled(true);
     return;
   }
 }
 /** Cancels block physics events in arenas not currently running. */
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onBlockPhysics(BlockPhysicsEvent event) {
   Material material = event.getChangedType();
   if (material == Material.WATER || material == Material.LAVA || UGUtils.hasPhysics(material)) {
     Arena arena =
         ultimateGames.getArenaManager().getLocationArena(event.getBlock().getLocation());
     if (arena != null && arena.getStatus() != ArenaStatus.RUNNING) {
       event.setCancelled(true);
     }
   }
 }
 @Override
 public void onBlockPhysics(BlockPhysicsEvent event) {
   if (event.isCancelled()) {
     return;
   }
   PortalManager pm = this.plugin.getPortalManager();
   MVPortal portal = pm.isPortal(null, event.getBlock().getLocation());
   if (portal != null
       && (event.getChangedType() == Material.PORTAL
           || event.getBlock().getType() == Material.PORTAL)) {
     event.setCancelled(true);
   }
 }
  @Override
  public void onBlockPhysics(BlockPhysicsEvent event) {
    Block block = event.getBlock();
    Material material = block.getType();
    if (material == Material.LEVER || material == Material.STONE_BUTTON) {
      Material adjMaterial = getBlockBehindButton(block).getType();

      if (adjMaterial == Material.PISTON_BASE
          || adjMaterial == Material.PISTON_STICKY_BASE
          || adjMaterial == Material.PISTON_MOVING_PIECE) {
        event.setCancelled(true);
        return;
      }
    }
  }
 public void onBlockPhysics(BlockPhysicsEvent event) {
   if (event.isCancelled()) {
     return;
   }
   // Forces diode not to update and disable itself
   if (event.getBlock().getTypeId() == Material.DIODE_BLOCK_ON.getId()) {
     ConcurrentHashMap<Block, Sensor> sensorList = SensorManager.getSensorList();
     Iterator<Entry<Block, Sensor>> i = sensorList.entrySet().iterator();
     while (i.hasNext()) {
       Entry<Block, Sensor> e = i.next();
       if (SensorManager.isSign(e.getKey())
           && ((GenericSensor) e.getValue()).equals(event.getBlock().getLocation())) {
         event.setCancelled(true);
         return;
       }
     }
   }
 }
Exemple #9
0
 @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
 public void onBlockPhysics(BlockPhysicsEvent event) {
   final Block physics = event.getBlock();
   if (physics.getRelative(BlockFace.DOWN).getType() != Material.AIR) {
     return;
   }
   final Sprout sprout =
       plugin
           .getWorldRegistry()
           .remove(physics.getWorld().getName(), physics.getX(), physics.getY(), physics.getZ());
   final SaveThread thread = ((SaveThread) ThreadRegistry.get(physics.getWorld().getName()));
   if (thread != null) {
     thread.remove(physics.getLocation(), (SimpleSprout) sprout);
   }
   if (sprout == null) {
     return;
   }
   event.setCancelled(true);
   physics.setType(Material.AIR);
   ((SpoutBlock) physics).setCustomBlock(null);
   if (!sprout.getRequiredTools().isEmpty()) {
     disperseDrops(sprout, physics, false);
   }
 }
 @Override
 public void onBlockPhysics(BlockPhysicsEvent event) {
   if (!manager.allowPhysics(event.getBlock())) {
     event.setCancelled(true);
   }
 }