Java源码示例:com.sk89q.worldedit.IncompleteRegionException
示例1
/**
* 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);
}
示例2
/**
* 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));
}
}
示例3
@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;
}
示例4
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
if (positions.isEmpty()) {
throw new IncompleteRegionException();
}
return new BlockVector(positions.get(0));
}
示例5
@Override
public Region getRegion() throws IncompleteRegionException {
if (!region.isDefined()) {
throw new IncompleteRegionException();
}
return region;
}
示例6
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
if (pos1 == null) {
throw new IncompleteRegionException();
}
return pos1;
}
示例7
@Override
public Polygonal2DRegion getRegion() throws IncompleteRegionException {
if (!isDefined()) {
throw new IncompleteRegionException();
}
return region;
}
示例8
/**
* 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()));
}
}
示例9
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
if (!isDefined()) {
throw new IncompleteRegionException();
}
return region.getCenter().toBlockVector();
}
示例10
@Override
public CylinderRegion getRegion() throws IncompleteRegionException {
if (!isDefined()) {
throw new IncompleteRegionException();
}
return region;
}
示例11
/**
* 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();
}
}
示例12
@Override
public Region getRegion() throws IncompleteRegionException {
if (!region.isDefined()) {
throw new IncompleteRegionException();
}
return region;
}
示例13
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
if (position1 == null) {
throw new IncompleteRegionException();
}
return position1;
}
示例14
@Override
public CuboidRegion getRegion() throws IncompleteRegionException {
if (position1 == null || position2 == null) {
throw new IncompleteRegionException();
}
return region;
}
示例15
@Override
public EllipsoidRegion getRegion() throws IncompleteRegionException {
if (!isDefined()) {
throw new IncompleteRegionException();
}
return region;
}
示例16
@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());
}
示例17
@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;
}
}
示例18
@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;
}
}
示例19
@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;
}
}
示例20
@Override
public Region getRegion() throws IncompleteRegionException {
return region;
}
示例21
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
return pos1;
}
示例22
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
return pos1;
}
示例23
@Override
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
return region.getCenter().toBlockVector();
}
示例24
@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);
}
示例25
/**
* 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());
}