fix chat (/say and /me) i guess
This commit is contained in:
parent
6e91fe82d4
commit
a49b078a6f
5 changed files with 71 additions and 46 deletions
|
@ -4,13 +4,12 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="actually revert greplog update because it breaks stuff">
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/data/FilteredPlayer.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java" afterDir="false" />
|
||||
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="fix chat (/say and /me) i guess">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/ConsoleCommandContext.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/ConsoleCommandContext.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/PlayerCommandContext.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/PlayerCommandContext.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -102,13 +101,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680245437032</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00060" summary="improve serverinfo">
|
||||
<created>1681536905476</created>
|
||||
<option name="number" value="00060" />
|
||||
<option name="presentableId" value="LOCAL-00060" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1681536905476</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00061" summary="make self care use core if it can">
|
||||
<created>1681547507213</created>
|
||||
<option name="number" value="00061" />
|
||||
|
@ -445,7 +437,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1682250189954</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="109" />
|
||||
<task id="LOCAL-00109" summary="add filter (ignore messy code plz)">
|
||||
<created>1682317167720</created>
|
||||
<option name="number" value="00109" />
|
||||
<option name="presentableId" value="LOCAL-00109" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1682317167721</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="110" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -460,8 +459,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="add a working (or not?) stereo to music" />
|
||||
<MESSAGE value="improve and fix cmd handler (first commit on arch) yup this is my first commit on arch linux,.,.,..,.,., yes i use arch btw :sunglasses:" />
|
||||
<MESSAGE value="1.19.4 + add stuff (kinda broken ..,,.)" />
|
||||
<MESSAGE value="add/improve/fix stuff ig mabe mabe mabe useCore!1!1!" />
|
||||
<MESSAGE value="ig fix music filename mabe mabe" />
|
||||
|
@ -485,7 +482,9 @@
|
|||
<MESSAGE value="put the setter back" />
|
||||
<MESSAGE value="use serverName instead of host:port for console i guess" />
|
||||
<MESSAGE value="actually revert greplog update because it breaks stuff" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="actually revert greplog update because it breaks stuff" />
|
||||
<MESSAGE value="add filter (ignore messy code plz)" />
|
||||
<MESSAGE value="fix chat (/say and /me) i guess" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="fix chat (/say and /me) i guess" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ public class PlayerCommandContext extends CommandContext {
|
|||
|
||||
@Override
|
||||
public Component displayName () {
|
||||
return Component.text(playerName);
|
||||
return sender().displayName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue