Use right config value for butcher radius. Add max radius for butcher.

This commit is contained in:
Wizjany 2012-11-23 20:10:38 -05:00
parent aadfc30fbb
commit 56d534bf0d
4 changed files with 27 additions and 19 deletions

View File

@ -19,13 +19,14 @@
package com.sk89q.worldedit; package com.sk89q.worldedit;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.ItemID;
import com.sk89q.worldedit.snapshots.SnapshotRepository;
import java.io.File; import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.ItemID;
import com.sk89q.worldedit.snapshots.SnapshotRepository;
/** /**
* Represents WorldEdit's configuration. * Represents WorldEdit's configuration.
* *
@ -104,6 +105,7 @@ public abstract class LocalConfiguration {
public String scriptsDir = "craftscripts"; public String scriptsDir = "craftscripts";
public boolean showFirstUseVersion = true; public boolean showFirstUseVersion = true;
public int butcherDefaultRadius = -1; public int butcherDefaultRadius = -1;
public int butcherMaxRadius = -1;
/** /**
* Loads the configuration. * Loads the configuration.

View File

@ -378,13 +378,18 @@ public class UtilityCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
// technically the default can be larger than the max, but that's not my problem
int radius = config.butcherDefaultRadius; int radius = config.butcherDefaultRadius;
if (args.argsLength() > 0) { // there might be a better way to do this but my brain is fried right now
if (args.getString(0).equals("all")) { if (args.argsLength() > 0) { // user inputted radius, override the default
radius = -1; radius = args.getInteger(0);
} else { if (config.butcherMaxRadius != -1) { // clamp if there is a max
radius = Math.max(1, args.getInteger(0)); if (radius == -1) {
radius = config.butcherMaxRadius;
} else { // Math.min does not work if radius is -1 (actually highest possible value)
radius = Math.min(radius, config.butcherMaxRadius);
}
} }
} }

View File

@ -19,12 +19,6 @@
package com.sk89q.worldedit.util; package com.sk89q.worldedit.util;
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.LogFormat;
import com.sk89q.worldedit.snapshots.SnapshotRepository;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
@ -33,6 +27,12 @@ import java.util.logging.Handler;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.LogFormat;
import com.sk89q.worldedit.snapshots.SnapshotRepository;
/** /**
* A less simple implementation of {@link LocalConfiguration} using YAML configuration files. * A less simple implementation of {@link LocalConfiguration} using YAML configuration files.
* *
@ -71,6 +71,8 @@ public class YAMLConfiguration extends LocalConfiguration {
maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius)); maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius));
maxSuperPickaxeSize = Math.max(1, config.getInt( maxSuperPickaxeSize = Math.max(1, config.getInt(
"limits.max-super-pickaxe-size", maxSuperPickaxeSize)); "limits.max-super-pickaxe-size", maxSuperPickaxeSize));
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
registerHelp = true; registerHelp = true;
logCommands = config.getBoolean("logging.log-commands", logCommands); logCommands = config.getBoolean("logging.log-commands", logCommands);
superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items", superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items",
@ -88,7 +90,6 @@ public class YAMLConfiguration extends LocalConfiguration {
scriptTimeout = config.getInt("scripting.timeout", scriptTimeout); scriptTimeout = config.getInt("scripting.timeout", scriptTimeout);
scriptsDir = config.getString("scripting.dir", scriptsDir); scriptsDir = config.getString("scripting.dir", scriptsDir);
butcherDefaultRadius = config.getInt("butcher-default-radius", butcherDefaultRadius);
saveDir = config.getString("saving.dir", saveDir); saveDir = config.getString("saving.dir", saveDir);

View File

@ -25,6 +25,9 @@ limits:
max-radius: -1 max-radius: -1
max-super-pickaxe-size: 5 max-super-pickaxe-size: 5
max-brush-radius: 5 max-brush-radius: 5
butcher-radius:
default: -1
maximum: -1
disallowed-blocks: [6, 7, 14, 15, 16, 26, 27, 28, 29, 39, 31, 32, 33, 34, 36, 37, 38, 39, 40, 46, 50, 51, 56, 59, 69, 73, 74, 75, 76, 77, 81, 83] disallowed-blocks: [6, 7, 14, 15, 16, 26, 27, 28, 29, 39, 31, 32, 33, 34, 36, 37, 38, 39, 40, 46, 50, 51, 56, 59, 69, 73, 74, 75, 76, 77, 81, 83]
use-inventory: use-inventory:
@ -57,9 +60,6 @@ history:
size: 15 size: 15
expiration: 10 expiration: 10
butcher:
butcher-default-radius: -1
wand-item: 271 wand-item: 271
shell-save-type: shell-save-type:
no-double-slash: false no-double-slash: false