diff --git a/src/main/java/com/gmail/nossr50/commands/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/SkillCommand.java index 56d8300b7..04efea1cd 100644 --- a/src/main/java/com/gmail/nossr50/commands/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/SkillCommand.java @@ -81,9 +81,22 @@ public abstract class SkillCommand implements CommandExecutor { return true; } + protected String[] calculateAbilityDisplayValues(double chance) { + if (isLucky) { + double luckyChance = chance * 1.3333D; + + if (luckyChance >= 100D) { + return new String[] { percent.format(chance / 100.0D), percent.format(1.0D) }; + } + + return new String[] { percent.format(chance / 100.0D), percent.format(luckyChance / 100.0D) }; + } + + return new String[] { percent.format(chance / 100.0D), null }; + } + protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) { double abilityChance; - double luckyChance; if (skillValue >= maxBonusLevel) { abilityChance = maxChance; @@ -93,7 +106,7 @@ public abstract class SkillCommand implements CommandExecutor { } if (isLucky) { - luckyChance = abilityChance * 1.3333D; + double luckyChance = abilityChance * 1.3333D; if (luckyChance >= 100D) { return new String[] { percent.format(abilityChance / 100.0D), percent.format(1.0D) }; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index d01c75865..0759ca257 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.gathering.Fishing; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Skills; public class FishingCommand extends SkillCommand { @@ -15,22 +14,18 @@ public class FishingCommand extends SkillCommand { private int lootTier; private String magicChance; private String magicChanceLucky; - private String chanceRaining; - private int shakeUnlockLevel; + private String chanceRaining = ""; private String shakeChance; private String shakeChanceLucky; private String fishermansDietRank; - private int magicHunterMultiplier = advancedConfig.getFishingMagicMultiplier(); - private int fishermansDietRankChange = advancedConfig.getFarmerDietRankChange(); + private int fishermansDietRankChange = AdvancedConfig.getInstance().getFarmerDietRankChange(); private int fishermansDietRankMaxLevel = fishermansDietRankChange * 5; private boolean canTreasureHunt; private boolean canMagicHunt; private boolean canShake; private boolean canFishermansDiet; - private boolean lucky; - private boolean raining; public FishingCommand() { super(SkillType.FISHING); @@ -38,30 +33,32 @@ public class FishingCommand extends SkillCommand { @Override protected void dataCalculations() { - //TREASURE HUNTER - raining = player.getWorld().hasStorm(); - chanceRaining = ""; - lootTier = Fishing.getFishingLootTier(profile); - double magicChanceD = lootTier * magicHunterMultiplier; - if (raining) { + + //TREASURE HUNTER + double enchantChance = lootTier * Fishing.magicHunterMultiplier; + + if (player.getWorld().hasStorm()) { chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining"); - magicChanceD = magicChanceD * 1.1D; + enchantChance = enchantChance * 1.1D; } - magicChance = percent.format(magicChanceD / 100D); - if (magicChanceD * 1.3333D >= 100D) magicChanceLucky = percent.format(1D); - else magicChanceLucky = percent.format(magicChanceD * 1.3333D / 100D); - //Shake - int dropChance = Fishing.getShakeChance(lootTier); - shakeChance = percent.format(dropChance / 100D); - if (dropChance * 1.3333D >= 100D) shakeChanceLucky = percent.format(1D); - else shakeChanceLucky = percent.format(dropChance * 1.3333D / 100D); - shakeUnlockLevel = advancedConfig.getShakeUnlockLevel(); + String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance); + magicChance = treasureHunterStrings[0]; + magicChanceLucky = treasureHunterStrings[1]; - //Fishermans Diet - if (skillValue >= fishermansDietRankMaxLevel) fishermansDietRank = "5"; - else fishermansDietRank = String.valueOf((int) ((double) skillValue / (double) fishermansDietRankChange)); + //SHAKE + String[] shakeStrings = calculateAbilityDisplayValues(Fishing.getShakeChance(lootTier)); + shakeChance = shakeStrings[0]; + shakeChanceLucky = shakeStrings[1]; + + //FISHERMAN'S DIET + if (skillValue >= fishermansDietRankMaxLevel) { + fishermansDietRank = "5"; + } + else { + fishermansDietRank = String.valueOf((int) (skillValue / fishermansDietRankChange)); + } } @Override @@ -70,7 +67,6 @@ public class FishingCommand extends SkillCommand { canMagicHunt = Permissions.fishingMagic(player); canShake = Permissions.shakeMob(player); canFishermansDiet = Permissions.fishermansDiet(player); - lucky = Permissions.luckyFishing(player); } @Override @@ -80,10 +76,7 @@ public class FishingCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (lucky) { - String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix"); - player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.FISHING) }) })); - } + luckyEffectsDisplay(); if (canTreasureHunt) { player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") })); @@ -114,21 +107,25 @@ public class FishingCommand extends SkillCommand { } if (canMagicHunt) { - if (lucky) + if (isLucky) { player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance}) + chanceRaining + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { magicChanceLucky })); - else + } + else { player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance}) + chanceRaining); + } } if (canShake) { - if (skillValue < advancedConfig.getShakeUnlockLevel()) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0", new Object[] { shakeUnlockLevel }) })); + if (skillValue < Fishing.shakeUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0", new Object[] { Fishing.shakeUnlockLevel }) })); } else { - if (lucky) + if (isLucky) { player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", new Object[] { shakeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { shakeChanceLucky })); - else + } + else { player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", new Object[] { shakeChance })); + } } } diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index c405437de..45989fe7c 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -77,6 +77,8 @@ public class AdvancedConfig extends ConfigLoader { public int getFishingMagicMultiplier() { return config.getInt("Skills.Fishing.MagicHunter_Multiplier", 5); } + public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); } + /* Shake */ public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); } public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); } @@ -86,7 +88,7 @@ public class AdvancedConfig extends ConfigLoader { public int getShakeChanceRank5() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_5", 75); } /* HERBALISM */ - public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Food_RankChange", 200); } + public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Farmer_Diet_RankChange", 200); } public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb_StageChange", 200); } public int getGreenThumbChanceMax() { return config.getInt("Skills.Herbalism.GreenThumb_ChanceMax", 100); } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 8301d8b4b..cf5a9bd8d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -305,97 +305,110 @@ public class EntityListener implements Listener { int rankChange = 0; boolean fish = false; boolean herb = false; - int FoodRank1 = advancedConfig.getFarmerDietRankChange(); - int FoodRank2 = advancedConfig.getFarmerDietRankChange() * 2; - int FoodRankMax = advancedConfig.getFarmerDietRankChange() * 5; + int herbFoodRank1 = advancedConfig.getFarmerDietRankChange(); + int herbFoodRank2 = advancedConfig.getFarmerDietRankChange() * 2; + int herbFoodRankMax = advancedConfig.getFarmerDietRankChange() * 5; + int fishFoodRank1 = advancedConfig.getFishermanDietRankChange(); + int fishFoodRank2 = advancedConfig.getFishermanDietRankChange() * 2; + int fishFoodRankMax = advancedConfig.getFishermanDietRankChange() * 5; switch (food) { case BREAD: /* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank1; + rankChange = herbFoodRank1; break; case COOKIE: /* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank2; + rankChange = herbFoodRank2; break; case MELON: /* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank2; + rankChange = herbFoodRank2; break; case MUSHROOM_SOUP: /* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank1; + rankChange = herbFoodRank1; break; case CARROT_ITEM: /* CARROT RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank1; + rankChange = herbFoodRank1; break; case POTATO_ITEM: /* POTATO RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank2; + rankChange = herbFoodRank2; break; case BAKED_POTATO: /* BAKED POTATO RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank1; + rankChange = herbFoodRank1; break; case POISONOUS_POTATO: /* POISONOUS POTATO RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank2; + rankChange = herbFoodRank2; break; case GOLDEN_CARROT: /* GOLDEN CARROT RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank1; + rankChange = herbFoodRank1; break; case PUMPKIN_PIE: /* PUMPKIN PIE RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ herb = true; - rankChange = FoodRank1; + rankChange = herbFoodRank1; break; case RAW_FISH: /* RAW FISH RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ - rankChange = FoodRank2; + rankChange = fishFoodRank2; fish = true; break; case COOKED_FISH: /* COOKED FISH RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ - rankChange = FoodRank1; + rankChange = fishFoodRank1; fish = true; - break; + default: return; } - if (herb && !Permissions.farmersDiet(player)) { - return; - } - else if (fish && !Permissions.fishermansDiet(player)) { - return; - } + if (herb) { + if (!Permissions.farmersDiet(player)) { + return; + } - for (int i = FoodRank1; i <= FoodRankMax; i += rankChange) { - if ((herb && herbLevel >= i) || (fish && fishLevel >= i)) { - foodChange++; + for (int i = herbFoodRank1; i <= herbFoodRankMax; i += rankChange) { + if (herbLevel >= i) { + foodChange++; + } + } + } + else if (fish) { + if (!Permissions.fishermansDiet(player)) { + return; + } + + for (int i = fishFoodRank1; i <= fishFoodRankMax; i += rankChange) { + if (fish && fishLevel >= i) { + foodChange++; + } } } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java index aaacc6ccb..7a7e9d911 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -36,7 +36,20 @@ import com.gmail.nossr50.util.Skills; import com.gmail.nossr50.util.Users; public class Fishing { - static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); + public static int fishingTierLevel1 = AdvancedConfig.getInstance().getFishingTierLevelsTier1(); + public static int fishingTierLevel2 = AdvancedConfig.getInstance().getFishingTierLevelsTier2(); + public static int fishingTierLevel3 = AdvancedConfig.getInstance().getFishingTierLevelsTier3(); + public static int fishingTierLevel4 = AdvancedConfig.getInstance().getFishingTierLevelsTier4(); + public static int fishingTierLevel5 = AdvancedConfig.getInstance().getFishingTierLevelsTier5(); + + public static int shakeChanceLevel1 = AdvancedConfig.getInstance().getShakeChanceRank1(); + public static int shakeChanceLevel2 = AdvancedConfig.getInstance().getShakeChanceRank2(); + public static int shakeChanceLevel3 = AdvancedConfig.getInstance().getShakeChanceRank3(); + public static int shakeChanceLevel4 = AdvancedConfig.getInstance().getShakeChanceRank4(); + public static int shakeChanceLevel5 = AdvancedConfig.getInstance().getShakeChanceRank5(); + public static int shakeUnlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel(); + + public static int magicHunterMultiplier = AdvancedConfig.getInstance().getFishingMagicMultiplier(); /** * Get the player's current fishing loot tier. @@ -49,13 +62,13 @@ public class Fishing { int level = profile.getSkillLevel(SkillType.FISHING); int fishingTier; - if (level >= advancedConfig.getFishingTierLevelsTier5()) { + if (level >= fishingTierLevel5) { fishingTier = 5; - } else if (level >= advancedConfig.getFishingTierLevelsTier4()) { + } else if (level >= fishingTierLevel4) { fishingTier = 4; - } else if (level >= advancedConfig.getFishingTierLevelsTier3()) { + } else if (level >= fishingTierLevel3) { fishingTier = 3; - } else if (level >= advancedConfig.getFishingTierLevelsTier2()) { + } else if (level >= fishingTierLevel2) { fishingTier = 2; } else { fishingTier = 1; @@ -133,7 +146,6 @@ public class Fishing { if (theCatch.getItemStack().getType() != Material.RAW_FISH) { int lootTier = Fishing.getFishingLootTier(profile); - int magicHunterMultiplier = advancedConfig.getFishingMagicMultiplier(); int specificChance = 1; boolean enchanted = false; ItemStack fishingResults = theCatch.getItemStack(); @@ -460,19 +472,19 @@ public class Fishing { public static int getShakeChance(int lootTier) { switch (lootTier) { case 1: - return advancedConfig.getShakeChanceRank1(); + return shakeChanceLevel1; case 2: - return advancedConfig.getShakeChanceRank2(); + return shakeChanceLevel2; case 3: - return advancedConfig.getShakeChanceRank3(); + return shakeChanceLevel3; case 4: - return advancedConfig.getShakeChanceRank4(); + return shakeChanceLevel4; case 5: - return advancedConfig.getShakeChanceRank5(); + return shakeChanceLevel5; default: return 10; diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 8c4d6fa6b..0a38520c8 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -116,12 +116,15 @@ Skills: # MagicHunter_Multiplier: Determines the chance of fishing enchanted items. The chance is calculated by getting the fishing TreasureHunt tier and multiplying it with MagicHunter_Multiplier MagicHunter_Multiplier: 5 + + # This determines when Fisherman's Diet adds extra hunger recovery to food + Fisherman_Diet_RankChange: 200 # # Settings for Herbalism ### Herbalism: # This determines when Farmersdiet and Fishermans diet add extra hunger recovery to food - Food_RankChange: 200 + Farmer_Diet_RankChange: 200 # GreenThumb_StageChange: Level value when the GreenThumb stage level goes up # GreenThumb_ChanceMax: Maximum chance of GreenThumb diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 97ee87a6f..54e769a4d 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -122,7 +122,7 @@ Fishing.Skillup=[[YELLOW]]Fishing skill increased by {0}. Total ({1}) #HERBALISM Herbalism.Ability.DoubleDropChance=[[RED]]Double Drop Chance: [[YELLOW]]{0} -Herbalism.Ability.FD=[[RED]]Farmers Diet: [[YELLOW]]Rank {0} +Herbalism.Ability.FD=[[RED]]Farmer''s Diet: [[YELLOW]]Rank {0} Herbalism.Ability.GTe.Length=[[RED]]Green Terra Length: [[YELLOW]]{0}s Herbalism.Ability.GTe.NeedMore=[[RED]]You need more seeds to spread Green Terra. Herbalism.Ability.GTh.Chance=[[RED]]Green Thumb Chance: [[YELLOW]]{0}