Jump to content

[1.12.2] merge same chat message


superhize

Recommended Posts

[Reposted cause 1.8.9 is not supported here]

 

Hello, i would like to make a mod that merge same message in chat.

 

Instead of this

KIGSnFI.png

 

i want this

 

q2fv2i7.png

 

As i sent the same message, first message got edited and number increment.

 

I think i need to use the ClientChatReceivedEvent but i'm not sure.

 

I do not know how to explain this clearly, so i hope y'all understand.

 

(if a similar mod already exist, please link it to me)

Link to comment
Share on other sites

Make a static field that stores the last chat message received.

Subscribe to ClientChatReceivedEvent and compare the received message to the last message variable. Cancel the event if they have the same content, else set the last message variable to the received message.

I might have misunderstood the question.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

20 hours ago, superhize said:

[Reposted cause 1.8.9 is not supported here]

 

Hello, i would like to make a mod that merge same message in chat.

 

Instead of this

KIGSnFI.png

 

i want this

 

q2fv2i7.png

 

As i sent the same message, first message got edited and number increment.

 

I think i need to use the ClientChatReceivedEvent but i'm not sure.

 

I do not know how to explain this clearly, so i hope y'all understand.

 

(if a similar mod already exist, please link it to me)

 

I don’t think it’s possible, because you have to delete old user messages and combine them into one, merging messages is easy. But I think it is impossible to delete messages from just one user.

Can I edit posts? If yes, then you are lucky, if not, then you will need to somehow delete the old messages of this particular user and send an already merged message.

Link to comment
Share on other sites

10 hours ago, MairwunNx said:

 

I don’t think it’s possible, because you have to delete old user messages and combine them into one, merging messages is easy. But I think it is impossible to delete messages from just one user.

Can I edit posts? If yes, then you are lucky, if not, then you will need to somehow delete the old messages of this particular user and send an already merged message.

Ok, so far i got that:

 

idea64_2019-10-20_21-56-32

 

But i do not know how to get the chatId...

Link to comment
Share on other sites

On 10/19/2019 at 9:12 AM, superhize said:

[Reposted cause 1.8.9 is not supported here]

 

Hello, i would like to make a mod that merge same message in chat.

 

Instead of this

KIGSnFI.png

 

i want this

 

q2fv2i7.png

 

As i sent the same message, first message got edited and number increment.

 

I think i need to use the ClientChatReceivedEvent but i'm not sure.

 

I do not know how to explain this clearly, so i hope y'all understand.

 

(if a similar mod already exist, please link it to me)

There's no real way to actually delete one chat message or modify it after it had been sent. The is a way to delete every chat message, but that won't solve your problem.

Link to comment
Share on other sites

  • 5 months later...

Hey, i found what i want, here the code if someone want.

 

    public static String lastMessage = "";

    public static int line;

    public static int amount;

    @SubscribeEvent
    public static void chat(ClientChatReceivedEvent event) {
            NewChatGui guiNewChat = (Minecraft.getInstance()).ingameGUI.getChatGUI();
            if (lastMessage.equals(event.getMessage().getFormattedText())) {
                guiNewChat.deleteChatLine(line);
                amount++;
                lastMessage = event.getMessage().getFormattedText();
                event.getMessage().appendText(TextFormatting.GRAY + " (" +TextFormatting.GOLD+"x"+ amount +TextFormatting.GRAY+ ")");
            } else {
                amount = 1;
                lastMessage = event.getMessage().getFormattedText();
            }
            line++;
            if (!event.isCanceled())
                guiNewChat.printChatMessageWithOptionalDeletion(event.getMessage(), line);
            if (line > 256)
                line = 0;
            event.setCanceled(true);
    }

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.