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

Port worldedit commands

Dieser Commit ist enthalten in:
Kenzie Togami 2019-04-25 21:03:28 -07:00
Ursprung 9b0fda9f83
Commit d8290cbd8f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 5D200B325E157A81
3 geänderte Dateien mit 60 neuen und 45 gelöschten Zeilen

Datei anzeigen

@ -509,8 +509,8 @@ public class UtilityCommands {
@Arg(desc = "The page to retrieve", def = "1") @Arg(desc = "The page to retrieve", def = "1")
int page, int page,
@Arg(desc = "The command to retrieve help for", def = "", variable = true) @Arg(desc = "The command to retrieve help for", def = "", variable = true)
List<String> commandPath) throws WorldEditException { List<String> command) throws WorldEditException {
PrintCommandHelp.help(commandPath, page, we, actor); PrintCommandHelp.help(command, page, we, actor);
} }

Datei anzeigen

@ -20,12 +20,12 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.google.common.io.Files; import com.google.common.io.Files;
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.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.PrintCommandHelp;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -36,6 +36,10 @@ import com.sk89q.worldedit.util.paste.ActorCallbackPaste;
import com.sk89q.worldedit.util.report.ConfigReport; import com.sk89q.worldedit.util.report.ConfigReport;
import com.sk89q.worldedit.util.report.ReportList; import com.sk89q.worldedit.util.report.ReportList;
import com.sk89q.worldedit.util.report.SystemInfoReport; import com.sk89q.worldedit.util.report.SystemInfoReport;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.Switch;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -44,8 +48,10 @@ import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.TextStyle; import java.time.format.TextStyle;
import java.util.List;
import java.util.Locale; import java.util.Locale;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class WorldEditCommands { public class WorldEditCommands {
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z"); private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
@ -56,11 +62,9 @@ public class WorldEditCommands {
} }
@Command( @Command(
aliases = { "version", "ver" }, name = "version",
usage = "", aliases = { "ver" },
desc = "Get WorldEdit version", desc = "Get WorldEdit version"
min = 0,
max = 0
) )
public void version(Actor actor) throws WorldEditException { public void version(Actor actor) throws WorldEditException {
actor.print("WorldEdit version " + WorldEdit.getVersion()); actor.print("WorldEdit version " + WorldEdit.getVersion());
@ -81,11 +85,8 @@ public class WorldEditCommands {
} }
@Command( @Command(
aliases = { "reload" }, name = "reload",
usage = "", desc = "Reload configuration"
desc = "Reload configuration",
min = 0,
max = 0
) )
@CommandPermissions("worldedit.reload") @CommandPermissions("worldedit.reload")
public void reload(Actor actor) throws WorldEditException { public void reload(Actor actor) throws WorldEditException {
@ -94,9 +95,14 @@ public class WorldEditCommands {
actor.print("Configuration reloaded!"); actor.print("Configuration reloaded!");
} }
@Command(aliases = {"report"}, desc = "Writes a report on WorldEdit", flags = "p", max = 0) @Command(
name = "report",
desc = "Writes a report on WorldEdit"
)
@CommandPermissions({"worldedit.report"}) @CommandPermissions({"worldedit.report"})
public void report(Actor actor, CommandContext args) throws WorldEditException { public void report(Actor actor,
@Switch(name = 'p', desc = "Pastebins the report")
boolean pastebin) throws WorldEditException {
ReportList report = new ReportList("Report"); ReportList report = new ReportList("Report");
report.add(new SystemInfoReport()); report.add(new SystemInfoReport());
report.add(new ConfigReport()); report.add(new ConfigReport());
@ -110,7 +116,7 @@ public class WorldEditCommands {
actor.printError("Failed to write report: " + e.getMessage()); actor.printError("Failed to write report: " + e.getMessage());
} }
if (args.hasFlag('p')) { if (pastebin) {
actor.checkPermission("worldedit.report.pastebin"); actor.checkPermission("worldedit.report.pastebin");
ActorCallbackPaste.pastebin( ActorCallbackPaste.pastebin(
we.getSupervisor(), actor, result, "WorldEdit report: %s.report", we.getSupervisor(), actor, result, "WorldEdit report: %s.report",
@ -120,11 +126,8 @@ public class WorldEditCommands {
} }
@Command( @Command(
aliases = { "cui" }, name = "cui",
usage = "", desc = "Complete CUI handshake (internal usage)"
desc = "Complete CUI handshake (internal usage)",
min = 0,
max = 0
) )
public void cui(Player player, LocalSession session) throws WorldEditException { public void cui(Player player, LocalSession session) throws WorldEditException {
session.setCUISupport(true); session.setCUISupport(true);
@ -132,14 +135,13 @@ public class WorldEditCommands {
} }
@Command( @Command(
aliases = { "tz" }, name = "tz",
usage = "[timezone]", desc = "Set your timezone for snapshots"
desc = "Set your timezone for snapshots",
min = 1,
max = 1
) )
public void tz(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void tz(Player player, LocalSession session,
ZoneId tz = ZoneId.of(args.getString(0)); @Arg(desc = "The timezone to set")
String timezone) throws WorldEditException {
ZoneId tz = ZoneId.of(timezone);
session.setTimezone(tz); session.setTimezone(tz);
player.print("Timezone set for this session to: " + tz.getDisplayName( player.print("Timezone set for this session to: " + tz.getDisplayName(
TextStyle.FULL, Locale.ENGLISH TextStyle.FULL, Locale.ENGLISH
@ -149,13 +151,15 @@ public class WorldEditCommands {
} }
@Command( @Command(
aliases = { "help" }, name = "help",
usage = "[<command>]", desc = "Displays help for WorldEdit commands"
desc = "Displays help for WorldEdit commands",
min = 0,
max = -1
) )
@CommandPermissions("worldedit.help") @CommandPermissions("worldedit.help")
public void help(Actor actor, CommandContext args) throws WorldEditException { public void help(Actor actor,
@Arg(desc = "The page to retrieve", def = "1")
int page,
@Arg(desc = "The command to retrieve help for", def = "", variable = true)
List<String> command) throws WorldEditException {
PrintCommandHelp.help(command, page, we, actor);
} }
} }

Datei anzeigen

@ -62,6 +62,8 @@ import com.sk89q.worldedit.command.ToolUtilCommands;
import com.sk89q.worldedit.command.ToolUtilCommandsRegistration; import com.sk89q.worldedit.command.ToolUtilCommandsRegistration;
import com.sk89q.worldedit.command.UtilityCommands; import com.sk89q.worldedit.command.UtilityCommands;
import com.sk89q.worldedit.command.UtilityCommandsRegistration; import com.sk89q.worldedit.command.UtilityCommandsRegistration;
import com.sk89q.worldedit.command.WorldEditCommands;
import com.sk89q.worldedit.command.WorldEditCommandsRegistration;
import com.sk89q.worldedit.command.argument.Arguments; import com.sk89q.worldedit.command.argument.Arguments;
import com.sk89q.worldedit.command.argument.BooleanConverter; import com.sk89q.worldedit.command.argument.BooleanConverter;
import com.sk89q.worldedit.command.argument.CommaSeparatedValuesConverter; import com.sk89q.worldedit.command.argument.CommaSeparatedValuesConverter;
@ -311,6 +313,24 @@ public final class PlatformCommandMananger {
.required() .required()
.build()); .build());
}); });
commandManager.register("worldedit", cmd -> {
cmd.aliases(ImmutableList.of("we"));
cmd.description("WorldEdit commands");
cmd.action(Command.Action.NULL_ACTION);
CommandManager manager = DefaultCommandManagerService.getInstance()
.newCommandManager();
register(
manager,
WorldEditCommandsRegistration.builder(),
new WorldEditCommands(worldEdit)
);
cmd.addPart(SubCommandPart.builder("action", "Sub-command to run.")
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required()
.build());
});
register( register(
commandManager, commandManager,
BiomeCommandsRegistration.builder(), BiomeCommandsRegistration.builder(),
@ -388,10 +408,6 @@ public final class PlatformCommandMananger {
.builder(builder) .builder(builder)
.commands() .commands()
.register(adapt(new SelectionCommand(new ApplyCommand(new ReplaceParser(), "Set all blocks within selection"), "worldedit.region.set")), "/set") .register(adapt(new SelectionCommand(new ApplyCommand(new ReplaceParser(), "Set all blocks within selection"), "worldedit.region.set")), "/set")
.group("worldedit", "we")
.describeAs("WorldEdit commands")
.registerMethods(new WorldEditCommands(worldEdit))
.parent()
.group("brush", "br") .group("brush", "br")
.describeAs("Brushing commands") .describeAs("Brushing commands")
.register(adapt(new ShapedBrushCommand(new DeformCommand(), "worldedit.brush.deform")), "deform") .register(adapt(new ShapedBrushCommand(new DeformCommand(), "worldedit.brush.deform")), "deform")
@ -402,11 +418,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("tool")
.describeAs("Bind functions to held items")
.registerMethods(new ToolCommands(worldEdit))
.parent()
.graph()
.getDispatcher(); .getDispatcher();
*/ */
} }