2012-05-31 13:50:37 -04:00
|
|
|
package com.gmail.nossr50.commands;
|
|
|
|
|
|
|
|
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.datatypes.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.util.Misc;
|
|
|
|
import com.gmail.nossr50.util.Page;
|
|
|
|
import com.gmail.nossr50.util.Users;
|
|
|
|
|
2012-05-31 14:44:54 -04:00
|
|
|
public abstract class SkillCommand implements CommandExecutor {
|
2012-05-31 13:50:37 -04:00
|
|
|
private SkillType skill;
|
|
|
|
private String skillString;
|
|
|
|
private String permission;
|
|
|
|
|
2012-05-31 14:01:47 -04:00
|
|
|
protected Player player;
|
2012-05-31 14:24:55 -04:00
|
|
|
protected PlayerProfile profile;
|
2012-05-31 14:01:47 -04:00
|
|
|
protected float skillValue;
|
2012-05-31 13:50:37 -04:00
|
|
|
|
2012-05-31 14:01:47 -04:00
|
|
|
protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
2012-05-31 13:50:37 -04:00
|
|
|
|
2012-05-31 14:01:47 -04:00
|
|
|
public SkillCommand(SkillType skill) {
|
2012-05-31 13:50:37 -04:00
|
|
|
this.skill = skill;
|
|
|
|
this.skillString = Misc.getCapitalized(skill.toString());
|
2012-05-31 14:01:47 -04:00
|
|
|
this.permission = "mcmmo.skills." + skillString.toLowerCase();
|
2012-05-31 13:50:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
if (CommandHelper.noConsoleUsage(sender)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CommandHelper.noCommandPermissions(sender, permission)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
player = (Player) sender;
|
|
|
|
profile = Users.getProfile(player);
|
|
|
|
|
2012-10-30 17:59:58 -07:00
|
|
|
if (profile == null) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-05 09:57:10 -04:00
|
|
|
skillValue = profile.getSkillLevel(skill);
|
2012-05-31 13:50:37 -04:00
|
|
|
dataCalculations();
|
|
|
|
permissionsCheck();
|
|
|
|
|
|
|
|
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString(skillString + ".SkillName") }));
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain." + skillString) }));
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill) }));
|
|
|
|
|
|
|
|
if (effectsHeaderPermissions()) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
|
|
|
}
|
|
|
|
|
|
|
|
effectsDisplay();
|
|
|
|
|
|
|
|
if (statsHeaderPermissions()) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
|
|
|
}
|
|
|
|
|
|
|
|
statsDisplay();
|
|
|
|
|
|
|
|
Page.grabGuidePageForSkill(skill, player, args);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract void dataCalculations();
|
|
|
|
|
|
|
|
protected abstract void permissionsCheck();
|
|
|
|
|
|
|
|
protected abstract boolean effectsHeaderPermissions();
|
|
|
|
|
|
|
|
protected abstract void effectsDisplay();
|
|
|
|
|
|
|
|
protected abstract boolean statsHeaderPermissions();
|
|
|
|
|
2012-05-31 14:01:47 -04:00
|
|
|
protected abstract void statsDisplay();
|
2012-05-31 13:50:37 -04:00
|
|
|
}
|