Changed Updater Icon handling
This commit is contained in:
parent
b99761318b
commit
5dc7d357ac
4 changed files with 13 additions and 52 deletions
|
@ -2,8 +2,6 @@ package org.betterx.bclib.client.gui.screens;
|
|||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.entrypoints.EntrypointUtil;
|
||||
import org.betterx.bclib.networking.VersionCheckEntryPoint;
|
||||
import org.betterx.bclib.networking.VersionChecker;
|
||||
import org.betterx.ui.ColorUtil;
|
||||
import org.betterx.ui.layout.components.HorizontalStack;
|
||||
|
@ -24,6 +22,7 @@ import net.fabricmc.api.EnvType;
|
|||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.fabricmc.loader.api.metadata.CustomValue;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class UpdatesScreen extends BCLibLayoutScreen {
|
||||
|
@ -38,12 +37,18 @@ public class UpdatesScreen extends BCLibLayoutScreen {
|
|||
if (modID.equals(BCLib.MOD_ID)) {
|
||||
return UPDATE_LOGO_LOCATION;
|
||||
}
|
||||
return EntrypointUtil.getCommon(VersionCheckEntryPoint.class)
|
||||
.stream()
|
||||
.map(vc -> vc.updaterIcon(modID))
|
||||
.filter(r -> r != null)
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
ModContainer nfo = FabricLoader.getInstance().getModContainer(modID).orElse(null);
|
||||
if (nfo != null) {
|
||||
CustomValue element = nfo.getMetadata().getCustomValue("bclib");
|
||||
if (element != null) {
|
||||
CustomValue.CvObject obj = element.getAsObject();
|
||||
if (obj != null) {
|
||||
CustomValue icon = obj.get("updater_icon");
|
||||
return new ResourceLocation(modID, icon.getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
package org.betterx.bclib.entrypoints;
|
||||
|
||||
public interface BCLibEntryPoint {
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package org.betterx.bclib.entrypoints;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class EntrypointUtil {
|
||||
private static <T extends BCLibEntryPoint> List<T> getEntryPoints(boolean client, Class<T> select) {
|
||||
return FabricLoader.getInstance()
|
||||
.getEntrypoints(
|
||||
client ? "bclib_client" : "bclib",
|
||||
BCLibEntryPoint.class
|
||||
)
|
||||
.stream()
|
||||
.filter(o -> select.isAssignableFrom(o.getClass()))
|
||||
.map(e -> (T) e)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T extends BCLibEntryPoint> List<T> getCommon(Class<T> select) {
|
||||
return getEntryPoints(false, select);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T extends BCLibEntryPoint> List<T> getClient(Class<T> select) {
|
||||
return getEntryPoints(true, select);
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package org.betterx.bclib.networking;
|
||||
|
||||
import org.betterx.bclib.entrypoints.BCLibEntryPoint;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface VersionCheckEntryPoint extends BCLibEntryPoint {
|
||||
ResourceLocation updaterIcon(String modID);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue