Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.minecraft.network.chat.MessageSignature;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.util.profiling.ProfilerFiller;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -36,6 +38,10 @@ public class MixinChatComponent {
@Shadow
Minecraft minecraft;

@Shadow
@Final
private static Logger LOGGER;

@Inject(method = "render(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/gui/Font;IIIZZ)V", at = @At("HEAD"), cancellable = true)
public void render(GuiGraphics guiGraphics, Font font, int i, int j, int k, boolean bl, boolean bl2, CallbackInfo ci) {
if (!ChatPlus.INSTANCE.isEnabled() || (Config.INSTANCE.getValues().getShowVanillaWhenUnfocused() && !ChatManager.INSTANCE.isChatFocused())) {
Expand Down Expand Up @@ -110,5 +116,14 @@ public void addMessage(
EventBus.INSTANCE.post(SkipNewMessageEvent.class, messageEvent);
}
}
@Inject(method = "deleteMessage(Lnet/minecraft/network/chat/MessageSignature;)V", at = @At("RETURN"))
public void deleteMessage(MessageSignature messageSignature, CallbackInfo ci) {
if (!ChatPlus.INSTANCE.isEnabled()) {
return;
}

for (ChatTab chatTab : ChatManager.INSTANCE.getGlobalSortedTabs()) {
chatTab.deleteMessage(messageSignature);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,28 @@ class ChatTab {
return added
}

fun deleteMessage(signature: MessageSignature) {
val messageIndex = messages.indexOfFirst { it.guiMessage.signature == signature }
if (messageIndex == -1) return

val message = messages.removeAt(messageIndex)
EventBus.post(ChatTabRemoveMessageEvent(chatWindow, this, message))

displayedMessages.removeIf {
val match = it.linkedMessage === message
if (match) {
EventBus.post(ChatTabRemoveDisplayMessageEvent(chatWindow, this, it))
}
match
}

unfilteredDisplayedMessages.removeIf {
it.linkedMessage === message
}

refreshDisplayMessages()
}

fun clear() {
messages = ArrayList()
displayedMessages = ArrayList()
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ supported_minecraft_version=1.21.11
enabled_platforms=fabric,neoforge
archives_base_name=chatplus
mod_id=chatplus
mod_version=2.7.1
mod_version=2.7.2
mod_name=ChatPlus
mod_description=Minecraft chat improved.
mod_authors=ebicep
Expand Down