3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 11:00:04 +01:00

Port super pickaxe commands

Dieser Commit ist enthalten in:
Kenzie Togami 2019-04-24 00:00:56 -07:00
Ursprung 2ea30dc70e
Commit e447ac55db
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 5D200B325E157A81
3 geänderte Dateien mit 59 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -19,9 +19,6 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -29,8 +26,14 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.tool.AreaPickaxe; import com.sk89q.worldedit.command.tool.AreaPickaxe;
import com.sk89q.worldedit.command.tool.RecursivePickaxe; import com.sk89q.worldedit.command.tool.RecursivePickaxe;
import com.sk89q.worldedit.command.tool.SinglePickaxe; import com.sk89q.worldedit.command.tool.SinglePickaxe;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class SuperPickaxeCommands { public class SuperPickaxeCommands {
private final WorldEdit we; private final WorldEdit we;
@ -39,32 +42,26 @@ public class SuperPickaxeCommands {
} }
@Command( @Command(
aliases = { "single" }, name = "single",
usage = "", desc = "Enable the single block super pickaxe mode"
desc = "Enable the single block super pickaxe mode",
min = 0,
max = 0
) )
@CommandPermissions("worldedit.superpickaxe") @CommandPermissions("worldedit.superpickaxe")
public void single(Player player, LocalSession session) throws WorldEditException { public void single(Player player, LocalSession session) throws WorldEditException {
session.setSuperPickaxe(new SinglePickaxe()); session.setSuperPickaxe(new SinglePickaxe());
session.enableSuperPickAxe(); session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable."); player.print("Mode changed. Left click with a pickaxe. // to disable.");
} }
@Command( @Command(
aliases = { "area" }, name = "area",
usage = "<radius>", desc = "Enable the area super pickaxe pickaxe mode"
desc = "Enable the area super pickaxe pickaxe mode",
min = 1,
max = 1
) )
@CommandPermissions("worldedit.superpickaxe.area") @CommandPermissions("worldedit.superpickaxe.area")
public void area(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void area(Player player, LocalSession session,
@Arg(desc = "The range of the area pickaxe")
int range) throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
int range = args.getInteger(0);
if (range > config.maxSuperPickaxeSize) { if (range > config.maxSuperPickaxeSize) {
player.printError("Maximum range: " + config.maxSuperPickaxeSize); player.printError("Maximum range: " + config.maxSuperPickaxeSize);
@ -77,17 +74,16 @@ public class SuperPickaxeCommands {
} }
@Command( @Command(
aliases = { "recur", "recursive" }, name = "recursive",
usage = "<radius>", aliases = { "recur" },
desc = "Enable the recursive super pickaxe pickaxe mode", desc = "Enable the recursive super pickaxe pickaxe mode"
min = 1,
max = 1
) )
@CommandPermissions("worldedit.superpickaxe.recursive") @CommandPermissions("worldedit.superpickaxe.recursive")
public void recursive(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void recursive(Player player, LocalSession session,
@Arg(desc = "The range of the recursive pickaxe")
double range) throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
double range = args.getDouble(0);
if (range > config.maxSuperPickaxeSize) { if (range > config.maxSuperPickaxeSize) {
player.printError("Maximum range: " + config.maxSuperPickaxeSize); player.printError("Maximum range: " + config.maxSuperPickaxeSize);

Datei anzeigen

@ -1,3 +1,22 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* 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
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.command.argument; package com.sk89q.worldedit.command.argument;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;

Datei anzeigen

@ -54,6 +54,8 @@ import com.sk89q.worldedit.command.SnapshotCommands;
import com.sk89q.worldedit.command.SnapshotCommandsRegistration; import com.sk89q.worldedit.command.SnapshotCommandsRegistration;
import com.sk89q.worldedit.command.SnapshotUtilCommands; import com.sk89q.worldedit.command.SnapshotUtilCommands;
import com.sk89q.worldedit.command.SnapshotUtilCommandsRegistration; import com.sk89q.worldedit.command.SnapshotUtilCommandsRegistration;
import com.sk89q.worldedit.command.SuperPickaxeCommands;
import com.sk89q.worldedit.command.SuperPickaxeCommandsRegistration;
import com.sk89q.worldedit.command.argument.Arguments; import com.sk89q.worldedit.command.argument.Arguments;
import com.sk89q.worldedit.command.argument.CommaSeparatedValuesConverter; import com.sk89q.worldedit.command.argument.CommaSeparatedValuesConverter;
import com.sk89q.worldedit.command.argument.DirectionConverter; import com.sk89q.worldedit.command.argument.DirectionConverter;
@ -257,7 +259,7 @@ public final class PlatformCommandMananger {
.build()); .build());
}); });
commandManager.register("snapshot", cmd -> { commandManager.register("snapshot", cmd -> {
cmd.aliases(ImmutableList.of("snapshot", "snap")); cmd.aliases(ImmutableList.of("snap"));
cmd.description("Snapshot commands for saving/loading snapshots"); cmd.description("Snapshot commands for saving/loading snapshots");
cmd.action(Command.Action.NULL_ACTION); cmd.action(Command.Action.NULL_ACTION);
@ -274,6 +276,24 @@ public final class PlatformCommandMananger {
.required() .required()
.build()); .build());
}); });
commandManager.register("superpickaxe", cmd -> {
cmd.aliases(ImmutableList.of("pickaxe", "sp"));
cmd.description("Super-pickaxe commands");
cmd.action(Command.Action.NULL_ACTION);
CommandManager manager = DefaultCommandManagerService.getInstance()
.newCommandManager();
register(
manager,
SuperPickaxeCommandsRegistration.builder(),
new SuperPickaxeCommands(worldEdit)
);
cmd.addPart(SubCommandPart.builder("action", "Sub-command to run.")
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required()
.build());
});
commandManager.register("brush", cmd -> { commandManager.register("brush", cmd -> {
cmd.aliases(ImmutableList.of("br")); cmd.aliases(ImmutableList.of("br"));
cmd.description("Brushing commands"); cmd.description("Brushing commands");
@ -353,7 +373,6 @@ public final class PlatformCommandMananger {
dispatcher = new CommandGraph() dispatcher = new CommandGraph()
.builder(builder) .builder(builder)
.commands() .commands()
.registerMethods(new SnapshotUtilCommands(worldEdit))
.registerMethods(new ToolUtilCommands(worldEdit)) .registerMethods(new ToolUtilCommands(worldEdit))
.registerMethods(new ToolCommands(worldEdit)) .registerMethods(new ToolCommands(worldEdit))
.registerMethods(new UtilityCommands(worldEdit)) .registerMethods(new UtilityCommands(worldEdit))
@ -372,10 +391,6 @@ public final class PlatformCommandMananger {
.register(adapt(new ShapedBrushCommand(ProvidedValue.create(new Deform("y-=1", Mode.RAW_COORD), "Raise one block"), "worldedit.brush.raise")), "raise") .register(adapt(new ShapedBrushCommand(ProvidedValue.create(new Deform("y-=1", Mode.RAW_COORD), "Raise one block"), "worldedit.brush.raise")), "raise")
.register(adapt(new ShapedBrushCommand(ProvidedValue.create(new Deform("y+=1", Mode.RAW_COORD), "Lower one block"), "worldedit.brush.lower")), "lower") .register(adapt(new ShapedBrushCommand(ProvidedValue.create(new Deform("y+=1", Mode.RAW_COORD), "Lower one block"), "worldedit.brush.lower")), "lower")
.parent() .parent()
.group("superpickaxe", "pickaxe", "sp")
.describeAs("Super-pickaxe commands")
.registerMethods(new SuperPickaxeCommands(worldEdit))
.parent()
.group("tool") .group("tool")
.describeAs("Bind functions to held items") .describeAs("Bind functions to held items")
.registerMethods(new ToolCommands(worldEdit)) .registerMethods(new ToolCommands(worldEdit))