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
.idea
bin
build
src/test

View File

@ -4,7 +4,7 @@ plugins {
}
group 'ley.modding'
version '1.0'
version '1.1.0'
sourceCompatibility = 1.8
@ -15,7 +15,7 @@ repositories {
name "minecraft"
}
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'

View File

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

View File

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