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-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2019-04-25 19:49:03 +00:00
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
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-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.util.HandSide;
|
2019-04-25 19:49:03 +00:00
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Tool commands.
|
|
|
|
*/
|
2019-04-25 19:49:03 +00:00
|
|
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
2014-04-03 02:08:50 +00:00
|
|
|
public class ToolUtilCommands {
|
|
|
|
private final WorldEdit we;
|
|
|
|
|
|
|
|
public ToolUtilCommands(WorldEdit we) {
|
|
|
|
this.we = we;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-04-25 19:49:03 +00:00
|
|
|
name = "/",
|
|
|
|
aliases = { "," },
|
|
|
|
desc = "Toggle the super pickaxe function"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.superpickaxe")
|
2019-04-25 19:49:03 +00:00
|
|
|
public void togglePickaxe(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The new super pickaxe state", def = "")
|
|
|
|
Boolean superPickaxe) throws WorldEditException {
|
|
|
|
boolean hasSuperPickAxe = session.hasSuperPickAxe();
|
|
|
|
if (superPickaxe != null && superPickaxe == hasSuperPickAxe) {
|
|
|
|
player.printError("Super pickaxe already " + (superPickaxe ? "enabled" : "disabled") + ".");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (hasSuperPickAxe) {
|
2014-04-03 02:08:50 +00:00
|
|
|
session.disableSuperPickAxe();
|
2019-04-25 19:49:03 +00:00
|
|
|
player.print("Super pickaxe disabled.");
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
|
|
|
session.enableSuperPickAxe();
|
2019-04-25 19:49:03 +00:00
|
|
|
player.print("Super pickaxe enabled.");
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-04-25 19:49:03 +00:00
|
|
|
name = "mask",
|
|
|
|
desc = "Set the brush mask"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.mask")
|
2019-04-25 19:49:03 +00:00
|
|
|
public void mask(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The mask to set", def = "")
|
|
|
|
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(
|
2019-04-25 19:49:03 +00:00
|
|
|
name = "material",
|
2019-04-25 20:30:16 +00:00
|
|
|
aliases = { "/material" },
|
2019-04-25 19:49:03 +00:00
|
|
|
desc = "Set the brush material"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.material")
|
2019-04-25 19:49:03 +00:00
|
|
|
public void material(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The pattern of blocks to use")
|
|
|
|
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(
|
2019-04-25 19:49:03 +00:00
|
|
|
name = "range",
|
|
|
|
desc = "Set the brush range"
|
|
|
|
)
|
2014-04-03 02:08:50 +00:00
|
|
|
@CommandPermissions("worldedit.brush.options.range")
|
2019-04-25 19:49:03 +00:00
|
|
|
public void range(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The range of the brush")
|
|
|
|
int range) throws WorldEditException {
|
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(
|
2019-04-25 19:49:03 +00:00
|
|
|
name = "size",
|
|
|
|
desc = "Set the brush size"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.size")
|
2019-04-25 19:49:03 +00:00
|
|
|
public void size(Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The size of the brush")
|
|
|
|
int size) throws WorldEditException {
|
|
|
|
we.checkMaxBrushRadius(size);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-04-25 19:49:03 +00:00
|
|
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setSize(size);
|
2014-04-03 02:08:50 +00:00
|
|
|
player.print("Brush size set.");
|
|
|
|
}
|
|
|
|
}
|