Excavation to SkillCommand

This commit is contained in:
GJ 2012-05-31 14:18:03 -04:00
parent 806d116501
commit cc5d438550

View File

@ -1,50 +1,37 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command; import com.gmail.nossr50.commands.SkillCommand;
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 ExcavationCommand implements CommandExecutor { public class ExcavationCommand extends SkillCommand {
private float skillValue;
private String gigaDrillBreakerLength; private String gigaDrillBreakerLength;
private boolean canGigaDrill; private boolean canGigaDrill;
private boolean canTreasureHunt; private boolean canTreasureHunt;
public ExcavationCommand() {
super(SkillType.EXCAVATION);
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { protected void dataCalculations() {
if (CommandHelper.noConsoleUsage(sender)) { gigaDrillBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
return true; }
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.excavation")) { @Override
return true; protected void permissionsCheck() {
} canGigaDrill = permInstance.gigaDrillBreaker(player);
canTreasureHunt = permInstance.excavationTreasures(player);
}
Player player = (Player) sender; @Override
PlayerProfile PP = Users.getProfile(player); protected boolean effectsHeaderPermissions() {
return canGigaDrill || canTreasureHunt;
skillValue = (float) PP.getSkillLevel(SkillType.EXCAVATION); }
dataCalculations(skillValue);
permissionsCheck(player);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Excavation.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Excavation") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
if (canGigaDrill || canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
@Override
protected void effectsDisplay() {
if (canGigaDrill) { if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") })); player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") }));
} }
@ -52,25 +39,17 @@ public class ExcavationCommand implements CommandExecutor {
if (canTreasureHunt) { if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") })); player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
} }
}
@Override
protected boolean statsHeaderPermissions() {
return canGigaDrill;
}
@Override
protected void statsDisplay() {
if (canGigaDrill) { if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength })); player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
} }
Page.grabGuidePageForSkill(SkillType.EXCAVATION, player, args);
return true;
}
private void dataCalculations(float skillValue) {
gigaDrillBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canGigaDrill = permInstance.gigaDrillBreaker(player);
canTreasureHunt = permInstance.excavationTreasures(player);
} }
} }