Thanks to @Jack for sparking the idea
Variables:
int currentXP;
int gainedXP;
int drawXP;
int screenWidth = 520;
int screenHeight = 337;
double yMovement;
int alpha = 255;
In your onStart method:
currentXP = client.getSkills().getExperience(Skill.YOUR_SKILL);
Code for your onPaint method:
gainedXP = client.getSkills().getExperience(Skill.YOUR_SKILL);
if (gainedXP != currentXP) {
drawXP = gainedXP - currentXP;
currentXP = client.getSkills().getExperience(Skill.YOUR_SKILL);
yMovement = 0;
alpha = 255;
}
if (drawXP != 0 && alpha > 1) {
g.setColor(new Color(255, 255, 255, alpha -= 2));
String drawString = "+ " + drawXP;
int stringLength = (int) g.getFontMetrics().getStringBounds(drawString, g).getWidth();
g.drawString(drawString, screenWidth / 2 - stringLength / 2, (int) ((screenHeight / 2) - (yMovement += .7)));
}
If you're drawing other things after this remember to set the color back to what you want!! Here's what it looks like in game: