diff --git a/src/main/java/world/bentobox/chunkblock/Settings.java b/src/main/java/world/bentobox/chunkblock/Settings.java index 4defcee..381709d 100644 --- a/src/main/java/world/bentobox/chunkblock/Settings.java +++ b/src/main/java/world/bentobox/chunkblock/Settings.java @@ -116,13 +116,6 @@ public class Settings implements WorldSettings { @ConfigEntry(path = "chunkblock.levels-per-chunk") private int levelsPerChunk = 1; - @ConfigComment("Maximum number of chunks an island can claim, including the center chunk.") - @ConfigComment("441 chunks is a full 21 x 21 chunk square. Use -1 for no limit beyond what the") - @ConfigComment("island protection range can hold. The effective maximum is always capped so") - @ConfigComment("claimed chunks fit inside the protection range.") - @ConfigEntry(path = "chunkblock.max-chunks") - private int maxChunks = 441; - @ConfigComment("Require confirmation before level credit is spent on a chunk. When true, the") @ConfigComment("first hit on the border previews the target chunk and its cost; the player") @ConfigComment("must then sneak and hit the border again to actually claim it. This stops a") @@ -313,8 +306,8 @@ public class Settings implements WorldSettings { @ConfigComment("Default protection range radius in blocks. Cannot be larger than distance.") @ConfigComment("Admins can change protection sizes for players individually using /chadmin range set ") @ConfigComment("or set this permission: chunkblock.island.range.") - @ConfigComment("ChunkBlock: this must cover the largest unlockable ring of chunks (see chunkblock.max-chunks).") - @ConfigComment("With max-chunks 441 (21x21, ring 10) the minimum needed is 168.") + @ConfigComment("ChunkBlock: the protection range determines how many chunks can be claimed.") + @ConfigComment("With range 168 the largest ring is 10, giving a 21x21 = 441 chunk square.") @ConfigEntry(path = "world.protection-range") private int islandProtectionRange = 168; @@ -2624,20 +2617,6 @@ public void setLevelsPerChunk(int levelsPerChunk) { this.levelsPerChunk = levelsPerChunk; } - /** - * @return the configured maximum number of unlockable chunks including the center; -1 means unlimited - */ - public int getMaxChunks() { - return maxChunks; - } - - /** - * @param maxChunks the maxChunks to set - */ - public void setMaxChunks(int maxChunks) { - this.maxChunks = maxChunks; - } - /** * @return true if ring milestones are announced to the whole server */ diff --git a/src/main/java/world/bentobox/chunkblock/chunks/ChunkManager.java b/src/main/java/world/bentobox/chunkblock/chunks/ChunkManager.java index f461f73..930bd17 100644 --- a/src/main/java/world/bentobox/chunkblock/chunks/ChunkManager.java +++ b/src/main/java/world/bentobox/chunkblock/chunks/ChunkManager.java @@ -50,7 +50,7 @@ public enum ClaimResult { ALREADY_UNLOCKED, /** The chunk does not touch the island's unlocked territory */ NOT_ADJACENT, - /** The chunk is outside the island's protection range or over max-chunks */ + /** The chunk is outside the island's protection range */ BEYOND_LIMIT, /** Not enough level credit */ NO_CREDIT @@ -301,9 +301,7 @@ public ClaimResult checkGeometry(Island island, int chunkX, int chunkZ) { if (data.isChunkUnlocked(dx, dz)) { return ClaimResult.ALREADY_UNLOCKED; } - if (Math.max(Math.abs(dx), Math.abs(dz)) > maxRingRadius(island) - || (addon.getSettings().getMaxChunks() >= 0 - && data.getUnlockedChunkCount() >= addon.getSettings().getMaxChunks())) { + if (Math.max(Math.abs(dx), Math.abs(dz)) > maxRingRadius(island)) { return ClaimResult.BEYOND_LIMIT; } // Must share a face with territory the island already owns @@ -379,18 +377,15 @@ public int maxRingRadius(Island island) { } /** - * Returns the effective maximum number of chunks this island can unlock: the - * configured max-chunks, additionally capped by what fits inside the island's - * protection range. + * Returns the maximum number of chunks this island can unlock, determined by + * what fits inside the island's protection range. * * @param island the island * @return the maximum unlockable chunk count, always >= 1 */ public int getMaxChunks(Island island) { int rangeRadius = maxRingRadius(island); - int rangeCap = (2 * rangeRadius + 1) * (2 * rangeRadius + 1); - int configured = addon.getSettings().getMaxChunks(); - return Math.max(1, configured < 0 ? rangeCap : Math.min(configured, rangeCap)); + return Math.max(1, (2 * rangeRadius + 1) * (2 * rangeRadius + 1)); } /** diff --git a/src/main/java/world/bentobox/chunkblock/listeners/LevelListener.java b/src/main/java/world/bentobox/chunkblock/listeners/LevelListener.java index 81e1ef1..3144218 100644 --- a/src/main/java/world/bentobox/chunkblock/listeners/LevelListener.java +++ b/src/main/java/world/bentobox/chunkblock/listeners/LevelListener.java @@ -191,9 +191,6 @@ public void celebrateClaim(Island island, int chunkX, int chunkZ, @Nullable UUID user.sendMessage("chunkblock.chunks.claimed", TextVariables.NAME, claimerName, "[number]", String.valueOf(count), "[credit]", String.valueOf(creditLeft)); - if (count >= cm.getMaxChunks(island)) { - user.sendMessage("chunkblock.chunks.max-reached", "[number]", String.valueOf(count)); - } user.getPlayer().playSound(user.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F); } }); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 74192ec..48b7c83 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -51,11 +51,6 @@ chunkblock: # Island levels are chunk currency: credit = island level minus levels already # spent. The island owner spends credit by hitting the border where they want to expand. levels-per-chunk: 1 - # Maximum number of chunks an island can claim, including the center chunk. - # 441 chunks is a full 21 x 21 chunk square. Use -1 for no limit beyond what the - # island protection range can hold. The effective maximum is always capped so - # claimed chunks fit inside the protection range. - max-chunks: 441 claim: # Require confirmation before level credit is spent on a chunk. When true, the # first hit on the border previews the target chunk and its cost; the player diff --git a/src/test/java/world/bentobox/chunkblock/chunks/ChunkManagerTest.java b/src/test/java/world/bentobox/chunkblock/chunks/ChunkManagerTest.java index 8a6680c..2a75be2 100644 --- a/src/test/java/world/bentobox/chunkblock/chunks/ChunkManagerTest.java +++ b/src/test/java/world/bentobox/chunkblock/chunks/ChunkManagerTest.java @@ -133,15 +133,6 @@ void testClaimBeyondProtectionRangeDenied() { assertEquals(ClaimResult.BEYOND_LIMIT, cm.claim(island, 3, 0)); } - @Test - void testClaimBeyondMaxChunksDenied() { - level = 100000; - settings.setMaxChunks(3); - assertEquals(ClaimResult.OK, cm.claim(island, 1, 0)); - assertEquals(ClaimResult.OK, cm.claim(island, -1, 0)); - assertEquals(ClaimResult.BEYOND_LIMIT, cm.claim(island, 0, 1)); - } - @Test void testLevelsPerChunkCost() { settings.setLevelsPerChunk(10); @@ -210,13 +201,15 @@ void testOffsetIslandCenter() { } @Test - void testMaxChunksCappedByProtectionRange() { - assertEquals(441, cm.getMaxChunks(island)); + void testMaxChunksDerivedFromProtectionRange() { + // Default setup: protectionRange=240, maxRingRadius=(240-8)/16=14, (2*14+1)^2=841 + assertEquals(841, cm.getMaxChunks(island)); when(island.getProtectionRange()).thenReturn(50); + // (50-8)/16=2, (2*2+1)^2=25 assertEquals(25, cm.getMaxChunks(island)); - settings.setMaxChunks(-1); - when(island.getProtectionRange()).thenReturn(240); - assertEquals(841, cm.getMaxChunks(island)); + when(island.getProtectionRange()).thenReturn(168); + // (168-8)/16=10, (2*10+1)^2=441 + assertEquals(441, cm.getMaxChunks(island)); } @Test