Skip to content
This repository was archived by the owner on Aug 13, 2023. It is now read-only.

Commit df741e9

Browse files
author
u-lumaa
committed
fixed everything
1 parent 8b621a7 commit df741e9

File tree

6 files changed

+42
-44
lines changed

6 files changed

+42
-44
lines changed

src/main/java/com/lumaa/libu/LibuLib.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,30 @@
33
import com.lumaa.libu.update.ModrinthMod;
44
import com.lumaa.libu.update.UpdateChecker;
55
import net.fabricmc.api.ClientModInitializer;
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
68

79
import java.io.IOException;
10+
import java.util.Arrays;
811
import java.util.List;
9-
import java.util.logging.Logger;
1012

1113
public class LibuLib implements ClientModInitializer {
12-
private static final Logger logger = Logger.getLogger("libu");
14+
public static final Logger logger = LoggerFactory.getLogger("libu");
1315
private static final String ID = "libu";
1416

15-
private static List<UpdateChecker> updates;
17+
private static List<UpdateChecker> updates = Arrays.asList();
1618
public static final UpdateChecker updateChecker = new UpdateChecker(new ModrinthMod("LibuLib", "libulib", "Dev"));
17-
public static final String version = "A1";
19+
public static final String version = "Dev";
1820
public static final boolean published = false;
1921

2022
@Override
2123
public void onInitializeClient() {
2224
logger.info("LibuLib has awaken");
2325

24-
updates.forEach((update -> {
25-
try {
26-
update.findLatestVersion();
27-
} catch (IOException e) {
28-
e.printStackTrace();
29-
}
30-
}));
31-
3226
if (published) {
3327
try {
3428
updateChecker.findLatestVersion();
29+
addUpdate(updateChecker);
3530
} catch (IOException e) {
3631
e.printStackTrace();
3732
}
@@ -42,11 +37,8 @@ public static List<UpdateChecker> getUpdates() {
4237
return updates;
4338
}
4439

45-
public static void setUpdates(List<UpdateChecker> updates) {
46-
LibuLib.updates = updates;
47-
}
48-
4940
public static void addUpdate(UpdateChecker update) {
5041
LibuLib.updates.add(update);
42+
LibuLib.logger.info("[LibuLib] Will check %d".formatted(update.getMod().name));
5143
}
5244
}

src/main/java/com/lumaa/libu/mixin/TitleScreenMixin.java

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,26 @@ protected TitleScreenMixin(Text title) {
2121
}
2222

2323
@Inject(at = @At("TAIL"), method = "init()V")
24-
public void init(CallbackInfo ci) throws IOException {
25-
// update all the mods using LibuLib
26-
LibuLib.getUpdates().forEach(update -> {
27-
try {
28-
if (!update.getString("version_number").equals(update.getMod().versionId) && !updatePopped) {
29-
if (update.getMod().versionId == "Dev") {
30-
updatePopped = true;
31-
} else {
32-
updatePopped = true;
33-
this.client.setScreen(new UpdateScreen(LibuLib.updateChecker.getMod(), Text.translatable("update.libulib.title"), Text.translatable("update.libulib.description")));
24+
public void init(CallbackInfo ci) {
25+
// update all the mods using LibuLib (including LibuLib)
26+
if (LibuLib.getUpdates().size() > 0) {
27+
LibuLib.getUpdates().forEach(update -> {
28+
LibuLib.logger.info("[LibuLib] UpdateChecker - Checking %d".formatted(update.getMod().name));
29+
try {
30+
if (!update.getString("version_number").equals(update.getMod().versionId) && !update.isShown()) {
31+
if (update.getMod().versionId == "Dev") {
32+
update.setShown(true);
33+
} else {
34+
update.setShown(true);
35+
this.client.setScreen(new UpdateScreen(LibuLib.updateChecker.getMod(), Text.translatable("update.libulib.title".formatted(update.getMod().name)), Text.translatable("update.libulib.description".formatted(update.getMod().name, update.getMod().versionId, update.getString("version_number"), update.getMod().name))));
36+
}
3437
}
38+
} catch (IOException e) {
39+
e.printStackTrace();
3540
}
36-
} catch (IOException e) {
37-
e.printStackTrace();
38-
}
39-
});
40-
41-
// update LibuLib (last because message will appear first if many)
42-
if (LibuLib.published) {
43-
if (!LibuLib.updateChecker.getString("version_number").equals(LibuLib.version) && !updatePopped) {
44-
if (LibuLib.version == "Dev") {
45-
updatePopped = true;
46-
} else {
47-
updatePopped = true;
48-
this.client.setScreen(new UpdateScreen(LibuLib.updateChecker.getMod(), Text.translatable("update.libulib.title"), Text.translatable("update.libulib.description")));
49-
}
50-
}
41+
});
42+
} else {
43+
LibuLib.logger.error("[LibuLib] No mods in UpdateChecker list");
5144
}
5245
}
5346
}

src/main/java/com/lumaa/libu/update/UpdateChecker.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
public class UpdateChecker {
1414
private static ModrinthMod mod;
1515
private static JsonObject modObject;
16+
private static boolean shown = false;
1617

1718
public UpdateChecker(ModrinthMod mod) {
1819
this.mod = mod;
@@ -57,4 +58,12 @@ public String getString(String memberName) {
5758
public static ModrinthMod getMod() {
5859
return mod;
5960
}
61+
62+
public static boolean isShown() {
63+
return shown;
64+
}
65+
66+
public void setShown(boolean shown) {
67+
this.shown = shown;
68+
}
6069
}

src/main/resources/assets/libu/lang/en_us.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"mod.libulib.name": "LibuLib",
33
"mod.libulib.short_name": "Libu",
44

5-
"update.libulib.title": "LibuLib has an update!",
6-
"update.libulib.description": "You are now currently using an outdated version of LibuLib, version %d.\nWe recommend you to update to the newest version, version %d of LibuLib."
5+
"update.libulib.title": "%d has an update!",
6+
"update.libulib.description": "You are now currently using an outdated version of %d, version %d.\nWe recommend you to update to the newest version, version %d of %d."
77
}

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
"environment": "*",
1919
"entrypoints": {
20-
"main": [
20+
"client": [
2121
"com.lumaa.libu.LibuLib"
2222
]
2323
},

src/main/resources/libu.mixins.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
"minVersion": "0.8",
44
"package": "com.lumaa.libu.mixin",
55
"compatibilityLevel": "JAVA_17",
6+
"mixins": [
7+
],
68
"client": [
79
"TitleScreenMixin"
810
],
11+
"server": [
12+
],
913
"injectors": {
1014
"defaultRequire": 1
1115
}

0 commit comments

Comments
 (0)