Notification Manager

IntermediateUtility

Sends customizable notifications for various game events. Demonstrates notification system usage.

15 min read

What It Does

Sends customizable notifications for various game events. Demonstrates notification system usage.

Source Code

java
1package com.example;
2
3import net.runelite.api.Client;
4import net.runelite.api.events.StatChanged;
5import net.runelite.client.eventbus.Subscribe;
6import net.runelite.client.plugins.Plugin;
7import net.runelite.client.plugins.PluginDescriptor;
8import net.runelite.client.ui.overlay.Overlay;
9import javax.inject.Inject;
10
11@PluginDescriptor(
12    name = "Notification Manager",
13    description = "Sends notifications"
14)
15public class NotificationPlugin extends Plugin {
16    @Inject
17    private Client client;
18
19    @Inject
20    private NotificationManager notificationManager;
21
22    @Subscribe
23    public void onStatChanged(StatChanged event) {
24        if (event.getLevel() > event.getBoostedLevel()) {
25            // Level up
26            notificationManager.notify(
27                "Level Up!",
28                "Congratulations on reaching level " + event.getLevel() + 
29                " in " + event.getSkill().getName() + "!",
30                NotificationType.LEVEL_UP
31            );
32        }
33    }
34}

Code Annotations

Line 18

Inject NotificationManager

Line 22

Detect level ups

Line 24

Send notification

API Classes Used

Key Concepts

  • Inject NotificationManager
  • Detect level ups
  • Send notification

Next Steps

  • Learn about NotificationManager API
  • Add configurable notification types
  • Add sound notifications