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 0e0f08f9d..c718d6431 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java @@ -77,8 +77,14 @@ public class BungeeListener implements Listener { the proxy will just fallback to using the config file perms. */ if (!plugin.getStorage().isAcceptingLogins()) { - // log that the user tried to login, but was denied at this stage. - plugin.getLog().warn("Permissions storage is not loaded. No permissions data will be loaded for: " + c.getUniqueId() + " - " + c.getName()); + if (plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) { + // cancel the login attempt + e.setCancelReason(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(plugin.getLocaleManager()))); + e.setCancelled(true); + } else { + // log that the user tried to login, but was denied at this stage. + plugin.getLog().warn("Permissions storage is not loaded. No permissions data will be loaded for: " + c.getUniqueId() + " - " + c.getName()); + } e.completeIntent(plugin); return; @@ -104,7 +110,14 @@ public class BungeeListener implements Listener { ex.printStackTrace(); // there was some error loading - plugin.getLog().warn("Error loading data. No permissions data will be loaded for: " + c.getUniqueId() + " - " + c.getName()); + if (plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) { + // cancel the login attempt + e.setCancelReason(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(plugin.getLocaleManager()))); + e.setCancelled(true); + } else { + plugin.getLog().warn("Error loading data. No permissions data will be loaded for: " + c.getUniqueId() + " - " + c.getName()); + } + } // finally, complete our intent to modify state, so the proxy can continue handling the connection. @@ -126,13 +139,20 @@ public class BungeeListener implements Listener { } if (user == null) { - plugin.getProxy().getScheduler().schedule(plugin, () -> { - if (!player.isConnected()) { - return; - } + if (plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) { + // disconnect the user + plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded - cancelling login."); + e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(plugin.getLocaleManager()))); + } else { + // just send a message + plugin.getProxy().getScheduler().schedule(plugin, () -> { + if (!player.isConnected()) { + return; + } - player.sendMessage(new TextComponent(Message.LOADING_ERROR.asString(plugin.getLocaleManager()))); - }, 3, TimeUnit.SECONDS); + player.sendMessage(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(plugin.getLocaleManager()))); + }, 1, TimeUnit.SECONDS); + } } } diff --git a/bungee/src/main/resources/config.yml b/bungee/src/main/resources/config.yml index 07e4d2357..ecd3b2515 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -83,6 +83,18 @@ allow-invalid-usernames: false # Useful if you're having issues with UUID forwarding or data not being loaded. debug-logins: false +# If LuckPerms should ensure all players have permission data when they connect to the server. +# +# When set to true, LuckPerms will cancel login attempts if it is unable to load permissions data +# for a user, of if the storage provider is unavailable. +# +# When set to false, LuckPerms will allow a player to connect regardless of whether their +# permissions data could be loaded. +# +# This option does not exist on other platforms, and effectively defaults to true - however, +# the option is provided on BungeeCord, as it is less likely to be so dependant on permissions. +cancel-failed-logins: false + # If the plugin should send log notifications to users whenever permissions are modified. log-notify: true diff --git a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java index 6152fa839..96fc1238c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java +++ b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java @@ -132,6 +132,11 @@ public class ConfigKeys { */ public static final ConfigKey DEBUG_LOGINS = BooleanKey.of("debug-logins", false); + /** + * If LP should cancel login attempts for players whose permission data could not be loaded. + */ + public static final ConfigKey CANCEL_FAILED_LOGINS = BooleanKey.of("cancel-failed-logins", false); + /** * Controls how temporary add commands should behave */