Fixed bug with fishing treasures throwing an error when treasures list

is empty.
This commit is contained in:
GJ
2012-04-17 15:21:23 -04:00
parent 35f62d4e45
commit f6a6316b7a
2 changed files with 8 additions and 6 deletions

View File

@ -98,11 +98,13 @@ public class Fishing {
}
if (LoadProperties.fishingDrops) {
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
if (rewards.size() > 0) {
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
theCatch.setItemStack(treasure.getDrop());
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
theCatch.setItemStack(treasure.getDrop());
}
}
}
else {
@ -115,7 +117,6 @@ public class Fishing {
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value
}
m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH)); //Always drop a fish
PP.addXP(SkillType.FISHING, LoadProperties.mfishing);
Skills.XpCheckSkill(SkillType.FISHING, player);
}