Skip to content

Commit

Permalink
Simplify some code
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed May 11, 2024
1 parent c101ef0 commit 8307e0d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/main/java/io/github/gaming32/worldhost/WorldHost.java
Expand Up @@ -775,16 +775,16 @@ public static String getModVersion(String modId) {
//#endif
}

//#if FABRIC && MC >= 1.18.2
public static int getMMCLines(boolean isPause) {
//#if FABRIC && MC >= 1.18.2
if (FabricLoader.getInstance().isModLoaded("isxander-main-menu-credits")) {
final var baseConfig = MainMenuCredits.getInstance().getConfig();
final var config = isPause ? baseConfig.PAUSE_MENU : baseConfig.MAIN_MENU;
return (CONFIG.getOnlineStatusLocation() == OnlineStatusLocation.RIGHT ? config.getBottomRight() : config.getBottomLeft()).size();
}
//#endif
return 0;
}
//#endif

public static <T> T httpGet(
CloseableHttpClient client,
Expand Down Expand Up @@ -821,7 +821,7 @@ public static CompletableFuture<Optional<String>> checkForUpdates() {
final String latestVersion = httpGet(
client, "https://api.modrinth.com/v2/project/world-host/version",
builder -> builder
.addParameter("game_versions", "[\"" + WorldHost.getModVersion("minecraft") + "\"]")
.addParameter("game_versions", "[\"" + getModVersion("minecraft") + "\"]")
.addParameter("loaders", "[\"" + MOD_LOADER + "\"]"),
input -> {
try (JsonReader reader = JsonReader.json(new InputStreamReader(input, StandardCharsets.UTF_8))) {
Expand Down
Expand Up @@ -38,13 +38,11 @@ private void onlineStatus(CallbackInfo ci) {
if (location == OnlineStatusLocation.OFF) return;
int x = 7;
int y = 15;
//#if FABRIC && MC >= 1.18.2
final int mmcLines = WorldHost.getMMCLines(true);
if (mmcLines > 0) {
x = 2;
y = 10 + mmcLines * 12;
}
//#endif
addRenderableWidget(new OnlineStatusButton(
location == OnlineStatusLocation.RIGHT ? width - x : x,
height - y,
Expand Down
Expand Up @@ -33,14 +33,11 @@ private void onlineStatus(CallbackInfo ci) {
final OnlineStatusLocation location = WorldHost.CONFIG.getOnlineStatusLocation();
if (location == OnlineStatusLocation.OFF) return;
int y = 20;
//#if FABRIC
//#if MC >= 1.18.2
final int mmcLines = WorldHost.getMMCLines(false);
if (mmcLines > 0) {
y += mmcLines * 12;
}
//#endif
//#else
//#if FORGELIKE
//$$ int[] forgeLineCount = {-1};
//$$ final BiConsumer<Integer, String> lineConsumer = (i, s) -> forgeLineCount[0]++;
//$$ if (location == OnlineStatusLocation.LEFT) {
Expand Down

0 comments on commit 8307e0d

Please sign in to comment.