Skip to content

Commit 8437866

Browse files
committed
V2 update. servers.dat merging, file repository, less crashes
1 parent bc98be9 commit 8437866

26 files changed

Lines changed: 1417 additions & 177 deletions

build.gradle

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ plugins {
55
id 'java'
66
id 'idea'
77
id 'maven-publish'
8-
id 'net.neoforged.moddev' version "2.0.75"
8+
id 'net.neoforged.moddev' version "2.0.118"
99
}
1010

1111
ext.ENV = System.getenv()
1212
def isLocal = !ENV.containsKey("GITHUB_RUN_NUMBER")
1313

1414
version = "${mod_version}-${isLocal ? "local.${Instant.now().epochSecond}" : "build.${ENV.GITHUB_RUN_NUMBER}"}"
1515
group = project.maven_group
16-
base.archivesBaseName = project.archives_base_name
16+
base.archivesName = project.archives_base_name
1717

18-
println("Building version: ${version}")
18+
println("Building version: $version")
1919

2020
neoForge {
2121
version = project.neoforge_version
@@ -76,6 +76,13 @@ repositories {
7676
url "https://maven.neoforged.net/releases"
7777
}
7878

79+
maven {
80+
url = 'https://maven.latvian.dev/releases'
81+
content {
82+
includeGroup "dev.latvian.apps"
83+
}
84+
}
85+
7986
maven {
8087
name = 'ParchmentMC'
8188
url = 'https://maven.parchmentmc.org'

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ mod_name=Pack Sync
88
maven_group=dev.latvian.mods
99
mod_author=latvian.dev
1010

11-
mod_version=2104.1.0
11+
mod_version=2104.1.1
1212

13-
neoforge_version=21.4.124
14-
neoForge.parchment.minecraftVersion=1.21.4
15-
neoForge.parchment.mappingsVersion=2025.03.23
13+
neoforge_version=21.5.95
14+
neoForge.parchment.minecraftVersion=1.21.5
15+
neoForge.parchment.mappingsVersion=2025.06.15

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package dev.latvian.mods.packsync;
2+
3+
import net.neoforged.fml.ModLoadingIssue;
4+
import net.neoforged.neoforgespi.IIssueReporting;
5+
6+
import java.io.BufferedInputStream;
7+
import java.math.BigInteger;
8+
import java.nio.file.Files;
9+
import java.nio.file.Path;
10+
import java.security.MessageDigest;
11+
12+
public interface Checksum {
13+
static String checksum(Path path, String algorithm, String format, IIssueReporting issues) {
14+
if (Files.notExists(path)) {
15+
return "";
16+
}
17+
18+
try (var in = new BufferedInputStream(Files.newInputStream(path))) {
19+
var md = MessageDigest.getInstance(algorithm);
20+
var tempBuffer = new byte[32768];
21+
22+
while (true) {
23+
int len = in.read(tempBuffer);
24+
25+
if (len >= 0) {
26+
md.update(tempBuffer, 0, len);
27+
} else {
28+
break;
29+
}
30+
}
31+
32+
return format.formatted(new BigInteger(1, md.digest()));
33+
} catch (Exception ex) {
34+
issues.addIssue(ModLoadingIssue.error("Failed to read checksum of file %s!", path.getFileName().toString()).withCause(ex).withAffectedPath(path));
35+
}
36+
37+
return "";
38+
}
39+
40+
static String md5(Path path, IIssueReporting issues) {
41+
return checksum(path, "MD5", "%032x", issues);
42+
}
43+
44+
static String sha512(Path path, IIssueReporting issues) {
45+
return checksum(path, "SHA-512", "%0128x", issues);
46+
}
47+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package dev.latvian.mods.packsync;
2+
3+
import com.google.gson.JsonObject;
4+
import net.neoforged.neoforgespi.IIssueReporting;
5+
6+
import java.nio.file.Path;
7+
8+
public record FileInfo(
9+
String checksum,
10+
String filename,
11+
long size,
12+
String artifact,
13+
String version
14+
) {
15+
public FileInfo(JsonObject json) {
16+
this(
17+
json.get("checksum").getAsString(),
18+
json.get("filename").getAsString(),
19+
json.get("size").getAsLong(),
20+
json.has("artifact") ? json.get("artifact").getAsString() : "",
21+
json.has("version") ? json.get("version").getAsString() : ""
22+
);
23+
}
24+
25+
public FileInfo(String filename, long size) {
26+
this("", filename, size, "", "");
27+
}
28+
29+
public boolean isEqual(Path path, IIssueReporting issues) {
30+
return size == PackSync.size(path) && checksum.equals(Checksum.md5(path, issues));
31+
}
32+
33+
public void toJson(JsonObject json) {
34+
json.addProperty("checksum", checksum);
35+
json.addProperty("filename", filename);
36+
json.addProperty("size", size);
37+
38+
if (!artifact.isEmpty()) {
39+
json.addProperty("artifact", artifact);
40+
}
41+
42+
if (!version.isEmpty()) {
43+
json.addProperty("version", version);
44+
}
45+
}
46+
}

src/main/java/dev/latvian/mods/packsync/KnownFile.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)