Skip to content

Commit 79f8e60

Browse files
committed
update 1.0.8
1 parent fb2eb30 commit 79f8e60

File tree

8 files changed

+53
-12
lines changed

8 files changed

+53
-12
lines changed

Launcher/src/main/java/com/laeben/corelauncher/LauncherConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.laeben.corelauncher.minecraft.entities.Library;
66

77
public final class LauncherConfig {
8-
public static final double VERSION = 1.071;
8+
public static final double VERSION = 1.08;
99
private static final String APP_ID = "clauncher";
1010
public static final LaebenApp APPLICATION;
1111

Launcher/src/main/java/com/laeben/corelauncher/minecraft/modding/Modder.java

+33-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
import com.laeben.corelauncher.minecraft.modding.modrinth.entities.DependencyInfo;
1515
import com.laeben.corelauncher.minecraft.wrappers.optifine.OptiFine;
1616
import com.laeben.corelauncher.utils.EventHandler;
17+
import com.laeben.corelauncher.utils.Logger;
1718
import com.laeben.corelauncher.utils.NetUtils;
19+
import javafx.application.Platform;
1820

1921
import java.io.FileNotFoundException;
2022
import java.util.List;
@@ -42,16 +44,16 @@ public void installMods(Profile p, List<Mod> mods) throws NoConnectionException,
4244
var path = p.getPath().to("mods");
4345
int i = 0;
4446
int size = mods.size();
45-
for (var a : mods){
47+
for (var a : mods.stream().toList()){
48+
handler.execute(new KeyEvent("," + a.name + ":.resource.progress;" + (++i) + ";" + size));
49+
4650
if (a.fileUrl == null)
4751
continue;
4852

4953
var pxx = path.to(a.fileName);
5054
if (pxx.exists())
5155
continue;
5256

53-
handler.execute(new KeyEvent("," + a.name + ":.resource.progress;" + (++i) + ";" + size));
54-
5557
String url = a.fileUrl;
5658
if (url.startsWith("OptiFine")){
5759
var f = OptiFine.getOptiFine().getVersion(p.getVersionId(), url);
@@ -63,8 +65,23 @@ public void installMods(Profile p, List<Mod> mods) throws NoConnectionException,
6365
continue;
6466
}
6567

68+
if (NetUtils.download(url, path.to(a.fileName), false) != null)
69+
continue;
70+
71+
var up = update(p, a);
72+
if (url.equals(up.fileUrl))
73+
continue;
6674

67-
if (NetUtils.download(url, path.to(a.fileName), false) == null){
75+
Platform.runLater(() -> {
76+
remove(p, a);
77+
try {
78+
include(p, up);
79+
} catch (NoConnectionException | HttpException e) {
80+
Logger.getLogger().log(e);
81+
}
82+
});
83+
84+
if (NetUtils.download(up.fileUrl, path.to(up.fileName), false) == null){
6885
var x = Modrinth.getModrinth().getProjectVersions(a.name, p.getVersionId(), p.getWrapper().getIdentifier(), DependencyInfo.noDependencies());
6986
var s = x.stream().flatMap(f -> f.getFiles().stream()).filter(f -> f.filename != null && f.filename.equals(a.fileName)).findFirst();
7087

@@ -76,6 +93,18 @@ public void installMods(Profile p, List<Mod> mods) throws NoConnectionException,
7693
}
7794
}
7895
}
96+
public CResource update(Profile p, CResource m) throws NoConnectionException, HttpException {
97+
if (m.id == null)
98+
return m;
99+
100+
List<CResource> all = List.of();
101+
if (m.isForge())
102+
all = CurseForge.getForge().getResources(p.getVersionId(), List.of((int)m.id), p, true);
103+
else if (m.isModrinth())
104+
all = Modrinth.getModrinth().getCResources(List.of(m.id.toString()), p.getVersionId(), p.getWrapper().getIdentifier());
105+
106+
return all.isEmpty() ? m : all.get(0);
107+
}
79108
public void includeMods(Profile p, List<Mod> mods){
80109
for (var m : mods){
81110
if (p.getMods().stream().anyMatch(x -> x.equals(m)))

Launcher/src/main/java/com/laeben/corelauncher/minecraft/modding/curseforge/CurseForge.java

-1
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,4 @@ public void reload(){
184184
public List<ForgeCategory> getCategories(){
185185
return categories;
186186
}
187-
188187
}

Launcher/src/main/java/com/laeben/corelauncher/minecraft/modding/modrinth/Modrinth.java

+3
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ public List<RinthCategory> getAllCategories() throws NoConnectionException, Http
172172

173173
private List<Version> processVersions(String json, DependencyInfo dp) throws NoConnectionException, HttpException {
174174
var response = gson.fromJson(json, JsonArray.class);
175+
if (response == null)
176+
return List.of();
177+
175178
var list = response.asList().stream().map(x -> gson.fromJson(x, Version.class)).collect(Collectors.toList());
176179

177180
if (dp.includeDependencies()){

Launcher/src/main/java/com/laeben/corelauncher/ui/controller/JavaManager.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ public static LStage getManager(){
3737
public static void openManager(){
3838
if (getManager().isShowing())
3939
getManager().requestFocus();
40-
else{
41-
getManager().close();
42-
instance = null;
40+
else
4341
getManager().show();
44-
}
4542
}
4643

4744
public JavaManager(){
@@ -61,6 +58,15 @@ public JavaManager(){
6158
}
6259
}, true);
6360

61+
FXManager.getManager().getHandler().addHandler("javaman", a -> {
62+
if (!(a instanceof KeyEvent e) || !e.getKey().equals("close"))
63+
return;
64+
if (!e.getSource().equals(instance))
65+
return;
66+
67+
instance = null;
68+
}, true);
69+
6470
menu = new ContextMenu();
6571
menu.setStyle("-fx-background-color: #252525;");
6672
menu.getItems().addAll(Arrays.stream(supportedJavaVersions).mapToObj(x -> {

Launcher/src/main/resources/com/laeben/corelauncher/data/Translate_en_US.properties

+2
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,7 @@ mods.sort.follows=By Follows
148148
frame.title.rinthbrowser=Modrinth
149149
mods.error.noVersions=Cannot find any versions fit into your game version.
150150
import.error.invalidURL=Invalid URL.
151+
frame.title.importmod=Import Mod
152+
frame.title.multiplemod=Import Multiple Mods
151153

152154

Launcher/src/main/resources/com/laeben/corelauncher/data/Translate_tr_TR.properties

+2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ mods.sort.follows=Takip Sayısı
148148
frame.title.rinthbrowser=Modrinth
149149
mods.error.noVersions=Oyun sürümünüze uyan herhangi bir sürüm bulunamadı.
150150
import.error.invalidURL=Geçersiz URL.
151+
frame.title.importmod=Mod İçeri Aktar
152+
frame.title.multiplemod=Birden Fazla Modu İçeri Aktar
151153

152154

153155

Launcher/src/main/resources/com/laeben/corelauncher/layout/main.fxml

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
</AnchorPane>
5353
<AnchorPane AnchorPane.bottomAnchor="150" AnchorPane.leftAnchor="320" AnchorPane.rightAnchor="15" AnchorPane.topAnchor="15">
5454
<ListView fx:id="lvProfiles" AnchorPane.rightAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.bottomAnchor="0" AnchorPane.topAnchor="0" />
55-
<CButton fx:id="btnAddProfile" prefHeight="45.0" prefWidth="45.0" styleClass="circle-button" text="+" AnchorPane.bottomAnchor="10" AnchorPane.rightAnchor="65" />
56-
<CButton fx:id="btnImportProfile" prefHeight="45.0" prefWidth="45.0" styleClass="circle-button" text="" style="-fx-font-size: 13pt;" AnchorPane.bottomAnchor="10" AnchorPane.rightAnchor="10"/>
55+
<CButton fx:id="btnAddProfile" prefHeight="45.0" prefWidth="45.0" styleClass="circle-button" text="+" AnchorPane.bottomAnchor="10" AnchorPane.leftAnchor="65" />
56+
<CButton fx:id="btnImportProfile" prefHeight="45.0" prefWidth="45.0" styleClass="circle-button" text="" style="-fx-font-size: 13pt;" AnchorPane.bottomAnchor="10" AnchorPane.leftAnchor="10"/>
5757
</AnchorPane>
5858

5959
<AnchorPane prefHeight="130" AnchorPane.bottomAnchor="15" AnchorPane.leftAnchor="320" AnchorPane.rightAnchor="15">

0 commit comments

Comments
 (0)