feat: move limits for (brush, superpickaxe and normal) radii to fawe (#2635)

- closes #2587
This commit is contained in:
Jordan 2024-05-24 15:09:57 +02:00 committed by GitHub
parent 3dc949e383
commit f9c523c173
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 470 additions and 101 deletions

View File

@ -120,7 +120,6 @@ public class WorldEditPlugin extends JavaPlugin {
public void onLoad() {
//FAWE start
this.bukkitConsoleCommandSender = new BukkitCommandSender(this, Bukkit.getConsoleSender());
// This is already covered by Spigot, however, a more pesky warning with a proper explanation over "Ambiguous plugin name..." can't hurt.
Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins();
for (Plugin p : plugins) {
@ -138,6 +137,14 @@ public class WorldEditPlugin extends JavaPlugin {
//noinspection ResultOfMethodCallIgnored
getDataFolder().mkdirs();
//FAWE start - Modify WorldEdit config name
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this);
// Load config before we say we've loaded platforms as it is used in listeners of the event
// Load config in onLoad to ensure it is loaded before FAWE settings to allow (inelegant) copying of values across
// where needed
config.load();
//FAWE end
WorldEdit worldEdit = WorldEdit.getInstance();
// Setup platform
@ -148,14 +155,14 @@ public class WorldEditPlugin extends JavaPlugin {
migrateLegacyConfig();
//FAWE end
//FAWE start - Modify WorldEdit config name
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this);
//FAWE end
//FAWE start - Setup permission attachments
permissionAttachmentManager = new BukkitPermissionAttachmentManager(this);
//FAWE end
//FAWE start - initialise bukkitConsoleCommandSender later
this.bukkitConsoleCommandSender = new BukkitCommandSender(this, Bukkit.getConsoleSender());
//FAWE end
Path delChunks = Paths.get(getDataFolder().getPath(), DELCHUNKS_FILE_NAME);
if (Files.exists(delChunks)) {
ChunkDeleter.runFromFile(delChunks, true);
@ -189,8 +196,6 @@ public class WorldEditPlugin extends JavaPlugin {
new FaweBukkit(this);
//FAWE end
config.load(); // Load config before we say we've loaded platforms as it is used in listeners of the event
WorldEdit.getInstance().getEventBus().post(new PlatformsRegisteredEvent());
PermissionsResolverManager.initialize(this); // Setup permission resolver

View File

@ -24,11 +24,13 @@ limits:
max-polygonal-points:
default: -1
maximum: 20
# radius, superpickaxe, brush radius are ignored, use FAWE config limits
max-radius: -1
max-super-pickaxe-size: 5
max-brush-radius: 100
butcher-radius:
default: -1
# Ignored, use FAWE config limits
maximum: -1
disallowed-blocks:
- "minecraft:wheat"

View File

@ -13,7 +13,7 @@ public class ScrollRange extends Scroll {
@Override
public boolean increment(Player player, int amount) {
int max = WorldEdit.getInstance().getConfiguration().maxBrushRadius;
int max = player.getLimit().MAX_BRUSH_RADIUS;
int newSize = MathMan.wrap(getTool().getRange() + amount, (int) (getTool().getSize() + 1), max);
getTool().setRange(newSize);
return true;

View File

@ -12,7 +12,7 @@ public class ScrollSize extends Scroll {
@Override
public boolean increment(Player player, int amount) {
int max = WorldEdit.getInstance().getConfiguration().maxRadius;
int max = player.getLimit().MAX_RADIUS;
double newSize = Math.max(0, Math.min(max == -1 ? 4095 : max, getTool().getSize() + amount));
getTool().setSize(newSize);
return true;

View File

@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.configuration;
import com.fastasyncworldedit.core.limit.FaweLimit;
import com.fastasyncworldedit.core.limit.PropertyRemap;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockTypesCache;
@ -140,8 +141,22 @@ public class Settings extends Config {
);
limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE);
limit.MAX_ITERATIONS = Math.max(
limit.MAX_ITERATIONS,
newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE
limit.MAX_ITERATIONS, newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE);
limit.MAX_RADIUS = Math.max(
limit.MAX_RADIUS,
newLimit.MAX_RADIUS != -1 ? newLimit.MAX_RADIUS : Integer.MAX_VALUE
);
limit.MAX_SUPER_PICKAXE_SIZE = Math.max(
limit.MAX_SUPER_PICKAXE_SIZE,
newLimit.MAX_SUPER_PICKAXE_SIZE != -1 ? newLimit.MAX_SUPER_PICKAXE_SIZE : Integer.MAX_VALUE
);
limit.MAX_BRUSH_RADIUS = Math.max(
limit.MAX_BRUSH_RADIUS,
newLimit.MAX_BRUSH_RADIUS != -1 ? newLimit.MAX_BRUSH_RADIUS : Integer.MAX_VALUE
);
limit.MAX_BUTCHER_RADIUS = Math.max(
limit.MAX_BUTCHER_RADIUS,
newLimit.MAX_BUTCHER_RADIUS != -1 ? newLimit.MAX_BUTCHER_RADIUS : Integer.MAX_VALUE
);
limit.MAX_HISTORY = Math.max(
limit.MAX_HISTORY,
@ -352,6 +367,14 @@ public class Settings extends Config {
public int MAX_ITERATIONS = 1000;
@Comment("Max allowed entities (e.g. cows)")
public int MAX_ENTITIES = 1337;
@Comment("Max allowed radius (e.g. for //sphere)")
public int MAX_RADIUS = LocalConfiguration.MAX_RADIUS;
@Comment("Max allowed superpickaxe size")
public int MAX_SUPER_PICKAXE_SIZE = LocalConfiguration.MAX_SUPER_RADIUS;
@Comment("Max allowed brush radius")
public int MAX_BRUSH_RADIUS = LocalConfiguration.MAX_BRUSH_RADIUS;
@Comment("Max allowed butcher radius")
public int MAX_BUTCHER_RADIUS = LocalConfiguration.MAX_BUTCHER_RADIUS;
@Comment({
"Blockstates include Banner, Beacon, BrewingStand, Chest, CommandBlock, ",
"CreatureSpawner, Dispenser, Dropper, EndGateway, Furnace, Hopper, Jukebox, ",

View File

@ -0,0 +1,30 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.fastasyncworldedit.core.exception;
/**
* Thrown when a maximum radius for a brush is reached.
*/
public class BrushRadiusLimitException extends RadiusLimitException {
public BrushRadiusLimitException(int maxBrushRadius) {
super(maxBrushRadius);
}
}

View File

@ -0,0 +1,41 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.fastasyncworldedit.core.exception;
import com.sk89q.worldedit.WorldEditException;
/**
* Thrown when a maximum radius is reached, such as, for example,
* in the case of a sphere command.
*/
public class RadiusLimitException extends WorldEditException {
private final int maxRadius;
public RadiusLimitException(int maxRadius) {
this.maxRadius = maxRadius;
}
public int getMaxRadius() {
return maxRadius;
}
//FAWE end
}

View File

@ -18,6 +18,10 @@ public class FaweLimit {
public int SCHEM_FILE_SIZE_LIMIT = 0;
public int SCHEM_FILE_NUM_LIMIT = 0;
public int MAX_EXPRESSION_MS = 0;
public int MAX_RADIUS = 0;
public int MAX_SUPER_PICKAXE_SIZE = 0;
public int MAX_BRUSH_RADIUS = 0;
public int MAX_BUTCHER_RADIUS = 0;
public int INVENTORY_MODE = Integer.MAX_VALUE;
public int SPEED_REDUCTION = Integer.MAX_VALUE;
public boolean FAST_PLACEMENT = false;
@ -123,6 +127,10 @@ public class FaweLimit {
MAX.UNIVERSAL_DISALLOWED_BLOCKS = false;
MAX.DISALLOWED_BLOCKS = Collections.emptySet();
MAX.REMAP_PROPERTIES = Collections.emptySet();
MAX.MAX_RADIUS = Integer.MAX_VALUE;
MAX.MAX_SUPER_PICKAXE_SIZE = Integer.MAX_VALUE;
MAX.MAX_BRUSH_RADIUS = Integer.MAX_VALUE;
MAX.MAX_BUTCHER_RADIUS = Integer.MAX_VALUE;
}
public boolean MAX_CHANGES() {
@ -250,7 +258,12 @@ public class FaweLimit {
&& (STRIP_NBT == null || STRIP_NBT.isEmpty())
// && !UNIVERSAL_DISALLOWED_BLOCKS --> do not include this, it effectively has no relevance
&& (DISALLOWED_BLOCKS == null || DISALLOWED_BLOCKS.isEmpty())
&& (REMAP_PROPERTIES == null || REMAP_PROPERTIES.isEmpty());
&& (REMAP_PROPERTIES == null || REMAP_PROPERTIES.isEmpty())
&& MAX_RADIUS == Integer.MAX_VALUE
&& MAX_SUPER_PICKAXE_SIZE == Integer.MAX_VALUE
&& MAX_BRUSH_RADIUS == Integer.MAX_VALUE
&& MAX_BUTCHER_RADIUS == Integer.MAX_VALUE;
}
public void set(FaweLimit limit) {
@ -273,6 +286,10 @@ public class FaweLimit {
UNIVERSAL_DISALLOWED_BLOCKS = limit.UNIVERSAL_DISALLOWED_BLOCKS;
DISALLOWED_BLOCKS = limit.DISALLOWED_BLOCKS;
REMAP_PROPERTIES = limit.REMAP_PROPERTIES;
MAX_RADIUS = limit.MAX_RADIUS;
MAX_SUPER_PICKAXE_SIZE = limit.MAX_SUPER_PICKAXE_SIZE;
MAX_BRUSH_RADIUS = limit.MAX_BRUSH_RADIUS;
MAX_BUTCHER_RADIUS = limit.MAX_BUTCHER_RADIUS;
}
public FaweLimit copy() {
@ -296,6 +313,10 @@ public class FaweLimit {
limit.UNIVERSAL_DISALLOWED_BLOCKS = UNIVERSAL_DISALLOWED_BLOCKS;
limit.DISALLOWED_BLOCKS = DISALLOWED_BLOCKS;
limit.REMAP_PROPERTIES = REMAP_PROPERTIES;
limit.MAX_RADIUS = MAX_RADIUS;
limit.MAX_SUPER_PICKAXE_SIZE = MAX_SUPER_PICKAXE_SIZE;
limit.MAX_BRUSH_RADIUS = MAX_BRUSH_RADIUS;
limit.MAX_BUTCHER_RADIUS = MAX_BUTCHER_RADIUS;
return limit;
}

View File

@ -52,12 +52,26 @@ import java.util.Set;
public abstract class LocalConfiguration {
private static final Logger LOGGER = LogManagerCompat.getLogger();
//FAWE start - inelegant but required to transfer to FAWE limits as defaults
public static int MAX_RADIUS;
public static int MAX_SUPER_RADIUS;
public static int MAX_BRUSH_RADIUS;
public static int MAX_BUTCHER_RADIUS;
//FAWE end
public boolean profile = false;
public boolean traceUnflushedSessions = true;
public Set<String> disallowedBlocks = new HashSet<>();
protected BlockMask disallowedBlocksMask;
/**
* @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_CHANGES}
*/
@Deprecated
public int defaultChangeLimit = -1;
/**
* @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_CHANGES}
*/
@Deprecated
public int maxChangeLimit = -1;
public int defaultVerticalHeight = 256;
public int defaultMaxPolygonalPoints = -1;
@ -68,8 +82,20 @@ public abstract class LocalConfiguration {
public boolean snapshotsConfigured = false;
public SnapshotRepository snapshotRepo = null;
public SnapshotDatabase snapshotDatabase = null;
/**
* @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_RADIUS}
*/
@Deprecated
public int maxRadius = -1;
/**
* @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_SUPER_PICKAXE_SIZE}
*/
@Deprecated
public int maxSuperPickaxeSize = 5;
/**
* @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_BRUSH_RADIUS}
*/
@Deprecated
public int maxBrushRadius = 6;
public boolean logCommands = false;
public String logFile = "";
@ -92,6 +118,10 @@ public abstract class LocalConfiguration {
public String scriptsDir = "craftscripts";
public boolean showHelpInfo = true; // unused
public int butcherDefaultRadius = -1;
/**
* @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_BUTCHER_RADIUS}
*/
@Deprecated
public int butcherMaxRadius = -1;
public boolean allowSymlinks = false;
public boolean serverSideCUI = true;

View File

@ -19,9 +19,24 @@
package com.sk89q.worldedit;
import com.fastasyncworldedit.core.exception.BrushRadiusLimitException;
import com.fastasyncworldedit.core.exception.RadiusLimitException;
/**
* Thrown when a maximum radius for a brush is reached.
*
* @deprecated Use {@link RadiusLimitException}
*/
@Deprecated
public class MaxBrushRadiusException extends MaxRadiusException {
//FAWE start
/**
* @deprecated Use {@link BrushRadiusLimitException}
*/
@Deprecated
public MaxBrushRadiusException() {
}
//FAWE end
}

View File

@ -19,10 +19,24 @@
package com.sk89q.worldedit;
import com.fastasyncworldedit.core.exception.RadiusLimitException;
/**
* Thrown when a maximum radius is reached, such as, for example,
* in the case of a sphere command.
*
* @deprecated Use {@link RadiusLimitException}
*/
@Deprecated
public class MaxRadiusException extends WorldEditException {
//FAWE start
/**
* @deprecated Use {@link RadiusLimitException}
*/
@Deprecated
public MaxRadiusException() {
}
//FAWE end
}

View File

@ -20,6 +20,8 @@
package com.sk89q.worldedit;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.exception.BrushRadiusLimitException;
import com.fastasyncworldedit.core.exception.RadiusLimitException;
import com.fastasyncworldedit.core.extension.factory.TransformFactory;
import com.fastasyncworldedit.core.extent.ResettableExtent;
import com.google.common.base.Throwables;
@ -437,7 +439,9 @@ public final class WorldEdit {
*
* @param radius the radius
* @throws MaxRadiusException if the radius is bigger than the configured radius
* @deprecated Use {@link WorldEdit#checkMaxRadius(double, Actor)}
*/
@Deprecated
public void checkMaxRadius(double radius) throws MaxRadiusException {
if (getConfiguration().maxRadius > 0 && radius > getConfiguration().maxRadius) {
throw new MaxRadiusException();
@ -449,7 +453,9 @@ public final class WorldEdit {
*
* @param radius the radius
* @throws MaxBrushRadiusException if the radius is bigger than the configured radius
* @deprecated Use {@link WorldEdit#checkMaxBrushRadius(double, Actor)}
*/
@Deprecated
public void checkMaxBrushRadius(double radius) throws MaxBrushRadiusException {
if (getConfiguration().maxBrushRadius > 0 && radius > getConfiguration().maxBrushRadius) {
throw new MaxBrushRadiusException();
@ -457,6 +463,10 @@ public final class WorldEdit {
}
//FAWE start
/**
* @deprecated Use {@link WorldEdit#checkMaxBrushRadius(Expression, Actor)}
*/
@Deprecated(forRemoval = true, since = "TODO")
public void checkMaxBrushRadius(Expression radius) throws MaxBrushRadiusException {
double val = radius.evaluate();
checkArgument(val >= 0, "Radius must be a positive number.");
@ -466,6 +476,53 @@ public final class WorldEdit {
}
}
}
/**
* Check the given radius against the give actor's limit.
*
* @param radius Radius to check
* @param actor Actor to check for
* @throws MaxRadiusException If given radius larger than allowed
* @since TODO
*/
public void checkMaxRadius(double radius, Actor actor) {
int max = actor.getLimit().MAX_RADIUS;
if (max > 0 && radius > max) {
throw new RadiusLimitException(max);
}
}
/**
* Check the given radius against the give actor's limit.
*
* @param radius Radius to check
* @param actor Actor to check for
* @throws MaxRadiusException If given radius larger than allowed
* @since TODO
*/
public void checkMaxBrushRadius(double radius, Actor actor) {
int max = actor.getLimit().MAX_BRUSH_RADIUS;
if (max > 0 && radius > max) {
throw new RadiusLimitException(max);
}
}
/**
* Check the given radius against the give actor's limit.
*
* @param expression Radius to check
* @param actor Actor to check for
* @throws BrushRadiusLimitException If given radius larger than allowed
* @since TODO
*/
public void checkMaxBrushRadius(Expression expression, Actor actor) {
double radius = expression.evaluate();
checkArgument(radius >= 0, "Radius must be a positive number.");
int max = actor.getLimit().MAX_BRUSH_RADIUS;
if (max > 0 && radius > max) {
throw new BrushRadiusLimitException(max);
}
}
//FAWE end
/**

View File

@ -186,7 +186,10 @@ public class BrushCommands {
@ArgFlag(name = 'm', desc = "Mask to limit blocks being considered", def = "")
Mask mask
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
checkCommandArgument(minFreqDiff >= 0 && minFreqDiff <= 26, "minFreqDiff not in range 0 <= value <= 26");
if (mask != null && !(mask instanceof CachedMask)) {
mask = new CachedMask(mask, false);
@ -212,7 +215,10 @@ public class BrushCommands {
@Arg(desc = "fillRec", def = "1")
int fillRec
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new ErodeBrush(erodefaces, erodeRec, fillFaces, fillRec), "worldedit.brush.erode").setSize(radius);
}
@ -234,7 +240,10 @@ public class BrushCommands {
@Arg(desc = "fillRec", def = "1")
int fillRec
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new RaiseBrush(erodefaces, erodeRec, fillFaces, fillRec), "worldedit.brush.pull").setSize(radius);
}
@ -252,7 +261,10 @@ public class BrushCommands {
@Arg(name = "filled", desc = "Whether the circle should be filled", def = "false")
boolean filled
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new CircleBrush(filled), "worldedit.brush.sphere").setSize(radius).setFill(fill);
}
@ -276,7 +288,10 @@ public class BrushCommands {
@Switch(name = 'd', desc = "Apply in depth first order")
boolean depthFirst
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new RecurseBrush(depthFirst), "worldedit.brush.recursive").setSize(radius).setFill(fill)
.setMask(new IdMask(editSession));
}
@ -299,7 +314,10 @@ public class BrushCommands {
@Switch(name = 'f', desc = "Create a flat line")
boolean flat
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new LineBrush(shell, select, flat), "worldedit.brush.line").setSize(radius).setFill(fill);
}
@ -326,7 +344,10 @@ public class BrushCommands {
Expression radius
)
throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
player.print(Caption.of("fawe.worldedit.brush.brush.spline", (radius)));
set(context, new SplineBrush(player), "worldedit.brush.spline").setSize(radius).setFill(fill);
}
@ -379,7 +400,10 @@ public class BrushCommands {
@Switch(name = 'd', desc = "sags the catenary toward the facing direction")
boolean facingDirection
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new CatenaryBrush(shell, select, facingDirection, lengthFactor), "worldedit.brush.spline")
.setSize(radius).setFill(fill);
}
@ -411,7 +435,10 @@ public class BrushCommands {
double quality
) throws WorldEditException {
player.print(Caption.of("fawe.worldedit.brush.brush.spline", (radius)));
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new SurfaceSpline(tension, bias, continuity, quality), "surfacespline").setSize(radius)
.setFill(fill);
}
@ -436,9 +463,11 @@ public class BrushCommands {
double amplitude
) throws WorldEditException {
double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
worldEdit.checkMaxBrushRadius(max);
Brush brush =
new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100);
worldEdit.checkMaxBrushRadius(
max,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100);
set(context, brush, "worldedit.brush.rock").setSize(max).setFill(fill);
}
@ -459,7 +488,10 @@ public class BrushCommands {
@Arg(desc = "Lines", def = "10")
int count
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new ShatterBrush(count), "worldedit.brush.shatter").setSize(radius).setFill(fill)
.setMask(new ExistingBlockMask(editSession));
}
@ -490,7 +522,10 @@ public class BrushCommands {
boolean randomRotate
)
throws WorldEditException, FileNotFoundException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
InputStream stream = getHeightmapStream(image);
HeightBrush brush;
int minY = player.getWorld().getMinY();
@ -526,7 +561,10 @@ public class BrushCommands {
URL url = new URL(imageURL);
MainUtil.checkImageHost(url.toURI());
BufferedImage image = MainUtil.readImage(url);
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
if (yscale != 1) {
ImageUtil.scaleAlpha(image, yscale);
alpha = true;
@ -553,7 +591,10 @@ public class BrushCommands {
@Arg(desc = "Expression", def = "5")
Expression radius
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new SurfaceSphereBrush(), "worldedit.brush.surface").setFill(fill).setSize(radius);
}
@ -578,7 +619,10 @@ public class BrushCommands {
@Switch(name = 'o', desc = "Overlay the block")
boolean overlay
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
Brush brush;
if (overlay) {
brush = new ScatterOverlayBrush((int) points, (int) distance);
@ -612,7 +656,10 @@ public class BrushCommands {
@Switch(name = 'r', desc = "Apply random rotation")
boolean rotate
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
try {
MultiClipboardHolder clipboards =
ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true);
@ -651,7 +698,10 @@ public class BrushCommands {
List<Pattern> patternLayers
)
throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new LayerBrush(patternLayers.toArray(new Pattern[0])), "worldedit.brush.layer").setSize(radius);
}
@ -678,7 +728,10 @@ public class BrushCommands {
@Arg(desc = "boolean", def = "true")
boolean solid
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new SplatterBrush((int) points, (int) recursion, solid), "worldedit.brush.splatter").setSize(radius)
.setFill(fill);
}
@ -711,7 +764,10 @@ public class BrushCommands {
boolean print
)
throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(
context,
new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " "), print),
@ -838,7 +894,10 @@ public class BrushCommands {
InjectedValueAccess context
)
throws WorldEditException, FileNotFoundException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
InputStream stream = getHeightmapStream(image);
HeightBrush brush;
int minY = player.getWorld().getMinY();
@ -908,7 +967,10 @@ public class BrushCommands {
@Switch(name = 'a', desc = "Apply auto view based rotation on paste")
boolean autoRotate
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
player.print(Caption.of("fawe.worldedit.brush.brush.copy", (radius)));
set(context, new CopyPastaBrush(player, session, randomRotate, autoRotate), "worldedit.brush.copy").setSize(radius);
@ -933,7 +995,10 @@ public class BrushCommands {
@Switch(name = 'p', desc = "Show any printed output")
boolean print
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
String cmd = StringMan.join(input, " ");
set(context, new CommandBrush(cmd, print), "worldedit.brush.command").setSize(radius);
}
@ -1042,7 +1107,7 @@ public class BrushCommands {
String permission
)
throws WorldEditException {
WorldEdit.getInstance().checkMaxBrushRadius(radius);
WorldEdit.getInstance().checkMaxBrushRadius(radius, player);
BrushTool tool = session.getBrushTool(player);
tool.setSize(radius);
tool.setFill(null);
@ -1197,7 +1262,10 @@ public class BrushCommands {
@Switch(name = 'f', desc = "Create falling spheres instead")
boolean falling
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
Brush brush;
if (hollow) {
brush = new HollowSphereBrush();
@ -1244,8 +1312,14 @@ public class BrushCommands {
@Switch(name = 'h', desc = "Create hollow cylinders instead")
boolean hollow
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(height);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
worldEdit.checkMaxBrushRadius(
height,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
BrushSettings settings;
if (hollow) {
@ -1293,9 +1367,18 @@ public class BrushCommands {
BlockVector3 size = clipboard.getDimensions();
worldEdit.checkMaxBrushRadius(size.getBlockX() / 2D - 1);
worldEdit.checkMaxBrushRadius(size.getBlockY() / 2D - 1);
worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1);
worldEdit.checkMaxBrushRadius(
size.getBlockX() / 2D - 1,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
worldEdit.checkMaxBrushRadius(
size.getBlockY() / 2D - 1,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
worldEdit.checkMaxBrushRadius(
size.getBlockZ() / 2D - 1,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(
context,
@ -1324,7 +1407,10 @@ public class BrushCommands {
Mask mask,
InjectedValueAccess context
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
//FAWE start
FaweLimit limit = Settings.settings().getLimit(player);
@ -1359,7 +1445,10 @@ public class BrushCommands {
@ArgFlag(name = 'm', desc = "The mask of blocks to use for the heightmap")
Mask mask, InjectedValueAccess context
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
//FAWE start
FaweLimit limit = Settings.settings().getLimit(player);
@ -1386,7 +1475,10 @@ public class BrushCommands {
@Arg(desc = "The radius to extinguish", def = "5")
Expression radius
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new SphereBrush(), "worldedit.brush.ex").setSize(radius).setFill(BlockTypes.AIR.getDefaultState())
.setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE));
@ -1405,7 +1497,10 @@ public class BrushCommands {
@Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius")
boolean fromMaxY
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
set(context, new GravityBrush(fromMaxY), "worldedit.brush.gravity").setSize(radius);
}
@ -1439,7 +1534,10 @@ public class BrushCommands {
@Switch(name = 'w', desc = "Also kill water mobs")
boolean killWater, InjectedValueAccess context
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(
radius,
context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"))
);
CreatureButcher flags = new CreatureButcher(player);
flags.or(
@ -1508,7 +1606,7 @@ public class BrushCommands {
RegionFactory shape,
String permission
) throws WorldEditException {
WorldEdit.getInstance().checkMaxBrushRadius(radius);
WorldEdit.getInstance().checkMaxBrushRadius(radius, player);
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
tool.setSize(radius);
tool.setFill(null);

View File

@ -130,9 +130,9 @@ public class GenerationCommands {
return 0;
}
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusZ);
worldEdit.checkMaxRadius(height);
worldEdit.checkMaxRadius(radiusX, actor);
worldEdit.checkMaxRadius(radiusZ, actor);
worldEdit.checkMaxRadius(height, actor);
if (thickness > radiusX || thickness > radiusZ) {
actor.print(Caption.of("worldedit.hcyl.thickness-too-large"));
@ -178,9 +178,9 @@ public class GenerationCommands {
}
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusZ);
worldEdit.checkMaxRadius(height);
worldEdit.checkMaxRadius(radiusX, actor);
worldEdit.checkMaxRadius(radiusZ, actor);
worldEdit.checkMaxRadius(height, actor);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
@ -224,9 +224,9 @@ public class GenerationCommands {
}
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusZ);
worldEdit.checkMaxRadius(height);
worldEdit.checkMaxRadius(radiusX, actor);
worldEdit.checkMaxRadius(radiusZ, actor);
worldEdit.checkMaxRadius(height, actor);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCone(pos, pattern, radiusX, radiusZ, height, !hollow, thickness);
@ -290,9 +290,9 @@ public class GenerationCommands {
}
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusY);
worldEdit.checkMaxRadius(radiusZ);
worldEdit.checkMaxRadius(radiusX, actor);
worldEdit.checkMaxRadius(radiusY, actor);
worldEdit.checkMaxRadius(radiusZ, actor);
BlockVector3 pos = session.getPlacementPosition(actor);
if (raised) {
pos = pos.add(0, (int) radiusY, 0);
@ -323,7 +323,7 @@ public class GenerationCommands {
double density
) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
worldEdit.checkMaxRadius(size);
worldEdit.checkMaxRadius(size, actor);
density /= 100;
int affected = editSession.makeForest(session.getPlacementPosition(actor), size, density, type);
actor.print(Caption.of("worldedit.forestgen.created", TextComponent.of(affected)));
@ -345,7 +345,7 @@ public class GenerationCommands {
double density
) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
worldEdit.checkMaxRadius(size);
worldEdit.checkMaxRadius(size, actor);
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), size, density);
actor.print(Caption.of("worldedit.pumpkins.created", TextComponent.of(affected)));
return affected;
@ -382,7 +382,7 @@ public class GenerationCommands {
@Switch(name = 'h', desc = "Make a hollow pyramid")
boolean hollow
) throws WorldEditException {
worldEdit.checkMaxRadius(size);
worldEdit.checkMaxRadius(size, actor);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
@ -736,7 +736,7 @@ public class GenerationCommands {
double amplitude
) throws WorldEditException {
double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
worldEdit.checkMaxRadius(max);
worldEdit.checkMaxRadius(max, actor);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeBlob(
pos,

View File

@ -66,10 +66,11 @@ public class SuperPickaxeCommands {
int range
) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) {
player.print(Caption.of("worldedit.tool.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
if (range > player.getLimit().MAX_SUPER_PICKAXE_SIZE) {
player.print(Caption.of(
"worldedit.tool.superpickaxe.max-range",
TextComponent.of(player.getLimit().MAX_SUPER_PICKAXE_SIZE)
));
return;
}
session.setSuperPickaxe(new AreaPickaxe(range));
@ -89,10 +90,11 @@ public class SuperPickaxeCommands {
double range
) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) {
player.print(Caption.of("worldedit.tool.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
if (range > player.getLimit().MAX_SUPER_PICKAXE_SIZE) {
player.print(Caption.of(
"worldedit.tool.superpickaxe.max-range",
TextComponent.of(player.getLimit().MAX_SUPER_PICKAXE_SIZE)
));
return;
}

View File

@ -297,10 +297,11 @@ public class ToolCommands {
int range
) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) {
player.print(Caption.of("worldedit.tool.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
if (range > player.getLimit().MAX_SUPER_PICKAXE_SIZE) {
player.print(Caption.of(
"worldedit.tool.superpickaxe.max-range",
TextComponent.of(player.getLimit().MAX_SUPER_PICKAXE_SIZE)
));
return;
}
setTool(player, session, new FloodFillTool(range, pattern), "worldedit.tool.floodfill.equip");

View File

@ -154,7 +154,7 @@ public class ToolUtilCommands {
@Arg(desc = "The size of the brush")
int size
) throws WorldEditException {
we.checkMaxBrushRadius(size);
we.checkMaxBrushRadius(size, player);
session.getBrushTool(player).setSize(size);
player.print(Caption.of("worldedit.tool.size.set"));

View File

@ -246,8 +246,9 @@ public class UtilityCommands {
double radius = radiusExp.evaluate();
//FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
we.checkMaxRadius(radius, actor);
depth = Math.max(1, depth);
we.checkMaxRadius(depth, actor);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillDirection(pos, pattern, radius, depth, direction);
@ -333,9 +334,9 @@ public class UtilityCommands {
double radius = radiusExp.evaluate();
//FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
we.checkMaxRadius(radius, actor);
depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth);
we.checkMaxRadius(radius);
we.checkMaxRadius(radius, actor);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillXZ(pos, pattern, radius, depth, true);
@ -364,7 +365,7 @@ public class UtilityCommands {
//FAWE end
double radius = radiusExp.evaluate();
radius = Math.max(0, radius);
we.checkMaxRadius(radius);
we.checkMaxRadius(radius, actor);
int affected = editSession.drainArea(session.getPlacementPosition(actor), radius, waterlogged, plants);
actor.print(Caption.of("worldedit.drain.drained", TextComponent.of(affected)));
return affected;
@ -383,7 +384,7 @@ public class UtilityCommands {
double radius
) throws WorldEditException {
radius = Math.max(0, radius);
we.checkMaxRadius(radius);
we.checkMaxRadius(radius, actor);
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.LAVA);
actor.print(Caption.of("worldedit.fixlava.fixed", TextComponent.of(affected)));
return affected;
@ -402,7 +403,7 @@ public class UtilityCommands {
double radius
) throws WorldEditException {
radius = Math.max(0, radius);
we.checkMaxRadius(radius);
we.checkMaxRadius(radius, actor);
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.WATER);
actor.print(Caption.of("worldedit.fixwater.fixed", TextComponent.of(affected)));
return affected;
@ -423,7 +424,7 @@ public class UtilityCommands {
Integer height
) throws WorldEditException {
size = Math.max(1, size);
we.checkMaxRadius(size);
we.checkMaxRadius(size, actor);
height = height != null
? Math.min((world.getMaxY() - world.getMinY() + 1), height + 1)
@ -448,7 +449,7 @@ public class UtilityCommands {
Integer height
) throws WorldEditException {
size = Math.max(1, size);
we.checkMaxRadius(size);
we.checkMaxRadius(size, actor);
height = height != null
? Math.min((world.getMaxY() - world.getMinY() + 1), height + 1)
@ -476,7 +477,7 @@ public class UtilityCommands {
new MaskTraverser(mask).setNewExtent(editSession);
//FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
we.checkMaxRadius(radius, actor);
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, radius);
actor.print(Caption.of("worldedit.removenear.removed", TextComponent.of(affected)));
@ -503,7 +504,7 @@ public class UtilityCommands {
new MaskTraverser(from).setNewExtent(editSession);
//FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
we.checkMaxRadius(radius, actor);
BlockVector3 base = session.getPlacementPosition(actor);
BlockVector3 min = base.subtract(radius, radius, radius);
@ -542,7 +543,7 @@ public class UtilityCommands {
) throws WorldEditException {
size = Math.max(1, size);
height = Math.max(1, height);
we.checkMaxRadius(size);
we.checkMaxRadius(size, actor);
BlockVector3 position = session.getPlacementPosition(actor);
@ -579,7 +580,7 @@ public class UtilityCommands {
) throws WorldEditException {
size = Math.max(1, size);
height = Math.max(1, height);
we.checkMaxRadius(size);
we.checkMaxRadius(size, actor);
int affected = editSession.thaw(session.getPlacementPosition(actor), size, height);
actor.print(Caption.of(
@ -610,7 +611,7 @@ public class UtilityCommands {
) throws WorldEditException {
size = Math.max(1, size);
height = Math.max(1, height);
we.checkMaxRadius(size);
we.checkMaxRadius(size, actor);
final boolean onlyNormalDirt = !convertCoarse;
final int affected = editSession.green(
@ -635,11 +636,9 @@ public class UtilityCommands {
Integer radius
) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
int defaultRadius = actor.getLimit().MAX_RADIUS != -1 ? Math.min(40, actor.getLimit().MAX_RADIUS) : 40;
int size = radius != null ? Math.max(1, radius) : defaultRadius;
we.checkMaxRadius(size);
we.checkMaxRadius(size, actor);
Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE);
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, size);
@ -685,12 +684,12 @@ public class UtilityCommands {
actor.print(Caption.of("worldedit.butcher.explain-all"));
return 0;
} else if (radius == -1) {
if (config.butcherMaxRadius != -1) {
radius = config.butcherMaxRadius;
if (actor.getLimit().MAX_BUTCHER_RADIUS != -1) {
radius = actor.getLimit().MAX_BUTCHER_RADIUS;
}
}
if (config.butcherMaxRadius != -1) {
radius = Math.min(radius, config.butcherMaxRadius);
if (actor.getLimit().MAX_BUTCHER_RADIUS != -1) {
radius = Math.min(radius, actor.getLimit().MAX_BUTCHER_RADIUS);
}
CreatureButcher flags = new CreatureButcher(actor);

View File

@ -477,7 +477,7 @@ public class BrushTool
try {
new PatternTraverser(current).reset(editSession);
double size = current.getSize();
WorldEdit.getInstance().checkMaxBrushRadius(size);
WorldEdit.getInstance().checkMaxBrushRadius(size, player);
brush.build(editSession, target.toBlockPoint(), current.getMaterial(), size);
} catch (MaxChangedBlocksException e) {
player.print(Caption.of("worldedit.tool.max-block-changes"));

View File

@ -75,7 +75,7 @@ public @interface Confirm {
if (checkExisting(context)) {
return true;
}
int max = WorldEdit.getInstance().getConfiguration().maxRadius;
int max = actor.getLimit().MAX_RADIUS;
if (max != -1 && value > max) {
actor.print(Caption.of("fawe.cancel.reason.confirm.radius",
value, max, getArgs(context)

View File

@ -20,6 +20,8 @@
package com.sk89q.worldedit.internal.command.exception;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.exception.BrushRadiusLimitException;
import com.fastasyncworldedit.core.exception.RadiusLimitException;
import com.fastasyncworldedit.core.internal.exception.FaweException;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.DisallowedItemException;
@ -134,6 +136,18 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
);
}
//FAWE start
@ExceptionMatch
public void convert(BrushRadiusLimitException e) throws CommandException {
throw newCommandException(Caption.of("fawe.error.limit.max-brush-radius", TextComponent.of(e.getMaxRadius())), e);
}
@ExceptionMatch
public void convert(RadiusLimitException e) throws CommandException {
throw newCommandException(Caption.of("fawe.error.limit.max-radius", TextComponent.of(e.getMaxRadius())), e);
}
//FAWE end
@ExceptionMatch
public void convert(UnknownDirectionException e) throws CommandException {
throw newCommandException(e.getRichMessage(), e);

View File

@ -136,6 +136,14 @@ public class PropertiesConfiguration extends LocalConfiguration {
scriptsDir = getString("craftscript-dir", scriptsDir);
butcherDefaultRadius = getInt("butcher-default-radius", butcherDefaultRadius);
butcherMaxRadius = getInt("butcher-max-radius", butcherMaxRadius);
//FAWE start
MAX_RADIUS = maxRadius;
MAX_BRUSH_RADIUS = maxBrushRadius;
MAX_SUPER_RADIUS = maxSuperPickaxeSize;
MAX_BUTCHER_RADIUS = butcherMaxRadius;
//FAWE end
allowSymlinks = getBool("allow-symbolic-links", allowSymlinks);
serverSideCUI = getBool("server-side-cui", serverSideCUI);
extendedYLimit = getBool("extended-y-limit", extendedYLimit);

View File

@ -95,6 +95,13 @@ public class YAMLConfiguration extends LocalConfiguration {
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
//FAWE start
MAX_RADIUS = maxRadius;
MAX_BRUSH_RADIUS = maxBrushRadius;
MAX_SUPER_RADIUS = maxSuperPickaxeSize;
MAX_BUTCHER_RADIUS = butcherMaxRadius;
//FAWE end
disallowedBlocks = config.getStringList("limits.disallowed-blocks", Lists.newArrayList(getDefaultDisallowedBlocks()))
.stream()
.map(s -> s.contains(":") ? s.toLowerCase(Locale.ROOT) : ("minecraft:" + s).toLowerCase(Locale.ROOT))

View File

@ -137,6 +137,8 @@
"fawe.error.limit.disallowed-property": "Your limit disallows use of property '{0}'",
"fawe.error.region-mask-invalid": "Invalid region mask: {0}",
"fawe.error.occurred-continuing": "Ignorable error occurred during edit: {0}",
"fawe.error.limit.max-brush-radius": "Maximum brush radius in limit: {0}",
"fawe.error.limit.max-radius": "Maximum radius in limit: {0}",
"fawe.cancel.count": "Cancelled {0} edits.",
"fawe.cancel.reason.confirm": "Use //confirm to execute {0}",
"fawe.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}",