Created
January 16, 2021 06:34
-
-
Save dexman545/2bff5caf7caaaba6d3aa6add5b13d3a7 to your computer and use it in GitHub Desktop.
(Almost) Lazy Man's https://modmuss50.me/fabric.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the newest available loader version. | |
* | |
* @return loader version. | |
*/ | |
static String getNewestLoaderVersion() { | |
def loaderVersions = new JsonSlurper().parse(new URL("https://meta.fabricmc.net/v2/versions/loader/")) | |
assert loaderVersions instanceof ArrayList<LinkedHashMap> // Type check to to remove visual errors | |
return loaderVersions.first().version | |
} | |
/** | |
* Get correct Yarn version for project's MC version. | |
* | |
* @param newest whether to return the newest available Yarn version, or the oldest. Oldest may be preferred to avoid | |
* invalidating genSources' output. | |
* @return the correct Yarn version. | |
*/ | |
String getChosenYarnVersion(boolean newest) { | |
def yarnVersions = new JsonSlurper().parse( | |
new URL("https://meta.fabricmc.net/v2/versions/yarn/${project.minecraft_version}")) | |
assert yarnVersions instanceof ArrayList<LinkedHashMap> // Type check to to remove visual errors | |
return newest ? yarnVersions.first().version : yarnVersions.last().version | |
} | |
/** | |
* Get the latest MC version. | |
* | |
* @param isStable if snapshots should be ignored or not. | |
* @return the MC version. | |
*/ | |
static String getLatestMc(boolean isStable) { | |
def mcVersions = new JsonSlurper().parse(new URL("https://meta.fabricmc.net/v2/versions/game")) | |
assert mcVersions instanceof ArrayList<LinkedHashMap> // Type check to to remove visual errors | |
if (!isStable) return mcVersions.first().version | |
for (LinkedHashMap mcVer : mcVersions) { | |
if (mcVer.stable) return mcVer.version | |
} | |
} | |
/** | |
* Get latest Mod Menu version from Fabric's maven. Not keyed to MC version. | |
* | |
* @return mod menu version. | |
*/ | |
// I got tired of having to find the right version, ok? | |
static String getLatestModMenu() { | |
def modMenuVersions = new XmlSlurper().parseText( | |
new URL("https://maven.fabricmc.net/io/github/prospector/modmenu/maven-metadata.xml").text) | |
// For some reason Groovy was not happy with accessing it as a map, so this nonsense exists | |
def x = modMenuVersions.getProperty('versioning') | |
return x['latest'] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment