Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change -h Tool Command Flag to Always Impact Secondary Brush #2560

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.util.StringMan;
import com.google.common.collect.Iterables;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
Expand Down Expand Up @@ -72,8 +71,8 @@ public ToolUtilCommands(WorldEdit we) {
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
public void mask(
Player player, LocalSession session,
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
boolean offHand,
@Switch(name = 'h', desc = "Modifies the secondary brush")
boolean secondary,
@Arg(desc = "The destination mask", def = "")
Mask maskOpt, Arguments arguments
) throws WorldEditException {
Expand All @@ -86,9 +85,8 @@ public void mask(
player.print(Caption.of("worldedit.tool.mask.disabled"));
tool.setMask(null);
} else {
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get()))
.getSubstring();
BrushSettings settings = secondary ? tool.getSecondary() : tool.getPrimary();
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
settings.setMask(maskOpt);
tool.update();
Expand All @@ -107,9 +105,9 @@ 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
//FAWE start - add secondary
@Switch(name = 'h', desc = "Modifies the secondary brush")
boolean secondary, Arguments arguments
) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
Expand All @@ -119,7 +117,7 @@ public void material(
if (pattern == null) {
tool.setFill(null);
} else {
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
BrushSettings settings = secondary ? tool.getSecondary() : tool.getPrimary();
settings.setFill(pattern);
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
Expand Down Expand Up @@ -152,11 +150,18 @@ public void range(
public void size(
Player player, LocalSession session,
@Arg(desc = "The size of the brush")
int size
int size,
@Switch(name = 'h', desc = "Modifies the secondary brush")
boolean secondary, Arguments arguments
) throws WorldEditException {
we.checkMaxBrushRadius(size);
BrushTool tool = session.getBrushTool(player, false);

session.getBrushTool(player).setSize(size);
BrushSettings settings = secondary ? tool.getSecondary() : tool.getPrimary();
settings.setSize(size);
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
tool.update();
player.print(Caption.of("worldedit.tool.size.set"));
}

Expand All @@ -171,12 +176,12 @@ public void traceMask(
@Arg(desc = "The trace mask to set", def = "")
Mask maskOpt
) throws WorldEditException {
BrushTool brushTool = session.getBrushTool(player, false);
if (brushTool == null) {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(Caption.of("worldedit.brush.none.equipped"));
return;
}
brushTool.setTraceMask(maskOpt);
tool.setTraceMask(maskOpt);
if (maskOpt == null) {
player.print(Caption.of("worldedit.tool.tracemask.disabled"));
} else {
Expand Down Expand Up @@ -288,7 +293,7 @@ public void target(
)
@CommandPermissions("worldedit.brush.targetoffset")
public void targetOffset(
Player player, EditSession editSession, LocalSession session,
Player player, LocalSession session,
@Arg(name = "offset", desc = "offset", def = "0") int offset
) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
Expand All @@ -306,22 +311,22 @@ public void targetOffset(
)
@CommandPermissions("worldedit.brush.scroll")
public void scroll(
Player player, EditSession editSession, LocalSession session,
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
boolean offHand,
Player player, LocalSession session,
@Switch(name = 'h', desc = "Modifies the secondary brush")
boolean secondary,
@Arg(desc = "Target Modes", def = "none")
Scroll.Action mode,
@Arg(desc = "The scroll action", variable = true)
List<String> commandStr
) throws WorldEditException {
BrushTool bt = session.getBrushTool(player, false);
if (bt == null) {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
return;
}

BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
Scroll action = Scroll.fromArguments(bt, player, session, mode, commandStr, true);
BrushSettings settings = secondary ? tool.getSecondary() : tool.getPrimary();
Scroll action = Scroll.fromArguments(tool, player, session, mode, commandStr, true);
settings.setScrollAction(action);
if (mode == Scroll.Action.NONE) {
player.print(Caption.of("fawe.worldedit.brush.brush.scroll.action.unset"));
Expand All @@ -330,7 +335,7 @@ public void scroll(
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
player.print(Caption.of("fawe.worldedit.brush.brush.scroll.action.set", mode));
}
bt.update();
tool.update();
}

@Command(
Expand All @@ -341,11 +346,11 @@ public void scroll(
)
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
public void smask(
Player player, LocalSession session, EditSession editSession,
Player player, LocalSession session,
@Arg(desc = "The destination mask", def = "")
Mask maskArg,
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
boolean offHand,
@Switch(name = 'h', desc = "Modifies the secondary brush")
boolean secondary,
Arguments arguments
) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
Expand All @@ -358,7 +363,7 @@ public void smask(
tool.setSourceMask(null);
return;
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
BrushSettings settings = secondary ? tool.getSecondary() : tool.getPrimary();
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
settings.setSourceMask(maskArg);
Expand All @@ -373,10 +378,10 @@ public void smask(
)
@CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"})
public void transform(
Player player, LocalSession session, EditSession editSession,
Player player, LocalSession session,
@Arg(desc = "The transform", def = "") ResettableExtent transform,
@Switch(name = 'h', desc = "Whether the offhand should be considered or not")
boolean offHand,
@Switch(name = 'h', desc = "Modifies the secondary brush")
boolean secondary,
Arguments arguments
) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
Expand All @@ -389,7 +394,7 @@ public void transform(
tool.setTransform(null);
return;
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
BrushSettings settings = secondary ? tool.getSecondary() : tool.getPrimary();
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
settings.setTransform(transform);
Expand Down
Loading