Ejemplo n.º 1
0
  @Override
  public void Run(Player player, Server server, String[] args) {
    PlayerSettings settings = plugin.getPlayerSettings(player);

    settings.setFirstPosition(
        player
            .getTargetBlock(null, plugin.getWorldEditSettings().getMaxSelectionRange())
            .getLocation());

    if (settings.getSelection() == null) {
      player.sendMessage(formatMessage("First position is set!"));
    } else {
      player.sendMessage(
          formatMessage(
              "First position is set!(" + settings.getSelection().getBlocks().size() + " blocks)"));
    }
  }
Ejemplo n.º 2
0
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (player.getItemInHand().getType() == plugin.getWorldEditSettings().getWandMaterial()) {
      PlayerSettings settings = plugin.getPlayerSettings(player);

      if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
        settings.setFirstPosition(event.getClickedBlock().getLocation());

        if (settings.getSelection() == null) {
          player.sendMessage("First position is set!");
        } else {
          player.sendMessage(
              "First position is set!(" + settings.getSelection().getBlocks().size() + " blocks)");
        }

        event.setCancelled(true);
      } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        settings.setSecondPosition(event.getClickedBlock().getLocation());

        if (settings.getSelection() == null) {
          player.sendMessage("Second position is set!");
        } else {
          player.sendMessage(
              "Second position is set!(" + settings.getSelection().getBlocks().size() + " blocks)");
        }

        event.setCancelled(true);
      }
    }
  }