Skip to content

Commit

Permalink
hideEmpty setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jessev14 committed Dec 28, 2022
1 parent 6ebda82 commit 334852a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/custom-character-sheet-sections.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const moduleID = "custom-character-sheet-sections";


Hooks.once('init', () => {
game.settings.register(moduleID, 'hideEmpty', {
name: 'Hide Empty Sections',
scope: 'world',
config: true,
type: Boolean,
default: false
});
});

Hooks.once("ready", () => {
libWrapper.register(moduleID, "CONFIG.Actor.sheetClasses.character['dnd5e.ActorSheet5eCharacter'].cls.prototype.getData", customSectionGetData, "WRAPPER");
});
Expand Down Expand Up @@ -43,6 +53,16 @@ Hooks.on("renderActorSheet5eCharacter", (app, html, appData) => {
$(this).remove();
return;
});

if (game.settings.get(moduleID, 'hideEmpty')) {
const headers = html[0].querySelectorAll('li.items-header');
for (const header of headers) {
const ol = header.nextElementSibling;
if (ol.tagName !== 'OL' || ol.childElementCount) continue;

header.remove();
}
}
});


Expand Down

0 comments on commit 334852a

Please sign in to comment.