Stat Display

BeginnerDisplay

Displays your current skill levels and experience in an overlay. Shows how to access skill data and format it for display.

12 min read

What It Does

Displays your current skill levels and experience in an overlay. Shows how to access skill data and format it for display.

Source Code

java
1package com.example;
2
3import net.runelite.api.Client;
4import net.runelite.api.Skill;
5import net.runelite.client.ui.overlay.Overlay;
6import net.runelite.client.ui.overlay.OverlayManager;
7import net.runelite.client.plugins.Plugin;
8import net.runelite.client.plugins.PluginDescriptor;
9import javax.inject.Inject;
10import java.awt.*;
11
12@PluginDescriptor(
13    name = "Stat Display",
14    description = "Shows your skill levels"
15)
16public class StatDisplayPlugin extends Plugin {
17    @Inject
18    private Client client;
19
20    @Inject
21    private OverlayManager overlayManager;
22
23    private final Overlay overlay = new Overlay() {
24        @Override
25        public Dimension render(Graphics2D graphics) {
26            graphics.setColor(Color.WHITE);
27            int y = 20;
28            
29            for (Skill skill : Skill.values()) {
30                int level = client.getRealSkillLevel(skill);
31                int xp = client.getSkillExperience(skill);
32                graphics.drawString(skill.getName() + ": " + level + " (" + xp + " XP)", 10, y);
33                y += 15;
34            }
35            
36            return new Dimension(200, y);
37        }
38    };
39
40    @Override
41    protected void startUp() {
42        overlayManager.add(overlay);
43    }
44
45    @Override
46    protected void shutDown() {
47        overlayManager.remove(overlay);
48    }
49}

Code Annotations

Line 28

Iterate through all skills using Skill enum

Line 29

Get real skill level (not boosted)

Line 30

Get total experience for the skill

API Classes Used

Key Concepts

  • Iterate through all skills using Skill enum
  • Get real skill level (not boosted)
  • Get total experience for the skill

Next Steps

  • Learn about Skill enum
  • Add configurable skill filtering
  • Format numbers with commas