Skip to content

Commit

Permalink
Fixed ${version} bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksilassila committed Dec 17, 2022
1 parent c8a8c7e commit 970eb37
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: ./**/build/*.jar
path: ./**/build/libs/*.jar
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=false
# Mod Properties
mod_version=3.1
mod_version=3.2
maven_group=net.fabricmc
archives_base_name=litematica-printer
11 changes: 11 additions & 0 deletions v1_17/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ val malilib_version: String by project
val litematica_projectid: String by project
val litematica_fileid: String by project

val mod_version: String by project

dependencies {
// implementation(project(":common"))
minecraft("com.mojang:minecraft:${minecraft_version}")
Expand All @@ -31,6 +33,15 @@ repositories {
maven("https://www.cursemaven.com")
}

// Process resources
tasks.withType<ProcessResources> {
inputs.property("version", mod_version)

filesMatching("fabric.mod.json") {
expand(mapOf("version" to mod_version))
}
}

val sourceModule = "v1_17"
val targetModules = arrayOf("v1_19", "v1_18", "v1_19_3")

Expand Down
11 changes: 11 additions & 0 deletions v1_18/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ val malilib_version: String by project
val litematica_projectid: String by project
val litematica_fileid: String by project

val mod_version: String by project

dependencies {
// implementation(project(":common"))
minecraft("com.mojang:minecraft:${minecraft_version}")
Expand All @@ -31,6 +33,15 @@ repositories {
maven("https://www.cursemaven.com")
}

// Process resources
tasks.withType<ProcessResources> {
inputs.property("version", mod_version)

filesMatching("fabric.mod.json") {
expand(mapOf("version" to mod_version))
}
}

val sourceModule = "v1_18"
val targetModules = arrayOf("v1_19", "v1_19_3", "v1_17")

Expand Down
11 changes: 11 additions & 0 deletions v1_19/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ val malilib_version: String by project
val litematica_projectid: String by project
val litematica_fileid: String by project

val mod_version: String by project

dependencies {
// implementation(project(":common"))
minecraft("com.mojang:minecraft:${minecraft_version}")
Expand All @@ -31,6 +33,15 @@ repositories {
maven("https://www.cursemaven.com")
}

// Process resources
tasks.withType<ProcessResources> {
inputs.property("version", mod_version)

filesMatching("fabric.mod.json") {
expand(mapOf("version" to mod_version))
}
}

val sourceModule = "v1_19"
val targetModules = arrayOf("v1_19_3", "v1_18", "v1_17")

Expand Down
11 changes: 11 additions & 0 deletions v1_19_3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ val malilib_version: String by project
val litematica_projectid: String by project
val litematica_fileid: String by project

val mod_version: String by project

dependencies {
// implementation(project(":common"))
minecraft("com.mojang:minecraft:${minecraft_version}")
Expand All @@ -31,6 +33,15 @@ repositories {
maven("https://www.cursemaven.com")
}

// Process resources
tasks.withType<ProcessResources> {
inputs.property("version", mod_version)

filesMatching("fabric.mod.json") {
expand(mapOf("version" to mod_version))
}
}

val sourceModule = "v1_19_3"
val targetModules = arrayOf("v1_19", "v1_18", "v1_17")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import net.minecraft.world.RaycastContext;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,40 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.io.IOUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Scanner;

public class UpdateChecker {
public static final String version = "v3.1";
public static final String version = "v3.2";

// Try to get this to work at some point
// static {
// try (InputStream in = UpdateChecker.class.getResourceAsStream("/fabric.mod.json")) {
// String jsonString = IOUtils.toString(in, StandardCharsets.UTF_8);
// JsonObject json = JsonParser.parseString(jsonString).getAsJsonObject();
// System.out.println("JSON object: " + json);
// System.out.println("Raw json: " + jsonString);
// System.out.println("File: " + new File(UpdateChecker.class.getResource("/fabric.mod.json").getFile()));
// String version = json.get("version").getAsString();
// System.out.println("Reading fabric.mod.json");
// System.out.println("Parsed version: " + version);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }

public static String getPrinterVersion() {
try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) {
if (scanner.hasNext()) {
JsonArray tags = new JsonParser().parse(scanner.next()).getAsJsonArray();
JsonArray tags = JsonParser.parseString(scanner.next()).getAsJsonArray();
return ((JsonObject) tags.get(0)).get("name").getAsString();
}
} catch (Exception exception) {
Expand Down

0 comments on commit 970eb37

Please sign in to comment.