Skip to content

Commit

Permalink
update 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
etkmlm committed Aug 24, 2023
1 parent fb2eb30 commit 79f8e60
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.laeben.corelauncher.minecraft.entities.Library;

public final class LauncherConfig {
public static final double VERSION = 1.071;
public static final double VERSION = 1.08;
private static final String APP_ID = "clauncher";
public static final LaebenApp APPLICATION;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import com.laeben.corelauncher.minecraft.modding.modrinth.entities.DependencyInfo;
import com.laeben.corelauncher.minecraft.wrappers.optifine.OptiFine;
import com.laeben.corelauncher.utils.EventHandler;
import com.laeben.corelauncher.utils.Logger;
import com.laeben.corelauncher.utils.NetUtils;
import javafx.application.Platform;

import java.io.FileNotFoundException;
import java.util.List;
Expand Down Expand Up @@ -42,16 +44,16 @@ public void installMods(Profile p, List<Mod> mods) throws NoConnectionException,
var path = p.getPath().to("mods");
int i = 0;
int size = mods.size();
for (var a : mods){
for (var a : mods.stream().toList()){
handler.execute(new KeyEvent("," + a.name + ":.resource.progress;" + (++i) + ";" + size));

if (a.fileUrl == null)
continue;

var pxx = path.to(a.fileName);
if (pxx.exists())
continue;

handler.execute(new KeyEvent("," + a.name + ":.resource.progress;" + (++i) + ";" + size));

String url = a.fileUrl;
if (url.startsWith("OptiFine")){
var f = OptiFine.getOptiFine().getVersion(p.getVersionId(), url);
Expand All @@ -63,8 +65,23 @@ public void installMods(Profile p, List<Mod> mods) throws NoConnectionException,
continue;
}

if (NetUtils.download(url, path.to(a.fileName), false) != null)
continue;

var up = update(p, a);
if (url.equals(up.fileUrl))
continue;

if (NetUtils.download(url, path.to(a.fileName), false) == null){
Platform.runLater(() -> {
remove(p, a);
try {
include(p, up);
} catch (NoConnectionException | HttpException e) {
Logger.getLogger().log(e);
}
});

if (NetUtils.download(up.fileUrl, path.to(up.fileName), false) == null){
var x = Modrinth.getModrinth().getProjectVersions(a.name, p.getVersionId(), p.getWrapper().getIdentifier(), DependencyInfo.noDependencies());
var s = x.stream().flatMap(f -> f.getFiles().stream()).filter(f -> f.filename != null && f.filename.equals(a.fileName)).findFirst();

Expand All @@ -76,6 +93,18 @@ public void installMods(Profile p, List<Mod> mods) throws NoConnectionException,
}
}
}
public CResource update(Profile p, CResource m) throws NoConnectionException, HttpException {
if (m.id == null)
return m;

List<CResource> all = List.of();
if (m.isForge())
all = CurseForge.getForge().getResources(p.getVersionId(), List.of((int)m.id), p, true);
else if (m.isModrinth())
all = Modrinth.getModrinth().getCResources(List.of(m.id.toString()), p.getVersionId(), p.getWrapper().getIdentifier());

return all.isEmpty() ? m : all.get(0);
}
public void includeMods(Profile p, List<Mod> mods){
for (var m : mods){
if (p.getMods().stream().anyMatch(x -> x.equals(m)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,4 @@ public void reload(){
public List<ForgeCategory> getCategories(){
return categories;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ public List<RinthCategory> getAllCategories() throws NoConnectionException, Http

private List<Version> processVersions(String json, DependencyInfo dp) throws NoConnectionException, HttpException {
var response = gson.fromJson(json, JsonArray.class);
if (response == null)
return List.of();

var list = response.asList().stream().map(x -> gson.fromJson(x, Version.class)).collect(Collectors.toList());

if (dp.includeDependencies()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ public static LStage getManager(){
public static void openManager(){
if (getManager().isShowing())
getManager().requestFocus();
else{
getManager().close();
instance = null;
else
getManager().show();
}
}

public JavaManager(){
Expand All @@ -61,6 +58,15 @@ public JavaManager(){
}
}, true);

FXManager.getManager().getHandler().addHandler("javaman", a -> {
if (!(a instanceof KeyEvent e) || !e.getKey().equals("close"))
return;
if (!e.getSource().equals(instance))
return;

instance = null;
}, true);

menu = new ContextMenu();
menu.setStyle("-fx-background-color: #252525;");
menu.getItems().addAll(Arrays.stream(supportedJavaVersions).mapToObj(x -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,7 @@ mods.sort.follows=By Follows
frame.title.rinthbrowser=Modrinth
mods.error.noVersions=Cannot find any versions fit into your game version.
import.error.invalidURL=Invalid URL.
frame.title.importmod=Import Mod
frame.title.multiplemod=Import Multiple Mods


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



Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
</AnchorPane>
<AnchorPane AnchorPane.bottomAnchor="150" AnchorPane.leftAnchor="320" AnchorPane.rightAnchor="15" AnchorPane.topAnchor="15">
<ListView fx:id="lvProfiles" AnchorPane.rightAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.bottomAnchor="0" AnchorPane.topAnchor="0" />
<CButton fx:id="btnAddProfile" prefHeight="45.0" prefWidth="45.0" styleClass="circle-button" text="+" AnchorPane.bottomAnchor="10" AnchorPane.rightAnchor="65" />
<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"/>
<CButton fx:id="btnAddProfile" prefHeight="45.0" prefWidth="45.0" styleClass="circle-button" text="+" AnchorPane.bottomAnchor="10" AnchorPane.leftAnchor="65" />
<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"/>
</AnchorPane>

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

0 comments on commit 79f8e60

Please sign in to comment.