Просмотр исходного кода

Ensure main config is registered

Lortseam 4 лет назад
Родитель
Сommit
37e43266ae

+ 31 - 0
lib/src/main/java/me/lortseam/completeconfig/data/ConfigRegistry.java

@@ -10,6 +10,7 @@ import net.minecraft.text.TextColor;
 import java.util.Collection;
 import java.util.*;
 import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 @UtilityClass
@@ -100,6 +101,36 @@ public final class ConfigRegistry {
             }
         }
 
+        @Override
+        public boolean remove(Object o) {
+            if (o == main) {
+                main = null;
+            }
+            return super.remove(o);
+        }
+
+        @Override
+        public boolean removeAll(Collection<?> c) {
+            if (c.contains(main)) {
+                main = null;
+            }
+            return super.removeAll(c);
+        }
+
+        @Override
+        public boolean removeIf(Predicate<? super Config> filter) {
+            if (filter.test(main)) {
+                main = null;
+            }
+            return super.removeIf(filter);
+        }
+
+        @Override
+        public void clear() {
+            main = null;
+            super.clear();
+        }
+
     }
 
 }