diff --git a/build.gradle b/build.gradle index b83144b..286bcc0 100644 --- a/build.gradle +++ b/build.gradle @@ -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' @@ -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' diff --git a/core/build.gradle b/core/build.gradle index e92db1e..7aa1ca5 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -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' diff --git a/core/src/main/java/me/zort/containr/Container.java b/core/src/main/java/me/zort/containr/Container.java index 3f40543..f854f0a 100644 --- a/core/src/main/java/me/zort/containr/Container.java +++ b/core/src/main/java/me/zort/containr/Container.java @@ -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<>(); @@ -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 Map content(Class clazz) { Map content = new HashMap<>(); diff --git a/core/src/main/java/me/zort/containr/GUI.java b/core/src/main/java/me/zort/containr/GUI.java index f630b63..5d9acea 100644 --- a/core/src/main/java/me/zort/containr/GUI.java +++ b/core/src/main/java/me/zort/containr/GUI.java @@ -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) { @@ -204,7 +204,7 @@ public void update(@NotNull Player p, boolean clear, Class... Objects.requireNonNull(p, "Player cannot be null"); try { - updateContextInfo(p); + initializeModel(p); container.innerContainers().forEach(c -> c.refresh(p)); Map content = container.content(clazz.length > 0 ? Arrays.asList(clazz) : null); content.keySet().forEach(slot -> {