3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

Warn about null permission functions.

Dieser Commit ist enthalten in:
Andrew Steinborn 2021-03-23 07:31:57 -04:00
Ursprung 0016f4ce19
Commit 3111816545
2 geänderte Dateien mit 18 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -17,6 +17,7 @@ import com.velocitypowered.api.event.connection.PreLoginEvent.PreLoginComponentR
import com.velocitypowered.api.event.permission.PermissionsSetupEvent; import com.velocitypowered.api.event.permission.PermissionsSetupEvent;
import com.velocitypowered.api.event.player.GameProfileRequestEvent; import com.velocitypowered.api.event.player.GameProfileRequestEvent;
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent; import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.api.util.UuidUtils; import com.velocitypowered.api.util.UuidUtils;
@ -231,7 +232,16 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
.thenAcceptAsync(event -> { .thenAcceptAsync(event -> {
if (!mcConnection.isClosed()) { if (!mcConnection.isClosed()) {
// wait for permissions to load, then set the players permission function // 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); completeLoginProtocolPhaseAndInitialize(player);
} }
}, mcConnection.eventLoop()); }, mcConnection.eventLoop());

Datei anzeigen

@ -65,6 +65,13 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
PermissionsSetupEvent event = new PermissionsSetupEvent(this, s -> ALWAYS_TRUE); PermissionsSetupEvent event = new PermissionsSetupEvent(this, s -> ALWAYS_TRUE);
// we can safely block here, this is before any listeners fire // we can safely block here, this is before any listeners fire
this.permissionFunction = this.server.getEventManager().fire(event).join().createFunction(this); 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 @Override