javascript/features/playground/playground_commands.js
// on the legel of the |player| calling this command.
on the legel of the |player| calling this command.
on the legel of the |player| calling this command .
async onPlaygroundSettingsCommand(player) {
        const categories = new Map(); 
        const menu = new Menu('Choose a category of settings', ['Category', 'Settings']);
        const communication = this.communication_();
        categories.set('Blocked words', {
            settings: communication.getBlockedWords().length + ' words',
            listener: PlaygroundCommands.prototype.handleBlockedWords.bind(this, player),
        });
        categories.set('Player communication', {
            settings: communication.isCommunicationMuted() ? '{FFFF00}disabled' : 'enabled',
            listener: PlaygroundCommands.prototype.handleBlockCommunication.bind(this, player),
        });
        categories.set('Substitutions', {
            settings: communication.getReplacements().length + ' words',
            listener: PlaygroundCommands.prototype.handleSubstitutions.bind(this, player),
        });
        if (player.isManagement()) {
            const settingCategories = new Map();
            for (const setting of this.settings_().getSettings()) {
                if (!settingCategories.has(setting.category))
                    settingCategories.set(setting.category, new Set());
                settingCategories.get(setting.category).add(setting);
            }
            for (const [category, categorySettings] of settingCategories.entries()) {
                const label = category[0].toUpperCase() + category.substring(1);
                const settings = `${categorySettings.size} settings`;
                const listener =
                    PlaygroundCommands.prototype.handleSettingCategory.bind(this, player, category);
                categories.set(label, { settings, listener });
            }
        }
        const sortedCategories = Array.from(categories.keys()).sort();
        for (const category of sortedCategories) {
            const { settings, listener } = categories.get(category);
            menu.addItem(category, settings, listener);
        }
        await menu.displayForPlayer(player);
    }
async onPlaygroundSettingsCommand ( player ) { const categories = new Map ( ) ; const menu = new Menu ( 'Choose a category of settings' , [ 'Category' , 'Settings' ] ) ; const communication = this . communication_ ( ) ; categories . set ( 'Blocked words' , { settings : communication . getBlockedWords ( ) . length + ' words' , listener : PlaygroundCommands . prototype . handleBlockedWords . bind ( this , player ) , } ) ; categories . set ( 'Player communication' , { settings : communication . isCommunicationMuted ( ) ? '{FFFF00}disabled' : 'enabled' , listener : PlaygroundCommands . prototype . handleBlockCommunication . bind ( this , player ) , } ) ; categories . set ( 'Substitutions' , { settings : communication . getReplacements ( ) . length + ' words' , listener : PlaygroundCommands . prototype . handleSubstitutions . bind ( this , player ) , } ) ; if ( player . isManagement ( ) ) { const settingCategories = new Map ( ) ; for ( const setting of this . settings_ ( ) . getSettings ( ) ) { if ( ! settingCategories . has ( setting . category ) ) settingCategories . set ( setting . category , new Set ( ) ) ; settingCategories . get ( setting . category ) . add ( setting ) ; } for ( const [ category , categorySettings ] of settingCategories . entries ( ) ) { const label = category [ 0 ] . toUpperCase ( ) + category . substring ( 1 ) ; const settings = ` ${ categorySettings . size } ` ; const listener = PlaygroundCommands . prototype . handleSettingCategory . bind ( this , player , category ) ; categories . set ( label , { settings , listener } ) ; } } const sortedCategories = Array . from ( categories . keys ( ) ) . sort ( ) ; for ( const category of sortedCategories ) { const { settings , listener } = categories . get ( category ) ; menu . addItem ( category , settings , listener ) ; } await menu . displayForPlayer ( player ) ; }
on the legel of the |player| calling this command.
on the legel of the |player| calling this command .
// label => { settings, listener } // Administrators and Management members alive have access to the word filters. // Management members have access to individual settings for all features on the server as // well. These require far more context to be able to effectively toggle. // (1) Split up all available settings in categories & settings belonging to them. // (2) Create a label and listener for each of the setting categories. // Now sort the available |categories|, compile the menu, and display it to the |player|.