diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java b/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java index 34b89eee..b87aa3a0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java @@ -133,8 +133,11 @@ public class CommandManager { return CommandResult.INVALID_ARGS; } + List arguments = new ArrayList<>(args); + handleRewrites(arguments); + try { - return main.execute(plugin, sender, new ArrayList<>(args.subList(1, args.size())), label); + return main.execute(plugin, sender, arguments.subList(1, arguments.size()), label); } catch (Exception e) { e.printStackTrace(); return CommandResult.FAILURE; @@ -184,4 +187,93 @@ public class CommandManager { .filter(c -> c.isAuthorized(sender)) .forEach(c -> Util.sendPluginMessage(sender, "&3> &a" + String.format(c.getUsage(), label))); } + + private static void handleRewrites(List args) { + if (args.size() >= 3) { + if (!args.get(0).equalsIgnoreCase("user") && !args.get(0).equalsIgnoreCase("group")) { + return; + } + + + String s = args.get(2).toLowerCase(); + switch (s) { + // Provide aliases + case "p": + case "perm": + case "perms": + args.remove(2); + args.add(2, "permission"); + break; + case "m": + args.remove(2); + args.add(2, "meta"); + break; + case "i": + case "inherit": + case "inheritances": + case "group": + case "rank": + args.remove(2); + args.add(2, "parent"); + break; + + // Provide backwards compatibility + case "listnodes": + args.remove(2); + args.add(2, "permission"); + args.add(3, "info"); + break; + case "set": + case "unset": + case "settemp": + case "unsettemp": + args.add(2, "permission"); + break; + case "listgroups": + args.remove(2); + args.add(2, "parent"); + args.add(3, "info"); + break; + case "addgroup": + case "setinherit": + args.remove(2); + args.add(2, "parent"); + args.add(3, "add"); + break; + case "removegroup": + case "unsetinherit": + args.remove(2); + args.add(2, "parent"); + args.add(3, "remove"); + break; + case "addtempgroup": + case "settempinherit": + args.remove(2); + args.add(2, "parent"); + args.add(3, "addtemp"); + break; + case "removetempgroup": + case "unsettempinherit": + args.remove(2); + args.add(2, "parent"); + args.add(3, "removetemp"); + break; + case "chatmeta": + args.remove(2); + args.add(2, "meta"); + args.add(3, "info"); + break; + case "addprefix": + case "addsuffix": + case "removeprefix": + case "removesuffix": + case "addtempprefix": + case "addtempsuffix": + case "removetempprefix": + case "removetempsuffix": + args.add(2, "meta"); + break; + } + } + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java index 5b62bb2e..accc671e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java @@ -103,7 +103,7 @@ public abstract class SubCommand { } } - Util.sendPluginMessage(sender, "&3> &a" + getName() + usage); + Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + usage); } public void sendDetailedUsage(Sender sender) { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java index ca7461f4..5155aafe 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java @@ -22,6 +22,7 @@ package me.lucko.luckperms.common.commands.generic; +import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.*; import me.lucko.luckperms.common.constants.Message; @@ -38,7 +39,12 @@ public class SecondaryMainCommand extends SubCommand private final List secondaryCommands; public SecondaryMainCommand(String name, String description, boolean user, List secondaryCommands) { - super(name, description, null, Predicate.alwaysFalse(), null); + super(name, description, null, Predicate.alwaysFalse(), + !name.equals("Meta") ? ImmutableList.copyOf(secondaryCommands.stream() + .map(s -> Arg.create(s.getName(), false, s.getDescription())) + .collect(Collectors.toList()) + ) : null + ); this.secondaryCommands = secondaryCommands; this.user = user; }