diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitBootstrap.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitBootstrap.java index 74d2af06..5ad588c7 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitBootstrap.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitBootstrap.java @@ -85,6 +85,7 @@ public class LPBukkitBootstrap extends JavaPlugin implements LuckPermsBootstrap // load/enable latches private final CountDownLatch loadLatch = new CountDownLatch(1); private final CountDownLatch enableLatch = new CountDownLatch(1); + private boolean serverStarting = true; // if the plugin has been loaded on an incompatible version private boolean incompatibleVersion = false; @@ -150,6 +151,9 @@ public class LPBukkitBootstrap extends JavaPlugin implements LuckPermsBootstrap this.startTime = System.currentTimeMillis(); try { this.plugin.enable(); + + // schedule a task to update the 'serverStarting' flag + getServer().getScheduler().runTask(this, () -> this.serverStarting = false); } finally { this.enableLatch.countDown(); } @@ -162,6 +166,7 @@ public class LPBukkitBootstrap extends JavaPlugin implements LuckPermsBootstrap } this.plugin.disable(); + this.serverStarting = true; } @Override @@ -174,6 +179,10 @@ public class LPBukkitBootstrap extends JavaPlugin implements LuckPermsBootstrap return this.loadLatch; } + public boolean isServerStarting() { + return this.serverStarting; + } + // provide information about the plugin @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java index 2de88993..ef549ee6 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java @@ -95,15 +95,15 @@ public class VaultPermissionHook extends AbstractVaultPermission { } // are we on the main thread? - if (Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) { + if (!plugin.getBootstrap().isServerStarting() && Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) { throw new RuntimeException( - "Unable to lookup a UUID for '" + player + "'. \n" + - "This request was made on the main server thread. \n" + - "It is not safe to execute a request to load username data from the database in this context. \n" + + "The operation to lookup a UUID for '" + player + "' was cancelled by LuckPerms. This is NOT a bug. \n" + + "The lookup request was made on the main server thread. It is not safe to execute a request to \n" + + "load username data from the database in this context. \n" + "If you are a plugin author, please either make your request asynchronously, \n" + "or provide an 'OfflinePlayer' object with the UUID already populated. \n" + - "Server admins can disable this catch by setting 'vault-unsafe-lookups' to true in the LP config, \n" + - "but should consider the consequences (lag) before doing so." + "Alternatively, server admins can disable this catch by setting 'vault-unsafe-lookups' to true \n" + + "in the LP config, but should consider the consequences (lag) before doing so." ); } @@ -131,14 +131,14 @@ public class VaultPermissionHook extends AbstractVaultPermission { } // are we on the main thread? - if (Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) { + if (!plugin.getBootstrap().isServerStarting() && Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) { throw new RuntimeException( - "Unable to obtain user data for '" + uuid + "'. \n" + - "This request was made on the main server thread. \n" + - "It is not safe to execute a request to load user data from the database in this context. \n" + + "The operation to load user data for '" + uuid + "' was cancelled by LuckPerms. This is NOT a bug. \n" + + "The lookup request was made on the main server thread. It is not safe to execute a request to \n" + + "load username data from the database in this context. \n" + "If you are a plugin author, please consider making your request asynchronously. \n" + - "Server admins can disable this catch by setting 'vault-unsafe-lookups' to true in the LP config, \n" + - "but should consider the consequences (lag) before doing so." + "Alternatively, server admins can disable this catch by setting 'vault-unsafe-lookups' to true \n" + + "in the LP config, but should consider the consequences (lag) before doing so." ); }