diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b42b018..bde6e60 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,13 +4,12 @@
-
-
-
-
+
-
-
+
+
+
+
@@ -102,13 +101,6 @@
1680245437032
-
- 1681536905476
-
-
-
- 1681536905476
-
1681547507213
@@ -445,7 +437,14 @@
1682250189954
-
+
+ 1682317167720
+
+
+
+ 1682317167721
+
+
@@ -460,8 +459,6 @@
-
-
@@ -485,7 +482,9 @@
-
+
+
+
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/ConsoleCommandContext.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/ConsoleCommandContext.java
index f695de9..249b778 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/ConsoleCommandContext.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/ConsoleCommandContext.java
@@ -9,7 +9,7 @@ public class ConsoleCommandContext extends CommandContext {
private final Bot bot;
public ConsoleCommandContext (Bot bot, String prefix) {
- super(bot, prefix, bot.players().getEntry(bot.username()) /* real */, null, null);
+ super(bot, prefix, bot.players().getBotEntry() /* real */, null, null);
this.bot = bot;
}
@@ -21,6 +21,6 @@ public class ConsoleCommandContext extends CommandContext {
@Override
public Component displayName () {
- return Component.text(bot.username()).color(NamedTextColor.YELLOW);
+ return sender().displayName().color(NamedTextColor.YELLOW);
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/PlayerCommandContext.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/PlayerCommandContext.java
index de98378..2a00bd7 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/PlayerCommandContext.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/PlayerCommandContext.java
@@ -26,6 +26,6 @@ public class PlayerCommandContext extends CommandContext {
@Override
public Component displayName () {
- return Component.text(playerName);
+ return sender().displayName();
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java
index 6e62471..e2cabab 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java
@@ -36,7 +36,7 @@ public class TestCommand implements Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Component component = Component.translatable(
"Hello, World! Username: %s, Sender UUID: %s, Prefix: %s, Args: %s",
- context.displayName(),
+ context.sender().profile().getName(),
Component.text(context.sender().profile().getIdAsString()),
Component.text(context.prefix()),
Component.text(String.join(", ", args))
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 62b1c6a..9172e70 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
@@ -96,43 +96,69 @@ public class ChatPlugin extends SessionAdapter {
if (entry == null) return;
- final PlayerMessage playerMessage = new PlayerMessage(entry, packet.getName(), Component.text(packet.getContent()));
+ final PlayerMessage playerMessage = new PlayerMessage(
+ entry,
+ packet.getName(),
+ Component.text(packet.getContent())
+ );
for (ChatListener listener : listeners) {
listener.playerMessageReceived(playerMessage);
- final Component component = Component.translatable(
- "chat.type.text",
- entry.displayName(),
- Component.text(packet.getContent())
- );
- listener.systemMessageReceived(
- ComponentUtilities.stringify(component),
- component
- );
+ if (packet.getChatType() == 4) { // type 4 is /say
+ final Component component = Component.translatable(
+ "chat.type.announcement",
+ playerMessage.displayName(),
+ playerMessage.contents()
+ );
+
+ listener.systemMessageReceived(
+ ComponentUtilities.stringify(component),
+ component
+ );
+ } else {
+ final Component unsignedContent = packet.getUnsignedContent();
+
+ if (unsignedContent == null) return;
+
+ listener.systemMessageReceived(
+ ComponentUtilities.stringify(unsignedContent),
+ unsignedContent
+ );
+ }
}
}
public void packetReceived (ClientboundDisguisedChatPacket packet) {
- // totallynotskidded™ from chipmunkbot
- PlayerMessage parsedFromMessage = null;
- final Component component = packet.getMessage();
+ // totallynotskidded™ from chipmunkbot and modified a bit i guess
+ // PlayerMessage parsedFromMessage = null;
- for (ChatParser parser : chatParsers) {
- parsedFromMessage = parser.parse(component);
- if (parsedFromMessage != null) break;
- }
+ // i think im missing other types
+ if (packet.getChatType() == 1) { // type 1 is /me
+ final Component name = packet.getName();
+ final Component content = packet.getMessage();
- if (parsedFromMessage == null) return;
+ for (ChatParser parser : chatParsers) {
+ final Component component = Component.translatable(
+ "chat.type.emote",
+ name,
+ content
+ );
- final PlayerMessage playerMessage = new PlayerMessage(parsedFromMessage.sender(), packet.getName(), parsedFromMessage.contents());
+ final PlayerMessage parsed = parser.parse(component);
- for (ChatListener listener : listeners) {
- listener.playerMessageReceived(playerMessage);
- listener.systemMessageReceived(
- ComponentUtilities.stringify(component),
- component
- );
+ if (parsed == null) continue;
+
+ final PlayerMessage playerMessage = new PlayerMessage(parsed.sender(), packet.getName(), parsed.contents());
+
+ for (ChatListener listener : listeners) {
+ listener.playerMessageReceived(playerMessage);
+ listener.systemMessageReceived(
+ ComponentUtilities.stringify(component),
+ component
+ );
+ }
+ }
}
}