@EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerBreakHanging(HangingBreakByEntityEvent event) {
    if (event.isCancelled()) return;

    if (event.getRemover() instanceof Player) {
      final Player player = (Player) event.getRemover();
      final Entity entity = event.getEntity();

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

      if (entity != null && !plugin.canBuildOnLocation(player, entity.getLocation()))
        event.setCancelled(true);

      plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
    }
  }
Ejemplo n.º 2
0
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onHangingBreakByEntity(final HangingBreakByEntityEvent event) {
    Entity entity = event.getRemover();

    if (entity instanceof Player) {
      Player p = (Player) entity;

      boolean canbuild = PlotMe.cPerms(p, "plotme.admin.buildanywhere");

      Location l = event.getEntity().getLocation();

      if (PlotManager.isPlotWorld(l)) {
        String id = PlotManager.getPlotId(l);

        if (id.equalsIgnoreCase("")) {
          if (!canbuild) {
            p.sendMessage(PlotMe.caption("ErrCannotBuild"));
            event.setCancelled(true);
          }
        } else {
          Plot plot = PlotManager.getPlotById(p, id);

          if (plot == null) {
            if (!canbuild) {
              p.sendMessage(PlotMe.caption("ErrCannotBuild"));
              event.setCancelled(true);
            }
          } else if (!plot.isAllowed(p.getName())) {
            if (!canbuild) {
              p.sendMessage(PlotMe.caption("ErrCannotBuild"));
              event.setCancelled(true);
            }
          } else {
            plot.resetExpire(PlotManager.getMap(l).DaysToExpiration);
          }
        }
      }
    }
  }
Ejemplo n.º 3
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void event(HangingBreakByEntityEvent event) {

    if (event.getEntity() instanceof ItemFrame || event.getEntity() instanceof Painting) {

      Hanging hanging = event.getEntity();

      if (event.getRemover() instanceof Player) {

        Player player = (Player) event.getRemover();

        if (usingMagicHoe(player)) {

          if (!player.hasPermission("umagic.usage")) {
            event.setCancelled(true);
            return;
          }

          if (!player.getGameMode().equals(GameMode.SURVIVAL)) {
            event.setCancelled(true);
            return;
          }

          hanging.setMetadata(metaFram, new FixedMetadataValue(getPlugin(), true));
          saveMetadata(hanging.getLocation(), metaFram);

          hanging.getWorld().playSound(hanging.getLocation(), Sound.UI_BUTTON_CLICK, 0.75f, 0.75f);
          event.setCancelled(true);

        } else if (hanging.hasMetadata(metaFram)) {

          hanging.removeMetadata(metaFram, getPlugin());
          removeMetadata(hanging.getLocation());
        }
      }
    }
  }
Ejemplo n.º 4
0
  @EventHandler(priority = EventPriority.HIGH)
  public void paintingFrameBreak(HangingBreakByEntityEvent event) {
    org.bukkit.entity.Entity victim = event.getEntity();
    org.bukkit.entity.Entity remover = event.getRemover();
    OwnedLand land = OwnedLand.getApplicableLand(victim.getLocation());
    if (land == null) {
      return;
    }
    if (remover.getType().toString().equals("PLAYER")) {
      Player p = (Player) remover;
      if (!land.hasPermTo(p, this)) {
        p.sendMessage(
            ChatColor.RED + getPlugin().getMessageConfig().getString("event.build.hangingBreak"));
        event.setCancelled(true);
      }
      // System.out.println("Attacker Name:" + p.getName());

    }
  }