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
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU 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.
|
|
|
|
*
|
2020-08-25 01:31:47 +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 General Public License for more details.
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://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;
|
|
|
|
|
2021-07-23 15:48:51 +00:00
|
|
|
import com.fastasyncworldedit.core.command.tool.TargetMode;
|
2021-07-24 15:34:05 +00:00
|
|
|
import com.fastasyncworldedit.core.command.tool.brush.BrushSettings;
|
2021-07-23 15:48:51 +00:00
|
|
|
import com.fastasyncworldedit.core.command.tool.scroll.Scroll;
|
2021-07-24 15:34:05 +00:00
|
|
|
import com.fastasyncworldedit.core.configuration.Caption;
|
2021-08-16 09:03:06 +00:00
|
|
|
import com.fastasyncworldedit.core.extent.ResettableExtent;
|
2021-07-01 20:16:25 +00:00
|
|
|
import com.fastasyncworldedit.core.util.MathMan;
|
|
|
|
import com.fastasyncworldedit.core.util.StringMan;
|
2019-08-29 12:57:03 +00:00
|
|
|
import com.google.common.collect.Iterables;
|
|
|
|
import com.sk89q.worldedit.EditSession;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2019-08-29 12:57:03 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BaseItem;
|
|
|
|
import com.sk89q.worldedit.command.argument.Arguments;
|
|
|
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
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 02:55:38 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
2019-08-29 12:57:03 +00:00
|
|
|
import com.sk89q.worldedit.event.platform.CommandEvent;
|
|
|
|
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
2014-06-28 02:55:38 +00:00
|
|
|
import com.sk89q.worldedit.function.mask.Mask;
|
|
|
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
2019-08-29 12:57:03 +00:00
|
|
|
import com.sk89q.worldedit.internal.command.CommandArgParser;
|
2018-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.util.HandSide;
|
2019-07-06 00:46:48 +00:00
|
|
|
import org.enginehub.piston.annotation.Command;
|
|
|
|
import org.enginehub.piston.annotation.CommandContainer;
|
|
|
|
import org.enginehub.piston.annotation.param.Arg;
|
2019-08-29 12:57:03 +00:00
|
|
|
import org.enginehub.piston.annotation.param.Switch;
|
|
|
|
|
|
|
|
import java.util.List;
|
2020-10-05 17:41:41 +00:00
|
|
|
import java.util.Locale;
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tool commands.
|
|
|
|
*/
|
2019-07-06 00:46:48 +00:00
|
|
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
2014-04-03 02:08:50 +00:00
|
|
|
public class ToolUtilCommands {
|
2021-07-24 15:34:05 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
private final WorldEdit we;
|
|
|
|
|
|
|
|
public ToolUtilCommands(WorldEdit we) {
|
|
|
|
this.we = we;
|
|
|
|
}
|
|
|
|
|
2021-07-23 15:48:51 +00:00
|
|
|
//FAWE start - destination mask > mask
|
2014-04-03 02:08:50 +00:00
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "mask",
|
|
|
|
aliases = "/mask",
|
|
|
|
desc = "Set the brush destination mask"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2019-08-29 12:57:03 +00:00
|
|
|
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
2021-07-24 15:34:05 +00:00
|
|
|
public void mask(
|
|
|
|
Player player, LocalSession session,
|
|
|
|
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
|
|
|
boolean offHand,
|
|
|
|
@Arg(desc = "The destination mask", def = "")
|
|
|
|
Mask maskOpt, Arguments arguments
|
|
|
|
) throws WorldEditException {
|
2019-08-29 12:57:03 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player, false);
|
|
|
|
if (tool == null) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
|
2019-07-06 00:46:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-08-06 20:18:44 +00:00
|
|
|
if (maskOpt == null) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("worldedit.tool.mask.disabled"));
|
2019-08-29 12:57:03 +00:00
|
|
|
tool.setMask(null);
|
2020-01-26 18:01:16 +00:00
|
|
|
} else {
|
|
|
|
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
|
|
|
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get()))
|
2021-07-24 15:34:05 +00:00
|
|
|
.getSubstring();
|
2020-01-26 18:01:16 +00:00
|
|
|
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
|
|
|
|
settings.setMask(maskOpt);
|
|
|
|
tool.update();
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("worldedit.tool.mask.set"));
|
2020-01-26 18:01:16 +00:00
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
2021-07-23 15:48:51 +00:00
|
|
|
//FAWE end
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "material",
|
|
|
|
aliases = {"mat", "/material", "pattern"},
|
|
|
|
desc = "Set the brush material"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.material")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void material(
|
|
|
|
Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The pattern of blocks to use")
|
|
|
|
Pattern pattern,
|
|
|
|
//FAWE start - add offhand
|
|
|
|
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
|
|
|
boolean offHand, Arguments arguments
|
|
|
|
) throws WorldEditException {
|
2019-08-29 12:57:03 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player, false);
|
|
|
|
if (tool == null) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
|
2019-08-29 12:57:03 +00:00
|
|
|
return;
|
2020-10-05 17:41:41 +00:00
|
|
|
}
|
2019-10-23 16:58:36 +00:00
|
|
|
if (pattern == null) {
|
2019-08-29 12:57:03 +00:00
|
|
|
tool.setFill(null);
|
2019-11-21 13:50:05 +00:00
|
|
|
} else {
|
2020-10-05 17:41:41 +00:00
|
|
|
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
|
|
|
settings.setFill(pattern);
|
|
|
|
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
|
|
|
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
|
|
|
|
tool.update();
|
|
|
|
}
|
2021-07-23 15:48:51 +00:00
|
|
|
//FAWE end
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("worldedit.tool.material.set"));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "range",
|
|
|
|
aliases = "/range",
|
|
|
|
desc = "Set the brush range"
|
|
|
|
)
|
2014-04-03 02:08:50 +00:00
|
|
|
@CommandPermissions("worldedit.brush.options.range")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void range(
|
|
|
|
Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The range of the brush")
|
|
|
|
int range
|
|
|
|
) throws WorldEditException {
|
2021-07-23 15:48:51 +00:00
|
|
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range);
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("worldedit.tool.range.set"));
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "size",
|
|
|
|
desc = "Set the brush size"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.size")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void size(
|
|
|
|
Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The size of the brush")
|
|
|
|
int size
|
|
|
|
) throws WorldEditException {
|
2019-10-23 16:58:36 +00:00
|
|
|
we.checkMaxBrushRadius(size);
|
2019-07-06 00:46:48 +00:00
|
|
|
|
2020-08-24 19:39:41 +00:00
|
|
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setSize(size);
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("worldedit.tool.size.set"));
|
2019-08-29 12:57:03 +00:00
|
|
|
}
|
2020-08-25 01:31:47 +00:00
|
|
|
|
2019-08-29 12:57:03 +00:00
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "tracemask",
|
|
|
|
aliases = {"tarmask", "tm", "targetmask"},
|
|
|
|
desc = "Set the mask used to stop tool traces"
|
2019-05-24 01:12:31 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.options.tracemask")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void traceMask(
|
|
|
|
Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The trace mask to set", def = "")
|
|
|
|
Mask maskOpt
|
|
|
|
) throws WorldEditException {
|
2019-11-19 21:23:47 +00:00
|
|
|
session.getBrushTool(player, false).setTraceMask(maskOpt);
|
|
|
|
if (maskOpt == null) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("worldedit.tool.tracemask.disabled"));
|
2019-05-24 01:12:31 +00:00
|
|
|
} else {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("worldedit.tool.tracemask.set"));
|
2019-05-24 01:12:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-19 21:23:47 +00:00
|
|
|
|
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "/superpickaxe",
|
|
|
|
aliases = {",", "/sp", "/pickaxe", "/"},
|
|
|
|
desc = "Toggle the super pickaxe function"
|
2019-08-29 12:57:03 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.superpickaxe")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void togglePickaxe(
|
|
|
|
Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The new super pickaxe state", def = "")
|
|
|
|
Boolean superPickaxe
|
|
|
|
) {
|
2019-11-19 21:23:47 +00:00
|
|
|
boolean hasSuperPickAxe = session.hasSuperPickAxe();
|
|
|
|
if (superPickaxe != null && superPickaxe == hasSuperPickAxe) {
|
2021-07-24 15:34:05 +00:00
|
|
|
player.print(Caption.of(superPickaxe
|
|
|
|
? "worldedit.tool.superpickaxe.enabled.already"
|
|
|
|
: "worldedit.tool.superpickaxe.disabled.already"));
|
2020-10-05 17:41:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-11-19 21:23:47 +00:00
|
|
|
if (hasSuperPickAxe) {
|
2019-08-29 12:57:03 +00:00
|
|
|
session.disableSuperPickAxe();
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("worldedit.tool.superpickaxe.disabled"));
|
2019-07-06 00:46:48 +00:00
|
|
|
} else {
|
2019-08-29 12:57:03 +00:00
|
|
|
session.enableSuperPickAxe();
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("worldedit.tool.superpickaxe.enabled"));
|
2019-08-29 12:57:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-23 15:48:51 +00:00
|
|
|
//FAWE start
|
2019-08-29 12:57:03 +00:00
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "primary",
|
|
|
|
aliases = {"/primary"},
|
|
|
|
desc = "Set the right click brush",
|
|
|
|
descFooter = "Set the right click brush"
|
2019-08-29 12:57:03 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.primary")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void primary(
|
|
|
|
Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The brush command", variable = true) List<String> commandStr
|
|
|
|
) throws WorldEditException {
|
2019-08-29 12:57:03 +00:00
|
|
|
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
|
|
|
BrushTool tool = session.getBrushTool(player, false);
|
|
|
|
session.setTool(item, null, player);
|
|
|
|
String cmd = "brush " + StringMan.join(commandStr, " ");
|
|
|
|
CommandEvent event = new CommandEvent(player, cmd);
|
|
|
|
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
|
|
|
BrushTool newTool = session.getBrushTool(item, player, false);
|
|
|
|
if (newTool != null && tool != null) {
|
|
|
|
newTool.setSecondary(tool.getSecondary());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "secondary",
|
|
|
|
aliases = {"/secondary"},
|
|
|
|
desc = "Set the left click brush",
|
|
|
|
descFooter = "Set the left click brush"
|
2019-08-29 12:57:03 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.secondary")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void secondary(
|
|
|
|
Player player, LocalSession session,
|
|
|
|
@Arg(desc = "The brush command", variable = true)
|
|
|
|
List<String> commandStr
|
|
|
|
) throws WorldEditException {
|
2019-08-29 12:57:03 +00:00
|
|
|
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
|
|
|
BrushTool tool = session.getBrushTool(player, false);
|
|
|
|
session.setTool(item, null, player);
|
|
|
|
String cmd = "brush " + StringMan.join(commandStr, " ");
|
|
|
|
CommandEvent event = new CommandEvent(player, cmd);
|
|
|
|
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
|
|
|
BrushTool newTool = session.getBrushTool(item, player, false);
|
|
|
|
if (newTool != null && tool != null) {
|
|
|
|
newTool.setPrimary(tool.getPrimary());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "target",
|
|
|
|
aliases = {"tar", "/target", "/tar"},
|
|
|
|
desc = "Toggle between different target modes"
|
2019-08-29 12:57:03 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.target")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void target(
|
|
|
|
Player player, LocalSession session,
|
|
|
|
@Arg(name = "mode", desc = "int", def = "0")
|
|
|
|
int mode
|
|
|
|
) throws WorldEditException {
|
2019-08-29 12:57:03 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player, false);
|
|
|
|
if (tool == null) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
|
2019-08-29 12:57:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
TargetMode[] modes = TargetMode.values();
|
|
|
|
TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
|
|
|
|
tool.setTargetMode(newMode);
|
2020-10-05 17:41:41 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.target.mode.set", newMode));
|
2019-08-29 12:57:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "targetoffset",
|
|
|
|
aliases = {"to"},
|
|
|
|
desc = "Set the targeting mask"
|
2019-08-29 12:57:03 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.targetoffset")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void targetOffset(
|
|
|
|
Player player, EditSession editSession, LocalSession session,
|
|
|
|
@Arg(name = "offset", desc = "offset", def = "0") int offset
|
|
|
|
) throws WorldEditException {
|
2019-08-29 12:57:03 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player, false);
|
|
|
|
if (tool == null) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
|
2019-08-29 12:57:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
tool.setTargetOffset(offset);
|
2020-10-05 17:41:41 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.target.offset.set", offset));
|
2019-08-29 12:57:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "scroll",
|
|
|
|
desc = "Toggle between different target modes"
|
2019-08-29 12:57:03 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.brush.scroll")
|
2021-07-24 15:34:05 +00:00
|
|
|
public void scroll(
|
|
|
|
Player player, EditSession editSession, LocalSession session,
|
|
|
|
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
|
|
|
boolean offHand,
|
|
|
|
@Arg(desc = "Target Modes", def = "none")
|
|
|
|
Scroll.Action mode,
|
|
|
|
@Arg(desc = "The scroll action", variable = true)
|
|
|
|
List<String> commandStr
|
|
|
|
) throws WorldEditException {
|
2019-08-29 12:57:03 +00:00
|
|
|
BrushTool bt = session.getBrushTool(player, false);
|
|
|
|
if (bt == null) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
|
2019-08-29 12:57:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-10-23 14:44:13 +00:00
|
|
|
|
2019-08-29 12:57:03 +00:00
|
|
|
BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
|
2019-10-23 14:44:13 +00:00
|
|
|
Scroll action = Scroll.fromArguments(bt, player, session, mode, commandStr, true);
|
2019-08-29 12:57:03 +00:00
|
|
|
settings.setScrollAction(action);
|
2019-10-23 14:44:13 +00:00
|
|
|
if (mode == Scroll.Action.NONE) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.scroll.action.unset"));
|
2019-08-29 12:57:03 +00:00
|
|
|
} else if (action != null) {
|
2020-10-05 17:41:41 +00:00
|
|
|
String full = (mode.name().toLowerCase(Locale.ROOT) + " " + StringMan.join(commandStr, " ")).trim();
|
2019-10-23 14:44:13 +00:00
|
|
|
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
|
2020-10-05 17:41:41 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.scroll.action.set", mode));
|
2019-08-29 12:57:03 +00:00
|
|
|
}
|
|
|
|
bt.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2021-07-24 15:34:05 +00:00
|
|
|
name = "smask",
|
|
|
|
aliases = {"/smask", "/sourcemask", "sourcemask"},
|
|
|
|
desc = "Set the brush source mask",
|
|
|
|
descFooter = "Set the brush source mask"
|
2019-08-29 12:57:03 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
2021-07-24 15:34:05 +00:00
|
|
|
public void smask(
|
|
|
|
Player player, LocalSession session, EditSession editSession,
|
|
|
|
@Arg(desc = "The destination mask", def = "")
|
|
|
|
Mask maskArg,
|
|
|
|
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
|
|
|
boolean offHand,
|
|
|
|
Arguments arguments
|
|
|
|
) throws WorldEditException {
|
2019-08-29 12:57:03 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player, false);
|
|
|
|
if (tool == null) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
|
2019-08-29 12:57:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (maskArg == null) {
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.source.mask.disabled"));
|
2019-08-29 12:57:03 +00:00
|
|
|
tool.setSourceMask(null);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
|
|
|
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
|
|
|
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
|
|
|
|
settings.setSourceMask(maskArg);
|
|
|
|
tool.update();
|
2021-04-05 17:54:49 +00:00
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.source.mask"));
|
2019-08-29 12:57:03 +00:00
|
|
|
}
|
|
|
|
|
2021-08-16 09:03:06 +00:00
|
|
|
@Command(
|
|
|
|
name = "transform",
|
|
|
|
aliases = {"/transform"},
|
|
|
|
desc = "Set the brush transform"
|
|
|
|
)
|
|
|
|
@CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"})
|
2021-09-08 15:39:43 +00:00
|
|
|
public void transform(
|
|
|
|
Player player, LocalSession session, EditSession editSession,
|
|
|
|
@Arg(desc = "The transform", def = "") ResettableExtent transform,
|
|
|
|
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
|
|
|
|
boolean offHand,
|
|
|
|
Arguments arguments
|
|
|
|
) throws WorldEditException {
|
2021-08-16 09:03:06 +00:00
|
|
|
BrushTool tool = session.getBrushTool(player, false);
|
|
|
|
if (tool == null) {
|
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (transform == null) {
|
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.transform.disabled"));
|
|
|
|
tool.setTransform(null);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
|
|
|
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
|
|
|
settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
|
|
|
|
settings.setTransform(transform);
|
|
|
|
tool.update();
|
|
|
|
player.print(Caption.of("fawe.worldedit.brush.brush.transform"));
|
|
|
|
}
|
2021-07-23 15:48:51 +00:00
|
|
|
//FAWE end
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|