Ejemplo n.º 1
0
  @Override
  public boolean importWorldeditSelection() {
    LocalSession worldeditsession =
        getSelection().getPlugin().getWorldEdit().getSession(getPlayer());
    if (worldeditsession == null) {
      return false;
    }

    Region region;
    try {
      region = worldeditsession.getSelection(worldeditsession.getSelectionWorld());
    } catch (IncompleteRegionException e) {
      return false;
    }

    if (!(region instanceof com.sk89q.worldedit.regions.Polygonal2DRegion)) {
      // getPlayer().sendMessage(ChatColor.RED + "Your worldedit selection is invalid type.");
      return false;
    }

    com.sk89q.worldedit.regions.Polygonal2DRegion npolysel =
        (com.sk89q.worldedit.regions.Polygonal2DRegion) region;
    clearPoints();
    for (BlockVector2D vec : npolysel.getPoints()) {
      addPoint(new ZoneVertice(vec.getBlockX(), vec.getBlockZ()));
    }
    setHeight(
        new ZoneVertice(
            npolysel.getMinimumPoint().getBlockY(), npolysel.getMaximumPoint().getBlockY()),
        true);

    return true;
  }
Ejemplo n.º 2
0
  /**
   * Gets the region selection for the player.
   *
   * @param player
   * @return the selection or null if there was none
   */
  public Selection getSelection(Player player) {
    if (player == null) {
      throw new IllegalArgumentException("Null player not allowed");
    }
    if (!player.isOnline()) {
      throw new IllegalArgumentException("Offline player not allowed");
    }

    LocalSession session = controller.getSession(wrapPlayer(player));
    RegionSelector selector =
        session.getRegionSelector(BukkitUtil.getLocalWorld(player.getWorld()));

    try {
      Region region = selector.getRegion();
      World world = ((BukkitWorld) session.getSelectionWorld()).getWorld();

      if (region instanceof CuboidRegion) {
        return new CuboidSelection(world, selector, (CuboidRegion) region);
      } else if (region instanceof Polygonal2DRegion) {
        return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
      } else {
        return null;
      }
    } catch (IncompleteRegionException e) {
      return null;
    }
  }