update update checker
This commit is contained in:
parent
4e8fba5725
commit
08affaf9ec
|
@ -5,6 +5,7 @@ import matterlink.command.CommandMatterlink
|
||||||
import matterlink.command.MatterLinkCommandSender
|
import matterlink.command.MatterLinkCommandSender
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.util.text.TextComponentString
|
||||||
|
import net.minecraftforge.common.ForgeVersion
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler
|
import net.minecraftforge.fml.common.FMLCommonHandler
|
||||||
import net.minecraftforge.fml.common.Mod
|
import net.minecraftforge.fml.common.Mod
|
||||||
import net.minecraftforge.fml.common.event.*
|
import net.minecraftforge.fml.common.event.*
|
||||||
|
@ -64,4 +65,5 @@ object MatterLink : IMatterLink() {
|
||||||
|
|
||||||
override val mcVersion: String = MCVERSION
|
override val mcVersion: String = MCVERSION
|
||||||
override val modVersion: String = MODVERSION
|
override val modVersion: String = MODVERSION
|
||||||
|
override val forgeVersion = ForgeVersion.getVersion()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import matterlink.command.CommandMatterlink
|
||||||
import matterlink.command.MatterLinkCommandSender
|
import matterlink.command.MatterLinkCommandSender
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.util.text.TextComponentString
|
||||||
|
import net.minecraftforge.common.ForgeVersion
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler
|
import net.minecraftforge.fml.common.FMLCommonHandler
|
||||||
import net.minecraftforge.fml.common.Mod
|
import net.minecraftforge.fml.common.Mod
|
||||||
import net.minecraftforge.fml.common.event.*
|
import net.minecraftforge.fml.common.event.*
|
||||||
|
@ -64,4 +65,5 @@ object MatterLink : IMatterLink() {
|
||||||
|
|
||||||
override val mcVersion: String = MCVERSION
|
override val mcVersion: String = MCVERSION
|
||||||
override val modVersion: String = MODVERSION
|
override val modVersion: String = MODVERSION
|
||||||
|
override val forgeVersion = ForgeVersion.getVersion()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import matterlink.command.CommandMatterlink
|
||||||
import matterlink.command.MatterLinkCommandSender
|
import matterlink.command.MatterLinkCommandSender
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.util.text.TextComponentString
|
||||||
|
import net.minecraftforge.common.ForgeVersion
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler
|
import net.minecraftforge.fml.common.FMLCommonHandler
|
||||||
import net.minecraftforge.fml.common.Mod
|
import net.minecraftforge.fml.common.Mod
|
||||||
import net.minecraftforge.fml.common.event.*
|
import net.minecraftforge.fml.common.event.*
|
||||||
|
@ -69,4 +70,5 @@ object MatterLink : IMatterLink() {
|
||||||
|
|
||||||
override val mcVersion: String = MCVERSION
|
override val mcVersion: String = MCVERSION
|
||||||
override val modVersion: String = MODVERSION
|
override val modVersion: String = MODVERSION
|
||||||
|
override val forgeVersion = ForgeVersion.getVersion()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import matterlink.command.MatterLinkCommandSender
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import net.minecraft.server.MinecraftServer
|
import net.minecraft.server.MinecraftServer
|
||||||
import net.minecraft.util.ChatComponentText
|
import net.minecraft.util.ChatComponentText
|
||||||
|
import net.minecraftforge.common.ForgeVersion
|
||||||
import net.minecraftforge.common.MinecraftForge
|
import net.minecraftforge.common.MinecraftForge
|
||||||
import org.apache.logging.log4j.Level
|
import org.apache.logging.log4j.Level
|
||||||
import org.apache.logging.log4j.Logger
|
import org.apache.logging.log4j.Logger
|
||||||
|
@ -66,4 +67,5 @@ class MatterLink : IMatterLink() {
|
||||||
|
|
||||||
override val mcVersion: String = MCVERSION
|
override val mcVersion: String = MCVERSION
|
||||||
override val modVersion: String = MODVERSION
|
override val modVersion: String = MODVERSION
|
||||||
|
override val forgeVersion = ForgeVersion.getVersion()
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ lateinit var instance: IMatterLink
|
||||||
abstract class IMatterLink {
|
abstract class IMatterLink {
|
||||||
abstract val mcVersion: String
|
abstract val mcVersion: String
|
||||||
abstract val modVersion: String
|
abstract val modVersion: String
|
||||||
|
abstract val forgeVersion: String
|
||||||
|
|
||||||
abstract fun commandSenderFor(user: String, userId: String, server: String): IMinecraftCommandSender
|
abstract fun commandSenderFor(user: String, userId: String, server: String): IMinecraftCommandSender
|
||||||
|
|
||||||
|
@ -20,8 +21,6 @@ abstract class IMatterLink {
|
||||||
fun start() {
|
fun start() {
|
||||||
serverStartTime = System.currentTimeMillis()
|
serverStartTime = System.currentTimeMillis()
|
||||||
MessageHandler.start(clear = true, firstRun = true, message = "Server started, connecting to matterbridge API")
|
MessageHandler.start(clear = true, firstRun = true, message = "Server started, connecting to matterbridge API")
|
||||||
|
|
||||||
UpdateChecker.run()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package matterlink.bridge
|
||||||
|
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import matterlink.instance
|
import matterlink.instance
|
||||||
|
import matterlink.update.UpdateChecker
|
||||||
import org.apache.http.client.methods.HttpPost
|
import org.apache.http.client.methods.HttpPost
|
||||||
import org.apache.http.entity.ContentType
|
import org.apache.http.entity.ContentType
|
||||||
import org.apache.http.entity.StringEntity
|
import org.apache.http.entity.StringEntity
|
||||||
|
@ -68,6 +69,10 @@ object MessageHandler {
|
||||||
text = message //?: "Connected to matterbridge API"
|
text = message //?: "Connected to matterbridge API"
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(firstRun) {
|
||||||
|
UpdateChecker.run()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun transmitMessage(message: ApiMessage) {
|
private fun transmitMessage(message: ApiMessage) {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package matterlink.update
|
package matterlink.update
|
||||||
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.FieldNamingPolicy
|
||||||
|
import com.google.gson.GsonBuilder
|
||||||
|
import matterlink.bridge.ApiMessage
|
||||||
|
import matterlink.bridge.MessageHandler
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
import matterlink.instance
|
import matterlink.instance
|
||||||
import org.apache.http.HttpResponse
|
import org.apache.http.HttpResponse
|
||||||
|
@ -32,15 +35,19 @@ class UpdateChecker : Thread() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val gson = Gson()
|
val gson = GsonBuilder()
|
||||||
|
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
|
||||||
|
.create()
|
||||||
|
|
||||||
instance.info("Checking for new versions...")
|
instance.info("Checking for new versions...")
|
||||||
|
|
||||||
val client: HttpClient = HttpClients.createDefault()
|
val client: HttpClient = HttpClients.createDefault()
|
||||||
val request = HttpGet("https://goo.gl/5CMc1N")
|
val request = HttpGet("https://cursemeta.dries007.net/api/v2/direct/GetAllFilesForAddOn/287323")
|
||||||
|
|
||||||
with(instance) {
|
with(instance) {
|
||||||
request.setHeader("User-Agent", "Minecraft/$mcVersion MatterLink/$modVersion")
|
val useragent = "MatterLink/$modVersion MinecraftForge/$mcVersion-$forgeVersion (https://github.com/elytra/MatterLink)"
|
||||||
|
instance.debug("setting User-Agent: '$useragent'")
|
||||||
|
request.setHeader("User-Agent", useragent)
|
||||||
}
|
}
|
||||||
|
|
||||||
val response: HttpResponse = client.execute(request)
|
val response: HttpResponse = client.execute(request)
|
||||||
|
@ -53,7 +60,7 @@ class UpdateChecker : Thread() {
|
||||||
|
|
||||||
gson.fromJson(content, Array<CurseFile>::class.java)
|
gson.fromJson(content, Array<CurseFile>::class.java)
|
||||||
.filter {
|
.filter {
|
||||||
it.fileStatus == "semiNormal" && it.gameVersion.contains(instance.mcVersion)
|
it.fileStatus == "SemiNormal" && it.gameVersion.contains(instance.mcVersion)
|
||||||
}
|
}
|
||||||
.sortedByDescending { it.fileName.substringAfterLast(" ") }
|
.sortedByDescending { it.fileName.substringAfterLast(" ") }
|
||||||
|
|
||||||
|
@ -102,9 +109,9 @@ class UpdateChecker : Thread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.warn("Mod out of date! New $version available at ${latest.downloadURL}")
|
instance.warn("Mod out of date! New $version available at ${latest.downloadURL}")
|
||||||
// MessageHandler.transmit(ApiMessage(
|
MessageHandler.transmit(ApiMessage(
|
||||||
// username = cfg.relay.systemUser,
|
username = cfg.outgoing.systemUser,
|
||||||
// text = "Matterlink out of date! You are $count $version behind! Please download new version from ${latest.downloadURL}"
|
text = "MatterLink out of date! You are $count $version behind! Please download new version from ${latest.downloadURL}"
|
||||||
// ))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
mod_name = MatterLink
|
mod_name = MatterLink
|
||||||
mod_version = 1.5.2
|
mod_version = 1.5.3
|
||||||
forgelin_version = 1.6.0
|
forgelin_version = 1.6.0
|
||||||
curse_id = 287323
|
curse_id = 287323
|
||||||
curse_release_type = beta
|
curse_release_type = beta
|
Loading…
Reference in New Issue