2014-04-03 02:08:50 +00:00
|
|
|
/*
|
2014-04-04 22:03:18 +00:00
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
2014-04-03 02:08:50 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* 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 Lesser General Public License
|
|
|
|
* for more details.
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-04-03 02:08:50 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-04-04 22:03:18 +00:00
|
|
|
*/
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
package com.sk89q.worldedit.command;
|
|
|
|
|
2019-04-06 23:13:23 +00:00
|
|
|
import com.boydti.fawe.config.BBC;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.minecraft.util.commands.Command;
|
|
|
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
|
|
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2014-06-28 02:55:38 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
|
|
|
import com.sk89q.worldedit.function.mask.Mask;
|
|
|
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
2018-08-21 16:58:10 +00:00
|
|
|
import com.sk89q.worldedit.internal.expression.Expression;
|
2018-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.util.HandSide;
|
2014-06-28 02:55:38 +00:00
|
|
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tool commands.
|
|
|
|
*/
|
|
|
|
public class ToolUtilCommands {
|
|
|
|
private final WorldEdit we;
|
|
|
|
|
|
|
|
public ToolUtilCommands(WorldEdit we) {
|
|
|
|
this.we = we;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/", "," },
|
|
|
|
usage = "[on|off]",
|
2014-07-29 18:04:04 +00:00
|
|
|
desc = "Toggle the super pickaxe function",
|
2014-04-03 02:08:50 +00:00
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.superpickaxe")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void togglePickaxe(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
String newState = args.getString(0, null);
|
|
|
|
if (session.hasSuperPickAxe()) {
|
|
|
|
if ("on".equals(newState)) {
|
2019-04-06 23:13:23 +00:00
|
|
|
player.printError(BBC.getPrefix() + "Super pick axe already enabled.");
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session.disableSuperPickAxe();
|
|
|
|
player.print("Super pick axe disabled.");
|
|
|
|
} else {
|
|
|
|
if ("off".equals(newState)) {
|
2019-04-06 23:13:23 +00:00
|
|
|
player.printError(BBC.getPrefix() + "Super pick axe already disabled.");
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
session.enableSuperPickAxe();
|
|
|
|
player.print("Super pick axe enabled.");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "mask" },
|
|
|
|
usage = "[mask]",
|
|
|
|
desc = "Set the brush mask",
|
|
|
|
min = 0,
|
|
|
|
max = -1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.mask")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void mask(Player player, LocalSession session, @Optional Mask mask) throws WorldEditException {
|
2014-06-28 02:55:38 +00:00
|
|
|
if (mask == null) {
|
2018-06-17 07:50:04 +00:00
|
|
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setMask(null);
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Brush mask disabled.");
|
|
|
|
} else {
|
2018-06-17 07:50:04 +00:00
|
|
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setMask(mask);
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Brush mask set.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "mat", "material" },
|
|
|
|
usage = "[pattern]",
|
|
|
|
desc = "Set the brush material",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.material")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void material(Player player, LocalSession session, Pattern pattern) throws WorldEditException {
|
2018-06-17 07:50:04 +00:00
|
|
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setFill(pattern);
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Brush material set.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "range" },
|
|
|
|
usage = "[pattern]",
|
|
|
|
desc = "Set the brush range",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.range")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void range(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
int range = args.getInteger(0);
|
2018-06-17 07:50:04 +00:00
|
|
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range);
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Brush range set.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "size" },
|
2018-08-21 16:58:10 +00:00
|
|
|
usage = "[size]",
|
2014-04-03 02:08:50 +00:00
|
|
|
desc = "Set the brush size",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.size")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void size(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
int radius = args.getInteger(0);
|
|
|
|
we.checkMaxBrushRadius(radius);
|
2018-06-17 07:50:04 +00:00
|
|
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setSize(radius);
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Brush size set.");
|
|
|
|
}
|
|
|
|
}
|