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 a38b7335 authored by AtjonTV's avatar AtjonTV

Release 3.5.0

* Added
  * Added timed updates (Every minute / 60_000 milli seconds)
  * Added command '/aaab settings set [setting] [value]'

* Changed
  * Enable updates by default
  * Code cleanup

* Removed
  * Removed call to '/i/:uuid' if the UUID was not found in the cache
Signed-off-by: AtjonTV's avatarAtjonTV <thomas.obernosterer@atvg-studios.com>
parent 8674b714
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MacroExpansionManager">
<option name="directoryName" value="SkCRAdxe" />
<component name="EntryPointsManager">
<list size="1">
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
</list>
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
......
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>
\ No newline at end of file
......@@ -13,6 +13,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security
[3.5.0] - 04.06.2019
### Added
* Added timed updates (Every minute / 60_000 milli seconds)
* Added command `/aaab settings set [setting] [value]`
### Changed
* Enable updates by default
* Code cleanup
### Removed
* Removed call to `/i/:uuid` if the UUID was not found in the cache
[3.4.0] - 02.06.2019
### Added
......
......@@ -12,7 +12,7 @@ plugins {
}
group 'com.atvgstudios'
version '3.4.0'
version '3.5.0'
repositories {
mavenCentral()
......
......@@ -2,22 +2,32 @@ package com.atvgstudios.aaab
import com.atvgstudios.aaab.api.UserAPI
import com.atvgstudios.aaab.extensions.sendMsg
import klib.annotations.Experimental
import klib.functions.pairOf
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{
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}")
if (params.size == 4) {
if (params[1] == "set" && sender.hasPermission("aaab.set_settings")) {
val setting = params[2]
val value = params[3]
Config.updateSetting(pairOf(setting, value))
sender.sendMsg("Updated setting '$setting'")
}
} else {
Console.log("Player ${sender.name} issued command '/aaab settings', got: ${Config.configs}")
sender.sendMsg("Settings: ${Config.configs}")
}
}
params[0] == "token" && params[1].length == 16 -> {
Console.log("Player ${sender.name} issued command '/aaab token ${params[1]}', sending to remote")
......@@ -29,7 +39,7 @@ class Commands : CommandExecutor {
return false
}
}
}else {
} else {
sender.sendMsg("AltAccountAutoBan v${Plugin.version} by Thomas Obernosterer")
}
}
......
package com.atvgstudios.aaab
import com.atvgstudios.aaab.api.UserAPI
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()) {
if (checkConfigFile()) {
val fileData = Konfig.parseFile(File("$dataFolder/config.konf"))
for (config in fileData) {
configs[config.key] = config.value
}
if("remote" in configs) {
if ("remote" in configs) {
UserAPI.remote = configs["remote"] as String
}
if("refresh_limit" in configs) {
if ("refresh_limit" in configs) {
Listener.refreshCount = Integer.parseInt(configs["refresh_limit"] as String)
}
}
}
fun writeConfig() {
if (checkConfigFile()) {
val configFile = File("$dataFolder/config.konf")
configFile.renameTo(File("$dataFolder/config_old.konf"))
configFile.createNewFile()
Konfig.writeFile(configs, configFile)
}
}
fun getString(key: String): String {
if(configs.isNotEmpty() && key in configs) {
if (configs.isNotEmpty() && key in configs) {
return configs[key] as String
}
......@@ -37,7 +44,7 @@ object Config {
}
fun getInt(key: String): Int {
if(configs.isNotEmpty() && key in configs) {
if (configs.isNotEmpty() && key in configs) {
return Integer.parseInt(configs[key] as String)
}
......@@ -45,13 +52,29 @@ object Config {
}
fun getBoolean(key: String): Boolean {
if(configs.isNotEmpty() && key in configs) {
if (configs.isNotEmpty() && key in configs) {
return (configs[key] as String).toBoolean()
}
return false
}
fun updateSetting(setting: Pair<String, String>) {
if (setting.first in configs) {
val oldSetting = configs[setting.first]
when (oldSetting) {
is Int -> configs[setting.first] = Integer.parseInt(setting.second)
is Boolean -> configs[setting.first] = setting.second.toBoolean()
else -> configs[setting.first] = setting.second
}
if (configs[setting.first] != oldSetting) {
writeConfig()
}
}
}
fun checkConfigFile(): Boolean {
val configFolder = File(dataFolder)
val configFile = File("${configFolder.absolutePath}/config.konf")
......@@ -60,22 +83,22 @@ object Config {
var fileOK = false
if(configFolder.exists() && configFolder.isDirectory) {
if(configFile.exists() && configFile.isFile) {
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) {
} catch (e: Exception) {
Console.log("Cannot load config file: ${e.message}")
}
}else {
} else {
Console.log("Cannot find config file, trying to create ..")
if(configFile.createNewFile()) {
if (configFile.createNewFile()) {
Console.log("Created file, writing default config ..")
val defaultConfig = hashMapOf(
"updates" to false,
"updates" to true,
"remote" to "https://aaab-online.xyz",
"refresh_limit" to 10
)
......@@ -91,7 +114,7 @@ object Config {
}
} else {
Console.log("Cannot find config folder, trying to create ..")
if(configFolder.mkdir()) {
if (configFolder.mkdir()) {
Console.log("Created folder, rerunning check!")
return checkConfigFile()
} else {
......
package com.atvgstudios.aaab
import klib.annotations.Experimental
@Experimental
object Console {
fun log(stuff: Any?) {
println("${Plugin.prefix} $stuff")
}
fun log(vararg stuff: Any?) {
print("${Plugin.prefix} ")
stuff.forEach {
......
......@@ -22,32 +22,31 @@ class Listener : Listener {
joinCount++
val uuid = e.player.uniqueId.toString().replace("-", "")
fun ban(){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ban ${e.player.name} §4Usage of known Alt-Account from MC-Leaks.\nBanned using AAAB v3 (https://aaab-online.xyz)")
fun ban() {
Bukkit.getServer().dispatchCommand(
Bukkit.getConsoleSender(),
"ban ${e.player.name} §4Usage of known Alt-Account from MC-Leaks.\nBanned using AAAB v3 (https://aaab-online.xyz)"
)
}
if(CacheDB.PROFILES_KEY in cosnixDB) {
if (CacheDB.PROFILES_KEY in cosnixDB) {
val allProfiles = cosnixDB[CacheDB.PROFILES_KEY] as List<Profile>
val name = allProfiles.find { it.id == uuid }
if(name != null) {
if (name != null) {
ban()
}else{
if(UserAPI.isBanned(uuid)) {
ban()
}
}
}else{
if(UserAPI.isBanned(uuid)) {
} else {
if (UserAPI.isBanned(uuid)) {
ban()
}
}
if(joinCount == refreshCount) {
if (joinCount == refreshCount) {
joinCount = 0
if(CacheDB.PROFILES_KEY in cosnixDB) {
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.getAfter(dataCount)
......
......@@ -3,22 +3,22 @@ package com.atvgstudios.aaab
import com.atvgstudios.aaab.api.UserAPI
import com.atvgstudios.aaab.db.CacheDB
import com.atvgstudios.cosnixdb.CosnixDB
import com.github.kittinunf.fuel.Fuel
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
import java.util.*
@Experimental
class Plugin : JavaPlugin() {
companion object {
var version: String = "3.4.0"
var version: String = "3.5.0"
val prefix = "AAAB-v3 »"
}
val t = Timer()
override fun onEnable() {
Console.log("Initializing AAAB-v3 [Running: $version]")
......@@ -36,14 +36,27 @@ class Plugin : JavaPlugin() {
Console.log("Initialized AAAB-v3!")
Updater.update()
if (Config.getBoolean("updates")) {
timedUpdate()
}
}
override fun onDisable() {
fun timedUpdate() {
t.scheduleAtFixedRate(object : TimerTask() {
override fun run() {
Console.log("Running timed update ..")
Updater.update()
}
}, 60_000, 180_000)
}
override fun onDisable() {
t.cancel()
}
private fun createkLibJsonHandler() {
kLibInf.jsonHandler = object: Json {
kLibInf.jsonHandler = object : Json {
override fun fromObject(data: Any): String {
return Gson().toJson(data)
}
......@@ -52,6 +65,5 @@ class Plugin : JavaPlugin() {
return Gson().fromJson(data, type)
}
}
}
}
\ No newline at end of file
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
......@@ -10,7 +9,6 @@ import org.bukkit.Bukkit
import java.io.File
import java.net.URL
@Experimental
object Updater {
val SoftwareID = "56e5b4f5"
val SoftwareKey = "aaab_plugin"
......@@ -33,7 +31,7 @@ object Updater {
val newIndexContent = StringBuilder()
partialIndexContent.forEach {
if(it != "") {
if (it != "") {
newIndexContent.appendln(it)
}
}
......@@ -45,7 +43,7 @@ object Updater {
private fun internalCheckUpdate(): Boolean {
val indexSettings = Konfig.parseFile(indexFile)
return if(indexSettings["$SoftwareKey.id"] == SoftwareID) {
return if (indexSettings["$SoftwareKey.id"] == SoftwareID) {
filePath = indexSettings["$SoftwareKey.path"] as String
fileSig = indexSettings["$SoftwareKey.sig"] as String
fileVersion = indexSettings["$SoftwareKey.version"] as String
......@@ -53,16 +51,18 @@ object Updater {
val indexVersion = SemVer.parse("$fileVersion-r1+0")
val liveVersion = SemVer.parse("${Plugin.version}-r1+0")
if(indexVersion > liveVersion) {
if (indexVersion > liveVersion) {
return true
}
false
} else {false}
} else {
false
}
}
fun checkUpdate() {
Console.log("Checking for available Updates.")
if(internalCheckUpdate()) {
if (internalCheckUpdate()) {
Console.log("Update available! (Running: ${Plugin.version}, Available: $fileVersion)")
} else {
Console.log("No Update Available! (Running: ${Plugin.version}, Available: $fileVersion)")
......@@ -70,19 +70,20 @@ object Updater {
}
fun getUpdate() {
if(internalCheckUpdate()) {
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)
URL("https://software.atvg-studios.com$filePath/$SoftwareID-$fileVersion-$fileSig.jar").openStream()
.toFile(updatedFile)
Console.log("Downloaded $fileVersion, checking Sig!")
if(updatedFile.Sha1Checksum() == fileSig) {
if (updatedFile.Sha1Checksum() == fileSig) {
Console.log("Verified file Sig successfully!")
val file = File("plugins/aaab-$fileVersion.jar")
if(file.exists()) file.delete()
if (file.exists()) file.delete()
Console.log("Installing new plugin $fileVersion")
updatedFile.copyTo(file)
......@@ -90,8 +91,8 @@ object Updater {
Console.log("Removing old plugin ${Plugin.version}")
val oldFile = File("plugins/aaab-${Plugin.version}.jar")
val oldFile2 = File("plugins/aaab.jar")
if(oldFile.exists()) oldFile.delete()
if(oldFile2.exists()) oldFile2.delete()
if (oldFile.exists()) oldFile.delete()
if (oldFile2.exists()) oldFile2.delete()
Console.log("Reloading Server")
Bukkit.getServer().reload()
......@@ -106,7 +107,7 @@ object Updater {
fun update() {
getIndex()
checkUpdate()
if(Config.getBoolean("updates")) {
if (Config.getBoolean("updates")) {
getUpdate()
}
}
......
package com.atvgstudios.aaab.api
class Profile (
class Profile(
val id: String,
val name: String
)
\ No newline at end of file
package com.atvgstudios.aaab.api
class ProfileResponse (
class ProfileResponse(
val profiles: List<Profile>
)
\ No newline at end of file
package com.atvgstudios.aaab.api
import com.atvgstudios.aaab.Console
import com.atvgstudios.aaab.Plugin
import com.atvgstudios.aaab.extensions.setDefaultHeaders
import com.github.kittinunf.fuel.Fuel
import com.github.kittinunf.fuel.gson.responseObject
import com.google.gson.reflect.TypeToken
import klib.annotations.Experimental
import klib.kLibInf
import org.bukkit.Bukkit
@Experimental
object UserAPI {
var remote = "https://aaab-online.xyz"
......@@ -27,7 +23,7 @@ object UserAPI {
}
fun sendToken(token: String) {
val f = Fuel.get("$remote/t/$token")
Fuel.get("$remote/t/$token")
.setDefaultHeaders()
.responseString()
}
......@@ -41,7 +37,7 @@ object UserAPI {
val (res, _) = f.third
if(res == null) return ArrayList()
if (res == null) return ArrayList()
val listOfProfiles = object : TypeToken<List<Profile>>() {}.type
......@@ -59,7 +55,7 @@ object UserAPI {
val (res, _) = f.third
if(res == null) return ArrayList()
if (res == null) return ArrayList()
val listOfProfiles = object : TypeToken<List<Profile>>() {}.type
......
......@@ -2,8 +2,6 @@ package com.atvgstudios.aaab.extensions
import com.atvgstudios.aaab.Plugin
import com.github.kittinunf.fuel.core.Request
import klib.extensions.asSha256
import org.bukkit.Bukkit
fun Request.setDefaultHeaders(): Request {
return this
......
......@@ -2,7 +2,7 @@ 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.4.0
version: 3.5.0
website: https://aaab-online.xyz
commands:
......@@ -10,8 +10,8 @@ commands:
description: Plugin commands
usage: /aaab [settings, token]
settings:
description: Get information about the AAAB Plugin Configs
usage: /aaab settings
description: Get/Set the AAAB Plugin Configs
usage: /aaab settings [set] [setting] [value]
permission: aaab.see_settings
token:
description: Send a token to the Plugin's Server
......@@ -22,6 +22,10 @@ permissions:
default: op
children:
aaab.see_settings: true
aaab.set_settings: true
aaab.see_settings:
description: View the current plugin settings
\ No newline at end of file
description: View the current plugin settings
aaab.set_settings:
description: Write a new plugin setting
\ 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