Verified Commit 4b3c83b2 authored by AtjonTV's avatar AtjonTV

Release 3.3.0

Added
 * Config Engine using our custom Konfig format
   * Adding in setting 'updates'
   * Adding in setting 'refresh_limit'
   * Adding in setting 'remote'
 * Using the SmartSync Technology of AAAB-Proxy for join-refreshes
 * Adding in /aaab command
   * Adding in '/aaab settings' command
 * Adding in aaab.* Permission
   * Adding in 'aaab.see_settings' Permission
Fixed
 * Wrong version compare
 * Wrong update installation path

(Closes #1 and #2)
Signed-off-by: AtjonTV's avatarAtjonTV <thomas.obernosterer@atvg-studios.com>
parent a09eb81b
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
[3.3.0] - 01.06.2019
### Added
* Config Engine using our custom Konfig format
* Adding in setting 'updates'
* Adding in setting 'refresh_limit'
* Adding in setting 'remote'
* Using the SmartSync Technology of AAAB-Proxy for join-refreshes
* Adding in /aaab command
* Adding in '/aaab settings' command
* Adding in aaab.* Permission
* Adding in 'aaab.see_settings' Permission
### Fixed
* Wrong version compare
* Wrong update installation path
\ No newline at end of file
buildscript {
ext.klib_version = '2.0.0'
ext.klib_version = '2.1.1'
ext.fuel_version = '2.1.0'
ext.gson_version = '2.8.5'
ext.spigot_version = '1.13.2'
ext.cosnix_version = '0.3.0'
ext.cosnix_version = '0.4.3'
}
plugins {
......@@ -12,7 +12,7 @@ plugins {
}
group 'com.atvgstudios'
version '3.2.0'
version '3.3.0'
repositories {
mavenCentral()
......
package com.atvgstudios.aaab
import com.atvgstudios.aaab.extensions.sendMsg
import klib.annotations.Experimental
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.event.EventHandler
@Experimental
class Commands : CommandExecutor {
@EventHandler
override fun onCommand(sender: CommandSender, cmd: Command, s: String, params: Array<out String>): Boolean {
if(cmd.name == "aaab") {
if(params.isNotEmpty()) {
when{
params[0] == "settings" && sender.hasPermission("aaab.see_settings") -> {
Console.log("Player ${sender.name} issued command '/aaab settings', got: ${Config.configs}")
sender.sendMsg("Settings: ${Config.configs}")
}
else -> {
Console.log("Player ${sender.name} tried issued command '/aaab ${params[0]}', but has no perms or the command is unknown")
return false
}
}
}else {
sender.sendMsg("AltAccountAutoBan v${Plugin.version} by Thomas Obernosterer")
}
}
return true
}
}
\ No newline at end of file
package com.atvgstudios.aaab
import klib.annotations.Experimental
import klib.objects.Konfig
import java.io.File
import java.lang.Exception
@Experimental
object Config {
val dataFolder = "plugins/aaab-v3"
val configs: MutableMap<String, Any> = HashMap()
fun loadConfig() {
if(checkConfigFile()) {
val fileData = Konfig.parseFile(File("$dataFolder/config.konf"))
for (config in fileData) {
configs[config.key] = config.value
}
}
}
fun getString(key: String): String {
if(configs.isNotEmpty() && key in configs) {
return configs[key] as String
}
return ""
}
fun getInt(key: String): Int {
if(configs.isNotEmpty() && key in configs) {
return Integer.parseInt(configs[key] as String)
}
return -1
}
fun getBoolean(key: String): Boolean {
if(configs.isNotEmpty() && key in configs) {
return (configs[key] as String).toBoolean()
}
return false
}
fun checkConfigFile(): Boolean {
val configFolder = File(dataFolder)
val configFile = File("${configFolder.absolutePath}/config.konf")
Console.log("Checking config ..")
var fileOK = false
if(configFolder.exists() && configFolder.isDirectory) {
if(configFile.exists() && configFile.isFile) {
try {
Konfig.parseFile(configFile)
Console.log("Found config, all fine!")
fileOK = true
}catch (e: Exception) {
Console.log("Cannot load config file: ${e.message}")
}
}else {
Console.log("Cannot find config file, trying to create ..")
if(configFile.createNewFile()) {
Console.log("Created file, writing default config ..")
val defaultConfig = hashMapOf(
"updates" to false,
"remote" to "https://aaab-online.xyz",
"refresh_limit" to 10
)
Konfig.writeFile(defaultConfig, configFile)
Console.log("Write default config, rerunning check!")
return checkConfigFile()
} else {
Console.log("Cannot create config file!")
}
}
} else {
Console.log("Cannot find config folder, trying to create ..")
if(configFolder.mkdir()) {
Console.log("Created folder, rerunning check!")
return checkConfigFile()
} else {
Console.log("Cannot create config folder!")
}
}
return fileOK
}
}
\ No newline at end of file
package com.atvgstudios.aaab
import klib.annotations.Experimental
@Experimental
object Console {
fun log(stuff: Any?) {
println("AAAB-v3 » $stuff")
println("${Plugin.prefix} $stuff")
}
fun log(vararg stuff: Any?) {
print("AAAB-v3 » ")
print("${Plugin.prefix} ")
stuff.forEach {
print("$it, ")
}
......
......@@ -45,8 +45,9 @@ class Listener : Listener {
joinCount = 0
if(CacheDB.PROFILES_KEY in cosnixDB) {
val dataCount = (cosnixDB[CacheDB.PROFILES_KEY] as List<Profile>).count()
cosnixDB % CacheDB.PROFILES_KEY
cosnixDB[CacheDB.PROFILES_KEY] = UserAPI.getAll()
cosnixDB[CacheDB.PROFILES_KEY] = UserAPI.getAfter(dataCount)
}
}
}
......
......@@ -14,7 +14,8 @@ import java.lang.reflect.Type
@Experimental
class Plugin : JavaPlugin() {
companion object {
var version: String = "3.2.0"
var version: String = "3.3.0"
val prefix = "AAAB-v3 »"
}
override fun onEnable() {
......@@ -26,9 +27,12 @@ class Plugin : JavaPlugin() {
cosnixDB[CacheDB.PROFILES_KEY] = UserAPI.getAll()
server.pluginManager.registerEvents(Listener(), this)
getCommand("aaab")?.setExecutor(Commands())
version = Bukkit.getServer().pluginManager.getPlugin("AAAB-v3")?.description?.version ?: version
Config.loadConfig()
Console.log("Initialized AAAB-v3!")
Updater.update()
......
......@@ -42,7 +42,7 @@ object Updater {
indexFile.writeText(newIndexContent.toString())
}
fun checkUpdate(): Boolean {
private fun internalCheckUpdate(): Boolean {
val indexSettings = Konfig.parseFile(indexFile)
return if(indexSettings["$SoftwareKey.id"] == SoftwareID) {
......@@ -50,20 +50,28 @@ object Updater {
fileSig = indexSettings["$SoftwareKey.sig"] as String
fileVersion = indexSettings["$SoftwareKey.version"] as String
val indexVersion = SemVer.parse(fileVersion)
val liveVersion = SemVer.parse(Plugin.version)
val indexVersion = SemVer.parse("$fileVersion-r1+0")
val liveVersion = SemVer.parse("${Plugin.version}-r1+0")
if(liveVersion > indexVersion) {
if(indexVersion > liveVersion) {
return true
}
false
} else {false}
}
fun getUpdate() {
fun checkUpdate() {
Console.log("Checking for available Updates.")
if(checkUpdate()) {
Console.log("Update available. Updating! (Running: ${Plugin.version}, Available: $fileVersion)")
if(internalCheckUpdate()) {
Console.log("Update available! (Running: ${Plugin.version}, Available: $fileVersion)")
} else {
Console.log("No Update Available! (Running: ${Plugin.version}, Available: $fileVersion)")
}
}
fun getUpdate() {
if(internalCheckUpdate()) {
Console.log("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)
......@@ -73,15 +81,15 @@ object Updater {
if(updatedFile.Sha1Checksum() == fileSig) {
Console.log("Verified file Sig successfully!")
val file = File("aaab-$fileVersion.jar")
val file = File("plugins/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")
val oldFile = File("plugins/aaab-${Plugin.version}.jar")
val oldFile2 = File("plugins/aaab.jar")
if(oldFile.exists()) oldFile.delete()
if(oldFile2.exists()) oldFile2.delete()
......@@ -92,13 +100,14 @@ object Updater {
Console.log("Cannot confirm file Sig. Aborting Update!")
return
}
} else {
Console.log("No Update Available! (Running: ${Plugin.version}, Available: $fileVersion)")
}
}
fun update() {
getIndex()
checkUpdate()
if(Config.getBoolean("updates")) {
getUpdate()
}
}
}
......@@ -7,27 +7,50 @@ import com.google.gson.reflect.TypeToken
import klib.kLibInf
object UserAPI {
var remote = "https://aaab-online.xyz"
fun isBanned(uuid: String): Boolean {
val f = Fuel.get("https://aaab-online.xyz/i/$uuid")
val f = Fuel.get("$remote/i/$uuid")
.responseObject<UserResponse>()
Console.log("Checking: https://aaab-online.xyz/i/$uuid")
Console.log("Checking: $remote/i/$uuid")
val (res, _) = f.third
return res?.ok ?: false
}
fun getAfter(num: Int): List<Profile> {
val f = Fuel.get("$remote/a/$num")
.responseString()
println("Syncing with $remote on $num")
val (res, _) = f.third
if(res == null) return ArrayList()
val listOfProfiles = object : TypeToken<List<Profile>>() {}.type
val profiles = kLibInf.jsonHandler.toObject(res, listOfProfiles) ?: return ArrayList()
return profiles as List<Profile>
}
fun getAll(): List<Profile> {
val f = Fuel.get("https://aaab-online.xyz/a")
val f = Fuel.get("$remote/a")
.responseString()
Console.log("Refreshing: https://aaab-online.xyz/a")
Console.log("Syncing with $remote")
val (res, _) = f.third
if(res == null) return ArrayList()
val listOfProfiles = object : TypeToken<List<Profile>>() {}.type
return kLibInf.jsonHandler.toObject(res!!, listOfProfiles) as List<Profile>
val profiles = kLibInf.jsonHandler.toObject(res, listOfProfiles) ?: return ArrayList()
return profiles as List<Profile>
}
}
\ No newline at end of file
package com.atvgstudios.aaab.extensions
import com.atvgstudios.aaab.Plugin
import org.bukkit.command.CommandSender
fun CommandSender.sendMsg(message: String) {
sendMessage("${Plugin.prefix} $message")
}
\ No newline at end of file
......@@ -2,5 +2,23 @@ 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.2.0
version: 3.3.0
website: https://aaab-online.xyz
commands:
aaab:
description: Plugin commands
usage: /<command> [settings]
settings:
description: Get information about the AAAB Plugin Configs
usage: /aaab <command>
permission: aaab.see_settings
permissions:
aaab.*:
default: op
children:
aaab.see_settings: true
aaab.see_settings:
description: View the current plugin settings
\ 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