javascript/features/playground/playground_commands.js
// Grants an exception for a not yet determined player to use the |commandName|.
Grants an exception for a not yet determined player to use the |commandName|.
Grants an exception for a not yet determined player to use the |commandName| .
async grantCommandException(commandName, player) {
        const answer = await Question.ask(player, {
            question: 'Select a player',
            message: 'Which player should be allowed to use /' + commandName + '?',
            leftButton: 'Grant'
        });
        if (!answer)
            return;  
        const subject = server.playerManager.find({ nameOrId: answer, returnPlayer: true });
        if (!subject) {
            const retry = await MessageBox.display(player, {
                title: 'Unable to identify the target player',
                message: 'Either no or too many players were found for "' + answer + '".',
                leftButton: 'Cancel',
                rightButton: 'Retry'
            });
            if (!retry)
                return;
            return await grantCommandException(commandName, player);
        }
        if (!subject.account.isRegistered()) {
            return await MessageBox.display(player, {
                title: 'Unable to grant an exception',
                message: 'Exceptions can only be granted to registered players. Consider asking ' +
                         subject.name + ' to register?'
            });
        }
        if (subject === player) {
            return await MessageBox.display(player, {
                title: 'Unable to grant an exception',
                message: 'There is no point in granting exceptions to yourself, sorry.'
            });
        }
        this.access_.addException(commandName, subject, player );
        if (this.access_.getCommandLevel(commandName) != Player.LEVEL_MANAGEMENT) {
            this.announce_().announceToAdministrators(
                Message.LVP_ANNOUNCE_CMD_EXCEPTION, player.name, player.id, subject.name,
                commandName);
        }
        return await MessageBox.display(player, {
            title: 'The exception has been granted!',
            message: '/' + commandName + ' is now available to ' + subject.name + '.'
        });
    }
async grantCommandException ( commandName , player ) { const answer = await Question . ask ( player , { question : 'Select a player' , message : 'Which player should be allowed to use /' + commandName + '?' , leftButton : 'Grant' } ) ; if ( ! answer ) return ; const subject = server . playerManager . find ( { nameOrId : answer , returnPlayer : true } ) ; if ( ! subject ) { const retry = await MessageBox . display ( player , { title : 'Unable to identify the target player' , message : 'Either no or too many players were found for "' + answer + '".' , leftButton : 'Cancel' , rightButton : 'Retry' } ) ; if ( ! retry ) return ; return await grantCommandException ( commandName , player ) ; } if ( ! subject . account . isRegistered ( ) ) { return await MessageBox . display ( player , { title : 'Unable to grant an exception' , message : 'Exceptions can only be granted to registered players. Consider asking ' + subject . name + ' to register?' } ) ; } if ( subject === player ) { return await MessageBox . display ( player , { title : 'Unable to grant an exception' , message : 'There is no point in granting exceptions to yourself, sorry.' } ) ; } this . access_ . addException ( commandName , subject , player ) ; if ( this . access_ . getCommandLevel ( commandName ) != Player . LEVEL_MANAGEMENT ) { this . announce_ ( ) . announceToAdministrators ( Message . LVP_ANNOUNCE_CMD_EXCEPTION , player . name , player . id , subject . name , commandName ) ; } return await MessageBox . display ( player , { title : 'The exception has been granted!' , message : '/' + commandName + ' is now available to ' + subject . name + '.' } ) ; }
Grants an exception for a not yet determined player to use the |commandName|.
Grants an exception for a not yet determined player to use the |commandName| .
// the |player| cancelled the dialog. /* sourcePlayer */