I made my first plugin! - "Master Volume" Option

Hi all, hope I'm posting in the right place.

Does anyone else find the default title music waaaay too loud? I had started up a new project and tried to find settings to reduce the volume of everything on startup (before the player goes to the options) but found that I'd have to manually lower the volume setting on each sound. At least, I think you have to do that. . . .Either way, I decided to try and make a plugin to do just that!

Spoiler: Plugin
JavaScript:
(function() {
    // Lower master volume initially
    WebAudio.setMasterVolume(0.4);

    // Create master volume configuration
    Object.defineProperty(ConfigManager, 'masterVolume', {
        get: function() {
            return (WebAudio._masterVolume * 100).clamp(0, 100);
        },
        set: function(value) {
            WebAudio.setMasterVolume((value / 100).clamp(0, 1));
        },
        configurable: true
    });
    
    // Make and apply changes to volume when selected in options
    var _ConfigManager_MakeData = ConfigManager.prototype.makeData;
    ConfigManager.prototype.makeData = function() {
        _ConfigManager_MakeData.call(this);
        var config = {};
        config.masterVolume = this.masterVolume;
        return config;
    }
    var _ConfigManager_ApplyData = ConfigManager.prototype.applyData;
    ConfigManager.prototype.applyData = function(config) {
        _ConfigManager_ApplyData.call(this, config);
        this.masterVolume = this.readVolume(config, 'masterVolume');
    }

    // Add master volume option to UI
    var _Window_Options_AddVolumeOptions = Window_Options.prototype.addVolumeOptions;
    Window_Options.prototype.addVolumeOptions = function() {
        this.addCommand('Master Volume', 'masterVolume');
        _Window_Options_AddVolumeOptions.call(this);
    }

 })();

I only know the barest minimum of making plugins, so there's gonna be some bad practices here, but I felt proud enough to share anyway. I hope anyone would be willing to point out mistakes I did make or any best practices I should follow. Thanks!
Hi!
Congratulations 🙂
When I was learning I had a bad time understanding how to apply new data into the config manager xD
But, if you are doing it just for yourself, so I think it's cool!

But if you want to share with the community, maybe you can search how to make plugin parameters too!

Also, just a heads up when you go alias a function that already return something to you:
JavaScript:
var ConfigManager_makeData = ConfigManager.makeData;
ConfigManager.makeData = function() {
    const alias = ConfigManager_makeData.call(this); //store the previous return value from the function, in this case the "config" object.
    alias.masterVolume = this.masterVolume; // add your thing into the config object
    return alias; // Return the default function + your changes
};
Also, just a heads up when you go alias a function that already return something to you:

Thanks for the heads up! I'm surprised not doing this didn't break the plugin (or maybe it did and I just didn't do anything to expose it:LZYyuck:).
It works! Super useful thing! Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/i-made-my-first-plugin-master-volume-option.125398/