mcMMO/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java

124 lines
4.5 KiB
Java
Raw Normal View History

2012-01-09 20:00:13 +01:00
package com.gmail.nossr50.commands.skills;
2012-11-22 22:40:55 +01:00
import org.bukkit.ChatColor;
2012-05-31 20:24:55 +02:00
import com.gmail.nossr50.commands.SkillCommand;
2012-11-21 21:49:54 +01:00
import com.gmail.nossr50.config.AdvancedConfig;
2012-01-09 20:00:13 +01:00
import com.gmail.nossr50.datatypes.SkillType;
2012-04-27 11:47:11 +02:00
import com.gmail.nossr50.locale.LocaleLoader;
2012-05-01 19:58:47 +02:00
import com.gmail.nossr50.skills.gathering.Fishing;
2012-01-09 20:00:13 +01:00
2012-05-31 20:24:55 +02:00
public class FishingCommand extends SkillCommand {
2012-11-21 21:49:54 +01:00
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
2012-12-24 22:56:25 +01:00
private int lootTier;
private String magicChance;
2012-11-21 21:49:54 +01:00
private int shakeUnlockLevel;
private String shakeChance;
private String fishermansDietRank;
private boolean canTreasureHunt;
private boolean canMagicHunt;
private boolean canShake;
private boolean canFishermansDiet;
2012-05-31 20:24:55 +02:00
public FishingCommand() {
super(SkillType.FISHING);
}
2012-04-24 15:21:21 +02:00
2012-05-31 20:24:55 +02:00
@Override
protected void dataCalculations() {
lootTier = Fishing.getFishingLootTier(profile);
2012-12-24 22:56:25 +01:00
magicChance = percent.format(lootTier / 15D);
2012-11-13 23:27:58 +01:00
int dropChance = Fishing.getShakeChance(lootTier);
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
2012-12-24 22:56:25 +01:00
dropChance = (int) (dropChance * 1.25D);
2012-11-13 23:27:58 +01:00
}
shakeChance = String.valueOf(dropChance);
if (skillValue >= 1000) {
fishermansDietRank = "5";
}
else if (skillValue >= 800) {
fishermansDietRank = "4";
}
else if (skillValue >= 600) {
fishermansDietRank = "3";
}
else if (skillValue >= 400) {
fishermansDietRank = "2";
}
else {
fishermansDietRank = "1";
2012-11-21 22:47:17 +01:00
}
shakeUnlockLevel = advancedConfig.getShakeUnlockLevel();
2012-05-31 20:24:55 +02:00
}
2012-05-31 20:24:55 +02:00
@Override
protected void permissionsCheck() {
canTreasureHunt = permInstance.fishingTreasures(player);
canMagicHunt = permInstance.fishingMagic(player);
canShake = permInstance.shakeMob(player);
canFishermansDiet = permInstance.fishermansDiet(player);
2012-05-31 20:24:55 +02:00
}
2012-01-09 20:00:13 +01:00
2012-05-31 20:24:55 +02:00
@Override
protected boolean effectsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
2012-01-09 20:00:13 +01:00
2012-05-31 20:24:55 +02:00
@Override
protected void effectsDisplay() {
2012-11-22 22:40:55 +01:00
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Fishing" }) }));
}
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
}
2012-01-09 20:00:13 +01:00
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
2012-04-24 15:21:21 +02:00
}
if (canShake) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
}
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7") }));
}
2012-05-31 20:24:55 +02:00
}
2012-05-31 20:24:55 +02:00
@Override
protected boolean statsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
2012-05-31 20:24:55 +02:00
@Override
protected void statsDisplay() {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { lootTier }));
}
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance }));
}
if (canShake) {
2012-11-21 21:49:54 +01:00
if (skillValue < advancedConfig.getShakeUnlockLevel()) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0", new Object[] { shakeUnlockLevel }) }));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", new Object[] { shakeChance }));
}
2012-04-24 15:21:21 +02:00
}
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", new Object[] { fishermansDietRank }));
}
}
2012-01-09 20:00:13 +01:00
}