2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
2013-10-07 15:59:20 +02:00
|
|
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
2019-01-13 08:54:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
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-29 20:38:20 +01:00
|
|
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.util.TextComponentFactory;
|
2013-03-03 16:09:41 +01:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
2019-01-15 12:16:21 +01:00
|
|
|
import com.gmail.nossr50.util.skills.RankUtils;
|
2019-01-15 07:11:58 +01:00
|
|
|
import net.md_5.bungee.api.chat.TextComponent;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
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() {
|
2019-01-13 08:54:53 +01:00
|
|
|
super(PrimarySkillType.FISHING);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
|
2018-12-29 14:24:55 +01:00
|
|
|
// FISHING_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) {
|
2019-01-15 12:16:21 +01:00
|
|
|
canTreasureHunt = canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
|
|
|
|
canMagicHunt = canUseSubskill(player, SubSkillType.FISHING_MAGIC_HUNTER);
|
|
|
|
canShake = canUseSubskill(player, SubSkillType.FISHING_SHAKE);
|
|
|
|
canFishermansDiet = canUseSubskill(player, SubSkillType.FISHING_FISHERMANS_DIET);
|
|
|
|
canMasterAngler = canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER);
|
|
|
|
canIceFish = canUseSubskill(player, SubSkillType.FISHING_ICE_FISHING);
|
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) {
|
2019-01-21 19:43:47 +01:00
|
|
|
messages.add(getStatMessage(false, true, SubSkillType.FISHING_TREASURE_HUNTER, String.valueOf(lootTier), String.valueOf(RankUtils.getHighestRank(SubSkillType.FISHING_TREASURE_HUNTER))));
|
|
|
|
messages.add(getStatMessage(true, true, SubSkillType.FISHING_TREASURE_HUNTER,
|
|
|
|
String.valueOf(trapTreasure),
|
|
|
|
String.valueOf(commonTreasure),
|
|
|
|
String.valueOf(uncommonTreasure),
|
|
|
|
String.valueOf(rareTreasure),
|
|
|
|
String.valueOf(epicTreasure),
|
|
|
|
String.valueOf(legendaryTreasure),
|
|
|
|
String.valueOf(recordTreasure)));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canMagicHunt) {
|
2019-01-21 19:43:47 +01:00
|
|
|
messages.add(getStatMessage(SubSkillType.FISHING_MAGIC_HUNTER, magicChance));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canIceFish) {
|
2019-01-21 19:43:47 +01:00
|
|
|
messages.add(getStatMessage(SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_ICE_FISHING.getLocaleStatDescription()));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (canMasterAngler) {
|
2019-01-21 19:43:47 +01:00
|
|
|
//TODO: Update this with more details
|
|
|
|
messages.add(getStatMessage(SubSkillType.FISHING_MASTER_ANGLER, 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) {
|
2019-01-21 19:43:47 +01:00
|
|
|
messages.add(getStatMessage(SubSkillType.FISHING_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) {
|
2019-01-21 19:43:47 +01:00
|
|
|
messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(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
|
|
|
}
|
2019-01-02 17:06:18 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<TextComponent> getTextComponents(Player player) {
|
|
|
|
List<TextComponent> textComponents = new ArrayList<>();
|
2019-01-04 16:58:39 +01:00
|
|
|
|
2019-01-13 08:54:53 +01:00
|
|
|
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.FISHING);
|
2019-01-04 16:58:39 +01:00
|
|
|
|
2019-01-02 17:06:18 +01:00
|
|
|
return textComponents;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|