Title says it all, here's my code and a picture below;
Code:
public static final boolean checkRunes(Player player, boolean delete, int... runes) {
int weaponId = player.getEquipment().getWeaponId();
int shieldId = player.getEquipment().getShieldId();
int runesCount = 0;
while (runesCount < runes.length) {
int runeId = runes[runesCount++];
int amount = runes[runesCount++];
if (hasInfiniteRunes(runeId, weaponId, shieldId))
continue;
else if (hasSpecialRunes(player, runeId, amount))
continue;
else if (hasStaffOfLight(weaponId) && Utils.getRandom(8) == 0 && runeId != 21773)
continue;
if (!player.getInventory().containsItem(runeId, amount)) {
player.getPackets().sendGameMessage("You do not have enough " + ItemDefinitions.getItemDefinitions(runeId).getName().replace("rune", "Rune")+ "s to cast this spell.");
return false;
}
}
if (delete) {
runesCount = 0;
while (runesCount < runes.length) {
int runeId = runes[runesCount++];
int amount = runes[runesCount++];
if (hasInfiniteRunes(runeId, weaponId, shieldId))
continue;
if (hasSpecialRunes(player, runeId, amount))
runeId = getRuneForId(runeId);
player.getInventory().deleteItem(runeId, amount);
}
}
return true;
}