Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12.2] Send Message to Player


ChiroxT
 Share

Recommended Posts

How do i send a Message to a specific Player?

i tried following:

EntityPlayer p = Minecraft.getMinecraft().world.getPlayerEntityByName(playername);
if (p != null) {
	p.sendMessage(new TextComponentString(msg);
}

but this only causes the Message to appear on my own Chat.

 

The addChatMessage also seem not to work anymore, so how is the new way?

Can i prevent it from appearing in chat (gets handled by ClientChatReceivedEvent)

Link to comment
Share on other sites

2 hours ago, ChiroxT said:

Minecraft.getMinecraft()

This is the client. Not the server. This will crash the server. The only player here will be the local user.

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

1) You have to do it server side

2) Use the server's player list

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

55 minutes ago, diesieben07 said:

You need to call EntityPlayer::sendMessage on the server. That is as specific as I can get, because you have not specified when or how exactly you want these messages to be sent.

This is a Guild System and this feature is for inviting players.

The Leader enters the name in a Textbox and presses a button.

This shall send a Message to this specific Player which gets handled by ClientChatReceivedEvent, which shows a Accept/Refuse dialog.

 

All those Gui's and the function of accepting are working. Just the Message to the player is my last Problem.

 

How can i manage, that the server knows, that it have to send this message. I thought about writing the player- and the guildname into a List, but then, this list must be checked constantly by the server and in case, send the message.

Link to comment
Share on other sites

2 hours ago, diesieben07 said:

Why are you doing this via chat messages?! You should be using custom packets, like was said above.

Nothing of what you are doing requires chat messages.

Maybe because this is my first Forge-Mod???

I did not knew about this feature and tutorials on YT also did not speak about it.

 

I will check it out, but what i were reading for now seemed to be pretty usable :D just wanna understand it before using it :)

  • Like 1
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.

Guest
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.