-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
524 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import io.itsusinn.pkg.pkgIn | ||
import net.fabricmc.loom.api.LoomGradleExtensionAPI | ||
|
||
plugins { | ||
java | ||
kotlin("jvm") | ||
id("architectury-plugin") | ||
id("dev.architectury.loom") | ||
id("com.github.johnrengelman.shadow") | ||
id("io.itsusinn.pkg") | ||
} | ||
architectury { | ||
minecraft = "1.18.2" | ||
platformSetupLoomIde() | ||
forge() | ||
} | ||
repositories { | ||
maven("https://files.minecraftforge.net/maven") | ||
maven("https://maven.minecraftforge.net") | ||
maven("https://maven.parchmentmc.org") | ||
mavenCentral() | ||
} | ||
pkg { | ||
excludePath("META-INF/*.kotlin_module") | ||
excludePathStartWith("META-INF/versions") | ||
excludePathStartWith("META-INF/proguard") | ||
excludePathStartWith("META-INF/maven") | ||
excludePathStartWith("org/slf4j") | ||
excludePathStartWith("kotlinx/coroutines/flow") | ||
listOf("asn1", "jcajce", "jce", "pqc", "x509", "math", "i18n", "iana", "internal").forEach { | ||
excludePathStartWith("org/bouncycastle/$it") | ||
} | ||
val task = tasks.remapJar.get() | ||
task.dependsOn("pkg") | ||
shadowJar { | ||
task.inputFile.set(this.archiveFile) | ||
} | ||
relocateKotlinStdlib() | ||
relocateKotlinxLib() | ||
kotlinRelocate("org.yaml.snakeyaml", "$group.relocate.org.yaml.snakeyaml") | ||
} | ||
|
||
loom { | ||
silentMojangMappingsLicense() | ||
} | ||
|
||
dependencies { | ||
val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom") | ||
minecraft("com.mojang:minecraft:1.18.2") | ||
mappings(loom.officialMojangMappings()) | ||
|
||
forge("net.minecraftforge:forge:1.18.2-40.0.12") | ||
compileOnly("org.jetbrains.kotlin:kotlin-stdlib") | ||
|
||
pkgIn(project(":common")) | ||
pkgIn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") | ||
pkgIn("io.nats:jnats:2.15.3") | ||
pkgIn("org.mesagisto:mesagisto-client:1.5.2") | ||
} | ||
|
||
java { | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
tasks { | ||
compileKotlin { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
freeCompilerArgs = listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn") | ||
} | ||
sourceCompatibility = "1.8" | ||
} | ||
processResources { | ||
inputs.property("version", project.version) | ||
filesMatching("META-INF/mods.toml") { | ||
expand("version" to project.version) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
loom.platform=forge |
34 changes: 34 additions & 0 deletions
34
forge-1_12/src/main/java/org/meowcat/mesagisto/forge/ModAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.meowcat.mesagisto.forge | ||
|
||
import net.minecraft.server.MinecraftServer | ||
import net.minecraftforge.common.MinecraftForge | ||
import net.minecraftforge.event.server.ServerStartingEvent | ||
import net.minecraftforge.event.server.ServerStoppingEvent | ||
import org.apache.logging.log4j.LogManager | ||
import org.apache.logging.log4j.Logger | ||
import org.meowcat.mesagisto.forge.impl.ChatImpl | ||
import org.mesagisto.mcmod.ModEntry | ||
|
||
val logger: Logger = LogManager.getLogger("mesagisto") | ||
|
||
@net.minecraftforge.fml.common.Mod("mesagisto") | ||
class ModAdapter { | ||
private lateinit var server: MinecraftServer | ||
init { | ||
MinecraftForge.EVENT_BUS.addListener(ChatImpl::deliverChatEvent) | ||
MinecraftForge.EVENT_BUS.addListener(this::onServerStart) | ||
MinecraftForge.EVENT_BUS.addListener(this::onServerStop) | ||
} | ||
private fun onServerStart( | ||
event: ServerStartingEvent | ||
) { | ||
server = event.server | ||
ChatImpl.server = event.server | ||
ModEntry.onEnable() | ||
} | ||
private fun onServerStop( | ||
event: ServerStoppingEvent | ||
) { | ||
ModEntry.onDisable() | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
forge-1_12/src/main/java/org/meowcat/mesagisto/forge/impl/ChatImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.meowcat.mesagisto.forge.impl | ||
|
||
import net.minecraft.network.chat.ChatType | ||
import net.minecraft.network.chat.TextComponent | ||
import net.minecraft.server.MinecraftServer | ||
import net.minecraftforge.event.ServerChatEvent | ||
import org.mesagisto.mcmod.api.ChatHandler | ||
import org.mesagisto.mcmod.api.IChat | ||
import java.util.* | ||
|
||
class IChatImpl : IChat by ChatImpl | ||
|
||
object ChatImpl : IChat { | ||
lateinit var server: MinecraftServer | ||
private val handlers: MutableList<ChatHandler> = arrayListOf() | ||
|
||
fun deliverChatEvent(event: ServerChatEvent) { | ||
handlers.forEach { | ||
it.hande(event.player.name.string, event.message) | ||
} | ||
} | ||
override fun broadcastMessage(message: String) { | ||
server.playerList.broadcastMessage(TextComponent(message), ChatType.SYSTEM, UUID.randomUUID()) | ||
} | ||
override fun registerChatHandler(callback: ChatHandler) { | ||
handlers.add(callback) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
forge-1_12/src/main/java/org/meowcat/mesagisto/forge/impl/CompatImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.meowcat.mesagisto.forge.impl | ||
|
||
import org.meowcat.mesagisto.forge.logger | ||
import org.mesagisto.mcmod.api.ICompat | ||
import org.mesagisto.mcmod.api.Log4jLogger | ||
|
||
class ICompatImpl : ICompat by CompatImpl | ||
|
||
object CompatImpl : ICompat { | ||
override fun getLogger(): Log4jLogger = logger | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
modLoader="javafml" | ||
loaderVersion="[40,)" | ||
license='LGPLv3' | ||
|
||
[[mods]] | ||
modId="mesagisto" | ||
version="$version" | ||
displayName="MesagistoMod" | ||
authors="Itsusinn" | ||
description=''' | ||
Mesagisto: A message forwarding program connecting different instant-message platforms. 信使: 一款连接不同即时通讯平台的消息转发程序. | ||
''' |
1 change: 1 addition & 0 deletions
1
forge-1_12/src/main/resources/META-INF/services/org.mesagisto.mcmod.api.IChat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.meowcat.mesagisto.forge.impl.IChatImpl |
1 change: 1 addition & 0 deletions
1
forge-1_12/src/main/resources/META-INF/services/org.mesagisto.mcmod.api.ICompat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.meowcat.mesagisto.forge.impl.ICompatImpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pack": { | ||
"description": "Empty resources by Mesagisto", | ||
"pack_format": 4 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import io.itsusinn.pkg.pkgIn | ||
import net.fabricmc.loom.api.LoomGradleExtensionAPI | ||
|
||
plugins { | ||
java | ||
kotlin("jvm") | ||
id("architectury-plugin") | ||
id("dev.architectury.loom") | ||
id("com.github.johnrengelman.shadow") | ||
id("io.itsusinn.pkg") | ||
} | ||
architectury { | ||
minecraft = "1.18.2" | ||
platformSetupLoomIde() | ||
forge() | ||
} | ||
repositories { | ||
maven("https://files.minecraftforge.net/maven") | ||
maven("https://maven.minecraftforge.net") | ||
maven("https://maven.parchmentmc.org") | ||
mavenCentral() | ||
} | ||
pkg { | ||
excludePath("META-INF/*.kotlin_module") | ||
excludePathStartWith("META-INF/versions") | ||
excludePathStartWith("META-INF/proguard") | ||
excludePathStartWith("META-INF/maven") | ||
excludePathStartWith("org/slf4j") | ||
excludePathStartWith("kotlinx/coroutines/flow") | ||
listOf("asn1", "jcajce", "jce", "pqc", "x509", "math", "i18n", "iana", "internal").forEach { | ||
excludePathStartWith("org/bouncycastle/$it") | ||
} | ||
val task = tasks.remapJar.get() | ||
task.dependsOn("pkg") | ||
shadowJar { | ||
task.inputFile.set(this.archiveFile) | ||
} | ||
relocateKotlinStdlib() | ||
relocateKotlinxLib() | ||
kotlinRelocate("org.yaml.snakeyaml", "$group.relocate.org.yaml.snakeyaml") | ||
} | ||
|
||
loom { | ||
silentMojangMappingsLicense() | ||
} | ||
|
||
dependencies { | ||
val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom") | ||
minecraft("com.mojang:minecraft:1.18.2") | ||
mappings(loom.officialMojangMappings()) | ||
|
||
forge("net.minecraftforge:forge:1.18.2-40.0.12") | ||
compileOnly("org.jetbrains.kotlin:kotlin-stdlib") | ||
|
||
pkgIn(project(":common")) | ||
pkgIn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") | ||
pkgIn("io.nats:jnats:2.15.3") | ||
pkgIn("org.mesagisto:mesagisto-client:1.5.2") | ||
} | ||
|
||
java { | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
tasks { | ||
compileKotlin { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
freeCompilerArgs = listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn") | ||
} | ||
sourceCompatibility = "1.8" | ||
} | ||
processResources { | ||
inputs.property("version", project.version) | ||
filesMatching("META-INF/mods.toml") { | ||
expand("version" to project.version) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
loom.platform=forge |
34 changes: 34 additions & 0 deletions
34
forge-1_16/src/main/java/org/meowcat/mesagisto/forge/ModAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.meowcat.mesagisto.forge | ||
|
||
import net.minecraft.server.MinecraftServer | ||
import net.minecraftforge.common.MinecraftForge | ||
import net.minecraftforge.event.server.ServerStartingEvent | ||
import net.minecraftforge.event.server.ServerStoppingEvent | ||
import org.apache.logging.log4j.LogManager | ||
import org.apache.logging.log4j.Logger | ||
import org.meowcat.mesagisto.forge.impl.ChatImpl | ||
import org.mesagisto.mcmod.ModEntry | ||
|
||
val logger: Logger = LogManager.getLogger("mesagisto") | ||
|
||
@net.minecraftforge.fml.common.Mod("mesagisto") | ||
class ModAdapter { | ||
private lateinit var server: MinecraftServer | ||
init { | ||
MinecraftForge.EVENT_BUS.addListener(ChatImpl::deliverChatEvent) | ||
MinecraftForge.EVENT_BUS.addListener(this::onServerStart) | ||
MinecraftForge.EVENT_BUS.addListener(this::onServerStop) | ||
} | ||
private fun onServerStart( | ||
event: ServerStartingEvent | ||
) { | ||
server = event.server | ||
ChatImpl.server = event.server | ||
ModEntry.onEnable() | ||
} | ||
private fun onServerStop( | ||
event: ServerStoppingEvent | ||
) { | ||
ModEntry.onDisable() | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
forge-1_16/src/main/java/org/meowcat/mesagisto/forge/impl/ChatImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.meowcat.mesagisto.forge.impl | ||
|
||
import net.minecraft.network.chat.ChatType | ||
import net.minecraft.network.chat.TextComponent | ||
import net.minecraft.server.MinecraftServer | ||
import net.minecraftforge.event.ServerChatEvent | ||
import org.mesagisto.mcmod.api.ChatHandler | ||
import org.mesagisto.mcmod.api.IChat | ||
import java.util.* | ||
|
||
class IChatImpl : IChat by ChatImpl | ||
|
||
object ChatImpl : IChat { | ||
lateinit var server: MinecraftServer | ||
private val handlers: MutableList<ChatHandler> = arrayListOf() | ||
|
||
fun deliverChatEvent(event: ServerChatEvent) { | ||
handlers.forEach { | ||
it.hande(event.player.name.string, event.message) | ||
} | ||
} | ||
override fun broadcastMessage(message: String) { | ||
server.playerList.broadcastMessage(TextComponent(message), ChatType.SYSTEM, UUID.randomUUID()) | ||
} | ||
override fun registerChatHandler(callback: ChatHandler) { | ||
handlers.add(callback) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
forge-1_16/src/main/java/org/meowcat/mesagisto/forge/impl/CompatImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.meowcat.mesagisto.forge.impl | ||
|
||
import org.meowcat.mesagisto.forge.logger | ||
import org.mesagisto.mcmod.api.ICompat | ||
import org.mesagisto.mcmod.api.Log4jLogger | ||
|
||
class ICompatImpl : ICompat by CompatImpl | ||
|
||
object CompatImpl : ICompat { | ||
override fun getLogger(): Log4jLogger = logger | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
modLoader="javafml" | ||
loaderVersion="[40,)" | ||
license='LGPLv3' | ||
|
||
[[mods]] | ||
modId="mesagisto" | ||
version="$version" | ||
displayName="MesagistoMod" | ||
authors="Itsusinn" | ||
description=''' | ||
Mesagisto: A message forwarding program connecting different instant-message platforms. 信使: 一款连接不同即时通讯平台的消息转发程序. | ||
''' |
1 change: 1 addition & 0 deletions
1
forge-1_16/src/main/resources/META-INF/services/org.mesagisto.mcmod.api.IChat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.meowcat.mesagisto.forge.impl.IChatImpl |
1 change: 1 addition & 0 deletions
1
forge-1_16/src/main/resources/META-INF/services/org.mesagisto.mcmod.api.ICompat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.meowcat.mesagisto.forge.impl.ICompatImpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pack": { | ||
"description": "Empty resources by Mesagisto", | ||
"pack_format": 4 | ||
} | ||
} |
Oops, something went wrong.