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;
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.boydti.fawe.config.BBC;
|
|
|
|
import com.boydti.fawe.object.brush.InspectBrush;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.LocalConfiguration;
|
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2018-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.BlockDataCyler;
|
|
|
|
import com.sk89q.worldedit.command.tool.BlockReplacer;
|
|
|
|
import com.sk89q.worldedit.command.tool.DistanceWand;
|
|
|
|
import com.sk89q.worldedit.command.tool.FloatingTreeRemover;
|
|
|
|
import com.sk89q.worldedit.command.tool.FloodFillTool;
|
|
|
|
import com.sk89q.worldedit.command.tool.LongRangeBuildTool;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.NavigationWand;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.QueryTool;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.SelectionWand;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.command.tool.TreePlanter;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
2018-06-15 05:41:37 +00:00
|
|
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
2019-08-06 20:18:44 +00:00
|
|
|
import com.sk89q.worldedit.internal.expression.Expression;
|
2018-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.util.HandSide;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.util.TreeGenerator;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.world.item.ItemType;
|
|
|
|
import org.enginehub.piston.annotation.Command;
|
|
|
|
import org.enginehub.piston.annotation.CommandContainer;
|
|
|
|
import org.enginehub.piston.annotation.param.Arg;
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
2014-04-03 02:08:50 +00:00
|
|
|
public class ToolCommands {
|
|
|
|
private final WorldEdit we;
|
|
|
|
|
|
|
|
public ToolCommands(WorldEdit we) {
|
|
|
|
this.we = we;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "none",
|
|
|
|
desc = "Unbind a bound tool from your current item"
|
|
|
|
)
|
|
|
|
public void none(Player player, LocalSession session) throws WorldEditException {
|
|
|
|
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, null);
|
2019-07-06 00:46:48 +00:00
|
|
|
player.print("Tool unbound from your current item.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
name = "/selwand",
|
|
|
|
aliases = "selwand",
|
|
|
|
desc = "Selection wand tool"
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.setwand")
|
|
|
|
public void selwand(Player player, LocalSession session) throws WorldEditException {
|
|
|
|
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new SelectionWand());
|
2019-07-06 00:46:48 +00:00
|
|
|
player.print("Selection wand bound to " + itemType.getName() + ".");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
name = "/navwand",
|
|
|
|
aliases = "navwand",
|
|
|
|
desc = "Navigation wand tool"
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.setwand")
|
|
|
|
public void navwand(Player player, LocalSession session) throws WorldEditException {
|
|
|
|
|
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new NavigationWand());
|
2019-07-06 00:46:48 +00:00
|
|
|
player.print("Navigation wand bound to " + itemStack.getType().getName() + ".");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
name = "info",
|
|
|
|
desc = "Block information tool"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2018-08-12 14:03:07 +00:00
|
|
|
@CommandPermissions("worldedit.tool.info")
|
2019-04-03 05:53:34 +00:00
|
|
|
public void info(Player player, LocalSession session) throws WorldEditException {
|
2019-07-06 00:46:48 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new QueryTool());
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.TOOL_INFO.send(player, itemStack.getType().getName());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "inspect",
|
|
|
|
desc = "Inspect edits within a radius"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2018-08-12 14:03:07 +00:00
|
|
|
@CommandPermissions("worldedit.tool.inspect")
|
2019-08-06 20:18:44 +00:00
|
|
|
public void inspectBrush(Player player, LocalSession session) throws WorldEditException {
|
2019-07-06 00:46:48 +00:00
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new InspectBrush());
|
2019-07-06 00:46:48 +00:00
|
|
|
BBC.TOOL_INSPECT.send(player, itemStack.getType().getName());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "tree",
|
|
|
|
desc = "Tree generator tool"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.tool.tree")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void tree(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "Type of tree to generate", def = "tree")
|
|
|
|
TreeGenerator.TreeType type) throws WorldEditException {
|
|
|
|
|
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new TreePlanter(type));
|
2019-07-06 00:46:48 +00:00
|
|
|
BBC.TOOL_TREE.send(player, itemStack.getType().getName());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "repl",
|
|
|
|
desc = "Block replacer tool"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.tool.replacer")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void repl(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The pattern of blocks to place")
|
|
|
|
Pattern pattern) throws WorldEditException {
|
|
|
|
|
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new BlockReplacer(pattern));
|
2019-07-06 00:46:48 +00:00
|
|
|
BBC.TOOL_REPL.send(player, itemStack.getType().getName());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "cycler",
|
|
|
|
desc = "Block data cycler tool"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.tool.data-cycler")
|
2019-03-16 23:04:24 +00:00
|
|
|
public void cycler(Player player, LocalSession session) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new BlockDataCyler());
|
2019-07-06 00:46:48 +00:00
|
|
|
BBC.TOOL_CYCLER.send(player, itemStack.getType().getName());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "floodfill",
|
|
|
|
aliases = { "flood" },
|
|
|
|
desc = "Flood fill tool"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.tool.flood-fill")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void floodFill(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The pattern to flood fill")
|
|
|
|
Pattern pattern,
|
|
|
|
@Arg(desc = "The range to perform the fill")
|
|
|
|
int range) throws WorldEditException {
|
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
LocalConfiguration config = we.getConfiguration();
|
2019-07-06 00:46:48 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
if (range > config.maxSuperPickaxeSize) {
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-07-06 00:46:48 +00:00
|
|
|
|
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new FloodFillTool(range, pattern));
|
2019-07-06 00:46:48 +00:00
|
|
|
BBC.TOOL_FLOOD_FILL.send(player, itemStack.getType().getName());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "deltree",
|
|
|
|
desc = "Floating tree remover tool"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.tool.deltree")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void deltree(Player player, LocalSession session) throws WorldEditException {
|
|
|
|
|
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new FloatingTreeRemover());
|
2019-07-06 00:46:48 +00:00
|
|
|
BBC.TOOL_DELTREE.send(player, itemStack.getType().getName());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "farwand",
|
|
|
|
desc = "Wand at a distance tool"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.tool.farwand")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void farwand(Player player, LocalSession session) throws WorldEditException {
|
|
|
|
|
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new DistanceWand());
|
2019-07-06 00:46:48 +00:00
|
|
|
BBC.TOOL_FARWAND.send(player, itemStack.getType().getName());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "lrbuild",
|
|
|
|
aliases = { "/lrbuild" },
|
|
|
|
desc = "Long-range building tool"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.tool.lrbuild")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void longrangebuildtool(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "Pattern to set on left-click")
|
|
|
|
Pattern primary,
|
|
|
|
@Arg(desc = "Pattern to set on right-click")
|
|
|
|
Pattern secondary) throws WorldEditException {
|
|
|
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
|
|
|
|
2019-07-17 16:31:13 +00:00
|
|
|
session.setTool(player, new LongRangeBuildTool(primary, secondary));
|
2019-07-06 00:46:48 +00:00
|
|
|
BBC.TOOL_LRBUILD_BOUND.send(player, itemStack.getType().getName());
|
2018-08-12 14:03:07 +00:00
|
|
|
BBC.TOOL_LRBUILD_INFO.send(player, secondary, primary);
|
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|