aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java17
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java2
2 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java b/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java
index a9666d3..5aa727d 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITTypeContainer.java
@@ -1,7 +1,9 @@
package shcm.shsupercm.fabric.citresewn.api;
+import shcm.shsupercm.fabric.citresewn.cit.ActiveCITs;
import shcm.shsupercm.fabric.citresewn.cit.CIT;
import shcm.shsupercm.fabric.citresewn.cit.CITType;
+import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;
import java.util.List;
import java.util.function.Supplier;
@@ -12,16 +14,29 @@ public abstract class CITTypeContainer<T extends CITType> implements CITDisposab
public final Supplier<T> createType;
public final String id;
+ protected boolean empty = true;
+
public CITTypeContainer(Class<T> type, Supplier<T> createType, String id) {
this.type = type;
this.createType = createType;
this.id = id;
}
- public abstract void load(List<CIT<T>> parsedCITs);
+ protected abstract void load(List<CIT<T>> parsedCITs);
@SuppressWarnings("unchecked")
public final void loadUntyped(List<?> parsedCITs) {
+ if (!parsedCITs.isEmpty())
+ empty = false;
load((List<CIT<T>>) parsedCITs);
}
+
+ public final void unload() {
+ dispose();
+ empty = true;
+ }
+
+ public boolean active() {
+ return !empty && CITResewnConfig.INSTANCE.enabled && ActiveCITs.isActive();
+ }
}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java
index f54cc54..c7ca38c 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/ActiveCITs.java
@@ -61,6 +61,6 @@ public class ActiveCITs implements CITDisposable { private ActiveCITs() {}
disposable.dispose();
for (CITTypeContainer<? extends CITType> typeContainer : CITRegistry.TYPES.values())
- typeContainer.dispose();
+ typeContainer.unload();
}
}