From 8f694e62775b82324983fc776c209a1c28c376a5 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 14 Oct 2014 08:19:00 +0200 Subject: [PATCH] Fix circle claim and bump the max radius. --- .../factions/cmd/CmdFactionsSet.java | 1 - .../factions/cmd/CmdFactionsSetCircle.java | 22 ++++++++----------- .../factions/cmd/CmdFactionsSetSquare.java | 16 ++++++-------- .../massivecraft/factions/entity/MConf.java | 2 +- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSet.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSet.java index d15ec448..8c712c08 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSet.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSet.java @@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; -import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; public class CmdFactionsSet extends FactionsCommand diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java index aa1f457e..30f11019 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java @@ -36,26 +36,22 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius final PS chunk = PS.valueOf(me).getChunk(true); final Set chunks = new LinkedHashSet(); + chunks.add(chunk); // The center should come first for pretty messages + Integer radiusZero = this.getRadiusZero(); if (radiusZero == null) return null; - double radius = radiusZero + 1.5; // Tweak ze magic constant to get ze requested behavior. - double radiusSquared = radius * radius; + double radiusSquared = radiusZero * radiusZero; - chunks.add(chunk); // The center should come first for pretty messages - - final int xmin = chunk.getChunkX() - radiusZero; - final int xmax = chunk.getChunkX() + radiusZero; - final int zmin = chunk.getChunkZ() - radiusZero; - final int zmax = chunk.getChunkZ() + radiusZero; - - for (int x = xmin; x <= xmax; x++) + for (int dx = -radiusZero; dx <= radiusZero; dx++) { - for (int z = zmin; z <= zmax; z++) + for (int dz = -radiusZero; dz <= radiusZero; dz++) { - double dx = x - chunk.getChunkX(); - double dz = z - chunk.getChunkZ(); if (dx*dx + dz*dz > radiusSquared) continue; + + int x = chunk.getChunkX() + dx; + int z = chunk.getChunkZ() + dz; + chunks.add(chunk.withChunkX(x).withChunkZ(z)); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java index ac8e64ab..d40d440b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java @@ -36,20 +36,18 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius final PS chunk = PS.valueOf(me).getChunk(true); final Set chunks = new LinkedHashSet(); + chunks.add(chunk); // The center should come first for pretty messages + Integer radiusZero = this.getRadiusZero(); if (radiusZero == null) return null; - chunks.add(chunk); // The center should come first for pretty messages - - final int xmin = chunk.getChunkX() - radiusZero; - final int xmax = chunk.getChunkX() + radiusZero; - final int zmin = chunk.getChunkZ() - radiusZero; - final int zmax = chunk.getChunkZ() + radiusZero; - - for (int x = xmin; x <= xmax; x++) + for (int dx = -radiusZero; dx <= radiusZero; dx++) { - for (int z = zmin; z <= zmax; z++) + for (int dz = -radiusZero; dz <= radiusZero; dz++) { + int x = chunk.getChunkX() + dx; + int z = chunk.getChunkZ() + dz; + chunks.add(chunk.withChunkX(x).withChunkZ(z)); } } diff --git a/src/main/java/com/massivecraft/factions/entity/MConf.java b/src/main/java/com/massivecraft/factions/entity/MConf.java index ebd5fb0a..847b1ff6 100644 --- a/src/main/java/com/massivecraft/factions/entity/MConf.java +++ b/src/main/java/com/massivecraft/factions/entity/MConf.java @@ -151,7 +151,7 @@ public class MConf extends Entity // SET LIMITS // -------------------------------------------- // - public int setRadiusMax = 5; + public int setRadiusMax = 30; public int setFillMax = 1000; // -------------------------------------------- //