Jump to content

Can't get chat from multiplayer


Orfby

Recommended Posts

I made a mod (for personal use) that is supposed to create a notification when someone says something in a chat.

 

This is my code:

 

ChatNotifier.java:

package com.notifier.chatnotifier;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = ChatNotifier.MODID, version = ChatNotifier.VERSION)
public class ChatNotifier
{
    public static final String MODID = "Chat Notifier";
    public static final String VERSION = "1.0";
    
    ChatEventHandler handler = new ChatEventHandler();
    
    @EventHandler
    public void preinit(FMLPreInitializationEvent event)
    {
    	FMLCommonHandler.instance().bus().register(handler);
    	MinecraftForge.EVENT_BUS.register(handler);
    }
}

 

ChatEventHandler.java:

package com.notifier.chatnotifier;

import java.io.IOException;

import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class ChatEventHandler
{
@SubscribeEvent
public void checkNormalChat(ServerChatEvent event)
{
	try 
	{
		Runtime.getRuntime().exec("notify-send " + event.username + " \"" + event.message + "\""); //Creates a notification (Linux only)
	} 
	catch (IOException e) 
	{
		e.printStackTrace();
	}
}
}

 

The mod works perfectly in singleplayer, but obviously the point of the mod is to create notifications in multiplayer. I've tested it on a completely vanilla server, and also in a craftbukkit server, and neither work.

Link to comment
Share on other sites

I have a work in progress mod that looks very similar to the one your creating (it has the exact same name) so I'm just wondering were abouts you got the idea for it?  I posted a Alpha version of my mod a few weeks back, information is available on http://www.xelitexirish.com/chat-notifier/

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

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

Link to comment
Share on other sites

I got the idea for it when I had Minecraft minimized and people wanted me, but I didn't know because I couldn't see it. After that I decided to make a simple mod for myself that sends a notification whenever someone says something in chat. The reason I called it chat notifier was because it did exactly that, notify me of chat. Your mod seems a little different to mine though because mine will send notifications (using system commands) when there is any message at all (which I plan on changing)

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.