mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Added back old region selector classes as deprecated.
This commit is contained in:
parent
8722104565
commit
3294431e00
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
/**
|
||||
* Get the number of points.
|
||||
*
|
||||
* @return the number of points
|
||||
*/
|
||||
public abstract int getPointCount();
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
@ -24,90 +24,89 @@ import com.sk89q.worldedit.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Region selection factory.
|
||||
*
|
||||
* @author sk89q
|
||||
* Region selectors create {@link Region}s from a series of "selected points."
|
||||
* They are used, for example, to allow users to create a {@link CuboidRegion}
|
||||
* by selecting two corners of the cuboid.
|
||||
*/
|
||||
public interface RegionSelector {
|
||||
|
||||
/**
|
||||
* Called when the first point is selected.
|
||||
*
|
||||
* @param pos
|
||||
* @param position the position
|
||||
* @return true if something changed
|
||||
*/
|
||||
public boolean selectPrimary(Vector pos);
|
||||
public boolean selectPrimary(Vector position);
|
||||
|
||||
/**
|
||||
* Called when the second point is selected.
|
||||
*
|
||||
* @param pos
|
||||
* @param position the position
|
||||
* @return true if something changed
|
||||
*/
|
||||
public boolean selectSecondary(Vector pos);
|
||||
public boolean selectSecondary(Vector position);
|
||||
|
||||
/**
|
||||
* Tell the player information about his/her primary selection.
|
||||
*
|
||||
* @param player
|
||||
* @param session
|
||||
* @param pos
|
||||
* @param player the player
|
||||
* @param session the session
|
||||
* @param position position
|
||||
*/
|
||||
public void explainPrimarySelection(LocalPlayer player,
|
||||
LocalSession session, Vector pos);
|
||||
public void explainPrimarySelection(LocalPlayer player, LocalSession session, Vector position);
|
||||
|
||||
/**
|
||||
* Tell the player information about his/her secondary selection.
|
||||
*
|
||||
* @param player
|
||||
* @param session
|
||||
* @param pos
|
||||
* @param player the player
|
||||
* @param session the session
|
||||
* @param position position
|
||||
*/
|
||||
public void explainSecondarySelection(LocalPlayer player,
|
||||
LocalSession session, Vector pos);
|
||||
public void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector position);
|
||||
|
||||
/**
|
||||
* The the player information about the region's changes. This may resend
|
||||
* all the defining region information if needed.
|
||||
*
|
||||
* @param player
|
||||
* @param session
|
||||
* @param player the player
|
||||
* @param session the session
|
||||
*/
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session);
|
||||
|
||||
/**
|
||||
* Get the primary position.
|
||||
*
|
||||
* @return
|
||||
* @throws IncompleteRegionException
|
||||
* @return the primary position
|
||||
* @throws IncompleteRegionException thrown if a region has not been fully defined
|
||||
*/
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException;
|
||||
|
||||
/**
|
||||
* Get the selection.
|
||||
*
|
||||
* @return
|
||||
* @throws IncompleteRegionException
|
||||
* @return the created region
|
||||
* @throws IncompleteRegionException thrown if a region has not been fully defined
|
||||
*/
|
||||
public Region getRegion() throws IncompleteRegionException;
|
||||
|
||||
/**
|
||||
* Get the region even if it's not fully defined.
|
||||
*
|
||||
* @return
|
||||
* @return an incomplete region object that is incomplete
|
||||
*/
|
||||
public Region getIncompleteRegion();
|
||||
|
||||
/**
|
||||
* Returns whether the region has been fully defined.
|
||||
*
|
||||
* @return
|
||||
* @return true if a selection is available
|
||||
*/
|
||||
public boolean isDefined();
|
||||
|
||||
/**
|
||||
* Get the number of blocks inside the region.
|
||||
*
|
||||
* @return number of blocks or -1 if undefined
|
||||
* @return number of blocks, or -1 if undefined
|
||||
*/
|
||||
public int getArea();
|
||||
|
||||
@ -124,14 +123,15 @@ public interface RegionSelector {
|
||||
/**
|
||||
* Get a lowercase name of this region selector type.
|
||||
*
|
||||
* @return
|
||||
* @return a lower case name of the type
|
||||
*/
|
||||
public String getTypeName();
|
||||
|
||||
/**
|
||||
* Get lines of information about the selection.
|
||||
*
|
||||
* @return
|
||||
* @return a list of lines describing the region
|
||||
*/
|
||||
public List<String> getInformationLines();
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -15,22 +15,11 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
@ -41,17 +30,40 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.polyhedron.Triangle;
|
||||
|
||||
public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* A {@link RegionSelector} for {@link ConvexPolyhedralRegion}s.
|
||||
*/
|
||||
public class ConvexPolyhedralRegionSelector extends com.sk89q.worldedit.regions.ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
private int maxVertices;
|
||||
private final ConvexPolyhedralRegion region;
|
||||
private BlockVector pos1;
|
||||
|
||||
public ConvexPolyhedralRegionSelector(LocalWorld world, int maxVertices) {
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
* @param maxVertices the maximum number of vertices, where a number below 0 means unbounded
|
||||
*/
|
||||
public ConvexPolyhedralRegionSelector(@Nullable LocalWorld world, int maxVertices) {
|
||||
this.maxVertices = maxVertices;
|
||||
region = new ConvexPolyhedralRegion(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param oldSelector the old selector
|
||||
* @param maxVertices the maximum number of vertices, where a number below 0 means unbounded
|
||||
*/
|
||||
public ConvexPolyhedralRegionSelector(RegionSelector oldSelector, int maxVertices) {
|
||||
checkNotNull(oldSelector);
|
||||
|
||||
this.maxVertices = maxVertices;
|
||||
if (oldSelector instanceof ConvexPolyhedralRegionSelector) {
|
||||
final ConvexPolyhedralRegionSelector convexPolyhedralRegionSelector = (ConvexPolyhedralRegionSelector) oldSelector;
|
||||
@ -219,4 +231,5 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
session.dispatchCUIEvent(player, new SelectionShapeEvent(getLegacyTypeID()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -15,44 +15,55 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Selector for cuboids.
|
||||
*
|
||||
* @author sk89q
|
||||
* A {@link RegionSelector} for {@link CuboidRegion}s.
|
||||
*/
|
||||
public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class CuboidRegionSelector extends com.sk89q.worldedit.regions.CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected BlockVector pos1;
|
||||
protected BlockVector pos2;
|
||||
protected CuboidRegion region;
|
||||
|
||||
public CuboidRegionSelector(LocalWorld world) {
|
||||
region = new CuboidRegion(world, new Vector(), new Vector());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new region selector with no world.
|
||||
*/
|
||||
public CuboidRegionSelector() {
|
||||
this((LocalWorld) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new region selector.
|
||||
*
|
||||
* @param world the world
|
||||
*/
|
||||
public CuboidRegionSelector(@Nullable LocalWorld world) {
|
||||
region = new CuboidRegion(world, new Vector(), new Vector());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of another selector.
|
||||
*
|
||||
* @param oldSelector another selector
|
||||
*/
|
||||
public CuboidRegionSelector(RegionSelector oldSelector) {
|
||||
this(oldSelector.getIncompleteRegion().getWorld());
|
||||
this(checkNotNull(oldSelector).getIncompleteRegion().getWorld());
|
||||
if (oldSelector instanceof CuboidRegionSelector) {
|
||||
final CuboidRegionSelector cuboidRegionSelector = (CuboidRegionSelector) oldSelector;
|
||||
|
||||
@ -74,14 +85,25 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
region.setPos2(pos2);
|
||||
}
|
||||
|
||||
public CuboidRegionSelector(LocalWorld world, Vector pos1, Vector pos2) {
|
||||
/**
|
||||
* Create a new region selector with the given two positions.
|
||||
*
|
||||
* @param world the world
|
||||
* @param pos1 position 1
|
||||
* @param pos2 position 2
|
||||
*/
|
||||
public CuboidRegionSelector(@Nullable LocalWorld world, Vector pos1, Vector pos2) {
|
||||
this(world);
|
||||
checkNotNull(world);
|
||||
checkNotNull(pos1);
|
||||
checkNotNull(pos2);
|
||||
this.pos1 = pos1.toBlockVector();
|
||||
this.pos2 = pos2.toBlockVector();
|
||||
region.setPos1(pos1);
|
||||
region.setPos2(pos2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector pos) {
|
||||
if (pos1 != null && (pos.compareTo(pos1) == 0)) {
|
||||
return false;
|
||||
@ -92,6 +114,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector pos) {
|
||||
if (pos2 != null && (pos.compareTo(pos2)) == 0) {
|
||||
return false;
|
||||
@ -102,6 +125,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(LocalPlayer player, LocalSession session, Vector pos) {
|
||||
if (pos1 != null && pos2 != null) {
|
||||
player.print("First position set to " + pos1 + " (" + region.getArea() + ").");
|
||||
@ -112,6 +136,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getArea()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector pos) {
|
||||
if (pos1 != null && pos2 != null) {
|
||||
player.print("Second position set to " + pos2 + " (" + region.getArea() + ").");
|
||||
@ -122,6 +147,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
if (pos1 != null) {
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos1, getArea()));
|
||||
@ -132,6 +158,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
if (pos1 == null) {
|
||||
throw new IncompleteRegionException();
|
||||
@ -140,10 +167,12 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return pos1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefined() {
|
||||
return pos1 != null && pos2 != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CuboidRegion getRegion() throws IncompleteRegionException {
|
||||
if (pos1 == null || pos2 == null) {
|
||||
throw new IncompleteRegionException();
|
||||
@ -152,24 +181,29 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CuboidRegion getIncompleteRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void learnChanges() {
|
||||
pos1 = region.getPos1().toBlockVector();
|
||||
pos2 = region.getPos2().toBlockVector();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
pos1 = null;
|
||||
pos2 = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "cuboid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInformationLines() {
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
|
||||
@ -184,6 +218,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArea() {
|
||||
if (pos1 == null) {
|
||||
return -1;
|
||||
@ -196,6 +231,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return region.getArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeCUI(LocalSession session, LocalPlayer player) {
|
||||
if (pos1 != null) {
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos1, getArea()));
|
||||
@ -206,18 +242,22 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeLegacyCUI(LocalSession session, LocalPlayer player) {
|
||||
describeCUI(session, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeID() {
|
||||
return "cuboid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTypeID() {
|
||||
return "cuboid";
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -15,36 +15,28 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionCylinderEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionMinMaxEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.internal.cui.*;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Selector for polygonal regions.
|
||||
*
|
||||
* @author sk89q
|
||||
* A {@link RegionSelector} for {@link CylinderRegion}s.
|
||||
*/
|
||||
public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class CylinderRegionSelector extends com.sk89q.worldedit.regions.CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected CylinderRegion region;
|
||||
protected static final NumberFormat format;
|
||||
|
||||
@ -53,12 +45,22 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
format.setMaximumFractionDigits(3);
|
||||
}
|
||||
|
||||
public CylinderRegionSelector(LocalWorld world) {
|
||||
/**
|
||||
* Create a new region selector.
|
||||
*
|
||||
* @param world the world
|
||||
*/
|
||||
public CylinderRegionSelector(@Nullable LocalWorld world) {
|
||||
region = new CylinderRegion(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new selector from the given one.
|
||||
*
|
||||
* @param oldSelector the old selector
|
||||
*/
|
||||
public CylinderRegionSelector(RegionSelector oldSelector) {
|
||||
this(oldSelector.getIncompleteRegion().getWorld());
|
||||
this(checkNotNull(oldSelector).getIncompleteRegion().getWorld());
|
||||
if (oldSelector instanceof CylinderRegionSelector) {
|
||||
final CylinderRegionSelector cylSelector = (CylinderRegionSelector) oldSelector;
|
||||
|
||||
@ -83,7 +85,16 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
}
|
||||
|
||||
public CylinderRegionSelector(LocalWorld world, Vector2D center, Vector2D radius, int minY, int maxY) {
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
* @param center the center
|
||||
* @param radius the radius
|
||||
* @param minY the minimum Y
|
||||
* @param maxY the maximum Y
|
||||
*/
|
||||
public CylinderRegionSelector(@Nullable LocalWorld world, Vector2D center, Vector2D radius, int minY, int maxY) {
|
||||
this(world);
|
||||
|
||||
region.setCenter(center);
|
||||
@ -93,6 +104,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
region.setMaximumY(Math.max(minY, maxY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector pos) {
|
||||
if (!region.getCenter().equals(Vector.ZERO) && pos.compareTo(region.getCenter()) == 0) {
|
||||
return false;
|
||||
@ -105,6 +117,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector pos) {
|
||||
Vector center = region.getCenter();
|
||||
if ((center.compareTo(Vector.ZERO)) == 0) {
|
||||
@ -120,12 +133,14 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(LocalPlayer player, LocalSession session, Vector pos) {
|
||||
player.print("Starting a new cylindrical selection at " + pos + ".");
|
||||
|
||||
session.describeCUI(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector pos) {
|
||||
Vector center = region.getCenter();
|
||||
if (!center.equals(Vector.ZERO)) {
|
||||
@ -138,10 +153,12 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
session.describeCUI(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
session.describeCUI(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
if (!isDefined()) {
|
||||
throw new IncompleteRegionException();
|
||||
@ -150,6 +167,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
return region.getCenter().toBlockVector();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CylinderRegion getRegion() throws IncompleteRegionException {
|
||||
if (!isDefined()) {
|
||||
throw new IncompleteRegionException();
|
||||
@ -158,25 +176,31 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CylinderRegion getIncompleteRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefined() {
|
||||
return !region.getRadius().equals(Vector2D.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void learnChanges() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
region = new CylinderRegion(region.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Cylinder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInformationLines() {
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
|
||||
@ -190,15 +214,18 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArea() {
|
||||
return region.getArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeCUI(LocalSession session, LocalPlayer player) {
|
||||
session.dispatchCUIEvent(player, new SelectionCylinderEvent(region.getCenter(), region.getRadius()));
|
||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeLegacyCUI(LocalSession session, LocalPlayer player) {
|
||||
if (isDefined()) {
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getArea()));
|
||||
@ -208,15 +235,19 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeID() {
|
||||
return "cylinder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTypeID() {
|
||||
return "cuboid";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -15,18 +15,11 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionEllipsoidPointEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
@ -34,24 +27,42 @@ import com.sk89q.worldedit.regions.EllipsoidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Selector for ellipsoids.
|
||||
*
|
||||
* @author TomyLobo
|
||||
* A {@link RegionSelector} for {@link EllipsoidRegion}s.
|
||||
*/
|
||||
public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected EllipsoidRegion region;
|
||||
|
||||
public EllipsoidRegionSelector(LocalWorld world) {
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
*/
|
||||
public EllipsoidRegionSelector(@Nullable LocalWorld world) {
|
||||
region = new EllipsoidRegion(world, new Vector(), new Vector());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new selector.
|
||||
*/
|
||||
public EllipsoidRegionSelector() {
|
||||
this((LocalWorld) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new selector from the given selector.
|
||||
*
|
||||
* @param oldSelector the old selector
|
||||
*/
|
||||
public EllipsoidRegionSelector(RegionSelector oldSelector) {
|
||||
this(oldSelector.getIncompleteRegion().getWorld());
|
||||
this(checkNotNull(oldSelector).getIncompleteRegion().getWorld());
|
||||
if (oldSelector instanceof EllipsoidRegionSelector) {
|
||||
final EllipsoidRegionSelector ellipsoidRegionSelector = (EllipsoidRegionSelector) oldSelector;
|
||||
|
||||
@ -73,13 +84,21 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
}
|
||||
|
||||
public EllipsoidRegionSelector(LocalWorld world, Vector center, Vector radius) {
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
* @param center the center
|
||||
* @param radius the radius
|
||||
*/
|
||||
public EllipsoidRegionSelector(@Nullable LocalWorld world, Vector center, Vector radius) {
|
||||
this(world);
|
||||
|
||||
region.setCenter(center);
|
||||
region.setRadius(radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector pos) {
|
||||
if (pos.equals(region.getCenter()) && region.getRadius().lengthSq() == 0) {
|
||||
return false;
|
||||
@ -90,6 +109,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector pos) {
|
||||
final Vector diff = pos.subtract(region.getCenter());
|
||||
final Vector minRadius = Vector.getMaximum(diff, diff.multiply(-1.0));
|
||||
@ -97,6 +117,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(LocalPlayer player, LocalSession session, Vector pos) {
|
||||
if (isDefined()) {
|
||||
player.print("Center position set to " + region.getCenter() + " (" + region.getArea() + ").");
|
||||
@ -107,6 +128,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
session.describeCUI(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector pos) {
|
||||
if (isDefined()) {
|
||||
player.print("Radius set to " + region.getRadius() + " (" + region.getArea() + ").");
|
||||
@ -117,14 +139,17 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
session.describeCUI(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
session.describeCUI(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefined() {
|
||||
return region.getRadius().lengthSq() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EllipsoidRegion getRegion() throws IncompleteRegionException {
|
||||
if (!isDefined()) {
|
||||
throw new IncompleteRegionException();
|
||||
@ -133,22 +158,27 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EllipsoidRegion getIncompleteRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void learnChanges() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
region.setCenter(new Vector());
|
||||
region.setRadius(new Vector());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "ellipsoid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInformationLines() {
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
|
||||
@ -165,28 +195,34 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArea() {
|
||||
return region.getArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeCUI(LocalSession session, LocalPlayer player) {
|
||||
session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(0, region.getCenter()));
|
||||
session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(1, region.getRadius()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeLegacyCUI(LocalSession session, LocalPlayer player) {
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getArea()));
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getArea()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTypeID() {
|
||||
return "cuboid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeID() {
|
||||
return "ellipsoid";
|
||||
}
|
||||
@ -195,4 +231,5 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
return region.getCenter().toBlockVector();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -15,27 +15,36 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Alternative selector for cuboids.
|
||||
*
|
||||
* @author sk89q
|
||||
* A {@link RegionSelector} for {@link CuboidRegion}s that enlarges the
|
||||
* region with every secondary selection.
|
||||
*/
|
||||
public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
public ExtendingCuboidRegionSelector(LocalWorld world) {
|
||||
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
*/
|
||||
public ExtendingCuboidRegionSelector(@Nullable LocalWorld world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new selector from another one.
|
||||
*
|
||||
* @param oldSelector the other selector
|
||||
*/
|
||||
public ExtendingCuboidRegionSelector(RegionSelector oldSelector) {
|
||||
super(oldSelector);
|
||||
|
||||
@ -49,7 +58,14 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
region.setPos2(pos2);
|
||||
}
|
||||
|
||||
public ExtendingCuboidRegionSelector(LocalWorld world, Vector pos1, Vector pos2) {
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
* @param pos1 the first position
|
||||
* @param pos2 the second position
|
||||
*/
|
||||
public ExtendingCuboidRegionSelector(@Nullable LocalWorld world, Vector pos1, Vector pos2) {
|
||||
this(world);
|
||||
pos1 = Vector.getMinimum(pos1, pos2);
|
||||
pos2 = Vector.getMaximum(pos1, pos2);
|
||||
@ -114,4 +130,5 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
|
||||
explainRegionAdjust(player, session);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -15,19 +15,11 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionMinMaxEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPoint2DEvent;
|
||||
@ -36,33 +28,56 @@ import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Selector for polygonal regions.
|
||||
*
|
||||
* @author sk89q
|
||||
* A {@link RegionSelector} for {@link Polygonal2DRegion}s.
|
||||
*/
|
||||
public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class Polygonal2DRegionSelector extends com.sk89q.worldedit.regions.Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
private int maxPoints;
|
||||
private BlockVector pos1;
|
||||
private Polygonal2DRegion region;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #Polygonal2DRegionSelector(LocalWorld, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Polygonal2DRegionSelector(LocalWorld world) {
|
||||
public Polygonal2DRegionSelector(@Nullable LocalWorld world) {
|
||||
this(world, 50);
|
||||
}
|
||||
|
||||
public Polygonal2DRegionSelector(LocalWorld world, int maxPoints) {
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
* @param maxPoints the maximum number of points
|
||||
*/
|
||||
public Polygonal2DRegionSelector(@Nullable LocalWorld world, int maxPoints) {
|
||||
this.maxPoints = maxPoints;
|
||||
region = new Polygonal2DRegion(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #Polygonal2DRegionSelector(RegionSelector, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Polygonal2DRegionSelector(RegionSelector oldSelector) {
|
||||
this(oldSelector, 50);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new selector from another one.
|
||||
*
|
||||
* @param oldSelector the old selector
|
||||
* @param maxPoints the maximum number of points
|
||||
*/
|
||||
public Polygonal2DRegionSelector(RegionSelector oldSelector, int maxPoints) {
|
||||
this(oldSelector.getIncompleteRegion().getWorld(), maxPoints);
|
||||
this(checkNotNull(oldSelector).getIncompleteRegion().getWorld(), maxPoints);
|
||||
if (oldSelector instanceof Polygonal2DRegionSelector) {
|
||||
final Polygonal2DRegionSelector polygonal2DRegionSelector = (Polygonal2DRegionSelector) oldSelector;
|
||||
|
||||
@ -86,12 +101,23 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
}
|
||||
|
||||
public Polygonal2DRegionSelector(LocalWorld world, List<BlockVector2D> points, int minY, int maxY) {
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
* @param points a list of points
|
||||
* @param minY the minimum Y
|
||||
* @param maxY the maximum Y
|
||||
*/
|
||||
public Polygonal2DRegionSelector(@Nullable LocalWorld world, List<BlockVector2D> points, int minY, int maxY) {
|
||||
checkNotNull(points);
|
||||
|
||||
final BlockVector2D pos2D = points.get(0);
|
||||
pos1 = new BlockVector(pos2D.getX(), minY, pos2D.getZ());
|
||||
region = new Polygonal2DRegion(world, points, minY, maxY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector pos) {
|
||||
if (pos.equals(pos1)) {
|
||||
return false;
|
||||
@ -105,6 +131,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector pos) {
|
||||
if (region.size() > 0) {
|
||||
final List<BlockVector2D> points = region.getPoints();
|
||||
@ -125,6 +152,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(LocalPlayer player, LocalSession session, Vector pos) {
|
||||
player.print("Starting a new polygon at " + pos + ".");
|
||||
|
||||
@ -133,6 +161,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector pos) {
|
||||
player.print("Added point #" + region.size() + " at " + pos + ".");
|
||||
|
||||
@ -140,11 +169,13 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
|
||||
describeCUI(session, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
if (pos1 == null) {
|
||||
throw new IncompleteRegionException();
|
||||
@ -153,6 +184,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
return pos1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygonal2DRegion getRegion() throws IncompleteRegionException {
|
||||
if (!isDefined()) {
|
||||
throw new IncompleteRegionException();
|
||||
@ -161,40 +193,54 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygonal2DRegion getIncompleteRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefined() {
|
||||
return region.size() > 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void learnChanges() {
|
||||
BlockVector2D pt = region.getPoints().get(0);
|
||||
pos1 = new BlockVector(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
pos1 = null;
|
||||
region = new Polygonal2DRegion(region.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "2Dx1D polygon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInformationLines() {
|
||||
return Collections.singletonList("# points: " + region.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArea() {
|
||||
return region.getArea();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of points.
|
||||
*
|
||||
* @return the number of points
|
||||
*/
|
||||
@Override
|
||||
public int getPointCount() {
|
||||
return region.getPoints().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeCUI(LocalSession session, LocalPlayer player) {
|
||||
final List<BlockVector2D> points = region.getPoints();
|
||||
for (int id = 0; id < points.size(); id++) {
|
||||
@ -204,19 +250,24 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeLegacyCUI(LocalSession session, LocalPlayer player) {
|
||||
describeCUI(session, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeID() {
|
||||
return "polygon2d";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTypeID() {
|
||||
return "polygon2d";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
@ -25,20 +25,34 @@ import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Selector for spheres.
|
||||
*
|
||||
* @author TomyLobo
|
||||
* A {@link RegionSelector} for {@link SphereRegionSelector}s.
|
||||
*/
|
||||
public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
public SphereRegionSelector(LocalWorld world) {
|
||||
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
*/
|
||||
public SphereRegionSelector(@Nullable LocalWorld world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new selector.
|
||||
*/
|
||||
public SphereRegionSelector() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new selector from another one
|
||||
*
|
||||
* @param oldSelector the old selector
|
||||
*/
|
||||
public SphereRegionSelector(RegionSelector oldSelector) {
|
||||
super(oldSelector);
|
||||
final Vector radius = region.getRadius();
|
||||
@ -46,7 +60,14 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
|
||||
}
|
||||
|
||||
public SphereRegionSelector(LocalWorld world, Vector center, int radius) {
|
||||
/**
|
||||
* Create a new selector.
|
||||
*
|
||||
* @param world the world
|
||||
* @param center the center position
|
||||
* @param radius the radius
|
||||
*/
|
||||
public SphereRegionSelector(@Nullable LocalWorld world, Vector center, int radius) {
|
||||
super(world, center, new Vector(radius, radius, radius));
|
||||
}
|
||||
|
||||
@ -73,4 +94,5 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
public String getTypeName() {
|
||||
return "sphere";
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user