瀏覽代碼

Throw exception if no screen builder found

Lortseam 4 年之前
父節點
當前提交
9527819c2f
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      lib/src/main/java/me/lortseam/completeconfig/gui/ConfigScreenBuilder.java

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

@@ -45,8 +45,10 @@ public abstract class ConfigScreenBuilder {
      * @param config the config to build the screen of
      * @return the built screen, if successful
      */
-    public static Optional<Screen> tryBuild(Screen parentScreen, Config config) {
-        return getMain(config.getMod().getId()).map(builder -> builder.build(parentScreen, config));
+    public static Screen tryBuild(Screen parentScreen, Config config) {
+        return getMain(config.getMod().getId()).orElseThrow(() -> {
+            return new UnsupportedOperationException("No screen builder found for mod " + config.getMod().getId());
+        }).build(parentScreen, config);
     }
 
     /**