Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ allprojects {
dependencies {
implementation project(':core')
implementation group: 'org.jetbrains', name: 'annotations', version: '20.1.0'
implementation 'de.tr7zw:item-nbt-api:2.13.1'
implementation 'de.tr7zw:item-nbt-api:2.15.5'
compileOnly 'io.projectreactor:reactor-core:3.5.2' // Should be included in using projects.
compileOnly 'commons-lang:commons-lang:2.6'
compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
Expand All @@ -43,7 +43,7 @@ dependencies {
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
testImplementation project(':core')
testImplementation group: 'org.jetbrains', name: 'annotations', version: '20.1.0'
testImplementation 'de.tr7zw:item-nbt-api:2.13.1'
testImplementation 'de.tr7zw:item-nbt-api:2.15.5'
testImplementation 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
testCompileOnly 'io.projectreactor:reactor-core:3.5.2' // Should be included in using projects.
testCompileOnly 'commons-lang:commons-lang:2.6'
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repositories {

dependencies {
implementation group: 'org.jetbrains', name: 'annotations', version: '20.1.0'
implementation 'de.tr7zw:item-nbt-api:2.14.1'
implementation 'de.tr7zw:item-nbt-api:2.15.5'
compileOnly 'io.projectreactor:reactor-core:3.5.2' // Should be included in using projects.
compileOnly 'commons-lang:commons-lang:2.6'
compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/me/zort/containr/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public abstract class Container implements ContainerComponent {
private final Region selection;
private Container parent;
private UpdateContext lastUpdateContext = null;
private boolean initialized = false;

public Container(final int xSize, final int ySize) {
this.containers = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -76,6 +77,14 @@ public Container(final int xSize, final int ySize) {
*/
@ApiStatus.OverrideOnly public void refresh(Player player) {}

protected void doInit() {
if (!initialized) {
init();

initialized = true;
}
}

@ApiStatus.OverrideOnly
public <T extends Element> Map<Integer, T> content(Class<T> clazz) {
Map<Integer, T> content = new HashMap<>();
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/me/zort/containr/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private void initializeModel(Player p) {
if (initList.contains(inner)) {
continue;
}
inner.init();
inner.doInit();
initList.add(inner);
}
if(initList.size() == initSizeBef) {
Expand Down Expand Up @@ -204,7 +204,7 @@ public void update(@NotNull Player p, boolean clear, Class<? extends Element>...
Objects.requireNonNull(p, "Player cannot be null");

try {
updateContextInfo(p);
initializeModel(p);
container.innerContainers().forEach(c -> c.refresh(p));
Map<Integer, ?> content = container.content(clazz.length > 0 ? Arrays.asList(clazz) : null);
content.keySet().forEach(slot -> {
Expand Down