From 2a4e6ac93a4a3dda9f87194220e5c1cc204b0d14 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Fri, 16 Aug 2013 08:16:37 +0200 Subject: [PATCH] Added a separate point maximum for polyhedral selections. --- .../java/com/sk89q/worldedit/LocalConfiguration.java | 2 ++ src/main/java/com/sk89q/worldedit/WorldEdit.java | 12 ++++++++++++ .../sk89q/worldedit/commands/SelectionCommands.java | 2 +- .../worldedit/util/PropertiesConfiguration.java | 2 ++ .../com/sk89q/worldedit/util/YAMLConfiguration.java | 3 +++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index 2540ab792..916826646 100644 --- a/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -84,6 +84,8 @@ public abstract class LocalConfiguration { public int maxChangeLimit = -1; public int defaultMaxPolygonalPoints = -1; public int maxPolygonalPoints = 20; + public int defaultMaxPolyhedronPoints = -1; + public int maxPolyhedronPoints = 20; public String shellSaveType = ""; public SnapshotRepository snapshotRepo = null; public int maxRadius = -1; diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 5c0782adb..0d5656d3e 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -905,6 +905,18 @@ public class WorldEdit { } } + public int getMaximumPolyhedronPoints(LocalPlayer player) { + if (player.hasPermission("worldedit.limit.unrestricted") || config.maxPolyhedronPoints < 0) { + return config.defaultMaxPolyhedronPoints; + } else { + if (config.defaultMaxPolyhedronPoints < 0) { + return config.maxPolyhedronPoints; + } + return Math.min(config.defaultMaxPolyhedronPoints, + config.maxPolyhedronPoints); + } + } + /** * Checks to see if the specified radius is within bounds. * diff --git a/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java b/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java index ac2080918..16c5de53f 100644 --- a/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java @@ -768,7 +768,7 @@ public class SelectionCommands { selector = new CylinderRegionSelector(oldSelector); player.print("Cylindrical selector: Left click=center, right click to extend."); } else if (typeName.equalsIgnoreCase("convex") || typeName.equalsIgnoreCase("hull") || typeName.equalsIgnoreCase("polyhedron")) { - int maxVertices = we.getMaximumPolygonalPoints(player); // TODO: separate maximum for polyhedra + int maxVertices = we.getMaximumPolyhedronPoints(player); selector = new ConvexPolyhedralRegionSelector(oldSelector, maxVertices); player.print("Convex polyhedral selector: Left click=First vertex, right click to add more."); } else { diff --git a/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index e25fc3aaf..491b57d1a 100644 --- a/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -83,6 +83,8 @@ public class PropertiesConfiguration extends LocalConfiguration { maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit); defaultMaxPolygonalPoints = getInt("default-max-polygon-points", defaultMaxPolygonalPoints); maxPolygonalPoints = getInt("max-polygon-points", maxPolygonalPoints); + defaultMaxPolyhedronPoints = getInt("default-max-polyhedron-points", defaultMaxPolyhedronPoints); + maxPolyhedronPoints = getInt("max-polyhedron-points", maxPolyhedronPoints); shellSaveType = getString("shell-save-type", shellSaveType); maxRadius = getInt("max-radius", maxRadius); maxSuperPickaxeSize = getInt("max-super-pickaxe-size", maxSuperPickaxeSize); diff --git a/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index d640fc644..c616f9754 100644 --- a/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -65,6 +65,9 @@ public class YAMLConfiguration extends LocalConfiguration { maxPolygonalPoints = Math.max(-1, config.getInt("limits.max-polygonal-points.maximum", maxPolygonalPoints)); + defaultMaxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.default", defaultMaxPolyhedronPoints)); + maxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.maximum", maxPolyhedronPoints)); + maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius)); maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius); maxSuperPickaxeSize = Math.max(1, config.getInt(