// don't allow entities to trample crops
 @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
 public void onEntityInteract(EntityInteractEvent event) {
   if (!GriefPrevention.instance.config_creaturesTrampleCrops
       && event.getBlock().getType() == Material.SOIL) {
     event.setCancelled(true);
   }
 }
示例#2
0
 @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
 public void onEntityInteract(EntityInteractEvent event) {
   // Prevent trampling from other Entities
   final Material mat = event.getBlock().getType();
   final Entity entity = event.getEntity();
   // TODO: Placement source is generic, not limited to soil or soulsand
   if (entity instanceof LivingEntity && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
     event.setCancelled(true);
   }
 }
 @EventHandler(priority = EventPriority.NORMAL)
 public void onEntityInteract(EntityInteractEvent event) {
   Block block = event.getBlock();
   Material mat = block.getType();
   Entity entity = event.getEntity();
   FlagPermissions perms = Residence.getPermsByLoc(block.getLocation());
   boolean hastrample = perms.has("trample", perms.has("hasbuild", true));
   if (!hastrample
       && !(entity.getType() == EntityType.FALLING_BLOCK)
       && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
     event.setCancelled(true);
   }
 }
 @EventHandler(priority = EventPriority.LOWEST)
 public void onEntityInteract(EntityInteractEvent event) {
   Block block = event.getBlock();
   Material mat = block.getType();
   Entity entity = event.getEntity();
   if ((entity.getType() == EntityType.FALLING_BLOCK)
       || !(mat == Material.SOIL || mat == Material.SOUL_SAND)) {
     return;
   }
   if (!AllowAction.allowAction(block.getLocation(), FlagManager.TRAMPLE)) {
     event.setCancelled(true);
   }
 }
  @EventHandler
  public void onEntityInteract(EntityInteractEvent event) {
    if (!(event.getEntity() instanceof Player)) {
      return;
    }

    if (event.getBlock().getType() != Material.SOIL
        && event.getBlock().getType() != Material.WHEAT) {
      return;
    }

    Player player = (Player) event.getEntity();
    Game game = Main.getInstance().getGameManager().getGameOfPlayer(player);

    if (game == null) {
      return;
    }

    if (game.getState() == GameState.WAITING) {
      event.setCancelled(true);
    }
  }