repackage

This commit is contained in:
TONY_All 2023-05-04 21:46:09 +08:00
parent de1ad1d31b
commit 4db42f957c
61 changed files with 276 additions and 287 deletions

View File

@ -3,7 +3,7 @@ plugins {
id("com.github.johnrengelman.shadow") id("com.github.johnrengelman.shadow")
} }
group = "cc.maxmc.msm.controlled" group = "com.mohist.mistyrain.controlled"
repositories { repositories {
mavenCentral() mavenCentral()
@ -20,7 +20,7 @@ dependencies {
tasks.shadowJar { tasks.shadowJar {
archiveClassifier.set(null as? String?) archiveClassifier.set(null as? String?)
relocate("kotlin", "cc.maxmc.msm.lib.kotlin") relocate("kotlin", "com.mohist.mistyrain.lib.kotlin")
} }
tasks.build { tasks.build {

View File

@ -1,15 +1,15 @@
package cc.maxmc.msm.controlled package com.mohist.mistyrain.controlled
import cc.maxmc.msm.api.MultiServerManAPIProvider import com.mohist.mistyrain.api.MultiServerManAPIProvider
import cc.maxmc.msm.controlled.api.APIImpl import com.mohist.mistyrain.common.network.netty.NetworkRegistry
import cc.maxmc.msm.controlled.listener.APIPacketListener import com.mohist.mistyrain.controlled.api.APIImpl
import cc.maxmc.msm.controlled.command.Api import com.mohist.mistyrain.controlled.command.Api
import cc.maxmc.msm.controlled.command.Send import com.mohist.mistyrain.controlled.command.Send
import cc.maxmc.msm.controlled.listener.ProtocolListener import com.mohist.mistyrain.controlled.listener.APIPacketListener
import cc.maxmc.msm.controlled.netty.NetClient import com.mohist.mistyrain.controlled.listener.ProtocolListener
import cc.maxmc.msm.controlled.settings.Settings import com.mohist.mistyrain.controlled.netty.NetClient
import cc.maxmc.msm.controlled.settings.SettingsReader import com.mohist.mistyrain.controlled.settings.Settings
import cc.maxmc.msm.common.network.netty.NetworkRegistry import com.mohist.mistyrain.controlled.settings.SettingsReader
import net.md_5.bungee.api.ProxyServer import net.md_5.bungee.api.ProxyServer
import net.md_5.bungee.api.plugin.Plugin import net.md_5.bungee.api.plugin.Plugin

View File

@ -1,9 +1,9 @@
package cc.maxmc.msm.controlled.api package com.mohist.mistyrain.controlled.api
import cc.maxmc.msm.api.MultiServerManAPI import com.mohist.mistyrain.api.MultiServerManAPI
import cc.maxmc.msm.api.misc.MatchInfo import com.mohist.mistyrain.api.misc.MatchInfo
import cc.maxmc.msm.controlled.netty.NetClient import com.mohist.mistyrain.common.network.packet.PPacketAPICall
import cc.maxmc.msm.common.network.packet.PPacketAPICall import com.mohist.mistyrain.controlled.netty.NetClient
import java.util.* import java.util.*
import java.util.concurrent.CompletableFuture import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit

View File

@ -1,6 +1,6 @@
package cc.maxmc.msm.controlled.command package com.mohist.mistyrain.controlled.command
import cc.maxmc.msm.api.MultiServerManAPIProvider import com.mohist.mistyrain.api.MultiServerManAPIProvider
import net.md_5.bungee.api.CommandSender import net.md_5.bungee.api.CommandSender
import net.md_5.bungee.api.chat.TextComponent import net.md_5.bungee.api.chat.TextComponent
import net.md_5.bungee.api.plugin.Command import net.md_5.bungee.api.plugin.Command

View File

@ -1,7 +1,7 @@
package cc.maxmc.msm.controlled.command package com.mohist.mistyrain.controlled.command
import cc.maxmc.msm.controlled.netty.NetClient import com.mohist.mistyrain.common.network.packet.PPacketDebug
import cc.maxmc.msm.common.network.packet.PPacketDebug import com.mohist.mistyrain.controlled.netty.NetClient
import net.md_5.bungee.api.CommandSender import net.md_5.bungee.api.CommandSender
import net.md_5.bungee.api.chat.TextComponent import net.md_5.bungee.api.chat.TextComponent
import net.md_5.bungee.api.plugin.Command import net.md_5.bungee.api.plugin.Command

View File

@ -1,14 +1,13 @@
package cc.maxmc.msm.controlled.listener package com.mohist.mistyrain.controlled.listener
import cc.maxmc.msm.controlled.api.APIImpl import com.mohist.mistyrain.common.network.packet.CPacketAPICallback
import cc.maxmc.msm.common.event.PacketReceiveEvent import com.mohist.mistyrain.controlled.api.APIImpl
import cc.maxmc.msm.common.network.packet.CPacketAPICallback
import net.md_5.bungee.api.plugin.Listener import net.md_5.bungee.api.plugin.Listener
import net.md_5.bungee.event.EventHandler import net.md_5.bungee.event.EventHandler
object APIPacketListener : Listener { object APIPacketListener : Listener {
@EventHandler @EventHandler
fun onPacket(packetEvent: PacketReceiveEvent) { fun onPacket(packetEvent: com.mohist.mistyrain.common.event.PacketReceiveEvent) {
val packet = packetEvent.packet val packet = packetEvent.packet
if (packet !is CPacketAPICallback) { if (packet !is CPacketAPICallback) {
return return

View File

@ -1,14 +1,12 @@
package cc.maxmc.msm.controlled.listener package com.mohist.mistyrain.controlled.listener
import cc.maxmc.msm.controlled.Controlled import com.mohist.mistyrain.common.network.packet.*
import cc.maxmc.msm.controlled.misc.SubServer import com.mohist.mistyrain.common.utils.log
import cc.maxmc.msm.controlled.netty.NetClient import com.mohist.mistyrain.common.utils.pluginScope
import cc.maxmc.msm.controlled.settings.Settings import com.mohist.mistyrain.controlled.Controlled
import cc.maxmc.msm.common.event.ChannelInactiveEvent import com.mohist.mistyrain.controlled.misc.SubServer
import cc.maxmc.msm.common.event.PacketReceiveEvent import com.mohist.mistyrain.controlled.netty.NetClient
import cc.maxmc.msm.common.network.packet.* import com.mohist.mistyrain.controlled.settings.Settings
import cc.maxmc.msm.common.utils.log
import cc.maxmc.msm.common.utils.pluginScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import net.md_5.bungee.api.plugin.Listener import net.md_5.bungee.api.plugin.Listener
import net.md_5.bungee.event.EventHandler import net.md_5.bungee.event.EventHandler
@ -21,7 +19,7 @@ object ProtocolListener : Listener {
private val serverCache = HashMap<UUID, SubServer>() private val serverCache = HashMap<UUID, SubServer>()
@EventHandler @EventHandler
fun onGetInfo(packetE: PacketReceiveEvent) { fun onGetInfo(packetE: com.mohist.mistyrain.common.event.PacketReceiveEvent) {
if (packetE.packet !is CPacketGetInfo) return if (packetE.packet !is CPacketGetInfo) return
val types = Controlled.instance.dataFolder.toPath().resolve("patterns").listDirectoryEntries() val types = Controlled.instance.dataFolder.toPath().resolve("patterns").listDirectoryEntries()
.filter { it.isDirectory() }.map { it.name }.toMutableSet() .filter { it.isDirectory() }.map { it.name }.toMutableSet()
@ -30,7 +28,7 @@ object ProtocolListener : Listener {
} }
@EventHandler @EventHandler
fun onRequestServer(packetE: PacketReceiveEvent) { fun onRequestServer(packetE: com.mohist.mistyrain.common.event.PacketReceiveEvent) {
val packet = packetE.packet as? CPacketRequestServer ?: return val packet = packetE.packet as? CPacketRequestServer ?: return
val serverInfo = packet.serverInfo val serverInfo = packet.serverInfo
log("§a| §7正在启动服务器 ${serverInfo.server}") log("§a| §7正在启动服务器 ${serverInfo.server}")
@ -47,12 +45,12 @@ object ProtocolListener : Listener {
} }
@EventHandler @EventHandler
fun onDisconnect(evt: ChannelInactiveEvent) { fun onDisconnect(evt: com.mohist.mistyrain.common.event.ChannelInactiveEvent) {
log("§c| §7与远程服务器断开连接.") log("§c| §7与远程服务器断开连接.")
} }
@EventHandler @EventHandler
fun onServerEnd(evt: PacketReceiveEvent) { fun onServerEnd(evt: com.mohist.mistyrain.common.event.PacketReceiveEvent) {
val packet = evt.packet as? CPacketEndServer ?: return val packet = evt.packet as? CPacketEndServer ?: return
val serverInfo = packet.server val serverInfo = packet.server
val server = val server =

View File

@ -1,8 +1,8 @@
package cc.maxmc.msm.controlled.misc package com.mohist.mistyrain.controlled.misc
import cc.maxmc.msm.controlled.Controlled import com.mohist.mistyrain.controlled.Controlled
import cc.maxmc.msm.controlled.settings.Settings import com.mohist.mistyrain.controlled.settings.Settings
import cc.maxmc.msm.controlled.utils.ScriptRunner import com.mohist.mistyrain.controlled.utils.ScriptRunner
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import java.nio.file.Path import java.nio.file.Path

View File

@ -1,9 +1,8 @@
package cc.maxmc.msm.controlled.netty package com.mohist.mistyrain.controlled.netty
import cc.maxmc.msm.common.network.BungeePacket import com.mohist.mistyrain.common.network.netty.NetworkRegistry
import cc.maxmc.msm.common.network.netty.NetworkRegistry import com.mohist.mistyrain.common.utils.log
import cc.maxmc.msm.common.utils.log import com.mohist.mistyrain.common.utils.pipelineInit
import cc.maxmc.msm.common.utils.pipelineInit
import io.netty.bootstrap.Bootstrap import io.netty.bootstrap.Bootstrap
import io.netty.channel.Channel import io.netty.channel.Channel
import io.netty.channel.ChannelOption import io.netty.channel.ChannelOption
@ -44,7 +43,7 @@ object NetClient {
} }
} }
fun sendPacket(packet: BungeePacket) { fun sendPacket(packet: com.mohist.mistyrain.common.network.BungeePacket) {
channel.writeAndFlush(packet) channel.writeAndFlush(packet)
} }

View File

@ -1,6 +1,6 @@
package cc.maxmc.msm.controlled.settings package com.mohist.mistyrain.controlled.settings
import cc.maxmc.msm.controlled.settings.SettingsReader.config import com.mohist.mistyrain.controlled.settings.SettingsReader.config
object Settings { object Settings {
val name val name

View File

@ -1,6 +1,6 @@
package cc.maxmc.msm.controlled.settings package com.mohist.mistyrain.controlled.settings
import cc.maxmc.msm.controlled.Controlled import com.mohist.mistyrain.controlled.Controlled
import net.md_5.bungee.api.ProxyServer import net.md_5.bungee.api.ProxyServer
import net.md_5.bungee.api.chat.TextComponent import net.md_5.bungee.api.chat.TextComponent
import net.md_5.bungee.config.Configuration import net.md_5.bungee.config.Configuration

View File

@ -1,6 +1,6 @@
package cc.maxmc.msm.controlled.utils package com.mohist.mistyrain.controlled.utils
import cc.maxmc.msm.common.utils.log import com.mohist.mistyrain.common.utils.log
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import java.nio.file.Path import java.nio.file.Path

View File

@ -1,3 +1,3 @@
name: Controlled name: Controlled
main: cc.maxmc.msm.controlled.Controlled main: com.mohist.mistyrain.controlled.Controlled
author: MistyRain author: MistyRain

View File

@ -3,7 +3,7 @@ plugins {
id("com.github.johnrengelman.shadow") id("com.github.johnrengelman.shadow")
} }
group = "cc.maxmc.msm.mastercontrol" group = "com.mohist.mistyrain.mastercontrol"
repositories { repositories {
mavenCentral() mavenCentral()
@ -21,7 +21,7 @@ dependencies {
tasks.shadowJar { tasks.shadowJar {
archiveClassifier.set(null as? String?) archiveClassifier.set(null as? String?)
relocate("kotlin", "cc.maxmc.msm.lib.kotlin") relocate("kotlin", "com.mohist.mistyrain.lib.kotlin")
} }
tasks.build { tasks.build {

View File

@ -1,11 +1,11 @@
package cc.maxmc.msm.mastercontrol package com.mohist.mistyrain.mastercontrol
import cc.maxmc.msm.api.MultiServerManAPIProvider import com.mohist.mistyrain.api.MultiServerManAPIProvider
import cc.maxmc.msm.mastercontrol.api.APIImpl import com.mohist.mistyrain.mastercontrol.api.APIImpl
import cc.maxmc.msm.mastercontrol.listener.PacketListener import com.mohist.mistyrain.mastercontrol.listener.PacketListener
import cc.maxmc.msm.mastercontrol.manager.MatchManager import com.mohist.mistyrain.mastercontrol.manager.MatchManager
import cc.maxmc.msm.mastercontrol.manager.ServerManager import com.mohist.mistyrain.mastercontrol.manager.ServerManager
import cc.maxmc.msm.mastercontrol.netty.NetManager import com.mohist.mistyrain.mastercontrol.netty.NetManager
import net.md_5.bungee.api.ProxyServer import net.md_5.bungee.api.ProxyServer
import net.md_5.bungee.api.plugin.Plugin import net.md_5.bungee.api.plugin.Plugin

View File

@ -1,9 +1,9 @@
package cc.maxmc.msm.mastercontrol.api package com.mohist.mistyrain.mastercontrol.api
import cc.maxmc.msm.api.MultiServerManAPI import com.mohist.mistyrain.api.MultiServerManAPI
import cc.maxmc.msm.api.misc.MatchInfo import com.mohist.mistyrain.api.misc.MatchInfo
import cc.maxmc.msm.mastercontrol.database.SQLDatabase import com.mohist.mistyrain.mastercontrol.database.SQLDatabase
import cc.maxmc.msm.mastercontrol.manager.MatchManager import com.mohist.mistyrain.mastercontrol.manager.MatchManager
object APIImpl : MultiServerManAPI { object APIImpl : MultiServerManAPI {
override fun getServer(type: String, players: List<String>): MatchInfo { override fun getServer(type: String, players: List<String>): MatchInfo {

View File

@ -1,8 +1,8 @@
package cc.maxmc.msm.mastercontrol.database package com.mohist.mistyrain.mastercontrol.database
import cc.maxmc.msm.api.misc.MatchInfo import com.mohist.mistyrain.api.misc.MatchInfo
import cc.maxmc.msm.mastercontrol.manager.MatchManager import com.mohist.mistyrain.mastercontrol.manager.MatchManager
import cc.maxmc.msm.mastercontrol.settings.Settings import com.mohist.mistyrain.mastercontrol.settings.Settings
import com.zaxxer.hikari.HikariConfig import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.pool.HikariPool import com.zaxxer.hikari.pool.HikariPool
import java.sql.Timestamp import java.sql.Timestamp

View File

@ -1,15 +1,12 @@
package cc.maxmc.msm.mastercontrol.listener package com.mohist.mistyrain.mastercontrol.listener
import cc.maxmc.msm.api.MultiServerManAPIProvider import com.mohist.mistyrain.api.MultiServerManAPIProvider
import cc.maxmc.msm.common.event.ChannelActiveEvent import com.mohist.mistyrain.common.network.packet.CPacketAPICallback
import cc.maxmc.msm.common.event.ChannelInactiveEvent import com.mohist.mistyrain.common.network.packet.CPacketDebug
import cc.maxmc.msm.common.event.PacketReceiveEvent import com.mohist.mistyrain.common.network.packet.PPacketAPICall
import cc.maxmc.msm.common.network.packet.CPacketAPICallback import com.mohist.mistyrain.common.network.packet.PPacketDebug
import cc.maxmc.msm.common.network.packet.CPacketDebug import com.mohist.mistyrain.common.utils.log
import cc.maxmc.msm.common.network.packet.PPacketAPICall import com.mohist.mistyrain.mastercontrol.manager.ChildManager
import cc.maxmc.msm.common.network.packet.PPacketDebug
import cc.maxmc.msm.common.utils.log
import cc.maxmc.msm.mastercontrol.manager.ChildManager
import net.md_5.bungee.api.plugin.Listener import net.md_5.bungee.api.plugin.Listener
import net.md_5.bungee.event.EventHandler import net.md_5.bungee.event.EventHandler
@ -17,7 +14,7 @@ object PacketListener : Listener {
val api = MultiServerManAPIProvider.getAPI() val api = MultiServerManAPIProvider.getAPI()
@EventHandler @EventHandler
fun onAPICall(evt: PacketReceiveEvent) { fun onAPICall(evt: com.mohist.mistyrain.common.event.PacketReceiveEvent) {
val packet = evt.packet val packet = evt.packet
if (packet !is PPacketAPICall) return if (packet !is PPacketAPICall) return
val callback = when (packet) { val callback = when (packet) {
@ -42,7 +39,7 @@ object PacketListener : Listener {
} }
@EventHandler @EventHandler
fun onPacket(evt: PacketReceiveEvent) { fun onPacket(evt: com.mohist.mistyrain.common.event.PacketReceiveEvent) {
val packet = evt.packet val packet = evt.packet
if (packet !is PPacketDebug) { if (packet !is PPacketDebug) {
return return
@ -52,13 +49,13 @@ object PacketListener : Listener {
} }
@EventHandler @EventHandler
fun onChannelActive(evt: ChannelActiveEvent) { fun onChannelActive(evt: com.mohist.mistyrain.common.event.ChannelActiveEvent) {
log("§a| §7子BC ${evt.channel.remoteAddress()} 成功连接.") log("§a| §7子BC ${evt.channel.remoteAddress()} 成功连接.")
ChildManager.registerChild(evt.channel) ChildManager.registerChild(evt.channel)
} }
@EventHandler @EventHandler
fun onChannelInactive(evt: ChannelInactiveEvent) { fun onChannelInactive(evt: com.mohist.mistyrain.common.event.ChannelInactiveEvent) {
log("§c| §7子BC ${evt.channel.remoteAddress()} 断开连接.") log("§c| §7子BC ${evt.channel.remoteAddress()} 断开连接.")
ChildManager.unregisterChild(evt.channel) ChildManager.unregisterChild(evt.channel)
} }

View File

@ -1,11 +1,11 @@
package cc.maxmc.msm.mastercontrol.manager package com.mohist.mistyrain.mastercontrol.manager
import cc.maxmc.msm.common.network.packet.CPacketGetInfo import com.mohist.mistyrain.common.network.packet.CPacketGetInfo
import cc.maxmc.msm.common.network.packet.PPacketChildInfo import com.mohist.mistyrain.common.network.packet.PPacketChildInfo
import cc.maxmc.msm.common.utils.awaitPacket import com.mohist.mistyrain.common.utils.awaitPacket
import cc.maxmc.msm.common.utils.log import com.mohist.mistyrain.common.utils.log
import cc.maxmc.msm.common.utils.pluginScope import com.mohist.mistyrain.common.utils.pluginScope
import cc.maxmc.msm.mastercontrol.misc.ChildBungee import com.mohist.mistyrain.mastercontrol.misc.ChildBungee
import io.netty.channel.Channel import io.netty.channel.Channel
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.util.* import java.util.*

View File

@ -1,7 +1,7 @@
package cc.maxmc.msm.mastercontrol.manager package com.mohist.mistyrain.mastercontrol.manager
import cc.maxmc.msm.api.misc.MatchInfo import com.mohist.mistyrain.api.misc.MatchInfo
import cc.maxmc.msm.mastercontrol.database.SQLDatabase import com.mohist.mistyrain.mastercontrol.database.SQLDatabase
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
object MatchManager { object MatchManager {

View File

@ -1,10 +1,10 @@
package cc.maxmc.msm.mastercontrol.manager package com.mohist.mistyrain.mastercontrol.manager
import cc.maxmc.msm.api.misc.ServerInfo import com.mohist.mistyrain.api.misc.ServerInfo
import cc.maxmc.msm.common.network.packet.CPacketEndServer import com.mohist.mistyrain.common.network.packet.CPacketEndServer
import cc.maxmc.msm.common.utils.log import com.mohist.mistyrain.common.utils.log
import cc.maxmc.msm.common.utils.pluginScope import com.mohist.mistyrain.common.utils.pluginScope
import cc.maxmc.msm.mastercontrol.misc.ChildBungee import com.mohist.mistyrain.mastercontrol.misc.ChildBungee
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.util.* import java.util.*

View File

@ -1,11 +1,10 @@
package cc.maxmc.msm.mastercontrol.misc package com.mohist.mistyrain.mastercontrol.misc
import cc.maxmc.msm.api.misc.ServerInfo import com.mohist.mistyrain.api.misc.ServerInfo
import cc.maxmc.msm.common.network.BungeePacket import com.mohist.mistyrain.common.network.packet.CPacketRequestServer
import cc.maxmc.msm.common.network.packet.CPacketRequestServer import com.mohist.mistyrain.common.network.packet.PPacketServerStarted
import cc.maxmc.msm.common.network.packet.PPacketServerStarted import com.mohist.mistyrain.common.utils.awaitPacket
import cc.maxmc.msm.common.utils.awaitPacket import com.mohist.mistyrain.common.utils.log
import cc.maxmc.msm.common.utils.log
import io.netty.channel.Channel import io.netty.channel.Channel
import java.net.InetSocketAddress import java.net.InetSocketAddress
import java.util.* import java.util.*
@ -13,7 +12,7 @@ import java.util.*
class ChildBungee( class ChildBungee(
val channel: Channel, val ports: Set<Int>, val types: Set<String>, val usedPorts: MutableSet<Int> = HashSet() val channel: Channel, val ports: Set<Int>, val types: Set<String>, val usedPorts: MutableSet<Int> = HashSet()
) { ) {
fun sendPacket(packet: BungeePacket) { fun sendPacket(packet: com.mohist.mistyrain.common.network.BungeePacket) {
channel.writeAndFlush(packet) channel.writeAndFlush(packet)
} }

View File

@ -1,9 +1,9 @@
package cc.maxmc.msm.mastercontrol.netty package com.mohist.mistyrain.mastercontrol.netty
import cc.maxmc.msm.common.network.netty.NetworkRegistry import com.mohist.mistyrain.common.network.netty.NetworkRegistry
import cc.maxmc.msm.common.utils.log import com.mohist.mistyrain.common.utils.log
import cc.maxmc.msm.common.utils.pipelineInit import com.mohist.mistyrain.common.utils.pipelineInit
import cc.maxmc.msm.mastercontrol.settings.Settings import com.mohist.mistyrain.mastercontrol.settings.Settings
import io.netty.bootstrap.ServerBootstrap import io.netty.bootstrap.ServerBootstrap
import io.netty.channel.ChannelFutureListener import io.netty.channel.ChannelFutureListener
import io.netty.channel.nio.NioEventLoopGroup import io.netty.channel.nio.NioEventLoopGroup

View File

@ -1,6 +1,6 @@
package cc.maxmc.msm.mastercontrol.settings package com.mohist.mistyrain.mastercontrol.settings
import cc.maxmc.msm.mastercontrol.settings.SettingsReader.config import com.mohist.mistyrain.mastercontrol.settings.SettingsReader.config
object Settings { object Settings {
val serverPort val serverPort

View File

@ -1,6 +1,6 @@
package cc.maxmc.msm.mastercontrol.settings package com.mohist.mistyrain.mastercontrol.settings
import cc.maxmc.msm.mastercontrol.MasterControl import com.mohist.mistyrain.mastercontrol.MasterControl
import net.md_5.bungee.api.ProxyServer import net.md_5.bungee.api.ProxyServer
import net.md_5.bungee.api.chat.TextComponent import net.md_5.bungee.api.chat.TextComponent
import net.md_5.bungee.config.Configuration import net.md_5.bungee.config.Configuration

View File

@ -1,3 +1,3 @@
name: MasterControl name: MasterControl
main: cc.maxmc.msm.mastercontrol.MasterControl main: com.mohist.mistyrain.mastercontrol.MasterControl
author: MistyRain author: MistyRain

View File

@ -74,15 +74,16 @@
- `match` - `match`
| id(int) | start(datetime) | end(datetime) | players(text) | type(varchar) | | id(int) | start(datetime) | end(datetime) | players(text) | type(varchar) |
| ------- | --------------- | ------------- | ------------------------------------ | ------------- | |---------|-----------------|---------------|--------------------------------------|---------------|
| 1 | 1678554776 | 1678554784 | TONY_All,Sanseyooyea,PlayerA,PlayerB | bedwars | | 1 | 1678554776 | 1678554784 | TONY_All,Sanseyooyea,PlayerA,PlayerB | bedwars |
## API 使用 ## API 使用
依赖: 依赖:
```kotlin ```kotlin
dependencies { dependencies {
compileOnly("cc.maxmc.msm:MultiServerMan-API:${version}") compileOnly("com.mohist.mistyrain:MultiServerMan-API:${version}")
} }
``` ```
@ -91,8 +92,8 @@ dependencies {
```java ```java
List<ProxyPlayer> players; List<ProxyPlayer> players;
MultiServerManAPI api = MultiServerManAPIProvider.getAPI(); MultiServerManAPI api=MultiServerManAPIProvider.getAPI();
api.getServer("default", players); api.getServer("default",players);
``` ```
## Q&A ## Q&A

View File

@ -2,7 +2,7 @@ plugins {
kotlin("jvm") kotlin("jvm")
} }
group = "cc.maxmc.msm.api" group = "com.mohist.mistyrain.api"
repositories { repositories {
mavenCentral() mavenCentral()

View File

@ -1,6 +1,6 @@
package cc.maxmc.msm.api; package com.mohist.mistyrain.api;
import cc.maxmc.msm.api.misc.MatchInfo; import com.mohist.mistyrain.api.misc.MatchInfo;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package cc.maxmc.msm.api; package com.mohist.mistyrain.api;
@SuppressWarnings("unused") // API @SuppressWarnings("unused") // API
public class MultiServerManAPIProvider { public class MultiServerManAPIProvider {

View File

@ -1,4 +1,4 @@
package cc.maxmc.msm.api.misc package com.mohist.mistyrain.api.misc
enum class EnumAPI { enum class EnumAPI {
GET_SERVER, GET_SERVER,

View File

@ -1,4 +1,4 @@
package cc.maxmc.msm.api.misc; package com.mohist.mistyrain.api.misc;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package cc.maxmc.msm.api.misc; package com.mohist.mistyrain.api.misc;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -2,7 +2,7 @@ plugins {
`maven-publish` `maven-publish`
} }
group = "cc.maxmc.msm" group = "com.mohist.mistyrain"
version = "1.1.0" version = "1.1.0"

View File

@ -2,7 +2,7 @@ plugins {
kotlin("jvm") kotlin("jvm")
} }
group = "cc.maxmc.msm.common" group = "com.mohist.mistyrain.common"
repositories { repositories {
mavenCentral() mavenCentral()

View File

@ -1,3 +0,0 @@
package cc.maxmc.msm.common
object Placeholder

View File

@ -1,6 +0,0 @@
package cc.maxmc.msm.common.event
import io.netty.channel.Channel
import net.md_5.bungee.api.plugin.Event
class ChannelActiveEvent(val channel: Channel): Event()

View File

@ -1,6 +0,0 @@
package cc.maxmc.msm.common.event
import io.netty.channel.Channel
import net.md_5.bungee.api.plugin.Event
class ChannelInactiveEvent(val channel: Channel): Event()

View File

@ -1,19 +0,0 @@
package cc.maxmc.msm.common.network.packet
import cc.maxmc.msm.api.misc.ServerInfo
import cc.maxmc.msm.common.network.BungeePacket
import cc.maxmc.msm.common.utils.readServerInfo
import cc.maxmc.msm.common.utils.writeServerInfo
import io.netty.buffer.ByteBuf
class CPacketEndServer(
var server: ServerInfo
) : BungeePacket() {
override fun encode(buf: ByteBuf) {
buf.writeServerInfo(server)
}
override fun decode(buf: ByteBuf) {
server = buf.readServerInfo()
}
}

View File

@ -1,11 +0,0 @@
package cc.maxmc.msm.common.network.packet
import cc.maxmc.msm.common.network.BungeePacket
import io.netty.buffer.ByteBuf
class CPacketGetInfo : BungeePacket() {
override fun encode(buf: ByteBuf) {}
override fun decode(buf: ByteBuf) {}
}

View File

@ -1,24 +0,0 @@
package cc.maxmc.msm.common.utils
import cc.maxmc.msm.common.network.BungeePacket
import io.netty.channel.Channel
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlin.coroutines.Continuation
import kotlin.coroutines.suspendCoroutine
val pluginScope = CoroutineScope(SupervisorJob() + CoroutineExceptionHandler { _, except ->
log("§c执行异步操作时出现异常 ${except.message}")
except.printStackTrace()
})
val awaiting =
ArrayList<Triple<Class<out BungeePacket>, (Channel, BungeePacket) -> Boolean, Continuation<BungeePacket>>>()
suspend inline fun <T : BungeePacket> awaitPacket(packetClass: Class<T>, noinline filter: (Channel, T) -> Boolean) =
suspendCoroutine<T> {
val triple = Triple(packetClass, filter, it)
@Suppress("UNCHECKED_CAST")
awaiting.add(triple as Triple<Class<out BungeePacket>, (Channel, BungeePacket) -> Boolean, Continuation<BungeePacket>>)
}

View File

@ -0,0 +1,3 @@
package com.mohist.mistyrain.common
object Placeholder

View File

@ -0,0 +1,6 @@
package com.mohist.mistyrain.common.event
import io.netty.channel.Channel
import net.md_5.bungee.api.plugin.Event
class ChannelActiveEvent(val channel: Channel) : Event()

View File

@ -0,0 +1,6 @@
package com.mohist.mistyrain.common.event
import io.netty.channel.Channel
import net.md_5.bungee.api.plugin.Event
class ChannelInactiveEvent(val channel: Channel) : Event()

View File

@ -1,7 +1,7 @@
package cc.maxmc.msm.common.event package com.mohist.mistyrain.common.event
import cc.maxmc.msm.common.network.BungeePacket
import io.netty.channel.Channel import io.netty.channel.Channel
import net.md_5.bungee.api.plugin.Event import net.md_5.bungee.api.plugin.Event
data class PacketReceiveEvent(val channel: Channel, val packet: BungeePacket) : Event() data class PacketReceiveEvent(val channel: Channel, val packet: com.mohist.mistyrain.common.network.BungeePacket) :
Event()

View File

@ -1,8 +1,8 @@
package cc.maxmc.msm.common.network package com.mohist.mistyrain.common.network
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
abstract class BungeePacket: Cloneable { abstract class BungeePacket : Cloneable {
abstract fun encode(buf: ByteBuf) abstract fun encode(buf: ByteBuf)
abstract fun decode(buf: ByteBuf) abstract fun decode(buf: ByteBuf)

View File

@ -1,10 +1,9 @@
package cc.maxmc.msm.common.network package com.mohist.mistyrain.common.network
import cc.maxmc.msm.common.event.ChannelActiveEvent import com.mohist.mistyrain.common.event.ChannelActiveEvent
import cc.maxmc.msm.common.event.ChannelInactiveEvent import com.mohist.mistyrain.common.event.ChannelInactiveEvent
import cc.maxmc.msm.common.event.PacketReceiveEvent import com.mohist.mistyrain.common.event.PacketReceiveEvent
import cc.maxmc.msm.common.utils.awaiting import com.mohist.mistyrain.common.utils.awaiting
import cc.maxmc.msm.common.utils.log
import io.netty.channel.ChannelHandler.Sharable import io.netty.channel.ChannelHandler.Sharable
import io.netty.channel.ChannelHandlerContext import io.netty.channel.ChannelHandlerContext
import io.netty.channel.SimpleChannelInboundHandler import io.netty.channel.SimpleChannelInboundHandler

View File

@ -1,13 +1,16 @@
package cc.maxmc.msm.common.network.netty package com.mohist.mistyrain.common.network.netty
import cc.maxmc.msm.common.network.BungeePacket
import cc.maxmc.msm.common.utils.debug
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
import io.netty.channel.ChannelHandlerContext import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.ByteToMessageCodec import io.netty.handler.codec.ByteToMessageCodec
class ClusterMsgCodec(private val current: NetworkRegistry.PacketDirection) : ByteToMessageCodec<BungeePacket>() { class ClusterMsgCodec(private val current: NetworkRegistry.PacketDirection) :
override fun encode(ctx: ChannelHandlerContext, msg: BungeePacket, out: ByteBuf) { ByteToMessageCodec<com.mohist.mistyrain.common.network.BungeePacket>() {
override fun encode(
ctx: ChannelHandlerContext,
msg: com.mohist.mistyrain.common.network.BungeePacket,
out: ByteBuf
) {
val id = NetworkRegistry.getPacketID(current, msg) val id = NetworkRegistry.getPacketID(current, msg)
out.writeInt(id) out.writeInt(id)
msg.encode(out) msg.encode(out)

View File

@ -1,12 +1,11 @@
package cc.maxmc.msm.common.network.netty package com.mohist.mistyrain.common.network.netty
import cc.maxmc.msm.common.network.BungeePacket
import cc.maxmc.msm.common.network.packet.*
import com.google.common.collect.HashBiMap import com.google.common.collect.HashBiMap
import com.mohist.mistyrain.common.network.packet.*
object NetworkRegistry { object NetworkRegistry {
private val parentBoundMap = HashBiMap.create<Int, Class<out BungeePacket>>() private val parentBoundMap = HashBiMap.create<Int, Class<out com.mohist.mistyrain.common.network.BungeePacket>>()
private val childBoundMap = HashBiMap.create<Int, Class<out BungeePacket>>() private val childBoundMap = HashBiMap.create<Int, Class<out com.mohist.mistyrain.common.network.BungeePacket>>()
init { init {
registerPacket(PacketDirection.PARENT_BOUND, PPacketDebug::class.java) registerPacket(PacketDirection.PARENT_BOUND, PPacketDebug::class.java)
@ -27,7 +26,10 @@ object NetworkRegistry {
} }
private fun registerPacket(direction: PacketDirection, packet: Class<out BungeePacket>) { private fun registerPacket(
direction: PacketDirection,
packet: Class<out com.mohist.mistyrain.common.network.BungeePacket>
) {
if (direction == PacketDirection.PARENT_BOUND) { if (direction == PacketDirection.PARENT_BOUND) {
parentBoundMap parentBoundMap
} else { } else {
@ -37,12 +39,12 @@ object NetworkRegistry {
} }
} }
fun getPacketID(side: PacketDirection, packet: BungeePacket): Int { fun getPacketID(side: PacketDirection, packet: com.mohist.mistyrain.common.network.BungeePacket): Int {
val map = if (side == PacketDirection.PARENT_BOUND) childBoundMap else parentBoundMap val map = if (side == PacketDirection.PARENT_BOUND) childBoundMap else parentBoundMap
return map.inverse()[packet::class.java] ?: throw IllegalStateException("Packet does not in registry.") return map.inverse()[packet::class.java] ?: throw IllegalStateException("Packet does not in registry.")
} }
fun getPacketByID(side: PacketDirection, id: Int): BungeePacket { fun getPacketByID(side: PacketDirection, id: Int): com.mohist.mistyrain.common.network.BungeePacket {
val map = if (side == PacketDirection.PARENT_BOUND) parentBoundMap else childBoundMap val map = if (side == PacketDirection.PARENT_BOUND) parentBoundMap else childBoundMap
return map[id]?.newInstance() ?: throw IllegalStateException("Packet does not in registry.") return map[id]?.newInstance() ?: throw IllegalStateException("Packet does not in registry.")
} }

View File

@ -1,16 +1,15 @@
package cc.maxmc.msm.common.network.packet package com.mohist.mistyrain.common.network.packet
import cc.maxmc.msm.api.misc.MatchInfo import com.mohist.mistyrain.api.misc.MatchInfo
import cc.maxmc.msm.common.network.BungeePacket import com.mohist.mistyrain.common.utils.readMatchInfo
import cc.maxmc.msm.common.utils.readMatchInfo import com.mohist.mistyrain.common.utils.writeMatchInfo
import cc.maxmc.msm.common.utils.writeMatchInfo
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
import net.md_5.bungee.protocol.DefinedPacket import net.md_5.bungee.protocol.DefinedPacket
import java.util.* import java.util.*
sealed class CPacketAPICallback( sealed class CPacketAPICallback(
var uid: UUID var uid: UUID
) : BungeePacket() { ) : com.mohist.mistyrain.common.network.BungeePacket() {
override fun encode(buf: ByteBuf) { override fun encode(buf: ByteBuf) {
DefinedPacket.writeUUID(uid, buf) DefinedPacket.writeUUID(uid, buf)
} }

View File

@ -1,11 +1,10 @@
package cc.maxmc.msm.common.network.packet package com.mohist.mistyrain.common.network.packet
import cc.maxmc.msm.common.network.BungeePacket
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
data class CPacketDebug( data class CPacketDebug(
var content: String = "" var content: String = ""
) : BungeePacket() { ) : com.mohist.mistyrain.common.network.BungeePacket() {
override fun encode(buf: ByteBuf) { override fun encode(buf: ByteBuf) {
val array = content.encodeToByteArray() val array = content.encodeToByteArray()

View File

@ -0,0 +1,18 @@
package com.mohist.mistyrain.common.network.packet
import com.mohist.mistyrain.api.misc.ServerInfo
import com.mohist.mistyrain.common.utils.readServerInfo
import com.mohist.mistyrain.common.utils.writeServerInfo
import io.netty.buffer.ByteBuf
class CPacketEndServer(
var server: ServerInfo
) : com.mohist.mistyrain.common.network.BungeePacket() {
override fun encode(buf: ByteBuf) {
buf.writeServerInfo(server)
}
override fun decode(buf: ByteBuf) {
server = buf.readServerInfo()
}
}

View File

@ -0,0 +1,10 @@
package com.mohist.mistyrain.common.network.packet
import io.netty.buffer.ByteBuf
class CPacketGetInfo : com.mohist.mistyrain.common.network.BungeePacket() {
override fun encode(buf: ByteBuf) {}
override fun decode(buf: ByteBuf) {}
}

View File

@ -1,16 +1,15 @@
package cc.maxmc.msm.common.network.packet package com.mohist.mistyrain.common.network.packet
import cc.maxmc.msm.api.misc.ServerInfo import com.mohist.mistyrain.api.misc.ServerInfo
import cc.maxmc.msm.common.network.BungeePacket import com.mohist.mistyrain.common.utils.readServerInfo
import cc.maxmc.msm.common.utils.readServerInfo import com.mohist.mistyrain.common.utils.writeServerInfo
import cc.maxmc.msm.common.utils.writeServerInfo
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
import net.md_5.bungee.protocol.DefinedPacket import net.md_5.bungee.protocol.DefinedPacket
class CPacketRequestServer( class CPacketRequestServer(
var type: String = "", var type: String = "",
var serverInfo: ServerInfo = ServerInfo(), var serverInfo: ServerInfo = ServerInfo(),
) : BungeePacket() { ) : com.mohist.mistyrain.common.network.BungeePacket() {
override fun encode(buf: ByteBuf) { override fun encode(buf: ByteBuf) {
DefinedPacket.writeString(type, buf) DefinedPacket.writeString(type, buf)
buf.writeServerInfo(serverInfo) buf.writeServerInfo(serverInfo)

View File

@ -1,7 +1,6 @@
package cc.maxmc.msm.common.network.packet package com.mohist.mistyrain.common.network.packet
import cc.maxmc.msm.api.misc.EnumAPI import com.mohist.mistyrain.api.misc.EnumAPI
import cc.maxmc.msm.common.network.BungeePacket
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
import net.md_5.bungee.protocol.DefinedPacket import net.md_5.bungee.protocol.DefinedPacket
import java.util.* import java.util.*
@ -9,7 +8,7 @@ import java.util.*
sealed class PPacketAPICall( sealed class PPacketAPICall(
var api: EnumAPI = EnumAPI.GET_SERVER, var api: EnumAPI = EnumAPI.GET_SERVER,
var uid: UUID = UUID.randomUUID() var uid: UUID = UUID.randomUUID()
) : BungeePacket() { ) : com.mohist.mistyrain.common.network.BungeePacket() {
override fun encode(buf: ByteBuf) { override fun encode(buf: ByteBuf) {
DefinedPacket.writeVarInt(api.ordinal, buf) DefinedPacket.writeVarInt(api.ordinal, buf)
DefinedPacket.writeUUID(uid, buf) DefinedPacket.writeUUID(uid, buf)

View File

@ -1,11 +1,10 @@
package cc.maxmc.msm.common.network.packet package com.mohist.mistyrain.common.network.packet
import cc.maxmc.msm.common.network.BungeePacket
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
import net.md_5.bungee.protocol.DefinedPacket import net.md_5.bungee.protocol.DefinedPacket
class PPacketChildInfo(var portRange: MutableSet<Int> = HashSet(), var types: MutableSet<String> = HashSet()) : class PPacketChildInfo(var portRange: MutableSet<Int> = HashSet(), var types: MutableSet<String> = HashSet()) :
BungeePacket() { com.mohist.mistyrain.common.network.BungeePacket() {
override fun encode(buf: ByteBuf) { override fun encode(buf: ByteBuf) {
DefinedPacket.writeVarInt(portRange.size, buf) DefinedPacket.writeVarInt(portRange.size, buf)
portRange.forEach { portRange.forEach {

View File

@ -1,11 +1,10 @@
package cc.maxmc.msm.common.network.packet package com.mohist.mistyrain.common.network.packet
import cc.maxmc.msm.common.network.BungeePacket
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
data class PPacketDebug( data class PPacketDebug(
var content: String = "" var content: String = ""
) : BungeePacket() { ) : com.mohist.mistyrain.common.network.BungeePacket() {
override fun encode(buf: ByteBuf) { override fun encode(buf: ByteBuf) {
val array = content.encodeToByteArray() val array = content.encodeToByteArray()

View File

@ -1,14 +1,13 @@
package cc.maxmc.msm.common.network.packet package com.mohist.mistyrain.common.network.packet
import cc.maxmc.msm.api.misc.ServerInfo import com.mohist.mistyrain.api.misc.ServerInfo
import cc.maxmc.msm.common.network.BungeePacket import com.mohist.mistyrain.common.utils.readServerInfo
import cc.maxmc.msm.common.utils.readServerInfo import com.mohist.mistyrain.common.utils.writeServerInfo
import cc.maxmc.msm.common.utils.writeServerInfo
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
class PPacketServerStarted( class PPacketServerStarted(
var serverInfo: ServerInfo = ServerInfo() var serverInfo: ServerInfo = ServerInfo()
) : BungeePacket() { ) : com.mohist.mistyrain.common.network.BungeePacket() {
override fun encode(buf: ByteBuf) { override fun encode(buf: ByteBuf) {
buf.writeServerInfo(serverInfo) buf.writeServerInfo(serverInfo)
} }

View File

@ -0,0 +1,26 @@
package com.mohist.mistyrain.common.utils
import io.netty.channel.Channel
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlin.coroutines.Continuation
import kotlin.coroutines.suspendCoroutine
val pluginScope = CoroutineScope(SupervisorJob() + CoroutineExceptionHandler { _, except ->
log("§c执行异步操作时出现异常 ${except.message}")
except.printStackTrace()
})
val awaiting =
ArrayList<Triple<Class<out com.mohist.mistyrain.common.network.BungeePacket>, (Channel, com.mohist.mistyrain.common.network.BungeePacket) -> Boolean, Continuation<com.mohist.mistyrain.common.network.BungeePacket>>>()
suspend inline fun <T : com.mohist.mistyrain.common.network.BungeePacket> awaitPacket(
packetClass: Class<T>,
noinline filter: (Channel, T) -> Boolean
) =
suspendCoroutine<T> {
val triple = Triple(packetClass, filter, it)
@Suppress("UNCHECKED_CAST")
awaiting.add(triple as Triple<Class<out com.mohist.mistyrain.common.network.BungeePacket>, (Channel, com.mohist.mistyrain.common.network.BungeePacket) -> Boolean, Continuation<com.mohist.mistyrain.common.network.BungeePacket>>)
}

View File

@ -1,4 +1,4 @@
package cc.maxmc.msm.common.utils package com.mohist.mistyrain.common.utils
import net.md_5.bungee.api.ProxyServer import net.md_5.bungee.api.ProxyServer
import net.md_5.bungee.api.chat.TextComponent import net.md_5.bungee.api.chat.TextComponent

View File

@ -1,10 +1,9 @@
package cc.maxmc.msm.common.utils package com.mohist.mistyrain.common.utils
import cc.maxmc.msm.api.misc.MatchInfo import com.mohist.mistyrain.api.misc.MatchInfo
import cc.maxmc.msm.api.misc.ServerInfo import com.mohist.mistyrain.api.misc.ServerInfo
import cc.maxmc.msm.common.network.ClusterPacketHandler import com.mohist.mistyrain.common.network.netty.ClusterMsgCodec
import cc.maxmc.msm.common.network.netty.ClusterMsgCodec import com.mohist.mistyrain.common.network.netty.NetworkRegistry
import cc.maxmc.msm.common.network.netty.NetworkRegistry
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
import io.netty.channel.Channel import io.netty.channel.Channel
import io.netty.channel.ChannelInitializer import io.netty.channel.ChannelInitializer
@ -23,7 +22,7 @@ fun pipelineInit(direction: NetworkRegistry.PacketDirection) = channelInit<Socke
pipeline().addLast("frame_decoder", Varint21FrameDecoder()) pipeline().addLast("frame_decoder", Varint21FrameDecoder())
pipeline().addLast("frame_prepender", Varint21LengthFieldPrepender()) pipeline().addLast("frame_prepender", Varint21LengthFieldPrepender())
pipeline().addLast("codec", ClusterMsgCodec(direction)) pipeline().addLast("codec", ClusterMsgCodec(direction))
pipeline().addLast("packet_handler", ClusterPacketHandler) pipeline().addLast("packet_handler", com.mohist.mistyrain.common.network.ClusterPacketHandler)
} }
fun ByteBuf.writeServerInfo(info: ServerInfo) { fun ByteBuf.writeServerInfo(info: ServerInfo) {