Jump to content

Recommended Posts

Posted

I have been trying to make a mod for a 1.7.10 server (To put in a 1.7.10 mod pack) that can message all of the players online. I have looked this question up, and have not found any answers.
How would I send a message to all of the players on the server? (When trying to do so, it only outputs to the console, and I believe that is because the mod is not installed on the client side.)

I am brand new at forge and java, so any help would be appreciated.

Posted
@SideOnly(Side.SERVER)
@SubscribeEvent
public void onDeath(PlayerEvent.Clone event)
{
    if (event.wasDeath) {
	    final String[] messages = {"Oh boiss we got a respawner O_O", "How dare ye respawn on me?", "GAAH! You died again!", "._. Just why...", "Was taht me or waas that you? -.-","Why isn't this in hardcore mode? It should be..."};
	    Random random = new Random();
	    int index = random.nextInt(messages.length);
	    ChatComponentText text = new ChatComponentText(messages[index]);
	    ChatStyle style = new ChatStyle();
	    style.setColor(EnumChatFormatting.LIGHT_PURPLE);
	    text.setChatStyle(style); 
	    FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendChatMsg(text);
	    System.out.println("Respawned");
    	}
    }
}

Here is the code.

Posted

1.7.10 is no longer supported on these forums due to its age.

Please update to a modern version of Minecraft to receive support.

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
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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