Badges on all the README's and code formatting

This commit is contained in:
nikky 2018-05-05 16:44:02 +02:00
parent 928576c64b
commit 3de56755be
25 changed files with 73 additions and 79 deletions

View File

@ -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()
}
}

View File

@ -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

View File

@ -1,7 +1,6 @@
package matterlink
import matterlink.config.BaseConfig
import matterlink.config.cfg
import net.minecraftforge.common.config.Configuration
import java.io.File

View File

@ -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

View File

@ -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()
}
}

View File

@ -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

View File

@ -1,7 +1,6 @@
package matterlink
import matterlink.config.BaseConfig
import matterlink.config.cfg
import net.minecraftforge.common.config.Configuration
import java.io.File

View File

@ -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

View File

@ -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()
}
}

View File

@ -1,6 +1,5 @@
package matterlink
import matterlink.bridge.command.IMinecraftCommandSender
import matterlink.command.CommandMatterlink
import matterlink.command.MatterLinkCommandSender
import matterlink.config.cfg

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -70,7 +70,7 @@ object MessageHandler {
))
}
if(firstRun) {
if (firstRun) {
UpdateChecker.run()
}
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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 <command>"

View File

@ -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) {
/**

View File

@ -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"

View File

@ -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

View File

@ -22,7 +22,7 @@ object TickHandler {
ServerChatHandler.writeIncomingToChat()
if(accumulator++ > updateInterval) {
if (accumulator++ > updateInterval) {
accumulator -= updateInterval
UpdateChecker.run()
}

View File

@ -8,13 +8,4 @@ data class CurseFile(
val gameVersion: List<String>,
val releaseType: String,
val fileStatus: String
) {
companion object {
val gson = Gson()
fun decode(json: String): CurseFile {
return gson.fromJson(json, CurseFile::class.java)
}
}
}
)

View File

@ -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