Clarify the way fishing enchantments work - need to fix command display

still.
This commit is contained in:
gmcferrin 2013-01-10 15:22:47 -05:00
parent ff4832a6a2
commit f43b4ebdc5

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.gathering;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -151,7 +150,8 @@ public class Fishing {
Item theCatch = (Item) event.getCaught(); Item theCatch = (Item) event.getCaught();
if (theCatch.getItemStack().getType() != Material.RAW_FISH) { if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
final int ENCHANTMENT_CHANCE = advancedConfig.getFishingEnchantmentChance(); int lootTier = Fishing.getFishingLootTier(profile);
int specificChance = 1;
boolean enchanted = false; boolean enchanted = false;
ItemStack fishingResults = theCatch.getItemStack(); ItemStack fishingResults = theCatch.getItemStack();
@ -164,22 +164,35 @@ public class Fishing {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
if (Misc.getRandom().nextInt(randomChance) <= ENCHANTMENT_CHANCE /* CHANCE OF ITEM BEING ENCHANTED
&& Permissions.fishingMagic(player)) { * 10% - Tier 1
* 20% - Tier 2
* 30% - Tier 3
* 40% - Tier 4
* 50% - Tier 5
*/
if (Misc.getRandom().nextInt(randomChance) <= (lootTier * 10) && Permissions.fishingMagic(player)) {
for (Enchantment newEnchant : Enchantment.values()) { for (Enchantment newEnchant : Enchantment.values()) {
if (newEnchant.canEnchantItem(fishingResults)) { if (newEnchant.canEnchantItem(fishingResults)) {
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments(); specificChance++;
for (Enchantment oldEnchant : resultEnchantments.keySet()) { for (Enchantment oldEnchant : fishingResults.getEnchantments().keySet()) {
if (oldEnchant.conflictsWith(newEnchant)) if (oldEnchant.conflictsWith(newEnchant))
specificChance--;
continue; continue;
} }
/* /* CHANCE OF GETTING EACH ENCHANTMENT
* Actual chance to have an enchantment is related * 50% - 1st Enchantment
* to your fishing skill * 33% - 2nd Enchantment
* 25% - 3rd Enchantment
* 20% - 4th Enchantment
* 16.66% - 5th Enchantment
* 14.29% - 6th Enchantment
* 12.5% - 7th Enchantment
* 11.11% - 8th Enchantment
*/ */
if (Misc.getRandom().nextInt(15) < Fishing.getFishingLootTier(profile)) { if (Misc.getRandom().nextInt(specificChance) < 1) {
enchanted = true; enchanted = true;
int randomEnchantLevel = Misc.getRandom().nextInt(newEnchant.getMaxLevel()) + 1; int randomEnchantLevel = Misc.getRandom().nextInt(newEnchant.getMaxLevel()) + 1;
@ -187,10 +200,8 @@ public class Fishing {
randomEnchantLevel = newEnchant.getStartLevel(); randomEnchantLevel = newEnchant.getStartLevel();
} }
if (randomEnchantLevel >= 1000)
continue;
fishingResults.addEnchantment(newEnchant,randomEnchantLevel); fishingResults.addEnchantment(newEnchant, randomEnchantLevel);
} }
} }
} }