mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-09-28 23:09:26 +02:00
Don't attempt to load permissions data for login events cancelled at the lowest priority
Makes LuckPerms more compatible with "anti-bot" plugins.
This commit is contained in:
@@ -81,7 +81,8 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
|||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent e) {
|
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent e) {
|
||||||
/* Called when the player first attempts a connection with the server.
|
/* Called when the player first attempts a connection with the server.
|
||||||
Listening on LOW priority to allow plugins to modify username / UUID data here. (auth plugins) */
|
Listening on LOW priority to allow plugins to modify username / UUID data here. (auth plugins)
|
||||||
|
Also, give other plugins a chance to cancel the event. */
|
||||||
|
|
||||||
/* wait for the plugin to enable. because these events are fired async, they can be called before
|
/* wait for the plugin to enable. because these events are fired async, they can be called before
|
||||||
the plugin has enabled. */
|
the plugin has enabled. */
|
||||||
@@ -95,6 +96,13 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
|||||||
this.plugin.getLogger().info("Processing pre-login for " + e.getUniqueId() + " - " + e.getName());
|
this.plugin.getLogger().info("Processing pre-login for " + e.getUniqueId() + " - " + e.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
||||||
|
// another plugin has disallowed the login.
|
||||||
|
this.plugin.getLogger().info("Another plugin has cancelled the connection for " + e.getUniqueId() + " - " + e.getName() + ". No permissions data will be loaded.");
|
||||||
|
this.deniedAsyncLogin.add(e.getUniqueId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Actually process the login for the connection.
|
/* Actually process the login for the connection.
|
||||||
We do this here to delay the login until the data is ready.
|
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.
|
If the login gets cancelled later on, then this will be cleaned up.
|
||||||
|
@@ -70,6 +70,12 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme
|
|||||||
this.plugin.getLogger().info("Processing pre-login for " + c.getUniqueId() + " - " + c.getName());
|
this.plugin.getLogger().info("Processing pre-login for " + c.getUniqueId() + " - " + c.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.isCancelled()) {
|
||||||
|
// another plugin has disallowed the login.
|
||||||
|
this.plugin.getLogger().info("Another plugin has cancelled the connection for " + c.getUniqueId() + " - " + c.getName() + ". No permissions data will be loaded.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||||
/* Actually process the login for the connection.
|
/* Actually process the login for the connection.
|
||||||
We do this here to delay the login until the data is ready.
|
We do this here to delay the login until the data is ready.
|
||||||
|
@@ -60,12 +60,20 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme
|
|||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerPreLogin(PlayerAsyncPreLoginEvent e) {
|
public void onPlayerPreLogin(PlayerAsyncPreLoginEvent e) {
|
||||||
/* Called when the player first attempts a connection with the server.
|
/* Called when the player first attempts a connection with the server.
|
||||||
Listening on LOW priority to allow plugins to modify username / UUID data here. (auth plugins) */
|
Listening on LOW priority to allow plugins to modify username / UUID data here. (auth plugins)
|
||||||
|
Also, give other plugins a chance to cancel the event. */
|
||||||
|
|
||||||
if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
|
if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
|
||||||
this.plugin.getLogger().info("Processing pre-login for " + e.getUuid() + " - " + e.getName());
|
this.plugin.getLogger().info("Processing pre-login for " + e.getUuid() + " - " + e.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.getLoginResult() != PlayerAsyncPreLoginEvent.LoginResult.SUCCESS) {
|
||||||
|
// another plugin has disallowed the login.
|
||||||
|
this.plugin.getLogger().info("Another plugin has cancelled the connection for " + e.getUuid() + " - " + e.getName() + ". No permissions data will be loaded.");
|
||||||
|
this.deniedAsyncLogin.add(e.getUuid());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Actually process the login for the connection.
|
/* Actually process the login for the connection.
|
||||||
We do this here to delay the login until the data is ready.
|
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.
|
If the login gets cancelled later on, then this will be cleaned up.
|
||||||
|
@@ -59,7 +59,8 @@ public class SpongeConnectionListener extends AbstractConnectionListener {
|
|||||||
@IsCancelled(Tristate.UNDEFINED)
|
@IsCancelled(Tristate.UNDEFINED)
|
||||||
public void onClientAuth(ClientConnectionEvent.Auth e) {
|
public void onClientAuth(ClientConnectionEvent.Auth e) {
|
||||||
/* Called when the player first attempts a connection with the server.
|
/* Called when the player first attempts a connection with the server.
|
||||||
Listening on AFTER_PRE priority to allow plugins to modify username / UUID data here. (auth plugins) */
|
Listening on AFTER_PRE priority to allow plugins to modify username / UUID data here. (auth plugins)
|
||||||
|
Also, give other plugins a chance to cancel the event. */
|
||||||
|
|
||||||
final GameProfile profile = e.getProfile();
|
final GameProfile profile = e.getProfile();
|
||||||
final String username = profile.getName().orElseThrow(() -> new RuntimeException("No username present for user " + profile.getUniqueId()));
|
final String username = profile.getName().orElseThrow(() -> new RuntimeException("No username present for user " + profile.getUniqueId()));
|
||||||
@@ -68,6 +69,13 @@ public class SpongeConnectionListener extends AbstractConnectionListener {
|
|||||||
this.plugin.getLogger().info("Processing auth event for " + profile.getUniqueId() + " - " + profile.getName());
|
this.plugin.getLogger().info("Processing auth event for " + profile.getUniqueId() + " - " + profile.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.isCancelled()) {
|
||||||
|
// another plugin has disallowed the login.
|
||||||
|
this.plugin.getLogger().info("Another plugin has cancelled the connection for " + profile.getUniqueId() + " - " + username + ". No permissions data will be loaded.");
|
||||||
|
this.deniedAsyncLogin.add(profile.getUniqueId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Actually process the login for the connection.
|
/* Actually process the login for the connection.
|
||||||
We do this here to delay the login until the data is ready.
|
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.
|
If the login gets cancelled later on, then this will be cleaned up.
|
||||||
|
Reference in New Issue
Block a user