Improved modifier help
This commit is contained in:
parent
fb3c8cc5e1
commit
914165b428
@ -6,7 +6,6 @@ import com.boydti.fawe.util.MainUtil;
|
|||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||||
import com.sk89q.minecraft.util.commands.Link;
|
import com.sk89q.minecraft.util.commands.Link;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||||
@ -70,6 +69,10 @@ public class UsageMessage extends Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String separateArg(String arg) {
|
||||||
|
return " " + arg;
|
||||||
|
}
|
||||||
|
|
||||||
private void attachCommandUsage(Description description, String commandString) {
|
private void attachCommandUsage(Description description, String commandString) {
|
||||||
List<Parameter> params = description.getParameters();
|
List<Parameter> params = description.getParameters();
|
||||||
String[] usage;
|
String[] usage;
|
||||||
@ -96,12 +99,11 @@ public class UsageMessage extends Message {
|
|||||||
|
|
||||||
prefix();
|
prefix();
|
||||||
text("&cUsage: ");
|
text("&cUsage: ");
|
||||||
commandString = (WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/") + commandString;
|
|
||||||
text("&7" + commandString);
|
text("&7" + commandString);
|
||||||
suggestTip(commandString + " ");
|
suggestTip(commandString + " ");
|
||||||
for (int i = 0; i < usage.length; i++) {
|
for (int i = 0; i < usage.length; i++) {
|
||||||
String argStr = usage[i];
|
String argStr = usage[i];
|
||||||
text(" " + argStr.replaceAll("[\\[|\\]|<|>]", "&8$0&7"));
|
text(separateArg(argStr.replaceAll("[\\[|\\]|<|>]", "&0$0&7")));
|
||||||
|
|
||||||
if (params.isEmpty()) continue;
|
if (params.isEmpty()) continue;
|
||||||
Parameter param = params.get(i);
|
Parameter param = params.get(i);
|
||||||
|
@ -31,6 +31,7 @@ import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
|||||||
import com.boydti.fawe.object.schematic.Schematic;
|
import com.boydti.fawe.object.schematic.Schematic;
|
||||||
import com.boydti.fawe.util.ImgurUtility;
|
import com.boydti.fawe.util.ImgurUtility;
|
||||||
import com.boydti.fawe.util.MaskTraverser;
|
import com.boydti.fawe.util.MaskTraverser;
|
||||||
|
import com.boydti.fawe.util.chat.Message;
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
@ -315,7 +316,7 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
if (url == null) {
|
if (url == null) {
|
||||||
BBC.GENERATING_LINK_FAILED.send(player);
|
BBC.GENERATING_LINK_FAILED.send(player);
|
||||||
} else {
|
} else {
|
||||||
BBC.DOWNLOAD_LINK.send(player, url.toString());
|
new Message(BBC.DOWNLOAD_LINK, url).link(url.getPath()).send(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Commands;
|
import com.boydti.fawe.config.Commands;
|
||||||
@ -47,8 +46,6 @@ import com.sk89q.worldedit.command.util.CreatureButcher;
|
|||||||
import com.sk89q.worldedit.command.util.EntityRemover;
|
import com.sk89q.worldedit.command.util.EntityRemover;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.factory.DefaultMaskParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
|
|
||||||
import com.sk89q.worldedit.extension.factory.HashTagPatternParser;
|
import com.sk89q.worldedit.extension.factory.HashTagPatternParser;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
@ -118,16 +115,7 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
"More Info: https://git.io/vSPmA"
|
"More Info: https://git.io/vSPmA"
|
||||||
)
|
)
|
||||||
public void patterns(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
public void patterns(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
if (args.argsLength() == 0) {
|
displayModifierHelp(player, args);
|
||||||
String base = getCommand().aliases()[0];
|
|
||||||
UsageMessage msg = new UsageMessage(getCallable(), base, args.getLocals());
|
|
||||||
msg.newline().paginate(base, 0, 1).send(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HashTagPatternParser parser = FaweAPI.getParser(HashTagPatternParser.class);
|
|
||||||
if (parser != null) {
|
|
||||||
UtilityCommands.help(args, worldEdit, player, getCommand().aliases()[0] + " ", parser.getDispatcher());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -142,16 +130,7 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
"More Info: https://git.io/v9r4K"
|
"More Info: https://git.io/v9r4K"
|
||||||
)
|
)
|
||||||
public void masks(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
public void masks(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
if (args.argsLength() == 0) {
|
displayModifierHelp(player, args);
|
||||||
String base = getCommand().aliases()[0];
|
|
||||||
UsageMessage msg = new UsageMessage(getCallable(), base, args.getLocals());
|
|
||||||
msg.newline().paginate(base, 0, 1).send(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DefaultMaskParser parser = FaweAPI.getParser(DefaultMaskParser.class);
|
|
||||||
if (parser != null) {
|
|
||||||
UtilityCommands.help(args, worldEdit, player, getCommand().aliases()[0] + " ", parser.getDispatcher());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -165,15 +144,29 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
"More Info: https://git.io/v9KHO"
|
"More Info: https://git.io/v9KHO"
|
||||||
)
|
)
|
||||||
public void transforms(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
public void transforms(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
displayModifierHelp(player, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayModifierHelp(Player player, CommandContext args) {
|
||||||
if (args.argsLength() == 0) {
|
if (args.argsLength() == 0) {
|
||||||
String base = getCommand().aliases()[0];
|
String base = getCommand().aliases()[0];
|
||||||
UsageMessage msg = new UsageMessage(getCallable(), base, args.getLocals());
|
UsageMessage msg = new UsageMessage(getCallable(), (WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/") + base, args.getLocals());
|
||||||
msg.newline().paginate(base, 0, 1).send(player);
|
msg.newline().paginate(base, 0, 1).send(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DefaultTransformParser parser = Fawe.get().getTransformParser();
|
HashTagPatternParser parser = FaweAPI.getParser(HashTagPatternParser.class);
|
||||||
if (parser != null) {
|
if (parser != null) {
|
||||||
UtilityCommands.help(args, worldEdit, player, getCommand().aliases()[0] + " ", parser.getDispatcher());
|
CommandMapping mapping = parser.getDispatcher().get(args.getString(0));
|
||||||
|
if (mapping != null) {
|
||||||
|
new UsageMessage(mapping.getCallable(), args.getString(0), args.getLocals()) {
|
||||||
|
@Override
|
||||||
|
public String separateArg(String arg) {
|
||||||
|
return "&7[" + arg + "&7]";
|
||||||
|
}
|
||||||
|
}.send(player);
|
||||||
|
} else {
|
||||||
|
UtilityCommands.help(args, worldEdit, player, getCommand().aliases()[0] + " ", parser.getDispatcher());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,7 +928,7 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
if (!(callable instanceof Dispatcher)) {
|
if (!(callable instanceof Dispatcher)) {
|
||||||
// TODO interactive box
|
// TODO interactive box
|
||||||
new UsageMessage(callable, Joiner.on(" ").join(visited)).send(actor);
|
new UsageMessage(callable, (WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/") + Joiner.on(" ").join(visited)).send(actor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatcher = (Dispatcher) callable;
|
dispatcher = (Dispatcher) callable;
|
||||||
@ -1018,7 +1011,7 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
msg.send(actor);
|
msg.send(actor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
new UsageMessage(callable, Joiner.on(" ").join(visited)).send(actor);
|
new UsageMessage(callable, (WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/") + Joiner.on(" ").join(visited)).send(actor);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -393,7 +393,7 @@ public final class CommandManager {
|
|||||||
BBC.NO_PERM.send(finalActor, StringMan.join(failedPermissions, " "));
|
BBC.NO_PERM.send(finalActor, StringMan.join(failedPermissions, " "));
|
||||||
} catch (InvalidUsageException e) {
|
} catch (InvalidUsageException e) {
|
||||||
if (e.isFullHelpSuggested()) {
|
if (e.isFullHelpSuggested()) {
|
||||||
UsageMessage usage = new UsageMessage(e.getCommand(), e.getCommandUsed("", ""), locals);
|
UsageMessage usage = new UsageMessage(e.getCommand(), e.getCommandUsed((WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/"), ""), locals);
|
||||||
usage.send(fp);
|
usage.send(fp);
|
||||||
String message = e.getMessage();
|
String message = e.getMessage();
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user