Skip to content

Commit

Permalink
new SkyClient-exclusive first launch message
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Nov 22, 2023
1 parent 0f7b415 commit c674cec
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/cc/polyfrost/oneconfig/utils/Notifications.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
import cc.polyfrost.oneconfig.renderer.NanoVGHelper;
import cc.polyfrost.oneconfig.renderer.asset.Icon;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -252,6 +254,8 @@ else if (desiredPosition != entry.getValue().getEnd())

private Animation dummyAnimation;
private static final Icon DEFAULT_ICON = new Icon(SVGs.ONECONFIG_HEAD_DARK);
private static final File crashPatchSkyClientFile = new File("./OneConfig/CrashPatch/SKYCLIENT");
private static final File oldCrashPatchSkyClientFile = new File("./W-OVERFLOW/CrashPatch/SKYCLIENT");

@Subscribe
private void onTickEvent(TickEvent event) {
Expand All @@ -260,7 +264,9 @@ private void onTickEvent(TickEvent event) {
Preferences.firstLaunch = false;
Preferences.getInstance().save();
dummyAnimation = new EaseInOutQuad(4000, 0, 1, false);
send("Welcome to OneConfig!", "Press '" + Preferences.oneConfigKeyBind.getDisplay() + "' to open.", DEFAULT_ICON, -1f, () -> {
boolean isSkyClient = isSkyClient();
String message = isSkyClient ? "SkyClient now includes OneConfig, the next-gen config library for Minecraft. You can now simply press '" + Preferences.oneConfigKeyBind.getDisplay() + "' to configure all your mods!" : "Press '" + Preferences.oneConfigKeyBind.getDisplay() + "' to open OneConfig, the next-gen config library for Minecraft.";
send("Welcome to OneConfig!", message, DEFAULT_ICON, -1f, () -> {
if (Platform.getGuiPlatform().getCurrentScreen() instanceof OneConfigGui || Preferences.oneconfigOpened) {
Preferences.oneconfigOpened = true;
Preferences.getInstance().save();
Expand All @@ -272,4 +278,10 @@ private void onTickEvent(TickEvent event) {
}
}
}

private boolean isSkyClient() {
if (crashPatchSkyClientFile.exists()) return true;
if (oldCrashPatchSkyClientFile.exists()) return true;
return Platform.getLoaderPlatform().getLoadedMods().stream().anyMatch(mod -> mod != null && StringUtils.contains(mod.id, "skyclient") || StringUtils.contains(mod.id, "skyblockclient") || StringUtils.equals(mod.id, "scc"));
}
}

0 comments on commit c674cec

Please sign in to comment.