@@ -824,20 +824,27 @@ export class FUStandardActorSheet extends ActorSheet {
824824 } ,
825825 ] ;
826826
827- // TODO: Deal with multiple behaviors spawning
828- // html.on('click', '.item-option', (jq) => {
829- // const itemId = jq.currentTarget.dataset.itemId;
830- // if (this.actor.type === 'npc' && game.settings.get('projectfu', 'optionBehaviorRoll')) {
831- // const item = this.actor.items.get(itemId);
832- // const behaviorClass = item?.system.isBehavior.value ? 'fas active' : 'far';
833- // contextMenuOptions.push({
834- // name: game.i18n.localize('FU.Behavior'),
835- // icon: `<i class="${behaviorClass} fa-address-book"></i>`,
836- // callback: this._onItemBehavior.bind(this),
837- // condition: (jq) => !!jq.data('itemId'),
838- // });
839- // }
840- // });
827+ html . on ( 'click' , '.item-option' , ( jq ) => {
828+ const itemId = jq . currentTarget . dataset . itemId ;
829+
830+ // Check for the Behavior option before adding it
831+ const behaviorOptionExists = contextMenuOptions . some ( ( option ) => option . name === game . i18n . localize ( 'FU.Behavior' ) ) ;
832+
833+ if ( this . actor . type === 'npc' && game . settings . get ( 'projectfu' , 'optionBehaviorRoll' ) && ! behaviorOptionExists ) {
834+ const item = this . actor . items . get ( itemId ) ;
835+
836+ if ( item ?. system ?. isBehavior ) {
837+ const behaviorClass = item . system . isBehavior . value ? 'fas active' : 'far' ;
838+
839+ contextMenuOptions . push ( {
840+ name : game . i18n . localize ( 'FU.Behavior' ) ,
841+ icon : `<i class="${ behaviorClass } fa-address-book"></i>` ,
842+ callback : this . _onItemBehavior . bind ( this ) ,
843+ condition : ( jq ) => ! ! jq . data ( 'itemId' ) ,
844+ } ) ;
845+ }
846+ }
847+ } ) ;
841848
842849 // Context
843850 // eslint-disable-next-line no-undef
0 commit comments