From c1e0b874d8a1a0601150a6ee7d816551cb5ad5aa Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 1 Jul 2018 15:07:25 +0100 Subject: [PATCH] Add helpful message for users on first startup --- .../common/command/CommandManager.java | 9 ++++- .../common/locale/command/CommandSpec.java | 39 ++++++++++++------- .../common/locale/message/Message.java | 9 +++++ .../common/plugin/LuckPermsPlugin.java | 8 ++-- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java index 9857be5c..1d47072d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java @@ -60,6 +60,7 @@ import me.lucko.luckperms.common.commands.track.TrackMainCommand; import me.lucko.luckperms.common.commands.user.UserMainCommand; import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.TextUtils; @@ -69,6 +70,7 @@ import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.ListIterator; @@ -172,7 +174,12 @@ public class CommandManager { if (this.mainCommands.stream().anyMatch(c -> c.shouldDisplay() && c.isAuthorized(sender))) { Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label); } else { - Message.NO_PERMISSION_FOR_SUBCOMMANDS.send(sender); + Collection groups = plugin.getGroupManager().getAll().values(); + if (groups.size() <= 1 && groups.stream().allMatch(g -> g.getOwnNodes().isEmpty())) { + Message.FIRST_TIME_SETUP.send(sender, label, sender.getName()); + } else { + Message.NO_PERMISSION_FOR_SUBCOMMANDS.send(sender); + } } return CommandResult.INVALID_ARGS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java b/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java index d5f9983d..c2b36852 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java @@ -38,50 +38,61 @@ import java.util.List; @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"), + USER("A set of commands for managing users within LuckPerms. " + + "(A 'user' in LuckPerms is just a player, and can refer to a UUID or username)", + "/%s user " + ), + GROUP("A set of commands for managing groups within LuckPerms. " + + "Groups are just collections of permission assignments that can be given to users. " + + "New groups are made using the 'creategroup' command.", + "/%s group " + ), + TRACK("A set of commands for managing tracks within LuckPerms. " + + "Tracks are a ordered collection of groups which can be used for defining " + + "promotions and demotions.", + "/%s track " + ), + LOG("A set of commands for managing the logging functionality within LuckPerms.", "/%s log"), - SYNC("Sync changes with the storage", "/%s sync"), - INFO("Print general plugin info", "/%s info"), - EDITOR("Creates a new editor session", "/%s editor [type]", + SYNC("Reloads all data from the plugins storage into memory, and applies any changes that are detected.", "/%s sync"), + INFO("Prints general information about the active plugin instance.", "/%s info"), + EDITOR("Creates a new web editor session", "/%s editor [type]", Argument.list( Argument.create("type", false, "the types to load into the editor. ('all', 'users' or 'groups')") ) ), - DEBUG("Produce debugging output", "/%s debug"), - VERBOSE("Manage verbose permission checking", "/%s verbose [filter]", + DEBUG("Produces a set of internal debugging output", "/%s debug"), + VERBOSE("Controls the plugins verbose permission check monitoring system.", "/%s verbose [filter]", Argument.list( Argument.create("on|record|off|upload", true, "whether to enable/disable logging, or to upload the logged output"), Argument.create("filter", false, "the filter to match entries against") ) ), - TREE("Generate a tree view of permissions", "/%s tree [scope] [player]", + TREE("Generates a tree view (ordered list hierarchy) of all permissions known to LuckPerms.", "/%s tree [scope] [player]", Argument.list( Argument.create("scope", false, "the root of the tree. specify \".\" to include all permissions"), Argument.create("player", false, "the name of an online player to check against") ) ), - SEARCH("Search for users/groups with a specific permission", "/%s search ", + SEARCH("Searchs for all of the users/groups with a specific permission", "/%s search ", Argument.list( Argument.create("permission", true, "the permission to search for"), Argument.create("page", false, "the page to view") ) ), - CHECK("Perform a standard permission check on an online player", "/%s check ", + CHECK("Performs a 'mock' permission check for an online player", "/%s check ", Argument.list( Argument.create("user", true, "the user to check"), Argument.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 ", + IMPORT("Imports data from a (previously created) export file", "/%s import ", Argument.list( Argument.create("file", true, "the file to import from") ) ), - EXPORT("Export data to a file", "/%s export ", + EXPORT("Exports all permissions data to an 'export' file. Be be re-imported at a later time.", "/%s export ", Argument.list( Argument.create("file", true, "the file to export to") ) diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java index 4a98d74e..17b7e307 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java @@ -50,6 +50,15 @@ public enum Message { VIEW_AVAILABLE_COMMANDS_PROMPT("&3Use &a/{} help &3to view available commands.", true), NO_PERMISSION_FOR_SUBCOMMANDS("&3You do not have permission to use any sub commands.", true), + FIRST_TIME_SETUP( + "{PREFIX}&3It seems that no permissions have been setup yet!" + "\n" + + "{PREFIX}&3Before you can use any of the LuckPerms commands in-game, you need to use the console to give yourself access." + "\n" + + "{PREFIX}&3Open your console and run:" + "\n" + + "{PREFIX} &3&l> &a{} user {} permission set luckperms.* true" + "\n\n" + + "{PREFIX}&3After you've done this, you can begin to define your permission assignments and groups." + "\n" + + "{PREFIX}&3Don't know where to start? Check here: &7https://github.com/lucko/LuckPerms/wiki/Usage", + false + ), EMPTY("{}", true), PLAYER_ONLINE("&aOnline", false), 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 4cb4c115..a35c9ce6 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 @@ -42,6 +42,8 @@ import me.lucko.luckperms.common.managers.group.GroupManager; import me.lucko.luckperms.common.managers.track.TrackManager; import me.lucko.luckperms.common.managers.user.UserManager; import me.lucko.luckperms.common.messaging.InternalMessagingService; +import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap; import me.lucko.luckperms.common.plugin.logging.PluginLogger; @@ -77,21 +79,21 @@ public interface LuckPermsPlugin { * * @return the user manager */ - UserManager getUserManager(); + UserManager getUserManager(); /** * Gets the group manager instance for the platform * * @return the group manager */ - GroupManager getGroupManager(); + GroupManager getGroupManager(); /** * Gets the track manager instance for the platform * * @return the track manager */ - TrackManager getTrackManager(); + TrackManager getTrackManager(); /** * Gets the plugin's configuration