javascript/features/playground/playground_commands.js
// part of this module with a dialog-based interface.
part of this module with a dialog-based interface.
part of this module with a dialog - based interface .
async onPlaygroundAccessCommand(player) {
        let commands = [];
        for (const [command, commandLevel] of this.access_.commands) {
            if (player.level < commandLevel)
                continue;
            commands.push(command);
        }
        commands.sort();
        const menu = new Menu('Command access settings', [
            'Command',
            'Level',
            'Exceptions'
        ]);
        commands.forEach(commandName => {
            const commandLevel = this.access_.getCommandLevel(commandName);
            const commandExceptions = this.access_.getExceptionCount(commandName);
            const defaultLevel = this.access_.getDefaultCommandLevel(commandName);
            const levelPrefix = commandLevel !== defaultLevel ? '{FFFF00}' : '';
            const level = playerLevelToString(commandLevel, true );
            const exceptions = commandExceptions != 0
                ? '{FFFF00}' + commandExceptions + ' exception' + (commandExceptions == 1 ? '': 's')
                : '-';
            menu.addItem('/' + commandName, levelPrefix + capitalizeFirstLetter(level), exceptions,
                         PlaygroundCommands.prototype.displayCommandMenu.bind(this, commandName));
        });
        await menu.displayForPlayer(player);
    }
async onPlaygroundAccessCommand ( player ) { let commands = [ ] ; for ( const [ command , commandLevel ] of this . access_ . commands ) { if ( player . level < commandLevel ) continue ; commands . push ( command ) ; } commands . sort ( ) ; const menu = new Menu ( 'Command access settings' , [ 'Command' , 'Level' , 'Exceptions' ] ) ; commands . forEach ( commandName => { const commandLevel = this . access_ . getCommandLevel ( commandName ) ; const commandExceptions = this . access_ . getExceptionCount ( commandName ) ; const defaultLevel = this . access_ . getDefaultCommandLevel ( commandName ) ; const levelPrefix = commandLevel !== defaultLevel ? '{FFFF00}' : '' ; const level = playerLevelToString ( commandLevel , true ) ; const exceptions = commandExceptions != 0 ? '{FFFF00}' + commandExceptions + ' exception' + ( commandExceptions == 1 ? '' : 's' ) : '-' ; menu . addItem ( '/' + commandName , levelPrefix + capitalizeFirstLetter ( level ) , exceptions , PlaygroundCommands . prototype . displayCommandMenu . bind ( this , commandName ) ) ; } ) ; await menu . displayForPlayer ( player ) ; }
part of this module with a dialog-based interface.
part of this module with a dialog - based interface .
// Sort the |commands| in alphabetical order, since there is no guarantee that the Access // Tracker maintains the commands in such order. /* plural */