use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class SnapshotCommands method after.
@Command(name = "after", desc = "Choose the nearest snapshot after a date")
@CommandPermissions("worldedit.snapshots.restore")
void after(Actor actor, World world, LocalSession session, @Arg(desc = "The soonest date that may be used") ZonedDateTime date) throws IOException {
LocalConfiguration config = we.getConfiguration();
checkSnapshotsConfigured(config);
if (config.snapshotRepo != null) {
legacy.after(actor, world, session, date);
return;
}
Snapshot snapshot;
try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
snapshot = snapshotStream.findFirst().orElse(null);
}
if (snapshot == null) {
actor.print(Caption.of("worldedit.snapshot.none-after", TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date))));
} else {
if (session.getSnapshotExperimental() != null) {
session.getSnapshotExperimental().close();
}
session.setSnapshotExperimental(snapshot);
actor.print(Caption.of("worldedit.snapshot.use", TextComponent.of(snapshot.getInfo().getDisplayName())));
}
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class SnapshotCommands method before.
@Command(name = "before", desc = "Choose the nearest snapshot before a date")
@CommandPermissions("worldedit.snapshots.restore")
void before(Actor actor, World world, LocalSession session, @Arg(desc = "The soonest date that may be used") ZonedDateTime date) throws IOException {
LocalConfiguration config = we.getConfiguration();
checkSnapshotsConfigured(config);
if (config.snapshotRepo != null) {
legacy.before(actor, world, session, date);
return;
}
Snapshot snapshot;
try (Stream<Snapshot> snapshotStream = config.snapshotDatabase.getSnapshotsNewestFirst(world.getName())) {
snapshot = snapshotStream.findFirst().orElse(null);
}
if (snapshot == null) {
actor.print(Caption.of("worldedit.snapshot.none-before", TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date))));
} else {
if (session.getSnapshotExperimental() != null) {
session.getSnapshotExperimental().close();
}
session.setSnapshotExperimental(snapshot);
actor.print(Caption.of("worldedit.snapshot.use", TextComponent.of(snapshot.getInfo().getDisplayName())));
}
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method targetOffset.
@Command(name = "targetoffset", aliases = { "to" }, desc = "Set the targeting mask")
@CommandPermissions("worldedit.brush.targetoffset")
public void targetOffset(Player player, EditSession editSession, LocalSession session, @Arg(name = "offset", desc = "offset", def = "0") int offset) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
return;
}
tool.setTargetOffset(offset);
player.print(Caption.of("fawe.worldedit.brush.brush.target.offset.set", offset));
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method secondary.
@Command(name = "secondary", aliases = { "/secondary" }, desc = "Set the left click brush", descFooter = "Set the left click brush")
@CommandPermissions("worldedit.brush.secondary")
public void secondary(Player player, LocalSession session, @Arg(desc = "The brush command", variable = true) List<String> commandStr) throws WorldEditException {
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());
}
}
use of org.enginehub.piston.annotation.Command in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method smask.
@Command(name = "smask", aliases = { "/smask", "/sourcemask", "sourcemask" }, desc = "Set the brush source mask", descFooter = "Set the brush source mask")
@CommandPermissions({ "worldedit.brush.options.mask", "worldedit.mask.brush" })
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 {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
return;
}
if (maskArg == null) {
player.print(Caption.of("fawe.worldedit.brush.brush.source.mask.disabled"));
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();
player.print(Caption.of("fawe.worldedit.brush.brush.source.mask"));
}
Aggregations