EssentialsX

EssentialsX

2M Downloads

ESSX Discord Console output doesnt filter colors. even breaks /spigot:tps

CatbotTsumi opened this issue ยท 1 comments

commented

Type of bug

Other unexpected behaviour

/ess dump all output

https://essentialsx.net/dump.html?id=33ccd4b35e004bf69b7d013b15d4323b

Error log (if applicable)

No response

Bug description

Whenever there's a color code like &6 anywhere in console output, it will display strange characters in discord console channel instead of just removing them.

Example image showing the usage of /execute tps working well (top)
but the execution of tps from the console breaks.
Example image
In this example the [33m shouldn't be there. and the .0 .0 .0 is supposed to display 20.0 20.0 20.0

This issue is not exclusive to that command, it happens with all console output.
Example image featuring random chat
You can see that there's a lot of [ + number + m and foreign characters inserted

Steps to reproduce

Any colored text in the console will cause the issue.
See the relayed console in discord.

Expected behaviour

Expected behavior is to have the console in discord not show any cmd color codes or whatever they are.
Just no colors and no characters that shouldnt be there is what is expected.

Actual behaviour

Unexpected characters are thrown into the discord console relay wherever a minecraft color is used.

commented

The issue seems to come from this line
https://github.com/EssentialsX/Essentials/blob/2.x/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/ConsoleInjector.java#L95

Replacing it with the following code seems to fix the output to discord:
String entry = FormatUtil.stripPaper(FormatUtil.stripFormat(FormatUtil.stripAnsi(FormatUtil.stripLogColorFormat(event.getMessage().getFormattedMessage())))).trim();

I'm not well versed with the internals of minecraft, and I cannot tell if this is the right fix to make, but everything should be stripped in the order of priorities.