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

Release 3.1.0

* Added caching using CosnixDB 0.3.0 (FaradayDB 2.1.0)
* Cache autorefrashes every 10 user joins
Signed-off-by: AtjonTV's avatarAtjonTV <thomas.obernosterer@atvg-studios.com>
parent 1d53e1e2
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -3,6 +3,7 @@ buildscript {
ext.fuel_version = '2.1.0'
ext.gson_version = '2.8.5'
ext.spigot_version = '1.13.2'
ext.cosnix_version = '0.3.0'
}
plugins {
......@@ -11,7 +12,7 @@ plugins {
}
group 'com.atvgstudios'
version '3.0.0'
version '3.1.0'
repositories {
mavenCentral()
......@@ -27,6 +28,7 @@ dependencies {
implementation "org.slf4j:slf4j-simple:1.8.0-beta4"
implementation "com.google.code.gson:gson:$gson_version"
implementation "com.atvgstudios:klib:$klib_version"
implementation "com.atvgstudios.cosnixdb:cosnixdb:$cosnix_version"
implementation "org.spigotmc:spigot:$spigot_version"
}
......
package com.atvgstudios.aaab
import com.atvgstudios.aaab.api.Profile
import com.atvgstudios.aaab.api.UserAPI
import com.atvgstudios.aaab.db.CacheDB
import com.atvgstudios.cosnixdb.CosnixDB
import org.bukkit.Bukkit
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerJoinEvent
class Listener : Listener {
private val cosnixDB = CosnixDB(CacheDB.DATABASE_KEY)
private var joinCount = 0
private val refreshCount = 10
@EventHandler
fun onPlayerJoin(e: PlayerJoinEvent) {
val x = UserAPI.isBanned(e.player.uniqueId.toString().replace("-", ""))
joinCount++
val uuid = e.player.uniqueId.toString().replace("-", "")
if(x) {
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(!cosnixDB && CacheDB.PROFILES_KEY in cosnixDB) {
val allProfiles = cosnixDB[CacheDB.PROFILES_KEY] as List<Profile>
val name = allProfiles.find { it.id == uuid }
if(name != null) {
ban()
}else{
if(UserAPI.isBanned(uuid)) {
ban()
}
}
}else{
if(UserAPI.isBanned(uuid)) {
ban()
}
}
if(joinCount == refreshCount) {
joinCount = 0
if(!cosnixDB && CacheDB.PROFILES_KEY in cosnixDB) {
cosnixDB[CacheDB.PROFILES_KEY] = UserAPI.getAll()
}
}
}
}
\ No newline at end of file
package com.atvgstudios.aaab
import com.atvgstudios.aaab.api.UserAPI
import com.atvgstudios.aaab.db.CacheDB
import com.atvgstudios.cosnixdb.CosnixDB
import com.google.gson.Gson
import klib.interfaces.Json
import klib.kLibInf
......@@ -9,6 +12,9 @@ import java.lang.reflect.Type
class Plugin : JavaPlugin() {
override fun onEnable() {
createkLibJsonHandler()
val cosnixDB = CosnixDB(CacheDB.DATABASE_KEY)
cosnixDB[CacheDB.PROFILES_KEY] = UserAPI.getAll()
server.pluginManager.registerEvents(Listener(), this)
}
......
package com.atvgstudios.aaab.api
class Profile (
val id: String,
val name: String
)
\ No newline at end of file
package com.atvgstudios.aaab.api
class ProfileResponse (
val profiles: List<Profile>
)
\ No newline at end of file
......@@ -12,4 +12,13 @@ object UserAPI {
return res?.ok ?: false
}
fun getAll(): List<Profile> {
val f = Fuel.get("https://aaab-online.xyz/a")
.responseObject<ProfileResponse>()
val (res, _) = f.third
return res!!.profiles
}
}
\ No newline at end of file
package com.atvgstudios.aaab.db
import klib.objects.uuid.UniqueID
object CacheDB {
val DATABASE_KEY = UniqueID.random
val PROFILES_KEY = UniqueID.random
}
\ No newline at end of file
......@@ -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.0.0
version: 3.1.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