fix some bugs, add main entrypoint in template
This commit is contained in:
parent
c033a05d8c
commit
fe222d7e7a
|
@ -8,7 +8,11 @@ Insert section about the installer here
|
|||
|
||||
## Third-Party Launchers
|
||||
|
||||
### PrismLauncher
|
||||
|
||||
### PrismLauncher/MultiMC
|
||||
|
||||
*put an instance generator here*
|
||||
|
||||
|
||||
Add an instance generator to the installer and describe it here\
|
||||
**or**\
|
||||
|
|
17
public/resources/template/src/main/java/Main.java
Normal file
17
public/resources/template/src/main/java/Main.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package $maven_group.$mod_id;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import dev.frogmc.froglib.entrypoints.MainExtension;
|
||||
import dev.frogmc.frogloader.api.mod.ModProperties;
|
||||
|
||||
public class $mod_name_pascalMain implements MainExtension {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("$mod_name");
|
||||
|
||||
@Override
|
||||
public void onInit(ModProperties self){
|
||||
LOGGER.info("Hello World!");
|
||||
}
|
||||
}
|
|
@ -11,10 +11,11 @@ credits = [
|
|||
]
|
||||
|
||||
[frog.dependencies]
|
||||
depends = {
|
||||
{ "id" = "minecraft", versions = "~$game_version", name = "Minecraft", link = "https://minecraft.net" }
|
||||
depends = [
|
||||
{ "id" = "minecraft", versions = "~$game_version", name = "Minecraft", link = "https://minecraft.net" },
|
||||
{ "id" = "frogloader", versions = ">=$loader_version", name = "Frog Loader", link = "https://frogmc.dev" }
|
||||
}
|
||||
]
|
||||
|
||||
[frog.extensions]
|
||||
mixin_config = "$mod_id.mixins.json"
|
||||
main = "$maven_group.$mod_name_pascalMain"
|
||||
|
|
97
template.md
97
template.md
|
@ -6,10 +6,6 @@ next: false
|
|||
editLink: false
|
||||
lastUpdated: false
|
||||
outline: false
|
||||
head:
|
||||
- - meta
|
||||
- property: Access-Control-Allow-Origin
|
||||
content: https://git.frogmc.dev/
|
||||
---
|
||||
|
||||
<!-- This is a mess! Someone improve this please. -->
|
||||
|
@ -18,18 +14,20 @@ head:
|
|||
import { ref, onMounted } from 'vue'
|
||||
import { saveAs } from 'file-saver'
|
||||
const assetBaseUrl = "/resources"
|
||||
const gameVersion = ref()
|
||||
const showSnapshots = ref()
|
||||
const versionSelector = ref()
|
||||
const modIdRef = ref()
|
||||
const modNameRef = ref()
|
||||
const mavenGroupRef = ref()
|
||||
const licenseRef = ref()
|
||||
const useSnapshots = ref()
|
||||
let releases = []
|
||||
let snapshots = []
|
||||
let versions = []
|
||||
let latestLoader
|
||||
let latestPhytotelma
|
||||
let latestLoaderSnapshot
|
||||
let latestPhytotelmaSnapshot
|
||||
|
||||
async function getGameVersions() {
|
||||
const response = await fetch("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json")
|
||||
|
@ -40,7 +38,7 @@ head:
|
|||
versionSelector.value.innerHTML = ""
|
||||
|
||||
for (let version of releases) {
|
||||
versionSelector.value.innerHTML += "<option value=\""+version.id+"\">"+version.id+"</option>"
|
||||
versionSelector.value.innerHTML += "<option value=\""+version.id+"\">"+version.id+"</option>"
|
||||
}
|
||||
if (showSnapshots.value) {
|
||||
for (let version of snapshots) {
|
||||
|
@ -65,13 +63,25 @@ head:
|
|||
})
|
||||
|
||||
function getLatestProjectVersions() {
|
||||
fetchVersionFromMaven("snapshots", "frogloader").then((v) => {
|
||||
fetchVersionFromMaven("releases", "frogloader").then((v) => {
|
||||
latestLoader = v
|
||||
document.getElementById("frogLoaderVersionBadge").innerHTML = v
|
||||
document.getElementById("frogLoaderVersionReleaseBadge").innerHTML = v
|
||||
}).catch((err) => {
|
||||
document.getElementById("frogLoaderVersionReleaseBadge").innerHTML = "No version found!"
|
||||
})
|
||||
fetchVersionFromMaven("releases", "phytotelma").then((v) => {
|
||||
latestPhytotelma = v
|
||||
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) => {
|
||||
latestPhytotelma = v
|
||||
document.getElementById("phytotelmaVersionBadge").innerHTML = v
|
||||
latestPhytotelmaSnapshot = v
|
||||
document.getElementById("phytotelmaVersionSnapshotBadge").innerHTML = v
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -84,6 +94,28 @@ head:
|
|||
}
|
||||
|
||||
function generate() {
|
||||
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
|
||||
}
|
||||
|
||||
let zip = JSZip()
|
||||
|
||||
let gradle = zip.folder("gradle")
|
||||
|
@ -139,6 +171,16 @@ head:
|
|||
let main = src.folder("main")
|
||||
let java = main.folder("java")
|
||||
let resources = main.folder("resources")
|
||||
let classes = java
|
||||
for (let part of mavenGroupRef.value.split(/\\./g)) {
|
||||
classes = classes.folder(part)
|
||||
}
|
||||
const classFileName = modNameRef.value.replaceAll(" ", "")
|
||||
promises.push(
|
||||
readAsset("/template/src/main/java/Main.java").then((data) => {
|
||||
classes.file(classFileName+"Main", data)
|
||||
})
|
||||
)
|
||||
promises.push(
|
||||
readAsset("/template/src/main/resources/frog.mod.toml").then((data) => {
|
||||
resources.file("frog.mod.toml", data)
|
||||
|
@ -167,13 +209,14 @@ head:
|
|||
async function readAsset(path){
|
||||
const response = await fetch(assetBaseUrl+path)
|
||||
return await response.text().then((data) => {
|
||||
data = data.replace(/\\$mod_id/g, modIdRef.value)
|
||||
data = data.replace(/\\$mod_name/g, modNameRef.value)
|
||||
data = data.replace(/\\$maven_group/g, mavenGroupRef.value)
|
||||
data = data.replace(/\\$license/g, licenseRef.value)
|
||||
data = data.replace(/\\$loader_version/g, latestLoader)
|
||||
data = data.replace(/\\$phytotelma_version/g, latestPhytotelma)
|
||||
data = data.replace(/\\$game_version/g, versionSelector.value.selected)
|
||||
data = data.replaceAll("$mod_id", modIdRef.value)
|
||||
data = data.replaceAll("$mod_name_pascal", modNameRef.value.replaceAll(" ", "")
|
||||
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)
|
||||
data = data.replaceAll("$phytotelma_version", latestPhytotelma)
|
||||
data = data.replaceAll("$game_version", versionSelector.value.value)
|
||||
return data
|
||||
})
|
||||
}
|
||||
|
@ -203,7 +246,6 @@ head:
|
|||
}
|
||||
.generate {
|
||||
padding: 4px;
|
||||
//border: 4px solid var(--vp-c-brand-soft);
|
||||
border-radius: 14px;
|
||||
}
|
||||
</style>
|
||||
|
@ -232,22 +274,29 @@ head:
|
|||
<td><input v-model="licenseRef" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Version</td>
|
||||
<td>Minecraft Version</td>
|
||||
<td>
|
||||
<select v-model="gameVersion" ref="versionSelector">
|
||||
<select ref="versionSelector">
|
||||
<option value="loading">Loading Versions...</option>
|
||||
</select>
|
||||
<input type="checkbox" v-model="showSnapshots" @change="getVersions">Show snapshots</input>
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button class="generate" @click="generate">Generate</button>
|
||||
<div id="missingBox"></div>
|
||||
<button class="generate" @click="generate">Download</button>
|
||||
</div>
|
||||
|
||||
## Latest Versions
|
||||
|
||||
[FrogLoader](/contributing/tools.md#frogloader) <Badge type="tip" id="frogLoaderVersionBadge">Loading...</Badge>
|
||||
[FrogLoader](/contributing/tools.md#frogloader) <Badge type="tip" id="frogLoaderVersionReleaseBadge">Loading Release...</Badge> <Badge type="warning" id="frogLoaderVersionSnapshotBadge">Loading Snapshot...</Badge>
|
||||
|
||||
[Phytotelma](/contributing/tools.md#phytotelma) <Badge type="tip" id="phytotelmaVersionBadge">Loading...</Badge>
|
||||
[Phytotelma](/contributing/tools.md#phytotelma) <Badge type="tip" id="phytotelmaVersionReleaseBadge">Loading Release...</Badge> <Badge type="warning" id="phytotelmaVersionSnapshotBadge">Loading Snapshot...</Badge>
|
||||
|
||||
|
|
Loading…
Reference in a new issue