diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java index f342cc15e..7ce22c38a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginSessionHandler.java @@ -17,6 +17,7 @@ import com.velocitypowered.api.event.connection.PreLoginEvent.PreLoginComponentR import com.velocitypowered.api.event.permission.PermissionsSetupEvent; import com.velocitypowered.api.event.player.GameProfileRequestEvent; import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent; +import com.velocitypowered.api.permission.PermissionFunction; import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.api.util.UuidUtils; @@ -231,7 +232,16 @@ public class LoginSessionHandler implements MinecraftSessionHandler { .thenAcceptAsync(event -> { if (!mcConnection.isClosed()) { // wait for permissions to load, then set the players permission function - player.setPermissionFunction(event.createFunction(player)); + final PermissionFunction function = event.createFunction(player); + if (function == null) { + logger.error( + "A plugin permission provider {} provided an invalid permission function" + + " for player {}. This is a bug in the plugin, not in Velocity. Falling" + + " back to the default permission function.", player.getUsername(), + event.getProvider()); + } else { + player.setPermissionFunction(function); + } completeLoginProtocolPhaseAndInitialize(player); } }, mcConnection.eventLoop()); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java index 4273549ed..2bff9cf72 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java @@ -65,6 +65,13 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons PermissionsSetupEvent event = new PermissionsSetupEvent(this, s -> ALWAYS_TRUE); // we can safely block here, this is before any listeners fire this.permissionFunction = this.server.getEventManager().fire(event).join().createFunction(this); + if (this.permissionFunction == null) { + logger.error( + "A plugin permission provider {} provided an invalid permission function" + + " for the console. This is a bug in the plugin, not in Velocity. Falling" + + " back to the default permission function.", event.getProvider()); + this.permissionFunction = ALWAYS_TRUE; + } } @Override