OSPL20 will be replaced with MPL2.0 after 1st February 2021! Read more here
OSPL18 and OSPL19 will be replaced with MIT after 1st February2021! Read more here

Verified Commit a09eb81b authored by AtjonTV's avatar AtjonTV

Release 3.2.0

parent bb32a3f0
buildscript {
ext.klib_version = '1.2.0'
ext.klib_version = '2.0.0'
ext.fuel_version = '2.1.0'
ext.gson_version = '2.8.5'
ext.spigot_version = '1.13.2'
......@@ -12,7 +12,7 @@ plugins {
}
group 'com.atvgstudios'
version '3.1.2'
version '3.2.0'
repositories {
mavenCentral()
......
package com.atvgstudios.aaab
object Console {
fun log(stuff: Any?) {
println("AAAB-v3 » $stuff")
}
fun log(vararg stuff: Any?) {
print("AAAB-v3 » ")
stuff.forEach {
print("$it, ")
}
}
}
\ No newline at end of file
......@@ -4,19 +4,34 @@ import com.atvgstudios.aaab.api.UserAPI
import com.atvgstudios.aaab.db.CacheDB
import com.atvgstudios.cosnixdb.CosnixDB
import com.google.gson.Gson
import klib.annotations.Experimental
import klib.interfaces.Json
import klib.kLibInf
import org.bukkit.Bukkit
import org.bukkit.plugin.java.JavaPlugin
import java.lang.reflect.Type
@Experimental
class Plugin : JavaPlugin() {
companion object {
var version: String = "3.2.0"
}
override fun onEnable() {
Console.log("Initializing AAAB-v3 [Running: $version]")
createkLibJsonHandler()
val cosnixDB = CosnixDB(CacheDB.DATABASE_KEY)
cosnixDB[CacheDB.PROFILES_KEY] = UserAPI.getAll()
server.pluginManager.registerEvents(Listener(), this)
version = Bukkit.getServer().pluginManager.getPlugin("AAAB-v3")?.description?.version ?: version
Console.log("Initialized AAAB-v3!")
Updater.update()
}
override fun onDisable() {
......
package com.atvgstudios.aaab
import com.github.kittinunf.fuel.Fuel
import klib.annotations.Experimental
import klib.extensions.Sha1Checksum
import klib.extensions.toFile
import klib.objects.Konfig
import klib.types.SemVer
import org.bukkit.Bukkit
import java.io.File
import java.net.URL
@Experimental
object Updater {
val SoftwareID = "56e5b4f5"
val SoftwareKey = "aaab_plugin"
private val indexFile = File.createTempFile("atvg-studios_software-index", ".konf")
private val updatedFile = File.createTempFile("atvg-studios_software-update", ".jar")
private var filePath = "/aaab-plugin"
private var fileSig = ""
private var fileVersion = ""
fun getIndex() {
Console.log("Updating version index from Update-Server")
val f = Fuel.get("https://software.atvg-studios.com/index")
.responseString()
val indexContent = f.third.component1() ?: ""
val partialIndexContent = indexContent.split("\n")
val newIndexContent = StringBuilder()
partialIndexContent.forEach {
if(it != "") {
newIndexContent.appendln(it)
}
}
// Write to index cache file
indexFile.writeText(newIndexContent.toString())
}
fun checkUpdate(): Boolean {
val indexSettings = Konfig.parseFile(indexFile)
return if(indexSettings["$SoftwareKey.id"] == SoftwareID) {
filePath = indexSettings["$SoftwareKey.path"] as String
fileSig = indexSettings["$SoftwareKey.sig"] as String
fileVersion = indexSettings["$SoftwareKey.version"] as String
val indexVersion = SemVer.parse(fileVersion)
val liveVersion = SemVer.parse(Plugin.version)
if(liveVersion > indexVersion) {
return true
}
false
} else {false}
}
fun getUpdate() {
Console.log("Checking for available Updates.")
if(checkUpdate()) {
Console.log("Update available. Updating! (Running: ${Plugin.version}, Available: $fileVersion)")
Console.log("Downloading $fileVersion from Update-Server.")
URL("https://software.atvg-studios.com$filePath/$SoftwareID-$fileVersion-$fileSig.jar").openStream().toFile(updatedFile)
Console.log("Downloaded $fileVersion, checking Sig!")
if(updatedFile.Sha1Checksum() == fileSig) {
Console.log("Verified file Sig successfully!")
val file = File("aaab-$fileVersion.jar")
if(file.exists()) file.delete()
Console.log("Installing new plugin $fileVersion")
updatedFile.copyTo(file)
Console.log("Removing old plugin ${Plugin.version}")
val oldFile = File("aaab-${Plugin.version}.jar")
val oldFile2 = File("aaab.jar")
if(oldFile.exists()) oldFile.delete()
if(oldFile2.exists()) oldFile2.delete()
Console.log("Reloading Server")
Bukkit.getServer().reload()
Console.log("Finished Installation of AAAB Update!")
} else {
Console.log("Cannot confirm file Sig. Aborting Update!")
return
}
} else {
Console.log("No Update Available! (Running: ${Plugin.version}, Available: $fileVersion)")
}
}
fun update() {
getIndex()
getUpdate()
}
}
\ No newline at end of file
package com.atvgstudios.aaab.api
import com.atvgstudios.aaab.Console
import com.github.kittinunf.fuel.Fuel
import com.github.kittinunf.fuel.gson.responseObject
import com.google.gson.reflect.TypeToken
......@@ -10,7 +11,7 @@ object UserAPI {
val f = Fuel.get("https://aaab-online.xyz/i/$uuid")
.responseObject<UserResponse>()
println("[AAAB-v3] Checking: https://aaab-online.xyz/i/$uuid")
Console.log("Checking: https://aaab-online.xyz/i/$uuid")
val (res, _) = f.third
......@@ -21,7 +22,7 @@ object UserAPI {
val f = Fuel.get("https://aaab-online.xyz/a")
.responseString()
println("[AAAB-v3] Refreshing: https://aaab-online.xyz/a")
Console.log("Refreshing: https://aaab-online.xyz/a")
val (res, _) = f.third
......
......@@ -2,5 +2,5 @@ main: com.atvgstudios.aaab.Plugin
name: AAAB-v3
description: This is the third generation of AAAB that uses a completly new online API and is more performant.
author: Thomas Obernosterer <thomas.obernosterer@atvg-studios.com>
version: 3.1.2
version: 3.2.0
website: https://aaab-online.xyz
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment