3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 11:00:05 +01:00

Made a checkMaxBrushRadius method for centralized use.

Dieser Commit ist enthalten in:
wizjany 2013-08-02 21:33:11 -04:00
Ursprung bc39a913ea
Commit d7324f6b13
4 geänderte Dateien mit 35 neuen und 43 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,10 @@
package com.sk89q.worldedit;
/**
*
* Thrown when a maximum radius for a brush is reached.
*
*/
public class MaxBrushRadiusException extends MaxRadiusException {
}

Datei anzeigen

@ -917,6 +917,18 @@ public class WorldEdit {
} }
} }
/**
* Checks to see if the specified brush radius is within bounds.
*
* @param radius
* @throws MaxBrushRadiusException
*/
public void checkMaxBrushRadius(double radius) throws MaxBrushRadiusException {
if (config.maxBrushRadius > 0 && radius > config.maxBrushRadius) {
throw new MaxBrushRadiusException();
}
}
/** /**
* Get a file relative to the defined working directory. If the specified * Get a file relative to the defined working directory. If the specified
* path is absolute, then the working directory is not used. * path is absolute, then the working directory is not used.
@ -1445,6 +1457,8 @@ public class WorldEdit {
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {
player.printError("Max blocks changed in an operation reached (" player.printError("Max blocks changed in an operation reached ("
+ e.getBlockLimit() + ")."); + e.getBlockLimit() + ").");
} catch (MaxBrushRadiusException e) {
player.printError("Maximum allowed brush radius/height: " + config.maxBrushRadius);
} catch (MaxRadiusException e) { } catch (MaxRadiusException e) {
player.printError("Maximum radius: " + config.maxRadius); player.printError("Maximum radius: " + config.maxRadius);
} catch (UnknownDirectionException e) { } catch (UnknownDirectionException e) {

Datei anzeigen

@ -77,11 +77,7 @@ public class BrushCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2; double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
if (radius > config.maxBrushRadius) { we.checkMaxBrushRadius(radius);
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
Pattern fill = we.getBlockPattern(player, args.getString(0)); Pattern fill = we.getBlockPattern(player, args.getString(0));
@ -116,18 +112,10 @@ public class BrushCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2; double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
if (radius > config.maxBrushRadius) { we.checkMaxBrushRadius(radius);
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
int height = args.argsLength() > 2 ? args.getInteger(2) : 1; int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
if (height > config.maxBrushRadius) { we.checkMaxBrushRadius(height);
player.printError("Maximum allowed brush radius/height: "
+ config.maxBrushRadius);
return;
}
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
Pattern fill = we.getBlockPattern(player, args.getString(0)); Pattern fill = we.getBlockPattern(player, args.getString(0));
@ -170,13 +158,9 @@ public class BrushCommands {
Vector size = clipboard.getSize(); Vector size = clipboard.getSize();
if (size.getBlockX() > config.maxBrushRadius we.checkMaxBrushRadius(size.getBlockX());
|| size.getBlockY() > config.maxBrushRadius we.checkMaxBrushRadius(size.getBlockY());
|| size.getBlockZ() > config.maxBrushRadius) { we.checkMaxBrushRadius(size.getBlockZ());
player.printError("Maximum allowed brush radius/height: "
+ config.maxBrushRadius);
return;
}
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard"); tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
@ -202,11 +186,7 @@ public class BrushCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
double radius = args.argsLength() > 0 ? args.getDouble(0) : 2; double radius = args.argsLength() > 0 ? args.getDouble(0) : 2;
if (radius > config.maxBrushRadius) { we.checkMaxBrushRadius(radius);
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
int iterations = args.argsLength() > 1 ? args.getInteger(1) : 4; int iterations = args.argsLength() > 1 ? args.getInteger(1) : 4;
@ -232,11 +212,7 @@ public class BrushCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
double radius = args.argsLength() > 1 ? args.getDouble(1) : 5; double radius = args.argsLength() > 1 ? args.getDouble(1) : 5;
if (radius > config.maxBrushRadius) { we.checkMaxBrushRadius(radius);
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
Pattern fill = new SingleBlockPattern(new BaseBlock(0)); Pattern fill = new SingleBlockPattern(new BaseBlock(0));
@ -268,11 +244,7 @@ public class BrushCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5; double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
if (radius > config.maxBrushRadius) { we.checkMaxBrushRadius(radius);
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setSize(radius); tool.setSize(radius);

Datei anzeigen

@ -152,11 +152,7 @@ public class ToolUtilCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
int radius = args.getInteger(0); int radius = args.getInteger(0);
if (radius > config.maxBrushRadius) { we.checkMaxBrushRadius(radius);
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
session.getBrushTool(player.getItemInHand()).setSize(radius); session.getBrushTool(player.getItemInHand()).setSize(radius);
player.print("Brush size set."); player.print("Brush size set.");