-
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
8 changed files
with
254 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import io.itsusinn.pkg.pkgIn | ||
|
||
plugins { | ||
java | ||
id("fabric-loom") | ||
id("org.jetbrains.kotlin.jvm") | ||
id("org.jetbrains.kotlin.plugin.serialization") | ||
id("com.github.johnrengelman.shadow") | ||
id("io.itsusinn.pkg") | ||
} | ||
pkg { | ||
excludePath("mappings/*") | ||
excludePath("META-INF/*.kotlin_module") | ||
excludePath("*.md") | ||
excludePath("DebugProbesKt.bin") | ||
shadowJar { | ||
tasks.remapJar { | ||
val task = this@shadowJar | ||
dependsOn(task) | ||
mustRunAfter(task) | ||
|
||
// this.inputFile.set(task.outputs.files.singleFile) | ||
this.input.set(task.outputs.files.singleFile) | ||
// 这里需要借助fabric-loom进行remap | ||
} | ||
minimize() | ||
} | ||
relocateKotlinxLib() | ||
relocateKotlinStdlib() | ||
} | ||
tasks { | ||
processResources { | ||
inputs.property("version", project.version) | ||
filesMatching("fabric.mod.json") { | ||
expand(mutableMapOf("version" to project.version)) | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
modImplementation("net.fabricmc:fabric-loader:0.12.2") | ||
modImplementation("net.fabricmc.fabric-api:fabric-api:0.29.3+1.16") | ||
|
||
minecraft("com.mojang:minecraft:1.18.2") | ||
mappings("net.fabricmc:yarn:1.18.2+build.1:v2") | ||
|
||
pkgIn(project(":common")) | ||
pkgIn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") | ||
pkgIn("io.nats:jnats:2.14.0") | ||
pkgIn("org.meowcat:mesagisto-client-jvm:1.3.0") | ||
pkgIn("com.charleskorn.kaml:kaml:0.43.0") | ||
} |
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,91 @@ | ||
compile(){ | ||
rm -rf packages | ||
mkdir -p packages | ||
rm build/libs/*-dev.jar | ||
mv build/libs/*.jar packages/ | ||
mv packages/*.jar packages/all.jar | ||
} | ||
extract(){ | ||
rm -rf extract | ||
mkdir -p extract | ||
unzip packages/all.jar -d extract/ > /dev/null | ||
} | ||
linux-x86_64(){ | ||
target=target/linux-x86_64 | ||
name=linux-x86_64.jar | ||
|
||
mkdir -p $target/extract $target/tmp | ||
cp -r extract $target | ||
# rocksdb | ||
mv $target/extract/librocksdbjni-linux64.so $target/tmp | ||
rm $target/extract/librocksdbjni* | ||
mv $target/tmp/librocksdbjni-linux64.so $target/extract | ||
# package | ||
jar -c -f packages/$name -C $target/extract/ . | ||
rm -rf $target | ||
} | ||
linux-x86(){ | ||
target=target/linux-x86 | ||
name=linux-x86.jar | ||
|
||
mkdir -p $target/extract $target/tmp | ||
cp -r extract $target | ||
# rocksdb | ||
mv $target/extract/librocksdbjni-linux32.so $target/tmp | ||
rm $target/extract/librocksdbjni* | ||
mv $target/tmp/librocksdbjni-linux32*.so $target/extract | ||
# package | ||
jar -c -f packages/$name -C $target/extract/ . | ||
rm -rf $target | ||
} | ||
windows-x86_64(){ | ||
target=target/windows-x86_64 | ||
name=windows-x86_64.jar | ||
|
||
mkdir -p $target/extract $target/tmp | ||
cp -r extract $target | ||
# rocksdb | ||
mv $target/extract/librocksdbjni-win64.dll $target/tmp | ||
rm $target/extract/librocksdbjni* | ||
mv $target/tmp/librocksdbjni-win64.dll $target/extract | ||
# package | ||
jar -c -f packages/$name -C $target/extract/ . | ||
rm -rf $target | ||
} | ||
mac-x86_64(){ | ||
target=target/mac-x86_64 | ||
name=mac-x86_64.jar | ||
|
||
mkdir -p $target/extract $target/tmp | ||
cp -r extract $target | ||
# rocksdb | ||
mv $target/extract/librocksdbjni-osx-x86_64.jnilib $target/tmp | ||
rm $target/extract/librocksdbjni* | ||
mv $target/tmp/librocksdbjni-osx-x86_64.jnilib $target/extract | ||
# package | ||
jar -c -f packages/$name -C $target/extract/ . | ||
rm -rf $target | ||
} | ||
all_target(){ | ||
linux-x86_64 | ||
linux-x86 | ||
windows-x86_64 | ||
mac-x86_64 | ||
cd packages | ||
prefix=fabric-1.18- | ||
for files in $(ls *.jar) | ||
do mv $files $prefix$files | ||
done | ||
cd .. | ||
} | ||
clean(){ | ||
rm -rf extract target | ||
} | ||
build(){ | ||
compile | ||
extract | ||
all_target | ||
clean | ||
} | ||
build | ||
|
18 changes: 18 additions & 0 deletions
18
1_18/src/main/java/org/meowcat/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,18 @@ | ||
package org.meowcat.mesagisto.fabric.impl | ||
|
||
import net.minecraft.network.MessageType | ||
import net.minecraft.server.MinecraftServer | ||
import net.minecraft.text.Text | ||
import org.meowcat.mesagisto.fabric.api.IChat | ||
import java.util.* // ktlint-disable no-wildcard-imports | ||
|
||
class ChatImpl : IChat { | ||
private lateinit var server: MinecraftServer | ||
override fun setServer(server: MinecraftServer) { | ||
this.server = server | ||
} | ||
|
||
override fun broadcastMessage(message: Text, type: MessageType, senderUuid: UUID) { | ||
server.playerManager.broadcast(message, type, senderUuid) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
1_18/src/main/java/org/meowcat/mesagisto/fabric/mixin/ServerChatMixin.java
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,31 @@ | ||
package org.meowcat.mesagisto.fabric.mixin; | ||
|
||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.server.filter.TextStream.Message; | ||
import org.meowcat.mesagisto.fabric.Mod; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(ServerPlayNetworkHandler.class) | ||
public abstract class ServerChatMixin { | ||
@Shadow | ||
public ServerPlayerEntity player; | ||
|
||
@Inject( | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Ljava/util/function/Function;Lnet/minecraft/network/MessageType;Ljava/util/UUID;)V" | ||
), | ||
method = "handleMessage", | ||
cancellable = true | ||
) | ||
private void handleMessage(Message message, CallbackInfo ci) { | ||
ServerPlayerEntity player = this.player; | ||
String content = message.getRaw(); | ||
Mod.INSTANCE.onServerChat(player, content); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
1_18/src/main/resources/META-INF/services/org.meowcat.mesagisto.fabric.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.fabric.impl.ChatImpl |
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 @@ | ||
{ | ||
"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" | ||
}, | ||
"mixins": [ | ||
"mesagisto.mixins.json" | ||
], | ||
"environment": "*", | ||
"license": "LGPLv2", | ||
"entrypoints": { | ||
"main": ["org.meowcat.mesagisto.fabric.ModAdapter"] | ||
}, | ||
"depends": { | ||
"fabricloader": ">=0.12.2", | ||
"fabric": "*", | ||
"minecraft": "1.18.*" | ||
} | ||
} |
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 @@ | ||
{ | ||
"required": true, | ||
"package": "org.meowcat.mesagisto.fabric.mixin", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": [ | ||
"ServerChatMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
}, | ||
"refmap": "1_18-refmap.json" | ||
} |
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,11 +1,28 @@ | ||
build-1_16_5(){ | ||
cd 1_16_5 | ||
build-1_16(){ | ||
cd 1_16 | ||
bash build.sh | ||
cd .. | ||
mv 1_16_5/packages/* packages/ | ||
mv 1_16/packages/* packages/ | ||
} | ||
build-1_17(){ | ||
cd 1_17 | ||
bash build.sh | ||
cd .. | ||
mv 1_17/packages/* packages/ | ||
} | ||
build-1_18(){ | ||
cd 1_18 | ||
bash build.sh | ||
cd .. | ||
mv 1_18/packages/* packages/ | ||
} | ||
build(){ | ||
mkdir packages | ||
build-1_16_5 | ||
./gradlew clean :1_16:remapJar | ||
build-1_16 | ||
./gradlew clean :1_17:remapJar | ||
build-1_17 | ||
./gradlew clean :1_18:remapJar | ||
build-1_18 | ||
} | ||
build |