From a31aefe855dcf9ab4ed55fbacb8d3a52a9b8ab10 Mon Sep 17 00:00:00 2001
From: ChomeNS <95471003+ChomeNS@users.noreply.github.com>
Date: Sat, 22 Apr 2023 09:22:33 +0700
Subject: [PATCH] fard
---
.idea/workspace.xml | 23 +++++-----
.../chomens_bot/plugins/ChatPlugin.java | 42 ++++++++++---------
2 files changed, 34 insertions(+), 31 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c055a69c..66b934e5 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,8 @@
-
+
-
@@ -95,13 +94,6 @@
1680245437032
-
- 1681115395510
-
-
-
- 1681115395510
-
1681194542547
@@ -438,7 +430,14 @@
1682120738153
-
+
+ 1682122055989
+
+
+
+ 1682122055990
+
+
@@ -453,7 +452,6 @@
-
@@ -478,7 +476,8 @@
-
+
+
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java
index 96523c19..7c60bd92 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java
@@ -137,27 +137,28 @@ public class ChatPlugin extends SessionAdapter {
}
private void sendChatTick () {
- if (queue.size() == 0) return;
+ try {
+ if (queue.size() == 0) return;
- final String message = queue.get(0);
+ final String message = queue.get(0);
- final String[] splitted = message.split("(?<=\\G.{255})|\\n");
+ final String[] splitted = message.split("(?<=\\G.{255})|\\n");
- for (String splitMessage : splitted) {
- if (splitMessage.trim().equals("")) continue;
+ for (String splitMessage : splitted) {
+ if (splitMessage.trim().equals("")) continue;
- if (splitMessage.startsWith("/")) {
- bot.session().send(new ServerboundChatCommandPacket(
- splitMessage.substring(1),
- Instant.now().toEpochMilli(),
- 0L,
- Collections.emptyList(),
- 0,
- new BitSet()
- ));
- } else {
- // Temporary fix for the bot getting kicked instead of chatting
- bot.core().run("essentials:sudo " + bot.players().getBotEntry().profile().getIdAsString() + " c:" + splitMessage);
+ if (splitMessage.startsWith("/")) {
+ bot.session().send(new ServerboundChatCommandPacket(
+ splitMessage.substring(1),
+ Instant.now().toEpochMilli(),
+ 0L,
+ Collections.emptyList(),
+ 0,
+ new BitSet()
+ ));
+ } else {
+ // Temporary fix for the bot getting kicked instead of chatting
+ bot.core().run("essentials:sudo " + bot.players().getBotEntry().profile().getIdAsString() + " c:" + splitMessage);
// bot.session().send(new ServerboundChatPacket(
// splitMessage,
// Instant.now().toEpochMilli(),
@@ -166,10 +167,13 @@ public class ChatPlugin extends SessionAdapter {
// 0,
// new BitSet()
// ));
+ }
}
- }
- queue.remove(0);
+ queue.remove(0);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
public void send (String message) {