Jump to content

Recommended Posts

Posted

I know this is a silly question to ask but is there a way to get the chat right after the players name?  I need to check if the players name is in chat and it keeps firing when that user sends a message.  Its a client ONLY mod so I cant use any server methods.

 

Also, is there a way to play a sound that overrides the minecraft sound settings and plays even if sound is turned off?

Thanks,

~Shaun O'Neill

View my website at -> http://www.xelitexirish.com/

You can nearly always contact me on my twitter (XeliteXirish)

Posted

I know you may already have the first one solved, but in case others don't know, and would like to know, you can subscribe to the ClientChatReceivedEvent and use regex to separate the player name from the chat.

 

	try {
		if (event.type == 0) {
			UUID player = null;
			Pattern p = Pattern.compile("\\<(.*?)\\>");
			Matcher m = p.matcher(event.message.getUnformattedText());
			while (m.find()) {
				String s = m.group(1);
				for (EntityPlayer ep:(List<EntityPlayer>)Minecraft.getMinecraft().theWorld.playerEntities) {
					if (ep.getName().equals(s)) {
						player = ep.getUniqueID();
						break;
					}
				}
			}
			if (player != null && event.message.getFormattedText() != null) {
				String chat =  event.message.getFormattedText().replaceFirst("\\<(.*?)\\> ", "");
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}

Posted

I know you may already have the first one solved, but in case others don't know, and would like to know, you can subscribe to the ClientChatReceivedEvent and use regex to separate the player name from the chat.

 

	try {
		if (event.type == 0) {
			UUID player = null;
			Pattern p = Pattern.compile("\\<(.*?)\\>");
			Matcher m = p.matcher(event.message.getUnformattedText());
			while (m.find()) {
				String s = m.group(1);
				for (EntityPlayer ep:(List<EntityPlayer>)Minecraft.getMinecraft().theWorld.playerEntities) {
					if (ep.getName().equals(s)) {
						player = ep.getUniqueID();
						break;
					}
				}
			}
			if (player != null && event.message.getFormattedText() != null) {
				String chat =  event.message.getFormattedText().replaceFirst("\\<(.*?)\\> ", "");
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}

 

Just out of curiosity, can you not just split the chat by every space and just check everything after the first word which is always the player name?  Thats what I did and it seems to be okay.

View my website at -> http://www.xelitexirish.com/

You can nearly always contact me on my twitter (XeliteXirish)

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.

Announcements



×
×
  • Create New...

Important Information

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