Skip to content

Commit

Permalink
More update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Feb 4, 2025
1 parent ca79121 commit acdf4aa
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@
} else {
- this.f_8924_.m_6846_().m_240416_(component, false);
+ this.f_8924_.m_6846_().m_240416_(ichatbasecomponent, false);
+ KouKou.sendToGroup(ichatbasecomponent.getString());
+ KouKou.death(ichatbasecomponent.getString());
}
} else {
this.f_8906_.m_9829_(new ClientboundPlayerCombatKillPacket(this.m_19879_(), CommonComponents.f_237098_));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2,16 +_,27 @@
@@ -2,16 +_,28 @@

import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
+import com.mohistmc.ai.koukou.KouKou;
+import com.mohistmc.api.ServerAPI;
+import com.mohistmc.bukkit.LoginHandler;
+import com.mohistmc.bukkit.inventory.MohistModsInventory;
Expand Down Expand Up @@ -2006,7 +2007,7 @@
PacketUtils.m_131359_(p_253950_, this, this.f_9743_.m_284548_());
RemoteChatSession.Data remotechatsession$data = p_253950_.f_252446_();
ProfilePublicKey.Data profilepublickey$data = this.f_252494_ != null ? this.f_252494_.f_243855_().f_219781_() : null;
@@ -1719,4 +_,118 @@
@@ -1719,4 +_,119 @@
interface EntityInteraction {
InteractionResult m_143694_(ServerPlayer p_143695_, Entity p_143696_, InteractionHand p_143697_);
}
Expand Down Expand Up @@ -2055,6 +2056,7 @@
+ String originalFormat = event.getFormat(), originalMessage = event.getMessage();
+ Bukkit.getPluginManager().callEvent(event);
+
+ KouKou.chat(originalMessage);
+ if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) {
+ // Evil plugins still listening to deprecated event
+ final PlayerChatEvent queueEvent = new PlayerChatEvent(thisPlayer, event.getMessage(), event.getFormat(), event.getRecipients());
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/mohistmc/ai/koukou/AIConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public static void init() {
INSTANCE.yaml.addDefault("command.enable", false);
INSTANCE.yaml.addDefault("command.owners", List.of("123456789"));
INSTANCE.yaml.addDefault("command.name", "执行");
INSTANCE.yaml.addDefault("message.group_to_server.enable", false);
INSTANCE.yaml.addDefault("message.server_to_group.enable", false);
INSTANCE.yaml.addDefault("message.death.enable", false);
INSTANCE.save();
}

Expand Down Expand Up @@ -67,4 +70,16 @@ public String server_name() {
return yaml.getString("server_name", "群消息");
}

public boolean group_to_server() {
return yaml.getBoolean("message.group_to_server.enable");
}

public boolean server_to_group() {
return yaml.getBoolean("message.server_to_group.enable");
}

public boolean death() {
return yaml.getBoolean("message.death.enable");
}

}
17 changes: 15 additions & 2 deletions src/main/java/com/mohistmc/ai/koukou/KouKou.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,21 @@ public static void sendToGroup(String message) {
}

public static void sendToGroup(String groupId, String message) {
if (!AIConfig.INSTANCE.enable()) return;
send_group_msg(String.valueOf(groupId), message);
if (AIConfig.INSTANCE.enable()) {
send_group_msg(String.valueOf(groupId), message);
}
}

public static void chat(String message) {
if (AIConfig.INSTANCE.server_to_group()) {
sendToGroup(message);
}
}

public static void death(String message) {
if (AIConfig.INSTANCE.death()) {
sendToGroup(message);
}
}

@SneakyThrows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onEvent(HttpPostEvent event) {
String pattern = "\\[CQ:.*?]";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(msg);
if (!m.find()) {
if (!m.find() && AIConfig.INSTANCE.group_to_server()) {
Bukkit.broadcastMessage("[%s] <%s>: %s".formatted(AIConfig.INSTANCE.server_name(), sender_nickname, msg));
}

Expand Down

0 comments on commit acdf4aa

Please sign in to comment.