|
@@ -2,10 +2,14 @@ package me.lortseam.completeconfig.gui.cloth;
|
|
|
|
|
|
import com.google.common.collect.MoreCollectors;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
|
+import lombok.AccessLevel;
|
|
|
+import lombok.Getter;
|
|
|
+import me.lortseam.completeconfig.CompleteConfig;
|
|
|
import me.lortseam.completeconfig.data.BoundedEntry;
|
|
|
import me.lortseam.completeconfig.data.ColorEntry;
|
|
|
import me.lortseam.completeconfig.data.Entry;
|
|
|
import me.lortseam.completeconfig.data.EnumEntry;
|
|
|
+import me.lortseam.completeconfig.extensions.CompleteConfigExtension;
|
|
|
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
|
|
|
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
|
|
import me.shedaniel.clothconfig2.impl.builders.DropdownMenuBuilder;
|
|
@@ -16,16 +20,16 @@ import net.minecraft.text.TextColor;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
|
|
import java.lang.reflect.Type;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.function.Predicate;
|
|
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
|
public final class GuiRegistry {
|
|
|
|
|
|
+ @Getter(AccessLevel.PACKAGE)
|
|
|
+ private static final GuiRegistry instance = new GuiRegistry();
|
|
|
+
|
|
|
public static <T, A extends AbstractConfigListEntry> A build(Function<ConfigEntryBuilder, FieldBuilder<T, A>> builder, boolean requiresRestart) {
|
|
|
FieldBuilder<T, A> fieldBuilder = builder.apply(ConfigEntryBuilder.create());
|
|
|
fieldBuilder.requireRestart(requiresRestart);
|
|
@@ -34,8 +38,11 @@ public final class GuiRegistry {
|
|
|
|
|
|
private final List<GuiProviderRegistration> registrations = new ArrayList<>();
|
|
|
|
|
|
- GuiRegistry() {
|
|
|
+ private GuiRegistry() {
|
|
|
registerDefaultProviders();
|
|
|
+ CompleteConfig.getExtensions().stream().map(CompleteConfigExtension::gui).filter(Objects::nonNull).forEach(guiExtension -> {
|
|
|
+ guiExtension.registerProviders(this);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
public void registerProvider(GuiProvider<?> provider, Predicate<Entry<?>> predicate, Type... types) {
|
|
@@ -63,7 +70,7 @@ public final class GuiRegistry {
|
|
|
}
|
|
|
|
|
|
public void registerColorProvider(GuiProvider<? extends ColorEntry<?>> provider, boolean alphaModeSupported, Type... types) {
|
|
|
- registerProvider(provider, entry -> entry instanceof ColorEntry<?> && (!((ColorEntry) entry).isAlphaMode() || alphaModeSupported), types);
|
|
|
+ registerProvider(provider, entry -> entry instanceof ColorEntry<?> && (!((ColorEntry<?>) entry).isAlphaMode() || alphaModeSupported), types);
|
|
|
}
|
|
|
|
|
|
private void registerDefaultProviders() {
|