aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-02-12 20:01:06 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-02-12 20:01:06 +0200
commit207048093b7727ff1dec581e6cb523a7a3086c59 (patch)
tree1a74f5116da74f0f62c6149660f4ba369186e764 /src
parentf681f4f8811881b6a7b349f3b215c74a27a7ed4d (diff)
downloadCITResewn-207048093b7727ff1dec581e6cb523a7a3086c59.tar.gz
CITResewn-207048093b7727ff1dec581e6cb523a7a3086c59.tar.bz2
CITResewn-207048093b7727ff1dec581e6cb523a7a3086c59.zip
Fixed type container disposing
Diffstat (limited to 'src')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/ActiveCITs.java10
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITRegistry.java12
2 files changed, 10 insertions, 12 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/ActiveCITs.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/ActiveCITs.java
index afc228c..4d9377c 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/ActiveCITs.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/ActiveCITs.java
@@ -4,6 +4,7 @@ import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.profiler.Profiler;
import shcm.shsupercm.fabric.citresewn.api.CITDisposable;
+import shcm.shsupercm.fabric.citresewn.api.CITTypeContainer;
import shcm.shsupercm.fabric.citresewn.pack.GlobalProperties;
import shcm.shsupercm.fabric.citresewn.pack.PackParser;
@@ -42,7 +43,11 @@ public class ActiveCITs implements CITDisposable { private ActiveCITs() {}
active.cits.computeIfAbsent(cit.type.getClass(), type -> new ArrayList<>()).add(cit);
for (Map.Entry<Class<? extends CITType>, List<CIT>> entry : active.cits.entrySet()) {
entry.getValue().sort(Comparator.<CIT>comparingInt(cit -> cit.weight).reversed().thenComparing(cit -> cit.propertiesIdentifier.toString()));
- CITRegistry.load(entry.getKey(), entry.getValue());
+ for (CITTypeContainer<? extends CITType> typeContainer : CITRegistry.TYPES.values())
+ if (typeContainer.type == entry.getKey()) {
+ typeContainer.load(entry.getValue());
+ break;
+ }
}
profiler.pop();
@@ -55,6 +60,7 @@ public class ActiveCITs implements CITDisposable { private ActiveCITs() {}
for (CITDisposable disposable : FabricLoader.getInstance().getEntrypoints(CITDisposable.ENTRYPOINT, CITDisposable.class))
disposable.dispose();
-
+ for (CITTypeContainer<? extends CITType> typeContainer : CITRegistry.TYPES.values())
+ typeContainer.dispose();
}
}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITRegistry.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITRegistry.java
index e24e598..ba61757 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITRegistry.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cit/CITRegistry.java
@@ -16,8 +16,8 @@ import static shcm.shsupercm.fabric.citresewn.CITResewn.info;
import static shcm.shsupercm.fabric.citresewn.CITResewn.logWarnLoading;
public class CITRegistry {
- private static final Map<Identifier, CITTypeContainer<? extends CITType>> TYPES = new HashMap<>();
- private static final Map<PropertyKey, CITConditionContainer<? extends CITCondition>> CONDITIONS = new HashMap<>();
+ public static final Map<Identifier, CITTypeContainer<? extends CITType>> TYPES = new HashMap<>();
+ public static final Map<PropertyKey, CITConditionContainer<? extends CITCondition>> CONDITIONS = new HashMap<>();
public static void registerAll() {
info("Registering CIT Conditions");
@@ -40,14 +40,6 @@ public class CITRegistry {
}
}
- public static void load(Class<? extends CITType> type, List<CIT> cits) {
- for (CITTypeContainer<? extends CITType> typeContainer : TYPES.values())
- if (typeContainer.type == type) {
- typeContainer.load(cits);
- break;
- }
- }
-
public static CITCondition parseCondition(PropertyKey key, PropertyValue value, PropertyGroup properties) throws CITParsingException {
CITConditionContainer<? extends CITCondition> conditionContainer = CONDITIONS.get(key);
if (conditionContainer == null) {