javascript/features/playground/playground_commands.js
// level that's equal or below their own level, to avoid "losing" a command.
level that's equal or below their own level, to avoid "losing" a command.
level that ' s equal or below their own level to avoid " losing " a command .
async displayCommandLevelMenu(commandName, player) {
        const currentLevel = this.access_.getCommandLevel(commandName);
        const defaultLevel = this.access_.getDefaultCommandLevel(commandName);
        const menu = new Menu('/' + commandName + ' required level');
        [
            Player.LEVEL_PLAYER,
            Player.LEVEL_ADMINISTRATOR,
            Player.LEVEL_MANAGEMENT
        ].forEach(level => {
            if (level > player.level)
                return;
            const levelPrefix = currentLevel === level ? '{ADFF2F}' : '';
            const levelSuffix = defaultLevel === level ? ' (default)' : '';
            const levelName = playerLevelToString(level, true );
            menu.addItem(levelPrefix + capitalizeFirstLetter(levelName) + levelSuffix, async() => {
                if (currentLevel === level) {
                    return await MessageBox.display(player, {
                        title: 'No need to update the level',
                        message: 'This command is already available to ' + levelName + '.'
                    });
                }
                this.access_.setCommandLevel(commandName, level);
                this.announce_().announceToAdministrators(
                    Message.LVP_ANNOUNCE_CMD_LEVEL, player.name, player.id, commandName, levelName)
                if (level == Player.LEVEL_PLAYER) {
                    this.announce_().announceToPlayers(
                        Message.LVP_ANNOUNCE_CMD_AVAILABLE, player.name, commandName);
                } else if (currentLevel == Player.LEVEL_PLAYER) {
                    this.announce_().announceToPlayers(
                        Message.LVP_ANNOUNCE_CMD_REVOKED, player.name, commandName);
                }
                return await MessageBox.display(player, {
                    title: 'The level has been updated!',
                    message: '/' + commandName + ' is now available to ' + levelName + '.'
                });
            });
        });
        await menu.displayForPlayer(player);
    }
async displayCommandLevelMenu ( commandName , player ) { const currentLevel = this . access_ . getCommandLevel ( commandName ) ; const defaultLevel = this . access_ . getDefaultCommandLevel ( commandName ) ; const menu = new Menu ( '/' + commandName + ' required level' ) ; [ Player . LEVEL_PLAYER , Player . LEVEL_ADMINISTRATOR , Player . LEVEL_MANAGEMENT ] . forEach ( level => { if ( level > player . level ) return ; const levelPrefix = currentLevel === level ? '{ADFF2F}' : '' ; const levelSuffix = defaultLevel === level ? ' (default)' : '' ; const levelName = playerLevelToString ( level , true ) ; menu . addItem ( levelPrefix + capitalizeFirstLetter ( levelName ) + levelSuffix , async ( ) => { if ( currentLevel === level ) { return await MessageBox . display ( player , { title : 'No need to update the level' , message : 'This command is already available to ' + levelName + '.' } ) ; } this . access_ . setCommandLevel ( commandName , level ) ; this . announce_ ( ) . announceToAdministrators ( Message . LVP_ANNOUNCE_CMD_LEVEL , player . name , player . id , commandName , levelName ) if ( level == Player . LEVEL_PLAYER ) { this . announce_ ( ) . announceToPlayers ( Message . LVP_ANNOUNCE_CMD_AVAILABLE , player . name , commandName ) ; } else if ( currentLevel == Player . LEVEL_PLAYER ) { this . announce_ ( ) . announceToPlayers ( Message . LVP_ANNOUNCE_CMD_REVOKED , player . name , commandName ) ; } return await MessageBox . display ( player , { title : 'The level has been updated!' , message : '/' + commandName + ' is now available to ' + levelName + '.' } ) ; } ) ; } ) ; await menu . displayForPlayer ( player ) ; }
level that's equal or below their own level, to avoid "losing" a command.
level that ' s equal or below their own level to avoid " losing " a command .
/* plural */ // Make an announcement to players if the command was either granted to them, or // taken away from them. We like to cause anarchy by upset mobs.