Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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)

  • Author

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)

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.