I am making a bukkit plugin, and I am using an API called MCStats, to create the graph, you add Plotters like so…
mobs.addPlotter(new Metrics.Plotter("Player") {
@Override
public int getValue() {
return 0;
}
});
But I want to get the values from a HashMap, and idealy something like this…
for(String mob: mobNames) {
mobs.addPlotter(new Metrics.Plotter(mob) {
@Override
public int getValue() {
return Stats.getValue(mob);
}
});
}
But obviously, it can’t access the mob variable, if I set it to final, it still wont be able to change in the loop. How can I work around this problem?
You can, in fact, use
finalin an enhancedforloop: