You are checking if the stat was already reduced and then sending the message, but still reducing the stats after the check.
Add a return at the end of the if statement where you check if the stat is already drained, or use an 'else' after it.
Code:
case 26: // confuse
player.setNextAnimation(new Animation(716));
mage_hit_gfx = 104;
player.setNextGraphics(new Graphics(102, 0, 80));
base_mage_xp = 13;
magic_sound = 152;
Hit special = getMagicHit(player, getRandomMagicMaxHit(player, 70));
delayMagicHit(2, special);
World.sendProjectile(new NewProjectile(player, target, 103, !player.withinDistance(target, 1) ? 40 : 15, 20, 65));
if (target instanceof Player) {
Player p = (Player) target;
if (p.getSkills().getLevel(Skills.ATTACK) < p.getSkills().getLevel(Skills.ATTACK)); {
player.getPackets().sendGameMessage("Your spell has no effect because the targets Attack has already been reduced.");
} else {
p.getSkills().drainLevel(0, p.getSkills().getLevel(0) / 5);
p.getPackets().sendGameMessage("Your Attack skills have been drained.");
player.getPackets().sendGameMessage("Your spell weakened your enemy.");
}
}
return 5;
One other thing is that you're not reducing your opponent's attack by 5%, you are dividing it by 5. Which means you would be reducing it by 20%