Acrobatics to SkillCommand

This commit is contained in:
GJ 2012-05-31 14:01:47 -04:00
parent 1bd9974f89
commit d15e189b7c
3 changed files with 57 additions and 84 deletions

View File

@ -20,17 +20,17 @@ public abstract class SkillCommand implements CommandExecutor{
private String skillString;
private String permission;
private Player player;
protected Player player;
private PlayerProfile profile;
private float skillValue;
protected float skillValue;
private DecimalFormat percent = new DecimalFormat("##0.00%");
private Permissions permInstance = Permissions.getInstance();
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected Permissions permInstance = Permissions.getInstance();
public SkillCommand(SkillType skill, String permission) {
public SkillCommand(SkillType skill) {
this.skill = skill;
this.skillString = Misc.getCapitalized(skill.toString());
this.permission = permission;
this.permission = "mcmmo.skills." + skillString.toLowerCase();
}
@Override
@ -81,5 +81,5 @@ public abstract class SkillCommand implements CommandExecutor{
protected abstract boolean statsHeaderPermissions();
protected abstract boolean statsDisplay();
protected abstract void statsDisplay();
}

View File

@ -1,22 +1,10 @@
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.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class AcrobaticsCommand implements CommandExecutor {
private float skillValue;
public class AcrobaticsCommand extends SkillCommand {
private String dodgeChance;
private String rollChance;
private String gracefulRollChance;
@ -25,67 +13,12 @@ public class AcrobaticsCommand implements CommandExecutor {
private boolean canRoll;
private boolean canGracefulRoll;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.acrobatics")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.ACROBATICS);
dataCalculations(skillValue);
permissionsCheck(player);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Acrobatics.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Acrobatics") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3") }));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
}
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
}
Page.grabGuidePageForSkill(SkillType.ACROBATICS, player, args);
return true;
public AcrobaticsCommand(SkillType skill) {
super(skill);
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
@Override
protected void dataCalculations() {
if (skillValue >= 1000) {
dodgeChance = "20.00%";
rollChance = "100.00%";
@ -108,11 +41,50 @@ public class AcrobaticsCommand implements CommandExecutor {
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
@Override
protected void permissionsCheck() {
canDodge = permInstance.dodge(player);
canRoll = permInstance.roll(player);
canGracefulRoll = permInstance.gracefulRoll(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void effectsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3") }));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void statsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
}
}
}

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.commands.skills.*;
import com.gmail.nossr50.commands.spout.*;
import com.gmail.nossr50.commands.mc.*;
@ -284,7 +285,7 @@ public class mcMMO extends JavaPlugin {
//Register commands
//Skills commands
getCommand("acrobatics").setExecutor(new AcrobaticsCommand());
getCommand("acrobatics").setExecutor(new AcrobaticsCommand(SkillType.ACROBATICS));
getCommand("archery").setExecutor(new ArcheryCommand());
getCommand("axes").setExecutor(new AxesCommand());
getCommand("excavation").setExecutor(new ExcavationCommand());