Jump to content

Sending Message to All Players?


TLHPoE

Recommended Posts

Is there an easy way to send a message to all the players on a server? I have a working method but it seems a bit overkill.

 

@SubscribeEvent
public void livingDeathEvent(LivingDeathEvent event) {
	EntityLiving entity = (EntityLiving) event.entityLiving;
	boolean f1 = false;
	if(!entity.worldObj.isRemote) {
		if(entity instanceof EntityDragon) {
			ServerProxyRF.getWorldProperty(entity.worldObj.getWorldInfo().getWorldName(), "hasDefeatedEnderDragon", false).set(true);
			f1 = true;
		}
	} else {
		if(f1) {
			Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_RED + "You hear screams of terror echo throughout the dimensions..."));
		}
	}
}

Kain

Link to comment
Share on other sites

That second leg of your outer if will never send the message. Your local variable (f1) is always false in that leg. It only gets set true (sometimes) in the other leg. Get rid of the "} else {" and just let the code fall through to the "if (f1) ..." part.

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.

Announcements



×
×
  • Create New...

Important Information

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