This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b5287b
commit 4747beb
Showing
8 changed files
with
151 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
This library is made for Among Us thus, everything must be named accordingly ex. 'Bakkastom', 'AmogusServer' and 'SussyModule'. | ||
This library is made for Among Us thus, everything must be named accordingly ex. `Bakkastom`, `AmogusServer` and `SussyModule`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[versions] | ||
slf4j = "2.0.7" | ||
logback = "1.4.5" | ||
|
||
kotlin = "1.9.0" | ||
|
||
configs = "4.0.9" | ||
json = "20230618" | ||
|
||
platform = "1.1.1" | ||
|
||
|
||
[libraries] | ||
slf4j = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j"} | ||
logback-core = { group = "ch.qos.logback", name = "logback-core", version.ref = "logback" } | ||
logback-classic = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logback" } | ||
|
||
platform = { module = "org.hypejet:platform", version.ref = "platform" } | ||
|
||
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" } | ||
kotlin-stdlib-jdk8 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" } | ||
|
||
json = { module = "org.json:json", version.ref = "json" } | ||
configs-hjson = { module = "eu.okaeri:okaeri-configs-hjson", version.ref = "configs" } | ||
configs-yaml-snakeyaml = { module = "eu.okaeri:okaeri-configs-yaml-snakeyaml", version.ref = "configs" } | ||
configs-serdes-commons = { module = "eu.okaeri:okaeri-configs-serdes-commons", version.ref = "configs" } | ||
|
||
|
||
[bundles] | ||
logging = ["logback-core", "logback-classic", "slf4j"] | ||
kotlin = ["kotlin-stdlib-jdk8", "kotlin-reflect"] | ||
config = ["json", "configs-hjson", "configs-yaml-snakeyaml", "configs-serdes-commons"] | ||
|
||
[plugins] | ||
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.hypejet.bakka | ||
|
||
interface AmogusServer { | ||
fun stopCleanly() { | ||
AmogusServerImpl.INSTANCE.modules.forEach { it.disable() } | ||
AmogusServerImpl.serverProcess.stop() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.hypejet.bakka | ||
|
||
import org.hypejet.bakka.module.SussyModule | ||
import kotlin.properties.Delegates | ||
import kotlin.reflect.KClass | ||
|
||
class AmogusServerImpl(address: String, port: Int, val modules: List<SussyModule>) : AmogusServer { | ||
|
||
companion object { | ||
private const val DEFAULT_ADDRESS = "0.0.0.0" | ||
private const val DEFAULT_PORT = 443 | ||
|
||
lateinit var serverProcess: ServerProcess | ||
private set | ||
|
||
var PRODUCTION by Delegates.notNull<Boolean>() | ||
private set | ||
lateinit var INSTANCE: AmogusServerImpl | ||
private set | ||
} | ||
|
||
init { | ||
INSTANCE = this | ||
|
||
// Call enable function in modules | ||
modules.forEach { it.enable() } | ||
serverProcess = ServerProcess() | ||
} | ||
|
||
@Suppress("unused") | ||
class Builder { | ||
private var address = DEFAULT_ADDRESS | ||
private var port = DEFAULT_PORT | ||
|
||
private val modules = ArrayList<SussyModule>() | ||
|
||
private var production = false | ||
|
||
fun address(address: String) : Builder { | ||
this.address = address | ||
return this | ||
} | ||
|
||
fun port(port: Int) : Builder { | ||
this.port = port | ||
return this | ||
} | ||
|
||
fun module(module: SussyModule) : Builder { | ||
this.modules.add(module) | ||
return this | ||
} | ||
|
||
fun unmodule(module: KClass<out SussyModule>) : Builder { | ||
this.modules.removeAll { it.javaClass == module.java } | ||
return this | ||
} | ||
|
||
fun production() : Builder { | ||
this.production = true | ||
return this | ||
} | ||
|
||
fun commonModules() : Builder { | ||
return this | ||
} | ||
|
||
fun build() : AmogusServerImpl { | ||
PRODUCTION = this.production | ||
return AmogusServerImpl( | ||
this.address, | ||
this.port, | ||
this.modules | ||
) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.hypejet.bakka | ||
|
||
class ServerProcess { | ||
fun start(port: Int, address: String) { | ||
AmogusServerImpl.INSTANCE.modules.forEach { it.start() } | ||
} | ||
|
||
fun stop() { | ||
AmogusServerImpl.INSTANCE.modules.forEach { it.stop() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.hypejet.bakka.module | ||
|
||
import org.hypejet.platform.Module | ||
import java.nio.file.Path | ||
|
||
abstract class SussyModule(private val name: String) : Module() { | ||
override val dataDirectory: Path | ||
get() = Path.of("modules", this.name) | ||
|
||
override fun disable() {} | ||
override fun enable() {} | ||
open fun stop() {} | ||
open fun start() {} | ||
} |