Fixing formatting

This commit is contained in:
TfT_02 2013-01-03 17:40:22 +01:00
parent 9ae74e0fba
commit cdd9745341

View File

@ -106,10 +106,8 @@ public class Fishing {
break; break;
} }
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) {
&& Permissions.getInstance().fishingTreasures(player)) { FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
FishingTreasure treasure = rewards.get(random.nextInt(rewards
.size()));
int randomChance = 100; int randomChance = 100;
@ -118,26 +116,20 @@ public class Fishing {
} }
if (random.nextDouble() * randomChance <= treasure.getDropChance()) { if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
Users.getPlayer(player).addXP(SkillType.FISHING, Users.getPlayer(player).addXP(SkillType.FISHING,treasure.getXp());
treasure.getXp());
theCatch.setItemStack(treasure.getDrop()); theCatch.setItemStack(treasure.getDrop());
} }
} else { } else {
theCatch.setItemStack(new ItemStack(Material.RAW_FISH)); theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
} }
short maxDurability = theCatch.getItemStack().getType() short maxDurability = theCatch.getItemStack().getType().getMaxDurability();
.getMaxDurability();
if (maxDurability > 0) { if (maxDurability > 0) {
theCatch.getItemStack().setDurability( theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); // Change durability to random value
(short) (random.nextInt(maxDurability))); // Change
// durability to
// random value
} }
Skills.xpProcessing(player, profile, SkillType.FISHING, Config Skills.xpProcessing(player, profile, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
.getInstance().getFishingBaseXP());
} }
/** /**
@ -157,8 +149,7 @@ 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 final int ENCHANTMENT_CHANCE = advancedConfig.getFishingEnchantmentChance();
.getFishingEnchantmentChance();
boolean enchanted = false; boolean enchanted = false;
ItemStack fishingResults = theCatch.getItemStack(); ItemStack fishingResults = theCatch.getItemStack();
@ -171,15 +162,12 @@ public class Fishing {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);
} }
if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
&& Permissions.getInstance().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 Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
.getEnchantments();
for (Enchantment oldEnchant : resultEnchantments for (Enchantment oldEnchant : resultEnchantments.keySet()) {
.keySet()) {
if (oldEnchant.conflictsWith(newEnchant)) if (oldEnchant.conflictsWith(newEnchant))
continue; continue;
} }
@ -188,23 +176,18 @@ public class Fishing {
* Actual chance to have an enchantment is related * Actual chance to have an enchantment is related
* to your fishing skill * to your fishing skill
*/ */
if (random.nextInt(15) < Fishing if (random.nextInt(15) < Fishing.getFishingLootTier(profile)) {
.getFishingLootTier(profile)) {
enchanted = true; enchanted = true;
int randomEnchantLevel = random int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;
.nextInt(newEnchant.getMaxLevel()) + 1;
if (randomEnchantLevel < newEnchant if (randomEnchantLevel < newEnchant.getStartLevel()) {
.getStartLevel()) { randomEnchantLevel = newEnchant.getStartLevel();
randomEnchantLevel = newEnchant
.getStartLevel();
} }
if (randomEnchantLevel >= 1000) if (randomEnchantLevel >= 1000)
continue; continue;
fishingResults.addEnchantment(newEnchant, fishingResults.addEnchantment(newEnchant,randomEnchantLevel);
randomEnchantLevel);
} }
} }
} }
@ -237,8 +220,7 @@ public class Fishing {
int dropChance = getShakeChance(lootTier); int dropChance = getShakeChance(lootTier);
if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) { if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) {
dropChance = (int) (dropChance * 1.25); // With lucky perk on max dropChance = (int) (dropChance * 1.25); // With lucky perk on max level tier, its 100%
// level tier, its 100%
} }
final int DROP_CHANCE = random.nextInt(100); final int DROP_CHANCE = random.nextInt(100);