2024-06-05 16:42:57 -04:00
|
|
|
---
|
|
|
|
title: Mod Template Generator
|
|
|
|
sidebar: false
|
|
|
|
prev: false
|
|
|
|
next: false
|
|
|
|
editLink: false
|
|
|
|
lastUpdated: false
|
2024-06-08 12:12:21 -04:00
|
|
|
outline: false
|
2024-06-05 16:42:57 -04:00
|
|
|
---
|
|
|
|
|
|
|
|
<!-- This is a mess! Someone improve this please. -->
|
|
|
|
<script setup>
|
2024-06-08 11:27:05 -04:00
|
|
|
import JSZip from 'jszip'
|
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
|
import { saveAs } from 'file-saver'
|
2024-06-09 08:00:37 -04:00
|
|
|
const assetBaseUrl = "/resources/template"
|
2024-06-08 11:27:05 -04:00
|
|
|
const showSnapshots = ref()
|
2024-06-05 16:42:57 -04:00
|
|
|
const versionSelector = ref()
|
2024-06-08 11:27:05 -04:00
|
|
|
const modIdRef = ref()
|
|
|
|
const modNameRef = ref()
|
|
|
|
const mavenGroupRef = ref()
|
|
|
|
const licenseRef = ref()
|
2024-06-09 07:08:01 -04:00
|
|
|
const useSnapshots = ref()
|
2024-06-08 11:27:05 -04:00
|
|
|
let releases = []
|
|
|
|
let snapshots = []
|
|
|
|
let versions = []
|
|
|
|
let latestLoader
|
|
|
|
let latestPhytotelma
|
2024-06-09 07:08:01 -04:00
|
|
|
let latestLoaderSnapshot
|
|
|
|
let latestPhytotelmaSnapshot
|
2024-06-05 16:42:57 -04:00
|
|
|
|
|
|
|
async function getGameVersions() {
|
|
|
|
const response = await fetch("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json")
|
|
|
|
return await response.json()
|
|
|
|
}
|
2024-06-08 11:27:05 -04:00
|
|
|
|
|
|
|
function getVersions() {
|
|
|
|
versionSelector.value.innerHTML = ""
|
|
|
|
|
|
|
|
for (let version of releases) {
|
2024-06-09 07:08:01 -04:00
|
|
|
versionSelector.value.innerHTML += "<option value=\""+version.id+"\">"+version.id+"</option>"
|
2024-06-08 11:27:05 -04:00
|
|
|
}
|
|
|
|
if (showSnapshots.value) {
|
|
|
|
for (let version of snapshots) {
|
|
|
|
versionSelector.value.innerHTML += "<option value=\""+version.id+"\">"+version.id+"</option>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-06-05 16:42:57 -04:00
|
|
|
|
2024-06-08 11:27:05 -04:00
|
|
|
onMounted(() => {
|
|
|
|
getGameVersions().then((v) => {
|
|
|
|
versions = v.versions
|
|
|
|
for (let version of versions){
|
|
|
|
if (version.type === "snapshot"){
|
|
|
|
snapshots.push(version)
|
|
|
|
} else {
|
|
|
|
releases.push(version)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getVersions()
|
|
|
|
})
|
|
|
|
getLatestProjectVersions()
|
2024-06-05 16:42:57 -04:00
|
|
|
})
|
|
|
|
|
2024-06-08 11:27:05 -04:00
|
|
|
function getLatestProjectVersions() {
|
2024-06-09 07:08:01 -04:00
|
|
|
fetchVersionFromMaven("releases", "frogloader").then((v) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
latestLoader = v
|
2024-06-09 07:08:01 -04:00
|
|
|
document.getElementById("frogLoaderVersionReleaseBadge").innerHTML = v
|
|
|
|
}).catch((err) => {
|
|
|
|
document.getElementById("frogLoaderVersionReleaseBadge").innerHTML = "No version found!"
|
2024-06-08 11:27:05 -04:00
|
|
|
})
|
2024-06-09 07:08:01 -04:00
|
|
|
fetchVersionFromMaven("releases", "phytotelma").then((v) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
latestPhytotelma = v
|
2024-06-09 07:08:01 -04:00
|
|
|
document.getElementById("phytotelmaVersionReleaseBadge").innerHTML = v
|
|
|
|
}).catch((err) => {
|
|
|
|
document.getElementById("phytotelmaVersionReleaseBadge").innerHTML = "No version found!"
|
|
|
|
})
|
|
|
|
fetchVersionFromMaven("snapshots", "frogloader").then((v) => {
|
|
|
|
latestLoaderSnapshot = v
|
|
|
|
document.getElementById("frogLoaderVersionSnapshotBadge").innerHTML = v
|
|
|
|
})
|
|
|
|
fetchVersionFromMaven("snapshots", "phytotelma").then((v) => {
|
|
|
|
latestPhytotelmaSnapshot = v
|
|
|
|
document.getElementById("phytotelmaVersionSnapshotBadge").innerHTML = v
|
2024-06-08 11:27:05 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchVersionFromMaven(repository, name) {
|
|
|
|
const response = await fetch("https://maven.frogmc.dev/"+repository+"/dev/frogmc/"+name+"/maven-metadata.xml")
|
|
|
|
const text = await response.text()
|
|
|
|
const parser = new DOMParser()
|
|
|
|
const doc = parser.parseFromString(text, "text/xml")
|
|
|
|
return doc.getElementsByTagName("latest")[0].textContent
|
|
|
|
}
|
|
|
|
|
|
|
|
function generate() {
|
2024-06-09 07:08:01 -04:00
|
|
|
let missing = []
|
|
|
|
if (modIdRef.value === undefined) {
|
|
|
|
missing.push("Mod ID")
|
|
|
|
}
|
|
|
|
if (modNameRef.value === undefined) {
|
|
|
|
missing.push("Mod Name")
|
|
|
|
}
|
|
|
|
if (mavenGroupRef.value === undefined) {
|
|
|
|
missing.push("Maven Group")
|
|
|
|
}
|
|
|
|
if (licenseRef.value === undefined) {
|
|
|
|
missing.push("License")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (missing.length > 0) {
|
|
|
|
let html = "<div class=\"danger custom-block\"><p class=\"custom-block-title\">Missing Inputs</p><p>"
|
|
|
|
html += missing.join("</p><p>")
|
|
|
|
html += "</p></div>"
|
|
|
|
document.getElementById("missingBox").innerHTML = html
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-06-08 11:27:05 -04:00
|
|
|
let zip = JSZip()
|
|
|
|
|
|
|
|
let gradle = zip.folder("gradle")
|
|
|
|
let wrapper = gradle.folder("wrapper")
|
|
|
|
let promises = []
|
|
|
|
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAsset("/gradle/libs.versions.toml").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
gradle.file("libs.versions.toml", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAssetBinary("/gradle/wrapper/gradle-wrapper.properties").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
wrapper.file("gradle-wrapper.properties", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAssetBinary("/gradle/wrapper/gradle-wrapper.jar").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
wrapper.file("gradle-wrapper.jar", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAsset("/.gitignore").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
zip.file(".gitignore", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAsset("/build.gradle.kts").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
zip.file("build.gradle.kts", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAssetBinary("/gradlew.sh").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
zip.file("gradlew", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAssetBinary("/gradlew.bat").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
zip.file("gradlew.bat", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAsset("/build.gradle.kts").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
zip.file("build.gradle.kts", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAsset("/settings.gradle.kts").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
zip.file("settings.gradle.kts", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
let src = zip.folder("src")
|
|
|
|
let main = src.folder("main")
|
|
|
|
let java = main.folder("java")
|
|
|
|
let resources = main.folder("resources")
|
2024-06-09 07:08:01 -04:00
|
|
|
let classes = java
|
|
|
|
for (let part of mavenGroupRef.value.split(/\\./g)) {
|
|
|
|
classes = classes.folder(part)
|
|
|
|
}
|
|
|
|
const classFileName = modNameRef.value.replaceAll(" ", "")
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAsset("/src/main/java/Main.java").then((data) => {
|
2024-06-09 07:08:01 -04:00
|
|
|
classes.file(classFileName+"Main", data)
|
|
|
|
})
|
|
|
|
)
|
2024-06-08 11:27:05 -04:00
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAsset("/src/main/resources/frog.mod.toml").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
resources.file("frog.mod.toml", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
promises.push(
|
2024-06-09 08:00:37 -04:00
|
|
|
readAsset("/src/main/resources/example_mod.mixins.json").then((data) => {
|
2024-06-08 11:27:05 -04:00
|
|
|
resources.file(modIdRef.value+".mixins.json", data)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
Promise.all(promises).then((values) => {
|
|
|
|
zip.generateAsync({type:"blob"}).then(function (blob) {
|
|
|
|
saveAs(blob, modIdRef.value+"_template.zip")
|
|
|
|
}, function (err) {
|
|
|
|
alert("Failed to download generated zip file, please report this!")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async function readAssetBinary(path) {
|
2024-06-08 12:12:21 -04:00
|
|
|
const response = await fetch(assetBaseUrl+path)
|
2024-06-08 11:27:05 -04:00
|
|
|
return await response.blob()
|
|
|
|
}
|
|
|
|
|
|
|
|
async function readAsset(path){
|
2024-06-08 12:12:21 -04:00
|
|
|
const response = await fetch(assetBaseUrl+path)
|
2024-06-08 11:27:05 -04:00
|
|
|
return await response.text().then((data) => {
|
2024-06-09 07:08:01 -04:00
|
|
|
data = data.replaceAll("$mod_id", modIdRef.value)
|
2024-06-09 07:09:19 -04:00
|
|
|
data = data.replaceAll("$mod_name_pascal", modNameRef.value.replaceAll(" ", ""))
|
2024-06-09 07:08:01 -04:00
|
|
|
data = data.replaceAll("$mod_name", modNameRef.value)
|
|
|
|
data = data.replaceAll("$maven_group", mavenGroupRef.value)
|
|
|
|
data = data.replaceAll("$license", licenseRef.value)
|
|
|
|
data = data.replaceAll("$loader_version", useSnapshots.value ? latestLoaderSnapshot : latestLoader)
|
2024-06-09 08:00:37 -04:00
|
|
|
data = data.replaceAll("$phytotelma_version", useSnapshots.value ? latestPhytotelmaSnapshot : latestPhytotelma)
|
2024-06-09 07:08:01 -04:00
|
|
|
data = data.replaceAll("$game_version", versionSelector.value.value)
|
2024-06-08 11:27:05 -04:00
|
|
|
return data
|
|
|
|
})
|
|
|
|
}
|
2024-06-09 08:00:37 -04:00
|
|
|
|
|
|
|
function inputsChanged() {
|
|
|
|
document.getElementById("missingBox").innerHTML = ""
|
2024-06-08 11:27:05 -04:00
|
|
|
}
|
2024-06-09 08:00:37 -04:00
|
|
|
</script>
|
2024-06-05 16:42:57 -04:00
|
|
|
|
|
|
|
# {{ $frontmatter.title }}
|
|
|
|
|
2024-06-08 11:27:05 -04:00
|
|
|
## Inputs
|
2024-06-05 16:42:57 -04:00
|
|
|
|
2024-06-08 11:27:05 -04:00
|
|
|
<div id="inputs">
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
2024-06-09 08:00:37 -04:00
|
|
|
<td>Mod ID</td>
|
|
|
|
<td><input v-model="modIdRef" @input="inputsChanged" /></td>
|
2024-06-08 11:27:05 -04:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Mod Name</td>
|
2024-06-09 08:00:37 -04:00
|
|
|
<td><input v-model="modNameRef" @input="inputsChanged" /></td>
|
2024-06-08 11:27:05 -04:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Maven Group</td>
|
2024-06-09 08:00:37 -04:00
|
|
|
<td><input v-model="mavenGroupRef" @input="inputsChanged" /></td>
|
2024-06-08 11:27:05 -04:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>License (SPDX)</td>
|
2024-06-09 08:00:37 -04:00
|
|
|
<td><input v-model="licenseRef" @input="inputsChanged" /></td>
|
2024-06-08 11:27:05 -04:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2024-06-09 07:08:01 -04:00
|
|
|
<td>Minecraft Version</td>
|
2024-06-08 11:27:05 -04:00
|
|
|
<td>
|
2024-06-09 07:08:01 -04:00
|
|
|
<select ref="versionSelector">
|
2024-06-08 11:27:05 -04:00
|
|
|
<option value="loading">Loading Versions...</option>
|
|
|
|
</select>
|
2024-06-09 07:08:01 -04:00
|
|
|
<input type="checkbox" v-model="showSnapshots" @change="getVersions">Show Snapshots</input>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Library Versions</td>
|
|
|
|
<td>
|
|
|
|
<input type="checkbox" v-model="useSnapshots">Use Snapshots (Beta Versions)</input>
|
2024-06-08 11:27:05 -04:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2024-06-09 07:08:01 -04:00
|
|
|
<div id="missingBox"></div>
|
2024-06-09 08:00:37 -04:00
|
|
|
<button @click="generate">Download</button>
|
2024-06-08 11:27:05 -04:00
|
|
|
</div>
|
2024-06-05 16:42:57 -04:00
|
|
|
|
2024-06-08 11:27:05 -04:00
|
|
|
## Latest Versions
|
2024-06-05 16:42:57 -04:00
|
|
|
|
2024-06-09 07:08:01 -04:00
|
|
|
[FrogLoader](/contributing/tools.md#frogloader) <Badge type="tip" id="frogLoaderVersionReleaseBadge">Loading Release...</Badge> <Badge type="warning" id="frogLoaderVersionSnapshotBadge">Loading Snapshot...</Badge>
|
2024-06-05 16:42:57 -04:00
|
|
|
|
2024-06-09 07:08:01 -04:00
|
|
|
[Phytotelma](/contributing/tools.md#phytotelma) <Badge type="tip" id="phytotelmaVersionReleaseBadge">Loading Release...</Badge> <Badge type="warning" id="phytotelmaVersionSnapshotBadge">Loading Snapshot...</Badge>
|
2024-06-05 16:42:57 -04:00
|
|
|
|