Questions about how plugins work

I'm assuming that plugin code executes after all the base code does, and that you can thus override base functions.

As for this bit though... I read that this is a self-invoking function. Is this the entry point for plugins like main in C++?
(function() {})();

What exactly is this doing in the sticky template?
var parameters = PluginManager.parameters('template');
Not sure how C++ works, but a self invoking function is an entry point for plugins that need to be executed immediately and won't be executed repetitively.
And the parameters template is responsible for taking care of plugin parameters (you can see how it works in any yanfly plugins that have parameters you can set in the plugin manager).
I'm not sure I understood the whole question but.
PHP:
// auto execute when read (no wait to be call)
(function() {
// do something
})();


// not executed when read, but storing, and wait for call
function name(){
// do something
};

name(); // now its execute
(function() {})();

Creates a new scope for functions and code to be executed in JavaScript. So for example, you could use a self-invoking function to immediately execute code 1, and again create a sense of privacy with all your variables. That's because a function defines new scopes in JavaScript.

var parameters = PluginManager.parameters('template');
Allows you to access parameters defined in the pluginManager or the $plugins object in RPGMakerMV. "template" would be looking for the plugin named 'template'; if 'template' isn't found the parameters will be undefined.

http://endlessillusoft.com/functions-scoping-namespacing/ Talks about scoping and namespacing; take a look.

This might also help: http://endlessillusoft.com/rpgmaker-mv-es6-part-5-block-scope-variables/
Thanks everyone. I just successfully made my first plugin. I cleaned up the template a bit to focus on the code itself (way too many comments for my liking). It successfully runs with MV 1.6.0 beta.
Code:
/*:
 * @plugindesc Test plugin
 * @author Windows i7
 */

 (function(){
     
    var _Scene_Title_MV = Scene_Title.prototype.drawGameTitle;
   
    Scene_Title.prototype.drawGameTitle = function(){
        _Scene_Title_MV.call(this);
        this._gameTitleSprite.bitmap.drawText("Test", 20, 90, Graphics.width - 20 * 2, 48, 'center');
    }   
    
 })();
Thanks everyone. I just successfully made my first plugin.
Congratulations 😎

I cleaned up the template a bit to focus on the code itself (way too many comments for my liking).
I completely 100% agree -- way too many comments make the code unreadable. I've been doing the same thing & removing comments.
Sorry I am late to the parade, but a note on C++ versus JavaScript.

C++ is a top-down execution (in most cases). While you can setup states with C++, it becomes a very different language.
JavaScript, in comparison, is a "state machine design" operation. As Kino mentioned - scopes are created and the code is executed "in scope".
An easy way to think about it is "event-based system", where you attach your JS code to an event.
Example: User clicked on "Items" menu item -> default function runs to display appropriate window.
You attach your code to the same event to display a message, or add/remove items.
Another example would be UI control: on UI ready and loaded -> create windows to display content.

Original thread: https://forums.rpgmakerweb.com/threads/questions-about-how-plugins-work.87625/