瀏覽代碼

Shrink the ConfigScreenBuilder class

Lortseam 4 年之前
父節點
當前提交
bb39a7db78

+ 2 - 20
src/main/java/me/lortseam/completeconfig/gui/ConfigScreenBuilder.java

@@ -1,29 +1,11 @@
 package me.lortseam.completeconfig.gui;
 
 import me.lortseam.completeconfig.data.Config;
-import me.lortseam.completeconfig.gui.cloth.ClothConfigScreenBuilder;
 import net.fabricmc.api.EnvType;
 import net.fabricmc.api.Environment;
-import net.fabricmc.loader.api.FabricLoader;
 import net.minecraft.client.gui.screen.Screen;
 
-import java.util.Optional;
-
-public interface ConfigScreenBuilder {
-
-    /**
-     * Returns a new instance of the default screen builder, if present.
-     *
-     * <p>More specifically, if installed, the {@link ClothConfigScreenBuilder} is used by default.
-     *
-     * @return the default screen builder or an empty value if absent
-     */
-    static Optional<ConfigScreenBuilder> getDefault() {
-        if (FabricLoader.getInstance().isModLoaded("cloth-config2")) {
-            return Optional.of(new ClothConfigScreenBuilder());
-        }
-        return Optional.empty();
-    }
+public abstract class ConfigScreenBuilder {
 
     /**
      * Builds a screen based on a config.
@@ -33,6 +15,6 @@ public interface ConfigScreenBuilder {
      * @return the built screen
      */
     @Environment(EnvType.CLIENT)
-    Screen build(Screen parentScreen, Config config);
+    public abstract Screen build(Screen parentScreen, Config config);
 
 }

+ 1 - 1
src/main/java/me/lortseam/completeconfig/gui/cloth/ClothConfigScreenBuilder.java

@@ -25,7 +25,7 @@ import java.util.function.Supplier;
  * A screen builder based on the Cloth Config API.
  */
 @Environment(EnvType.CLIENT)
-public class ClothConfigScreenBuilder implements ConfigScreenBuilder {
+public final class ClothConfigScreenBuilder extends ConfigScreenBuilder {
 
     private final Supplier<ConfigBuilder> supplier;
     @Getter