Example #1
0
  public void a(Packet7UseEntity packet7useentity) {
    // CraftBukkit start
    if (this.player.dead) {
      return;
    }
    // CraftBukkit end

    WorldServer worldserver = this.minecraftServer.a(this.player.dimension);
    Entity entity = worldserver.getEntity(packet7useentity.target);

    if (entity != null && this.player.e(entity) && this.player.g(entity) < 36.0D) {
      if (packet7useentity.c == 0) {
        // CraftBukkit start
        PlayerInteractEntityEvent piee =
            new PlayerInteractEntityEvent((Player) getPlayer(), entity.getBukkitEntity());
        server.getPluginManager().callEvent(piee);
        if (piee.isCancelled()) {
          return;
        }
        // CraftBukkit end
        this.player.c(entity);
      } else if (packet7useentity.c == 1) {
        this.player.d(entity);
      }
    }
  }
 @EventHandler
 public void entityInteractEvent(PlayerInteractEntityEvent event) {
   if (!event.isCancelled() && event.getRightClicked() != null) {
     boolean allowed =
         protectionManager.CanUseItem(
             event.getPlayer(), event.getPlayer().getLocation(), ItemType.Item);
     if (!allowed) event.setCancelled(true);
   }
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();
    final Entity e = event.getRightClicked();

    if (player.getWorld() != plugin.getIslandWorld()) return;
    if (player.isOp()) return;
    if (player.hasPermission("islandworld.bypass.island")) return;

    if (e instanceof Vehicle) {
      if (!(plugin.getConfig().getBoolean("flags.use-vehicle", false)
          || plugin.canBuildOnLocation(player, e.getLocation()))) event.setCancelled(true);
    } else {
      if (e != null && !plugin.canBuildOnLocation(player, e.getLocation()))
        event.setCancelled(true);
    }

    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }