mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-30 19:41:24 +01:00
Fishing to SkillCommand
This commit is contained in:
parent
cc5d438550
commit
ec02422226
@ -21,7 +21,7 @@ public abstract class SkillCommand implements CommandExecutor{
|
||||
private String permission;
|
||||
|
||||
protected Player player;
|
||||
private PlayerProfile profile;
|
||||
protected PlayerProfile profile;
|
||||
protected float skillValue;
|
||||
|
||||
protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
@ -1,22 +1,11 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class FishingCommand implements CommandExecutor {
|
||||
public class FishingCommand extends SkillCommand {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
|
||||
@ -24,31 +13,30 @@ public class FishingCommand implements CommandExecutor {
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
|
||||
public FishingCommand() {
|
||||
super(SkillType.FISHING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
protected void dataCalculations() {
|
||||
lootTier = Fishing.getFishingLootTier(profile);
|
||||
magicChance = percent.format((float) lootTier / 15);
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.fishing")) {
|
||||
return true;
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreasureHunt = permInstance.fishingTreasures(player);
|
||||
canMagicHunt = permInstance.fishingMagic(player);
|
||||
canShake = permInstance.shakeMob(player);
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
lootTier = Fishing.getFishingLootTier(PP);
|
||||
dataCalculations(lootTier);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Fishing.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Fishing") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
|
||||
|
||||
if (canTreasureHunt || canMagicHunt || canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
|
||||
}
|
||||
@ -60,11 +48,15 @@ public class FishingCommand implements CommandExecutor {
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canTreasureHunt || canMagicHunt || canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { lootTier }));
|
||||
}
|
||||
@ -75,30 +67,12 @@ public class FishingCommand implements CommandExecutor {
|
||||
|
||||
if (canShake) {
|
||||
//TODO: Do we really need to display this twice? Not like there are any associated stats.
|
||||
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
|
||||
if (profile.getSkillLevel(SkillType.FISHING) < 150) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
|
||||
}
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.FISHING, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dataCalculations(int lootTier) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
magicChance = percent.format((float) lootTier / 15);
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canTreasureHunt = permInstance.fishingTreasures(player);
|
||||
canMagicHunt = permInstance.fishingMagic(player);
|
||||
canShake = permInstance.shakeMob(player);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user