Archery to SkillCommand

This commit is contained in:
GJ 2012-05-31 14:08:17 -04:00
parent 5b3b9fbc30
commit 066c9d9fec

View File

@ -1,22 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat; import com.gmail.nossr50.commands.SkillCommand;
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.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ArcheryCommand implements CommandExecutor { public class ArcheryCommand extends SkillCommand {
private float skillValue;
private String skillShotBonus; private String skillShotBonus;
private String dazeChance; private String dazeChance;
private String retrieveChance; private String retrieveChance;
@ -25,67 +13,12 @@ public class ArcheryCommand implements CommandExecutor {
private boolean canDaze; private boolean canDaze;
private boolean canRetrieve; private boolean canRetrieve;
@Override public ArcheryCommand() {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { super(SkillType.ARCHERY);
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.archery")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.ARCHERY);
dataCalculations(skillValue);
permissionsCheck(player);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Archery.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Archery") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
if (canSkillShot || canDaze || canRetrieve) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
}
if (canSkillShot || canDaze || canRetrieve) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
}
Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args);
return true;
} }
private void dataCalculations(float skillValue) { @Override
DecimalFormat percent = new DecimalFormat("##0.00%"); protected void dataCalculations() {
if (skillValue >= 1000) { if (skillValue >= 1000) {
skillShotBonus = "200.00%"; skillShotBonus = "200.00%";
dazeChance = "50.00%"; dazeChance = "50.00%";
@ -98,11 +31,50 @@ public class ArcheryCommand implements CommandExecutor {
} }
} }
private void permissionsCheck(Player player) { @Override
Permissions permInstance = Permissions.getInstance(); protected void permissionsCheck() {
canSkillShot = permInstance.archeryBonus(player); canSkillShot = permInstance.archeryBonus(player);
canDaze = permInstance.daze(player); canDaze = permInstance.daze(player);
canRetrieve = permInstance.trackArrows(player); canRetrieve = permInstance.trackArrows(player);
} }
@Override
protected boolean effectsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void effectsDisplay() {
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void statsDisplay() {
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
}
}
} }