diff --git a/1.10.2/src/main/kotlin/matterlink/EventHandler.kt b/1.10.2/src/main/kotlin/matterlink/EventHandler.kt index b343dba..5d26ddb 100644 --- a/1.10.2/src/main/kotlin/matterlink/EventHandler.kt +++ b/1.10.2/src/main/kotlin/matterlink/EventHandler.kt @@ -8,7 +8,6 @@ import net.minecraft.command.server.CommandEmote import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayerMP import net.minecraft.server.dedicated.DedicatedServer -import net.minecraft.tileentity.TileEntityCommandBlock import net.minecraftforge.event.CommandEvent import net.minecraftforge.event.ServerChatEvent import net.minecraftforge.event.entity.living.LivingDeathEvent @@ -101,7 +100,7 @@ object EventHandler { @SubscribeEvent @JvmStatic fun serverTickEvent(e: TickEvent.ServerTickEvent) { - if(e.phase == TickEvent.Phase.END) + if (e.phase == TickEvent.Phase.END) TickHandler.handleTick() } } \ No newline at end of file diff --git a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt index dfdf85b..fa4fea1 100644 --- a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt @@ -1,6 +1,5 @@ package matterlink -import matterlink.bridge.command.IMinecraftCommandSender import matterlink.command.CommandMatterlink import matterlink.command.MatterLinkCommandSender import matterlink.config.cfg @@ -8,7 +7,10 @@ import net.minecraft.util.text.TextComponentString import net.minecraftforge.common.ForgeVersion import net.minecraftforge.fml.common.FMLCommonHandler import net.minecraftforge.fml.common.Mod -import net.minecraftforge.fml.common.event.* +import net.minecraftforge.fml.common.event.FMLInitializationEvent +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent +import net.minecraftforge.fml.common.event.FMLServerStartingEvent +import net.minecraftforge.fml.common.event.FMLServerStoppingEvent import org.apache.logging.log4j.Level import org.apache.logging.log4j.Logger diff --git a/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt b/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt index 1bd8339..a1d30cb 100644 --- a/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt +++ b/1.10.2/src/main/kotlin/matterlink/MatterLinkConfig.kt @@ -1,7 +1,6 @@ package matterlink import matterlink.config.BaseConfig -import matterlink.config.cfg import net.minecraftforge.common.config.Configuration import java.io.File diff --git a/1.10.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt b/1.10.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt index 26f3c8d..dd3724a 100644 --- a/1.10.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt +++ b/1.10.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt @@ -1,9 +1,6 @@ package matterlink.command -import matterlink.bridge.ApiMessage -import matterlink.bridge.MessageHandler import matterlink.bridge.command.IMinecraftCommandSender -import matterlink.config.cfg import net.minecraft.command.CommandResultStats import net.minecraft.command.ICommandSender import net.minecraft.entity.Entity diff --git a/1.11.2/src/main/kotlin/matterlink/EventHandler.kt b/1.11.2/src/main/kotlin/matterlink/EventHandler.kt index cbfdfd2..4c561bb 100644 --- a/1.11.2/src/main/kotlin/matterlink/EventHandler.kt +++ b/1.11.2/src/main/kotlin/matterlink/EventHandler.kt @@ -8,7 +8,6 @@ import net.minecraft.command.server.CommandEmote import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayerMP import net.minecraft.server.dedicated.DedicatedServer -import net.minecraft.tileentity.TileEntityCommandBlock import net.minecraftforge.event.CommandEvent import net.minecraftforge.event.ServerChatEvent import net.minecraftforge.event.entity.living.LivingDeathEvent @@ -102,7 +101,7 @@ object EventHandler { @SubscribeEvent @JvmStatic fun serverTickEvent(e: TickEvent.ServerTickEvent) { - if(e.phase == TickEvent.Phase.END) + if (e.phase == TickEvent.Phase.END) TickHandler.handleTick() } } \ No newline at end of file diff --git a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt index fcd57f3..6dc65f4 100644 --- a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt @@ -1,6 +1,5 @@ package matterlink -import matterlink.bridge.command.IMinecraftCommandSender import matterlink.command.CommandMatterlink import matterlink.command.MatterLinkCommandSender import matterlink.config.cfg @@ -8,7 +7,10 @@ import net.minecraft.util.text.TextComponentString import net.minecraftforge.common.ForgeVersion import net.minecraftforge.fml.common.FMLCommonHandler import net.minecraftforge.fml.common.Mod -import net.minecraftforge.fml.common.event.* +import net.minecraftforge.fml.common.event.FMLInitializationEvent +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent +import net.minecraftforge.fml.common.event.FMLServerStartingEvent +import net.minecraftforge.fml.common.event.FMLServerStoppingEvent import org.apache.logging.log4j.Level import org.apache.logging.log4j.Logger diff --git a/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt b/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt index 1bd8339..a1d30cb 100644 --- a/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt +++ b/1.11.2/src/main/kotlin/matterlink/MatterLinkConfig.kt @@ -1,7 +1,6 @@ package matterlink import matterlink.config.BaseConfig -import matterlink.config.cfg import net.minecraftforge.common.config.Configuration import java.io.File diff --git a/1.11.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt b/1.11.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt index 61dfaa3..d9a843a 100644 --- a/1.11.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt +++ b/1.11.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt @@ -1,9 +1,6 @@ package matterlink.command -import matterlink.bridge.ApiMessage -import matterlink.bridge.MessageHandler import matterlink.bridge.command.IMinecraftCommandSender -import matterlink.config.cfg import net.minecraft.command.CommandResultStats import net.minecraft.command.ICommandSender import net.minecraft.entity.Entity diff --git a/1.12.2/src/main/kotlin/matterlink/EventHandler.kt b/1.12.2/src/main/kotlin/matterlink/EventHandler.kt index be89cd1..f43d289 100644 --- a/1.12.2/src/main/kotlin/matterlink/EventHandler.kt +++ b/1.12.2/src/main/kotlin/matterlink/EventHandler.kt @@ -7,7 +7,6 @@ import net.minecraft.command.server.CommandBroadcast import net.minecraft.command.server.CommandEmote import net.minecraft.entity.player.EntityPlayer import net.minecraft.server.dedicated.DedicatedServer -import net.minecraft.tileentity.TileEntityCommandBlock import net.minecraftforge.event.CommandEvent import net.minecraftforge.event.ServerChatEvent import net.minecraftforge.event.entity.living.LivingDeathEvent @@ -96,7 +95,7 @@ object EventHandler { @SubscribeEvent @JvmStatic fun serverTickEvent(e: TickEvent.ServerTickEvent) { - if(e.phase == TickEvent.Phase.END) + if (e.phase == TickEvent.Phase.END) TickHandler.handleTick() } } \ No newline at end of file diff --git a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt index ae2b0a6..c85e784 100644 --- a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt @@ -1,6 +1,5 @@ package matterlink -import matterlink.bridge.command.IMinecraftCommandSender import matterlink.command.CommandMatterlink import matterlink.command.MatterLinkCommandSender import matterlink.config.cfg diff --git a/1.7.10/src/main/kotlin/matterlink/EventHandler.kt b/1.7.10/src/main/kotlin/matterlink/EventHandler.kt index 74f4641..c823e81 100644 --- a/1.7.10/src/main/kotlin/matterlink/EventHandler.kt +++ b/1.7.10/src/main/kotlin/matterlink/EventHandler.kt @@ -11,7 +11,6 @@ import net.minecraft.command.server.CommandEmote import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayerMP import net.minecraft.server.dedicated.DedicatedServer -import net.minecraft.tileentity.TileEntityCommandBlock import net.minecraftforge.event.CommandEvent import net.minecraftforge.event.ServerChatEvent import net.minecraftforge.event.entity.living.LivingDeathEvent diff --git a/1.7.10/src/main/kotlin/matterlink/MatterLink.kt b/1.7.10/src/main/kotlin/matterlink/MatterLink.kt index 9f59758..d98daab 100644 --- a/1.7.10/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.7.10/src/main/kotlin/matterlink/MatterLink.kt @@ -2,9 +2,11 @@ package matterlink import cpw.mods.fml.common.FMLCommonHandler import cpw.mods.fml.common.Mod -import cpw.mods.fml.common.event.* +import cpw.mods.fml.common.event.FMLInitializationEvent +import cpw.mods.fml.common.event.FMLPreInitializationEvent +import cpw.mods.fml.common.event.FMLServerStartingEvent +import cpw.mods.fml.common.event.FMLServerStoppingEvent import matterlink.command.CommandMatterlink -import matterlink.bridge.command.IMinecraftCommandSender import matterlink.command.MatterLinkCommandSender import matterlink.config.cfg import net.minecraft.server.MinecraftServer diff --git a/1.7.10/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt b/1.7.10/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt index a23fc88..53c8eae 100644 --- a/1.7.10/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt +++ b/1.7.10/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt @@ -1,9 +1,6 @@ package matterlink.command -import matterlink.bridge.ApiMessage -import matterlink.bridge.MessageHandler import matterlink.bridge.command.IMinecraftCommandSender -import matterlink.config.cfg import net.minecraft.command.ICommandSender import net.minecraft.server.MinecraftServer import net.minecraft.util.ChatComponentText diff --git a/README.md b/README.md index 588dd11..03dec55 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # MatterLink +- [Downloads](#downloads) +- [Dependencies](#dependencies) +- [Features](#features) +- [Setup](#setup) + A MatterBridge endpoint for MC servers! THIS MOD REQUIRES YOU TO ALSO RUN A MATTERBRIDGE RELAY @@ -7,26 +12,37 @@ https://github.com/42wim/matterbridge Chat with us on IRC: [#matterbridge @ irc.esper.net](irc://irc.esper.net/matterbridge) -Requires the matterbridge config api section to be setup along these lines: +## Downloads -``` -[api] -[api.local] - BindAddress="0.0.0.0:4242" # or listen only to localhost: 127.0.0.1:4242 - #OPTIONAL (no authorization if token is empty) - Token="mytoken" - Buffer=1000 - RemoteNickFormat="{NICK}" - ShowJoinPart = true -``` +[![Github All Releases](https://img.shields.io/github/downloads/elytra/MatterLink/total.svg?style=for-the-badge&label=Github%20Releases&logo=github)](https://github.com/elytra/MatterLink/releases) + +[![Jenkins](https://img.shields.io/jenkins/s/https/ci.elytradev.com/job/elytra/job/MatterLink/job/master.svg?style=for-the-badge&label=Jenkins%20Build)](https://ci.elytradev.com/job/elytra/job/MatterLink/job/master/lastSuccessfulBuild/artifact/) + +[![Files](https://curse.nikky.moe/api/img/287323/files?logo&style=for-the-badge&version=1.12.2)](https://minecraft.curseforge.com/projects/287323/files) + +[![Download](https://curse.nikky.moe/api/img/287323?logo&style=for-the-badge&version=1.12.2)](https://curse.nikky.moe/api/url/287323?version=1.12.2) + +[![Download](https://curse.nikky.moe/api/img/287323?logo&style=for-the-badge&version=1.11.2)](https://curse.nikky.moe/api/url/287323?version=1.11.2) + +[![Download](https://curse.nikky.moe/api/img/287323?logo&style=for-the-badge&version=1.10.2)](https://curse.nikky.moe/api/url/287323?version=1.10.2) + +[![Download](https://curse.nikky.moe/api/img/287323?logo&style=for-the-badge&version=1.7.10)](https://curse.nikky.moe/api/url/287323?version=1.7.10) + +## Dependencies + +[![Files](https://curse.nikky.moe/api/img/248453/files?logo&style=for-the-badge)](https://minecraft.curseforge.com/projects/248453/files) ## Features -* Custom bridge commands, including passthrough to MC! - Default commands: `help, tps, list, seed, uptime` +### Custom bridge commands + +including passthrough to MC! +Default commands: `help, tps, list, seed, uptime` + +Commands are specified in JSON format as follows: + +Passthrough command (executes the configured command from the MC server console) -Commands are specified in JSON format as follows: -Passthrough command (executes the configured command as if from the MC server console) ```json { "alias": "tps", @@ -37,7 +53,9 @@ Passthrough command (executes the configured command as if from the MC server co "allowArgs": false } ``` + Response command + ```json { "alias": "uptime", @@ -48,10 +66,13 @@ Response command "allowArgs": false } ``` -* Command permissions! + +### Command permissions + Higher numbers mean more permissions. Configured on a network-by-network basis. For IRC, this is your hostmask. For Discord, this is your userid (NOT the four-digit number.) + ```json { "irc.esper": { @@ -68,19 +89,21 @@ For Discord, this is your userid (NOT the four-digit number.) then reconnects. ``` -## Downloads - -https://github.com/elytra/MatterLink/releases - -https://ci.elytradev.com/job/elytra/job/MatterLink/job/master/lastSuccessfulBuild/ - may be unstable - -https://minecraft.curseforge.com/projects/matterlink - -## Dependencies - -- forgelin: https://minecraft.curseforge.com/projects/shadowfacts-forgelin - ## Setup + +Requires the matterbridge config api section to be setup along these lines: + +``` +[api] +[api.local] + BindAddress="0.0.0.0:4242" # or listen only to localhost: 127.0.0.1:4242 + #OPTIONAL (no authorization if token is empty) + Token="mytoken" + Buffer=1000 + RemoteNickFormat="{NICK}" + ShowJoinPart = true +``` + Now you just need to run MatterBridge on the server, the default configuration works with the provided sample. Install matterbridge and try out the basic sample: @@ -93,7 +116,6 @@ matterbridge now start the server with matterlink (and forgelin )in the mods folder - and then [RTFM!!!](https://github.com/42wim/matterbridge#configuration) and configure all your needed gateways, endpoints etc powered by wishful thinking \ No newline at end of file diff --git a/core/src/main/kotlin/matterlink/IMatterLink.kt b/core/src/main/kotlin/matterlink/IMatterLink.kt index 02d3216..48b9e64 100644 --- a/core/src/main/kotlin/matterlink/IMatterLink.kt +++ b/core/src/main/kotlin/matterlink/IMatterLink.kt @@ -4,7 +4,6 @@ import matterlink.bridge.MessageHandler import matterlink.bridge.command.BridgeCommandRegistry import matterlink.bridge.command.IMinecraftCommandSender import matterlink.config.cfg -import matterlink.update.UpdateChecker lateinit var instance: IMatterLink diff --git a/core/src/main/kotlin/matterlink/bridge/MessageHandler.kt b/core/src/main/kotlin/matterlink/bridge/MessageHandler.kt index 179fddf..526f6e5 100644 --- a/core/src/main/kotlin/matterlink/bridge/MessageHandler.kt +++ b/core/src/main/kotlin/matterlink/bridge/MessageHandler.kt @@ -70,7 +70,7 @@ object MessageHandler { )) } - if(firstRun) { + if (firstRun) { UpdateChecker.run() } } diff --git a/core/src/main/kotlin/matterlink/bridge/command/BridgeCommandRegistry.kt b/core/src/main/kotlin/matterlink/bridge/command/BridgeCommandRegistry.kt index eb41e4c..c63fab0 100644 --- a/core/src/main/kotlin/matterlink/bridge/command/BridgeCommandRegistry.kt +++ b/core/src/main/kotlin/matterlink/bridge/command/BridgeCommandRegistry.kt @@ -66,8 +66,8 @@ object BridgeCommandRegistry { operator fun get(command: String) = commandMap[command] fun getName(command: IBridgeCommand): String? { - commandMap.forEach{(alias, cmd) -> - if(command == cmd) return alias + commandMap.forEach { (alias, cmd) -> + if (command == cmd) return alias } return null } diff --git a/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt b/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt index 93a7184..7f99ecb 100644 --- a/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt +++ b/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt @@ -22,8 +22,7 @@ data class CustomCommand( override fun execute(alias: String, user: String, userId: String, server: String, args: String): Boolean { if (!allowArgs && args.isNotBlank()) return false - if (TickHandler.tickCounter - lastUsed < timeout) - { + if (TickHandler.tickCounter - lastUsed < timeout) { instance.debug("dropped command $alias") return true //eat command silently } diff --git a/core/src/main/kotlin/matterlink/bridge/command/HelpCommand.kt b/core/src/main/kotlin/matterlink/bridge/command/HelpCommand.kt index 85f2710..dfa34fc 100644 --- a/core/src/main/kotlin/matterlink/bridge/command/HelpCommand.kt +++ b/core/src/main/kotlin/matterlink/bridge/command/HelpCommand.kt @@ -2,7 +2,6 @@ package matterlink.bridge.command import matterlink.bridge.ApiMessage import matterlink.bridge.MessageHandler -import matterlink.config.cfg object HelpCommand : IBridgeCommand { override val help: String = "Returns the help string for the given command. Syntax: help " diff --git a/core/src/main/kotlin/matterlink/bridge/command/IMinecraftCommandSender.kt b/core/src/main/kotlin/matterlink/bridge/command/IMinecraftCommandSender.kt index 4eaa242..ec72121 100644 --- a/core/src/main/kotlin/matterlink/bridge/command/IMinecraftCommandSender.kt +++ b/core/src/main/kotlin/matterlink/bridge/command/IMinecraftCommandSender.kt @@ -2,8 +2,6 @@ package matterlink.bridge.command import matterlink.bridge.ApiMessage import matterlink.bridge.MessageHandler -import matterlink.config.cfg -import matterlink.instance abstract class IMinecraftCommandSender(val user: String, val userId: String, val server: String) { /** diff --git a/core/src/main/kotlin/matterlink/command/CommandCore.kt b/core/src/main/kotlin/matterlink/command/CommandCore.kt index 8687bb0..3c49d33 100644 --- a/core/src/main/kotlin/matterlink/command/CommandCore.kt +++ b/core/src/main/kotlin/matterlink/command/CommandCore.kt @@ -1,10 +1,8 @@ package matterlink.command -import matterlink.bridge.ApiMessage import matterlink.bridge.MessageHandler import matterlink.bridge.command.BridgeCommandRegistry import matterlink.config.cfg -import matterlink.instance object CommandCore { fun getName() = "bridge" diff --git a/core/src/main/kotlin/matterlink/handlers/DeathHandler.kt b/core/src/main/kotlin/matterlink/handlers/DeathHandler.kt index 64b6575..38b01c2 100644 --- a/core/src/main/kotlin/matterlink/handlers/DeathHandler.kt +++ b/core/src/main/kotlin/matterlink/handlers/DeathHandler.kt @@ -20,7 +20,7 @@ object DeathHandler { val emojis = cfg.outgoing.death.damageTypeMapping[damageType]?.split(' ') ?: listOf("\uD83D\uDC7B unknown type '$damageType'") val damageEmoji = emojis[random.nextInt(emojis.size)] - msg += " " + damageEmoji + msg += " $damageEmoji" } MessageHandler.transmit(ApiMessage( text = msg diff --git a/core/src/main/kotlin/matterlink/handlers/TickHandler.kt b/core/src/main/kotlin/matterlink/handlers/TickHandler.kt index 554d34f..a9d4837 100644 --- a/core/src/main/kotlin/matterlink/handlers/TickHandler.kt +++ b/core/src/main/kotlin/matterlink/handlers/TickHandler.kt @@ -22,7 +22,7 @@ object TickHandler { ServerChatHandler.writeIncomingToChat() - if(accumulator++ > updateInterval) { + if (accumulator++ > updateInterval) { accumulator -= updateInterval UpdateChecker.run() } diff --git a/core/src/main/kotlin/matterlink/update/CurseFile.kt b/core/src/main/kotlin/matterlink/update/CurseFile.kt index 559f0ce..e7b1c63 100644 --- a/core/src/main/kotlin/matterlink/update/CurseFile.kt +++ b/core/src/main/kotlin/matterlink/update/CurseFile.kt @@ -8,13 +8,4 @@ data class CurseFile( val gameVersion: List, val releaseType: String, val fileStatus: String -) { - companion object { - val gson = Gson() - - fun decode(json: String): CurseFile { - return gson.fromJson(json, CurseFile::class.java) - } - } - -} \ No newline at end of file +) \ No newline at end of file diff --git a/core/src/main/kotlin/matterlink/update/UpdateChecker.kt b/core/src/main/kotlin/matterlink/update/UpdateChecker.kt index 801b4c8..70c03be 100644 --- a/core/src/main/kotlin/matterlink/update/UpdateChecker.kt +++ b/core/src/main/kotlin/matterlink/update/UpdateChecker.kt @@ -7,9 +7,7 @@ import matterlink.bridge.MessageHandler import matterlink.config.cfg import matterlink.instance import org.apache.http.HttpResponse -import org.apache.http.client.HttpClient import org.apache.http.client.methods.HttpGet -import org.apache.http.impl.client.CloseableHttpClient import org.apache.http.impl.client.HttpClients import java.io.BufferedReader