Ok, so I am currently finding the code for the project I'm working on, and decided that Enum for data storage would be my best bet. But for the first time in my life, enum.ordinal () returns -1?
Here is the code:
DuelRules.Rules rule = DuelRules.Rules.values()[(buttonId - (buttonId < 29 ? 18 : 19))];
if (buttonId == 29) {
rule = DuelRules.Rules.POCKET;
}
System.out.println(rule + ", " + rule.ordinal());
rules.swapRule(player, other, rule);
reset(false);
This statement is here:
System.out.println(rule + ", " + rule.ordinal());
It prints the correct rule value, but when it prints rule.ordinal (), does it print -1?
Example:
HAT, -1
My enum:
public enum Rules {
HAT(5000, 1),
CAPE(5000, 2),
AMULET(5000, 4),
WEAPON(5000, 8),
BODY(5000, 16),
SHIELD(5000, 32),
LEG(5000, 128),
GLOVE(5000, 512),
BOOT(5000, 1024),
RING(5000, 4096),
ARROW(5000, 8192),
POCKET(17837, 1),
FORFEIT(4989),
MOVEMENT(4990),
RANGE(4991),
MELEE(4992),
MAGIC(4993),
DRINKS(4994),
FOOD(4995),
PRAYER(4996),
OBSTACLES(4997),
FUN_WEAPONS(4998),
NO_ABILITIES(4999),
SUMMONING(5001);
private final int varbitId;
private final int value;
private Rules(int id, int... value) {
this.varbitId = id;
this.value = value.length > 0 ? value[0] : 0;
}
}
Note that the enumeration is inside another class, not sure if this could affect the result. Thanks for your help, I am completely lost with this.
EDIT: In further reviews, did I find that the sequence number changes, passing it as an argument?
Screenshots of the console:

The code:
} else if (buttonId >= 18 && buttonId <= 42) {
DuelRules.Rules rule = DuelRules.Rules.values()[(buttonId - (buttonId < 29 ? 18 : 19))];
System.out.println("Point one: "+rule + ", " + rule.ordinal());
rules.swapRule(player, other, rule);
getDuel(other).rules.setRules(player, other, rules
.rules);
reset(false);
sendFlash(interfaceId, buttonId);
}
Where he prints paragraph 1, the Rule and its ordinary are correct, in this case OBSTACLES, 20
rules.swapRule, -1?
public boolean swapRule(Player player, Player other, Rules rule) {
System.out.println("Point 2(swapRule): " + rule + ", " + rule.ordinal());
}
?