From 33adba4a6f2c7868a462c65528ca35e84f698a59 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Mon, 8 Jun 2020 05:50:17 -0400 Subject: [PATCH] Use a long to refer to the volume of a region to prevent overflow (#1350) * Use a long to refer to the volume of a region, and rename the method to getVolume * Fixed issues noted in review * Forgot to floor * Fixed review notes * Can use a long here rather than BigDecimal * Improve javadocs * style (cherry picked from commit 328030fd6281e58a4ea1d0cdd0a2e274da90afbe) --- .../bukkit/util/CommandRegistration.java | 21 ++++--- .../cache/preloader/AsyncPreloader.java | 2 +- .../processors/LimitExtent.java | 58 +++++++++---------- .../com/boydti/fawe/object/FaweLimit.java | 7 +++ .../regions/selector/FuzzyRegionSelector.java | 6 +- .../worldedit/command/ClipboardCommands.java | 2 +- .../worldedit/command/ExpandCommands.java | 12 ++-- .../worldedit/command/SelectionCommands.java | 6 +- .../platform/AbstractPlayerActor.java | 5 +- .../internal/cui/SelectionPoint2DEvent.java | 18 +++++- .../internal/cui/SelectionPointEvent.java | 9 ++- .../worldedit/regions/AbstractRegion.java | 20 +++---- .../worldedit/regions/CylinderRegion.java | 14 ++++- .../worldedit/regions/EllipsoidRegion.java | 18 ++++-- .../sk89q/worldedit/regions/NullRegion.java | 2 +- .../worldedit/regions/Polygonal2DRegion.java | 18 ++++-- .../com/sk89q/worldedit/regions/Region.java | 30 +++++++++- .../worldedit/regions/RegionSelector.java | 25 +++++++- .../worldedit/regions/TransformRegion.java | 4 +- .../ConvexPolyhedralRegionSelector.java | 10 ++-- .../selector/CuboidRegionSelector.java | 20 +++---- .../selector/CylinderRegionSelector.java | 10 ++-- .../selector/EllipsoidRegionSelector.java | 12 ++-- .../ExtendingCuboidRegionSelector.java | 4 +- .../selector/Polygonal2DRegionSelector.java | 10 ++-- .../selector/SphereRegionSelector.java | 2 +- .../session/request/RequestSelection.java | 4 +- 27 files changed, 225 insertions(+), 124 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java index 079e14a29..f5daf2fc9 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java @@ -20,11 +20,6 @@ package com.sk89q.bukkit.util; import com.sk89q.util.ReflectionUtil; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -33,6 +28,12 @@ import org.bukkit.command.PluginIdentifiableCommand; import org.bukkit.command.SimpleCommandMap; import org.bukkit.plugin.Plugin; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + public class CommandRegistration { static { @@ -61,6 +62,7 @@ public class CommandRegistration { } return null; } + public boolean register(List registered) { CommandMap commandMap = getCommandMap(); if (registered == null || commandMap == null) { @@ -82,12 +84,13 @@ public class CommandRegistration { if (fallbackCommands != null) { return fallbackCommands; } + CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap"); if (commandMap == null) { - Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() + - ": Could not retrieve server CommandMap, using fallback instead!"); - fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer()); - Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin); + Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() + + ": Could not retrieve server CommandMap, using fallback instead!"); + fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer()); + Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin); } else { serverCommandMap = commandMap; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/AsyncPreloader.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/AsyncPreloader.java index 9154248f3..31745548d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/AsyncPreloader.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/AsyncPreloader.java @@ -50,7 +50,7 @@ public class AsyncPreloader implements Preloader, Runnable { MutablePair> existing = cancelAndGet(player); try { Region region = session.getSelection(world); - if (!(region instanceof CuboidRegion) || region.getArea() > 50466816) { + if (!(region instanceof CuboidRegion) || region.getVolume() > 50466816) { // TOO LARGE or NOT CUBOID return; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java index 1c59fc96d..6e3b13281 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java @@ -52,7 +52,7 @@ public class LimitExtent extends PassthroughExtent { @Override public List getEntities(Region region) { - limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); try { return getExtent().getEntities(region); } catch (FaweException e) { @@ -223,8 +223,8 @@ public class LimitExtent extends PassthroughExtent { @Override public void addCaves(Region region) throws WorldEditException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { getExtent().addCaves(region); } catch (FaweException e) { @@ -236,8 +236,8 @@ public class LimitExtent extends PassthroughExtent { @Override public void generate(Region region, GenBase gen) throws WorldEditException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { getExtent().generate(region, gen); } catch (FaweException e) { @@ -249,8 +249,8 @@ public class LimitExtent extends PassthroughExtent { @Override public void addSchems(Region region, Mask mask, List clipboards, int rarity, boolean rotate) throws WorldEditException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { getExtent().addSchems(region, mask, clipboards, rarity, rotate); } catch (FaweException e) { @@ -262,8 +262,8 @@ public class LimitExtent extends PassthroughExtent { @Override public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { getExtent().spawnResource(region, gen, rarity, frequency); } catch (FaweException e) { @@ -275,8 +275,8 @@ public class LimitExtent extends PassthroughExtent { @Override public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { getExtent().addOre(region, mask, material, size, frequency, rarity, minY, maxY); } catch (FaweException e) { @@ -288,8 +288,8 @@ public class LimitExtent extends PassthroughExtent { @Override public void addOres(Region region, Mask mask) throws WorldEditException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { getExtent().addOres(region, mask); } catch (FaweException e) { @@ -301,7 +301,7 @@ public class LimitExtent extends PassthroughExtent { @Override public List> getBlockDistribution(Region region) { - limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); try { return getExtent().getBlockDistribution(region); } catch (FaweException e) { @@ -314,7 +314,7 @@ public class LimitExtent extends PassthroughExtent { @Override public List> getBlockDistributionWithData(Region region) { - limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); try { return getExtent().getBlockDistributionWithData(region); } catch (FaweException e) { @@ -327,7 +327,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int countBlocks(Region region, Set searchBlocks) { - limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); try { return getExtent().countBlocks(region, searchBlocks); } catch (FaweException e) { @@ -340,7 +340,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int countBlocks(Region region, Mask searchMask) { - limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); try { return getExtent().countBlocks(region, searchMask); } catch (FaweException e) { @@ -353,7 +353,7 @@ public class LimitExtent extends PassthroughExtent { @Override public > int setBlocks(Region region, B block) throws MaxChangedBlocksException { - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { return getExtent().setBlocks(region, block); } catch (FaweException e) { @@ -366,7 +366,7 @@ public class LimitExtent extends PassthroughExtent { @Override public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException { - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { return getExtent().setBlocks(region, pattern); } catch (FaweException e) { @@ -379,8 +379,8 @@ public class LimitExtent extends PassthroughExtent { @Override public > int replaceBlocks(Region region, Set filter, B replacement) throws MaxChangedBlocksException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { return getExtent().replaceBlocks(region, filter, replacement); } catch (FaweException e) { @@ -393,8 +393,8 @@ public class LimitExtent extends PassthroughExtent { @Override public int replaceBlocks(Region region, Set filter, Pattern pattern) throws MaxChangedBlocksException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { return getExtent().replaceBlocks(region, filter, pattern); } catch (FaweException e) { @@ -407,8 +407,8 @@ public class LimitExtent extends PassthroughExtent { @Override public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { return getExtent().replaceBlocks(region, mask, pattern); } catch (FaweException e) { @@ -421,8 +421,8 @@ public class LimitExtent extends PassthroughExtent { @Override public int center(Region region, Pattern pattern) throws MaxChangedBlocksException { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { return getExtent().center(region, pattern); } catch (FaweException e) { @@ -448,8 +448,8 @@ public class LimitExtent extends PassthroughExtent { @Override public T apply(Region region, T filter, boolean full) { - limit.THROW_MAX_CHECKS(region.getArea()); - limit.THROW_MAX_CHANGES(region.getArea()); + limit.THROW_MAX_CHECKS(region.getVolume()); + limit.THROW_MAX_CHANGES(region.getVolume()); try { return getExtent().apply(region, filter, full); } catch (FaweException e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java index d3f366538..9b67bb819 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java @@ -162,6 +162,9 @@ public class FaweLimit { public void THROW_MAX_CHANGES(int amt) { if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES; } + public void THROW_MAX_CHANGES(long amt) { + if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES; + } public void THROW_MAX_FAILS(int amt) { if ((MAX_FAILS -= amt) <= 0) throw FaweCache.MAX_CHECKS; @@ -171,6 +174,10 @@ public class FaweLimit { if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS; } + public void THROW_MAX_CHECKS(long amt) { + if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS; + } + public void THROW_MAX_ITERATIONS(int amt) { if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.MAX_ITERATIONS; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java index 031ae7d4b..b9a348126 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java @@ -87,14 +87,12 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele @Override public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) { - int size = this.region.getArea(); - player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getArea() + ")")); + player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getVolume() + ")")); } @Override public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) { - int size = this.region.getArea(); - player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getArea() + ")")); + player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getVolume() + ")")); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 59817d210..cf57ae922 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -176,7 +176,7 @@ public class ClipboardCommands { lazyClipboard.setOrigin(session.getPlacementPosition(actor)); session.setClipboard(new ClipboardHolder(lazyClipboard)); - actor.print(Caption.of("fawe.worldedit.copy.command.copy" , region.getArea())); + actor.print(Caption.of("fawe.worldedit.copy.command.copy" , region.getVolume())); } // @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java index 96910e63f..6cfd12ef4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java @@ -104,14 +104,14 @@ public class ExpandCommands { private static void expandVert(LocalSession session, Actor actor, World world) throws IncompleteRegionException { Region region = session.getSelection(world); try { - int oldSize = region.getArea(); + long oldSize = region.getVolume(); region.expand( BlockVector3.at(0, (world.getMaxY() + 1), 0), BlockVector3.at(0, -(world.getMaxY() + 1), 0)); session.getRegionSelector(world).learnChanges(); - int newSize = region.getArea(); + long newSize = region.getVolume(); session.getRegionSelector(world).explainRegionAdjust(actor, session); - int changeSize = newSize - oldSize; + long changeSize = newSize - oldSize; actor.printInfo( TranslatableComponent.of("worldedit.expand.expanded.vert", TextComponent.of(changeSize)) ); @@ -134,7 +134,7 @@ public class ExpandCommands { @MultiDirection List direction) throws WorldEditException { Region region = session.getSelection(world); - int oldSize = region.getArea(); + long oldSize = region.getVolume(); if (reverseAmount == 0) { for (BlockVector3 dir : direction) { @@ -147,11 +147,11 @@ public class ExpandCommands { } session.getRegionSelector(world).learnChanges(); - int newSize = region.getArea(); + long newSize = region.getVolume(); session.getRegionSelector(world).explainRegionAdjust(actor, session); - int changeSize = newSize - oldSize; + long changeSize = newSize - oldSize; actor.printInfo(TranslatableComponent.of("worldedit.expand.expanded", TextComponent.of(changeSize))); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index 89cdbf862..12a5fce77 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -339,7 +339,7 @@ public class SelectionCommands { List direction) throws WorldEditException { try { Region region = session.getSelection(world); - int oldSize = region.getArea(); + long oldSize = region.getVolume(); if (reverseAmount == 0) { for (BlockVector3 dir : direction) { region.contract(dir.multiply(amount)); @@ -350,7 +350,7 @@ public class SelectionCommands { } } session.getRegionSelector(world).learnChanges(); - int newSize = region.getArea(); + long newSize = region.getVolume(); session.getRegionSelector(world).explainRegionAdjust(actor, session); @@ -501,7 +501,7 @@ public class SelectionCommands { actor.printInfo(TranslatableComponent.of("worldedit.size.size", TextComponent.of(size.toString()))); actor.printInfo(TranslatableComponent.of("worldedit.size.distance", TextComponent.of(region.getMaximumPoint().distance(region.getMinimumPoint())))); - actor.printInfo(TranslatableComponent.of("worldedit.size.blocks", TextComponent.of(region.getArea()))); + actor.printInfo(TranslatableComponent.of("worldedit.size.blocks", TextComponent.of(region.getVolume()))); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index afa19ab77..040c5bb74 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.extension.platform; -import com.boydti.fawe.config.Caption; import com.boydti.fawe.object.task.AsyncNotifyQueue; import com.sk89q.worldedit.EditSession; @@ -701,10 +700,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { * @return */ public Region getLargestRegion() { - int area = 0; + long area = 0; Region max = null; for (Region region : this.getCurrentRegions()) { - final int tmp = region.getArea(); + final long tmp = region.getVolume(); if (tmp > area) { area = tmp; max = region; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java index 1586dced9..a80791b32 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java @@ -27,8 +27,9 @@ public class SelectionPoint2DEvent implements CUIEvent { protected final int id; protected final int blockX; protected final int blockZ; - protected final int area; + protected final long area; + @Deprecated public SelectionPoint2DEvent(int id, BlockVector2 pos, int area) { this.id = id; this.blockX = pos.getX(); @@ -36,6 +37,7 @@ public class SelectionPoint2DEvent implements CUIEvent { this.area = area; } + @Deprecated public SelectionPoint2DEvent(int id, BlockVector3 pos, int area) { this.id = id; this.blockX = pos.getX(); @@ -43,6 +45,20 @@ public class SelectionPoint2DEvent implements CUIEvent { this.area = area; } + public SelectionPoint2DEvent(int id, BlockVector2 pos, long area) { + this.id = id; + this.blockX = pos.getX(); + this.blockZ = pos.getZ(); + this.area = area; + } + + public SelectionPoint2DEvent(int id, BlockVector3 pos, long area) { + this.id = id; + this.blockX = pos.getX(); + this.blockZ = pos.getZ(); + this.area = area; + } + @Override public String getTypeId() { return "p2"; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java index baac3ab1f..777a32770 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java @@ -25,14 +25,21 @@ public class SelectionPointEvent implements CUIEvent { protected final int id; protected final BlockVector3 pos; - protected final int area; + protected final long area; + @Deprecated public SelectionPointEvent(int id, BlockVector3 pos, int area) { this.id = id; this.pos = pos; this.area = area; } + public SelectionPointEvent(int id, BlockVector3 pos, long area) { + this.id = id; + this.pos = pos; + this.area = area; + } + @Override public String getTypeId() { return "p"; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java index 03fad6968..0cdd5348a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.regions; import com.boydti.fawe.object.collection.BlockVectorSet; +import com.google.common.primitives.Longs; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; @@ -44,7 +45,7 @@ public abstract class AbstractRegion extends AbstractSet implement @Override public int size() { - return getArea(); + return com.google.common.primitives.Ints.saturatedCast(getVolume()); } @Override @@ -106,19 +107,14 @@ public abstract class AbstractRegion extends AbstractSet implement return points; } - /** - * Get the number of blocks in the region. - * - * @return number of blocks - */ @Override - public int getArea() { + public long getVolume() { BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - return (max.getX() - min.getX() + 1) * - (max.getY() - min.getY() + 1) * - (max.getZ() - min.getZ() + 1); + return (max.getX() - min.getX() + 1L) * + (max.getY() - min.getY() + 1L) * + (max.getZ() - min.getZ() + 1L); } /** @@ -218,7 +214,7 @@ public abstract class AbstractRegion extends AbstractSet implement int result = worldHash ^ (worldHash >>> 32); result = 31 * result + this.getMinimumPoint().hashCode(); result = 31 * result + this.getMaximumPoint().hashCode(); - result = 31 * result + this.getArea(); + result = (int) (31 * result + this.getVolume()); return result; } @@ -239,7 +235,7 @@ public abstract class AbstractRegion extends AbstractSet implement if(this.getWorld().equals(region.getWorld()) && this.getMinimumPoint().equals(region.getMinimumPoint()) && this.getMaximumPoint().equals(region.getMaximumPoint()) - && this.getArea() == region.getArea()){ + && this.getVolume() == region.getVolume()){ return true; } return false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java index a682f48c4..faf78b7f7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java @@ -35,6 +35,9 @@ import com.sk89q.worldedit.math.geom.Polygons; import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator; import com.sk89q.worldedit.regions.iterator.FlatRegionIterator; import com.sk89q.worldedit.world.World; + +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.Iterator; import java.util.List; @@ -196,9 +199,16 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { return minY; } + private static final BigDecimal PI = BigDecimal.valueOf(Math.PI); + @Override - public int getArea() { - return (int) Math.floor(radius.getX() * radius.getZ() * Math.PI * getHeight()); + public long getVolume() { + return BigDecimal.valueOf(radius.getX()) + .multiply(BigDecimal.valueOf(radius.getZ())) + .multiply(PI) + .multiply(BigDecimal.valueOf(getHeight())) + .setScale(0, RoundingMode.FLOOR) + .longValue(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index aece100fc..273f642ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -32,6 +32,8 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.ChunkStore; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.HashSet; import java.util.Set; @@ -68,7 +70,7 @@ public class EllipsoidRegion extends AbstractRegion { /** * Construct a new instance of this ellipsoid region. * - * @param world the world + * @param world the world * @param center the center * @param radius the radius */ @@ -92,10 +94,16 @@ public class EllipsoidRegion extends AbstractRegion { return center.toVector3().add(getRadius()).toBlockPoint(); } + private static final BigDecimal ELLIPSOID_BASE_MULTIPLIER = BigDecimal.valueOf((4.0 / 3.0) * Math.PI); + @Override - public int getArea() { - return (int) Math - .floor((4.0 / 3.0) * Math.PI * radius.getX() * radius.getY() * radius.getZ()); + public long getVolume() { + return ELLIPSOID_BASE_MULTIPLIER + .multiply(BigDecimal.valueOf(radius.getX())) + .multiply(BigDecimal.valueOf(radius.getY())) + .multiply(BigDecimal.valueOf(radius.getZ())) + .setScale(0, RoundingMode.FLOOR) + .longValue(); } @Override @@ -118,7 +126,7 @@ public class EllipsoidRegion extends AbstractRegion { if ((diff.getBlockX() & 1) + (diff.getBlockY() & 1) + (diff.getBlockZ() & 1) != 0) { throw new RegionOperationException( - "Ellipsoid changes must be even for each dimensions."); + "Ellipsoid changes must be even for each dimensions."); } return diff.divide(2).floor(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java index 58e1d2197..7e8e19dfb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java @@ -53,7 +53,7 @@ public class NullRegion implements Region { } @Override - public int getArea() { + public long getVolume() { return 0; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java index d51f6e465..f6c94859a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java @@ -25,6 +25,8 @@ import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator; import com.sk89q.worldedit.regions.iterator.FlatRegionIterator; import com.sk89q.worldedit.world.World; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -197,18 +199,22 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { } @Override - public int getArea() { - double area = 0; + public long getVolume() { + long area = 0; int i, j = points.size() - 1; for (i = 0; i < points.size(); ++i) { - area += (points.get(j).getBlockX() + points.get(i).getBlockX()) - * (points.get(j).getBlockZ() - points.get(i).getBlockZ()); + long x = points.get(j).getBlockX() + points.get(i).getBlockX(); + long z = points.get(j).getBlockZ() - points.get(i).getBlockZ(); + area += x * z; j = i; } - return (int) Math.floor(Math.abs(area * 0.5) - * (maxY - minY + 1)); + return BigDecimal.valueOf(area) + .multiply(BigDecimal.valueOf(0.5)) + .abs() + .setScale(0, RoundingMode.FLOOR) + .longValue() * (maxY - minY + 1); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index ae7d3abe2..549faf501 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -32,8 +32,10 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.World; + import java.util.List; import java.util.Set; + import javax.annotation.Nullable; /** @@ -74,14 +76,40 @@ public interface Region extends Iterable, Cloneable, IBatchProcess * Get the number of blocks in the region. * * @return number of blocks + * @deprecated use {@link Region#getVolume()} to prevent overflows */ + @Deprecated default int getArea() { + return (int) getVolume(); + } + + /** + * Get the number of blocks in the region. + * + *

Note: This method must be overridden.

+ * + * @return number of blocks + */ + default long getVolume() { + // TODO Remove default status when getArea is removed. + try { + if (getClass().getMethod("getArea").getDeclaringClass().equals(Region.class)) { + throw new IllegalStateException("Class " + getClass().getName() + " must override getVolume."); + } + } catch (NoSuchMethodException e) { + throw new AssertionError(e); + } + return getArea(); + } + + /* FAWE code for getArea() before merge: + default int getArea() { BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); return (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1) * (max.getZ() - min.getZ() + 1); } - + */ /** * Get X-size. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java index e38f2a9c2..f607c5172 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java @@ -135,8 +135,31 @@ public interface RegionSelector { * Get the number of blocks inside the region. * * @return number of blocks, or -1 if undefined + * @deprecated use {@link RegionSelector#getVolume()} */ - int getArea(); + @Deprecated + default int getArea() { + return (int) getVolume(); + } + + /** + * Get the number of blocks inside the region. + * + *

Note: This method must be overridden.

+ * + * @return number of blocks, or -1 if undefined + */ + default long getVolume() { + // TODO Remove default once getArea is removed + try { + if (getClass().getMethod("getArea").getDeclaringClass().equals(RegionSelector.class)) { + throw new IllegalStateException("Class " + getClass().getName() + " must override getVolume."); + } + } catch (NoSuchMethodException e) { + throw new AssertionError(e); + } + return getArea(); + } /** * Update the selector with changes to the region. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java index 911e40b8b..733313421 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java @@ -113,8 +113,8 @@ public class TransformRegion extends AbstractRegion { } @Override - public int getArea() { - return region.getArea(); // Cannot transform this + public long getVolume() { + return region.getVolume(); // Cannot transform this } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java index e98522623..09156446b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java @@ -170,8 +170,8 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion } @Override - public int getArea() { - return region.getArea(); + public long getVolume() { + return region.getVolume(); } @Override @@ -250,7 +250,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion int lastVertexId = -1; for (BlockVector3 vertex : vertices) { vertexIds.put(vertex, ++lastVertexId); - session.dispatchCUIEvent(player, new SelectionPointEvent(lastVertexId, vertex, getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(lastVertexId, vertex, getVolume())); } for (Triangle triangle : triangles) { @@ -273,8 +273,8 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion checkNotNull(session); if (isDefined()) { - session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getArea())); - session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getVolume())); + session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getVolume())); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java index 1a4cecc71..dab4721d8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java @@ -161,13 +161,13 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion { player.printInfo(TranslatableComponent.of( "worldedit.selection.cuboid.explain.primary-area", TextComponent.of(position1.toString()), - TextComponent.of(region.getArea()) + TextComponent.of(region.getVolume()) )); } else if (position1 != null) { player.printInfo(TranslatableComponent.of("worldedit.selection.cuboid.explain.primary", TextComponent.of(position1.toString()))); } - session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getVolume())); } @Override @@ -180,13 +180,13 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion { player.printInfo(TranslatableComponent.of( "worldedit.selection.cuboid.explain.secondary-area", TextComponent.of(position2.toString()), - TextComponent.of(region.getArea()) + TextComponent.of(region.getVolume()) )); } else if (position2 != null) { player.printInfo(TranslatableComponent.of("worldedit.selection.cuboid.explain.secondary", TextComponent.of(position2.toString()))); } - session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getVolume())); } @Override @@ -197,11 +197,11 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion { session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID())); if (position1 != null) { - session.dispatchCUIEvent(player, new SelectionPointEvent(0, position1, getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(0, position1, getVolume())); } if (position2 != null) { - session.dispatchCUIEvent(player, new SelectionPointEvent(1, position2, getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(1, position2, getVolume())); } } @@ -268,7 +268,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion { } @Override - public int getArea() { + public long getVolume() { if (position1 == null) { return -1; } @@ -277,17 +277,17 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion { return -1; } - return region.getArea(); + return region.getVolume(); } @Override public void describeCUI(LocalSession session, Actor player) { if (position1 != null) { - session.dispatchCUIEvent(player, new SelectionPointEvent(0, position1, getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(0, position1, getVolume())); } if (position2 != null) { - session.dispatchCUIEvent(player, new SelectionPointEvent(1, position2, getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(1, position2, getVolume())); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java index 1b477f755..10de56191 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java @@ -188,7 +188,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { "worldedit.selection.cylinder.explain.secondary", TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getX())), TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getZ())), - TextComponent.of(region.getArea()) + TextComponent.of(region.getVolume()) )); } else { player.printError(TranslatableComponent.of("worldedit.selection.cylinder.explain.secondary-missing")); @@ -260,8 +260,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { } @Override - public int getArea() { - return region.getArea(); + public long getVolume() { + return region.getVolume(); } @Override @@ -273,8 +273,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { @Override public void describeLegacyCUI(LocalSession session, Actor player) { if (isDefined()) { - session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getArea())); - session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getVolume())); + session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getVolume())); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java index 86c9d595a..c42de1fad 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java @@ -151,7 +151,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion { player.printInfo(TranslatableComponent.of( "worldedit.selection.ellipsoid.explain.primary-area", TextComponent.of(region.getCenter().toString()), - TextComponent.of(region.getArea()) + TextComponent.of(region.getVolume()) )); } else { player.printInfo(TranslatableComponent.of( @@ -169,7 +169,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion { player.printInfo(TranslatableComponent.of( "worldedit.selection.ellipsoid.explain.secondary-area", TextComponent.of(region.getRadius().toString()), - TextComponent.of(region.getArea()) + TextComponent.of(region.getVolume()) )); } else { player.printInfo(TranslatableComponent.of( @@ -238,8 +238,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion { } @Override - public int getArea() { - return region.getArea(); + public long getVolume() { + return region.getVolume(); } @Override @@ -250,8 +250,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion { @Override public void describeLegacyCUI(LocalSession session, Actor player) { - session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getArea())); - session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getArea())); + session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getVolume())); + session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getVolume())); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java index 29fda872d..7a8c7b2ec 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java @@ -134,7 +134,7 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector { player.printInfo(TranslatableComponent.of( "worldedit.selection.extend.explain.primary", TextComponent.of(pos.toString()), - TextComponent.of(region.getArea()) + TextComponent.of(region.getVolume()) )); explainRegionAdjust(player, session); @@ -145,7 +145,7 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector { player.printInfo(TranslatableComponent.of( "worldedit.selection.extend.explain.secondary", TextComponent.of(pos.toString()), - TextComponent.of(region.getArea()) + TextComponent.of(region.getVolume()) )); explainRegionAdjust(player, session); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java index 26b48f2da..3ab10dfc2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java @@ -174,7 +174,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { player.printInfo(TranslatableComponent.of("worldedit.selection.polygon2d.explain.primary", TextComponent.of(pos.toString()))); session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID())); - session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getArea())); + session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getVolume())); session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY())); } @@ -186,7 +186,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { TextComponent.of(pos.toString()) )); - session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea())); + session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getVolume())); session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY())); } @@ -247,8 +247,8 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { } @Override - public int getArea() { - return region.getArea(); + public long getVolume() { + return region.getVolume(); } /** @@ -264,7 +264,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { public void describeCUI(LocalSession session, Actor player) { final List points = region.getPoints(); for (int id = 0; id < points.size(); id++) { - session.dispatchCUIEvent(player, new SelectionPoint2DEvent(id, points.get(id), getArea())); + session.dispatchCUIEvent(player, new SelectionPoint2DEvent(id, points.get(id), getVolume())); } session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY())); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java index ae909a077..641262a1a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java @@ -93,7 +93,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector { player.printInfo(TranslatableComponent.of( "worldedit.selection.sphere.explain.secondary-defined", TextComponent.of(region.getRadius().getX()), - TextComponent.of(region.getArea()) + TextComponent.of(region.getVolume()) )); } else { player.printInfo(TranslatableComponent.of("worldedit.selection.sphere.explain.secondary", TextComponent.of(region.getRadius().getX()))); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java index 9e37e4da0..212f93e19 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java @@ -78,8 +78,8 @@ public class RequestSelection implements Region { } @Override - public int getArea() { - return getRegion().getArea(); + public long getVolume() { + return getRegion().getVolume(); } @Override