@EventHandler(priority = EventPriority.LOWEST)
  public void onLowestEntityInteract(EntityInteractEvent event) {
    if (event.isCancelled() || event == null) {
      return;
    }

    if (!(event.getEntity() instanceof Player)) {
      return;
    }

    Player player = (Player) event.getEntity();
    String name = player.getName().toLowerCase();

    if (instance.getCitizensCommunicator().isNPC(player, instance)
        || Utils.getInstance().isUnrestricted(player)
        || CombatTagComunicator.isNPC(player)) {
      return;
    }

    if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
      return;
    }

    if (!data.isAuthAvailable(name)) {
      if (!Settings.isForcedRegistrationEnabled) {
        return;
      }
    }
    event.setCancelled(true);
  }
 // 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);
   }
 }
Ejemplo n.º 3
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);
   }
 }
Ejemplo n.º 4
0
 @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);
   }
 }
Ejemplo n.º 5
0
 @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);
    }
  }