Is there a way to keep an actor in the front of the party at all (or most) times?

In the game I'm creating, I want to have parts of my game where the player gets more party members than just the main character, and is able to switch them in and out of the party with the formation menu. However, I don't want the player to be able to switch the main character out of the party. I've heard that there's a Yanfly plugin that can achieve this, but as far as I am aware, that plugin must be paid for, and I would like to know if there are other solutions to this.
Try downloading the file from this link, or copy/pasting the following code into a Plugin file called PreventPartySwap.js (it must be called exactly that):
Code:
/*:
* @plugindesc Allows a variable and switch to specify an actor Id to be "locked"
* to the party such that they cannot be moved with the change party command
*
* @help If the switch number configured in the parameters is set to ON, then
* the actor whose Id matches the actorId variable configured in the
* parameters cannot be moved from their position in the party.
*
* By default, the switch is switch number 15 and the unmovable actor is
* actor 1.
*
* @param switchNumber
* @text Prevent swap switch #
* @type switch
* @desc The switch number to set ON if the actorId cannot be removed
* from the party
* @default 15
*
* @param actorId
* @text Actor Id to lock to party
* @type number
* @desc The Id of the actor who can't be swapped
* @default 1
*/

(function(module) {
    'use strict';

    var Zevia = module.Zevia || {};
    var parameters = PluginManager.parameters('PreventPartySwap');
    var switchNumber = parseInt(parameters.switchNumber);
    var actorId = parseInt(parameters.actorId);
    [switchNumber, actorId].forEach(function(requiredParameter, index) {
        if (isNaN(requiredParameter)) {
            throw new Error(
                'Configuration Error: PreventPartySwap requires a valid switch number and actorId to be' +
                ' specified in the setup parameters, but ' + requiredParameter + ' is not a valid value'
            );
        }
    });

    Zevia.menuProcessOk = Window_MenuStatus.prototype.processOk;
    Window_MenuStatus.prototype.processOk = function() {
        if ($gameSwitches.value(switchNumber) && $gameParty.members()[this.index()].actorId() === actorId) {
            SoundManager.playBuzzer();
            return;
        }
        Zevia.menuProcessOk.call(this);
    };
})(window);

The Plugin has two configurable options:
  • A switch number so you can turn off or on the ability to lock a party member to its place in the party. By default, it's switch 15
  • The Id of the actor you want to lock to the party. By default, it's 1
Turn the specified switch number on, and the actor with the specified actor Id cannot be moved using the Formation command.

Tested in a default project by going into the menu and using the Formation command, attempting to select Harold as either the first or second member to swap.
Try downloading the file from this link, or copy/pasting the following code into a Plugin file called PreventPartySwap.js (it must be called exactly that):
Thank you for this suggestion. It seems to work, although I haven't tested every place in the game where I have it on, so I'll probably mention if something ends up going wrong and I can't figure out how to make it work again. But! It has worked so far! So, thank you!

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-keep-an-actor-in-the-front-of-the-party-at-all-or-most-times.167233/