mirror of
https://github.com/System-End/Discord-MC-Chat.git
synced 2026-04-19 22:05:11 +00:00
重写完成至玩家加入离开服务器
This commit is contained in:
parent
d2858dd14b
commit
7337d13cd0
5 changed files with 36 additions and 26 deletions
|
|
@ -76,7 +76,5 @@ public class Main implements DedicatedServerModInitializer {
|
|||
|
||||
JDA.shutdown();
|
||||
});
|
||||
|
||||
//MinecraftEventListener.init();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
package top.xujiayao.mcdiscordchat.minecraft.mixins;
|
||||
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static top.xujiayao.mcdiscordchat.Main.LOGGER;
|
||||
|
||||
/**
|
||||
* @author Xujiayao
|
||||
*/
|
||||
@Mixin({TitleScreen.class})
|
||||
public class ExampleMixin {
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "init()V")
|
||||
private void init(CallbackInfo info) {
|
||||
LOGGER.info("This line is printed by an example mod mixin!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package top.xujiayao.mcdiscordchat.minecraft.mixins;
|
||||
|
||||
import net.dv8tion.jda.api.utils.MarkdownSanitizer;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.server.PlayerManager;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static top.xujiayao.mcdiscordchat.Main.CHANNEL;
|
||||
import static top.xujiayao.mcdiscordchat.Main.TEXTS;
|
||||
|
||||
/**
|
||||
* @author Xujiayao
|
||||
*/
|
||||
@Mixin(PlayerManager.class)
|
||||
public class MixinPlayerManager {
|
||||
|
||||
@Inject(method = "onPlayerConnect", at = @At("RETURN"))
|
||||
private void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
|
||||
CHANNEL.sendMessage(TEXTS.joinServer().replace("%playerName%", MarkdownSanitizer.escape(player.getEntityName()))).queue();
|
||||
}
|
||||
|
||||
@Inject(method = "remove", at = @At("RETURN"))
|
||||
private void remove(ServerPlayerEntity player, CallbackInfo ci) {
|
||||
CHANNEL.sendMessage(TEXTS.leftServer().replace("%playerName%", MarkdownSanitizer.escape(player.getEntityName()))).queue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,6 +20,9 @@
|
|||
"top.xujiayao.mcdiscordchat.Main"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"mcdiscordchat.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.13.3",
|
||||
"fabric": "*",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "top.xujiayao.mcdiscordchat.mixins",
|
||||
"package": "top.xujiayao.mcdiscordchat.minecraft.mixins",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ExampleMixin"
|
||||
"MixinPlayerManager"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue