Skip to content

Commit

Permalink
Add radius checks to a few more utility commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
wizjany committed Feb 25, 2019
1 parent 90797d1 commit 9eeb0ac
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -275,6 +275,7 @@ public void removeNear(Player player, LocalSession session, EditSession editSess
public void replaceNear(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {

int size = Math.max(1, args.getInteger(0));
we.checkMaxRadius(size);
int affected;
Set<BaseBlock> from;
Pattern to;
Expand All @@ -288,9 +289,11 @@ public void replaceNear(Player player, LocalSession session, EditSession editSes

if (args.argsLength() == 2) {
from = null;
context.setRestricted(true);
to = we.getPatternFactory().parseFromInput(args.getString(1), context);
} else {
from = we.getBlockFactory().parseFromListInput(args.getString(1), context);
context.setRestricted(true);
to = we.getPatternFactory().parseFromInput(args.getString(2), context);
}

Expand All @@ -317,8 +320,8 @@ public void replaceNear(Player player, LocalSession session, EditSession editSes
@CommandPermissions("worldedit.snow")
@Logging(PLACEMENT)
public void snow(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {

double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
we.checkMaxRadius(size);

int affected = editSession.simulateSnow(session.getPlacementPosition(player), size);
player.print(affected + " surfaces covered. Let it snow~");
Expand All @@ -334,8 +337,8 @@ public void snow(Player player, LocalSession session, EditSession editSession, C
@CommandPermissions("worldedit.thaw")
@Logging(PLACEMENT)
public void thaw(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {

double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
we.checkMaxRadius(size);

int affected = editSession.thaw(session.getPlacementPosition(player), size);
player.print(affected + " surfaces thawed.");
Expand All @@ -345,15 +348,16 @@ public void thaw(Player player, LocalSession session, EditSession editSession, C
aliases = { "/green", "green" },
usage = "[radius]",
desc = "Greens the area",
help = "Converts dirt to grass blocks. -f also converts coarse dirt.",
flags = "f",
min = 0,
max = 1
)
@CommandPermissions("worldedit.green")
@Logging(PLACEMENT)
public void green(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {

final double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
we.checkMaxRadius(size);
final boolean onlyNormalDirt = !args.hasFlag('f');

final int affected = editSession.green(session.getPlacementPosition(player), size, onlyNormalDirt);
Expand Down

0 comments on commit 9eeb0ac

Please sign in to comment.