Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
More Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Window5000 committed Aug 3, 2023
1 parent 2b5287b commit 4747beb
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 7 deletions.
2 changes: 1 addition & 1 deletion COBTRIBUTING.md → CONTRIBUTING.md
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`.
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.9.0"
alias(libs.plugins.kotlin)
`maven-publish`
id("org.jetbrains.dokka") version "1.8.20"
`java-library`
Expand All @@ -11,7 +11,11 @@ group = "org.hypejet"
version = "1.0-SNAPSHOT"

dependencies {
api(libs.platform)

api(libs.bundles.logging)
api(libs.bundles.kotlin)
api(libs.bundles.config)
}

kotlin.jvmToolchain(17)
Expand Down
35 changes: 35 additions & 0 deletions gradle/libs.versions.toml
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" }
8 changes: 8 additions & 0 deletions src/main/kotlin/org/hypejet/bakka/AmogusServer.kt
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()
}
}
77 changes: 77 additions & 0 deletions src/main/kotlin/org/hypejet/bakka/AmogusServerImpl.kt
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
)
}
}
}
5 changes: 0 additions & 5 deletions src/main/kotlin/org/hypejet/bakka/AmongUsServer.kt

This file was deleted.

11 changes: 11 additions & 0 deletions src/main/kotlin/org/hypejet/bakka/ServerProcess.kt
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() }
}
}
14 changes: 14 additions & 0 deletions src/main/kotlin/org/hypejet/bakka/module/SussyModule.kt
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() {}
}

0 comments on commit 4747beb

Please sign in to comment.