com.sk89q.worldedit.IncompleteRegionException Java Examples

The following examples show how to use com.sk89q.worldedit.IncompleteRegionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EllipsoidRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create a new selector from the given selector.
 *
 * @param oldSelector the old selector
 */
public EllipsoidRegionSelector(RegionSelector oldSelector) {
    this(checkNotNull(oldSelector).getIncompleteRegion().getWorld());
    if (oldSelector instanceof EllipsoidRegionSelector) {
        final EllipsoidRegionSelector ellipsoidRegionSelector = (EllipsoidRegionSelector) oldSelector;

        region = new EllipsoidRegion(ellipsoidRegionSelector.getIncompleteRegion());
    } else {
        Region oldRegion;
        try {
            oldRegion = oldSelector.getRegion();
        } catch (IncompleteRegionException e) {
            return;
        }

        BlockVector pos1 = oldRegion.getMinimumPoint().toBlockVector();
        BlockVector pos2 = oldRegion.getMaximumPoint().toBlockVector();

        Vector center = pos1.add(pos2).divide(2).floor();
        region.setCenter(center);
        region.setRadius(pos2.subtract(center));
    }
}
 
Example #2
Source File: CuboidRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create a copy of another selector.
 *
 * @param oldSelector another selector
 */
public CuboidRegionSelector(RegionSelector oldSelector) {
    this(checkNotNull(oldSelector).getIncompleteRegion().getWorld());

    if (oldSelector instanceof CuboidRegionSelector) {
        final CuboidRegionSelector cuboidRegionSelector = (CuboidRegionSelector) oldSelector;

        position1 = cuboidRegionSelector.position1;
        position2 = cuboidRegionSelector.position2;
    } else {
        final Region oldRegion;
        try {
            oldRegion = oldSelector.getRegion();
        } catch (IncompleteRegionException e) {
            return;
        }

        position1 = oldRegion.getMinimumPoint().toBlockVector();
        position2 = oldRegion.getMaximumPoint().toBlockVector();
    }
    region.setPos1(position1);
    region.setPos2(position2);
}
 
Example #3
Source File: FuzzyRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
    if (positions.isEmpty()) {
        throw new IncompleteRegionException();
    }
    return new BlockVector(positions.get(0));
}
 
Example #4
Source File: WorldEditHandler7_beta_4.java    From AreaShop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public WorldEditSelection getPlayerSelection(Player player) {
	try {
		Region region = pluginInterface.getWorldEdit().getSession(player).getSelection(BukkitAdapter.adapt(player.getWorld()));
		return new WorldEditSelection(
				player.getWorld(),
				BukkitAdapter.adapt(player.getWorld(), region.getMinimumPoint()),
				BukkitAdapter.adapt(player.getWorld(), region.getMaximumPoint())
		);
	} catch (IncompleteRegionException e) {
		return null;
	}
}
 
Example #5
Source File: FastAsyncWorldEditHandler.java    From AreaShop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public WorldEditSelection getPlayerSelection(Player player) {
	try {
		Region region = pluginInterface.getWorldEdit().getSession(player).getSelection(BukkitAdapter.adapt(player.getWorld()));
		return new WorldEditSelection(
				player.getWorld(),
				BukkitAdapter.adapt(player.getWorld(), region.getMinimumPoint()),
				BukkitAdapter.adapt(player.getWorld(), region.getMaximumPoint())
		);
	} catch (IncompleteRegionException e) {
		return null;
	}
}
 
Example #6
Source File: WorldEditHandler7_beta_1.java    From AreaShop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public WorldEditSelection getPlayerSelection(Player player) {
	try {
		Region region = pluginInterface.getWorldEdit().getSession(player).getSelection(BukkitAdapter.adapt(player.getWorld()));
		return new WorldEditSelection(
				player.getWorld(),
				BukkitAdapter.adapt(player.getWorld(), region.getMinimumPoint()),
				BukkitAdapter.adapt(player.getWorld(), region.getMaximumPoint())
		);
	} catch (IncompleteRegionException e) {
		return null;
	}
}
 
Example #7
Source File: MaskCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        aliases = {"#region", "#selection", "#sel"},
        desc = "inside the provided selection"
)
public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
    return new RegionMask(session.getSelection(player.getWorld()).clone());
}
 
Example #8
Source File: EllipsoidRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public EllipsoidRegion getRegion() throws IncompleteRegionException {
    if (!isDefined()) {
        throw new IncompleteRegionException();
    }

    return region;
}
 
Example #9
Source File: CuboidRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CuboidRegion getRegion() throws IncompleteRegionException {
    if (position1 == null || position2 == null) {
        throw new IncompleteRegionException();
    }

    return region;
}
 
Example #10
Source File: CuboidRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
    if (position1 == null) {
        throw new IncompleteRegionException();
    }

    return position1;
}
 
Example #11
Source File: ConvexPolyhedralRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Region getRegion() throws IncompleteRegionException {
    if (!region.isDefined()) {
        throw new IncompleteRegionException();
    }

    return region;
}
 
Example #12
Source File: ConvexPolyhedralRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new selector.
 *
 * @param oldSelector the old selector
 */
public ConvexPolyhedralRegionSelector(RegionSelector oldSelector) {
    checkNotNull(oldSelector);

    if (oldSelector instanceof ConvexPolyhedralRegionSelector) {
        final ConvexPolyhedralRegionSelector convexPolyhedralRegionSelector = (ConvexPolyhedralRegionSelector) oldSelector;

        pos1 = convexPolyhedralRegionSelector.pos1;
        region = new ConvexPolyhedralRegion(convexPolyhedralRegionSelector.region);
    } else {
        final Region oldRegion;
        try {
            oldRegion = oldSelector.getRegion();
        } catch (IncompleteRegionException e) {
            region = new ConvexPolyhedralRegion(oldSelector.getIncompleteRegion().getWorld());
            return;
        }

        final int minY = oldRegion.getMinimumPoint().getBlockY();
        final int maxY = oldRegion.getMaximumPoint().getBlockY();

        region = new ConvexPolyhedralRegion(oldRegion.getWorld());

        for (final BlockVector2D pt : new ArrayList<BlockVector2D>(oldRegion.polygonize(Integer.MAX_VALUE))) {
            region.addVertex(pt.toVector(minY));
            region.addVertex(pt.toVector(maxY));
        }

        learnChanges();
    }
}
 
Example #13
Source File: CylinderRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CylinderRegion getRegion() throws IncompleteRegionException {
    if (!isDefined()) {
        throw new IncompleteRegionException();
    }

    return region;
}
 
Example #14
Source File: CylinderRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
    if (!isDefined()) {
        throw new IncompleteRegionException();
    }

    return region.getCenter().toBlockVector();
}
 
Example #15
Source File: CylinderRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new selector from the given one.
 *
 * @param oldSelector the old selector
 */
public CylinderRegionSelector(RegionSelector oldSelector) {
    this(checkNotNull(oldSelector).getIncompleteRegion().getWorld());

    if (oldSelector instanceof CylinderRegionSelector) {
        final CylinderRegionSelector cylSelector = (CylinderRegionSelector) oldSelector;

        region = new CylinderRegion(cylSelector.region);
    } else {
        final Region oldRegion;
        try {
            oldRegion = oldSelector.getRegion();
        } catch (IncompleteRegionException e) {
            return;
        }

        Vector pos1 = oldRegion.getMinimumPoint();
        Vector pos2 = oldRegion.getMaximumPoint();

        Vector center = pos1.add(pos2).divide(2).floor();
        region.setCenter(center.toVector2D());
        region.setRadius(pos2.toVector2D().subtract(center.toVector2D()));

        region.setMaximumY(Math.max(pos1.getBlockY(), pos2.getBlockY()));
        region.setMinimumY(Math.min(pos1.getBlockY(), pos2.getBlockY()));
    }
}
 
Example #16
Source File: Polygonal2DRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Polygonal2DRegion getRegion() throws IncompleteRegionException {
    if (!isDefined()) {
        throw new IncompleteRegionException();
    }

    return region;
}
 
Example #17
Source File: Polygonal2DRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
    if (pos1 == null) {
        throw new IncompleteRegionException();
    }

    return pos1;
}
 
Example #18
Source File: PolyhedralRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Region getRegion() throws IncompleteRegionException {
    if (!region.isDefined()) {
        throw new IncompleteRegionException();
    }

    return region;
}
 
Example #19
Source File: WorldEditHelper.java    From WorldEditSelectionVisualizer with MIT License 5 votes vote down vote up
@Nullable
private Region getSelectedRegion(@Nullable LocalSession session) {
    if (session != null && session.getSelectionWorld() != null) {
        RegionSelector selector = session.getRegionSelector(session.getSelectionWorld());

        if (selector.isDefined()) {
            try {
                return selector.getRegion();
            } catch (IncompleteRegionException e) {
                plugin.getLogger().warning("Region still incomplete");
            }
        }
    }
    return null;
}
 
Example #20
Source File: ConvexPolyhedralRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
    return pos1;
}
 
Example #21
Source File: EllipsoidRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
    return region.getCenter().toBlockVector();
}
 
Example #22
Source File: PolyhedralRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
    return pos1;
}
 
Example #23
Source File: FuzzyRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Region getRegion() throws IncompleteRegionException {
    return region;
}
 
Example #24
Source File: DeathzoneCommands.java    From HeavySpleef with GNU General Public License v3.0 4 votes vote down vote up
@Command(name = "adddeathzone", permission = Permissions.PERMISSION_ADD_DEATHZONE, minArgs = 1,
		descref = Messages.Help.Description.ADDDEATHZONE,
		usage = "/spleef adddeathzone <Game> [Deathzone-Name]")
@PlayerOnly
public void onCommandAddDeathzone(CommandContext context, HeavySpleef heavySpleef) throws CommandException {
	SpleefPlayer player = heavySpleef.getSpleefPlayer(context.getSender());
	
	String gameName = context.getString(0);
	GameManager manager = heavySpleef.getGameManager();
	
	CommandValidate.isTrue(manager.hasGame(gameName), i18n.getVarString(Messages.Command.GAME_DOESNT_EXIST)
			.setVariable("game", gameName)
			.toString());
	Game game = manager.getGame(gameName);
	
	WorldEditPlugin plugin = (WorldEditPlugin) heavySpleef.getHookManager().getHook(HookReference.WORLDEDIT).getPlugin();
	com.sk89q.worldedit.entity.Player bukkitPlayer = plugin.wrapPlayer(player.getBukkitPlayer());
	World world = new BukkitWorld(player.getBukkitPlayer().getWorld());
	
	LocalSession session = plugin.getWorldEdit().getSessionManager().get(bukkitPlayer);
	RegionSelector selector = session.getRegionSelector(world);
	
	Region region;
	
	try {
		region = selector.getRegion().clone();
	} catch (IncompleteRegionException e) {
		player.sendMessage(i18n.getString(Messages.Command.DEFINE_FULL_WORLDEDIT_REGION));
		return;
	}
	
	validateSelectedRegion(region);
	
	String deathzoneName = context.argsLength() > 1 ? context.getString(1) : generateUniqueDeathzoneName(game);
	
	game.addDeathzone(deathzoneName, region);
	player.sendMessage(i18n.getVarString(Messages.Command.DEATHZONE_ADDED)
			.setVariable("deathzonename", deathzoneName)
			.toString());
	
	//Save the game
	heavySpleef.getDatabaseHandler().saveGame(game, null);
}
 
Example #25
Source File: WorldEditBinding.java    From FastAsyncWorldedit with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Gets a selection from a {@link ArgumentStack}.
 *
 * @param context the context
 * @param selection the annotation
 * @return a selection
 * @throws IncompleteRegionException if no selection is available
 * @throws ParameterException on other error
 */
@BindingMatch(classifier = Selection.class,
        type = Region.class,
        behavior = BindingBehavior.PROVIDES)
public Object getSelection(ArgumentStack context, Selection selection) throws IncompleteRegionException, ParameterException {
    Player sender = getPlayer(context);
    LocalSession session = worldEdit.getSessionManager().get(sender);
    return session.getSelection(FawePlayer.wrap(sender).getWorldForEditing());
}