Attempt to detect and warn about CraftBukkit + offline mode problems (#1439)

This commit is contained in:
Luck
2019-02-21 14:14:00 +00:00
Unverified
parent ae63a42c2e
commit 46072eb465
2 changed files with 29 additions and 0 deletions
@@ -50,12 +50,32 @@ import java.util.concurrent.TimeUnit;
public class BukkitConnectionListener extends AbstractConnectionListener implements Listener {
private final LPBukkitPlugin plugin;
private final boolean detectedCraftBukkitOfflineMode;
private final Set<UUID> deniedAsyncLogin = Collections.synchronizedSet(new HashSet<>());
private final Set<UUID> deniedLogin = Collections.synchronizedSet(new HashSet<>());
public BukkitConnectionListener(LPBukkitPlugin plugin) {
super(plugin);
this.plugin = plugin;
// check for craftbukkit + offline mode combination
String version = plugin.getBootstrap().getServer().getVersion();
boolean onlineMode = plugin.getBootstrap().getServer().getOnlineMode();
if (!onlineMode && version.startsWith("git-Bukkit-")) {
printCraftBukkitOfflineModeError();
this.detectedCraftBukkitOfflineMode = true;
} else {
this.detectedCraftBukkitOfflineMode = false;
}
}
private void printCraftBukkitOfflineModeError() {
this.plugin.getLogger().warn("It appears that your server is running CraftBukkit and configured in offline (cracked) mode.");
this.plugin.getLogger().warn("Due to a CraftBukkit limitation, LuckPerms cannot function correctly in this setup.");
this.plugin.getLogger().warn("To resolve this, please either a) upgrade from CraftBukkit to Spigot or Paper, or b) enable online-mode.");
this.plugin.getLogger().warn("For more info, please see: https://github.com/lucko/LuckPerms/wiki/Installation#craftbukkit-and-offline-mode");
}
@EventHandler(priority = EventPriority.LOW)
@@ -134,9 +154,17 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
this.deniedLogin.add(player.getUniqueId());
if (!getUniqueConnections().contains(player.getUniqueId())) {
this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() +
" doesn't have data pre-loaded, they have never been processed during pre-login in this session." +
" - denying login.");
if (this.detectedCraftBukkitOfflineMode) {
printCraftBukkitOfflineModeError();
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, Message.LOADING_STATE_ERROR_CB_OFFLINE_MODE.asString(this.plugin.getLocaleManager()));
return;
}
} else {
this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() +
" doesn't currently have data pre-loaded, but they have been processed before in this session." +