/** * Sets up permissions for the console. */ public void setupPermissions() { 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); }
private void initializePlayer(GameProfile profile, boolean onlineMode) { // Some connection types may need to alter the game profile. profile = mcConnection.getType().addGameProfileTokensIfRequired(profile, server.getConfiguration().getPlayerInfoForwardingMode()); GameProfileRequestEvent profileRequestEvent = new GameProfileRequestEvent(inbound, profile, onlineMode); server.getEventManager().fire(profileRequestEvent).thenCompose(profileEvent -> { // Initiate a regular connection and move over to it. ConnectedPlayer player = new ConnectedPlayer(server, profileEvent.getGameProfile(), mcConnection, inbound.getVirtualHost().orElse(null)); this.connectedPlayer = player; if (!server.canRegisterConnection(player)) { player.disconnect(VelocityMessages.ALREADY_CONNECTED); return CompletableFuture.completedFuture(null); } logger.info("{} has connected", player); return server.getEventManager() .fire(new PermissionsSetupEvent(player, ConnectedPlayer.DEFAULT_PERMISSIONS)) .thenAcceptAsync(event -> { if (!mcConnection.isClosed()) { // wait for permissions to load, then set the players permission function player.setPermissionFunction(event.createFunction(player)); finishLogin(player); } }, mcConnection.eventLoop()); }); }