-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop "You can only sleep at night" message filling the chat #102
Conversation
why would you click the bed ten times tho |
if (event.message.equals(new ChatComponentTranslation("tile.bed.noSleep", new Object[0])) | ||
|| event.message.equals(new ChatComponentTranslation("tile.bed.notSafe", new Object[0])) | ||
|| event.message.equals(new ChatComponentTranslation("tile.bed.occupied", new Object[0]))) { | ||
this.gameController.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(event.message, 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo you shouldn't use the printChatMessageWithOptionalDeletion method since you don't know which other mod uses which message ids, and it might start deleting other chat messages that you don't expect.
If you want to delete chat messages you should make your own deleteChatLine method that iterates though private final List chatLines = new ArrayList(); private final List field_146253_i = new ArrayList();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can I just set the message id a very big number?
there are 2 billion channels so it should not cause conflicts if I set it like 251545647
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can I just set the message id a very big number? there are 2 billion channels so it should not cause conflicts if I set it like 251545647
Imperfect but sounds reasonable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just stumbed upon this https://github.com/GTNewHorizons/EnderCore/blob/68ba8bc29db0bd00a344cb59fb3c25242e24c480/src/main/java/com/enderio/core/common/util/ChatUtil.java#L61
I guess we are fine with this solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we have HUD overlay above hotbar (GTNewHorizons/GTNHLib#7), so we can use that I guess
FIY there is a addChatThrottled api in structurelib that you can just steal or promote to gtnhlib. |
to be honest, it would be better to implement a simplified version of compact chat (that just checks the last message) rather than coding this for a single specific message |
Compact chat may collapses important messages from other mods, especially debug messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine for now. Thanks.
before
after
Minecraft.1.7.10.2022-09-08.00-10-41.mp4
About printChatMessageWithOptionalDeletion second argument:
"0" will not delete any duplicated chat, "1" is occupied by vanilla, "2" is occupied by Forge, so I use 3