Cleanup of UnarmedCommand.java

This commit is contained in:
GJ 2013-01-22 11:18:12 -05:00
parent e048a6d0d0
commit 74c32c4e59
11 changed files with 92 additions and 92 deletions

View File

@ -10,6 +10,7 @@ Key:
Version 1.4.00-dev
+ Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed.
+ Added config options for Hylian Luck skill
+ Added display values to Unarmed command for Iron Grip
= Fixed bug where Impact was applied incorrectly due to an inverted method call
= Fixed bug where Impact improperly determined the defender's armor
= Fixed ArrayIndexOutOfBoundsException resulting from being unranked in a skill when using FlatFile

View File

@ -1,36 +1,27 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.unarmed.Unarmed;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
public class UnarmedCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String berserkLength;
private String berserkLengthEndurance;
private String deflectChance;
private String deflectChanceLucky;
private String disarmChance;
private String disarmChanceLucky;
private String ironGripChance;
private String ironGripChanceLucky;
private String ironArmBonus;
private float disarmChanceMax = advancedConfig.getDisarmChanceMax();
private float disarmMaxLevel = advancedConfig.getDisarmMaxBonusLevel();
private float deflectChanceMax = advancedConfig.getDeflectChanceMax();
private float deflectMaxLevel = advancedConfig.getDeflectMaxBonusLevel();
private float ironArmMaxBonus = advancedConfig.getIronArmBonus();
private int ironArmIncreaseLevel = advancedConfig.getIronArmIncreaseLevel();
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private boolean canBerserk;
private boolean canDisarm;
private boolean canBonusDamage;
private boolean canDeflect;
private boolean lucky;
private boolean endurance;
private boolean canIronGrip;
public UnarmedCommand() {
super(SkillType.UNARMED);
@ -38,44 +29,33 @@ public class UnarmedCommand extends SkillCommand {
@Override
protected void dataCalculations() {
float disarmChanceF;
float deflectChanceF;
//Berserk
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
berserkLength = String.valueOf(length);
//BERSERK
String[] berserkStrings = calculateLengthDisplayValues();
berserkLength = berserkStrings[0];
berserkLengthEndurance = berserkStrings[1];
if (Permissions.activationTwelve(player)) {
length = length + 12;
}
else if (Permissions.activationEight(player)) {
length = length + 8;
}
else if (Permissions.activationFour(player)) {
length = length + 4;
}
int maxLength = SkillType.UNARMED.getAbility().getMaxTicks();
if (maxLength != 0 && length > maxLength) {
length = maxLength;
}
berserkLengthEndurance = String.valueOf(length);
//DISARM
String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance);
disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1];
//Disarm
if (skillValue >= disarmMaxLevel) disarmChanceF = disarmChanceMax;
else disarmChanceF = (float) (((double) disarmChanceMax / (double) disarmMaxLevel) * skillValue);
disarmChance = percent.format(disarmChanceF / 100D);
if (disarmChanceF * 1.3333D >= 100D) disarmChanceLucky = percent.format(1D);
else disarmChanceLucky = percent.format(disarmChanceF * 1.3333D / 100D);
//DEFLECT
String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance);
deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1];
//Deflect
if (skillValue >= deflectMaxLevel) deflectChanceF = deflectChanceMax;
else deflectChanceF = (float) (((double) deflectChanceMax / (double) deflectMaxLevel) * skillValue);
deflectChance = percent.format(deflectChanceF / 100D);
if (deflectChanceF * 1.3333D >= 100D) deflectChanceLucky = percent.format(1D);
else deflectChanceLucky = percent.format(deflectChanceF * 1.3333D / 100D);
//IRON ARM
if (skillValue >= ((Unarmed.ironArmMaxBonusDamage - 3) * Unarmed.ironArmIncreaseLevel)) {
ironArmBonus = String.valueOf(Unarmed.ironArmMaxBonusDamage);
}
else {
ironArmBonus = String.valueOf(3 + (skillValue / Unarmed.ironArmIncreaseLevel));
}
//Iron Arm
if (skillValue >= 250) ironArmBonus = String.valueOf(ironArmMaxBonus);
else ironArmBonus = String.valueOf(3 + ((double) skillValue / (double) ironArmIncreaseLevel));
//IRON GRIP
String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance);
ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1];
}
@Override
@ -84,21 +64,17 @@ public class UnarmedCommand extends SkillCommand {
canBonusDamage = Permissions.unarmedBonus(player);
canDeflect = Permissions.deflect(player);
canDisarm = Permissions.disarm(player);
lucky = Permissions.luckyUnarmed(player);
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
canIronGrip = Permissions.ironGrip(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm;
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.UNARMED) }) }));
}
luckyEffectsDisplay();
if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
@ -115,11 +91,15 @@ public class UnarmedCommand extends SkillCommand {
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
}
if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm;
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
}
@Override
@ -129,24 +109,39 @@ public class UnarmedCommand extends SkillCommand {
}
if (canDeflect) {
if (lucky)
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { deflectChanceLucky }));
else
}
else {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
}
}
if (canDisarm) {
if (lucky)
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { disarmChanceLucky }));
else
}
else {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
}
}
if (canIronGrip) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", new Object[] { ironGripChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { ironGripChanceLucky }));
}
else {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", new Object[] { ironGripChance }));
}
}
if (canBerserk) {
if (endurance)
if (hasEndurance) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { berserkLengthEndurance }));
else
}
else {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
}
}
}
}

View File

@ -169,13 +169,16 @@ public class AdvancedConfig extends ConfigLoader {
public int getSharpenedClawsBonus() { return config.getInt("Skills.Taming.SharpenedClaws_Bonus", 2); }
/* UNARMED */
public int getDisarmChanceMax() { return config.getInt("Skills.Unarmed.Disarm_ChanceMax", 33); }
public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm_ChanceMax", 33.0D); }
public int getDisarmMaxBonusLevel() { return config.getInt("Skills.Unarmed.Disarm_MaxBonusLevel", 1000); }
public int getDeflectChanceMax() { return config.getInt("Skills.Unarmed.Deflect_ChanceMax", 50); }
public double getDeflectChanceMax() { return config.getDouble("Skills.Unarmed.Deflect_ChanceMax", 50.0D); }
public int getDeflectMaxBonusLevel() { return config.getInt("Skills.Unarmed.Deflect_MaxBonusLevel", 1000); }
public int getIronGripChanceMax() { return config.getInt("Skills.Unarmed.IronGrip_ChanceMax", 100); }
public double getIronGripChanceMax() { return config.getDouble("Skills.Unarmed.IronGrip_ChanceMax", 100.0D); }
public int getIronGripMaxBonusLevel() { return config.getInt("Skills.Unarmed.IronGrip_MaxBonusLevel", 1000); }
public int getIronArmBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
public int getIronArmMaxBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm_IncreaseLevel", 50); }
/* WOODCUTTING */

View File

@ -18,7 +18,7 @@ public class DeflectEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Unarmed.DEFLECT_MAX_BONUS_LEVEL);
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Unarmed.deflectMaxBonusLevel);
}
protected void sendAbilityMessage() {

View File

@ -26,7 +26,7 @@ public class DisarmEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Unarmed.DISARM_MAX_BONUS_LEVEL);
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Unarmed.disarmMaxBonusLevel);
}
private void sendAbilityMessage() {

View File

@ -20,7 +20,7 @@ public class IronGripEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(Users.getProfile(defender).getSkillLevel(SkillType.UNARMED), Unarmed.IRON_GRIP_MAX_BONUS_LEVEL);
this.skillModifier = Misc.skillCheck(Users.getProfile(defender).getSkillLevel(SkillType.UNARMED), Unarmed.ironGripMaxBonusLevel);
}
protected void sendAbilityMessages() {

View File

@ -3,17 +3,15 @@ package com.gmail.nossr50.skills.unarmed;
import com.gmail.nossr50.config.AdvancedConfig;
public class Unarmed {
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus();
public static int ironArmIncreaseLevel = AdvancedConfig.getInstance().getIronArmIncreaseLevel();
public static final int BONUS_DAMAGE_MAX_BONUS_MODIFIER = advancedConfig.getIronArmBonus();
public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getIronArmIncreaseLevel();
public static double deflectMaxChance = AdvancedConfig.getInstance().getDisarmChanceMax() ;
public static int deflectMaxBonusLevel = AdvancedConfig.getInstance().getDisarmMaxBonusLevel();
public static final int DEFLECT_MAX_CHANCE = advancedConfig.getDisarmChanceMax() ;
public static final int DEFLECT_MAX_BONUS_LEVEL = advancedConfig.getDisarmMaxBonusLevel();
public static double disarmMaxChance = AdvancedConfig.getInstance().getDeflectChanceMax();
public static int disarmMaxBonusLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel();
public static final int DISARM_MAX_CHANCE = advancedConfig.getDeflectChanceMax();
public static final int DISARM_MAX_BONUS_LEVEL = advancedConfig.getDeflectMaxBonusLevel();
public static final int IRON_GRIP_MAX_CHANCE = advancedConfig.getIronGripChanceMax();
public static final int IRON_GRIP_MAX_BONUS_LEVEL = advancedConfig.getIronGripMaxBonusLevel();
public static double ironGripMaxChance = AdvancedConfig.getInstance().getIronGripChanceMax();
public static int ironGripMaxBonusLevel = AdvancedConfig.getInstance().getIronGripMaxBonusLevel();
}

View File

@ -14,10 +14,10 @@ public class UnarmedBonusDamageEventHandler {
}
protected void calculateDamageBonus() {
int damageBonus = 3 + (manager.getSkillLevel() / Unarmed.BONUS_DAMAGE_INCREASE_LEVEL);
int damageBonus = 3 + (manager.getSkillLevel() / Unarmed.ironArmIncreaseLevel);
if (damageBonus > Unarmed.BONUS_DAMAGE_MAX_BONUS_MODIFIER) {
damageBonus = Unarmed.BONUS_DAMAGE_MAX_BONUS_MODIFIER;
if (damageBonus > Unarmed.ironArmBonusDamage) {
damageBonus = Unarmed.ironArmBonusDamage;
}
this.damageBonus = damageBonus;

View File

@ -28,8 +28,8 @@ public class UnarmedManager extends SkillManager {
if (eventHandler.isHoldingItem()) {
eventHandler.calculateSkillModifier();
float chance = (float) (((double) Unarmed.DISARM_MAX_CHANCE / (double) Unarmed.DISARM_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Unarmed.DISARM_MAX_CHANCE) chance = Unarmed.DISARM_MAX_CHANCE;
float chance = (float) ((Unarmed.disarmMaxChance / Unarmed.disarmMaxBonusLevel) * skillLevel);
if (chance > Unarmed.disarmMaxChance) chance = (float) Unarmed.disarmMaxChance;
if (chance > Misc.getRandom().nextInt(activationChance)) {
if (!hasIronGrip(defender)) {
@ -55,8 +55,8 @@ public class UnarmedManager extends SkillManager {
DeflectEventHandler eventHandler = new DeflectEventHandler(this, event);
float chance = (float) (((double) Unarmed.DEFLECT_MAX_CHANCE / (double) Unarmed.DEFLECT_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Unarmed.DEFLECT_MAX_CHANCE) chance = Unarmed.DEFLECT_MAX_CHANCE;
float chance = (float) ((Unarmed.deflectMaxChance / Unarmed.deflectMaxBonusLevel) * skillLevel);
if (chance > Unarmed.deflectMaxChance) chance = (float) Unarmed.deflectMaxChance;
if (chance > Misc.getRandom().nextInt(activationChance)) {
eventHandler.cancelEvent();
@ -99,8 +99,8 @@ public class UnarmedManager extends SkillManager {
IronGripEventHandler eventHandler = new IronGripEventHandler(this, defender);
float chance = (float) (((double) Unarmed.IRON_GRIP_MAX_CHANCE / (double) Unarmed.IRON_GRIP_MAX_BONUS_LEVEL) * skillLevel);
if (chance > Unarmed.IRON_GRIP_MAX_CHANCE) chance = Unarmed.IRON_GRIP_MAX_CHANCE;
float chance = (float) ((Unarmed.ironGripMaxChance / Unarmed.ironGripMaxBonusLevel) * skillLevel);
if (chance > Unarmed.ironGripMaxChance) chance = (float) Unarmed.ironGripMaxChance;
if (chance > Misc.getRandom().nextInt(activationChance)) {
eventHandler.sendAbilityMessages();

View File

@ -224,7 +224,7 @@ Skills:
Taming:
# Gore_ChanceMax: Maximum chance of triggering gore
# Gore_MaxBonusLevel: On this level, the chance to cause Gore will be Gore_ChanceMax
Gore_ChanceMax: 100
Gore_ChanceMax: 100.0
Gore_MaxBonusLevel: 1000
# Gore_BleedTicks: Determines the length of the bleeding effect
@ -235,7 +235,7 @@ Skills:
# FastFood_UnlockLevel: Level when FastFood unlocks
# FastFood_Chance: The chance for wolves to heal hp when inflicting damage
FastFood_UnlockLevel: 50
FastFood_Chance: 50
FastFood_Chance: 50.0
# EnvironmentallyAware_UnlockLevel: Level when EnvironmentallyAware unlocks
EnvironmentallyAware_UnlockLevel: 100
@ -260,17 +260,17 @@ Skills:
Unarmed:
# Disarm_ChanceMax: Maximum chance of disarming other players
# Disarm_MaxBonusLevel: Level when the maximum chance to disarm is reached
Disarm_ChanceMax: 33
Disarm_ChanceMax: 33.0
Disarm_MaxBonusLevel: 1000
# Deflect_ChanceMax: Maximum chance of deflecting arrows
# Deflect_MaxBonusLevel: Level when the maximum chance to deflect is reached
Deflect_ChanceMax: 50
Deflect_ChanceMax: 50.0
Deflect_MaxBonusLevel: 1000
# IronGrip_ChanceMax: Maximum chance of preventing being disarmed
# IronGrip_MaxBonusLevel: Level when the maximum chance to prevent being disarmed is reached
IronGrip_ChanceMax: 100
IronGrip_ChanceMax: 100.0
IronGrip_MaxBonusLevel: 1000
# IronArmBonusMax: Maximum bonus damage for unarmed

View File

@ -327,6 +327,7 @@ Unarmed.Ability.Bonus.0=Iron Arm Style
Unarmed.Ability.Bonus.1=+{0} DMG Upgrade
Unarmed.Ability.Chance.ArrowDeflect=[[RED]]Arrow Deflect Chance: [[YELLOW]]{0}
Unarmed.Ability.Chance.Disarm=[[RED]]Disarm Chance: [[YELLOW]]{0}
Unarmed.Ability.Chance.IronGrip=[[RED]]Iron Grip Chance: [[YELLOW]{0}
Unarmed.Ability.IronGrip.Attacker=[[RED]]Your opponent has an iron grip!
Unarmed.Ability.IronGrip.Defender=[[GREEN]]Your iron grip kept you from being disarmed!
Unarmed.Ability.Lower=[[GRAY]]**YOU LOWER YOUR FISTS**
@ -339,6 +340,8 @@ Unarmed.Effect.4=Iron Arm Style
Unarmed.Effect.5=Hardens your arm over time
Unarmed.Effect.6=Arrow Deflect
Unarmed.Effect.7=Deflect arrows
Unarmed.Effect.8=Iron Grip
Unarmed.Effect.9=Prevents you from being disarmed
Unarmed.Listener=Unarmed:
Unarmed.SkillName=UNARMED
Unarmed.Skills.Berserk.Off=[[RED]]**Berserk has worn off**