From f6a6316b7a62d0f28090bc06a6b87f5cbbc4d7c7 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 17 Apr 2012 15:21:23 -0400 Subject: [PATCH] Fixed bug with fishing treasures throwing an error when treasures list is empty. --- Changelog.txt | 3 ++- src/main/java/com/gmail/nossr50/skills/Fishing.java | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index b70d03990..e3958d94c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,7 +14,8 @@ Version 1.3.06-dev = Fixed bug where {0} would be displayed in front of your power level in mcstats = Fixed mmoupdate not being useable from console = Fixed bug with repairing wooden tools - = Fixed bug with Nether Wart not awarding XP + = Fixed bug with Nether Wart not awarding XP + = Fixed bug with fishing treasures when treasures list is empty ! Changed mcremove to no longer kick players when they are removed from database ! Changed mcremove to work on offline users for FlatFile ! Changed PlayerProfile constructor to always take a boolean diff --git a/src/main/java/com/gmail/nossr50/skills/Fishing.java b/src/main/java/com/gmail/nossr50/skills/Fishing.java index 96a6203e7..a74c5e82f 100644 --- a/src/main/java/com/gmail/nossr50/skills/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/Fishing.java @@ -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); }