diff --git a/.locale/en_US.yml b/.locale/en_US.yml index 0bc2e51f..afad7e6e 100644 --- a/.locale/en_US.yml +++ b/.locale/en_US.yml @@ -288,3 +288,443 @@ import-end-error-header: > {PREFIX}&b(Import) &fOutput: import-end-error-content: "&b(Import) &b-> &c{0}" import-end-error-footer: "&b(Import) &7<------------------------------------------>" + +command-specs: + user: + description: "User commands" + usage: "/%s user " + group: + description: "Group commands" + usage: "/%s group " + track: + description: "Track commands" + usage: "/%s track " + log: + description: "Log commands" + usage: "/%s log" + sync: + description: "Sync changes with the storage" + usage: "/%s sync" + info: + description: "Print general plugin info" + usage: "/%s info" + verbose: + description: "Manage verbose permission checking" + usage: "/%s verbose [filter]" + args: + "on|record|off|paste": "whether to enable/disable logging, or to paste the logged output" + "filter": "the filter to match entries against" + tree: + description: "Generate a tree view of permissions" + usage: "/%s tree [selection] [max level] [player]" + args: + "selection": "the root of the tree. specify \".\" to include all permissions" + "max level": "how many branch levels should be returned" + "player": "the name of an online player to check against" + search: + description: "Search for users/groups with a specific permission" + usage: "/%s search " + args: + "permission": "the permission to search for" + "page": "the page to view" + check: + description: "Perform a standard permission check on an online player" + usage: "/%s check " + args: + "user": "the user to check" + "permission": "the permission to check for" + network-sync: + description: "Sync changes with the storage and request that all other servers on the network do the same" + usage: "/%s networksync" + import: + description: "Import data from a file" + usage: "/%s import " + args: + "file": "the file to import from" + export: + description: "Export data to a file" + usage: "/%s export " + args: + "file": "the file to export to" + reload-config: + description: "Reload some of the config options" + usage: "/%s reloadconfig" + bulk-update: + description: "Execute bulk change queries on all data" + usage: "/%s bulkupdate" + args: + "data type": "the type of data being changed. ('all', 'users' or 'groups')" + "action": "the action to perform on the data. ('update' or 'delete')" + "action field": "the field to act upon. only required for 'update'. ('permission', 'server' or 'world')" + "action value": "the value to replace with. only required for 'update'." + "constraint...": "the constraints required for the update" + migration: + description: "Migration commands" + usage: "/%s migration" + apply-edits: + description: "Applies permission changes made from the web editor" + usage: "/%s applyedits [target]" + args: + "code": "the unique code for the data" + "target": "who to apply the data to" + create-group: + description: "Create a new group" + usage: "/%s creategroup " + args: + "name": "the name of the group" + delete-group: + description: "Delete a group" + usage: "/%s deletegroup " + args: + "name": "the name of the group" + list-groups: + description: "List all groups on the platform" + usage: "/%s listgroups" + create-track: + description: "Create a new track" + usage: "/%s createtrack " + args: + "name": "the name of the track" + delete-track: + description: "Delete a track" + usage: "/%s deletetrack " + args: + "name": "the name of the track" + list-tracks: + description: "List all tracks on the platform" + usage: "/%s listtracks" + user-info: + description: "Shows info about the user" + user-switchprimarygroup: + description: "Switches the user's primary group" + args: + "group": "the group to switch to" + user-promote: + description: "Promotes the user up a track" + args: + "track": "the track to promote the user up" + "context...": "the contexts to promote the user in" + user-demote: + description: "Demotes the user down a track" + args: + "track": "the track to demote the user down" + "context...": "the contexts to demote the user in" + group-info: + description: "Gives info about the group" + group-listmembers: + description: "Show the users/groups who inherit from this group" + args: + "page": "the page to view" + group-setweight: + description: "Set the groups weight" + args: + "weight": "the weight to set" + group-rename: + description: "Rename the group" + args: + "name": "the new name" + group-clone: + description: "Clone the group" + args: + "name": "the name of the group to clone onto" + holder-editor: + description: "Opens the web permission editor" + holder-showtracks: + description: "Lists the tracks that the object is on" + holder-clear: + description: "Removes all permissions, parents and meta" + args: + "context...": "the contexts to filter by" + permission: + description: "Edit permissions" + parent: + description: "Edit inheritances" + meta: + description: "Edit metadata values" + permission-info: + description: "Lists the permission nodes the object has" + args: + "page": "the page to view" + "filter": "the string to filter by" + permission-set: + description: "Sets a permission for the object" + args: + "node": "the permission node to set" + "true|false": "the value of the node" + "context...": "the contexts to add the permission in" + permission-unset: + description: "Unsets a permission for the object" + args: + "node": "the permission node to unset" + "context...": "the contexts to remove the permission in" + permission-settemp: + description: "Sets a permission for the object temporarily" + args: + "node": "the permission node to set" + "true|false": "the value of the node" + "duration": "the duration until the permission node expires" + "context...": "the contexts to add the permission in" + permission-unsettemp: + description: "Unsets a temporary permission for the object" + args: + "node": "the permission node to unset" + "context...": "the contexts to remove the permission in" + permission-check: + description: "Checks to see if the object has a certain permission node" + args: + "node": "the permission node to check for" + "context...": "the contexts to check in" + permission-check-inherits: + description: "Checks to see if the object inherits a certain permission node" + args: + "node": "the permission node to check for" + "context...": "the contexts to check in" + parent-info: + description: "Lists the groups that this object inherits from" + parent-set: + description: "Removes all other groups the object inherits already and adds them to the one given" + args: + "group": "the group to set to" + "context...": "the contexts to set the group in" + parent-add: + description: "Sets another group for the object to inherit permissions from" + args: + "group": "the group to inherit from" + "context...": "the contexts to inherit the group in" + parent-remove: + description: "Removes a previously set inheritance rule" + args: + "group": "the group to remove" + "context...": "the contexts to remove the group in" + parent-set-track: + description: "Removes all other groups the object inherits from already on the given track and adds them to the one given" + args: + "track": "the track to set on" + "group": "the group to set to, or a number relating to the position of the group on the given track" + "context...": "the contexts to set the group in" + parent-add-temp: + description: "Sets another group for the object to inherit permissions from temporarily" + args: + "group": "the group to inherit from" + "duration": "the duration of the group membership" + "context...": "the contexts to inherit the group in" + parent-remove-temp: + description: "Removes a previously set temporary inheritance rule" + args: + "group": "the group to remove" + "context...": "the contexts to remove the group in" + parent-clear: + description: "Clears all parents" + args: + "context...": "the contexts to filter by" + parent-clear-track: + description: "Clears all parents on a given track" + args: + "track": "the track to remove on" + "context...": "the contexts to filter by" + meta-info: + description: "Shows all chat meta" + meta-set: + description: "Sets a meta value" + args: + "key": "the key to set" + "value": "the value to set" + "context...": "the contexts to add the meta pair in" + meta-unset: + description: "Unsets a meta value" + args: + "key": "the key to unset" + "context...": "the contexts to remove the meta pair in" + meta-settemp: + description: "Sets a meta value temporarily" + args: + "key": "the key to set" + "value": "the value to set" + "duration": "the duration until the meta value expires" + "context...": "the contexts to add the meta pair in" + meta-unsettemp: + description: "Unsets a temporary meta value" + args: + "key": "the key to unset" + "context...": "the contexts to remove the meta pair in" + meta-addprefix: + description: "Adds a prefix" + args: + "priority": "the priority to add the prefix at" + "prefix": "the prefix string" + "context...": "the contexts to add the prefix in" + meta-addsuffix: + description: "Adds a suffix" + args: + "priority": "the priority to add the suffix at" + "suffix": "the suffix string" + "context...": "the contexts to add the suffix in" + meta-removeprefix: + description: "Removes a prefix" + args: + "priority": "the priority to remove the prefix at" + "prefix": "the prefix string" + "context...": "the contexts to remove the prefix in" + meta-removesuffix: + description: "Removes a suffix" + args: + "priority": "the priority to remove the suffix at" + "suffix": "the suffix string" + "context...": "the contexts to remove the suffix in" + meta-addtemp-prefix: + description: "Adds a prefix temporarily" + args: + "priority": "the priority to add the prefix at" + "prefix": "the prefix string" + "duration": "the duration until the prefix expires" + "context...": "the contexts to add the prefix in" + meta-addtemp-suffix: + description: "Adds a suffix temporarily" + args: + "priority": "the priority to add the suffix at" + "suffix": "the suffix string" + "duration": "the duration until the suffix expires" + "context...": "the contexts to add the suffix in" + meta-removetemp-prefix: + description: "Removes a temporary prefix" + args: + "priority": "the priority to remove the prefix at" + "prefix": "the prefix string" + "context...": "the contexts to remove the prefix in" + meta-removetemp-suffix: + description: "Removes a temporary suffix" + args: + "priority": "the priority to remove the suffix at" + "suffix": "the suffix string" + "context...": "the contexts to remove the suffix in" + meta-clear: + description: "Clears all chat meta" + args: + "context...": "the contexts to filter by" + track-info: + description: "Gives info about the track" + track-append: + description: "Appends a group onto the end of the track" + args: + "group": "the group to append" + track-insert: + description: "Inserts a group at a given position along the track" + args: + "group": "the group to insert" + "position": "the position to insert the group at (the first position on the track is 1)" + track-remove: + description: "Removes a group from the track" + args: + "group": "the group to remove" + track-clear: + description: "Clears the groups on the track" + track-rename: + description: "Rename the track" + args: + "name": "the new name" + track-clone: + description: "Clone the track" + args: + "name": "the name of the track to clone onto" + log-recent: + description: "View recent actions" + args: + "user": "the name/uuid of the user to filter by" + "page": "the page number to view" + log-search: + description: "Search the log for an entry" + args: + "query": "the query to search by" + "page": "the page number to view" + log-notify: + description: "Toggle log notifications" + args: + "on|off": "whether to toggle on or off" + log-user-history: + description: "View a user's history" + args: + "user": "the name/uuid of the user" + "page": "the page number to view" + log-group-history: + description: "View an group's history" + args: + "group": "the name of the group" + "page": "the page number to view" + log-track-history: + description: "View a track's history" + args: + "track": "the name of the track" + "page": "the page number to view" + sponge: + description: "Edit extra Sponge data" + usage: "/%s sponge " + args: + "collection": "the collection to query" + "subject": "the subject to modify" + sponge-permission-info: + description: "Shows info about the subject's permissions" + args: + "contexts...": "the contexts to filter by" + sponge-permission-set: + description: "Sets a permission for the Subject" + args: + "node": "the permission node to set" + "tristate": "the value to set the permission to" + "contexts...": "the contexts to set the permission in" + sponge-permission-clear: + description: "Clears the Subjects permissions" + args: + "contexts...": "the contexts to clear permissions in" + sponge-parent-info: + description: "Shows info about the subject's parents" + args: + "contexts...": "the contexts to filter by" + sponge-parent-add: + description: "Adds a parent to the Subject" + args: + "collection": "the subject collection where the parent Subject is" + "subject": "the name of the parent Subject" + "contexts...": "the contexts to add the parent in" + sponge-parent-remove: + description: "Removes a parent from the Subject" + args: + "collection": "the subject collection where the parent Subject is" + "subject": "the name of the parent Subject" + "contexts...": "the contexts to remove the parent in" + sponge-parent-clear: + description: "Clears the Subjects parents" + args: + "contexts...": "the contexts to clear parents in" + sponge-option-info: + description: "Shows info about the subject's options" + args: + "contexts...": "the contexts to filter by" + sponge-option-set: + description: "Sets an option for the Subject" + args: + "key": "the key to set" + "value": "the value to set the key to" + "contexts...": "the contexts to set the option in" + sponge-option-unset: + description: "Unsets an option for the Subject" + args: + "key": "the key to unset" + "contexts...": "the contexts to unset the key in" + sponge-option-clear: + description: "Clears the Subjects options" + args: + "contexts...": "the contexts to clear options in" + migration-command: + description: "Migration command" + migration-groupmanager: + description: "Migration command" + args: + "migrate as global": "if world permissions should be ignored, and just migrated as global" + migration-powerfulperms: + description: "Migration command" + args: + "address": "the address of the PP database" + "database": "the name of the PP database" + "username": "the username to log into the DB" + "password": "the password to log into the DB" + "db table": "the name of the PP table where player data is stored" diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java index 43ca6d2c..e8109780 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java @@ -30,8 +30,8 @@ import lombok.RequiredArgsConstructor; import me.lucko.luckperms.bukkit.model.Injector; import me.lucko.luckperms.bukkit.model.LPPermissible; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.utils.LoginHelper; import org.bukkit.entity.Player; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java index 6a75d30e..c31df9e8 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java @@ -42,6 +42,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.ProgressLogger; @@ -70,8 +72,8 @@ public class MigrationBPermissions extends SubCommand { } } - public MigrationBPermissions() { - super("bpermissions", "Migration from bPermissions", MIGRATION, Predicates.alwaysFalse(), null); + public MigrationBPermissions(LocaleManager locale) { + super(CommandSpec.MIGRATION_COMMAND.spec(locale), "bpermissions", MIGRATION, Predicates.alwaysFalse()); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java index 09ade3a6..49b73410 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java @@ -28,7 +28,6 @@ package me.lucko.luckperms.bukkit.migration; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -36,6 +35,8 @@ import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.ProgressLogger; @@ -60,10 +61,8 @@ import java.util.function.Function; import java.util.stream.Collectors; public class MigrationGroupManager extends SubCommand { - public MigrationGroupManager() { - super("groupmanager", "Migration from GroupManager", Permission.MIGRATION, Predicates.is(0), - Arg.list(Arg.create("migrate as global", true, "if world permissions should be ignored, and just migrated as global")) - ); + public MigrationGroupManager(LocaleManager locale) { + super(CommandSpec.MIGRATION_GROUPMANAGER.spec(locale), "groupmanager", Permission.MIGRATION, Predicates.is(0)); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java index ddc4b498..3413452d 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java @@ -36,6 +36,8 @@ import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.ProgressLogger; @@ -56,8 +58,8 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; public class MigrationPermissionsEx extends SubCommand { - public MigrationPermissionsEx() { - super("permissionsex", "Migration from PermissionsEx", Permission.MIGRATION, Predicates.alwaysFalse(), null); + public MigrationPermissionsEx(LocaleManager locale) { + super(CommandSpec.MIGRATION_COMMAND.spec(locale), "permissionsex", Permission.MIGRATION, Predicates.alwaysFalse()); } @SuppressWarnings("deprecation") diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java index 155d86a6..ef50fef5 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java @@ -35,7 +35,6 @@ import com.github.cheesesoftware.PowerfulPermsAPI.PowerfulPermsPlugin; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -46,6 +45,8 @@ import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.dependencies.DependencyManager; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.storage.StorageType; import me.lucko.luckperms.common.utils.HikariSupplier; @@ -71,16 +72,8 @@ import static me.lucko.luckperms.common.constants.Permission.MIGRATION; // Only supports the latest versions of the PP API. (it seems to change randomly almost every release) public class MigrationPowerfulPerms extends SubCommand { - public MigrationPowerfulPerms() { - super("powerfulperms", "Migration from PowerfulPerms", MIGRATION, Predicates.not(5), - Arg.list( - Arg.create("address", true, "the address of the PP database"), - Arg.create("database", true, "the name of the PP database"), - Arg.create("username", true, "the username to log into the DB"), - Arg.create("password", true, "the password to log into the DB"), - Arg.create("db table", true, "the name of the PP table where player data is stored") - ) - ); + public MigrationPowerfulPerms(LocaleManager locale) { + super(CommandSpec.MIGRATION_POWERFULPERMS.spec(locale), "powerfulperms", MIGRATION, Predicates.not(5)); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java index ed0ce4a0..b24fc003 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java @@ -40,6 +40,8 @@ import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.ProgressLogger; @@ -62,8 +64,8 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; public class MigrationZPermissions extends SubCommand { - public MigrationZPermissions() { - super("zpermissions", "Migration from zPermissions", Permission.MIGRATION, Predicates.alwaysFalse(), null); + public MigrationZPermissions(LocaleManager locale) { + super(CommandSpec.MIGRATION_COMMAND.spec(locale), "zpermissions", Permission.MIGRATION, Predicates.alwaysFalse()); } @Override diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java index 5f2469c6..18fefe3b 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java @@ -31,8 +31,8 @@ import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.utils.LoginHelper; import net.md_5.bungee.api.chat.TextComponent; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java index d881f714..53577191 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java @@ -34,6 +34,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.ProgressLogger; @@ -50,8 +52,8 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; public class MigrationBungeePerms extends SubCommand { - public MigrationBungeePerms() { - super("bungeeperms", "Migration from BungeePerms", Permission.MIGRATION, Predicates.alwaysFalse(), null); + public MigrationBungeePerms(LocaleManager locale) { + super(CommandSpec.MIGRATION_COMMAND.spec(locale), "bungeeperms", Permission.MIGRATION, Predicates.alwaysFalse()); } @Override 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 0d5a7324..93e4a4b1 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 @@ -57,8 +57,9 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Constants; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.TextUtils; @@ -92,31 +93,33 @@ public class CommandManager { this.plugin = plugin; this.executor = Executors.newSingleThreadExecutor(); + LocaleManager locale = plugin.getLocaleManager(); + mainCommands = ImmutableList.builder() - .add(new UserMainCommand()) - .add(new GroupMainCommand()) - .add(new TrackMainCommand()) + .add(new UserMainCommand(locale)) + .add(new GroupMainCommand(locale)) + .add(new TrackMainCommand(locale)) .addAll(plugin.getExtraCommands()) - .add(new LogMainCommand()) - .add(new SyncCommand()) - .add(new InfoCommand()) - .add(new VerboseCommand()) - .add(new TreeCommand()) - .add(new SearchCommand()) - .add(new CheckCommand()) - .add(new NetworkSyncCommand()) - .add(new ImportCommand()) - .add(new ExportCommand()) - .add(new ReloadConfigCommand()) - .add(new BulkUpdateCommand()) - .add(new MigrationMainCommand()) - .add(new ApplyEditsCommand()) - .add(new CreateGroup()) - .add(new DeleteGroup()) - .add(new ListGroups()) - .add(new CreateTrack()) - .add(new DeleteTrack()) - .add(new ListTracks()) + .add(new LogMainCommand(locale)) + .add(new SyncCommand(locale)) + .add(new InfoCommand(locale)) + .add(new VerboseCommand(locale)) + .add(new TreeCommand(locale)) + .add(new SearchCommand(locale)) + .add(new CheckCommand(locale)) + .add(new NetworkSyncCommand(locale)) + .add(new ImportCommand(locale)) + .add(new ExportCommand(locale)) + .add(new ReloadConfigCommand(locale)) + .add(new BulkUpdateCommand(locale)) + .add(new MigrationMainCommand(locale)) + .add(new ApplyEditsCommand(locale)) + .add(new CreateGroup(locale)) + .add(new DeleteGroup(locale)) + .add(new ListGroups(locale)) + .add(new CreateTrack(locale)) + .add(new DeleteTrack(locale)) + .add(new ListTracks(locale)) .build(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/Command.java b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/Command.java index b4bff452..c711e933 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/Command.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/Command.java @@ -34,6 +34,7 @@ import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.LocalizedSpec; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import java.util.Collections; @@ -49,18 +50,15 @@ import java.util.function.Predicate; */ public abstract class Command { + @Getter + private final LocalizedSpec spec; + /** * The name of the command. Should be properly capitalised. */ @Getter private final String name; - /** - * A brief description of this command - */ - @Getter - private final String description; - /** * The permission required to use this command. Nullable. */ @@ -72,32 +70,25 @@ public abstract class Command { @Getter private final Predicate argumentCheck; - /** - * A list of arguments required for the command. These are just here for informational purposes, and aren't used - * for argument validation. - */ - private final List args; - /** * Child commands. Nullable. */ private final List> children; - public Command(String name, String description, Permission permission, Predicate argumentCheck, List args, List> children) { + public Command(LocalizedSpec spec, String name, Permission permission, Predicate argumentCheck, List> children) { + this.spec = spec; this.name = name; - this.description = description; this.permission = permission; this.argumentCheck = argumentCheck; - this.args = args == null ? null : ImmutableList.copyOf(args); this.children = children == null ? null : ImmutableList.copyOf(children); } - public Command(String name, String description, Permission permission, Predicate argumentCheck, List args) { - this(name, description, permission, argumentCheck, args, null); + public Command(LocalizedSpec spec, String name, Permission permission, Predicate argumentCheck) { + this(spec, name, permission, argumentCheck, null); } - public Command(String name, String description, Predicate argumentCheck) { - this(name, description, null, argumentCheck, null, null); + public Command(LocalizedSpec spec, String name, Predicate argumentCheck) { + this(spec, name, null, argumentCheck, null); } public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, T t, List args, String label) throws CommandException; @@ -147,13 +138,18 @@ public abstract class Command { return true; } + public String getDescription() { + return spec.description(); + } + /** * Returns the usage of this command. Will only return a non empty result for main commands. * * @return the usage of this command. */ public String getUsage() { - return ""; + String usage = spec.usage(); + return usage == null ? "" : usage; } public Optional getPermission() { @@ -161,7 +157,7 @@ public abstract class Command { } public Optional> getArgs() { - return Optional.ofNullable(args); + return Optional.ofNullable(spec.args()); } public Optional>> getChildren() { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/MainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/MainCommand.java index e5200896..5c4902ac 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/MainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/MainCommand.java @@ -25,14 +25,13 @@ package me.lucko.luckperms.common.commands.abstraction; -import lombok.Getter; - import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandManager; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; +import me.lucko.luckperms.common.locale.LocalizedSpec; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -44,13 +43,10 @@ import java.util.stream.Collectors; public abstract class MainCommand extends Command { - @Getter - private final String usage; private final int minArgs; // equals 1 if the command doesn't take a mid argument, e.g. /lp user sub-command.... - public MainCommand(String name, String description, String usage, int minArgs, List> children) { - super(name, description, null, Predicates.alwaysFalse(), null, children); - this.usage = usage; + public MainCommand(LocalizedSpec spec, String name, int minArgs, List> children) { + super(spec, name, null, Predicates.alwaysFalse(), children); this.minArgs = minArgs; } @@ -160,7 +156,7 @@ public abstract class MainCommand extends Command { .collect(Collectors.toList()); if (subs.size() > 0) { - Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(usage, label) + " ...)"); + Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(getUsage(), label) + " ...)"); for (Command s : subs) { s.sendUsage(sender, label); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedMainCommand.java index 3eb583c0..e1e58ef0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedMainCommand.java @@ -30,8 +30,9 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.LocalizedSpec; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -55,8 +56,8 @@ public class SharedMainCommand extends SubCommand */ private boolean user; - public SharedMainCommand(String name, String description, boolean user, List secondaryCommands) { - super(name, description, null, Predicates.alwaysFalse(), null); + public SharedMainCommand(LocalizedSpec spec, String name, boolean user, List secondaryCommands) { + super(spec, name, null, Predicates.alwaysFalse()); this.secondaryCommands = secondaryCommands; this.user = user; } @@ -89,7 +90,7 @@ public class SharedMainCommand extends SubCommand strippedArgs.addAll(args.subList(1, args.size())); } - if (sub.getIsArgumentInvalid().test(strippedArgs.size())) { + if (sub.getArgumentCheck().test(strippedArgs.size())) { sub.sendDetailedUsage(sender); return CommandResult.INVALID_ARGS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedSubCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedSubCommand.java index 5cdbad58..e2eec3af 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedSubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedSubCommand.java @@ -25,11 +25,8 @@ package me.lucko.luckperms.common.commands.abstraction; -import lombok.AllArgsConstructor; import lombok.Getter; -import com.google.common.collect.ImmutableList; - import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; @@ -39,6 +36,7 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.LocalizedSpec; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import java.util.Collections; @@ -50,19 +48,15 @@ import java.util.function.Predicate; * This doesn't extend the other Command or SubCommand classes to avoid generics hell. */ @Getter -@AllArgsConstructor public abstract class SharedSubCommand { + private final LocalizedSpec spec; + /** * The name of the sub command */ private final String name; - /** - * A brief description of what the sub command does - */ - private final String description; - /** * The permission needed to use this command */ @@ -72,8 +66,15 @@ public abstract class SharedSubCommand { /** * Predicate to test if the argument length given is invalid */ - private final Predicate isArgumentInvalid; - private final ImmutableList args; + private final Predicate argumentCheck; + + public SharedSubCommand(LocalizedSpec spec, String name, Permission userPermission, Permission groupPermission, Predicate argumentCheck) { + this.spec = spec; + this.name = name; + this.userPermission = userPermission; + this.groupPermission = groupPermission; + this.argumentCheck = argumentCheck; + } public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List args, String label) throws CommandException; @@ -83,9 +84,9 @@ public abstract class SharedSubCommand { public void sendUsage(Sender sender) { StringBuilder sb = new StringBuilder(); - if (args != null) { + if (getArgs() != null) { sb.append("&3 - &7"); - for (Arg arg : args) { + for (Arg arg : getArgs()) { sb.append(arg.asPrettyString()).append(" "); } } @@ -96,9 +97,9 @@ public abstract class SharedSubCommand { public void sendDetailedUsage(Sender sender) { Util.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName()); Util.sendPluginMessage(sender, "&b> &7" + getDescription()); - if (args != null) { + if (getArgs() != null) { Util.sendPluginMessage(sender, "&3Arguments:"); - for (Arg arg : args) { + for (Arg arg : getArgs()) { Util.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription()); } } @@ -108,6 +109,14 @@ public abstract class SharedSubCommand { return user ? userPermission.isAuthorized(sender) : groupPermission.isAuthorized(sender); } + public String getDescription() { + return spec.description(); + } + + public List getArgs() { + return spec.args(); + } + public static void save(PermissionHolder holder, Sender sender, LuckPermsPlugin plugin) { if (holder instanceof User) { User user = ((User) holder); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SingleCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SingleCommand.java index 7b06a40d..76a2a321 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SingleCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SingleCommand.java @@ -25,14 +25,13 @@ package me.lucko.luckperms.common.commands.abstraction; -import lombok.Getter; - import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.LocalizedSpec; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import java.util.List; @@ -43,12 +42,8 @@ import java.util.function.Predicate; */ public abstract class SingleCommand extends Command { - @Getter - private final String usage; - - public SingleCommand(String name, String description, String usage, Permission permission, Predicate argumentCheck, List args) { - super(name, description, permission, argumentCheck, args, null); - this.usage = usage; + public SingleCommand(LocalizedSpec spec, String name, Permission permission, Predicate argumentCheck) { + super(spec, name, permission, argumentCheck, null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java index 897c590c..1f34d72f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java @@ -33,11 +33,12 @@ import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.LocalizedSpec; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.messaging.NoopMessagingService; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -58,8 +59,8 @@ import java.util.stream.Collectors; @Getter public abstract class SubCommand extends Command { - public SubCommand(String name, String description, Permission permission, Predicate argumentCheck, List args) { - super(name, description, permission, argumentCheck, args); + public SubCommand(LocalizedSpec spec, String name, Permission permission, Predicate argumentCheck) { + super(spec, name, permission, argumentCheck); } /** diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/CommandMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/CommandMeta.java index 563946b6..81c0c0e1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/CommandMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/CommandMeta.java @@ -31,24 +31,26 @@ import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.common.commands.abstraction.SharedMainCommand; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; public class CommandMeta extends SharedMainCommand { - public CommandMeta(boolean user) { - super("Meta", "Edit metadata values", user, ImmutableList.builder() - .add(new MetaInfo()) - .add(new MetaSet()) - .add(new MetaUnset()) - .add(new MetaSetTemp()) - .add(new MetaUnsetTemp()) - .add(new MetaAddChatMeta(ChatMetaType.PREFIX)) - .add(new MetaAddChatMeta(ChatMetaType.SUFFIX)) - .add(new MetaRemoveChatMeta(ChatMetaType.PREFIX)) - .add(new MetaRemoveChatMeta(ChatMetaType.SUFFIX)) - .add(new MetaAddTempChatMeta(ChatMetaType.PREFIX)) - .add(new MetaAddTempChatMeta(ChatMetaType.SUFFIX)) - .add(new MetaRemoveTempChatMeta(ChatMetaType.PREFIX)) - .add(new MetaRemoveTempChatMeta(ChatMetaType.SUFFIX)) - .add(new MetaClear()) + public CommandMeta(LocaleManager locale, boolean user) { + super(CommandSpec.META.spec(locale), "Meta", user, ImmutableList.builder() + .add(new MetaInfo(locale)) + .add(new MetaSet(locale)) + .add(new MetaUnset(locale)) + .add(new MetaSetTemp(locale)) + .add(new MetaUnsetTemp(locale)) + .add(new MetaAddChatMeta(locale, ChatMetaType.PREFIX)) + .add(new MetaAddChatMeta(locale, ChatMetaType.SUFFIX)) + .add(new MetaRemoveChatMeta(locale, ChatMetaType.PREFIX)) + .add(new MetaRemoveChatMeta(locale, ChatMetaType.SUFFIX)) + .add(new MetaAddTempChatMeta(locale, ChatMetaType.PREFIX)) + .add(new MetaAddTempChatMeta(locale, ChatMetaType.SUFFIX)) + .add(new MetaRemoveTempChatMeta(locale, ChatMetaType.PREFIX)) + .add(new MetaRemoveTempChatMeta(locale, ChatMetaType.SUFFIX)) + .add(new MetaClear(locale)) .build()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java index 422b9f68..c7d5c4e7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java @@ -28,18 +28,19 @@ package me.lucko.luckperms.common.commands.impl.generic.meta; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -49,17 +50,13 @@ import java.util.stream.Collectors; public class MetaAddChatMeta extends SharedSubCommand { private final ChatMetaType type; - public MetaAddChatMeta(ChatMetaType type) { - super("add" + type.name().toLowerCase(), - "Adds a " + type.name().toLowerCase(), + public MetaAddChatMeta(LocaleManager locale, ChatMetaType type) { + super( + type == ChatMetaType.PREFIX ? CommandSpec.META_ADDPREFIX.spec(locale) : CommandSpec.META_ADDSUFFIX.spec(locale), + "add" + type.name().toLowerCase(), type == ChatMetaType.PREFIX ? Permission.USER_META_ADDPREFIX : Permission.USER_META_ADDSUFFIX, type == ChatMetaType.PREFIX ? Permission.GROUP_META_ADDPREFIX : Permission.GROUP_META_ADDSUFFIX, - Predicates.inRange(0, 1), - Arg.list( - Arg.create("priority", true, "the priority to add the " + type.name().toLowerCase() + " at"), - Arg.create(type.name().toLowerCase(), true, "the " + type.name().toLowerCase() + " string"), - Arg.create("context...", false, "the contexts to add the " + type.name().toLowerCase() + " in") - ) + Predicates.inRange(0, 1) ); this.type = type; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java index dbbf1e70..e15f6faa 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java @@ -29,7 +29,6 @@ import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; @@ -37,12 +36,14 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.TemporaryModifier; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -54,18 +55,13 @@ import java.util.stream.Collectors; public class MetaAddTempChatMeta extends SharedSubCommand { private final ChatMetaType type; - public MetaAddTempChatMeta(ChatMetaType type) { - super("addtemp" + type.name().toLowerCase(), - "Adds a " + type.name().toLowerCase() + " temporarily", + public MetaAddTempChatMeta(LocaleManager locale, ChatMetaType type) { + super( + type == ChatMetaType.PREFIX ? CommandSpec.META_ADDTEMP_PREFIX.spec(locale) : CommandSpec.META_ADDTEMP_SUFFIX.spec(locale), + "addtemp" + type.name().toLowerCase(), type == ChatMetaType.PREFIX ? Permission.USER_META_ADDTEMP_PREFIX : Permission.USER_META_ADDTEMP_SUFFIX, type == ChatMetaType.PREFIX ? Permission.GROUP_META_ADDTEMP_PREFIX : Permission.GROUP_META_ADDTEMP_SUFFIX, - Predicates.inRange(0, 2), - Arg.list( - Arg.create("priority", true, "the priority to add the " + type.name().toLowerCase() + " at"), - Arg.create(type.name().toLowerCase(), true, "the " + type.name().toLowerCase() + " string"), - Arg.create("duration", true, "the duration until the " + type.name().toLowerCase() + " expires"), - Arg.create("context...", false, "the contexts to add the " + type.name().toLowerCase() + " in") - ) + Predicates.inRange(0, 2) ); this.type = type; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaClear.java index ee509c2e..71af9839 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaClear.java @@ -26,17 +26,18 @@ package me.lucko.luckperms.common.commands.impl.generic.meta; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -44,12 +45,8 @@ import java.util.List; import java.util.stream.Collectors; public class MetaClear extends SharedSubCommand { - public MetaClear() { - super("clear", "Clears all chat meta", Permission.USER_META_CLEAR, Permission.GROUP_META_CLEAR, Predicates.alwaysFalse(), - Arg.list( - Arg.create("context...", false, "the contexts to filter by") - ) - ); + public MetaClear(LocaleManager locale) { + super(CommandSpec.META_CLEAR.spec(locale), "clear", Permission.USER_META_CLEAR, Permission.GROUP_META_CLEAR, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java index 19163193..9cb938c8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java @@ -32,9 +32,11 @@ import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.MetaComparator; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -55,8 +57,8 @@ public class MetaInfo extends SharedSubCommand { return val.replace("&", "{color char}"); } - public MetaInfo() { - super("info", "Shows all chat meta", Permission.USER_META_INFO, Permission.GROUP_META_INFO, Predicates.alwaysFalse(), null); + public MetaInfo(LocaleManager locale) { + super(CommandSpec.META_INFO.spec(locale), "info", Permission.USER_META_INFO, Permission.GROUP_META_INFO, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java index 5f7ee5b8..60cb6b33 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java @@ -28,18 +28,19 @@ package me.lucko.luckperms.common.commands.impl.generic.meta; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -49,17 +50,13 @@ import java.util.stream.Collectors; public class MetaRemoveChatMeta extends SharedSubCommand { private final ChatMetaType type; - public MetaRemoveChatMeta(ChatMetaType type) { - super("remove" + type.name().toLowerCase(), - "Removes a " + type.name().toLowerCase(), + public MetaRemoveChatMeta(LocaleManager locale, ChatMetaType type) { + super( + type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVEPREFIX.spec(locale) : CommandSpec.META_REMOVESUFFIX.spec(locale), + "remove" + type.name().toLowerCase(), type == ChatMetaType.PREFIX ? Permission.USER_META_REMOVEPREFIX : Permission.USER_META_REMOVESUFFIX, type == ChatMetaType.PREFIX ? Permission.GROUP_META_REMOVEPREFIX : Permission.GROUP_META_REMOVESUFFIX, - Predicates.is(0), - Arg.list( - Arg.create("priority", true, "the priority to remove the " + type.name().toLowerCase() + " at"), - Arg.create(type.name().toLowerCase(), false, "the " + type.name().toLowerCase() + " string"), - Arg.create("context...", false, "the contexts to remove the " + type.name().toLowerCase() + " in") - ) + Predicates.is(0) ); this.type = type; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java index f2e872f3..99a6baf8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java @@ -28,18 +28,19 @@ package me.lucko.luckperms.common.commands.impl.generic.meta; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -49,17 +50,13 @@ import java.util.stream.Collectors; public class MetaRemoveTempChatMeta extends SharedSubCommand { private final ChatMetaType type; - public MetaRemoveTempChatMeta(ChatMetaType type) { - super("removetemp" +type.name().toLowerCase(), - "Removes a temporary " + type.name().toLowerCase(), + public MetaRemoveTempChatMeta(LocaleManager locale, ChatMetaType type) { + super( + type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVETEMP_PREFIX.spec(locale) : CommandSpec.META_REMOVETEMP_SUFFIX.spec(locale), + "removetemp" + type.name().toLowerCase(), type == ChatMetaType.PREFIX ? Permission.USER_META_REMOVETEMP_PREFIX : Permission.USER_META_REMOVETEMP_SUFFIX, type == ChatMetaType.PREFIX ? Permission.GROUP_META_REMOVETEMP_PREFIX : Permission.GROUP_META_REMOVETEMP_SUFFIX, - Predicates.is(0), - Arg.list( - Arg.create("priority", true, "the priority to remove the " + type.name().toLowerCase() + " at"), - Arg.create(type.name().toLowerCase(), false, "the " +type.name().toLowerCase() + " string"), - Arg.create("context...", false, "the contexts to remove the " + type.name().toLowerCase() + " in") - ) + Predicates.is(0) ); this.type = type; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java index 4019165d..fafbab25 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java @@ -27,18 +27,19 @@ package me.lucko.luckperms.common.commands.impl.generic.meta; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -46,14 +47,8 @@ import java.util.List; import java.util.stream.Collectors; public class MetaSet extends SharedSubCommand { - public MetaSet() { - super("set", "Sets a meta value", Permission.USER_META_SET, Permission.GROUP_META_SET, Predicates.inRange(0, 1), - Arg.list( - Arg.create("key", true, "the key to set"), - Arg.create("value", true, "the value to set"), - Arg.create("context...", false, "the contexts to add the meta pair in") - ) - ); + public MetaSet(LocaleManager locale) { + super(CommandSpec.META_SET.spec(locale), "set", Permission.USER_META_SET, Permission.GROUP_META_SET, Predicates.inRange(0, 1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java index e63c82db..2206cbee 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java @@ -27,7 +27,6 @@ package me.lucko.luckperms.common.commands.impl.generic.meta; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; @@ -35,12 +34,14 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.TemporaryModifier; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -49,15 +50,8 @@ import java.util.List; import java.util.stream.Collectors; public class MetaSetTemp extends SharedSubCommand { - public MetaSetTemp() { - super("settemp", "Sets a meta value temporarily", Permission.USER_META_SETTEMP, Permission.GROUP_META_SETTEMP, Predicates.inRange(0, 2), - Arg.list( - Arg.create("key", true, "the key to set"), - Arg.create("value", true, "the value to set"), - Arg.create("duration", true, "the duration until the meta value expires"), - Arg.create("context...", false, "the contexts to add the meta pair in") - ) - ); + public MetaSetTemp(LocaleManager locale) { + super(CommandSpec.META_SETTEMP.spec(locale), "settemp", Permission.USER_META_SETTEMP, Permission.GROUP_META_SETTEMP, Predicates.inRange(0, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnset.java index 920f7b0d..1b006afd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnset.java @@ -26,17 +26,18 @@ package me.lucko.luckperms.common.commands.impl.generic.meta; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -44,14 +45,8 @@ import java.util.List; import java.util.stream.Collectors; public class MetaUnset extends SharedSubCommand { - public MetaUnset() { - super("unset", "Unsets a meta value", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET, - Predicates.is(0), - Arg.list( - Arg.create("key", true, "the key to unset"), - Arg.create("context...", false, "the contexts to remove the meta pair in") - ) - ); + public MetaUnset(LocaleManager locale) { + super(CommandSpec.META_UNSET.spec(locale), "unset", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnsetTemp.java index 4c1eee40..4c0df0d8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnsetTemp.java @@ -26,17 +26,18 @@ package me.lucko.luckperms.common.commands.impl.generic.meta; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -44,14 +45,8 @@ import java.util.List; import java.util.stream.Collectors; public class MetaUnsetTemp extends SharedSubCommand { - public MetaUnsetTemp() { - super("unsettemp", "Unsets a temporary meta value", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP, - Predicates.is(0), - Arg.list( - Arg.create("key", true, "the key to unset"), - Arg.create("context...", false, "the contexts to remove the meta pair in") - ) - ); + public MetaUnsetTemp(LocaleManager locale) { + super(CommandSpec.META_UNSETTEMP.spec(locale), "unsettemp", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderClear.java index 7f3ed143..578ced63 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderClear.java @@ -26,19 +26,20 @@ package me.lucko.luckperms.common.commands.impl.generic.other; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -46,13 +47,8 @@ import java.util.List; import java.util.stream.Collectors; public class HolderClear extends SubCommand { - public HolderClear(boolean user) { - super("clear", "Removes all permissions, parents and meta", user ? Permission.USER_CLEAR : Permission.GROUP_CLEAR, - Predicates.alwaysFalse(), - Arg.list( - Arg.create("context...", false, "the contexts to filter by") - ) - ); + public HolderClear(LocaleManager locale, boolean user) { + super(CommandSpec.HOLDER_CLEAR.spec(locale), "clear", user ? Permission.USER_CLEAR : Permission.GROUP_CLEAR, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java index 5c452776..1433e84b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java @@ -37,12 +37,14 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeModel; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -68,10 +70,8 @@ public class HolderEditor extends SubCommand { private static final String GROUP_ID_PATTERN = "group/"; private static final String FILE_NAME = "luckperms-data.json"; - public HolderEditor(boolean user) { - super("editor", "Opens the web permission editor", user ? Permission.USER_EDITOR : Permission.GROUP_EDITOR, - Predicates.alwaysFalse(), null - ); + public HolderEditor(LocaleManager locale, boolean user) { + super(CommandSpec.HOLDER_EDITOR.spec(locale), "editor", user ? Permission.USER_EDITOR : Permission.GROUP_EDITOR, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderShowTracks.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderShowTracks.java index ca8a6933..06477025 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderShowTracks.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderShowTracks.java @@ -31,9 +31,11 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -42,9 +44,8 @@ import java.util.Set; import java.util.stream.Collectors; public class HolderShowTracks extends SubCommand { - public HolderShowTracks(boolean user) { - super("showtracks", "Lists the tracks that the object is on", - user ? Permission.USER_SHOWTRACKS : Permission.GROUP_SHOWTRACKS, Predicates.alwaysFalse(), null); + public HolderShowTracks(LocaleManager locale, boolean user) { + super(CommandSpec.HOLDER_SHOWTRACKS.spec(locale), "showtracks", user ? Permission.USER_SHOWTRACKS : Permission.GROUP_SHOWTRACKS, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/CommandParent.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/CommandParent.java index 1b9b36ad..50b0d25c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/CommandParent.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/CommandParent.java @@ -30,19 +30,21 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.commands.abstraction.SharedMainCommand; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; public class CommandParent extends SharedMainCommand { - public CommandParent(boolean user) { - super("Parent", "Edit inheritances", user, ImmutableList.builder() - .add(new ParentInfo()) - .add(new ParentSet()) - .add(new ParentAdd()) - .add(new ParentRemove()) - .add(new ParentSetTrack()) - .add(new ParentAddTemp()) - .add(new ParentRemoveTemp()) - .add(new ParentClear()) - .add(new ParentClearTrack()) + public CommandParent(LocaleManager locale, boolean user) { + super(CommandSpec.PARENT.spec(locale), "Parent", user, ImmutableList.builder() + .add(new ParentInfo(locale)) + .add(new ParentSet(locale)) + .add(new ParentAdd(locale)) + .add(new ParentRemove(locale)) + .add(new ParentSetTrack(locale)) + .add(new ParentAddTemp(locale)) + .add(new ParentRemoveTemp(locale)) + .add(new ParentClear(locale)) + .add(new ParentClearTrack(locale)) .build()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAdd.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAdd.java index 73d309ac..2a89d4af 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAdd.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAdd.java @@ -27,18 +27,19 @@ package me.lucko.luckperms.common.commands.impl.generic.parent; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -48,14 +49,8 @@ import java.util.stream.Collectors; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; public class ParentAdd extends SharedSubCommand { - public ParentAdd() { - super("add", "Sets another group for the object to inherit permissions from", Permission.USER_PARENT_ADD, - Permission.GROUP_PARENT_ADD, Predicates.is(0), - Arg.list( - Arg.create("group", true, "the group to inherit from"), - Arg.create("context...", false, "the contexts to inherit the group in") - ) - ); + public ParentAdd(LocaleManager locale) { + super(CommandSpec.PARENT_ADD.spec(locale), "add", Permission.USER_PARENT_ADD, Permission.GROUP_PARENT_ADD, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAddTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAddTemp.java index 5c6966d6..8a3dd189 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAddTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAddTemp.java @@ -28,7 +28,6 @@ package me.lucko.luckperms.common.commands.impl.generic.parent; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; @@ -36,13 +35,15 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.TemporaryModifier; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -54,15 +55,8 @@ import java.util.stream.Collectors; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; public class ParentAddTemp extends SharedSubCommand { - public ParentAddTemp() { - super("addtemp", "Sets another group for the object to inherit permissions from temporarily", - Permission.USER_PARENT_ADDTEMP, Permission.GROUP_PARENT_ADDTEMP, Predicates.inRange(0, 1), - Arg.list( - Arg.create("group", true, "the group to inherit from"), - Arg.create("duration", true, "the duration of the group membership"), - Arg.create("context...", false, "the contexts to inherit the group in") - ) - ); + public ParentAddTemp(LocaleManager locale) { + super(CommandSpec.PARENT_ADD_TEMP.spec(locale), "addtemp", Permission.USER_PARENT_ADDTEMP, Permission.GROUP_PARENT_ADDTEMP, Predicates.inRange(0, 1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClear.java index ac41deab..fb550f30 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClear.java @@ -26,17 +26,18 @@ package me.lucko.luckperms.common.commands.impl.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -44,12 +45,8 @@ import java.util.List; import java.util.stream.Collectors; public class ParentClear extends SharedSubCommand { - public ParentClear() { - super("clear", "Clears all parents", Permission.USER_PARENT_CLEAR, Permission.GROUP_PARENT_CLEAR, Predicates.alwaysFalse(), - Arg.list( - Arg.create("context...", false, "the contexts to filter by") - ) - ); + public ParentClear(LocaleManager locale) { + super(CommandSpec.PARENT_CLEAR.spec(locale), "clear", Permission.USER_PARENT_CLEAR, Permission.GROUP_PARENT_CLEAR, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClearTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClearTrack.java index 8b8f76a4..de70215a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClearTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClearTrack.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.common.commands.impl.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; @@ -34,12 +33,14 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -49,13 +50,8 @@ import java.util.stream.Collectors; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getTrackTabComplete; public class ParentClearTrack extends SharedSubCommand { - public ParentClearTrack() { - super("cleartrack", "Clears all parents on a given track", Permission.USER_PARENT_CLEAR_TRACK, Permission.GROUP_PARENT_CLEAR_TRACK, Predicates.is(0), - Arg.list( - Arg.create("track", true, "the track to remove on"), - Arg.create("context...", false, "the contexts to filter by") - ) - ); + public ParentClearTrack(LocaleManager locale) { + super(CommandSpec.PARENT_CLEAR_TRACK.spec(locale), "cleartrack", Permission.USER_PARENT_CLEAR_TRACK, Permission.GROUP_PARENT_CLEAR_TRACK, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java index 653b6d15..3a1455e0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java @@ -32,9 +32,11 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -43,9 +45,8 @@ import java.util.List; import java.util.SortedSet; public class ParentInfo extends SharedSubCommand { - public ParentInfo() { - super("info", "Lists the groups that this object inherits from", - Permission.USER_PARENT_INFO, Permission.GROUP_PARENT_INFO, Predicates.alwaysFalse(), null); + public ParentInfo(LocaleManager locale) { + super(CommandSpec.PARENT_INFO.spec(locale), "info", Permission.USER_PARENT_INFO, Permission.GROUP_PARENT_INFO, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java index 74324dc7..38bd0375 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java @@ -27,7 +27,6 @@ package me.lucko.luckperms.common.commands.impl.generic.parent; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; @@ -35,12 +34,14 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -50,14 +51,8 @@ import java.util.stream.Collectors; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; public class ParentRemove extends SharedSubCommand { - public ParentRemove() { - super("remove", "Removes a previously set inheritance rule", Permission.USER_PARENT_REMOVE, - Permission.GROUP_PARENT_REMOVE, Predicates.is(0), - Arg.list( - Arg.create("group", true, "the group to remove"), - Arg.create("context...", false, "the contexts to remove the group in") - ) - ); + public ParentRemove(LocaleManager locale) { + super(CommandSpec.PARENT_REMOVE.spec(locale), "remove", Permission.USER_PARENT_REMOVE, Permission.GROUP_PARENT_REMOVE, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemoveTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemoveTemp.java index 5fff4b81..5cddb038 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemoveTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemoveTemp.java @@ -27,18 +27,19 @@ package me.lucko.luckperms.common.commands.impl.generic.parent; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -48,14 +49,8 @@ import java.util.stream.Collectors; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; public class ParentRemoveTemp extends SharedSubCommand { - public ParentRemoveTemp() { - super("removetemp", "Removes a previously set temporary inheritance rule", - Permission.USER_PARENT_REMOVETEMP, Permission.GROUP_PARENT_REMOVETEMP, Predicates.is(0), - Arg.list( - Arg.create("group", true, "the group to remove"), - Arg.create("context...", false, "the contexts to remove the group in") - ) - ); + public ParentRemoveTemp(LocaleManager locale) { + super(CommandSpec.PARENT_REMOVE_TEMP.spec(locale), "removetemp", Permission.USER_PARENT_REMOVETEMP, Permission.GROUP_PARENT_REMOVETEMP, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSet.java index bc74faf8..3e88dab6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSet.java @@ -26,19 +26,20 @@ package me.lucko.luckperms.common.commands.impl.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -48,14 +49,8 @@ import java.util.stream.Collectors; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; public class ParentSet extends SharedSubCommand { - public ParentSet() { - super("set", "Removes all other groups the object inherits already and adds them to the one given", - Permission.USER_PARENT_SET, Permission.GROUP_PARENT_SET, Predicates.is(0), - Arg.list( - Arg.create("group", true, "the group to set to"), - Arg.create("context...", false, "the contexts to set the group in") - ) - ); + public ParentSet(LocaleManager locale) { + super(CommandSpec.PARENT_SET.spec(locale), "set", Permission.USER_PARENT_SET, Permission.GROUP_PARENT_SET, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSetTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSetTrack.java index 3e3dff5e..d5aef3a0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSetTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSetTrack.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.common.commands.impl.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; @@ -34,12 +33,14 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -50,15 +51,8 @@ import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroup import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getTrackTabComplete; public class ParentSetTrack extends SharedSubCommand { - public ParentSetTrack() { - super("settrack", "Removes all other groups the object inherits from already on the given track and adds them to the one given", - Permission.USER_PARENT_SET_TRACK, Permission.GROUP_PARENT_SET_TRACK, Predicates.inRange(0, 1), - Arg.list( - Arg.create("track", true, "the track to set on"), - Arg.create("group", true, "the group to set to, or a number relating to the position of the group on the given track"), - Arg.create("context...", false, "the contexts to set the group in") - ) - ); + public ParentSetTrack(LocaleManager locale) { + super(CommandSpec.PARENT_SET_TRACK.spec(locale), "settrack", Permission.USER_PARENT_SET_TRACK, Permission.GROUP_PARENT_SET_TRACK, Predicates.inRange(0, 1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/CommandPermission.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/CommandPermission.java index a8dc5c7f..8819a177 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/CommandPermission.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/CommandPermission.java @@ -30,17 +30,19 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.commands.abstraction.SharedMainCommand; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; public class CommandPermission extends SharedMainCommand { - public CommandPermission(boolean user) { - super("Permission", "Edit permissions", user, ImmutableList.builder() - .add(new PermissionInfo()) - .add(new PermissionSet()) - .add(new PermissionUnset()) - .add(new PermissionSetTemp()) - .add(new PermissionUnsetTemp()) - .add(new PermissionCheck()) - .add(new PermissionCheckInherits()) + public CommandPermission(LocaleManager locale, boolean user) { + super(CommandSpec.PERMISSION.spec(locale), "Permission", user, ImmutableList.builder() + .add(new PermissionInfo(locale)) + .add(new PermissionSet(locale)) + .add(new PermissionUnset(locale)) + .add(new PermissionSetTemp(locale)) + .add(new PermissionUnsetTemp(locale)) + .add(new PermissionCheck(locale)) + .add(new PermissionCheckInherits(locale)) .build()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheck.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheck.java index eb5a42b7..d716b147 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheck.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheck.java @@ -27,17 +27,18 @@ package me.lucko.luckperms.common.commands.impl.generic.permission; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -46,14 +47,8 @@ import java.util.List; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; public class PermissionCheck extends SharedSubCommand { - public PermissionCheck() { - super("check", "Checks to see if the object has a certain permission node", Permission.USER_PERM_CHECK, - Permission.GROUP_PERM_CHECK, Predicates.is(0), - Arg.list( - Arg.create("node", true, "the permission node to check for"), - Arg.create("context...", false, "the contexts to check in") - ) - ); + public PermissionCheck(LocaleManager locale) { + super(CommandSpec.PERMISSION_CHECK.spec(locale), "check", Permission.USER_PERM_CHECK, Permission.GROUP_PERM_CHECK, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheckInherits.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheckInherits.java index c996c6fe..57a76943 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheckInherits.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheckInherits.java @@ -26,18 +26,19 @@ package me.lucko.luckperms.common.commands.impl.generic.permission; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.InheritanceInfo; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -46,14 +47,8 @@ import java.util.List; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; public class PermissionCheckInherits extends SharedSubCommand { - public PermissionCheckInherits() { - super("checkinherits", "Checks to see if the object inherits a certain permission node", - Permission.USER_PERM_CHECK_INHERITS, Permission.GROUP_PERM_CHECK_INHERITS, Predicates.is(0), - Arg.list( - Arg.create("node", true, "the permission node to check for"), - Arg.create("context...", false, "the contexts to check in") - ) - ); + public PermissionCheckInherits(LocaleManager locale) { + super(CommandSpec.PERMISSION_CHECK_INHERITS.spec(locale), "checkinherits", Permission.USER_PERM_CHECK_INHERITS, Permission.GROUP_PERM_CHECK_INHERITS, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java index 82eee65e..2c710a25 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java @@ -29,7 +29,6 @@ import com.google.common.collect.Maps; import me.lucko.luckperms.api.LocalizedNode; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; @@ -37,11 +36,13 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Constants; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -60,14 +61,8 @@ import java.util.SortedSet; import java.util.function.Consumer; public class PermissionInfo extends SharedSubCommand { - public PermissionInfo() { - super("info", "Lists the permission nodes the object has", Permission.USER_PERM_INFO, - Permission.GROUP_PERM_INFO, Predicates.notInRange(0, 2), - Arg.list( - Arg.create("page", false, "the page to view"), - Arg.create("filter", false, "the string to filter by") - ) - ); + public PermissionInfo(LocaleManager locale) { + super(CommandSpec.PERMISSION_INFO.spec(locale), "info", Permission.USER_PERM_INFO, Permission.GROUP_PERM_INFO, Predicates.notInRange(0, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSet.java index 84b4194c..1f5286f5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSet.java @@ -27,18 +27,19 @@ package me.lucko.luckperms.common.commands.impl.generic.permission; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -49,15 +50,8 @@ import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getBoolT import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; public class PermissionSet extends SharedSubCommand { - public PermissionSet() { - super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET, - Predicates.is(0), - Arg.list( - Arg.create("node", true, "the permission node to set"), - Arg.create("true|false", false, "the value of the node"), - Arg.create("context...", false, "the contexts to add the permission in") - ) - ); + public PermissionSet(LocaleManager locale) { + super(CommandSpec.PERMISSION_SET.spec(locale), "set", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSetTemp.java index 99c73def..c130b27c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSetTemp.java @@ -28,7 +28,6 @@ package me.lucko.luckperms.common.commands.impl.generic.permission; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; @@ -36,12 +35,14 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.TemporaryModifier; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -54,16 +55,8 @@ import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getBoolT import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; public class PermissionSetTemp extends SharedSubCommand { - public PermissionSetTemp() { - super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP, - Permission.GROUP_PERM_SETTEMP, Predicates.inRange(0, 1), - Arg.list( - Arg.create("node", true, "the permission node to set"), - Arg.create("true|false", false, "the value of the node"), - Arg.create("duration", true, "the duration until the permission node expires"), - Arg.create("context...", false, "the contexts to add the permission in") - ) - ); + public PermissionSetTemp(LocaleManager locale) { + super(CommandSpec.PERMISSION_SETTEMP.spec(locale), "settemp", Permission.USER_PERM_SETTEMP, Permission.GROUP_PERM_SETTEMP, Predicates.inRange(0, 1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnset.java index 1b918498..dfa50b1e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnset.java @@ -27,18 +27,19 @@ package me.lucko.luckperms.common.commands.impl.generic.permission; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -48,14 +49,8 @@ import java.util.stream.Collectors; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; public class PermissionUnset extends SharedSubCommand { - public PermissionUnset() { - super("unset", "Unsets a permission for the object", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET, - Predicates.is(0), - Arg.list( - Arg.create("node", true, "the permission node to unset"), - Arg.create("context...", false, "the contexts to remove the permission in") - ) - ); + public PermissionUnset(LocaleManager locale) { + super(CommandSpec.PERMISSION_UNSET.spec(locale), "unset", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnsetTemp.java index be052681..3afbf78b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnsetTemp.java @@ -27,18 +27,19 @@ package me.lucko.luckperms.common.commands.impl.generic.permission; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -48,14 +49,8 @@ import java.util.stream.Collectors; import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; public class PermissionUnsetTemp extends SharedSubCommand { - public PermissionUnsetTemp() { - super("unsettemp", "Unsets a temporary permission for the object", Permission.USER_PERM_UNSETTEMP, - Permission.GROUP_PERM_UNSETTEMP, Predicates.is(0), - Arg.list( - Arg.create("node", true, "the permission node to unset"), - Arg.create("context...", false, "the contexts to remove the permission in") - ) - ); + public PermissionUnsetTemp(LocaleManager locale) { + super(CommandSpec.PERMISSION_UNSETTEMP.spec(locale), "unsettemp", Permission.USER_PERM_UNSETTEMP, Permission.GROUP_PERM_UNSETTEMP, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/CreateGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/CreateGroup.java index 912d08ee..1358f819 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/CreateGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/CreateGroup.java @@ -26,26 +26,23 @@ package me.lucko.luckperms.common.commands.impl.group; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class CreateGroup extends SingleCommand { - public CreateGroup() { - super("CreateGroup", "Create a new group", "/%s creategroup ", Permission.CREATE_GROUP, Predicates.not(1), - Arg.list( - Arg.create("name", true, "the name of the group") - ) - ); + public CreateGroup(LocaleManager locale) { + super(CommandSpec.CREATE_GROUP.spec(locale), "CreateGroup", Permission.CREATE_GROUP, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/DeleteGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/DeleteGroup.java index a81299a1..b34b71ad 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/DeleteGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/DeleteGroup.java @@ -26,31 +26,25 @@ package me.lucko.luckperms.common.commands.impl.group; import me.lucko.luckperms.api.event.cause.DeletionCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; public class DeleteGroup extends SingleCommand { - public DeleteGroup() { - super("DeleteGroup", "Delete a group", "/%s deletegroup ", Permission.DELETE_GROUP, Predicates.not(1), - Arg.list( - Arg.create("name", true, "the name of the group") - ) - ); + public DeleteGroup(LocaleManager locale) { + super(CommandSpec.DELETE_GROUP.spec(locale), "DeleteGroup", Permission.DELETE_GROUP, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupClone.java index 33789f70..7c7357b3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupClone.java @@ -26,26 +26,25 @@ package me.lucko.luckperms.common.commands.impl.group; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class GroupClone extends SubCommand { - public GroupClone() { - super("clone", "Clone the group", Permission.GROUP_CLONE, Predicates.not(1), - Arg.list(Arg.create("name", true, "the name of the group to clone onto")) - ); + public GroupClone(LocaleManager locale) { + super(CommandSpec.GROUP_CLONE.spec(locale), "clone", Permission.GROUP_CLONE, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupInfo.java index 4091d3c9..0ff2ea06 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupInfo.java @@ -31,9 +31,11 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -43,8 +45,8 @@ import java.util.Set; import java.util.stream.Collectors; public class GroupInfo extends SubCommand { - public GroupInfo() { - super("info", "Gives info about the group", Permission.GROUP_INFO, Predicates.alwaysFalse(), null); + public GroupInfo(LocaleManager locale) { + super(CommandSpec.GROUP_INFO.spec(locale), "info", Permission.GROUP_INFO, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java index ccf84631..a5c7f497 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java @@ -29,7 +29,6 @@ import com.google.common.collect.Maps; import me.lucko.luckperms.api.HeldPermission; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -37,10 +36,12 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Constants; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.Group; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -63,13 +64,8 @@ import java.util.function.Function; import java.util.stream.Collectors; public class GroupListMembers extends SubCommand { - public GroupListMembers() { - super("listmembers", "Show the users/groups who inherit from this group", - Permission.GROUP_LISTMEMBERS, Predicates.notInRange(0, 1), - Arg.list( - Arg.create("page", false, "the page to view") - ) - ); + public GroupListMembers(LocaleManager locale) { + super(CommandSpec.GROUP_LISTMEMBERS.spec(locale), "listmembers", Permission.GROUP_LISTMEMBERS, Predicates.notInRange(0, 1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java index 3a3ff039..990700ef 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java @@ -36,27 +36,29 @@ import me.lucko.luckperms.common.commands.impl.generic.other.HolderShowTracks; import me.lucko.luckperms.common.commands.impl.generic.parent.CommandParent; import me.lucko.luckperms.common.commands.impl.generic.permission.CommandPermission; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.model.Group; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import java.util.ArrayList; import java.util.List; public class GroupMainCommand extends MainCommand { - public GroupMainCommand() { - super("Group", "Group commands", "/%s group ", 2, ImmutableList.>builder() - .add(new GroupInfo()) - .add(new CommandPermission<>(false)) - .add(new CommandParent<>(false)) - .add(new CommandMeta<>(false)) - .add(new HolderEditor<>(false)) - .add(new GroupListMembers()) - .add(new GroupSetWeight()) - .add(new HolderShowTracks<>(false)) - .add(new HolderClear<>(false)) - .add(new GroupRename()) - .add(new GroupClone()) + public GroupMainCommand(LocaleManager locale) { + super(CommandSpec.GROUP.spec(locale), "Group", 2, ImmutableList.>builder() + .add(new GroupInfo(locale)) + .add(new CommandPermission<>(locale, false)) + .add(new CommandParent<>(locale, false)) + .add(new CommandMeta<>(locale, false)) + .add(new HolderEditor<>(locale, false)) + .add(new GroupListMembers(locale)) + .add(new GroupSetWeight(locale)) + .add(new HolderShowTracks<>(locale, false)) + .add(new HolderClear<>(locale, false)) + .add(new GroupRename(locale)) + .add(new GroupClone(locale)) .build() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupRename.java index 46f524bd..4216d268 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupRename.java @@ -27,26 +27,25 @@ package me.lucko.luckperms.common.commands.impl.group; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.api.event.cause.DeletionCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class GroupRename extends SubCommand { - public GroupRename() { - super("rename", "Rename the group", Permission.GROUP_RENAME, Predicates.not(1), - Arg.list(Arg.create("name", true, "the new name")) - ); + public GroupRename(LocaleManager locale) { + super(CommandSpec.GROUP_RENAME.spec(locale), "rename", Permission.GROUP_RENAME, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetWeight.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetWeight.java index f47c26ad..2dd901d1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetWeight.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetWeight.java @@ -25,26 +25,25 @@ package me.lucko.luckperms.common.commands.impl.group; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.Group; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class GroupSetWeight extends SubCommand { - public GroupSetWeight() { - super("setweight", "Set the groups weight", Permission.GROUP_SETWEIGHT, Predicates.not(1), - Arg.list(Arg.create("weight", true, "the weight to set")) - ); + public GroupSetWeight(LocaleManager locale) { + super(CommandSpec.GROUP_SETWEIGHT.spec(locale), "setweight", Permission.GROUP_SETWEIGHT, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java index 191daac0..a1b4255f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java @@ -29,9 +29,11 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -39,8 +41,8 @@ import java.util.List; import java.util.stream.Collectors; public class ListGroups extends SingleCommand { - public ListGroups() { - super("ListGroups", "List all groups on the platform", "/%s listgroups", Permission.LIST_GROUPS, Predicates.alwaysFalse(), null); + public ListGroups(LocaleManager locale) { + super(CommandSpec.LIST_GROUPS.spec(locale), "ListGroups", Permission.LIST_GROUPS, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogGroupHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogGroupHistory.java similarity index 87% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogGroupHistory.java rename to common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogGroupHistory.java index 1447d016..f6fee7a6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogGroupHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogGroupHistory.java @@ -23,18 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log.subcommands; +package me.lucko.luckperms.common.commands.impl.log; import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -44,13 +45,8 @@ import java.util.Map; import java.util.SortedMap; public class LogGroupHistory extends SubCommand { - public LogGroupHistory() { - super("grouphistory", "View an group's history", Permission.LOG_GROUP_HISTORY, Predicates.notInRange(1, 2), - Arg.list( - Arg.create("group", true, "the name of the group"), - Arg.create("page", false, "the page number to view") - ) - ); + public LogGroupHistory(LocaleManager locale) { + super(CommandSpec.LOG_GROUP_HISTORY.spec(locale), "grouphistory", Permission.LOG_GROUP_HISTORY, Predicates.notInRange(1, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogMainCommand.java index b3b0f692..c55a277d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogMainCommand.java @@ -29,15 +29,11 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.commands.abstraction.Command; import me.lucko.luckperms.common.commands.abstraction.MainCommand; -import me.lucko.luckperms.common.commands.impl.log.subcommands.LogGroupHistory; -import me.lucko.luckperms.common.commands.impl.log.subcommands.LogNotify; -import me.lucko.luckperms.common.commands.impl.log.subcommands.LogRecent; -import me.lucko.luckperms.common.commands.impl.log.subcommands.LogSearch; -import me.lucko.luckperms.common.commands.impl.log.subcommands.LogTrackHistory; -import me.lucko.luckperms.common.commands.impl.log.subcommands.LogUserHistory; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.data.Log; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import java.util.Collections; @@ -46,14 +42,14 @@ import java.util.Optional; import java.util.stream.Collectors; public class LogMainCommand extends MainCommand { - public LogMainCommand() { - super("Log", "Log commands", "/%s log", 1, ImmutableList.>builder() - .add(new LogRecent()) - .add(new LogSearch()) - .add(new LogNotify()) - .add(new LogUserHistory()) - .add(new LogGroupHistory()) - .add(new LogTrackHistory()) + public LogMainCommand(LocaleManager locale) { + super(CommandSpec.LOG.spec(locale), "Log", 1, ImmutableList.>builder() + .add(new LogRecent(locale)) + .add(new LogSearch(locale)) + .add(new LogNotify(locale)) + .add(new LogUserHistory(locale)) + .add(new LogGroupHistory(locale)) + .add(new LogTrackHistory(locale)) .build() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogNotify.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java similarity index 90% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogNotify.java rename to common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java index 73924e0a..09e3cc07 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogNotify.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java @@ -23,16 +23,17 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log.subcommands; +package me.lucko.luckperms.common.commands.impl.log; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -41,10 +42,8 @@ import java.util.Set; import java.util.UUID; public class LogNotify extends SubCommand { - public LogNotify() { - super("notify", "Toggle notifications", Permission.LOG_NOTIFY, Predicates.notInRange(0, 1), - Arg.list(Arg.create("on|off", false, "whether to toggle on or off")) - ); + public LogNotify(LocaleManager locale) { + super(CommandSpec.LOG_NOTIFY.spec(locale), "notify", Permission.LOG_NOTIFY, Predicates.notInRange(0, 1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogRecent.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogRecent.java similarity index 91% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogRecent.java rename to common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogRecent.java index 1bf232b4..3adb42eb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogRecent.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogRecent.java @@ -23,19 +23,20 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log.subcommands; +package me.lucko.luckperms.common.commands.impl.log; import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -46,39 +47,8 @@ import java.util.SortedMap; import java.util.UUID; public class LogRecent extends SubCommand { - private static CommandResult showLog(int page, UUID filter, Sender sender, Log log) { - int maxPage = (filter != null) ? log.getRecentMaxPages(filter) : log.getRecentMaxPages(); - if (maxPage == 0) { - Message.LOG_NO_ENTRIES.send(sender); - return CommandResult.STATE_ERROR; - } - - if (page < 1 || page > maxPage) { - Message.LOG_INVALID_PAGE_RANGE.send(sender, maxPage); - return CommandResult.INVALID_ARGS; - } - - SortedMap entries = (filter != null) ? log.getRecent(page, filter) : log.getRecent(page); - if (filter != null) { - String name = entries.values().stream().findAny().get().getActorName(); - Message.LOG_RECENT_BY_HEADER.send(sender, name, page, maxPage); - } else { - Message.LOG_RECENT_HEADER.send(sender, page, maxPage); - } - - for (Map.Entry e : entries.entrySet()) { - Message.LOG_ENTRY.send(sender, e.getKey(), DateUtil.formatDateDiff(e.getValue().getTimestamp()), e.getValue().getFormatted()); - } - return CommandResult.SUCCESS; - } - - public LogRecent() { - super("recent", "View recent actions", Permission.LOG_RECENT, Predicates.notInRange(0, 2), - Arg.list( - Arg.create("user", false, "the name/uuid of the user to filter by"), - Arg.create("page", false, "the page number to view") - ) - ); + public LogRecent(LocaleManager locale) { + super(CommandSpec.LOG_RECENT.spec(locale), "recent", Permission.LOG_RECENT, Predicates.notInRange(0, 2)); } @Override @@ -150,4 +120,30 @@ public class LogRecent extends SubCommand { } } } + + private static CommandResult showLog(int page, UUID filter, Sender sender, Log log) { + int maxPage = (filter != null) ? log.getRecentMaxPages(filter) : log.getRecentMaxPages(); + if (maxPage == 0) { + Message.LOG_NO_ENTRIES.send(sender); + return CommandResult.STATE_ERROR; + } + + if (page < 1 || page > maxPage) { + Message.LOG_INVALID_PAGE_RANGE.send(sender, maxPage); + return CommandResult.INVALID_ARGS; + } + + SortedMap entries = (filter != null) ? log.getRecent(page, filter) : log.getRecent(page); + if (filter != null) { + String name = entries.values().stream().findAny().get().getActorName(); + Message.LOG_RECENT_BY_HEADER.send(sender, name, page, maxPage); + } else { + Message.LOG_RECENT_HEADER.send(sender, page, maxPage); + } + + for (Map.Entry e : entries.entrySet()) { + Message.LOG_ENTRY.send(sender, e.getKey(), DateUtil.formatDateDiff(e.getValue().getTimestamp()), e.getValue().getFormatted()); + } + return CommandResult.SUCCESS; + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogSearch.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogSearch.java similarity index 86% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogSearch.java rename to common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogSearch.java index 0110b6f0..efc27daf 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogSearch.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogSearch.java @@ -23,17 +23,18 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log.subcommands; +package me.lucko.luckperms.common.commands.impl.log; import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -44,13 +45,8 @@ import java.util.SortedMap; import java.util.stream.Collectors; public class LogSearch extends SubCommand { - public LogSearch() { - super("search", "Search the log for an entry", Permission.LOG_SEARCH, Predicates.is(0), - Arg.list( - Arg.create("query", true, "the query to search by"), - Arg.create("page", false, "the page number to view") - ) - ); + public LogSearch(LocaleManager locale) { + super(CommandSpec.LOG_SEARCH.spec(locale), "search", Permission.LOG_SEARCH, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogTrackHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogTrackHistory.java similarity index 87% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogTrackHistory.java rename to common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogTrackHistory.java index 4b42e10a..f60284bc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogTrackHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogTrackHistory.java @@ -23,18 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log.subcommands; +package me.lucko.luckperms.common.commands.impl.log; import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -44,13 +45,8 @@ import java.util.Map; import java.util.SortedMap; public class LogTrackHistory extends SubCommand { - public LogTrackHistory() { - super("trackhistory", "View a track's history", Permission.LOG_TRACK_HISTORY, Predicates.notInRange(1, 2), - Arg.list( - Arg.create("track", true, "the name of the track"), - Arg.create("page", false, "the page number to view") - ) - ); + public LogTrackHistory(LocaleManager locale) { + super(CommandSpec.LOG_TRACK_HISTORY.spec(locale), "trackhistory", Permission.LOG_TRACK_HISTORY, Predicates.notInRange(1, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogUserHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogUserHistory.java similarity index 89% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogUserHistory.java rename to common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogUserHistory.java index 78d86e5a..4399aa00 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/subcommands/LogUserHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogUserHistory.java @@ -23,19 +23,20 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log.subcommands; +package me.lucko.luckperms.common.commands.impl.log; import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -46,36 +47,8 @@ import java.util.SortedMap; import java.util.UUID; public class LogUserHistory extends SubCommand { - private static CommandResult showLog(int page, UUID user, Sender sender, Log log) { - int maxPage = log.getUserHistoryMaxPages(user); - if (maxPage == 0) { - Message.LOG_NO_ENTRIES.send(sender); - return CommandResult.STATE_ERROR; - } - - if (page < 1 || page > maxPage) { - Message.LOG_INVALID_PAGE_RANGE.send(sender, maxPage); - return CommandResult.INVALID_ARGS; - } - - SortedMap entries = log.getUserHistory(page, user); - String name = entries.values().stream().findAny().get().getActedName(); - Message.LOG_HISTORY_USER_HEADER.send(sender, name, page, maxPage); - - for (Map.Entry e : entries.entrySet()) { - Message.LOG_ENTRY.send(sender, e.getKey(), DateUtil.formatDateDiff(e.getValue().getTimestamp()), e.getValue().getFormatted()); - } - - return CommandResult.SUCCESS; - } - - public LogUserHistory() { - super("userhistory", "View a user's history", Permission.LOG_USER_HISTORY, Predicates.notInRange(1, 2), - Arg.list( - Arg.create("user", true, "the name/uuid of the user"), - Arg.create("page", false, "the page number to view") - ) - ); + public LogUserHistory(LocaleManager locale) { + super(CommandSpec.LOG_USER_HISTORY.spec(locale), "userhistory", Permission.LOG_USER_HISTORY, Predicates.notInRange(1, 2)); } @Override @@ -99,7 +72,6 @@ public class LogUserHistory extends SubCommand { } return showLog(page, uuid, sender, log); - } if (user.length() <= 16) { @@ -125,4 +97,27 @@ public class LogUserHistory extends SubCommand { Message.USER_INVALID_ENTRY.send(sender, user); return CommandResult.INVALID_ARGS; } + + private static CommandResult showLog(int page, UUID user, Sender sender, Log log) { + int maxPage = log.getUserHistoryMaxPages(user); + if (maxPage == 0) { + Message.LOG_NO_ENTRIES.send(sender); + return CommandResult.STATE_ERROR; + } + + if (page < 1 || page > maxPage) { + Message.LOG_INVALID_PAGE_RANGE.send(sender, maxPage); + return CommandResult.INVALID_ARGS; + } + + SortedMap entries = log.getUserHistory(page, user); + String name = entries.values().stream().findAny().get().getActedName(); + Message.LOG_HISTORY_USER_HEADER.send(sender, name, page, maxPage); + + for (Map.Entry e : entries.entrySet()) { + Message.LOG_ENTRY.send(sender, e.getKey(), DateUtil.formatDateDiff(e.getValue().getTimestamp()), e.getValue().getFormatted()); + } + + return CommandResult.SUCCESS; + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationMainCommand.java index bd90ed63..12fd2c8a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationMainCommand.java @@ -34,6 +34,8 @@ import me.lucko.luckperms.common.commands.abstraction.MainCommand; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -58,19 +60,19 @@ public class MigrationMainCommand extends MainCommand { private List> commands = null; private boolean display = true; - public MigrationMainCommand() { - super("Migration", "Migration commands", "/%s migration", 1, null); + public MigrationMainCommand(LocaleManager locale) { + super(CommandSpec.MIGRATION.spec(locale), "Migration", 1, null); } @Override public synchronized Optional>> getChildren() { if (commands == null) { - commands = getAvailableCommands(); + commands = getAvailableCommands(getSpec().getLocaleManager()); // Add dummy command to show in the list. if (commands.isEmpty()) { display = false; - commands.add(new SubCommand("No available plugins to migrate from", "No available plugins to migrate from.", Permission.MIGRATION, Predicates.alwaysFalse(), null) { + commands.add(new SubCommand(CommandSpec.MIGRATION_COMMAND.spec(getSpec().getLocaleManager()), "No available plugins to migrate from", Permission.MIGRATION, Predicates.alwaysFalse()) { @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List args, String label) throws CommandException { return CommandResult.SUCCESS; @@ -94,13 +96,13 @@ public class MigrationMainCommand extends MainCommand { } @SuppressWarnings("unchecked") - private static List> getAvailableCommands() { + private static List> getAvailableCommands(LocaleManager locale) { List> l = new ArrayList<>(); for (Map.Entry plugin : PLUGINS.entrySet()) { try { Class.forName(plugin.getKey()); - l.add((SubCommand) Class.forName(plugin.getValue()).newInstance()); + l.add((SubCommand) Class.forName(plugin.getValue()).getConstructor(LocaleManager.class).newInstance(locale)); } catch (Throwable ignored) {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ApplyEditsCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ApplyEditsCommand.java index 4274ac66..bd8fadba 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ApplyEditsCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ApplyEditsCommand.java @@ -32,17 +32,18 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeModel; import me.lucko.luckperms.common.core.model.PermissionHolder; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -59,14 +60,8 @@ import java.util.UUID; import java.util.stream.Collectors; public class ApplyEditsCommand extends SingleCommand { - public ApplyEditsCommand() { - super("ApplyEdits", "Applies permission changes made from the web editor", - "/%s applyedits [target]", Permission.APPLY_EDITS, Predicates.notInRange(1, 2), - Arg.list( - Arg.create("code", true, "the unique code for the data"), - Arg.create("target", false, "who to apply the data to") - ) - ); + public ApplyEditsCommand(LocaleManager locale) { + super(CommandSpec.APPLY_EDITS.spec(locale), "ApplyEdits", Permission.APPLY_EDITS, Predicates.notInRange(1, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/BulkUpdateCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/BulkUpdateCommand.java index dca07956..576b939d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/BulkUpdateCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/BulkUpdateCommand.java @@ -36,14 +36,15 @@ import me.lucko.luckperms.common.bulkupdate.action.UpdateAction; import me.lucko.luckperms.common.bulkupdate.comparisons.ComparisonType; import me.lucko.luckperms.common.bulkupdate.constraint.Constraint; import me.lucko.luckperms.common.bulkupdate.constraint.QueryField; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -54,16 +55,8 @@ import java.util.concurrent.TimeUnit; public class BulkUpdateCommand extends SingleCommand { private final Cache pendingOperations = Caffeine.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(); - public BulkUpdateCommand() { - super("BulkUpdate", "Execute bulk change queries on all data", "/%s bulkupdate", Permission.BULK_UPDATE, Predicates.alwaysFalse(), - Arg.list( - Arg.create("data type", true, "the type of data being changed. ('all', 'users' or 'groups')"), - Arg.create("action", true, "the action to perform on the data. ('update' or 'delete')"), - Arg.create("action field", false, "the field to act upon. only required for 'update'. ('permission', 'server' or 'world')"), - Arg.create("action value", false, "the value to replace with. only required for 'update'."), - Arg.create("constraint...", false, "the constraints required for the update") - ) - ); + public BulkUpdateCommand(LocaleManager locale) { + super(CommandSpec.BULK_UPDATE.spec(locale), "BulkUpdate", Permission.BULK_UPDATE, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/CheckCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/CheckCommand.java index 2b06b79a..ca62f84e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/CheckCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/CheckCommand.java @@ -26,16 +26,17 @@ package me.lucko.luckperms.common.commands.impl.misc; import me.lucko.luckperms.api.Tristate; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -44,14 +45,8 @@ import java.util.UUID; import java.util.stream.Collectors; public class CheckCommand extends SingleCommand { - public CheckCommand() { - super("Check", "Perform a standard permission check on an online player", - "/%s check ", Permission.CHECK, Predicates.not(2), - Arg.list( - Arg.create("user", true, "the user to check"), - Arg.create("permission", true, "the permission to check for") - ) - ); + public CheckCommand(LocaleManager locale) { + super(CommandSpec.CHECK.spec(locale), "Check", Permission.CHECK, Predicates.not(2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ExportCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ExportCommand.java index dbc48884..9d3e0677 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ExportCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ExportCommand.java @@ -25,13 +25,14 @@ package me.lucko.luckperms.common.commands.impl.misc; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Exporter; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -45,12 +46,8 @@ import java.util.concurrent.atomic.AtomicBoolean; public class ExportCommand extends SingleCommand { private AtomicBoolean running = new AtomicBoolean(false); - public ExportCommand() { - super("Export", "Export data to a file", "/%s export ", Permission.EXPORT, Predicates.not(1), - Arg.list( - Arg.create("file", true, "the file to export to") - ) - ); + public ExportCommand(LocaleManager locale) { + super(CommandSpec.EXPORT.spec(locale), "Export", Permission.EXPORT, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ImportCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ImportCommand.java index cd37dcb1..bab1e21f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ImportCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ImportCommand.java @@ -25,13 +25,14 @@ package me.lucko.luckperms.common.commands.impl.misc; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Importer; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -46,12 +47,8 @@ import java.util.concurrent.atomic.AtomicBoolean; public class ImportCommand extends SingleCommand { private AtomicBoolean running = new AtomicBoolean(false); - public ImportCommand() { - super("Import", "Import data from a file", "/%s import ", Permission.IMPORT, Predicates.not(1), - Arg.list( - Arg.create("file", true, "the file to import from") - ) - ); + public ImportCommand(LocaleManager locale) { + super(CommandSpec.IMPORT.spec(locale), "Import", Permission.IMPORT, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java index b8589f0e..c0537b97 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java @@ -31,8 +31,10 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.config.LuckPermsConfiguration; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.messaging.NoopMessagingService; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -44,21 +46,8 @@ import java.util.Map; import static me.lucko.luckperms.common.commands.utils.Util.formatBoolean; public class InfoCommand extends SingleCommand { - private static String formatValue(String value) { - if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { - return Util.formatBoolean(Boolean.parseBoolean(value)); - } - - try { - int i = Integer.parseInt(value); - return "&a" + i; - } catch (NumberFormatException ignored) {} - - return "&f" + value; - } - - public InfoCommand() { - super("Info", "Print general plugin info", "/%s info", Permission.INFO, Predicates.alwaysFalse(), null); + public InfoCommand(LocaleManager locale) { + super(CommandSpec.INFO.spec(locale), "Info", Permission.INFO, Predicates.alwaysFalse()); } @Override @@ -103,4 +92,17 @@ public class InfoCommand extends SingleCommand { return CommandResult.SUCCESS; } + + private static String formatValue(String value) { + if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { + return Util.formatBoolean(Boolean.parseBoolean(value)); + } + + try { + int i = Integer.parseInt(value); + return "&a" + i; + } catch (NumberFormatException ignored) {} + + return "&f" + value; + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/NetworkSyncCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/NetworkSyncCommand.java index 63de6f2f..3f4b2aa6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/NetworkSyncCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/NetworkSyncCommand.java @@ -28,8 +28,10 @@ package me.lucko.luckperms.common.commands.impl.misc; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.messaging.NoopMessagingService; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -38,9 +40,8 @@ import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class NetworkSyncCommand extends SingleCommand { - public NetworkSyncCommand() { - super("NetworkSync", "Sync changes with the storage and request that all other servers on the network do the same", - "/%s networksync", Permission.SYNC, Predicates.alwaysFalse(), null); + public NetworkSyncCommand(LocaleManager locale) { + super(CommandSpec.NETWORK_SYNC.spec(locale), "NetworkSync", Permission.SYNC, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ReloadConfigCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ReloadConfigCommand.java index 1b84993b..1494dac4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ReloadConfigCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ReloadConfigCommand.java @@ -29,16 +29,18 @@ import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class ReloadConfigCommand extends SingleCommand { - public ReloadConfigCommand() { - super("ReloadConfig", "Reload some of the config options", "/%s reloadconfig", Permission.RELOAD_CONFIG, Predicates.alwaysFalse(), null); + public ReloadConfigCommand(LocaleManager locale) { + super(CommandSpec.RELOAD_CONFIG.spec(locale), "ReloadConfig", Permission.RELOAD_CONFIG, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java index 7251f36b..6c34adcd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java @@ -29,7 +29,6 @@ import com.google.common.collect.Maps; import me.lucko.luckperms.api.HeldPermission; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; @@ -38,9 +37,11 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Constants; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -63,14 +64,8 @@ import java.util.function.Function; import java.util.stream.Collectors; public class SearchCommand extends SingleCommand { - public SearchCommand() { - super("Search", "Search for users/groups with a specific permission", - "/%s search ", Permission.SEARCH, Predicates.notInRange(1, 2), - Arg.list( - Arg.create("permission", true, "the permission to search for"), - Arg.create("page", false, "the page to view") - ) - ); + public SearchCommand(LocaleManager locale) { + super(CommandSpec.SEARCH.spec(locale), "Search", Permission.SEARCH, Predicates.notInRange(1, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SyncCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SyncCommand.java index 5845ca96..61fd4671 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SyncCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SyncCommand.java @@ -28,16 +28,18 @@ package me.lucko.luckperms.common.commands.impl.misc; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class SyncCommand extends SingleCommand { - public SyncCommand() { - super("Sync", "Sync changes with the storage", "/%s sync", Permission.SYNC, Predicates.alwaysFalse(), null); + public SyncCommand(LocaleManager locale) { + super(CommandSpec.SYNC.spec(locale), "Sync", Permission.SYNC, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java index 01b80e0d..86971fb2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java @@ -26,16 +26,17 @@ package me.lucko.luckperms.common.commands.impl.misc; import me.lucko.luckperms.api.caching.PermissionData; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.treeview.TreeView; import me.lucko.luckperms.common.treeview.TreeViewBuilder; @@ -50,15 +51,8 @@ import java.util.List; import java.util.UUID; public class TreeCommand extends SingleCommand { - public TreeCommand() { - super("Tree", "Generate a tree view of permissions", - "/%s tree [selection] [max level] [player]", Permission.TREE, Predicates.alwaysFalse(), - Arg.list( - Arg.create("selection", false, "the root of the tree. specify \".\" to include all permissions"), - Arg.create("max level", false, "how many branch levels should be returned"), - Arg.create("player", false, "the name of an online player to check against") - ) - ); + public TreeCommand(LocaleManager locale) { + super(CommandSpec.TREE.spec(locale), "Tree", Permission.TREE, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java index 4d75e628..86a01be5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java @@ -27,12 +27,13 @@ package me.lucko.luckperms.common.commands.impl.misc; import com.google.common.collect.ImmutableList; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.verbose.VerboseListener; @@ -49,13 +50,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; public class VerboseCommand extends SingleCommand { - public VerboseCommand() { - super("Verbose", "Manage verbose permission checking", "/%s verbose [filter]", Permission.VERBOSE, Predicates.is(0), - Arg.list( - Arg.create("on|record|off|paste", true, "whether to enable/disable logging, or to paste the logged output"), - Arg.create("filter", false, "the filter to match entries against") - ) - ); + public VerboseCommand(LocaleManager locale) { + super(CommandSpec.VERBOSE.spec(locale), "Verbose", Permission.VERBOSE, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/CreateTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/CreateTrack.java index 9a886eef..a9c5c09b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/CreateTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/CreateTrack.java @@ -26,26 +26,23 @@ package me.lucko.luckperms.common.commands.impl.track; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class CreateTrack extends SingleCommand { - public CreateTrack() { - super("CreateTrack", "Create a new track", "/%s createtrack ", Permission.CREATE_TRACK, Predicates.not(1), - Arg.list( - Arg.create("name", true, "the name of the track") - ) - ); + public CreateTrack(LocaleManager locale) { + super(CommandSpec.CREATE_TRACK.spec(locale), "CreateTrack", Permission.CREATE_TRACK, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/DeleteTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/DeleteTrack.java index 5373b0e3..07bfd7b6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/DeleteTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/DeleteTrack.java @@ -26,28 +26,24 @@ package me.lucko.luckperms.common.commands.impl.track; import me.lucko.luckperms.api.event.cause.DeletionCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; -import java.util.ArrayList; import java.util.List; public class DeleteTrack extends SingleCommand { - public DeleteTrack() { - super("DeleteTrack", "Delete a track", "/%s deletetrack ", Permission.DELETE_TRACK, Predicates.not(1), - Arg.list( - Arg.create("name", true, "the name of the track") - ) - ); + public DeleteTrack(LocaleManager locale) { + super(CommandSpec.DELETE_TRACK.spec(locale), "DeleteTrack", Permission.DELETE_TRACK, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/ListTracks.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/ListTracks.java index 20f950bb..cbc4a27d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/ListTracks.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/ListTracks.java @@ -29,8 +29,10 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SingleCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; @@ -38,8 +40,8 @@ import java.util.List; import java.util.stream.Collectors; public class ListTracks extends SingleCommand { - public ListTracks() { - super("ListTracks", "List all tracks on the platform", "/%s listtracks", Permission.LIST_TRACKS, Predicates.alwaysFalse(), null); + public ListTracks(LocaleManager locale) { + super(CommandSpec.LIST_TRACKS.spec(locale), "ListTracks", Permission.LIST_TRACKS, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackAppend.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackAppend.java index ef5ae793..16b952f5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackAppend.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackAppend.java @@ -25,18 +25,19 @@ package me.lucko.luckperms.common.commands.impl.track; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; @@ -44,10 +45,8 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class TrackAppend extends SubCommand { - public TrackAppend() { - super("append", "Appends a group onto the end of the track", Permission.TRACK_APPEND, Predicates.not(1), - Arg.list(Arg.create("group", true, "the group to append")) - ); + public TrackAppend(LocaleManager locale) { + super(CommandSpec.TRACK_APPEND.spec(locale), "append", Permission.TRACK_APPEND, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClear.java index 59efba50..70de8e04 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClear.java @@ -29,18 +29,20 @@ import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class TrackClear extends SubCommand { - public TrackClear() { - super("clear", "Clears the groups on the track", Permission.TRACK_CLEAR, Predicates.alwaysFalse(), null); + public TrackClear(LocaleManager locale) { + super(CommandSpec.TRACK_CLEAR.spec(locale), "clear", Permission.TRACK_CLEAR, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClone.java index 74f59746..4dccc828 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClone.java @@ -26,26 +26,25 @@ package me.lucko.luckperms.common.commands.impl.track; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class TrackClone extends SubCommand { - public TrackClone() { - super("clone", "Clone the track", Permission.TRACK_CLONE, Predicates.not(1), - Arg.list(Arg.create("name", true, "the name of the track to clone onto")) - ); + public TrackClone(LocaleManager locale) { + super(CommandSpec.TRACK_CLONE.spec(locale), "clone", Permission.TRACK_CLONE, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInfo.java index 5afcd86f..d3407270 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInfo.java @@ -30,17 +30,19 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Track; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class TrackInfo extends SubCommand { - public TrackInfo() { - super("info", "Gives info about the track", Permission.TRACK_INFO, Predicates.alwaysFalse(), null); + public TrackInfo(LocaleManager locale) { + super(CommandSpec.TRACK_INFO.spec(locale), "info", Permission.TRACK_INFO, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInsert.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInsert.java index 0b81627a..6f0a0e52 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInsert.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInsert.java @@ -25,18 +25,19 @@ package me.lucko.luckperms.common.commands.impl.track; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; @@ -44,13 +45,8 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class TrackInsert extends SubCommand { - public TrackInsert() { - super("insert", "Inserts a group at a given position along the track", Permission.TRACK_INSERT, Predicates.not(2), - Arg.list( - Arg.create("group", true, "the group to insert"), - Arg.create("position", true, "the position to insert the group at (the first position on the track is 1)") - ) - ); + public TrackInsert(LocaleManager locale) { + super(CommandSpec.TRACK_INSERT.spec(locale), "insert", Permission.TRACK_INSERT, Predicates.not(2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackMainCommand.java index 96423c18..1ece0932 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackMainCommand.java @@ -30,23 +30,25 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.commands.abstraction.Command; import me.lucko.luckperms.common.commands.abstraction.MainCommand; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.model.Track; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import java.util.ArrayList; import java.util.List; public class TrackMainCommand extends MainCommand { - public TrackMainCommand() { - super("Track", "Track commands", "/%s track ", 2, ImmutableList.>builder() - .add(new TrackInfo()) - .add(new TrackAppend()) - .add(new TrackInsert()) - .add(new TrackRemove()) - .add(new TrackClear()) - .add(new TrackRename()) - .add(new TrackClone()) + public TrackMainCommand(LocaleManager locale) { + super(CommandSpec.TRACK.spec(locale), "Track", 2, ImmutableList.>builder() + .add(new TrackInfo(locale)) + .add(new TrackAppend(locale)) + .add(new TrackInsert(locale)) + .add(new TrackRemove(locale)) + .add(new TrackClear(locale)) + .add(new TrackRename(locale)) + .add(new TrackClone(locale)) .build() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRemove.java index af4cd1fc..5a3b724b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRemove.java @@ -25,17 +25,18 @@ package me.lucko.luckperms.common.commands.impl.track; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; @@ -43,10 +44,8 @@ import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.List; public class TrackRemove extends SubCommand { - public TrackRemove() { - super("remove", "Removes a group from the track", Permission.TRACK_REMOVE, Predicates.not(1), - Arg.list(Arg.create("group", true, "the group to remove")) - ); + public TrackRemove(LocaleManager locale) { + super(CommandSpec.TRACK_REMOVE.spec(locale), "remove", Permission.TRACK_REMOVE, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRename.java index 63adb64b..78185bec 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRename.java @@ -27,26 +27,25 @@ package me.lucko.luckperms.common.commands.impl.track; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.api.event.cause.DeletionCause; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class TrackRename extends SubCommand { - public TrackRename() { - super("rename", "Rename the track", Permission.TRACK_RENAME, Predicates.not(1), - Arg.list(Arg.create("name", true, "the new name")) - ); + public TrackRename(LocaleManager locale) { + super(CommandSpec.TRACK_RENAME.spec(locale), "rename", Permission.TRACK_RENAME, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java index 5803cd62..c1cc88c7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java @@ -27,7 +27,6 @@ package me.lucko.luckperms.common.commands.impl.user; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -35,13 +34,15 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; @@ -51,13 +52,8 @@ import java.util.Set; import java.util.stream.Collectors; public class UserDemote extends SubCommand { - public UserDemote() { - super("demote", "Demotes the user down a track", Permission.USER_DEMOTE, Predicates.is(0), - Arg.list( - Arg.create("track", true, "the track to demote the user down"), - Arg.create("context...", false, "the contexts to demote the user in") - ) - ); + public UserDemote(LocaleManager locale) { + super(CommandSpec.USER_DEMOTE.spec(locale), "demote", Permission.USER_DEMOTE, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java index aacc3b01..0d809bb8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java @@ -33,9 +33,11 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -45,8 +47,8 @@ import java.util.Set; import java.util.stream.Collectors; public class UserInfo extends SubCommand { - public UserInfo() { - super("info", "Shows info about the user", Permission.USER_INFO, Predicates.alwaysFalse(), null); + public UserInfo(LocaleManager locale) { + super(CommandSpec.USER_INFO.spec(locale), "info", Permission.USER_INFO, Predicates.alwaysFalse()); } @SuppressWarnings("unchecked") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java index bcf0fe34..8c8a612f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java @@ -38,26 +38,28 @@ import me.lucko.luckperms.common.commands.impl.generic.permission.CommandPermiss import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import java.util.List; import java.util.UUID; public class UserMainCommand extends MainCommand { - public UserMainCommand() { - super("User", "User commands", "/%s user ", 2, ImmutableList.>builder() - .add(new UserInfo()) - .add(new CommandPermission<>(true)) - .add(new CommandParent<>(true)) - .add(new CommandMeta<>(true)) - .add(new HolderEditor<>(true)) - .add(new UserSwitchPrimaryGroup()) - .add(new UserPromote()) - .add(new UserDemote()) - .add(new HolderShowTracks<>(true)) - .add(new HolderClear<>(true)) + public UserMainCommand(LocaleManager locale) { + super(CommandSpec.USER.spec(locale), "User", 2, ImmutableList.>builder() + .add(new UserInfo(locale)) + .add(new CommandPermission<>(locale, true)) + .add(new CommandParent<>(locale, true)) + .add(new CommandMeta<>(locale, true)) + .add(new HolderEditor<>(locale, true)) + .add(new UserSwitchPrimaryGroup(locale)) + .add(new UserPromote(locale)) + .add(new UserDemote(locale)) + .add(new HolderShowTracks<>(locale, true)) + .add(new HolderClear<>(locale, true)) .build() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java index bcc6d8d3..5801f954 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java @@ -27,7 +27,6 @@ package me.lucko.luckperms.common.commands.impl.user; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -35,13 +34,15 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.DataConstraints; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; @@ -51,13 +52,8 @@ import java.util.Set; import java.util.stream.Collectors; public class UserPromote extends SubCommand { - public UserPromote() { - super("promote", "Promotes the user up a track", Permission.USER_PROMOTE, Predicates.is(0), - Arg.list( - Arg.create("track", true, "the track to promote the user up"), - Arg.create("context...", false, "the contexts to promote the user in") - ) - ); + public UserPromote(LocaleManager locale) { + super(CommandSpec.USER_PROMOTE.spec(locale), "promote", Permission.USER_PROMOTE, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserSwitchPrimaryGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserSwitchPrimaryGroup.java index 1648f972..5583426b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserSwitchPrimaryGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserSwitchPrimaryGroup.java @@ -26,27 +26,26 @@ package me.lucko.luckperms.common.commands.impl.user; import me.lucko.luckperms.api.context.ContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class UserSwitchPrimaryGroup extends SubCommand { - public UserSwitchPrimaryGroup() { - super("switchprimarygroup", "Switches the user's primary group", Permission.USER_SWITCHPRIMARYGROUP, Predicates.not(1), - Arg.list(Arg.create("group", true, "the group to switch to")) - ); + public UserSwitchPrimaryGroup(LocaleManager locale) { + super(CommandSpec.USER_SWITCHPRIMARYGROUP.spec(locale), "switchprimarygroup", Permission.USER_SWITCHPRIMARYGROUP, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/utils/Util.java b/common/src/main/java/me/lucko/luckperms/common/commands/utils/Util.java index 1883644c..bf4ed442 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/utils/Util.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/utils/Util.java @@ -31,7 +31,7 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; +import me.lucko.luckperms.common.locale.Message; import java.util.ArrayList; import java.util.Collection; diff --git a/common/src/main/java/me/lucko/luckperms/common/data/Exporter.java b/common/src/main/java/me/lucko/luckperms/common/data/Exporter.java index 37908d63..db859ba3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/data/Exporter.java +++ b/common/src/main/java/me/lucko/luckperms/common/data/Exporter.java @@ -28,11 +28,11 @@ package me.lucko.luckperms.common.data; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.storage.Storage; import me.lucko.luckperms.common.utils.ProgressLogger; diff --git a/common/src/main/java/me/lucko/luckperms/common/data/Importer.java b/common/src/main/java/me/lucko/luckperms/common/data/Importer.java index 44b8dc4e..09915ccb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/data/Importer.java +++ b/common/src/main/java/me/lucko/luckperms/common/data/Importer.java @@ -37,8 +37,8 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Constants; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; diff --git a/common/src/main/java/me/lucko/luckperms/common/data/LogEntry.java b/common/src/main/java/me/lucko/luckperms/common/data/LogEntry.java index 6b9fa10f..599440c1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/data/LogEntry.java +++ b/common/src/main/java/me/lucko/luckperms/common/data/LogEntry.java @@ -27,12 +27,12 @@ package me.lucko.luckperms.common.data; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/CommandSpec.java b/common/src/main/java/me/lucko/luckperms/common/locale/CommandSpec.java new file mode 100644 index 00000000..a75e6482 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/locale/CommandSpec.java @@ -0,0 +1,656 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.common.locale; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.ToString; + +import com.google.common.collect.ImmutableList; + +import me.lucko.luckperms.common.commands.Arg; + +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; + +/** + * An enumeration of the command defintion/usage messages used in the plugin. + * + *

The values in this enum are only defaults, and are only returned if no value for the key is present in the + * {@link LocaleManager}.

+ */ +@SuppressWarnings("SpellCheckingInspection") +public enum CommandSpec { + + USER("User commands", "/%s user "), + GROUP("Group commands", "/%s group "), + TRACK("Track commands", "/%s track "), + LOG("Log commands", "/%s log"), + + SYNC("Sync changes with the storage", "/%s sync"), + INFO("Print general plugin info", "/%s info"), + VERBOSE("Manage verbose permission checking", "/%s verbose [filter]", + Arg.list( + Arg.create("on|record|off|paste", true, "whether to enable/disable logging, or to paste the logged output"), + Arg.create("filter", false, "the filter to match entries against") + ) + ), + TREE("Generate a tree view of permissions", "/%s tree [selection] [max level] [player]", + Arg.list( + Arg.create("selection", false, "the root of the tree. specify \".\" to include all permissions"), + Arg.create("max level", false, "how many branch levels should be returned"), + Arg.create("player", false, "the name of an online player to check against") + ) + ), + SEARCH("Search for users/groups with a specific permission", "/%s search ", + Arg.list( + Arg.create("permission", true, "the permission to search for"), + Arg.create("page", false, "the page to view") + ) + ), + CHECK("Perform a standard permission check on an online player", "/%s check ", + Arg.list( + Arg.create("user", true, "the user to check"), + Arg.create("permission", true, "the permission to check for") + ) + ), + NETWORK_SYNC("Sync changes with the storage and request that all other servers on the network do the same", "/%s networksync"), + IMPORT("Import data from a file", "/%s import ", + Arg.list( + Arg.create("file", true, "the file to import from") + ) + ), + EXPORT("Export data to a file", "/%s export ", + Arg.list( + Arg.create("file", true, "the file to export to") + ) + ), + RELOAD_CONFIG("Reload some of the config options", "/%s reloadconfig"), + BULK_UPDATE("Execute bulk change queries on all data", "/%s bulkupdate", + Arg.list( + Arg.create("data type", true, "the type of data being changed. ('all', 'users' or 'groups')"), + Arg.create("action", true, "the action to perform on the data. ('update' or 'delete')"), + Arg.create("action field", false, "the field to act upon. only required for 'update'. ('permission', 'server' or 'world')"), + Arg.create("action value", false, "the value to replace with. only required for 'update'."), + Arg.create("constraint...", false, "the constraints required for the update") + ) + ), + MIGRATION("Migration commands", "/%s migration"), + APPLY_EDITS("Applies permission changes made from the web editor", "/%s applyedits [target]", + Arg.list( + Arg.create("code", true, "the unique code for the data"), + Arg.create("target", false, "who to apply the data to") + ) + ), + + CREATE_GROUP("Create a new group", "/%s creategroup ", + Arg.list( + Arg.create("name", true, "the name of the group") + ) + ), + DELETE_GROUP("Delete a group", "/%s deletegroup ", + Arg.list( + Arg.create("name", true, "the name of the group") + ) + ), + LIST_GROUPS("List all groups on the platform", "/%s listgroups"), + + CREATE_TRACK("Create a new track", "/%s createtrack ", + Arg.list( + Arg.create("name", true, "the name of the track") + ) + ), + DELETE_TRACK("Delete a track", "/%s deletetrack ", + Arg.list( + Arg.create("name", true, "the name of the track") + ) + ), + LIST_TRACKS("List all tracks on the platform", "/%s listtracks"), + + USER_INFO("Shows info about the user"), + USER_SWITCHPRIMARYGROUP("Switches the user's primary group", + Arg.list( + Arg.create("group", true, "the group to switch to") + ) + ), + USER_PROMOTE("Promotes the user up a track", + Arg.list( + Arg.create("track", true, "the track to promote the user up"), + Arg.create("context...", false, "the contexts to promote the user in") + ) + ), + USER_DEMOTE("Demotes the user down a track", + Arg.list( + Arg.create("track", true, "the track to demote the user down"), + Arg.create("context...", false, "the contexts to demote the user in") + ) + ), + + GROUP_INFO("Gives info about the group"), + GROUP_LISTMEMBERS("Show the users/groups who inherit from this group", + Arg.list( + Arg.create("page", false, "the page to view") + ) + ), + GROUP_SETWEIGHT("Set the groups weight", + Arg.list( + Arg.create("weight", true, "the weight to set") + ) + ), + GROUP_RENAME("Rename the group", + Arg.list( + Arg.create("name", true, "the new name") + ) + ), + GROUP_CLONE("Clone the group", + Arg.list( + Arg.create("name", true, "the name of the group to clone onto") + ) + ), + + HOLDER_EDITOR("Opens the web permission editor"), + HOLDER_SHOWTRACKS("Lists the tracks that the object is on"), + HOLDER_CLEAR("Removes all permissions, parents and meta", + Arg.list( + Arg.create("context...", false, "the contexts to filter by") + ) + ), + + PERMISSION("Edit permissions"), + PARENT("Edit inheritances"), + META("Edit metadata values"), + + PERMISSION_INFO("Lists the permission nodes the object has", + Arg.list( + Arg.create("page", false, "the page to view"), + Arg.create("filter", false, "the string to filter by") + ) + ), + PERMISSION_SET("Sets a permission for the object", + Arg.list( + Arg.create("node", true, "the permission node to set"), + Arg.create("true|false", false, "the value of the node"), + Arg.create("context...", false, "the contexts to add the permission in") + ) + ), + PERMISSION_UNSET("Unsets a permission for the object", + Arg.list( + Arg.create("node", true, "the permission node to unset"), + Arg.create("context...", false, "the contexts to remove the permission in") + ) + ), + PERMISSION_SETTEMP("Sets a permission for the object temporarily", + Arg.list( + Arg.create("node", true, "the permission node to set"), + Arg.create("true|false", false, "the value of the node"), + Arg.create("duration", true, "the duration until the permission node expires"), + Arg.create("context...", false, "the contexts to add the permission in") + ) + ), + PERMISSION_UNSETTEMP("Unsets a temporary permission for the object", + Arg.list( + Arg.create("node", true, "the permission node to unset"), + Arg.create("context...", false, "the contexts to remove the permission in") + ) + ), + PERMISSION_CHECK("Checks to see if the object has a certain permission node", + Arg.list( + Arg.create("node", true, "the permission node to check for"), + Arg.create("context...", false, "the contexts to check in") + ) + ), + PERMISSION_CHECK_INHERITS("Checks to see if the object inherits a certain permission node", + Arg.list( + Arg.create("node", true, "the permission node to check for"), + Arg.create("context...", false, "the contexts to check in") + ) + ), + + PARENT_INFO("Lists the groups that this object inherits from"), + PARENT_SET("Removes all other groups the object inherits already and adds them to the one given", + Arg.list( + Arg.create("group", true, "the group to set to"), + Arg.create("context...", false, "the contexts to set the group in") + ) + ), + PARENT_ADD("Sets another group for the object to inherit permissions from", + Arg.list( + Arg.create("group", true, "the group to inherit from"), + Arg.create("context...", false, "the contexts to inherit the group in") + ) + ), + PARENT_REMOVE("Removes a previously set inheritance rule", + Arg.list( + Arg.create("group", true, "the group to remove"), + Arg.create("context...", false, "the contexts to remove the group in") + ) + ), + PARENT_SET_TRACK("Removes all other groups the object inherits from already on the given track and adds them to the one given", + Arg.list( + Arg.create("track", true, "the track to set on"), + Arg.create("group", true, "the group to set to, or a number relating to the position of the group on the given track"), + Arg.create("context...", false, "the contexts to set the group in") + ) + ), + PARENT_ADD_TEMP("Sets another group for the object to inherit permissions from temporarily", + Arg.list( + Arg.create("group", true, "the group to inherit from"), + Arg.create("duration", true, "the duration of the group membership"), + Arg.create("context...", false, "the contexts to inherit the group in") + ) + ), + PARENT_REMOVE_TEMP("Removes a previously set temporary inheritance rule", + Arg.list( + Arg.create("group", true, "the group to remove"), + Arg.create("context...", false, "the contexts to remove the group in") + ) + ), + PARENT_CLEAR("Clears all parents", + Arg.list( + Arg.create("context...", false, "the contexts to filter by") + ) + ), + PARENT_CLEAR_TRACK("Clears all parents on a given track", + Arg.list( + Arg.create("track", true, "the track to remove on"), + Arg.create("context...", false, "the contexts to filter by") + ) + ), + + META_INFO("Shows all chat meta"), + META_SET("Sets a meta value", + Arg.list( + Arg.create("key", true, "the key to set"), + Arg.create("value", true, "the value to set"), + Arg.create("context...", false, "the contexts to add the meta pair in") + ) + ), + META_UNSET("Unsets a meta value", + Arg.list( + Arg.create("key", true, "the key to unset"), + Arg.create("context...", false, "the contexts to remove the meta pair in") + ) + ), + META_SETTEMP("Sets a meta value temporarily", + Arg.list( + Arg.create("key", true, "the key to set"), + Arg.create("value", true, "the value to set"), + Arg.create("duration", true, "the duration until the meta value expires"), + Arg.create("context...", false, "the contexts to add the meta pair in") + ) + ), + META_UNSETTEMP("Unsets a temporary meta value", + Arg.list( + Arg.create("key", true, "the key to unset"), + Arg.create("context...", false, "the contexts to remove the meta pair in") + ) + ), + META_ADDPREFIX("Adds a prefix", + Arg.list( + Arg.create("priority", true, "the priority to add the prefix at"), + Arg.create("prefix", true, "the prefix string"), + Arg.create("context...", false, "the contexts to add the prefix in") + ) + ), + META_ADDSUFFIX("Adds a suffix", + Arg.list( + Arg.create("priority", true, "the priority to add the suffix at"), + Arg.create("suffix", true, "the suffix string"), + Arg.create("context...", false, "the contexts to add the suffix in") + ) + ), + META_REMOVEPREFIX("Removes a prefix", + Arg.list( + Arg.create("priority", true, "the priority to remove the prefix at"), + Arg.create("prefix", false, "the prefix string"), + Arg.create("context...", false, "the contexts to remove the prefix in") + ) + ), + META_REMOVESUFFIX("Removes a suffix", + Arg.list( + Arg.create("priority", true, "the priority to remove the suffix at"), + Arg.create("suffix", false, "the suffix string"), + Arg.create("context...", false, "the contexts to remove the suffix in") + ) + ), + META_ADDTEMP_PREFIX("Adds a prefix temporarily", + Arg.list( + Arg.create("priority", true, "the priority to add the prefix at"), + Arg.create("prefix", true, "the prefix string"), + Arg.create("duration", true, "the duration until the prefix expires"), + Arg.create("context...", false, "the contexts to add the prefix in") + ) + ), + META_ADDTEMP_SUFFIX("Adds a suffix temporarily", + Arg.list( + Arg.create("priority", true, "the priority to add the suffix at"), + Arg.create("suffix", true, "the suffix string"), + Arg.create("duration", true, "the duration until the suffix expires"), + Arg.create("context...", false, "the contexts to add the suffix in") + ) + ), + META_REMOVETEMP_PREFIX("Removes a temporary prefix", + Arg.list( + Arg.create("priority", true, "the priority to remove the prefix at"), + Arg.create("prefix", false, "the prefix string"), + Arg.create("context...", false, "the contexts to remove the prefix in") + ) + ), + META_REMOVETEMP_SUFFIX("Removes a temporary suffix", + Arg.list( + Arg.create("priority", true, "the priority to remove the suffix at"), + Arg.create("suffix", false, "the suffix string"), + Arg.create("context...", false, "the contexts to remove the suffix in") + ) + ), + META_CLEAR("Clears all chat meta", + Arg.list( + Arg.create("context...", false, "the contexts to filter by") + ) + ), + + TRACK_INFO("Gives info about the track"), + TRACK_APPEND("Appends a group onto the end of the track", + Arg.list( + Arg.create("group", true, "the group to append") + ) + ), + TRACK_INSERT("Inserts a group at a given position along the track", + Arg.list( + Arg.create("group", true, "the group to insert"), + Arg.create("position", true, "the position to insert the group at (the first position on the track is 1)") + ) + ), + TRACK_REMOVE("Removes a group from the track", + Arg.list( + Arg.create("group", true, "the group to remove") + ) + ), + TRACK_CLEAR("Clears the groups on the track"), + TRACK_RENAME("Rename the track", + Arg.list( + Arg.create("name", true, "the new name") + ) + ), + TRACK_CLONE("Clone the track", + Arg.list( + Arg.create("name", true, "the name of the track to clone onto") + ) + ), + + LOG_RECENT("View recent actions", + Arg.list( + Arg.create("user", false, "the name/uuid of the user to filter by"), + Arg.create("page", false, "the page number to view") + ) + ), + LOG_SEARCH("Search the log for an entry", + Arg.list( + Arg.create("query", true, "the query to search by"), + Arg.create("page", false, "the page number to view") + ) + ), + LOG_NOTIFY("Toggle log notifications", + Arg.list( + Arg.create("on|off", false, "whether to toggle on or off") + ) + ), + LOG_USER_HISTORY("View a user's history", + Arg.list( + Arg.create("user", true, "the name/uuid of the user"), + Arg.create("page", false, "the page number to view") + ) + ), + LOG_GROUP_HISTORY("View an group's history", + Arg.list( + Arg.create("group", true, "the name of the group"), + Arg.create("page", false, "the page number to view") + ) + ), + LOG_TRACK_HISTORY("View a track's history", + Arg.list( + Arg.create("track", true, "the name of the track"), + Arg.create("page", false, "the page number to view") + ) + ), + + SPONGE("Edit extra Sponge data", "/%s sponge ", + Arg.list( + Arg.create("collection", true, "the collection to query"), + Arg.create("subject", true, "the subject to modify") + ) + ), + SPONGE_PERMISSION_INFO("Shows info about the subject's permissions", + Arg.list( + Arg.create("contexts...", false, "the contexts to filter by") + ) + ), + SPONGE_PERMISSION_SET("Sets a permission for the Subject", + Arg.list( + Arg.create("node", true, "the permission node to set"), + Arg.create("tristate", true, "the value to set the permission to"), + Arg.create("contexts...", false, "the contexts to set the permission in") + ) + ), + SPONGE_PERMISSION_CLEAR("Clears the Subjects permissions", + Arg.list( + Arg.create("contexts...", false, "the contexts to clear permissions in") + ) + ), + SPONGE_PARENT_INFO("Shows info about the subject's parents", + Arg.list( + Arg.create("contexts...", false, "the contexts to filter by") + ) + ), + SPONGE_PARENT_ADD("Adds a parent to the Subject", + Arg.list( + Arg.create("collection", true, "the subject collection where the parent Subject is"), + Arg.create("subject", true, "the name of the parent Subject"), + Arg.create("contexts...", false, "the contexts to add the parent in") + ) + ), + SPONGE_PARENT_REMOVE("Removes a parent from the Subject", + Arg.list( + Arg.create("collection", true, "the subject collection where the parent Subject is"), + Arg.create("subject", true, "the name of the parent Subject"), + Arg.create("contexts...", false, "the contexts to remove the parent in") + ) + ), + SPONGE_PARENT_CLEAR("Clears the Subjects parents", + Arg.list( + Arg.create("contexts...", false, "the contexts to clear parents in") + ) + ), + SPONGE_OPTION_INFO("Shows info about the subject's options", + Arg.list( + Arg.create("contexts...", false, "the contexts to filter by") + ) + ), + SPONGE_OPTION_SET("Sets an option for the Subject", + Arg.list( + Arg.create("key", true, "the key to set"), + Arg.create("value", true, "the value to set the key to"), + Arg.create("contexts...", false, "the contexts to set the option in") + ) + ), + SPONGE_OPTION_UNSET("Unsets an option for the Subject", + Arg.list( + Arg.create("key", true, "the key to unset"), + Arg.create("contexts...", false, "the contexts to unset the key in") + ) + ), + SPONGE_OPTION_CLEAR("Clears the Subjects options", + Arg.list( + Arg.create("contexts...", false, "the contexts to clear options in") + ) + ), + + MIGRATION_COMMAND("Migration command"), + MIGRATION_GROUPMANAGER("Migration command", + Arg.list( + Arg.create("migrate as global", true, "if world permissions should be ignored, and just migrated as global") + ) + ), + MIGRATION_POWERFULPERMS("Migration command", + Arg.list( + Arg.create("address", true, "the address of the PP database"), + Arg.create("database", true, "the name of the PP database"), + Arg.create("username", true, "the username to log into the DB"), + Arg.create("password", true, "the password to log into the DB"), + Arg.create("db table", true, "the name of the PP table where player data is stored") + ) + ); + + private final String description; + private final String usage; + private final List args; + + CommandSpec(String description, String usage, List args) { + this.description = description; + this.usage = usage; + this.args = args; + } + + CommandSpec(String description, String usage) { + this(description, usage, null); + } + + CommandSpec(String description) { + this(description, null, null); + } + + CommandSpec(String description, List args) { + this(description, null, args); + } + + /** + * Creates a {@link LocalizedSpec} for the spec using the platforms locale manager. + * + * @param localeManager the locale manager to use for the spec + * @return a localized spec instance + */ + public LocalizedSpec spec(LocaleManager localeManager) { + return new SimpleLocalizedSpec(this, localeManager); + } + + /** + * The localized data for a {@link CommandSpec}. + */ + @Getter + @ToString + @AllArgsConstructor + public static final class CommandSpecData { + private final String description; + private final String usage; + private final Map args; + } + + private static final class SimpleLocalizedSpec implements LocalizedSpec { + + @Getter + private final LocaleManager localeManager; + + private final CommandSpec spec; + + public SimpleLocalizedSpec(CommandSpec spec, LocaleManager localeManager) { + this.localeManager = localeManager; + this.spec = spec; + } + + public String description() { + CommandSpecData translation = localeManager.getTranslation(spec); + if (translation != null && translation.getDescription() != null) { + return translation.getDescription(); + } + + // fallback + return spec.description; + } + + public String usage() { + CommandSpecData translation = localeManager.getTranslation(spec); + if (translation != null && translation.getUsage() != null) { + return translation.getUsage(); + } + + // fallback + return spec.usage; + } + + public List args() { + CommandSpecData translation = localeManager.getTranslation(spec); + if (translation == null || translation.getArgs() == null) { + // fallback + return spec.args; + } + + List args = new ArrayList<>(spec.args); + ListIterator it = args.listIterator(); + while (it.hasNext()) { + Arg next = it.next(); + String s = translation.getArgs().get(next.getName()); + + // if a translation for the given arg key is present, apply the new description. + if (s != null) { + it.set(Arg.create(next.getName(), next.isRequired(), s)); + } + } + + return ImmutableList.copyOf(args); + } + } + + /** + * Prints this CommandSpec enum in a yml format, for reading by the {@link me.lucko.luckperms.common.locale.LocaleManager} + * @param args not needed + */ + public static void main(String[] args) { + System.out.println("command-specs:"); + + for (CommandSpec spec : values()) { + String key = spec.name().replace('_', '-').toLowerCase(); + + System.out.println(" " + key + ":"); + + if (spec.description != null) { + System.out.println(" description: \"" + spec.description.replace("\"", "\\\"") + "\""); + } + if (spec.usage != null) { + System.out.println(" usage: \"" + spec.usage.replace("\"", "\\\"") + "\""); + } + + if (spec.args != null && !spec.args.isEmpty()) { + System.out.println(" args:"); + for (Arg arg : spec.args) { + System.out.println(" \"" + arg.getName() + "\": \"" + arg.getDescription().replace("\"", "\\\"") + "\""); + } + } + } + } + +} diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java b/common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java index 072fd753..d5c5051e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java @@ -25,8 +25,6 @@ package me.lucko.luckperms.common.locale; -import me.lucko.luckperms.common.constants.Message; - import java.io.File; /** @@ -40,9 +38,18 @@ public interface LocaleManager { /** * Gets a translation for a given message key + * * @param key the key - * @return the translation, or null if there isn't a translation available. + * @return the translation, or null if there isn't any translation available. */ String getTranslation(Message key); + /** + * Gets a translation for a given command spec key + * + * @param key the key + * @return the translation data, or null if there isn't any translation available. + */ + CommandSpec.CommandSpecData getTranslation(CommandSpec key); + } diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/LocalizedSpec.java b/common/src/main/java/me/lucko/luckperms/common/locale/LocalizedSpec.java new file mode 100644 index 00000000..97c023f2 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/locale/LocalizedSpec.java @@ -0,0 +1,50 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.common.locale; + +import me.lucko.luckperms.common.commands.Arg; + +import java.util.List; + +/** + * Represents a localized instance of a {@link CommandSpec}. + */ +public interface LocalizedSpec { + + /** + * Gets the locale manager used to translate the {@link CommandSpec}. + * + * @return the locale manager + */ + LocaleManager getLocaleManager(); + + String description(); + + String usage(); + + List args(); + +} diff --git a/common/src/main/java/me/lucko/luckperms/common/constants/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java similarity index 99% rename from common/src/main/java/me/lucko/luckperms/common/constants/Message.java rename to common/src/main/java/me/lucko/luckperms/common/locale/Message.java index 07c1af3b..0484218a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/constants/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java @@ -23,15 +23,20 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.constants; +package me.lucko.luckperms.common.locale; import lombok.AllArgsConstructor; import lombok.Getter; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.locale.LocaleManager; +/** + * An enumeration of some of the messages used within the plugin. + * + *

The values in this enum are only defaults, and are only returned if no value for the key is present in the + * {@link LocaleManager}.

+ */ @SuppressWarnings("SpellCheckingInspection") @AllArgsConstructor public enum Message { @@ -425,11 +430,6 @@ public enum Message { private String message; private boolean showPrefix; - @Override - public String toString() { - return asString(null); - } - public String asString(LocaleManager localeManager, Object... objects) { String prefix = null; if (localeManager != null) { diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/NoopLocaleManager.java b/common/src/main/java/me/lucko/luckperms/common/locale/NoopLocaleManager.java index 14de8c28..9beacc85 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/NoopLocaleManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/NoopLocaleManager.java @@ -25,8 +25,6 @@ package me.lucko.luckperms.common.locale; -import me.lucko.luckperms.common.constants.Message; - import java.io.File; public class NoopLocaleManager implements LocaleManager { @@ -46,4 +44,9 @@ public class NoopLocaleManager implements LocaleManager { return null; } + @Override + public CommandSpec.CommandSpecData getTranslation(CommandSpec key) { + return null; + } + } diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/SimpleLocaleManager.java b/common/src/main/java/me/lucko/luckperms/common/locale/SimpleLocaleManager.java index 32e6650f..0334b7d1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/SimpleLocaleManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/SimpleLocaleManager.java @@ -27,8 +27,6 @@ package me.lucko.luckperms.common.locale; import com.google.common.collect.ImmutableMap; -import me.lucko.luckperms.common.constants.Message; - import org.yaml.snakeyaml.Yaml; import java.io.BufferedReader; @@ -39,28 +37,83 @@ import java.util.Map; public class SimpleLocaleManager implements LocaleManager { - private Map translations = null; + private Map messages = ImmutableMap.of(); + private Map commands = ImmutableMap.of(); @SuppressWarnings("unchecked") public void loadFromFile(File file) throws Exception { try (BufferedReader reader = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) { - translations = ImmutableMap.copyOf((Map) new Yaml().load(reader)); + ImmutableMap.Builder messages = ImmutableMap.builder(); + ImmutableMap.Builder commands = ImmutableMap.builder(); + + Map data = (Map) new Yaml().load(reader); + for (Map.Entry entry : data.entrySet()) { + if (entry.getKey() == null || entry.getKey().isEmpty() || entry.getValue() == null) { + continue; + } + + // might be a message + if (entry.getValue() instanceof String) { + String key = entry.getKey().toUpperCase().replace('-', '_'); + String value = (String) entry.getValue(); + + try { + messages.put(Message.valueOf(key), value); + } catch (IllegalArgumentException e) { + // ignore + } + } + + // might be the entries for command specifications - take care for malformed entries of differing types. + if (entry.getKey().equals("command-specs") && entry.getValue() instanceof Map) { + Map commandKeys = (Map) entry.getValue(); + + // key is the command id, value is a map of the commands attributes + for (Map.Entry commandKey : commandKeys.entrySet()) { + + // just try catch, can't be bothered with safe casting every single value. + try { + String id = (String) commandKey.getKey(); + Map attributes = (Map) commandKey.getValue(); + CommandSpec spec = CommandSpec.valueOf(id.toUpperCase().replace('-', '_')); + + String description = (String) attributes.get("description"); + String usage = (String) attributes.get("usage"); + Map args = (Map) attributes.get("args"); + if (args.isEmpty()) { + args = null; + } + + CommandSpec.CommandSpecData specData = new CommandSpec.CommandSpecData(description, usage, args == null ? null : ImmutableMap.copyOf(args)); + commands.put(spec, specData); + + } catch (IllegalArgumentException e) { + // ignore + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + this.messages = messages.build(); + this.commands = commands.build(); } } @Override public int getSize() { - return translations == null ? 0 : translations.size(); + return messages.size() + commands.size(); } @Override public String getTranslation(Message key) { - if (translations == null) { - return null; - } + return messages.get(key); + } - String k = key.name().toLowerCase().replace('_', '-'); - return translations.get(k); + @Override + public CommandSpec.CommandSpecData getTranslation(CommandSpec key) { + return commands.get(key); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java index 1fc47eb3..d990acf4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java @@ -36,11 +36,11 @@ import me.lucko.luckperms.common.commands.abstraction.Command; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.config.LuckPermsConfiguration; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.contexts.ContextManager; import me.lucko.luckperms.common.core.UuidCache; import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.managers.GroupManager; import me.lucko.luckperms.common.managers.TrackManager; import me.lucko.luckperms.common.managers.UserManager; diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/ProgressLogger.java b/common/src/main/java/me/lucko/luckperms/common/utils/ProgressLogger.java index 67bcb89c..3ec28f0b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/ProgressLogger.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/ProgressLogger.java @@ -29,7 +29,7 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/SenderLogger.java b/common/src/main/java/me/lucko/luckperms/common/utils/SenderLogger.java index 5d1b6744..46ca90a3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/SenderLogger.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/SenderLogger.java @@ -29,7 +29,7 @@ import lombok.AllArgsConstructor; import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; +import me.lucko.luckperms.common.locale.Message; @AllArgsConstructor public class SenderLogger implements Logger { diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java index 8bfa775f..c98640fd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java @@ -30,7 +30,7 @@ import lombok.RequiredArgsConstructor; import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.PasteUtils; import me.lucko.luckperms.common.utils.Scripting; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeListener.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeListener.java index 2236b975..43ead03e 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeListener.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeListener.java @@ -29,9 +29,9 @@ import lombok.RequiredArgsConstructor; import me.lucko.luckperms.api.caching.UserData; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.UuidCache; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.utils.LoginHelper; import me.lucko.luckperms.sponge.timings.LPTiming; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionClear.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionClear.java index 4600891f..49ab8da0 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionClear.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionClear.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -34,6 +33,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -41,12 +42,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import java.util.List; public class OptionClear extends SubCommand { - public OptionClear() { - super("clear", "Clears the Subjects options", Permission.SPONGE_OPTION_CLEAR, Predicates.alwaysFalse(), - Arg.list( - Arg.create("contexts...", false, "the contexts to clear options in") - ) - ); + public OptionClear(LocaleManager locale) { + super(CommandSpec.SPONGE_OPTION_CLEAR.spec(locale), "clear", Permission.SPONGE_OPTION_CLEAR, Predicates.alwaysFalse()); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionInfo.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionInfo.java index 538b59fd..8c2a3607 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionInfo.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionInfo.java @@ -28,7 +28,6 @@ package me.lucko.luckperms.sponge.commands; import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -36,6 +35,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -44,10 +45,8 @@ import java.util.List; import java.util.Map; public class OptionInfo extends SubCommand { - public OptionInfo() { - super("info", "Shows info about the subject's options", Permission.SPONGE_OPTION_INFO, Predicates.alwaysFalse(), - Arg.list(Arg.create("contexts...", false, "the contexts to filter by")) - ); + public OptionInfo(LocaleManager locale) { + super(CommandSpec.SPONGE_OPTION_INFO.spec(locale), "info", Permission.SPONGE_OPTION_INFO, Predicates.alwaysFalse()); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionSet.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionSet.java index 64b6dd95..b54b64c2 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionSet.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionSet.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -34,6 +33,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -41,14 +42,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import java.util.List; public class OptionSet extends SubCommand { - public OptionSet() { - super("set", "Sets an option for the Subject", Permission.SPONGE_OPTION_SET, Predicates.inRange(0, 1), - Arg.list( - Arg.create("key", true, "the key to set"), - Arg.create("value", true, "the value to set the key to"), - Arg.create("contexts...", false, "the contexts to set the option in") - ) - ); + public OptionSet(LocaleManager locale) { + super(CommandSpec.SPONGE_OPTION_SET.spec(locale), "set", Permission.SPONGE_OPTION_SET, Predicates.inRange(0, 1)); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionUnset.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionUnset.java index 0c6759e7..1fa0caa1 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionUnset.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionUnset.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -34,6 +33,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -41,13 +42,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import java.util.List; public class OptionUnset extends SubCommand { - public OptionUnset() { - super("unset", "Unsets an option for the Subject", Permission.SPONGE_OPTION_UNSET, Predicates.is(0), - Arg.list( - Arg.create("key", true, "the key to unset"), - Arg.create("contexts...", false, "the contexts to unset the key in") - ) - ); + public OptionUnset(LocaleManager locale) { + super(CommandSpec.SPONGE_OPTION_UNSET.spec(locale), "unset", Permission.SPONGE_OPTION_UNSET, Predicates.is(0)); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentAdd.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentAdd.java index ef701ee2..bb8ce854 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentAdd.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentAdd.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -34,6 +33,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.LuckPermsService; @@ -46,14 +47,8 @@ import org.spongepowered.api.Sponge; import java.util.List; public class ParentAdd extends SubCommand { - public ParentAdd() { - super("add", "Adds a parent to the Subject", Permission.SPONGE_PARENT_ADD, Predicates.inRange(0, 1), - Arg.list( - Arg.create("collection", true, "the subject collection where the parent Subject is"), - Arg.create("subject", true, "the name of the parent Subject"), - Arg.create("contexts...", false, "the contexts to add the parent in") - ) - ); + public ParentAdd(LocaleManager locale) { + super(CommandSpec.SPONGE_PARENT_ADD.spec(locale), "add", Permission.SPONGE_PARENT_ADD, Predicates.inRange(0, 1)); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentClear.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentClear.java index 3b257162..78b0923a 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentClear.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentClear.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -34,6 +33,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -41,12 +42,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import java.util.List; public class ParentClear extends SubCommand { - public ParentClear() { - super("clear", "Clears the Subjects parents", Permission.SPONGE_PARENT_CLEAR, Predicates.alwaysFalse(), - Arg.list( - Arg.create("contexts...", false, "the contexts to clear parents in") - ) - ); + public ParentClear(LocaleManager locale) { + super(CommandSpec.SPONGE_PARENT_CLEAR.spec(locale), "clear", Permission.SPONGE_PARENT_CLEAR, Predicates.alwaysFalse()); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentInfo.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentInfo.java index 2a353aff..35a4308f 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentInfo.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentInfo.java @@ -28,7 +28,6 @@ package me.lucko.luckperms.sponge.commands; import com.google.common.collect.ImmutableList; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -36,6 +35,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -45,10 +46,8 @@ import java.util.List; import java.util.Map; public class ParentInfo extends SubCommand { - public ParentInfo() { - super("info", "Shows info about the subject's parents", Permission.SPONGE_PARENT_INFO, Predicates.alwaysFalse(), - Arg.list(Arg.create("contexts...", false, "the contexts to filter by")) - ); + public ParentInfo(LocaleManager locale) { + super(CommandSpec.SPONGE_PARENT_INFO.spec(locale), "info", Permission.SPONGE_PARENT_INFO, Predicates.alwaysFalse()); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentRemove.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentRemove.java index fae713e8..2ad2423a 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentRemove.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentRemove.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -34,6 +33,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.LuckPermsService; @@ -46,14 +47,8 @@ import org.spongepowered.api.Sponge; import java.util.List; public class ParentRemove extends SubCommand { - public ParentRemove() { - super("remove", "Removes a parent from the Subject", Permission.SPONGE_PARENT_REMOVE, Predicates.inRange(0, 1), - Arg.list( - Arg.create("collection", true, "the subject collection where the parent Subject is"), - Arg.create("subject", true, "the name of the parent Subject"), - Arg.create("contexts...", false, "the contexts to remove the parent in") - ) - ); + public ParentRemove(LocaleManager locale) { + super(CommandSpec.SPONGE_PARENT_REMOVE.spec(locale), "remove", Permission.SPONGE_PARENT_REMOVE, Predicates.inRange(0, 1)); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionClear.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionClear.java index fe8dc9cb..e244695b 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionClear.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionClear.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -34,6 +33,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -41,12 +42,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import java.util.List; public class PermissionClear extends SubCommand { - public PermissionClear() { - super("clear", "Clears the Subjects permissions", Permission.SPONGE_PERMISSION_CLEAR, Predicates.alwaysFalse(), - Arg.list( - Arg.create("contexts...", false, "the contexts to clear permissions in") - ) - ); + public PermissionClear(LocaleManager locale) { + super(CommandSpec.SPONGE_PERMISSION_CLEAR.spec(locale), "clear", Permission.SPONGE_PERMISSION_CLEAR, Predicates.alwaysFalse()); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionInfo.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionInfo.java index 1704280c..c1276b87 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionInfo.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionInfo.java @@ -28,7 +28,6 @@ package me.lucko.luckperms.sponge.commands; import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -36,6 +35,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -44,10 +45,8 @@ import java.util.List; import java.util.Map; public class PermissionInfo extends SubCommand { - public PermissionInfo() { - super("info", "Shows info about the subject's permissions", Permission.SPONGE_PERMISSION_INFO, Predicates.alwaysFalse(), - Arg.list(Arg.create("contexts...", false, "the contexts to filter by")) - ); + public PermissionInfo(LocaleManager locale) { + super(CommandSpec.SPONGE_PERMISSION_INFO.spec(locale), "info", Permission.SPONGE_PERMISSION_INFO, Predicates.alwaysFalse()); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionSet.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionSet.java index ccf7dcf5..6b4c0fb3 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionSet.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionSet.java @@ -27,7 +27,6 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.SubCommand; @@ -35,6 +34,8 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -42,14 +43,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import java.util.List; public class PermissionSet extends SubCommand { - public PermissionSet() { - super("set", "Sets a permission for the Subject", Permission.SPONGE_PERMISSION_SET, Predicates.inRange(0, 1), - Arg.list( - Arg.create("node", true, "the permission node to set"), - Arg.create("tristate", true, "the value to set the permission to"), - Arg.create("contexts...", false, "the contexts to set the permission in") - ) - ); + public PermissionSet(LocaleManager locale) { + super(CommandSpec.SPONGE_PERMISSION_SET.spec(locale), "set", Permission.SPONGE_PERMISSION_SET, Predicates.inRange(0, 1)); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java index 8a9fe73c..1e02ae3d 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java @@ -28,14 +28,15 @@ package me.lucko.luckperms.sponge.commands; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandException; import me.lucko.luckperms.common.commands.CommandManager; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.abstraction.Command; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.Util; -import me.lucko.luckperms.common.constants.Message; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.ImmutableCollectors; import me.lucko.luckperms.common.utils.Predicates; @@ -55,41 +56,35 @@ import java.util.stream.Collectors; public class SpongeMainCommand extends Command { private final LPSpongePlugin plugin; - private final Map>> subCommands = ImmutableMap.>>builder() - .put("permission", ImmutableList.>builder() - .add(new PermissionInfo()) - .add(new PermissionSet()) - .add(new PermissionClear()) - .build() - ) - .put("parent", ImmutableList.>builder() - .add(new ParentInfo()) - .add(new ParentAdd()) - .add(new ParentRemove()) - .add(new ParentClear()) - .build() - ) - .put("option", ImmutableList.>builder() - .add(new OptionInfo()) - .add(new OptionSet()) - .add(new OptionUnset()) - .add(new OptionClear()) - .build() - ) - .build(); + private final Map>> subCommands; public SpongeMainCommand(LPSpongePlugin plugin) { - super( - "Sponge", - "Edit extra Sponge data", - null, - Predicates.alwaysFalse(), - Arg.list( - Arg.create("collection", true, "the collection to query"), - Arg.create("subject", true, "the subject to modify") - ), - null - ); + super(CommandSpec.SPONGE.spec(plugin.getLocaleManager()), "Sponge", null, Predicates.alwaysFalse()); + + LocaleManager locale = plugin.getLocaleManager(); + + subCommands = ImmutableMap.>>builder() + .put("permission", ImmutableList.>builder() + .add(new PermissionInfo(locale)) + .add(new PermissionSet(locale)) + .add(new PermissionClear(locale)) + .build() + ) + .put("parent", ImmutableList.>builder() + .add(new ParentInfo(locale)) + .add(new ParentAdd(locale)) + .add(new ParentRemove(locale)) + .add(new ParentClear(locale)) + .build() + ) + .put("option", ImmutableList.>builder() + .add(new OptionInfo(locale)) + .add(new OptionSet(locale)) + .add(new OptionUnset(locale)) + .add(new OptionClear(locale)) + .build() + ) + .build(); this.plugin = plugin; } @@ -199,8 +194,6 @@ public class SpongeMainCommand extends Command { return result; } - // TODO tab completion - @Override public void sendUsage(Sender sender, String label) { Util.sendPluginMessage(sender, "&3> &a" + String.format(getUsage(), label)); @@ -228,11 +221,6 @@ public class SpongeMainCommand extends Command { return getSubCommands().stream().filter(sc -> sc.isAuthorized(sender)).count() != 0; } - @Override - public String getUsage() { - return "/%s sponge "; - } - public List> getSubCommands() { return subCommands.values().stream().flatMap(List::stream).collect(ImmutableCollectors.toImmutableList()); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionManager.java b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionManager.java index 9b0407a0..72ac526c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionManager.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionManager.java @@ -35,6 +35,8 @@ import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.ProgressLogger; @@ -56,8 +58,8 @@ import java.util.concurrent.atomic.AtomicInteger; import static me.lucko.luckperms.sponge.migration.SpongeMigrationUtils.migrateSubject; public class MigrationPermissionManager extends SubCommand { - public MigrationPermissionManager() { - super("permissionmanager", "Migration from PermissionManager", Permission.MIGRATION, Predicates.alwaysFalse(), null); + public MigrationPermissionManager(LocaleManager locale) { + super(CommandSpec.MIGRATION_COMMAND.spec(locale), "permissionmanager", Permission.MIGRATION, Predicates.alwaysFalse()); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java index a1270d0a..c864b83f 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java @@ -36,6 +36,8 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Track; import me.lucko.luckperms.common.core.model.User; +import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.ProgressLogger; @@ -62,8 +64,8 @@ import java.util.concurrent.atomic.AtomicInteger; import static me.lucko.luckperms.sponge.migration.SpongeMigrationUtils.migrateSubject; public class MigrationPermissionsEx extends SubCommand { - public MigrationPermissionsEx() { - super("permissionsex", "Migration from PermissionsEx", Permission.MIGRATION, Predicates.alwaysFalse(), null); + public MigrationPermissionsEx(LocaleManager locale) { + super(CommandSpec.MIGRATION_COMMAND.spec(locale), "permissionsex", Permission.MIGRATION, Predicates.alwaysFalse()); } @Override