refactor project into modules

isolate core from forge related code
This commit is contained in:
NikkyAI 2018-02-09 21:50:22 +01:00 committed by Unknown
parent 66914a63ca
commit fdce1c0cc9
26 changed files with 266 additions and 188 deletions

84
1.12.2/build.gradle Normal file
View File

@ -0,0 +1,84 @@
buildscript {
ext.kotlin_version = '1.2.20'
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
}
}
apply plugin: 'kotlin'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.github.johnrengelman.shadow'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
archivesBaseName = "MatterLink"
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
minecraft {
version = "1.12.2-14.23.1.2599"
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20171003"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
replaceIn 'src/main/kotlin/matterlink/MatterLink.kt'
replace '@VERSION@', project.version
}
repositories {
jcenter()
maven {
url = 'http://unascribed.com/maven/releases'
}
maven {
url "http://maven.shadowfacts.net/"
}
}
dependencies {
compile project(':core')
compile group: "net.shadowfacts", name: "Forgelin", version: "1.6.0"
}
shadowJar {
relocate 'org.jetbrains.annotations', 'matterlink.jetbrains.annotations'
classifier ''
configurations = [project.configurations.shadow]
}
reobf {
shadowJar { mappingType = 'SEARGE' }
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}

View File

@ -5,18 +5,10 @@ import matterlink.bridge.command.BridgeCommandRegistry
import matterlink.bridge.command.HelpCommand import matterlink.bridge.command.HelpCommand
import matterlink.bridge.command.PlayerListCommand import matterlink.bridge.command.PlayerListCommand
import matterlink.command.CommandMatterlink import matterlink.command.CommandMatterlink
import matterlink.handlers.*
import net.minecraft.util.text.TextComponentString import net.minecraft.util.text.TextComponentString
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.FMLCommonHandler import net.minecraftforge.fml.common.FMLCommonHandler
import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.* import net.minecraftforge.fml.common.event.*
import org.apache.logging.log4j.Level
import org.apache.logging.log4j.Logger
import org.apache.logging.log4j.message.SimpleMessageFactory
import org.apache.logging.log4j.simple.SimpleLogger
import org.apache.logging.log4j.util.PropertiesUtil
import java.util.*
const val MODID = "matterlink" const val MODID = "matterlink"
const val NAME = "MatterLink" const val NAME = "MatterLink"
@ -30,18 +22,10 @@ const val VERSION = "@VERSION@"
acceptableRemoteVersions = "*", acceptableRemoteVersions = "*",
modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter" modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter"
) )
object MatterLink { object MatterLink : IMatterLink() {
//create fake logger to get around Nullability init {
var logger: Logger = SimpleLogger("", instance = this
Level.OFF, }
false,
false,
false,
false,
"",
SimpleMessageFactory(),
PropertiesUtil(Properties()),
System.out)
@Mod.EventHandler @Mod.EventHandler
fun preInit(event: FMLPreInitializationEvent) { fun preInit(event: FMLPreInitializationEvent) {
@ -75,12 +59,12 @@ object MatterLink {
} }
//FORGE-DEPENDENT //FORGE-DEPENDENT
fun wrappedSendToPlayers(msg: String) { override fun wrappedSendToPlayers(msg: String) {
FMLCommonHandler.instance().minecraftServerInstance.playerList.sendMessage(TextComponentString(msg)) FMLCommonHandler.instance().minecraftServerInstance.playerList.sendMessage(TextComponentString(msg))
} }
//FORGE-DEPENDENT //FORGE-DEPENDENT
fun wrappedPlayerList(): Array<String> { override fun wrappedPlayerList(): Array<String> {
return FMLCommonHandler.instance().minecraftServerInstance.playerList.onlinePlayerNames return FMLCommonHandler.instance().minecraftServerInstance.playerList.onlinePlayerNames
} }

View File

@ -4,45 +4,9 @@ import net.minecraftforge.common.config.Configuration
import java.io.File import java.io.File
import java.util.regex.Pattern import java.util.regex.Pattern
var cfg: MatterLinkConfig? = null class MatterLinkConfig(file: File) : IMatterLinkConfig() {
class MatterLinkConfig(file: File) {
private val CATEGORY_RELAY_OPTIONS = "relay"
private val CATEGORY_FORMATTING = "formatting"
private val CATEGORY_CONNECTION = "connection"
private val CATEGORY_COMMAND = "command"
val relay: RelayOptions
val connect: ConnectOptions
val formatting: FormattingOptions
val command: CommandOptions
data class RelayOptions(
val systemUser: String,
val deathEvents: Boolean,
val advancements: Boolean,
val joinLeave: Boolean
)
data class FormattingOptions(
val chat: String,
val joinLeave: String,
val action: String
)
data class ConnectOptions(
val url: String,
val authToken: String,
val gateway: String
)
data class CommandOptions(
val prefix: String,
val enable: Boolean
)
init { init {
MatterLink.logger.info("Reading bridge blueprints... from {}", file) logger.info("Reading bridge blueprints... from {}", file)
val config = Configuration(file) val config = Configuration(file)
config.addCustomCategoryComment(CATEGORY_RELAY_OPTIONS, "Relay options") config.addCustomCategoryComment(CATEGORY_RELAY_OPTIONS, "Relay options")
@ -51,25 +15,25 @@ class MatterLinkConfig(file: File) {
systemUser = config.getString( systemUser = config.getString(
"systemUser", "systemUser",
CATEGORY_RELAY_OPTIONS, CATEGORY_RELAY_OPTIONS,
"Server", relay.systemUser,
"Name of the server user (used by death and advancement messages and the /say command)" "Name of the server user (used by death and advancement messages and the /say command)"
), ),
deathEvents = config.getBoolean( deathEvents = config.getBoolean(
"deathEvents", "deathEvents",
CATEGORY_RELAY_OPTIONS, CATEGORY_RELAY_OPTIONS,
false, relay.deathEvents,
"Relay player death messages" "Relay player death messages"
), ),
advancements = config.getBoolean( advancements = config.getBoolean(
"advancements", "advancements",
CATEGORY_RELAY_OPTIONS, CATEGORY_RELAY_OPTIONS,
false, relay.advancements,
"Relay player advancements" "Relay player advancements"
), ),
joinLeave = config.getBoolean( joinLeave = config.getBoolean(
"joinLeave", "joinLeave",
CATEGORY_RELAY_OPTIONS, CATEGORY_RELAY_OPTIONS,
false, relay.joinLeave,
"Relay when a player joins or leaves the game" "Relay when a player joins or leaves the game"
) )
) )
@ -79,13 +43,13 @@ class MatterLinkConfig(file: File) {
enable = config.getBoolean( enable = config.getBoolean(
"enable", "enable",
CATEGORY_COMMAND, CATEGORY_COMMAND,
true, command.enable,
"Enable MC bridge commands" "Enable MC bridge commands"
), ),
prefix = config.getString( prefix = config.getString(
"commandPrefix", "prefix",
CATEGORY_COMMAND, CATEGORY_COMMAND,
"$", command.prefix,
"Prefix for MC bridge commands. Accepts a single character (not alphanumeric or /)", "Prefix for MC bridge commands. Accepts a single character (not alphanumeric or /)",
Pattern.compile("^[^0-9A-Za-z/]$") Pattern.compile("^[^0-9A-Za-z/]$")
) )
@ -97,19 +61,19 @@ class MatterLinkConfig(file: File) {
chat = config.getString( chat = config.getString(
"chat", "chat",
CATEGORY_FORMATTING, CATEGORY_FORMATTING,
"<{username}> {text}", formatting.chat,
"Generic chat event, just talking" "Generic chat event, just talking"
), ),
joinLeave = config.getString( joinLeave = config.getString(
"joinLeave", "joinLeave",
CATEGORY_FORMATTING, CATEGORY_FORMATTING,
"§6-- {username} {text}", formatting.joinLeave,
"Join and leave events from other gateways" "Join and leave events from other gateways"
), ),
action = config.getString( action = config.getString(
"action", "action",
CATEGORY_FORMATTING, CATEGORY_FORMATTING,
"§5* {username} {text}", formatting.action,
"User actions (/me) sent by users from other gateways" "User actions (/me) sent by users from other gateways"
) )
) )
@ -119,19 +83,19 @@ class MatterLinkConfig(file: File) {
url = config.getString( url = config.getString(
"connectURL", "connectURL",
CATEGORY_CONNECTION, CATEGORY_CONNECTION,
"http://localhost:4242", connect.url,
"The URL or IP address of the bridge server" "The URL or IP address of the bridge server"
), ),
authToken = config.getString( authToken = config.getString(
"authToken", "authToken",
CATEGORY_CONNECTION, CATEGORY_CONNECTION,
"", connect.authToken,
"Auth token used to connect to the bridge server" "Auth token used to connect to the bridge server"
), ),
gateway = config.getString( gateway = config.getString(
"gateway", "gateway",
CATEGORY_CONNECTION, CATEGORY_CONNECTION,
"minecraft", connect.gateway,
"MatterBridge gateway" "MatterBridge gateway"
) )
) )

View File

@ -2,9 +2,9 @@ package matterlink.command
import com.google.common.collect.Lists import com.google.common.collect.Lists
import matterlink.MODID import matterlink.MODID
import matterlink.MatterLink.logger
import matterlink.bridge.MessageHandler import matterlink.bridge.MessageHandler
import matterlink.bridge.ServerChatHandler import matterlink.bridge.ServerChatHandler
import matterlink.logger
import net.minecraft.command.CommandBase import net.minecraft.command.CommandBase
import net.minecraft.command.ICommandSender import net.minecraft.command.ICommandSender
import net.minecraft.server.MinecraftServer import net.minecraft.server.MinecraftServer
@ -39,13 +39,15 @@ class CommandMatterlink : CommandBase() {
val cmd = args[0].toLowerCase() val cmd = args[0].toLowerCase()
when (cmd) { when (cmd) {
"connect" -> if (MessageHandler.start()) { "connect" -> {
if (MessageHandler.start()) {
MessageHandler.rcvQueue.clear() MessageHandler.rcvQueue.clear()
logger.info("Connected to matterbridge relay") logger.info("Connected to matterbridge relay")
ServerChatHandler.processMessages = true ServerChatHandler.processMessages = true
} else { } else {
logger.error("Connection to matterbridge relay failed.") logger.error("Connection to matterbridge relay failed.")
} }
}
"disconnect" -> { "disconnect" -> {
MessageHandler.stop() MessageHandler.stop()
ServerChatHandler.processMessages = false ServerChatHandler.processMessages = false

4
Jenkinsfile vendored
View File

@ -1,5 +1,5 @@
node { node {
checkout scm checkout scm
sh './gradlew setupCiWorkspace clean build' sh './gradlew :1.12.2:setupCiWorkspace :1.12.2:clean :1.12.2:build'
archive 'build/libs/*jar' archive '1.12.2/build/libs/*jar'
} }

View File

@ -1,86 +1,16 @@
buildscript { plugins {
ext.kotlin_version = '1.2.20' id 'idea'
repositories { }
jcenter()
maven { url = "http://files.minecraftforge.net/maven" } subprojects {
mavenCentral() apply plugin: 'idea'
group = 'matterlink'
version = '1.1.0'
idea {
module {
excludeDirs += [file("run")]
} }
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
}
}
apply plugin: 'kotlin'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.github.johnrengelman.shadow'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
version = "1.1.0"
group = "matterlink" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "MatterLink"
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
minecraft {
version = "1.12.2-14.23.1.2599"
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20171003"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
replaceIn 'src/main/kotlin/matterlink/MatterLink.kt'
replace '@VERSION@', project.version
}
repositories {
jcenter()
maven {
url = 'http://unascribed.com/maven/releases'
}
maven {
url "http://maven.shadowfacts.net/"
}
}
dependencies {
compile group: "net.shadowfacts", name: "Forgelin", version: "1.6.0"
}
shadowJar {
relocate 'org.jetbrains.annotations', 'ivilengineering.jetbrains.annotations'
classifier ''
configurations = [project.configurations.shadow]
}
reobf {
shadowJar { mappingType = 'SEARGE' }
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
} }
} }

30
core/build.gradle Normal file
View File

@ -0,0 +1,30 @@
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
repositories {
jcenter()
}
dependencies {
compile 'org.apache.logging.log4j:log4j-api:2.8.1'
compile "org.apache.httpcomponents:httpclient:4.3.3"
compile "com.google.code.gson:gson:2.8.0"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

View File

@ -0,0 +1,40 @@
package matterlink
import org.apache.logging.log4j.Level
import org.apache.logging.log4j.Logger
import org.apache.logging.log4j.message.SimpleMessageFactory
import org.apache.logging.log4j.simple.SimpleLogger
import org.apache.logging.log4j.util.PropertiesUtil
import java.util.*
var instance: IMatterLink = DummyLink()
//create fake logger to get around Nullability
var logger: Logger = SimpleLogger("",
Level.OFF,
false,
false,
false,
false,
"",
SimpleMessageFactory(),
PropertiesUtil(Properties()),
System.out)
abstract class IMatterLink {
abstract fun wrappedSendToPlayers(msg: String)
abstract fun wrappedPlayerList(): Array<String>
}
class DummyLink : IMatterLink() {
override fun wrappedPlayerList(): Array<String> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun wrappedSendToPlayers(msg: String) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}

View File

@ -0,0 +1,39 @@
package matterlink
var cfg: IMatterLinkConfig? = null
abstract class IMatterLinkConfig {
protected val CATEGORY_RELAY_OPTIONS = "relay"
protected val CATEGORY_FORMATTING = "formatting"
protected val CATEGORY_CONNECTION = "connection"
protected val CATEGORY_COMMAND = "command"
var relay: RelayOptions = RelayOptions()
var connect: ConnectOptions = ConnectOptions()
var formatting: FormattingOptions = FormattingOptions()
var command: CommandOptions = CommandOptions()
data class RelayOptions(
val systemUser: String = "Server",
val deathEvents: Boolean = true,
val advancements: Boolean = true,
val joinLeave: Boolean = true
)
data class FormattingOptions(
val chat: String = "<{username}> {text}",
val joinLeave: String = "§6-- {username} {text}",
val action: String = "§5* {username} {text}"
)
data class ConnectOptions(
val url: String = "http://localhost:4242",
val authToken: String = "",
val gateway: String = "minecraft"
)
data class CommandOptions(
val prefix: String = "$",
val enable: Boolean = true
)
}

View File

@ -1,6 +1,5 @@
package matterlink package matterlink
private const val ZWSP: Char = '\u200b' private const val ZWSP: Char = '\u200b'
//Inserts a zero-width space at index 1 in the string' //Inserts a zero-width space at index 1 in the string'

View File

@ -1,6 +1,6 @@
package matterlink.bridge; package matterlink.bridge;
import matterlink.MatterLink import matterlink.logger
import org.apache.http.client.methods.HttpGet import org.apache.http.client.methods.HttpGet
import org.apache.http.impl.client.HttpClients import org.apache.http.impl.client.HttpClients
import java.io.InputStream import java.io.InputStream
@ -30,7 +30,7 @@ class HttpStreamConnection(private val getClosure: () -> HttpGet, private val mh
if (chars > 0) { if (chars > 0) {
buffer += String(buf.dropLast(buf.count() - chars).toByteArray()) buffer += String(buf.dropLast(buf.count() - chars).toByteArray())
MatterLink.logger.debug(buffer) logger.debug(buffer)
while (buffer.contains("\n")) { while (buffer.contains("\n")) {
val line = buffer.substringBefore("\n") val line = buffer.substringBefore("\n")
@ -44,9 +44,9 @@ class HttpStreamConnection(private val getClosure: () -> HttpGet, private val mh
} catch (e: SocketException) { } catch (e: SocketException) {
// MatterLink.logger.error("Bridge Connection interrupted...") // MatterLink.logger.error("Bridge Connection interrupted...")
} }
MatterLink.logger.debug("closing stream") logger.debug("closing stream")
content.close() content.close()
MatterLink.logger.debug("thread finished") logger.debug("thread finished")
onClose() onClose()
return return
} }

View File

@ -1,7 +1,8 @@
package matterlink.bridge package matterlink.bridge
import matterlink.MatterLink import matterlink.IMatterLink
import matterlink.cfg import matterlink.cfg
import matterlink.logger
import org.apache.http.client.methods.HttpGet import org.apache.http.client.methods.HttpGet
import org.apache.http.client.methods.HttpPost import org.apache.http.client.methods.HttpPost
import org.apache.http.client.methods.HttpRequestBase import org.apache.http.client.methods.HttpRequestBase
@ -30,7 +31,7 @@ object MessageHandler {
} }
private fun createThread(): HttpStreamConnection { private fun createThread(): HttpStreamConnection {
MatterLink.logger.info("Attempting to open bridge connection.") logger.info("Attempting to open bridge connection.")
return HttpStreamConnection( return HttpStreamConnection(
{ {
HttpGet(cfg!!.connect.url + "/api/stream").apply { HttpGet(cfg!!.connect.url + "/api/stream").apply {
@ -41,10 +42,10 @@ object MessageHandler {
rcvQueue.add( rcvQueue.add(
ApiMessage.decode(it) ApiMessage.decode(it)
) )
MatterLink.logger.debug("Received: " + it) logger.debug("Received: " + it)
}, },
{ {
MatterLink.logger.info("Bridge connection closed!") logger.info("Bridge connection closed!")
connected = false connected = false
} }
) )
@ -52,13 +53,13 @@ object MessageHandler {
fun transmit(msg: ApiMessage) { fun transmit(msg: ApiMessage) {
if (connected && streamConnection.isAlive) { if (connected && streamConnection.isAlive) {
MatterLink.logger.debug("Transmitting: " + msg) logger.debug("Transmitting: " + msg)
transmitMessage(msg) transmitMessage(msg)
} }
} }
fun stop() { fun stop() {
MatterLink.logger.info("Closing bridge connection...") logger.info("Closing bridge connection...")
// MessageHandler.transmit(ApiMessage(text="bridge closing", username="Server")) // MessageHandler.transmit(ApiMessage(text="bridge closing", username="Server"))
streamConnection.close() streamConnection.close()
} }
@ -87,14 +88,14 @@ object MessageHandler {
val response = client.execute(post) val response = client.execute(post)
val code = response.statusLine.statusCode val code = response.statusLine.statusCode
if (code != 200) { if (code != 200) {
MatterLink.logger.error("Server returned $code for $post") logger.error("Server returned $code for $post")
} }
sendErrors = 0 sendErrors = 0
} catch (e: IOException) { } catch (e: IOException) {
MatterLink.logger.error("sending message caused $e") logger.error("sending message caused $e")
sendErrors++ sendErrors++
if (sendErrors > 5) { if (sendErrors > 5) {
MatterLink.logger.error("caught too many errors, closing bridge") logger.error("caught too many errors, closing bridge")
stop() stop()
} }
} }

View File

@ -1,6 +1,7 @@
package matterlink.bridge package matterlink.bridge
import matterlink.MatterLink import matterlink.logger
import matterlink.instance
import matterlink.bridge.command.BridgeCommandRegistry import matterlink.bridge.command.BridgeCommandRegistry
import matterlink.cfg import matterlink.cfg
@ -13,7 +14,7 @@ object ServerChatHandler {
fun writeIncomingToChat() { fun writeIncomingToChat() {
if (!processMessages) return if (!processMessages) return
if (MessageHandler.rcvQueue.isNotEmpty()) if (MessageHandler.rcvQueue.isNotEmpty())
MatterLink.logger.debug("incoming: " + MessageHandler.rcvQueue.toString()) logger.debug("incoming: " + MessageHandler.rcvQueue.toString())
val nextMessage = MessageHandler.rcvQueue.poll() val nextMessage = MessageHandler.rcvQueue.poll()
if (nextMessage != null && nextMessage.gateway == cfg!!.connect.gateway) { if (nextMessage != null && nextMessage.gateway == cfg!!.connect.gateway) {
@ -30,15 +31,15 @@ object ServerChatHandler {
val user = nextMessage.username val user = nextMessage.username
val text = nextMessage.text val text = nextMessage.text
val json = nextMessage.encode() val json = nextMessage.encode()
MatterLink.logger.debug("Threw out message with unhandled event: ${nextMessage.event}") logger.debug("Threw out message with unhandled event: ${nextMessage.event}")
MatterLink.logger.debug(" Message contents:") logger.debug(" Message contents:")
MatterLink.logger.debug(" User: $user") logger.debug(" User: $user")
MatterLink.logger.debug(" Text: $text") logger.debug(" Text: $text")
MatterLink.logger.debug(" JSON: $json") logger.debug(" JSON: $json")
return return
} }
} }
MatterLink.wrappedSendToPlayers(message) instance.wrappedSendToPlayers(message)
} }
} }
} }

View File

@ -1,7 +1,9 @@
package matterlink.bridge.command package matterlink.bridge.command
import matterlink.MatterLink import matterlink.IMatterLink
import matterlink.cfg import matterlink.cfg
import matterlink.logger
import java.util.*
object BridgeCommandRegistry { object BridgeCommandRegistry {
@ -22,7 +24,7 @@ object BridgeCommandRegistry {
fun register(cmd: IBridgeCommand): Boolean { fun register(cmd: IBridgeCommand): Boolean {
if (cmd.name.isBlank() || commandMap.containsKey(cmd.name)) { if (cmd.name.isBlank() || commandMap.containsKey(cmd.name)) {
MatterLink.logger.error("Failed to register command: '${cmd.name}'") logger.error("Failed to register command: '${cmd.name}'")
return false return false
} }
commandMap[cmd.name] = cmd commandMap[cmd.name] = cmd

View File

@ -1,6 +1,6 @@
package matterlink.bridge.command package matterlink.bridge.command
import matterlink.MatterLink import matterlink.instance
import matterlink.antiping import matterlink.antiping
import matterlink.bridge.ApiMessage import matterlink.bridge.ApiMessage
import matterlink.bridge.MessageHandler import matterlink.bridge.MessageHandler
@ -11,7 +11,7 @@ object PlayerListCommand : IBridgeCommand {
override val help: String = "Lists online players." override val help: String = "Lists online players."
override fun call(args: String): Boolean { override fun call(args: String): Boolean {
if (args.isNotBlank()) return false if (args.isNotBlank()) return false
val playerList = MatterLink.wrappedPlayerList() val playerList = instance.wrappedPlayerList()
MessageHandler.transmit(ApiMessage( MessageHandler.transmit(ApiMessage(
username = cfg!!.relay.systemUser, username = cfg!!.relay.systemUser,
text = when { text = when {

2
settings.gradle Normal file
View File

@ -0,0 +1,2 @@
rootProject.name = 'MatterLink'
include 'core', '1.12.2'