experimental 1.7.10 fixes, improved version comparison in update checker
This commit is contained in:
parent
6a77fbc3f3
commit
82c550f37f
|
@ -35,7 +35,6 @@ minecraft {
|
|||
srgExtra "PK: kotlin matterlink/repack/kotlin"
|
||||
srgExtra "PK: org/jetbrains/annotations matterlink/repack/org/jetbrains/annotations"
|
||||
srgExtra "PK: com/google/gson matterlink/repack/com/google/gson"
|
||||
srgExtra "PK: org/apache/commons matterlink/repack/org/apache/commons"
|
||||
srgExtra "PK: org/apache/http matterlink/repack/org/apache/http"
|
||||
srgExtra "PK: org/intelij matterlink/repack/org/intelij"
|
||||
}
|
||||
|
|
|
@ -16,14 +16,20 @@ class UpdateChecker : Runnable {
|
|||
override fun run() {
|
||||
val gson = Gson()
|
||||
|
||||
val currentModVersion = instance.modVersion
|
||||
val currentMCVersion = instance.mcVersion
|
||||
val currentVersion = currentMCVersion + "-" + currentModVersion
|
||||
|
||||
instance.info("Checking for new versions...")
|
||||
|
||||
if (instance.modVersion.endsWith("-dev")) {
|
||||
|
||||
}
|
||||
|
||||
val client: HttpClient = HttpClients.createDefault()
|
||||
val response: HttpResponse = client.execute(HttpGet("http://bit.ly/matterlinkfiles"))
|
||||
val request = HttpGet("https://goo.gl/5CMc1N")
|
||||
|
||||
with(instance) {
|
||||
request.setHeader("User-Agent", "Minecraft/$mcVersion MatterLink/$modVersion")
|
||||
}
|
||||
|
||||
val response: HttpResponse = client.execute(request)
|
||||
val apiUpdateList = if (200 == response.statusLine.statusCode) { //HTTP 200 OK
|
||||
val buffer: BufferedReader = response.entity.content.bufferedReader()
|
||||
|
||||
|
@ -33,7 +39,7 @@ class UpdateChecker : Runnable {
|
|||
|
||||
gson.fromJson(content, Array<CurseFile>::class.java)
|
||||
.filter {
|
||||
it.gameVersion.contains(currentMCVersion)
|
||||
it.gameVersion.contains(instance.mcVersion)
|
||||
}
|
||||
.sortedByDescending { it.fileName.substringAfterLast(" ") }
|
||||
|
||||
|
@ -42,12 +48,29 @@ class UpdateChecker : Runnable {
|
|||
return
|
||||
}
|
||||
|
||||
val modVersionChunks = instance.modVersion
|
||||
.replace("-dev", "")
|
||||
.split('.')
|
||||
.map {
|
||||
it.toInt()
|
||||
}
|
||||
|
||||
val possibleUpdates = mutableListOf<CurseFile>()
|
||||
apiUpdateList.forEach {
|
||||
instance.debug(it.toString())
|
||||
val version = it.fileName.substringAfter("-")
|
||||
if(version > currentModVersion)
|
||||
{
|
||||
val version = it.fileName.substringAfterLast("-").split('.').map { it.toInt() }
|
||||
var bigger = false
|
||||
version.forEachIndexed { index, chunk ->
|
||||
if (!bigger) {
|
||||
val currentChunk = modVersionChunks.getOrNull(index) ?: 0
|
||||
instance.debug("$chunk > $currentChunk")
|
||||
if(chunk < currentChunk)
|
||||
return@forEach
|
||||
|
||||
bigger = chunk > currentChunk
|
||||
}
|
||||
}
|
||||
if (bigger) {
|
||||
possibleUpdates += it
|
||||
}
|
||||
}
|
||||
|
@ -57,16 +80,16 @@ class UpdateChecker : Runnable {
|
|||
possibleUpdates.sortByDescending { it.fileName.substringAfter(" ") }
|
||||
val count = possibleUpdates.count()
|
||||
val version = if (count == 1) "version" else "versions"
|
||||
|
||||
instance.info("Matterlink out of date! You are $count $version behind")
|
||||
possibleUpdates.forEach {
|
||||
instance.info("version: {} download: {}", it.fileName, it.downloadURL)
|
||||
}
|
||||
|
||||
instance.warn("Mod out of date! New $version available at ${latest.downloadURL}")
|
||||
MessageHandler.transmit(ApiMessage(
|
||||
username = cfg.relay.systemUser,
|
||||
text = "Matterlink out of date! You are $count $version behind! Please download new version from ${latest.downloadURL}"
|
||||
))
|
||||
// MessageHandler.transmit(ApiMessage(
|
||||
// username = cfg.relay.systemUser,
|
||||
// text = "Matterlink out of date! You are $count $version behind! Please download new version from ${latest.downloadURL}"
|
||||
// ))
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
mod_name = MatterLink
|
||||
mod_version = 1.4.3
|
||||
mod_version = 1.4.4
|
||||
forgelin_version = 1.6.0
|
Loading…
Reference in New Issue