Files
Mantle/src/main/java/slimeknights/mantle/client/book/data/LinkedSectionData.java
T
2020-01-11 17:49:46 -05:00

47 lines
1.1 KiB
Java

package slimeknights.mantle.client.book.data;
import java.util.ArrayList;
public class LinkedSectionData extends SectionData {
private transient ArrayList<SectionData> sections = new ArrayList<>();
public LinkedSectionData() {
super(true);
}
@Override
public void load() {
this.pages.clear();
this.name = this.name.toLowerCase();
for (SectionData section : this.sections) {
section.parent = this.parent;
section.unnamedPageCounter = this.unnamedPageCounter;
section.load();
this.unnamedPageCounter = section.unnamedPageCounter;
this.pages.addAll(section.pages);
}
this.icon.load(this.source);
}
public void addSection(SectionData data) {
if (!data.name.equalsIgnoreCase(this.name) && !this.sections.isEmpty()) {
throw new IllegalArgumentException("Linked sections must contain all sections of the same name.");
}
if (this.sections.isEmpty()) {
this.name = data.name;
this.icon = data.icon;
this.hideWhenLocked = data.hideWhenLocked;
}
this.requirements.addAll(data.requirements);
this.sections.add(data);
}
}