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

Commit 36e4bb9

Browse files
committed
0.2.2 fix
1 parent 537730b commit 36e4bb9

File tree

7 files changed

+43
-37
lines changed

7 files changed

+43
-37
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group 'com.redlimerl'
7-
version '0.2.1'
7+
version '0.2.2'
88
repositories {
99
mavenCentral()
1010
}

src/main/java/com/pistacium/modcheck/ModCheck.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@
1717
import java.util.Objects;
1818
import java.util.concurrent.ExecutorService;
1919
import java.util.concurrent.Executors;
20-
import java.util.logging.Level;
21-
import java.util.logging.Logger;
2220

2321
public class ModCheck {
2422

25-
public static final Logger LOGGER = Logger.getLogger("ModCheck");
26-
2723
public static void setStatus(ModCheckStatus status) {
2824
FRAME_INSTANCE.getProgressBar().setString(status.getDescription());
2925
}
@@ -65,7 +61,10 @@ public static void main(String[] args) {
6561
AVAILABLE_MODS.add(modData);
6662
}
6763
} catch (Throwable e) {
68-
LOGGER.log(Level.WARNING, "Failed to init " + jsonElement.getAsJsonObject().get("name").getAsString() + "!", e);
64+
StringWriter sw = new StringWriter();
65+
PrintWriter pw = new PrintWriter(sw);
66+
e.printStackTrace(pw);
67+
System.out.println("Failed to init " + jsonElement.getAsJsonObject().get("name").getAsString() + "!\r\n" + sw);
6968
} finally {
7069
FRAME_INSTANCE.getProgressBar().setValue((int) (10 + (((++count * 1f) / maxCount) * 90)));
7170
}

src/main/java/com/pistacium/modcheck/ModCheckConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public class ModCheckConstants {
44

5-
public static final String APPLICATION_VERSION = "0.2.1";
5+
public static final String APPLICATION_VERSION = "0.2.2";
66

77
}

src/main/java/com/pistacium/modcheck/ModCheckFrame.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,13 @@ private void initCenterLayout() {
280280
JButton selectAllButton = new JButton("Select All");
281281
selectAllButton.addActionListener(e -> {
282282
for (Map.Entry<ModData, JCheckBox> entry : modCheckBoxes.entrySet()) {
283+
if (entry.getKey().getIncompatibleMods().size() > 0) continue;
284+
283285
if (entry.getValue().isEnabled() && entry.getKey().getWarningMessage().isEmpty()) {
284286
entry.getValue().setSelected(true);
285287
}
286288
}
289+
JOptionPane.showMessageDialog(this, "<html><body>Some mods that have warnings (like noPeaceful)<br> or incompatible with other (like Starlight and Phosphor) aren't automatically selected.<br>You must be to select it yourself.</body></html>", "WARNING!", JOptionPane.WARNING_MESSAGE);
287290
});
288291
JButton deselectAllButton = new JButton("Deselect All");
289292
deselectAllButton.addActionListener(e -> {

src/main/java/com/pistacium/modcheck/mod/ModData.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.pistacium.modcheck.util.ModCheckUtils;
99

1010
import java.io.File;
11-
import java.nio.file.Path;
1211
import java.util.*;
1312

1413
public class ModData {
@@ -43,44 +42,44 @@ public ModData(JsonObject jsonObject) throws IllegalAccessException {
4342
}
4443

4544

45+
ModResources<?,?> resources = null;
4646
// GitHub releases loader
4747
if (Objects.equals(type, "github_releases")) {
48-
GitHubModResources resources = new GitHubModResources(
48+
resources = new GitHubModResources(
4949
ModCheckUtils.getUrlRequest(ModCheckUtils.getAPIUrl(resource.get("url").getAsString(), type)),
5050
versionPicks, assetObject.has("build") ? assetObject.get("build").getAsString() : null, supportVersions
5151
);
52-
resourcesList.add(resources);
5352
}
5453

5554

5655
// Modrinth releases loader
5756
if (Objects.equals(type, "modrinth_releases")) {
58-
ModrinthModResources resources = new ModrinthModResources(
57+
resources = new ModrinthModResources(
5958
ModCheckUtils.getUrlRequest(ModCheckUtils.getAPIUrl(resource.get("url").getAsString(), type)),
6059
versionPicks, assetObject.has("build") ? assetObject.get("build").getAsString() : null, supportVersions
6160
);
62-
resourcesList.add(resources);
6361
}
6462

6563

6664
// CurseForge files loader
6765
if (Objects.equals(type, "curseforge_files")) {
68-
CurseForgeModResources resources = new CurseForgeModResources(
66+
resources = new CurseForgeModResources(
6967
ModCheckUtils.getUrlRequest(ModCheckUtils.getAPIUrl(resource.get("url").getAsString(), type)),
7068
versionPicks, assetObject.has("build") ? assetObject.get("build").getAsString() : null, supportVersions
7169
);
72-
resourcesList.add(resources);
7370
}
7471

7572

7673
// Direct URL loader
7774
if (Objects.equals(type, "direct")) {
78-
DirectURLModResources resources = new DirectURLModResources(
75+
resources = new DirectURLModResources(
7976
ModCheckUtils.getAPIUrl(resource.get("url").getAsString(), type),
8077
versionPicks, assetObject.get("build").getAsString(), supportVersions
8178
);
82-
resourcesList.add(resources);
8379
}
80+
81+
82+
if (resources != null) resourcesList.add(resources);
8483
}
8584
}
8685

src/main/java/com/pistacium/modcheck/mod/resource/DirectURLModResources.java

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,51 @@
11
package com.pistacium.modcheck.mod.resource;
22

3-
import com.google.gson.JsonObject;
43
import com.pistacium.modcheck.mod.version.ModVersion;
54
import com.pistacium.modcheck.mod.version.VersionPick;
65

76
import java.util.ArrayList;
87
import java.util.List;
98

10-
public class DirectURLModResources extends ModResources<JsonObject, String> {
9+
public class DirectURLModResources extends ModResources<DirectURLModResources.DirectURLSource, DirectURLModResources.DirectURLSource> {
1110

12-
private final String url;
13-
private final String fileName;
11+
public static class DirectURLSource {
12+
private final String url;
13+
private final String fileName;
14+
15+
public DirectURLSource(String url, String fileName) {
16+
this.url = url;
17+
this.fileName = fileName;
18+
}
19+
}
1420

1521
public DirectURLModResources(String url, List<VersionPick> versionPicks, String defaultBuild, ArrayList<ModVersion> defaultMCVersions) {
16-
super(null, versionPicks, defaultBuild, defaultMCVersions);
17-
this.url = url;
18-
String[] urlArr = url.split("/");
19-
this.fileName = urlArr[urlArr.length - 1];
22+
super(url, versionPicks, defaultBuild, defaultMCVersions);
2023
}
2124

2225
@Override
23-
protected JsonObject convertData(String data) {
24-
return null;
26+
protected DirectURLSource convertData(String data) {
27+
String[] urlArr = data.split("/");
28+
String fileName = urlArr[urlArr.length - 1];
29+
return new DirectURLSource(data, fileName);
2530
}
2631

2732
@Override
28-
public Iterable<String> getChildAssets(JsonObject assets) {
29-
return new ArrayList<>();
33+
public Iterable<DirectURLSource> getChildAssets(DirectURLSource asset) {
34+
ArrayList<DirectURLSource> list = new ArrayList<>();
35+
list.add(asset);
36+
return list;
3037
}
3138

3239
@Override
33-
public boolean isPreRelease(String asset) {
40+
public boolean isPreRelease(DirectURLSource asset) {
3441
return false;
3542
}
3643

3744
@Override
38-
public List<ModResource> convertToModResources(String asset) {
45+
public List<ModResource> convertToModResources(DirectURLSource asset) {
3946
ArrayList<ModResource> modResources = new ArrayList<>();
4047
for (ModVersion defaultMCVersion : this.getDefaultMCVersions()) {
41-
modResources.add(new ModResource(defaultMCVersion, ModVersion.of(this.getDefaultBuild()), url, fileName));
48+
modResources.add(new ModResource(defaultMCVersion, ModVersion.of(this.getDefaultBuild()), asset.url, asset.fileName));
4249
}
4350
return modResources;
4451
}

src/main/java/com/pistacium/modcheck/mod/resource/ModResource.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
import java.io.File;
66
import java.io.FileOutputStream;
77
import java.io.IOException;
8-
import java.net.MalformedURLException;
98
import java.net.URL;
109
import java.net.URLConnection;
1110
import java.nio.channels.Channels;
1211
import java.nio.channels.ReadableByteChannel;
1312
import java.nio.file.Files;
1413
import java.nio.file.Path;
15-
import java.util.List;
1614
import java.util.Stack;
1715

1816
public class ModResource {
@@ -47,20 +45,20 @@ public String getDownloadUrl() {
4745

4846
public void downloadFile(Stack<File> modsPaths) throws IOException {
4947
if (modsPaths.size() < 1) return;
50-
URL url = new URL(downloadUrl);
48+
URL url = new URL(this.getDownloadUrl());
5149

5250
URLConnection con = url.openConnection();
5351

54-
File download = modsPaths.pop().toPath().resolve(fileName).toFile();
52+
File download = modsPaths.pop().toPath().resolve(this.getFileName()).toFile();
5553

5654
ReadableByteChannel rbc = Channels.newChannel(con.getInputStream());
5755
try (FileOutputStream fos = new FileOutputStream(download)) {
5856
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
5957
}
60-
System.out.println("Downloaded "+fileName+" in "+download.getPath());
58+
System.out.println("Downloaded "+this.getFileName()+" in "+download.getPath());
6159

6260
while (modsPaths.size() > 0) {
63-
Path copyPath = modsPaths.pop().toPath().resolve(fileName);
61+
Path copyPath = modsPaths.pop().toPath().resolve(this.getFileName());
6462
Files.copy(download.toPath(), copyPath);
6563
System.out.println("Copied to " + copyPath);
6664
}

0 commit comments

Comments
 (0)