Пример #1
0
  @EventHandler(priority = EventPriority.HIGH) // , ignoreCancelled = true
  public void onBlockPlace(final BlockPlaceEvent event) {
    Block b = event.getBlock();

    if (PlotManager.isPlotWorld(b)) {
      Player p = event.getPlayer();
      boolean canbuild = PlotMe.cPerms(p, "plotme.admin.buildanywhere");
      String id = PlotManager.getPlotId(b.getLocation());

      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(b).DaysToExpiration);
        }
      }
    }
  }
Пример #2
0
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onPlayerEggThrow(final PlayerEggThrowEvent event) {
    Location l = event.getEgg().getLocation();

    if (PlotManager.isPlotWorld(l)) {
      Player p = event.getPlayer();
      boolean canbuild = PlotMe.cPerms(p, "plotme.admin.buildanywhere");
      String id = PlotManager.getPlotId(l);

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

        if (plot == null) {
          if (!canbuild) {
            p.sendMessage(PlotMe.caption("ErrCannotUseEggs"));
            event.setHatching(false);
          }
        } else if (!plot.isAllowed(p.getName())) {
          if (!canbuild) {
            p.sendMessage(PlotMe.caption("ErrCannotUseEggs"));
            event.setHatching(false);
          }
        }
      }
    }
  }
Пример #3
0
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
    Location l = event.getRightClicked().getLocation();

    if (PlotManager.isPlotWorld(l)) {
      Player p = event.getPlayer();
      boolean canbuild = PlotMe.cPerms(p, "plotme.admin.buildanywhere");
      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);
        }
      }
    }
  }
Пример #4
0
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
    if (!PlotMe.cPerms(event.getPlayer(), "plotme.admin.buildanywhere")) {
      Block b = event.getBlockClicked();
      if (PlotManager.isPlotWorld(b)) {
        String id = PlotManager.getPlotId(b.getLocation());
        Player p = event.getPlayer();

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

          if (plot == null) {
            p.sendMessage(PlotMe.caption("ErrCannotBuild"));
            event.setCancelled(true);
          } else if (!plot.isAllowed(p.getName())) {
            p.sendMessage(PlotMe.caption("ErrCannotBuild"));
            event.setCancelled(true);
          }
        }
      }
    }
  }
Пример #5
0
  @SuppressWarnings("deprecation")
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onPlayerInteract(final PlayerInteractEvent event) {
    Block b = event.getClickedBlock();

    if (PlotManager.isPlotWorld(b)) {
      PlotMapInfo pmi = PlotManager.getMap(b);
      boolean blocked = false;
      Player player = event.getPlayer();
      boolean canbuild = PlotMe.cPerms(player, "plotme.admin.buildanywhere");

      if (event.isBlockInHand() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        BlockFace face = event.getBlockFace();
        Block builtblock =
            b.getWorld()
                .getBlockAt(
                    b.getX() + face.getModX(),
                    b.getY() + face.getModY(),
                    b.getZ() + face.getModZ());

        String id = PlotManager.getPlotId(builtblock.getLocation());

        Player p = event.getPlayer();

        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(b).DaysToExpiration);
            }
          }
        }
      } else {
        /*for(int blockid : pmi.ProtectedBlocks)
        {
        	if(blockid == b.getTypeId())
        	{
        		if(!PlotMe.cPerms(player, "plotme.unblock." + blockid))
        			blocked = true;

        		break;
        	}
        }*/

        if (pmi.ProtectedBlocks.contains(b.getTypeId())) {
          if (!PlotMe.cPerms(player, "plotme.unblock." + b.getTypeId())) blocked = true;
        }

        ItemStack is = event.getItem();

        if (is != null && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
          int itemid = is.getType().getId();
          byte itemdata = is.getData().getData();

          if (pmi.PreventedItems.contains("" + itemid)
              || pmi.PreventedItems.contains("" + itemid + ":" + itemdata)) {
            if (!PlotMe.cPerms(player, "plotme.unblock." + itemid)) blocked = true;
          }
        }

        if (blocked) {
          String id = PlotManager.getPlotId(b.getLocation());

          Player p = event.getPlayer();

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

            if (plot == null) {
              if (!canbuild) {
                if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                  p.sendMessage(PlotMe.caption("ErrCannotUse"));
                }
                event.setCancelled(true);
              }
            } else if (!plot.isAllowed(p.getName())) {
              if (!canbuild) {
                if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                  p.sendMessage(PlotMe.caption("ErrCannotUse"));
                }
                event.setCancelled(true);
              }
            }
          }
        }
      }
    }
  }