Jump to content

Recommended Posts

Posted

You need to use the chat event.

 

Question on the colors below peoples names on this forum.  What do the colored boxes below the rank mean?  I notice you have 3 green and are relatively new to the forum, not sure how that gets picked.

 

 

Here is an example.  The format code stuff is wrong.  It is before I converted to 1.7.2.  I don't have the right material on this comp.  Also, you would have to cahnge this to match your intent.  However, it is the framework.

 

 

  Reveal hidden contents

 

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

I put this in the mod class

 

@SubscribeEvent
public void onServerChatReceivedEvent(ServerChatEvent event) {

	// make sure a player is involved
	if (event.player != null) 
	{
		// Declare player
		EntityPlayer player = (EntityPlayer) event.player;

		if (player != null) 
		{
			// Cancel the event
			event.setCanceled(true);

			// Cycle through players and send the chat
			List players = MinecraftServer.getServer().getConfigurationManager().playerEntityList;

			for (int i = 0; i < + players.size(); i++) 
			{
				// Get the player
				EntityPlayer target = (EntityPlayer) players.get(i);

				// send the chat
				if(target.getDisplayName().contains("Player"))
				{
				String chattxt = EnumChatFormatting.RED + "[" + EnumChatFormatting.YELLOW + "Weapons+ Developer" + EnumChatFormatting.RED + "]" + player.getDisplayName() + event.message;
				target.addChatMessage(new ChatComponentTranslation(chattxt));
				}
			}
		}
	}
}

 

But it doesnt seem to work :/

Creator Of Weapons+ Mod & Sword Art Online HUD Mod

  • 4 years later...
Posted

I can't make this code work (obviously) in 1.12.2

Please, can someone update it?

I really need it for my mod.

 

Thanks

Posted

Please make your own thread, this one is 4 years old and long dead.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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