Misc cleanup

This commit is contained in:
Luck
2018-07-29 17:12:05 -07:00
Unverified
parent 952e41ad3d
commit b1ab465991
15 changed files with 91 additions and 49 deletions
@@ -133,8 +133,8 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
@Override
protected void registerCommands() {
this.commandManager = new NukkitCommandExecutor(this);
PluginCommand main = (PluginCommand) this.bootstrap.getServer().getPluginCommand("luckperms");
main.setExecutor(this.commandManager);
PluginCommand cmd = (PluginCommand) this.bootstrap.getServer().getPluginCommand("luckperms");
cmd.setExecutor(this.commandManager);
}
@Override
@@ -66,8 +66,6 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme
this.plugin.getLogger().info("Processing pre-login for " + e.getUuid() + " - " + e.getName());
}
recordConnection(e.getUuid());
/* Actually process the login for the connection.
We do this here to delay the login until the data is ready.
If the login gets cancelled later on, then this will be cleaned up.
@@ -80,13 +78,14 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme
try {
User user = loadUser(e.getUuid(), e.getName());
this.plugin.getEventFactory().handleUserLoginProcess(e.getUuid(), e.getName(), user);
recordConnection(e.getUuid());
} catch (Exception ex) {
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUuid() + " - " + e.getName());
ex.printStackTrace();
// deny the connection
this.deniedAsyncLogin.add(e.getUuid());
e.disAllow(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager()));
e.disAllow(Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager()));
}
}
@@ -122,11 +121,20 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme
/* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */
if (user == null) {
this.deniedLogin.add(e.getPlayer().getUniqueId());
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 need processed during pre-login in this session." +
" - denying login.");
} 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." +
" - denying login.");
}
this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login.");
e.setCancelled();
e.setKickMessage(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager()));
e.setKickMessage(Message.LOADING_STATE_ERROR.asString(this.plugin.getLocaleManager()));
return;
}
@@ -140,7 +148,13 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme
PermissibleInjector.inject(player, lpPermissible);
} catch (Throwable t) {
this.plugin.getLogger().warn("Exception thrown when setting up permissions for " +
player.getUniqueId() + " - " + player.getName() + " - denying login.");
t.printStackTrace();
e.setCancelled();
e.setKickMessage(Message.LOADING_SETUP_ERROR.asString(this.plugin.getLocaleManager()));
return;
}
this.plugin.refreshAutoOp(player);