diff --git a/src/main/java/com/terraformersmc/modmenu/api/ConfigScreenFactory.java b/src/main/java/com/terraformersmc/modmenu/api/ConfigScreenFactory.java new file mode 100644 index 00000000..cf22041e --- /dev/null +++ b/src/main/java/com/terraformersmc/modmenu/api/ConfigScreenFactory.java @@ -0,0 +1,37 @@ +/** + * MIT License + * + * Copyright (c) 2018-2020 Prospector + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.terraformersmc.modmenu.api; + +import net.minecraft.client.gui.screens.Screen; + +// This File was included from TerraformersMC/ModMenu +// to enable a ModMenu-Integration without having to +// compile against the actual plugin in an attempt +// to reduce dependencies + +@FunctionalInterface +public interface ConfigScreenFactory { + S create(Screen parent); +} diff --git a/src/main/java/com/terraformersmc/modmenu/api/ModMenuApi.java b/src/main/java/com/terraformersmc/modmenu/api/ModMenuApi.java new file mode 100644 index 00000000..28cb95d1 --- /dev/null +++ b/src/main/java/com/terraformersmc/modmenu/api/ModMenuApi.java @@ -0,0 +1,43 @@ +/** + * MIT License + * + * Copyright (c) 2018-2020 Prospector + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.terraformersmc.modmenu.api; + +import com.google.common.collect.ImmutableMap; + +import java.util.Map; + +// This File was included from TerraformersMC/ModMenu +// to enable a ModMenu-Integration without having to +// compile against the actual plugin in an attempt +// to reduce dependencies + +public interface ModMenuApi { + default ConfigScreenFactory getModConfigScreenFactory() { + return screen -> null; + } + + default Map> getProvidedConfigScreenFactories() { + return ImmutableMap.of(); + } +} diff --git a/src/main/java/com/terraformersmc/modmenu/util/ModMenuApiMarker.java b/src/main/java/com/terraformersmc/modmenu/util/ModMenuApiMarker.java deleted file mode 100644 index 54a17f17..00000000 --- a/src/main/java/com/terraformersmc/modmenu/util/ModMenuApiMarker.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.terraformersmc.modmenu.util; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -//This File was included from TerraformersMC/ModMenu -// to enable a ModMenu-Integration without having to -// compile against the actual plugin - -@Environment(EnvType.CLIENT) -public interface ModMenuApiMarker {} diff --git a/src/main/java/ru/bclib/gui/modmenu/EntryPoint.java b/src/main/java/ru/bclib/gui/modmenu/EntryPoint.java index 18f3e4d5..f4e96752 100644 --- a/src/main/java/ru/bclib/gui/modmenu/EntryPoint.java +++ b/src/main/java/ru/bclib/gui/modmenu/EntryPoint.java @@ -1,10 +1,10 @@ package ru.bclib.gui.modmenu; -import com.terraformersmc.modmenu.util.ModMenuApiMarker; +import com.terraformersmc.modmenu.api.ModMenuApi; import ru.bclib.integration.ModMenuIntegration; public class EntryPoint extends ModMenuIntegration { - public static final ModMenuApiMarker entrypointObject = createEntrypoint(new EntryPoint()); + public static final ModMenuApi entrypointObject = (ModMenuApi) createEntrypoint(new EntryPoint()); public EntryPoint() { super(MainScreen::new); diff --git a/src/main/java/ru/bclib/integration/ModMenuIntegration.java b/src/main/java/ru/bclib/integration/ModMenuIntegration.java index ac26946e..d375b96d 100644 --- a/src/main/java/ru/bclib/integration/ModMenuIntegration.java +++ b/src/main/java/ru/bclib/integration/ModMenuIntegration.java @@ -1,7 +1,8 @@ package ru.bclib.integration; import com.google.common.collect.ImmutableMap; -import com.terraformersmc.modmenu.util.ModMenuApiMarker; +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; import net.minecraft.client.gui.screens.Screen; import ru.bclib.integration.ModMenuIntegration.ModMenuScreenFactory; @@ -49,7 +50,7 @@ class ModMenuScreenFactoryImpl { * Mod is installed on the Client, and the correct ModMenu-EntryPoint is registered in your fabric.mod.json * the screen will show up. *

- * You only need to subclass this class, and initialize a static Field of Type {@link ModMenuApiMarker} using + * You only need to subclass this class, and initialize a static Field of Type {@link ModMenuApi} using * the {@link #createEntrypoint(ModMenuIntegration)}-Method. *

* Example: @@ -72,7 +73,7 @@ public abstract class ModMenuIntegration { * @param target The delegate Object that will receive calls from ModMenu * @return A Proxy that conforms to the ModMenu spec */ - public static ModMenuApiMarker createEntrypoint(ModMenuIntegration target) { + public static ModMenuApi createEntrypoint(ModMenuIntegration target) { Class iModMenuAPI; //Class iModMenuAPIMarker = null; try { @@ -89,7 +90,7 @@ public abstract class ModMenuIntegration { new Class[] {iModMenuAPI}, new BCLibModMenuInvocationHandler(target)); - return (ModMenuApiMarker)o; + return (ModMenuApi) o; } /** @@ -156,9 +157,7 @@ public abstract class ModMenuIntegration { * The Interface matches {@code com.terraformersmc.modmenu.api.ConfigScreenFactory} */ @FunctionalInterface - public interface ModMenuScreenFactory { - Screen create(Screen parent); - } + public interface ModMenuScreenFactory extends ConfigScreenFactory{} record BCLibModMenuInvocationHandler(ModMenuIntegration target) implements InvocationHandler { @Override