Add helpful message for users on first startup

This commit is contained in:
Luck 2018-07-01 15:07:25 +01:00
parent c780266139
commit c1e0b874d8
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 47 additions and 18 deletions

View File

@ -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.commands.user.UserMainCommand;
import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.LocaleManager;
import me.lucko.luckperms.common.locale.message.Message; 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.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.sender.Sender;
import me.lucko.luckperms.common.utils.TextUtils; import me.lucko.luckperms.common.utils.TextUtils;
@ -69,6 +70,7 @@ import net.kyori.text.event.ClickEvent;
import net.kyori.text.event.HoverEvent; import net.kyori.text.event.HoverEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
@ -171,9 +173,14 @@ public class CommandManager {
MessageUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2."); MessageUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2.");
if (this.mainCommands.stream().anyMatch(c -> c.shouldDisplay() && c.isAuthorized(sender))) { if (this.mainCommands.stream().anyMatch(c -> c.shouldDisplay() && c.isAuthorized(sender))) {
Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label); Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label);
} else {
Collection<? extends Group> 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 { } else {
Message.NO_PERMISSION_FOR_SUBCOMMANDS.send(sender); Message.NO_PERMISSION_FOR_SUBCOMMANDS.send(sender);
} }
}
return CommandResult.INVALID_ARGS; return CommandResult.INVALID_ARGS;
} }

View File

@ -38,50 +38,61 @@ import java.util.List;
@SuppressWarnings("SpellCheckingInspection") @SuppressWarnings("SpellCheckingInspection")
public enum CommandSpec { public enum CommandSpec {
USER("User commands", "/%s user <user>"), USER("A set of commands for managing users within LuckPerms. " +
GROUP("Group commands", "/%s group <group>"), "(A 'user' in LuckPerms is just a player, and can refer to a UUID or username)",
TRACK("Track commands", "/%s track <track>"), "/%s user <user>"
LOG("Log commands", "/%s log"), ),
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 <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 <track>"
),
LOG("A set of commands for managing the logging functionality within LuckPerms.", "/%s log"),
SYNC("Sync changes with the storage", "/%s sync"), SYNC("Reloads all data from the plugins storage into memory, and applies any changes that are detected.", "/%s sync"),
INFO("Print general plugin info", "/%s info"), INFO("Prints general information about the active plugin instance.", "/%s info"),
EDITOR("Creates a new editor session", "/%s editor [type]", EDITOR("Creates a new web editor session", "/%s editor [type]",
Argument.list( Argument.list(
Argument.create("type", false, "the types to load into the editor. ('all', 'users' or 'groups')") Argument.create("type", false, "the types to load into the editor. ('all', 'users' or 'groups')")
) )
), ),
DEBUG("Produce debugging output", "/%s debug"), DEBUG("Produces a set of internal debugging output", "/%s debug"),
VERBOSE("Manage verbose permission checking", "/%s verbose <on|record|off|upload> [filter]", VERBOSE("Controls the plugins verbose permission check monitoring system.", "/%s verbose <on|record|off|upload> [filter]",
Argument.list( Argument.list(
Argument.create("on|record|off|upload", true, "whether to enable/disable logging, or to upload the logged output"), 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") 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.list(
Argument.create("scope", false, "the root of the tree. specify \".\" to include all permissions"), 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") Argument.create("player", false, "the name of an online player to check against")
) )
), ),
SEARCH("Search for users/groups with a specific permission", "/%s search <permission>", SEARCH("Searchs for all of the users/groups with a specific permission", "/%s search <permission>",
Argument.list( Argument.list(
Argument.create("permission", true, "the permission to search for"), Argument.create("permission", true, "the permission to search for"),
Argument.create("page", false, "the page to view") Argument.create("page", false, "the page to view")
) )
), ),
CHECK("Perform a standard permission check on an online player", "/%s check <user> <permission>", CHECK("Performs a 'mock' permission check for an online player", "/%s check <user> <permission>",
Argument.list( Argument.list(
Argument.create("user", true, "the user to check"), Argument.create("user", true, "the user to check"),
Argument.create("permission", true, "the permission to check for") 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"), 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 <file>", IMPORT("Imports data from a (previously created) export file", "/%s import <file>",
Argument.list( Argument.list(
Argument.create("file", true, "the file to import from") Argument.create("file", true, "the file to import from")
) )
), ),
EXPORT("Export data to a file", "/%s export <file>", EXPORT("Exports all permissions data to an 'export' file. Be be re-imported at a later time.", "/%s export <file>",
Argument.list( Argument.list(
Argument.create("file", true, "the file to export to") Argument.create("file", true, "the file to export to")
) )

View File

@ -50,6 +50,15 @@ public enum Message {
VIEW_AVAILABLE_COMMANDS_PROMPT("&3Use &a/{} help &3to view available commands.", true), 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), 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), EMPTY("{}", true),
PLAYER_ONLINE("&aOnline", false), PLAYER_ONLINE("&aOnline", false),

View File

@ -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.track.TrackManager;
import me.lucko.luckperms.common.managers.user.UserManager; import me.lucko.luckperms.common.managers.user.UserManager;
import me.lucko.luckperms.common.messaging.InternalMessagingService; 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.model.User;
import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap; import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
import me.lucko.luckperms.common.plugin.logging.PluginLogger; import me.lucko.luckperms.common.plugin.logging.PluginLogger;
@ -77,21 +79,21 @@ public interface LuckPermsPlugin {
* *
* @return the user manager * @return the user manager
*/ */
UserManager<?> getUserManager(); UserManager<? extends User> getUserManager();
/** /**
* Gets the group manager instance for the platform * Gets the group manager instance for the platform
* *
* @return the group manager * @return the group manager
*/ */
GroupManager<?> getGroupManager(); GroupManager<? extends Group> getGroupManager();
/** /**
* Gets the track manager instance for the platform * Gets the track manager instance for the platform
* *
* @return the track manager * @return the track manager
*/ */
TrackManager<?> getTrackManager(); TrackManager<? extends Track> getTrackManager();
/** /**
* Gets the plugin's configuration * Gets the plugin's configuration