Jump to content

[1.7.2] Problem with colored chat message


SackCastellon

Recommended Posts

The problem is the following:

 

I've created a code to display a chat message with a red color:

EnumChatFormatting.RED + ModInfo[0] + " (" + ModInfo[1] + ") is out of date! Please visit " + ModInfo[3] + " to get the latest version (" + ModInfo[2] +")";

 

But when i run minecraft i don't get the full message on red, only the first line:

 

width=800 height=413https://dl.dropboxusercontent.com/u/184200482/img/chat_version_message.png[/img]

 

Does anybody know why does it happens and how to solve it?

 

Thanks for helping.

Link to comment
Share on other sites

What do you want the end result to be? When using EnumChatFormatting, whatever format you put will apply to the entire string unless you call EnumChatFormatting.RESET.

For example, if you do

par1EntityPlayer.addChatMessage(EnumChatFormatting.RED + "Red" + EnumChatFormatting.RESET + " White");

The Red will be colored red, and the white will be colored default.

 

Also, is that a clickable link?

Link to comment
Share on other sites

What do you want the end result to be? When using EnumChatFormatting, whatever format you put will apply to the entire string unless you call EnumChatFormatting.RESET.

 

His problem is that it isn't effecting the whole string, it's only effecting until a new-line.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

What do you want the end result to be? When using EnumChatFormatting, whatever format you put will apply to the entire string unless you call EnumChatFormatting.RESET.

 

His problem is that it isn't effecting the whole string, it's only effecting until a new-line.

*affecting, sorry, can't help it :P

 

I don't see why it wouldn't carry over from line to line.  In fact, it shouldn't, so your problem is in the link.

 

Also, I asked if it was a clickable link because I'm fairly confident the link would reset the chat formatting, so if you put EnumChatFormatting.RED after your link it should show everything but the link in red.

Link to comment
Share on other sites

What do you want the end result to be? When using EnumChatFormatting, whatever format you put will apply to the entire string unless you call EnumChatFormatting.RESET.

For example, if you do

par1EntityPlayer.addChatMessage(EnumChatFormatting.RED + "Red" + EnumChatFormatting.RESET + " White");

The Red will be colored red, and the white will be colored default.

 

Also, is that a clickable link?

 

What do you want the end result to be? When using EnumChatFormatting, whatever format you put will apply to the entire string unless you call EnumChatFormatting.RESET.

 

His problem is that it isn't effecting the whole string, it's only effecting until a new-line.

*affecting, sorry, can't help it :P

 

I don't see why it wouldn't carry over from line to line.  In fact, it shouldn't, so your problem is in the link.

 

Also, I asked if it was a clickable link because I'm fairly confident the link would reset the chat formatting, so if you put EnumChatFormatting.RED after your link it should show everything but the link in red.

 

No that is not a clickable link (I don't know how to do it)

Link to comment
Share on other sites

What do you want the end result to be? When using EnumChatFormatting, whatever format you put will apply to the entire string unless you call EnumChatFormatting.RESET.

 

His problem is that it isn't effecting the whole string, it's only effecting until a new-line.

 

yes, it's the problem I have.  Do you know how to solve it?

Link to comment
Share on other sites

yes, it's the problem I have.  Do you know how to solve it?

 

No.  I haven't messed with chat formatting in chat strings, only addInformation() which doesn't support newlines.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Have you tried adding the method a few more times to reset it?

 

Try this for example:

 

EnumChatFormatting.RED + ModInfo[0] + " (" + ModInfo[1] + ") is out of date! Please visit " + EnumChatFormatting.RED + ModInfo[3] + " to get the " + EnumChatFormatting.RED + "latest version (" + ModInfo[2] +")";

 

I don't know if it would work, because I have never had this issue before...

worth a try ;)

Link to comment
Share on other sites

Have you tried adding the method a few more times to reset it?

 

Try this for example:

 

EnumChatFormatting.RED + ModInfo[0] + " (" + ModInfo[1] + ") is out of date! Please visit " + EnumChatFormatting.RED + ModInfo[3] + " to get the " + EnumChatFormatting.RED + "latest version (" + ModInfo[2] +")";

 

I don't know if it would work, because I have never had this issue before...

worth a try ;)

 

Yes, i already thought about that, and it works:

 

width=800 height=413https://dl.dropboxusercontent.com/u/184200482/img/chat_version_message_1.png[/img]

 

BUT, if i reduce the chat width:

 

width=800 height=414https://dl.dropboxusercontent.com/u/184200482/img/chat_version_message_2.png[/img]

 

THEN, happens this:

 

width=800 height=413https://dl.dropboxusercontent.com/u/184200482/img/chat_version_message_3.png[/img]

 

So, it's not solved at all.  :(

Link to comment
Share on other sites

I wonder if its a problem with 1.7.2's EnumChatFormatting (1.6.2 EnumChatFormatting works for me [tested too])

 

Have you tried using your own String Formatter?

 

Here try this for example:

public class StringHandler {
public static String dark_black = "\u00a70";
public static String dark_blue = "\u00a71";
public static String dark_green = "\u00a72";
public static String dark_cyan = "\u00a73";
public static String dark_red = "\u00a74";
public static String dark_purple = "\u00a75";
public static String dark_yellow = "\u00a76";
        public static String gray = "\u00a77";
public static String dark_gray = "\u00a78";
public static String blue = "\u00a79";
public static String green = "\u00a7A";
public static String cyan = "\u00a7B";
public static String red = "\u00a7C";
public static String purple = "\u00a7D";
public static String yellow = "\u00a7E";
        public static String white = "\u00a7F";
}

 

Now, to use it:

StringHandler.red + ModInfo[0] + " (" + ModInfo[1] + ") is out of date! Please visit " + ModInfo[3] + " to get the latest version (" + ModInfo[2] +")";

 

Good luck :)

Link to comment
Share on other sites

I wonder if its a problem with 1.7.2's EnumChatFormatting (1.6.2 EnumChatFormatting works for me [tested too])

 

Have you tried using your own String Formatter?

 

Here try this for example:

public class StringHandler {
public static String dark_black = "\u00a70";
public static String dark_blue = "\u00a71";
public static String dark_green = "\u00a72";
public static String dark_cyan = "\u00a73";
public static String dark_red = "\u00a74";
public static String dark_purple = "\u00a75";
public static String dark_yellow = "\u00a76";
        public static String gray = "\u00a77";
public static String dark_gray = "\u00a78";
public static String blue = "\u00a79";
public static String green = "\u00a7A";
public static String cyan = "\u00a7B";
public static String red = "\u00a7C";
public static String purple = "\u00a7D";
public static String yellow = "\u00a7E";
        public static String white = "\u00a7F";
}

 

Now, to use it:

StringHandler.red + ModInfo[0] + " (" + ModInfo[1] + ") is out of date! Please visit " + ModInfo[3] + " to get the latest version (" + ModInfo[2] +")";

 

Good luck :)

 

???  No, i haven't.

 

It don't works  :'( :'(

Link to comment
Share on other sites

  • 7 months later...

I know this is a bit out of date, but in case anyone else wonders across this, I had to address this issue when adding a /reply command to private messages. While it may be a bit overkill, perhaps you could parse outgoing text through a custom method and split it at any spaces, and add your desired formatting before each word. In my scenario I had to iterate through the String[] 'parameters' and manually add spaces, so I also added the chat formatting, which fully addressed the issue. It generically could look something like this:

 

String s = "";
String[] m = message.split(" ");		
for(String t : m){
        s += formatString;
s += t;
s += " ";
}

 

...where message = the original message and formatString = the desired formatting and s = your new, completed message.

 

It feels overkill, but it works! Hope that helps.

I'll need help, and I'll give help. Just ask, you know I will!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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