2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
2013-10-29 20:38:20 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2013-10-24 21:17:10 +02:00
|
|
|
import org.bukkit.Location;
|
2013-05-02 03:57:42 +02:00
|
|
|
import org.bukkit.entity.EntityType;
|
2013-10-29 20:38:20 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2013-05-02 03:57:42 +02:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
2013-10-07 15:59:20 +02:00
|
|
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
2013-11-22 18:48:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
2013-10-07 15:59:20 +02:00
|
|
|
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
2013-10-01 14:57:21 +02:00
|
|
|
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
2013-10-29 20:38:20 +01:00
|
|
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2013-03-03 16:09:41 +01:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
public class FishingCommand extends SkillCommand {
|
|
|
|
private int lootTier;
|
|
|
|
private String shakeChance;
|
|
|
|
private String shakeChanceLucky;
|
2013-03-12 21:25:42 +01:00
|
|
|
private int fishermansDietRank;
|
2013-04-09 17:32:07 +02:00
|
|
|
private String biteChance;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
private String trapTreasure;
|
|
|
|
private String commonTreasure;
|
|
|
|
private String uncommonTreasure;
|
|
|
|
private String rareTreasure;
|
|
|
|
private String epicTreasure;
|
|
|
|
private String legendaryTreasure;
|
|
|
|
private String recordTreasure;
|
|
|
|
|
|
|
|
private String magicChance;
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
private boolean canTreasureHunt;
|
|
|
|
private boolean canMagicHunt;
|
|
|
|
private boolean canShake;
|
|
|
|
private boolean canFishermansDiet;
|
2013-04-09 17:32:07 +02:00
|
|
|
private boolean canMasterAngler;
|
2013-05-01 16:18:19 +02:00
|
|
|
private boolean canIceFish;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
public FishingCommand() {
|
|
|
|
super(SkillType.FISHING);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
|
|
|
|
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
2013-04-09 17:32:07 +02:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// TREASURE HUNTER
|
2013-03-12 21:25:42 +01:00
|
|
|
if (canTreasureHunt) {
|
2013-10-29 20:38:20 +01:00
|
|
|
lootTier = fishingManager.getLootTier();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
// Item drop rates
|
2013-10-29 20:38:20 +01:00
|
|
|
trapTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP) / 100.0);
|
|
|
|
commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
|
|
|
|
uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
|
|
|
|
rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
|
|
|
|
epicTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
|
|
|
|
legendaryTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
|
|
|
|
recordTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0);
|
2013-10-07 15:59:20 +02:00
|
|
|
|
|
|
|
// Magic hunter drop rates
|
2013-10-29 20:38:20 +01:00
|
|
|
double totalEnchantChance = 0;
|
|
|
|
|
|
|
|
for (Rarity rarity : Rarity.values()) {
|
2014-02-27 16:56:21 +01:00
|
|
|
if (rarity != Rarity.TRAP && rarity != Rarity.RECORD) {
|
2013-10-29 20:38:20 +01:00
|
|
|
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-29 20:38:20 +01:00
|
|
|
magicChance = percent.format(totalEnchantChance / 100.0);
|
2013-03-12 21:25:42 +01:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
// SHAKE
|
2013-03-12 21:25:42 +01:00
|
|
|
if (canShake) {
|
2013-10-29 20:38:20 +01:00
|
|
|
String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability(), isLucky);
|
2013-03-12 21:25:42 +01:00
|
|
|
shakeChance = shakeStrings[0];
|
|
|
|
shakeChanceLucky = shakeStrings[1];
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
// FISHERMAN'S DIET
|
2013-03-12 21:25:42 +01:00
|
|
|
if (canFishermansDiet) {
|
2013-10-29 20:38:20 +01:00
|
|
|
fishermansDietRank = calculateRank(skillValue, Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
|
2013-03-12 21:25:42 +01:00
|
|
|
}
|
2013-04-09 17:32:07 +02:00
|
|
|
|
|
|
|
// MASTER ANGLER
|
|
|
|
if (canMasterAngler) {
|
2014-02-27 16:56:21 +01:00
|
|
|
double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500);
|
2013-10-29 20:38:20 +01:00
|
|
|
Location location = fishingManager.getHookLocation();
|
2013-10-28 21:14:52 +01:00
|
|
|
|
|
|
|
if (location == null) {
|
|
|
|
location = player.getLocation();
|
|
|
|
}
|
2013-10-24 21:17:10 +02:00
|
|
|
|
2013-12-05 01:16:48 +01:00
|
|
|
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
|
2013-10-14 16:28:48 +02:00
|
|
|
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
2013-05-02 03:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
2013-10-14 16:28:48 +02:00
|
|
|
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
|
2013-05-02 03:57:42 +02:00
|
|
|
}
|
|
|
|
|
2013-10-29 20:38:20 +01:00
|
|
|
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0, isLucky)[0];
|
2013-04-09 17:32:07 +02:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected void permissionsCheck(Player player) {
|
2013-11-22 18:48:53 +01:00
|
|
|
canTreasureHunt = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHING_TREASURE_HUNTER);
|
|
|
|
canMagicHunt = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.MAGIC_HUNTER);
|
|
|
|
canShake = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHAKE);
|
|
|
|
canFishermansDiet = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET);
|
|
|
|
canMasterAngler = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.MASTER_ANGLER);
|
|
|
|
canIceFish = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ICE_FISHING);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected List<String> effectsDisplay() {
|
|
|
|
List<String> messages = new ArrayList<String>();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
if (canTreasureHunt) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canMagicHunt) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canIceFish) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-04-09 17:32:07 +02:00
|
|
|
|
|
|
|
if (canMasterAngler) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
2013-04-09 17:32:07 +02:00
|
|
|
}
|
2013-05-01 16:18:19 +02:00
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canShake) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
2013-10-07 15:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canFishermansDiet) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
2013-05-01 16:18:19 +02:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-29 20:38:20 +01:00
|
|
|
return messages;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
|
|
|
List<String> messages = new ArrayList<String>();
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
if (canTreasureHunt) {
|
2014-01-15 12:20:05 +01:00
|
|
|
messages.add(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.values().length));
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canMagicHunt) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canIceFish) {
|
|
|
|
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
|
2013-03-12 21:25:42 +01:00
|
|
|
|
|
|
|
if (skillValue < unlockLevel) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Fishing.Ability.IceFishing"));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canMasterAngler) {
|
2013-10-10 19:12:25 +02:00
|
|
|
int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel();
|
|
|
|
|
|
|
|
if (skillValue < unlockLevel) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
|
2013-10-10 19:12:25 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
2013-10-10 19:12:25 +02:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-05-01 16:18:19 +02:00
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canShake) {
|
|
|
|
int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE);
|
2013-05-01 16:18:19 +02:00
|
|
|
|
|
|
|
if (skillValue < unlockLevel) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
|
2013-05-01 16:18:19 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
|
2013-05-01 16:18:19 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-07 15:59:20 +02:00
|
|
|
|
|
|
|
if (canFishermansDiet) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
2013-10-07 15:59:20 +02:00
|
|
|
}
|
2013-10-29 20:38:20 +01:00
|
|
|
|
|
|
|
return messages;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|