2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
2013-05-02 03:57:42 +02:00
|
|
|
import org.bukkit.block.Biome;
|
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
|
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-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-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
|
|
|
|
protected void dataCalculations() {
|
2013-04-09 17:32:07 +02:00
|
|
|
boolean isStorming = player.getWorld().hasStorm();
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// TREASURE HUNTER
|
2013-03-12 21:25:42 +01:00
|
|
|
if (canTreasureHunt) {
|
|
|
|
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
// Item drop rates
|
|
|
|
trapTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP))[0];
|
|
|
|
commonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON))[0];
|
|
|
|
uncommonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON))[0];
|
|
|
|
rareTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE))[0];
|
|
|
|
epicTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC))[0];
|
|
|
|
legendaryTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY))[0];
|
|
|
|
recordTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD))[0];
|
|
|
|
|
|
|
|
// Magic hunter drop rates
|
|
|
|
double commonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.COMMON);
|
|
|
|
double uncommonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.UNCOMMON);
|
|
|
|
double rareEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.RARE);
|
|
|
|
double epicEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.EPIC);
|
|
|
|
double legendaryEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.LEGENDARY);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
magicChance = calculateAbilityDisplayValues(commonEnchantment + uncommonEnchantment + rareEnchantment + epicEnchantment + legendaryEnchantment)[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) {
|
|
|
|
String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability());
|
|
|
|
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) {
|
|
|
|
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
|
|
|
|
}
|
2013-04-09 17:32:07 +02:00
|
|
|
|
|
|
|
// MASTER ANGLER
|
|
|
|
if (canMasterAngler) {
|
2013-05-02 03:57:42 +02:00
|
|
|
double rawBiteChance = ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500));
|
|
|
|
Biome biome = player.getLocation().getBlock().getBiome();
|
|
|
|
|
|
|
|
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
|
|
|
rawBiteChance = rawBiteChance * 2.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
|
|
|
rawBiteChance = rawBiteChance * 2.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
|
2013-04-09 17:32:07 +02:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void permissionsCheck() {
|
|
|
|
canTreasureHunt = Permissions.fishingTreasureHunter(player);
|
|
|
|
canMagicHunt = Permissions.magicHunter(player);
|
|
|
|
canShake = Permissions.shake(player);
|
|
|
|
canFishermansDiet = Permissions.fishermansDiet(player);
|
2013-04-09 17:32:07 +02:00
|
|
|
canMasterAngler = Permissions.masterAngler(player);
|
2013-05-01 16:18:19 +02:00
|
|
|
canIceFish = Permissions.iceFishing(player);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean effectsHeaderPermissions() {
|
2013-05-01 16:18:19 +02:00
|
|
|
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void effectsDisplay() {
|
|
|
|
luckyEffectsDisplay();
|
|
|
|
|
|
|
|
if (canTreasureHunt) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1")));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canMagicHunt) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canIceFish) {
|
|
|
|
player.sendMessage(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) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
|
|
|
}
|
2013-05-01 16:18:19 +02:00
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canShake) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canFishermansDiet) {
|
|
|
|
player.sendMessage(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
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean statsHeaderPermissions() {
|
2013-05-01 16:18:19 +02:00
|
|
|
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void statsDisplay() {
|
|
|
|
if (canTreasureHunt) {
|
2013-10-01 14:57:21 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
|
2013-10-07 15:59:20 +02:00
|
|
|
player.sendMessage(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-07 15:59:20 +02:00
|
|
|
player.sendMessage(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-07 15:59:20 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-10-07 15:59:20 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canMasterAngler) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
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-07 15:59:20 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
|
2013-05-01 16:18:19 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-10-07 15:59:20 +02:00
|
|
|
player.sendMessage(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) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|