feat: commit local changes

This commit is contained in:
Timo Ley 2023-08-02 19:18:59 +02:00
parent cab557e439
commit 16974c03c6
6 changed files with 26 additions and 14 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
.gradle .gradle
.idea .idea
bin
build build
src/test src/test

View file

@ -4,7 +4,7 @@ plugins {
} }
group 'ley.modding' group 'ley.modding'
version '1.0' version '1.1.0'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
@ -15,7 +15,7 @@ repositories {
name "minecraft" name "minecraft"
} }
maven { maven {
url "https://data.tilera.xyz/maven/" url "https://maven.tilera.xyz/"
} }
} }

0
gradlew vendored Normal file → Executable file
View file

View file

@ -1,2 +1,8 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}
rootProject.name = 'testcraftupdate' rootProject.name = 'testcraftupdate'

View file

@ -37,23 +37,28 @@ public class UpdateTweaker implements ITweaker {
try { try {
File configfile = new File(gameDir.getAbsolutePath() + "/pack.json"); File configfile = new File(gameDir.getAbsolutePath() + "/pack.json");
if (configfile.exists()) { if (configfile.exists()) {
boolean updated = false;
Config config = Util.getConfig(configfile); Config config = Util.getConfig(configfile);
Version version = Util.checkVersion(config); Version version = Util.checkVersion(config);
if (version.isLatest()) if (!version.isLatest()) {
return; System.out.println(version.current + " is outdated, starting update...");
System.out.println(version.current + " is outdated, starting update..."); AddonscriptJSON oldAS = config.getAPI().getASFromTag(version.current);
AddonscriptJSON oldAS = config.getAPI().getASFromTag(version.current); AddonscriptJSON newAS = config.getAPI().getASFromTag(version.latest);
AddonscriptJSON newAS = config.getAPI().getASFromTag(version.latest); List<RelationFile> oldRel = Util.getRelations(oldAS);
List<RelationFile> oldRel = Util.getRelations(oldAS); List<RelationFile> newRel = Util.getRelations(newAS);
List<RelationFile> newRel = Util.getRelations(newAS); FileHandler handler = new FileHandler(gameDir);
FileHandler handler = new FileHandler(gameDir); handler.removeFiles(Util.getToRemove(oldRel, newRel));
handler.removeFiles(Util.getToRemove(oldRel, newRel)); handler.addFiles(Util.getToAdd(oldRel, newRel));
handler.addFiles(Util.getToAdd(oldRel, newRel)); handler.processOverrides(version.overrides, newAS, config);
handler.processOverrides(version.overrides, newAS, config); updated = true;
}
config.version = version.latest; config.version = version.latest;
FileWriter writer = new FileWriter(configfile); FileWriter writer = new FileWriter(configfile);
config.toJson(writer); config.toJson(writer);
writer.close(); writer.close();
if (updated) {
throw new RuntimeException("Successfully updated modpack. Please restart the game.");
}
} }
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);

View file

@ -13,7 +13,7 @@ public class Version {
} }
public boolean isLatest() { public boolean isLatest() {
return latest.equals(current); return current == null || latest.equals(current);
} }
} }