-
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
iHsin
committed
Jan 12, 2024
1 parent
ed72a77
commit 7870208
Showing
13 changed files
with
185 additions
and
12 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
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,69 @@ | ||
import io.itsusinn.pkg.pkgIn | ||
import net.fabricmc.loom.api.LoomGradleExtensionAPI | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
maven("https://maven.fabricmc.net/") | ||
} | ||
|
||
plugins { | ||
java | ||
id("dev.architectury.loom") | ||
id("architectury-plugin") | ||
|
||
id("org.jetbrains.kotlin.jvm") | ||
id("com.github.johnrengelman.shadow") | ||
id("io.itsusinn.pkg") | ||
} | ||
architectury { | ||
minecraft = "1.20.4" | ||
platformSetupLoomIde() | ||
fabric() | ||
} | ||
loom { | ||
fabricApi { } | ||
} | ||
pkg { | ||
excludePath("mappings/*") | ||
excludePath("META-INF/*.kotlin_module") | ||
excludePath("META-INF/versions/*") | ||
excludePath("META-INF/proguard/*") | ||
excludePath("META-INF/maven/*") | ||
excludePath("META-INF/com.android.tools/*") | ||
excludePath("META-INF/services/kotlin.reflect*") | ||
excludePath("org/slf4j/*") | ||
excludePath("org/jetbrains/annotations/*") | ||
excludePath("org/intellij/lang/annotations/*") | ||
excludePath("kotlin/*") | ||
excludePath("kotlinx/*") | ||
listOf("asn1", "jcajce", "jce", "pqc", "x509", "math", "i18n", "iana", "internal").forEach { | ||
excludePath("org/bouncycastle/$it/*") | ||
} | ||
|
||
val task = tasks.remapJar.get() | ||
task.dependsOn("pkg") | ||
shadowJar { | ||
task.inputFile.set(this.archiveFile) | ||
} | ||
} | ||
|
||
tasks { | ||
processResources { | ||
inputs.property("version", project.version) | ||
filesMatching("fabric.mod.json") { | ||
expand(mutableMapOf("version" to project.version)) | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
modImplementation("net.fabricmc:fabric-loader:0.15.3") | ||
modImplementation("net.fabricmc.fabric-api:fabric-api:0.93.1+1.20.4") | ||
|
||
minecraft("com.mojang:minecraft:1.20.4") | ||
mappings("net.fabricmc:yarn:1.20.4+build.3:v2") | ||
|
||
pkgIn(project(":common")) | ||
pkgIn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.2") | ||
} |
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=fabric |
36 changes: 36 additions & 0 deletions
36
fabric-1_20/src/main/java/org/mesagisto/fabric/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,36 @@ | ||
package org.mesagisto.fabric | ||
|
||
import net.fabricmc.api.ModInitializer | ||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents | ||
import net.fabricmc.fabric.api.message.v1.ServerMessageDecoratorEvent | ||
import net.minecraft.server.MinecraftServer | ||
import net.minecraft.server.network.ServerPlayerEntity | ||
import net.minecraft.text.Text | ||
import org.apache.logging.log4j.LogManager | ||
import org.apache.logging.log4j.Logger | ||
import org.mesagisto.fabric.impl.ChatImpl | ||
import org.mesagisto.mcmod.ModEntry | ||
import java.util.concurrent.CompletableFuture | ||
|
||
val logger: Logger = LogManager.getLogger("mesagisto") | ||
|
||
class ModAdapter : ModInitializer { | ||
private lateinit var server: MinecraftServer | ||
override fun onInitialize() { | ||
ServerLifecycleEvents.SERVER_STARTED.register { | ||
server = it | ||
ChatImpl.server = it | ||
ModEntry.onEnable() | ||
} | ||
ServerMessageDecoratorEvent.EVENT.register( | ||
ServerMessageDecoratorEvent.CONTENT_PHASE | ||
) { player: ServerPlayerEntity?, component: Text -> | ||
if (player == null) return@register component | ||
ChatImpl.deliverChatEvent(player, component) | ||
component | ||
} | ||
ServerLifecycleEvents.SERVER_STOPPING.register { | ||
ModEntry.onDisable() | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
fabric-1_20/src/main/java/org/mesagisto/fabric/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,26 @@ | ||
package org.mesagisto.fabric.impl | ||
|
||
import net.minecraft.server.MinecraftServer | ||
import net.minecraft.server.network.ServerPlayerEntity | ||
import net.minecraft.text.Text | ||
import org.mesagisto.mcmod.api.ChatHandler | ||
import org.mesagisto.mcmod.api.IChat | ||
|
||
class IChatImpl : IChat by ChatImpl | ||
|
||
object ChatImpl : IChat { | ||
lateinit var server: MinecraftServer | ||
private val handlers: MutableList<ChatHandler> = arrayListOf() | ||
|
||
fun deliverChatEvent(player: ServerPlayerEntity, content: Text) { | ||
handlers.forEach { | ||
it.handle(player.name.string, content.string) | ||
} | ||
} | ||
override fun broadcastMessage(message: String) { | ||
server.playerManager.broadcast(Text.literal(message), false) | ||
} | ||
override fun registerChatHandler(callback: ChatHandler) { | ||
handlers.add(callback) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
fabric-1_20/src/main/java/org/mesagisto/fabric/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.mesagisto.fabric.impl | ||
|
||
import org.mesagisto.fabric.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 | ||
} |
1 change: 1 addition & 0 deletions
1
fabric-1_20/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.mesagisto.fabric.impl.IChatImpl |
1 change: 1 addition & 0 deletions
1
fabric-1_20/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.mesagisto.fabric.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,27 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "mesagisto", | ||
"version": "${version}", | ||
|
||
"name": "Mesagisto Mod", | ||
"description": "Mesagisto: A message forwarding program connecting different instant-message platforms. 信使: 一款连接不同即时通讯平台的消息转发程序.", | ||
"authors": [ | ||
"Itsusinn" | ||
], | ||
"contact": { | ||
"homepage": "https://github.com/MeowCat-Studio/mesagisto", | ||
"sources": "https://github.com/MeowCat-Studio/fabric-message-source" | ||
}, | ||
"environment": "*", | ||
"license": "LGPLv3", | ||
"entrypoints": { | ||
"main": [ | ||
"org.mesagisto.fabric.ModAdapter" | ||
] | ||
}, | ||
"depends": { | ||
"fabricloader": ">=0.12.2", | ||
"fabric": "*", | ||
"minecraft": "1.20.*" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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