MP/TP restore items being consumed when MP/TP is full & how to avoid?

Hiya! So I've got a game in the works where one character uses MP to power skills, and the other character uses TP. Therefore items that restore each gauge are only useful for one character each. However, if you accidentally use them on the wrong character, they can be consumed for no benefit, which is frustrating, and not something I want players to have to deal with. I tried having it so each character's unused gauge is always full but hidden (using Yanfly's Skill Core), but this didn't always solve the issue. After some messing around I figured out that:

- MP-restoring items will give you a little "nope" sound if used on a character with full MP and won't be consumed...but only in the menu. If used in battle, they will always be consumed, even if they're not doing anything.

-TP-restoring items will always be consumed, even if the bar is already at max, whether inside or out of battle.

I then thought that I could solve the problem by replacing the standard "restore 100 MP/TP" effect with having the item run a common event that checks if the relevant character's gauge is full, fills it up if it isn't, and if it's already full just displays a "this is already full!" message and refunds the item. Since there's only two party members, I always know who the item is going to be used on, so you don't even have to target one and I can just have it automatically affect the right one. This works, but common events close the menu to run, which is a little more awkward and doesn't have the smoothness and satisfying feel of using the standard "restore MP/TP" in the item's effects box, which lets you stay in the menu and keep using other items.

Is there any way to have the functionality of the common event route, that won't be consumed if it's used on a full gauge, while still having the smooth UI experience of the default method?

I hope that makes sense? Happy to be pointed to a prior thread that helps, but I couldn't find anything quite matching this.
For not letting you use TP items in the menu when the actor is full, paste the below into a text editor, save as a *.js file, include as a plugin.

Code:
var origTestItemEffect = Game_Action.prototype.testItemEffect;
Game_Action.prototype.testItemEffect = function(target, effect)
{
    if (origTestItemEffect.call(this, target, effect))
        return true;

    if (effect.code == Game_Action.EFFECT_GAIN_TP)
        return target.tp < target.maxTp();

    return true;
};

For the in-battle part...that's kind of intended. Since you don't perform your action when it's selected at the beginning of the turn, part of the strategy in this kind of battle system can be "I anticipate I'm going to take a hit, so I'm selecting the heal now."

The easiest way to change that would be with Yanfly's Selection Core, you can make the items only able to select an actor as a target if they don't have full HP/MP/TP.
Aha, thank you for the wizardry!

And yup, it does look like Selection Core has what I'm looking for as far as fine-tuning it goes. I'd managed to go this far without getting the battle pack, but I know I'm gonna need it for my next project after this anyway, so hey, only stand to gain by grabbing it.
If you're spending any money on Yanfly, it's probably worth getting the full library. Just my opinion.
Fair enough! Buying in bulk does tend to be value in the long run, and I do see myself continuing to make stuff in the engine.

Just gonna need to figure out how to make the battle core not change a bunch of visual/timing stuff unless I specifically tell it to, haha. (More a fan of the "classic" style)

Original thread: https://forums.rpgmakerweb.com/threads/mp-tp-restore-items-being-consumed-when-mp-tp-is-full-how-to-avoid.171113/