mcMMO/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedCommand.java

147 lines
5.8 KiB
Java
Raw Normal View History

package com.gmail.nossr50.skills.unarmed;
2012-01-09 20:00:13 +01:00
2012-04-27 11:47:11 +02:00
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
2013-01-07 02:52:31 +01:00
import com.gmail.nossr50.util.Permissions;
2012-01-09 20:00:13 +01:00
2012-05-31 21:10:58 +02:00
public class UnarmedCommand extends SkillCommand {
private String berserkLength;
private String berserkLengthEndurance;
private String deflectChance;
private String deflectChanceLucky;
private String disarmChance;
private String disarmChanceLucky;
2013-01-22 17:18:12 +01:00
private String ironGripChance;
private String ironGripChanceLucky;
private String ironArmBonus;
2012-01-09 20:00:13 +01:00
private boolean canBerserk;
private boolean canDisarm;
private boolean canBonusDamage;
private boolean canDeflect;
2013-01-22 17:18:12 +01:00
private boolean canIronGrip;
2012-05-31 21:10:58 +02:00
public UnarmedCommand() {
super(SkillType.UNARMED);
}
@Override
2012-05-31 21:10:58 +02:00
protected void dataCalculations() {
2013-01-22 17:18:12 +01:00
//BERSERK
String[] berserkStrings = calculateLengthDisplayValues();
berserkLength = berserkStrings[0];
berserkLengthEndurance = berserkStrings[1];
//DISARM
String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance);
disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1];
//DEFLECT
String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance);
deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1];
//IRON ARM
if (skillValue >= ((Unarmed.ironArmMaxBonusDamage - 3) * Unarmed.ironArmIncreaseLevel)) {
ironArmBonus = String.valueOf(Unarmed.ironArmMaxBonusDamage);
}
2013-01-22 17:18:12 +01:00
else {
ironArmBonus = String.valueOf(3 + (skillValue / Unarmed.ironArmIncreaseLevel));
}
2013-01-22 17:18:12 +01:00
//IRON GRIP
String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance);
ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1];
2012-11-21 21:49:54 +01:00
}
2012-01-09 20:00:13 +01:00
2012-05-31 21:10:58 +02:00
@Override
protected void permissionsCheck() {
2013-01-07 02:52:31 +01:00
canBerserk = Permissions.berserk(player);
canBonusDamage = Permissions.unarmedBonus(player);
canDeflect = Permissions.deflect(player);
canDisarm = Permissions.disarm(player);
2013-01-22 17:18:12 +01:00
canIronGrip = Permissions.ironGrip(player);
2012-05-31 21:10:58 +02:00
}
2012-01-09 20:00:13 +01:00
2012-05-31 21:10:58 +02:00
@Override
protected boolean effectsHeaderPermissions() {
2013-01-22 17:18:12 +01:00
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
2012-05-31 21:10:58 +02:00
}
2012-05-31 21:10:58 +02:00
@Override
protected void effectsDisplay() {
2013-01-22 17:18:12 +01:00
luckyEffectsDisplay();
2012-11-22 22:40:55 +01:00
if (canBerserk) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1")));
}
if (canDisarm) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3")));
}
if (canBonusDamage) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5")));
}
if (canDeflect) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7")));
}
2013-01-22 17:18:12 +01:00
if (canIronGrip) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9")));
2013-01-22 17:18:12 +01:00
}
2012-05-31 21:10:58 +02:00
}
2012-05-31 21:10:58 +02:00
@Override
protected boolean statsHeaderPermissions() {
2013-01-22 17:18:12 +01:00
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
2012-05-31 21:10:58 +02:00
}
2012-05-31 21:10:58 +02:00
@Override
protected void statsDisplay() {
if (canBonusDamage) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
}
if (canDeflect) {
2013-01-22 17:18:12 +01:00
if (isLucky) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky));
2013-01-22 17:18:12 +01:00
}
else {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance));
2013-01-22 17:18:12 +01:00
}
}
if (canDisarm) {
2013-01-22 17:18:12 +01:00
if (isLucky) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky));
2013-01-22 17:18:12 +01:00
}
else {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance));
2013-01-22 17:18:12 +01:00
}
}
if (canIronGrip) {
if (isLucky) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky));
2013-01-22 17:18:12 +01:00
}
else {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance));
2013-01-22 17:18:12 +01:00
}
}
2012-01-09 20:00:13 +01:00
if (canBerserk) {
2013-01-22 17:18:12 +01:00
if (hasEndurance) {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance));
2013-01-22 17:18:12 +01:00
}
else {
2013-02-02 08:55:49 +01:00
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength));
2013-01-22 17:18:12 +01:00
}
}
}
2012-01-09 20:00:13 +01:00
}