Make command usage send with the correct label & bump version

This commit is contained in:
Luck 2016-07-17 14:44:52 +01:00
parent d33a3ffcea
commit 24ff465679
60 changed files with 146 additions and 144 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>luckperms</artifactId>
<groupId>me.lucko</groupId>
<version>1.0-SNAPSHOT</version>
<version>1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -18,7 +18,7 @@ class CommandManagerBukkit extends CommandManager implements CommandExecutor, Ta
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return onCommand(makeSender(sender), Arrays.asList(args));
return onCommand(makeSender(sender), label, Arrays.asList(args));
}

View File

@ -28,7 +28,7 @@ import java.util.stream.Collectors;
@Getter
public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
public static final String VERSION = "v1.0";
public static final String VERSION = "v1.1";
private LPConfiguration configuration;
private UserManager userManager;

View File

@ -1,6 +1,6 @@
name: LuckPerms
author: Luck
version: 1.0
version: 1.1
main: me.lucko.luckperms.LPBukkitPlugin
softdepend: [Vault]
description: A permissions plugin

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>luckperms</artifactId>
<groupId>me.lucko</groupId>
<version>1.0-SNAPSHOT</version>
<version>1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -23,7 +23,7 @@ import java.util.stream.Collectors;
@Getter
public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
public static final String VERSION = "v1.0";
public static final String VERSION = "v1.1";
private LPConfiguration configuration;
private UserManager userManager;
@ -41,6 +41,9 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
// register commands
getProxy().getPluginManager().registerCommand(this, new MainCommand(new CommandManager(this)));
// disable the default Bungee /perms command so it gets handled by the Bukkit plugin
getProxy().getDisabledCommands().add("perms");
final String storageMethod = configuration.getStorageMethod();
if (storageMethod.equalsIgnoreCase("mysql")) {

View File

@ -21,7 +21,7 @@ class MainCommand extends Command implements TabExecutor {
@Override
public void execute(CommandSender sender, String[] args) {
manager.onCommand(makeSender(sender), Arrays.asList(args));
manager.onCommand(makeSender(sender), "bperms", Arrays.asList(args));
}
@Override

View File

@ -1,3 +1,5 @@
name: LuckPerms
author: Luck
version: 1.1
main: me.lucko.luckperms.LPBungeePlugin
author: Luck
description: A permissions plugin

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>luckperms</artifactId>
<groupId>me.lucko</groupId>
<version>1.0-SNAPSHOT</version>
<version>1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -91,36 +91,36 @@ public class CommandManager {
* @param args the arguments provided
* @return if the command was successful (hint: it always is :> )
*/
public boolean onCommand(Sender sender, List<String> args) {
public boolean onCommand(Sender sender, String label, List<String> args) {
if (args.size() == 0) {
sendCommandUsage(sender);
sendCommandUsage(sender, label);
return true;
}
Optional<MainCommand> o = mainCommands.stream().filter(m -> m.getName().equalsIgnoreCase(args.get(0))).limit(1).findAny();
if (!o.isPresent()) {
sendCommandUsage(sender);
sendCommandUsage(sender, label);
return true;
}
final MainCommand main = o.get();
if (!main.canUse(sender)) {
sendCommandUsage(sender);
sendCommandUsage(sender, label);
return true;
}
if (main.getRequiredArgsLength() == 0) {
main.execute(plugin, sender, null);
main.execute(plugin, sender, null, label);
return true;
}
if (args.size() == 1) {
main.sendUsage(sender);
main.sendUsage(sender, label);
return true;
}
main.execute(plugin, sender, new ArrayList<>(args.subList(1, args.size())));
main.execute(plugin, sender, new ArrayList<>(args.subList(1, args.size())), label);
return true;
}
@ -155,11 +155,11 @@ public class CommandManager {
mainCommands.add(command);
}
private void sendCommandUsage(Sender sender) {
private void sendCommandUsage(Sender sender, String label) {
Message.INFO_BRIEF.send(sender, plugin.getVersion());
mainCommands.stream()
.filter(c -> c.canUse(sender))
.forEach(c -> Util.sendPluginMessage(sender, "&e-> &d" + c.getUsage()));
.forEach(c -> Util.sendPluginMessage(sender, "&e-> &d" + String.format(c.getUsage(), label)));
}
}

View File

@ -18,13 +18,13 @@ public abstract class MainCommand {
private final String usage;
private final int requiredArgsLength;
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, List<String> args);
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label);
protected abstract List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin);
public abstract List<? extends SubCommand> getSubCommands();
protected void sendUsage(Sender sender) {
protected void sendUsage(Sender sender, String label) {
if (getSubCommands().isEmpty()) {
Util.sendPluginMessage(sender, "&e-> &d" + getUsage());
Util.sendPluginMessage(sender, "&e-> &d" + String.format(getUsage(), label));
return;
}
@ -33,7 +33,7 @@ public abstract class MainCommand {
Util.sendPluginMessage(sender, "&e" + getName() + " Sub Commands:");
for (SubCommand s : subs) {
s.sendUsage(sender);
s.sendUsage(sender, label);
}
} else {

View File

@ -51,8 +51,8 @@ public abstract class SubCommand {
return permission.isAuthorized(sender);
}
public void sendUsage(Sender sender) {
Util.sendPluginMessage(sender, "&e-> &d" + getUsage());
public void sendUsage(Sender sender, String label) {
Util.sendPluginMessage(sender, "&e-> &d" + String.format(getUsage(), label));
}
public List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {

View File

@ -32,10 +32,6 @@ public class Util {
return new String(b);
}
public static boolean startsWithIgnoreCase(String s, String startsWith) {
return s.toLowerCase().startsWith(startsWith);
}
public static void sendBoolean(Sender sender, String node, boolean b) {
if (b) {
sender.sendMessage(Util.color("&b" + node + ": &atrue"));

View File

@ -13,13 +13,13 @@ import java.util.List;
public class CreateGroupCommand extends MainCommand {
public CreateGroupCommand() {
super("CreateGroup", "/perms creategroup <group>", 1);
super("CreateGroup", "/%s creategroup <group>", 1);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
if (args.size() == 0) {
sendUsage(sender);
sendUsage(sender, label);
return;
}

View File

@ -15,13 +15,13 @@ import java.util.stream.Collectors;
public class DeleteGroupCommand extends MainCommand {
public DeleteGroupCommand() {
super("DeleteGroup", "/perms deletegroup <group>", 1);
super("DeleteGroup", "/%s deletegroup <group>", 1);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
if (args.size() == 0) {
sendUsage(sender);
sendUsage(sender, label);
return;
}

View File

@ -17,13 +17,13 @@ public class GroupMainCommand extends MainCommand {
private final List<GroupSubCommand> subCommands = new ArrayList<>();
public GroupMainCommand() {
super("Group", "/perms group <group>", 2);
super("Group", "/%s group <group>", 2);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
if (args.size() < 2) {
sendUsage(sender);
sendUsage(sender, label);
return;
}
@ -46,7 +46,7 @@ public class GroupMainCommand extends MainCommand {
}
if (sub.isArgLengthInvalid(strippedArgs.size())) {
sub.sendUsage(sender);
sub.sendUsage(sender, label);
return;
}
@ -63,7 +63,7 @@ public class GroupMainCommand extends MainCommand {
return;
}
sub.execute(plugin, sender, group, strippedArgs);
sub.execute(plugin, sender, group, strippedArgs, label);
});
}

View File

@ -14,7 +14,7 @@ public abstract class GroupSubCommand extends SubCommand {
super(name, description, usage, permission);
}
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args);
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label);
protected void saveGroup(Group group, Sender sender, LuckPermsPlugin plugin) {
plugin.getDatastore().saveGroup(group, success -> {

View File

@ -14,11 +14,11 @@ import java.util.List;
public class ListGroupsCommand extends MainCommand {
public ListGroupsCommand() {
super("ListGroups", "/perms listgroups", 0);
super("ListGroups", "/%s listgroups", 0);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
plugin.getDatastore().loadAllGroups(success -> {
if (!success) {
Message.GROUPS_LOAD_ERROR.send(sender);

View File

@ -11,11 +11,11 @@ import java.util.List;
public class GroupClearCommand extends GroupSubCommand {
public GroupClearCommand() {
super("clear", "Clears a groups permissions", "/perms group <group> clear", Permission.GROUP_CLEAR);
super("clear", "Clears a groups permissions", "/%s group <group> clear", Permission.GROUP_CLEAR);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
group.clearNodes();
Message.CLEAR_SUCCESS.send(sender, group.getName());

View File

@ -12,11 +12,11 @@ import java.util.List;
public class GroupHasPermCommand extends GroupSubCommand {
public GroupHasPermCommand() {
super("haspermission", "Checks to see if a group has a certain permission node",
"/perms group <group> haspermission <node> [server]", Permission.GROUP_HASPERMISSION);
"/%s group <group> haspermission <node> [server]", Permission.GROUP_HASPERMISSION);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
if (args.size() == 2) {
Util.sendBoolean(sender, args.get(0), group.hasPermission(args.get(0), true, args.get(1).toLowerCase()));
} else {

View File

@ -11,12 +11,12 @@ import java.util.List;
public class GroupInfoCommand extends GroupSubCommand {
public GroupInfoCommand() {
super("info", "Gives info about the group", "/perms group <group> info", Permission.GROUP_INFO);
super("info", "Gives info about the group", "/%s group <group> info", Permission.GROUP_INFO);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
Message.GROUP_INFO.send(sender, group.getName(), group.getNodes().keySet().size(), group.getName());
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
Message.GROUP_INFO.send(sender, group.getName(), group.getNodes().keySet().size(), label, group.getName());
}
@Override

View File

@ -12,11 +12,11 @@ import java.util.List;
public class GroupInheritsPermCommand extends GroupSubCommand {
public GroupInheritsPermCommand() {
super("inheritspermission", "Checks to see if a group inherits a certain permission node",
"/perms group <group> inheritspermission <node> [server]", Permission.GROUP_INHERITSPERMISSION);
"/%s group <group> inheritspermission <node> [server]", Permission.GROUP_INHERITSPERMISSION);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
if (args.size() == 2) {
Util.sendBoolean(sender, args.get(0), group.inheritsPermission(args.get(0), true, args.get(1).toLowerCase()));
} else {

View File

@ -12,12 +12,12 @@ import java.util.List;
public class GroupListNodesCommand extends GroupSubCommand {
public GroupListNodesCommand() {
super("listnodes", "Lists the permission nodes the group has", "/perms group <group> listnodes",
super("listnodes", "Lists the permission nodes the group has", "/%s group <group> listnodes",
Permission.GROUP_LISTNODES);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
Message.LISTNODES.send(sender, group.getName(), Util.nodesToString(group.getNodes()));
}

View File

@ -13,11 +13,11 @@ import java.util.List;
public class GroupSetInheritCommand extends GroupSubCommand {
public GroupSetInheritCommand() {
super("setinherit", "Sets another group for this group to inherit permissions from",
"/perms group <group> setinherit <group> [server]", Permission.GROUP_SETINHERIT);
"/%s group <group> setinherit <group> [server]", Permission.GROUP_SETINHERIT);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
String groupName = args.get(0).toLowerCase();
plugin.getDatastore().loadGroup(groupName, success -> {

View File

@ -13,17 +13,17 @@ import java.util.List;
public class GroupSetPermissionCommand extends GroupSubCommand {
public GroupSetPermissionCommand() {
super("set", "Sets a permission for a group", "/perms group <group> set <node> <true|false> [server]",
super("set", "Sets a permission for a group", "/%s group <group> set <node> <true|false> [server]",
Permission.GROUP_SETPERMISSION);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
String node = args.get(0);
String bool = args.get(1).toLowerCase();
if (node.contains("/")) {
sendUsage(sender);
sendUsage(sender, label);
return;
}
@ -33,7 +33,7 @@ public class GroupSetPermissionCommand extends GroupSubCommand {
}
if (!bool.equalsIgnoreCase("true") && !bool.equalsIgnoreCase("false")) {
sendUsage(sender);
sendUsage(sender, label);
return;
}

View File

@ -14,11 +14,11 @@ import java.util.stream.Collectors;
public class GroupShowTracksCommand extends GroupSubCommand {
public GroupShowTracksCommand() {
super("showtracks", "Lists the tracks that this group features on", "/perms group <group> showtracks", Permission.GROUP_SHOWTRACKS);
super("showtracks", "Lists the tracks that this group features on", "/%s group <group> showtracks", Permission.GROUP_SHOWTRACKS);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
plugin.getDatastore().loadAllTracks(success -> {
if (!success) {
Message.TRACKS_LOAD_ERROR.send(sender);

View File

@ -14,15 +14,15 @@ import java.util.List;
public class GroupUnSetPermissionCommand extends GroupSubCommand {
public GroupUnSetPermissionCommand() {
super("unset", "Unsets a permission for a group",
"/perms group <group> unset <node> [server]", Permission.GROUP_UNSETPERMISSION);
"/%s group <group> unset <node> [server]", Permission.GROUP_UNSETPERMISSION);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
String node = args.get(0);
if (node.contains("/")) {
sendUsage(sender);
sendUsage(sender, label);
return;
}

View File

@ -13,11 +13,11 @@ import java.util.List;
public class GroupUnsetInheritCommand extends GroupSubCommand {
public GroupUnsetInheritCommand() {
super("unsetinherit", "Unsets another group for this group to inherit permissions from",
"/perms group <group> unsetinherit <group> [server]", Permission.GROUP_UNSETINHERIT);
"/%s group <group> unsetinherit <group> [server]", Permission.GROUP_UNSETINHERIT);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
String groupName = args.get(0).toLowerCase();
try {

View File

@ -12,11 +12,11 @@ import java.util.List;
public class DebugCommand extends MainCommand {
public DebugCommand() {
super("Debug", "/perms debug", 0);
super("Debug", "/%s debug", 0);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
Message.DEBUG.send(sender, plugin.getPlayerCount(), plugin.getUserManager().getUsers().size(),
plugin.getGroupManager().getGroups().size(), plugin.getTrackManager().getTracks().size()
);

View File

@ -12,11 +12,11 @@ import java.util.List;
public class InfoCommand extends MainCommand {
public InfoCommand() {
super("Info", "/perms info", 0);
super("Info", "/%s info", 0);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
Message.INFO.send(sender, plugin.getVersion(), plugin.getDatastore().getName());
}

View File

@ -12,11 +12,11 @@ import java.util.List;
public class SyncCommand extends MainCommand {
public SyncCommand() {
super("Sync", "/perms sync", 0);
super("Sync", "/%s sync", 0);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
Message.UPDATE_TASK_RUN.send(sender);
plugin.runUpdateTask();
}

View File

@ -13,13 +13,13 @@ import java.util.List;
public class CreateTrackCommand extends MainCommand {
public CreateTrackCommand() {
super("CreateTrack", "/perms createtrack <track>", 1);
super("CreateTrack", "/%s createtrack <track>", 1);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
if (args.size() == 0) {
sendUsage(sender);
sendUsage(sender, label);
return;
}

View File

@ -15,13 +15,13 @@ import java.util.stream.Collectors;
public class DeleteTrackCommand extends MainCommand {
public DeleteTrackCommand() {
super("DeleteTrack", "/perms deletetrack <track>", 1);
super("DeleteTrack", "/%s deletetrack <track>", 1);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
if (args.size() == 0) {
sendUsage(sender);
sendUsage(sender, label);
return;
}

View File

@ -14,11 +14,11 @@ import java.util.List;
public class ListTracksCommand extends MainCommand {
public ListTracksCommand() {
super("ListTracks", "/perms listtracks", 0);
super("ListTracks", "/%s listtracks", 0);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
plugin.getDatastore().loadAllTracks(success -> {
if (!success) {
Message.TRACKS_LOAD_ERROR.send(sender);

View File

@ -17,13 +17,13 @@ public class TrackMainCommand extends MainCommand {
private final List<TrackSubCommand> subCommands = new ArrayList<>();
public TrackMainCommand() {
super("Track", "/perms track <track>", 2);
super("Track", "/%s track <track>", 2);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
if (args.size() < 2) {
sendUsage(sender);
sendUsage(sender, label);
return;
}
@ -46,7 +46,7 @@ public class TrackMainCommand extends MainCommand {
}
if (sub.isArgLengthInvalid(strippedArgs.size())) {
sub.sendUsage(sender);
sub.sendUsage(sender, label);
return;
}
@ -63,7 +63,7 @@ public class TrackMainCommand extends MainCommand {
return;
}
sub.execute(plugin, sender, track, strippedArgs);
sub.execute(plugin, sender, track, strippedArgs, label);
});
}

View File

@ -14,7 +14,7 @@ public abstract class TrackSubCommand extends SubCommand {
super(name, description, usage, permission);
}
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args);
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label);
protected void saveTrack(Track track, Sender sender, LuckPermsPlugin plugin) {
plugin.getDatastore().saveTrack(track, success -> {

View File

@ -14,11 +14,11 @@ import java.util.List;
public class TrackAppendCommand extends TrackSubCommand {
public TrackAppendCommand() {
super("append", "Appends a group onto the end of the track", "/perms track <track> append <group>", Permission.TRACK_APPEND);
super("append", "Appends a group onto the end of the track", "/%s track <track> append <group>", Permission.TRACK_APPEND);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
String groupName = args.get(0).toLowerCase();
plugin.getDatastore().loadGroup(groupName, success -> {

View File

@ -11,11 +11,11 @@ import java.util.List;
public class TrackClearCommand extends TrackSubCommand {
public TrackClearCommand() {
super("clear", "Clears the groups on the track", "/perms track <track> clear", Permission.TRACK_CLEAR);
super("clear", "Clears the groups on the track", "/%s track <track> clear", Permission.TRACK_CLEAR);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
track.clearGroups();
Message.TRACK_CLEAR.send(sender, track.getName());
saveTrack(track, sender, plugin);

View File

@ -12,11 +12,11 @@ import java.util.List;
public class TrackInfoCommand extends TrackSubCommand {
public TrackInfoCommand() {
super("info", "Gives info about the track", "/perms track <track> info", Permission.TRACK_INFO);
super("info", "Gives info about the track", "/%s track <track> info", Permission.TRACK_INFO);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
Message.TRACK_INFO.send(sender, track.getName(), Util.listToArrowSep(track.getGroups()));
}

View File

@ -15,11 +15,11 @@ import java.util.List;
public class TrackInsertCommand extends TrackSubCommand {
public TrackInsertCommand() {
super("insert", "Inserts a group at a given position along the track",
"/perms track <track> insert <group> <position>", Permission.TRACK_INSERT);
"/%s track <track> insert <group> <position>", Permission.TRACK_INSERT);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
String groupName = args.get(0).toLowerCase();
int pos;
try {

View File

@ -12,11 +12,11 @@ import java.util.List;
public class TrackRemoveCommand extends TrackSubCommand {
public TrackRemoveCommand() {
super("remove", "Removes a group from the track", "/perms track <track> remove <group>", Permission.TRACK_REMOVE);
super("remove", "Removes a group from the track", "/%s track <track> remove <group>", Permission.TRACK_REMOVE);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
String groupName = args.get(0).toLowerCase();
try {
track.removeGroup(groupName);

View File

@ -19,13 +19,13 @@ public class UserMainCommand extends MainCommand {
private final List<UserSubCommand> subCommands = new ArrayList<>();
public UserMainCommand() {
super("User", "/perms user <user>", 2);
super("User", "/%s user <user>", 2);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
if (args.size() < 2) {
sendUsage(sender);
sendUsage(sender, label);
return;
}
@ -49,14 +49,14 @@ public class UserMainCommand extends MainCommand {
}
if (sub.isArgLengthInvalid(strippedArgs.size())) {
sub.sendUsage(sender);
sub.sendUsage(sender, label);
return;
}
final String user = args.get(0);
UUID u = Util.parseUuid(user);
if (u != null) {
runSub(plugin, sender, u, sub, strippedArgs);
runSub(plugin, sender, u, sub, strippedArgs, label);
return;
}
@ -68,7 +68,7 @@ public class UserMainCommand extends MainCommand {
Message.USER_NOT_FOUND.send(sender);
return;
}
runSub(plugin, sender, uuid, sub, strippedArgs);
runSub(plugin, sender, uuid, sub, strippedArgs, label);
});
return;
}
@ -91,7 +91,7 @@ public class UserMainCommand extends MainCommand {
return onAbstractTabComplete(sender, args, plugin);
}
private void runSub(LuckPermsPlugin plugin, Sender sender, UUID uuid, UserSubCommand command, List<String> strippedArgs) {
private void runSub(LuckPermsPlugin plugin, Sender sender, UUID uuid, UserSubCommand command, List<String> strippedArgs, String label) {
plugin.getDatastore().loadUser(uuid, success -> {
if (!success) {
Message.USER_NOT_FOUND.send(sender);
@ -103,7 +103,7 @@ public class UserMainCommand extends MainCommand {
Message.USER_NOT_FOUND.send(sender);
}
command.execute(plugin, sender, user, strippedArgs);
command.execute(plugin, sender, user, strippedArgs, label);
plugin.getUserManager().cleanupUser(user);
});
}

View File

@ -14,7 +14,7 @@ public abstract class UserSubCommand extends SubCommand {
super(name, description, usage, permission);
}
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args);
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label);
protected void saveUser(User user, Sender sender, LuckPermsPlugin plugin) {
user.refreshPermissions();

View File

@ -13,11 +13,11 @@ import java.util.List;
public class UserAddGroupCommand extends UserSubCommand {
public UserAddGroupCommand() {
super("addgroup", "Adds the user to a group", "/perms user <user> addgroup <group> [server]", Permission.USER_ADDGROUP);
super("addgroup", "Adds the user to a group", "/%s user <user> addgroup <group> [server]", Permission.USER_ADDGROUP);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
String groupName = args.get(0).toLowerCase();
plugin.getDatastore().loadGroup(groupName, success -> {

View File

@ -11,11 +11,11 @@ import java.util.List;
public class UserClearCommand extends UserSubCommand {
public UserClearCommand() {
super("clear", "Clears a users permissions and groups", "/perms user <user> clear", Permission.USER_CLEAR);
super("clear", "Clears a users permissions and groups", "/%s user <user> clear", Permission.USER_CLEAR);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
user.clearNodes();
plugin.getUserManager().giveDefaults(user);
Message.CLEAR_SUCCESS.send(sender, user.getName());

View File

@ -16,11 +16,11 @@ import java.util.List;
public class UserDemoteCommand extends UserSubCommand {
public UserDemoteCommand() {
super("demote", "Demotes a user along a track", "/perms user <user> demote <track>", Permission.USER_DEMOTE);
super("demote", "Demotes a user along a track", "/%s user <user> demote <track>", Permission.USER_DEMOTE);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
final String trackName = args.get(0).toLowerCase();
plugin.getDatastore().loadTrack(trackName, success -> {

View File

@ -11,11 +11,11 @@ import java.util.List;
public class UserGetUUIDCommand extends UserSubCommand {
public UserGetUUIDCommand() {
super("getuuid", "Get the UUID of a user", "/perms user <user> getuuid", Permission.USER_GETUUID);
super("getuuid", "Get the UUID of a user", "/%s user <user> getuuid", Permission.USER_GETUUID);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
Message.USER_GETUUID.send(sender, user.getName(), user.getUuid().toString());
}

View File

@ -12,11 +12,11 @@ import java.util.List;
public class UserHasPermCommand extends UserSubCommand {
public UserHasPermCommand() {
super("haspermission", "Checks to see if a user has a certain permission node",
"/perms user <user> haspermission <node> [server]", Permission.USER_HASPERMISSION);
"/%s user <user> haspermission <node> [server]", Permission.USER_HASPERMISSION);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
if (args.size() >= 2) {
Util.sendBoolean(sender, args.get(0), user.hasPermission(args.get(0), true, args.get(1)));
} else {

View File

@ -12,14 +12,14 @@ import java.util.List;
public class UserInfoCommand extends UserSubCommand {
public UserInfoCommand() {
super("info", "Gives info about the user", "/perms user <user> info", Permission.USER_INFO);
super("info", "Gives info about the user", "/%s user <user> info", Permission.USER_INFO);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
Message.USER_INFO.send(sender, user.getName(), user.getUuid(), plugin.getPlayerStatus(user.getUuid()),
Util.listToCommaSep(user.getGroupNames()), user.getPrimaryGroup(),
(user.getNodes().keySet().size() - user.getGroupNames().size()), user.getName()
(user.getNodes().keySet().size() - user.getGroupNames().size()), label, user.getName()
);
}

View File

@ -12,11 +12,11 @@ import java.util.List;
public class UserInheritsPermCommand extends UserSubCommand {
public UserInheritsPermCommand() {
super("inheritspermission", "Checks to see if a user inherits a certain permission node",
"/perms user <user> inheritspermission <node> [server]", Permission.USER_INHERITSPERMISSION);
"/%s user <user> inheritspermission <node> [server]", Permission.USER_INHERITSPERMISSION);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
if (args.size() >= 2) {
Util.sendBoolean(sender, args.get(0), user.inheritsPermission(args.get(0), true, args.get(1)));
} else {

View File

@ -12,11 +12,11 @@ import java.util.List;
public class UserListNodesCommand extends UserSubCommand {
public UserListNodesCommand() {
super("listnodes", "Lists the permission nodes the user has", "/perms user <user> listnodes", Permission.USER_LISTNODES);
super("listnodes", "Lists the permission nodes the user has", "/%s user <user> listnodes", Permission.USER_LISTNODES);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
Message.LISTNODES.send(sender, user.getName(), Util.nodesToString(user.getNodes()));
}

View File

@ -16,11 +16,11 @@ import java.util.List;
public class UserPromoteCommand extends UserSubCommand {
public UserPromoteCommand() {
super("promote", "Promotes the user along a track", "/perms user <user> promote <track>", Permission.USER_PROMOTE);
super("promote", "Promotes the user along a track", "/%s user <user> promote <track>", Permission.USER_PROMOTE);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
final String trackName = args.get(0).toLowerCase();
plugin.getDatastore().loadTrack(trackName, success -> {

View File

@ -12,11 +12,11 @@ import java.util.List;
public class UserRemoveGroupCommand extends UserSubCommand {
public UserRemoveGroupCommand() {
super("removegroup", "Removes a user from a group", "/perms user <user> removegroup <group> [server]", Permission.USER_REMOVEGROUP);
super("removegroup", "Removes a user from a group", "/%s user <user> removegroup <group> [server]", Permission.USER_REMOVEGROUP);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
String groupName = args.get(0).toLowerCase();
if ((args.size() == 1 || (args.size() == 2 && args.get(1).equalsIgnoreCase("global")))

View File

@ -14,16 +14,16 @@ import java.util.List;
public class UserSetPermissionCommand extends UserSubCommand {
public UserSetPermissionCommand() {
super("set", "Sets a permission for a user",
"/perms user <user> set <node> <true|false> [server]", Permission.USER_SETPERMISSION);
"/%s user <user> set <node> <true|false> [server]", Permission.USER_SETPERMISSION);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
String node = args.get(0);
String bool = args.get(1).toLowerCase();
if (node.contains("/")) {
sendUsage(sender);
sendUsage(sender, label);
return;
}
@ -33,7 +33,7 @@ public class UserSetPermissionCommand extends UserSubCommand {
}
if (!bool.equalsIgnoreCase("true") && !bool.equalsIgnoreCase("false")) {
sendUsage(sender);
sendUsage(sender, label);
return;
}

View File

@ -13,11 +13,11 @@ import java.util.List;
public class UserSetPrimaryGroupCommand extends UserSubCommand {
public UserSetPrimaryGroupCommand() {
super("setprimarygroup", "Sets a users primary group",
"/perms user <user> setprimarygroup <group>", Permission.USER_SETPRIMARYGROUP);
"/%s user <user> setprimarygroup <group>", Permission.USER_SETPRIMARYGROUP);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
Group group = plugin.getGroupManager().getGroup(args.get(0).toLowerCase());
if (group == null) {
Message.GROUP_DOES_NOT_EXIST.send(sender);
@ -30,7 +30,7 @@ public class UserSetPrimaryGroupCommand extends UserSubCommand {
}
if (!user.isInGroup(group)) {
Message.USER_PRIMARYGROUP_ERROR_NOTMEMBER.send(sender);
Message.USER_PRIMARYGROUP_ERROR_NOTMEMBER.send(sender, label);
return;
}

View File

@ -13,11 +13,11 @@ import java.util.List;
public class UserShowPosCommand extends UserSubCommand {
public UserShowPosCommand() {
super("showpos", "Shows a users position on a track", "/perms user <user> showpos <track>", Permission.USER_SHOWPOS);
super("showpos", "Shows a users position on a track", "/%s user <user> showpos <track>", Permission.USER_SHOWPOS);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
final String trackName = args.get(0).toLowerCase();
plugin.getDatastore().loadTrack(trackName, success -> {

View File

@ -14,11 +14,12 @@ import java.util.stream.Collectors;
public class UserShowTracksCommand extends UserSubCommand {
public UserShowTracksCommand() {
super("showtracks", "Lists the tracks that this user's primary group features on", "/perms user <user> showtracks", Permission.USER_SHOWTRACKS);
super("showtracks", "Lists the tracks that this user's primary group features on", "/%s user <user> showtracks",
Permission.USER_SHOWTRACKS);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
plugin.getDatastore().loadAllTracks(success -> {
if (!success) {
Message.TRACKS_LOAD_ERROR.send(sender);

View File

@ -14,15 +14,15 @@ import java.util.List;
public class UserUnSetPermissionCommand extends UserSubCommand {
public UserUnSetPermissionCommand() {
super("unset", "Unsets a permission for a user",
"/perms user <user> unset <node> [server]", Permission.USER_UNSETPERMISSION);
"/%s user <user> unset <node> [server]", Permission.USER_UNSETPERMISSION);
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
String node = args.get(0);
if (node.contains("/")) {
sendUsage(sender);
sendUsage(sender, label);
return;
}

View File

@ -120,7 +120,7 @@ public enum Message {
PREFIX + "&d-> &eGroups: &6%s" + "\n" +
PREFIX + "&d-> &ePrimary Group: &6%s" + "\n" +
PREFIX + "&d-> &ePermissions: &6%s" + "\n" +
PREFIX + "&d-> &bUse &a/perms user %s listnodes &bto see all permissions.",
PREFIX + "&d-> &bUse &a/%s user %s listnodes &bto see all permissions.",
false
),
USER_GETUUID("&bThe UUID of &e%s&b is &e%s&b.", true),
@ -131,7 +131,7 @@ public enum Message {
USER_REMOVEGROUP_ERROR_PRIMARY("You cannot remove a user from their primary group.", true),
USER_PRIMARYGROUP_SUCCESS("&b%s&a's primary group was set to &b%s&a.", true),
USER_PRIMARYGROUP_ERROR_ALREADYHAS("The user already has this group set as their primary group.", true),
USER_PRIMARYGROUP_ERROR_NOTMEMBER("The user must be a member of the group first! Use &4/perms user <user> addgroup <group>", true),
USER_PRIMARYGROUP_ERROR_NOTMEMBER("The user must be a member of the group first! Use &4/%s user <user> addgroup <group>", true),
USER_SHOWTRACKS_INFO("&aShowing tracks that contain the group '&b%s&a' (%s's primary group)", true),
USER_PROMOTE_SUCCESS_PROMOTE("&aPromoting user along track &b%s&a from &b%s&a to &b%s&a.", true),
USER_PROMOTE_SUCCESS_REMOVE("&b%s&a was removed from &b%s&a, added to &b%s&a, and their primary group was set to &b%s&a.", true),
@ -156,7 +156,7 @@ public enum Message {
GROUP_INFO(
PREFIX + "&d-> &eGroup: &6%s" + "\n" +
PREFIX + "&d-> &ePermissions: &6%s" + "\n" +
PREFIX + "&d-> &bUse &a/perms group %s listnodes &bto see all permissions.",
PREFIX + "&d-> &bUse &a/%s group %s listnodes &bto see all permissions.",
false
),
GROUP_SETINHERIT_SUCCESS("&b%s&a now inherits permissions from &b%s&a.", true),

View File

@ -7,7 +7,7 @@
<groupId>me.lucko</groupId>
<artifactId>luckperms</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.1</version>
<modules>
<module>bukkit</module>
<module>common</module>