Dealing with type conversion issues in the skill commands.

This commit is contained in:
Glitchfinder 2012-11-25 16:18:30 -08:00
parent b1cf9d139a
commit 082fa2ca0d
13 changed files with 232 additions and 232 deletions

View File

@ -10,90 +10,90 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class AcrobaticsCommand extends SkillCommand { public class AcrobaticsCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String dodgeChance; private String dodgeChance;
private String rollChance; private String rollChance;
private String gracefulRollChance; private String gracefulRollChance;
private float dodgeChanceMax = advancedConfig.getDodgeChanceMax(); private float dodgeChanceMax = advancedConfig.getDodgeChanceMax();
private float dodgeMaxBonusLevel = advancedConfig.getDodgeMaxBonusLevel(); private float dodgeMaxBonusLevel = advancedConfig.getDodgeMaxBonusLevel();
private float rollChanceMax = advancedConfig.getRollChanceMax(); private float rollChanceMax = advancedConfig.getRollChanceMax();
private float rollMaxBonusLevel = advancedConfig.getRollMaxBonusLevel(); private float rollMaxBonusLevel = advancedConfig.getRollMaxBonusLevel();
private float gracefulRollChanceMax = advancedConfig.getGracefulRollChanceMax(); private float gracefulRollChanceMax = advancedConfig.getGracefulRollChanceMax();
private float gracefulRollMaxBonusLevel = advancedConfig.getGracefulRollMaxBonusLevel(); private float gracefulRollMaxBonusLevel = advancedConfig.getGracefulRollMaxBonusLevel();
private boolean canDodge; private boolean canDodge;
private boolean canRoll; private boolean canRoll;
private boolean canGracefulRoll; private boolean canGracefulRoll;
public AcrobaticsCommand() { public AcrobaticsCommand() {
super(SkillType.ACROBATICS); super(SkillType.ACROBATICS);
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.0");
// DODGE // DODGE
if(skillValue >= dodgeMaxBonusLevel) dodgeChance = df.format(dodgeChanceMax); if(skillValue >= dodgeMaxBonusLevel) dodgeChance = df.format(dodgeChanceMax);
else dodgeChance = df.format((dodgeChanceMax / dodgeMaxBonusLevel) * skillValue); else dodgeChance = df.format(((double) dodgeChanceMax / (double) dodgeMaxBonusLevel) * (double) skillValue);
// ROLL // ROLL
if(skillValue >= rollMaxBonusLevel) rollChance = df.format(rollChanceMax); if(skillValue >= rollMaxBonusLevel) rollChance = df.format(rollChanceMax);
else rollChance = df.format((rollChanceMax / rollMaxBonusLevel) * skillValue); else rollChance = df.format(((double) rollChanceMax / (double) rollMaxBonusLevel) * (double) skillValue);
// GRACEFULROLL // GRACEFULROLL
if(skillValue >= gracefulRollMaxBonusLevel) gracefulRollChance = df.format(gracefulRollChanceMax); if(skillValue >= gracefulRollMaxBonusLevel) gracefulRollChance = df.format(gracefulRollChanceMax);
else gracefulRollChance = df.format((gracefulRollChanceMax / gracefulRollMaxBonusLevel) * skillValue); else gracefulRollChance = df.format(((double) gracefulRollChanceMax / (double) gracefulRollMaxBonusLevel) * (double) skillValue);
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck() {
canDodge = permInstance.dodge(player); canDodge = permInstance.dodge(player);
canRoll = permInstance.roll(player); canRoll = permInstance.roll(player);
canGracefulRoll = permInstance.gracefulRoll(player); canGracefulRoll = permInstance.gracefulRoll(player);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected boolean effectsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll; return canDodge || canGracefulRoll || canRoll;
} }
@Override @Override
protected void effectsDisplay() { protected void effectsDisplay() {
if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) { if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) {
String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Acrobatics" }) })); player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Acrobatics" }) }));
} }
if (canRoll) { if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") })); player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
} }
if (canGracefulRoll) { if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3") })); player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3") }));
} }
if (canDodge) { if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") })); player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
} }
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected boolean statsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll; return canDodge || canGracefulRoll || canRoll;
} }
@Override @Override
protected void statsDisplay() { protected void statsDisplay() {
if (canRoll) { if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance })); player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
} }
if (canGracefulRoll) { if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance })); player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
} }
if (canDodge) { if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance })); player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
} }
} }
} }

View File

@ -10,97 +10,97 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class ArcheryCommand extends SkillCommand { public class ArcheryCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String skillShotBonus; private String skillShotBonus;
private String dazeChance; private String dazeChance;
private String retrieveChance; private String retrieveChance;
private int skillShotIncreaseLevel = advancedConfig.getSkillShotIncreaseLevel(); private int skillShotIncreaseLevel = advancedConfig.getSkillShotIncreaseLevel();
private double skillShotIncreasePercentage = advancedConfig.getSkillShotIncreasePercentage(); private double skillShotIncreasePercentage = advancedConfig.getSkillShotIncreasePercentage();
private double skillShotBonusMax = advancedConfig.getSkillShotBonusMax(); private double skillShotBonusMax = advancedConfig.getSkillShotBonusMax();
private float dazeBonusMax = advancedConfig.getDazeBonusMax(); private float dazeBonusMax = advancedConfig.getDazeBonusMax();
private float dazeMaxBonusLevel = advancedConfig.getDazeMaxBonusLevel(); private float dazeMaxBonusLevel = advancedConfig.getDazeMaxBonusLevel();
private float retrieveBonusMax = advancedConfig.getRetrieveBonusMax(); private float retrieveBonusMax = advancedConfig.getRetrieveBonusMax();
private float retrieveMaxBonusLevel = advancedConfig.getRetrieveMaxBonusLevel(); private float retrieveMaxBonusLevel = advancedConfig.getRetrieveMaxBonusLevel();
private boolean canSkillShot; private boolean canSkillShot;
private boolean canDaze; private boolean canDaze;
private boolean canRetrieve; private boolean canRetrieve;
public ArcheryCommand() { public ArcheryCommand() {
super(SkillType.ARCHERY); super(SkillType.ARCHERY);
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.0");
// SkillShot // SkillShot
double bonus = (int)(skillValue / skillShotIncreaseLevel) * skillShotIncreasePercentage; double bonus = (int)((double) skillValue / (double) skillShotIncreaseLevel) * (double) skillShotIncreasePercentage;
if (bonus > skillShotBonusMax) skillShotBonus = percent.format(skillShotBonusMax); if (bonus > skillShotBonusMax) skillShotBonus = percent.format(skillShotBonusMax);
else skillShotBonus = percent.format(bonus); else skillShotBonus = percent.format(bonus);
// Daze // Daze
if(skillValue >= dazeMaxBonusLevel) dazeChance = df.format(dazeBonusMax); if(skillValue >= dazeMaxBonusLevel) dazeChance = df.format(dazeBonusMax);
else dazeChance = df.format((dazeBonusMax / dazeMaxBonusLevel) * skillValue); else dazeChance = df.format(((double) dazeBonusMax / (double) dazeMaxBonusLevel) * (double) skillValue);
// Retrieve // Retrieve
if(skillValue >= retrieveMaxBonusLevel) retrieveChance = df.format(retrieveBonusMax); if(skillValue >= retrieveMaxBonusLevel) retrieveChance = df.format(retrieveBonusMax);
else retrieveChance = df.format((retrieveBonusMax / retrieveMaxBonusLevel) * skillValue); else retrieveChance = df.format(((double) retrieveBonusMax / (double) retrieveMaxBonusLevel) * (double) skillValue);
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck() {
canSkillShot = permInstance.archeryBonus(player); canSkillShot = permInstance.archeryBonus(player);
canDaze = permInstance.daze(player); canDaze = permInstance.daze(player);
canRetrieve = permInstance.trackArrows(player); canRetrieve = permInstance.trackArrows(player);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected boolean effectsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve; return canSkillShot || canDaze || canRetrieve;
} }
@Override @Override
protected void effectsDisplay() { protected void effectsDisplay() {
if (player.hasPermission("mcmmo.perks.lucky.archery")) { if (player.hasPermission("mcmmo.perks.lucky.archery")) {
String perkPrefix = ChatColor.RED + "[mcMMO Perks] "; String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Archery" }) })); player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Archery" }) }));
} }
if (canSkillShot) { if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") })); player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
} }
if (canDaze) { if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") })); player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
} }
if (canRetrieve) { if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") })); player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
} }
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected boolean statsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve; return canSkillShot || canDaze || canRetrieve;
} }
@Override @Override
protected void statsDisplay() { protected void statsDisplay() {
if (canSkillShot) { if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus })); player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
} }
if (canDaze) { if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance })); player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
} }
if (canRetrieve) { if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance })); player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
} }
} }
} }

View File

@ -11,7 +11,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
public class AxesCommand extends SkillCommand { public class AxesCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String critChance; private String critChance;
private String bonusDamage; private String bonusDamage;
@ -19,13 +19,13 @@ public class AxesCommand extends SkillCommand {
private String greaterImpactDamage; private String greaterImpactDamage;
private String skullSplitterLength; private String skullSplitterLength;
private int bonusDamageAxesBonusMax = advancedConfig.getBonusDamageAxesBonusMax(); private int bonusDamageAxesBonusMax = advancedConfig.getBonusDamageAxesBonusMax();
private int bonusDamageAxesMaxBonusLevel = advancedConfig.getBonusDamageAxesMaxBonusLevel(); private int bonusDamageAxesMaxBonusLevel = advancedConfig.getBonusDamageAxesMaxBonusLevel();
private double critMaxChance = advancedConfig.getAxesCriticalChance(); private double critMaxChance = advancedConfig.getAxesCriticalChance();
private int critMaxBonusLevel = advancedConfig.getAxesCriticalMaxBonusLevel(); private int critMaxBonusLevel = advancedConfig.getAxesCriticalMaxBonusLevel();
private int greaterImpactIncreaseLevel = advancedConfig.getGreaterImpactIncreaseLevel(); private int greaterImpactIncreaseLevel = advancedConfig.getGreaterImpactIncreaseLevel();
// private double greaterImpactModifier = advancedConfig.getGreaterImpactModifier(); // private double greaterImpactModifier = advancedConfig.getGreaterImpactModifier();
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength(); private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private boolean canSkullSplitter; private boolean canSkullSplitter;
private boolean canCritical; private boolean canCritical;
@ -39,17 +39,17 @@ public class AxesCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.0");
int skillCheck = Misc.skillCheck((int)skillValue, critMaxBonusLevel); int skillCheck = Misc.skillCheck((int)skillValue, critMaxBonusLevel);
impactDamage = String.valueOf(1 + ((int) skillValue / greaterImpactIncreaseLevel)); impactDamage = String.valueOf(1 + ((double) skillValue / (double) greaterImpactIncreaseLevel));
skullSplitterLength = String.valueOf(2 + ((int) skillValue / abilityLengthIncreaseLevel)); skullSplitterLength = String.valueOf(2 + ((double) skillValue / (double) abilityLengthIncreaseLevel));
greaterImpactDamage = "2"; greaterImpactDamage = "2";
if (skillValue >= critMaxBonusLevel) critChance = df.format(critMaxChance); if (skillValue >= critMaxBonusLevel) critChance = df.format(critMaxChance);
else critChance = String.valueOf((critMaxChance / critMaxBonusLevel) * (float)skillCheck); else critChance = String.valueOf(((double) critMaxChance / (double) critMaxBonusLevel) * (double) skillCheck);
if (skillValue >= bonusDamageAxesMaxBonusLevel) bonusDamage = String.valueOf(bonusDamageAxesBonusMax); if (skillValue >= bonusDamageAxesMaxBonusLevel) bonusDamage = String.valueOf(bonusDamageAxesBonusMax);
else bonusDamage = String.valueOf((int) skillValue / (bonusDamageAxesMaxBonusLevel / bonusDamageAxesBonusMax)); else bonusDamage = String.valueOf((double) skillValue / ((double) bonusDamageAxesMaxBonusLevel / (double) bonusDamageAxesBonusMax));
} }
@Override @Override

View File

@ -8,7 +8,7 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class ExcavationCommand extends SkillCommand { public class ExcavationCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String gigaDrillBreakerLength; private String gigaDrillBreakerLength;
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength(); private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
@ -22,7 +22,7 @@ public class ExcavationCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
gigaDrillBreakerLength = String.valueOf(2 + ((int) skillValue / abilityLengthIncreaseLevel)); gigaDrillBreakerLength = String.valueOf(2 + ((double) skillValue / (double) abilityLengthIncreaseLevel));
} }
@Override @Override

View File

@ -30,10 +30,10 @@ public class FishingCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
lootTier = Fishing.getFishingLootTier(profile); lootTier = Fishing.getFishingLootTier(profile);
magicChance = percent.format((float) lootTier / 15); magicChance = percent.format((double) lootTier / 15D);
int dropChance = Fishing.getShakeChance(lootTier); int dropChance = Fishing.getShakeChance(lootTier);
if (player.hasPermission("mcmmo.perks.lucky.fishing")) { if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
dropChance = (int) (dropChance * 1.25); dropChance = (int) ((double) dropChance * 1.25D);
} }
shakeChance = String.valueOf(dropChance); shakeChance = String.valueOf(dropChance);

View File

@ -11,7 +11,7 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class HerbalismCommand extends SkillCommand { public class HerbalismCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String greenTerraLength; private String greenTerraLength;
private String greenThumbChance; private String greenThumbChance;
@ -42,21 +42,21 @@ public class HerbalismCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.0");
greenTerraLength = String.valueOf(2 + ((int) skillValue / abilityLengthIncreaseLevel)); greenTerraLength = String.valueOf(2 + ((double) skillValue / (double) abilityLengthIncreaseLevel));
//FARMERS DIET //FARMERS DIET
if(skillValue >= farmersDietMaxLevel) farmersDietRank = "5"; if(skillValue >= farmersDietMaxLevel) farmersDietRank = "5";
else farmersDietRank = String.valueOf((int)skillValue / farmersDietRankChange); else farmersDietRank = String.valueOf((double) skillValue / (double) farmersDietRankChange);
//GREEN THUMB //GREEN THUMB
if(skillValue >= greenThumbStageMaxLevel) greenThumbStage = "4"; if(skillValue >= greenThumbStageMaxLevel) greenThumbStage = "4";
else greenThumbStage = String.valueOf((int)skillValue / greenThumbStageChange); else greenThumbStage = String.valueOf((double) skillValue / (double) greenThumbStageChange);
if(skillValue >= greenThumbMaxLevel) greenThumbChance = String.valueOf(greenThumbMaxBonus); if(skillValue >= greenThumbMaxLevel) greenThumbChance = String.valueOf(greenThumbMaxBonus);
else greenThumbChance = String.valueOf((greenThumbMaxBonus / greenThumbMaxLevel) * skillValue); else greenThumbChance = String.valueOf(((double) greenThumbMaxBonus / (double) greenThumbMaxLevel) * (double) skillValue);
//DOUBLE DROPS //DOUBLE DROPS
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus); if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
else doubleDropChance = df.format((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue); else doubleDropChance = df.format(((double) doubleDropsMaxBonus / (double) doubleDropsMaxLevel) * (double) skillValue);
} }
@Override @Override

View File

@ -12,25 +12,25 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
public class MiningCommand extends SkillCommand { public class MiningCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String doubleDropChance; private String doubleDropChance;
private String superBreakerLength; private String superBreakerLength;
private String blastMiningRank; private String blastMiningRank;
private String blastRadiusIncrease; private String blastRadiusIncrease;
private String blastDamageDecrease; private String blastDamageDecrease;
private int blastMiningRank1 = advancedConfig.getBlastMiningRank1(); private int blastMiningRank1 = advancedConfig.getBlastMiningRank1();
private int blastMiningRank2 = advancedConfig.getBlastMiningRank2(); private int blastMiningRank2 = advancedConfig.getBlastMiningRank2();
private int blastMiningRank3 = advancedConfig.getBlastMiningRank3(); private int blastMiningRank3 = advancedConfig.getBlastMiningRank3();
private int blastMiningRank4 = advancedConfig.getBlastMiningRank4(); private int blastMiningRank4 = advancedConfig.getBlastMiningRank4();
private int blastMiningRank5 = advancedConfig.getBlastMiningRank5(); private int blastMiningRank5 = advancedConfig.getBlastMiningRank5();
private int blastMiningRank6 = advancedConfig.getBlastMiningRank6(); private int blastMiningRank6 = advancedConfig.getBlastMiningRank6();
private int blastMiningRank7 = advancedConfig.getBlastMiningRank7(); private int blastMiningRank7 = advancedConfig.getBlastMiningRank7();
private int blastMiningRank8 = advancedConfig.getBlastMiningRank8(); private int blastMiningRank8 = advancedConfig.getBlastMiningRank8();
private double doubleDropsMaxBonus = advancedConfig.getMiningDoubleDropChance(); private double doubleDropsMaxBonus = advancedConfig.getMiningDoubleDropChance();
private int doubleDropsMaxLevel = advancedConfig.getMiningDoubleDropMaxLevel(); private int doubleDropsMaxLevel = advancedConfig.getMiningDoubleDropMaxLevel();
public int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength(); public int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private boolean canSuperBreaker; private boolean canSuperBreaker;
private boolean canDoubleDrop; private boolean canDoubleDrop;
@ -45,10 +45,10 @@ public class MiningCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.0");
superBreakerLength = String.valueOf(2 + ((int) skillValue / abilityLengthIncreaseLevel)); superBreakerLength = String.valueOf(2 + ((double) skillValue / (double) abilityLengthIncreaseLevel));
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus); if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
else doubleDropChance = df.format((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue); else doubleDropChance = df.format(((double) doubleDropsMaxBonus / (double) doubleDropsMaxLevel) * (double) skillValue);
if (skillValue >= blastMiningRank8) { if (skillValue >= blastMiningRank8) {
blastMiningRank = "8"; blastMiningRank = "8";

View File

@ -64,10 +64,10 @@ public class RepairCommand extends SkillCommand {
salvageLevel = Config.getInstance().getSalvageUnlockLevel(); salvageLevel = Config.getInstance().getSalvageUnlockLevel();
if(skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = df.format(repairMasteryChanceMax); if(skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = df.format(repairMasteryChanceMax);
else repairMasteryBonus = df.format((repairMasteryChanceMax / repairMasteryMaxBonusLevel) * skillValue); else repairMasteryBonus = df.format(((double) repairMasteryChanceMax / (double) repairMasteryMaxBonusLevel) * (double) skillValue);
if(skillValue >= superRepairMaxBonusLevel) superRepairChance = df.format(superRepairChanceMax); if(skillValue >= superRepairMaxBonusLevel) superRepairChance = df.format(superRepairChanceMax);
else superRepairChance = df.format((superRepairChanceMax / superRepairMaxBonusLevel) * skillValue); else superRepairChance = df.format(((double) superRepairChanceMax / (double) superRepairMaxBonusLevel) * (double) skillValue);
arcaneForgingRank = Repair.getArcaneForgingRank(profile); arcaneForgingRank = Repair.getArcaneForgingRank(profile);
} }

View File

@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class SwordsCommand extends SkillCommand { public class SwordsCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String counterAttackChance; private String counterAttackChance;
private String bleedLength; private String bleedLength;
@ -36,19 +36,19 @@ public class SwordsCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.0");
serratedStrikesLength = String.valueOf(2 + ((int) skillValue / abilityLengthIncreaseLevel)); serratedStrikesLength = String.valueOf(2 + ((double) skillValue / (double) abilityLengthIncreaseLevel));
if (skillValue >= bleedMaxLevel) bleedLength = String.valueOf(bleedMaxTicks); if (skillValue >= bleedMaxLevel) bleedLength = String.valueOf(bleedMaxTicks);
else bleedLength = String.valueOf(bleedBaseTicks); else bleedLength = String.valueOf(bleedBaseTicks);
if(skillValue >= bleedMaxLevel) bleedChance = df.format(bleedChanceMax); if(skillValue >= bleedMaxLevel) bleedChance = df.format(bleedChanceMax);
else bleedChance = df.format((bleedChanceMax / bleedMaxLevel) * skillValue); else bleedChance = df.format(((double) bleedChanceMax / (double) bleedMaxLevel) * (double) skillValue);
if(skillValue >= counterMaxLevel) counterAttackChance = df.format(counterChanceMax); if(skillValue >= counterMaxLevel) counterAttackChance = df.format(counterChanceMax);
else counterAttackChance = df.format((counterChanceMax / counterMaxLevel) * skillValue); else counterAttackChance = df.format(((double) counterChanceMax / (double) counterMaxLevel) * (double) skillValue);
serratedStrikesLength = String.valueOf(serratedBleedTicks); serratedStrikesLength = String.valueOf(serratedBleedTicks);
} }
@Override @Override

View File

@ -11,17 +11,17 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class TamingCommand extends SkillCommand { public class TamingCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String goreChance; private String goreChance;
private float goreChanceMax = advancedConfig.getGoreChanceMax(); private float goreChanceMax = advancedConfig.getGoreChanceMax();
private float goreMaxLevel = advancedConfig.getGoreMaxBonusLevel(); private float goreMaxLevel = advancedConfig.getGoreMaxBonusLevel();
private int fastFoodUnlock = advancedConfig.getFastFoodUnlock(); private int fastFoodUnlock = advancedConfig.getFastFoodUnlock();
private float fastFoodChance = advancedConfig.getFastFoodChance(); private float fastFoodChance = advancedConfig.getFastFoodChance();
private int enviromentallyAwareUnlock = advancedConfig.getEnviromentallyAwareUnlock(); private int enviromentallyAwareUnlock = advancedConfig.getEnviromentallyAwareUnlock();
private int thickFurUnlock = advancedConfig.getThickFurUnlock(); private int thickFurUnlock = advancedConfig.getThickFurUnlock();
private int shockProofUnlock = advancedConfig.getShockProofUnlock(); private int shockProofUnlock = advancedConfig.getShockProofUnlock();
private int sharpenedClawUnlock = advancedConfig.getSharpenedClawsUnlock(); private int sharpenedClawUnlock = advancedConfig.getSharpenedClawsUnlock();
private boolean canBeastLore; private boolean canBeastLore;
private boolean canGore; private boolean canGore;
@ -38,9 +38,9 @@ public class TamingCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.0");
if(skillValue >= goreMaxLevel) goreChance = df.format(goreChanceMax); if(skillValue >= goreMaxLevel) goreChance = df.format(goreChanceMax);
else goreChance = df.format((goreChanceMax / goreMaxLevel) * skillValue); else goreChance = df.format(((double) goreChanceMax / (double) goreMaxLevel) * (double) skillValue);
} }
@Override @Override

View File

@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class UnarmedCommand extends SkillCommand { public class UnarmedCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String berserkLength; private String berserkLength;
private String deflectChance; private String deflectChance;
private String disarmChance; private String disarmChance;
@ -22,7 +22,7 @@ public class UnarmedCommand extends SkillCommand {
private float deflectMaxLevel = advancedConfig.getDeflectMaxBonusLevel(); private float deflectMaxLevel = advancedConfig.getDeflectMaxBonusLevel();
private float ironArmMaxBonus = advancedConfig.getIronArmBonus(); private float ironArmMaxBonus = advancedConfig.getIronArmBonus();
private int ironArmIncreaseLevel = advancedConfig.getIronArmIncreaseLevel(); private int ironArmIncreaseLevel = advancedConfig.getIronArmIncreaseLevel();
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength(); private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private boolean canBerserk; private boolean canBerserk;
private boolean canDisarm; private boolean canDisarm;
@ -35,17 +35,17 @@ public class UnarmedCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.0");
berserkLength = String.valueOf(2 + ((int) skillValue / abilityLengthIncreaseLevel)); berserkLength = String.valueOf(2 + ((double) skillValue / (double) abilityLengthIncreaseLevel));
if(skillValue >= disarmMaxLevel) disarmChance = df.format(disarmChanceMax); if(skillValue >= disarmMaxLevel) disarmChance = df.format(disarmChanceMax);
else disarmChance = df.format((disarmChanceMax / disarmMaxLevel) * skillValue); else disarmChance = df.format(((double) disarmChanceMax / (double) disarmMaxLevel) * (double) skillValue);
if(skillValue >= deflectMaxLevel) deflectChance = df.format(deflectChanceMax); if(skillValue >= deflectMaxLevel) deflectChance = df.format(deflectChanceMax);
else deflectChance = df.format((deflectChanceMax / deflectMaxLevel) * skillValue); else deflectChance = df.format(((double) deflectChanceMax / (double) deflectMaxLevel) * (double) skillValue);
if (skillValue >= 250) ironArmBonus = String.valueOf(ironArmMaxBonus); if (skillValue >= 250) ironArmBonus = String.valueOf(ironArmMaxBonus);
else ironArmBonus = String.valueOf(3 + ((int) skillValue / ironArmIncreaseLevel)); else ironArmBonus = String.valueOf(3 + ((double) skillValue / (double) ironArmIncreaseLevel));
} }
@Override @Override

View File

@ -11,14 +11,14 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class WoodcuttingCommand extends SkillCommand { public class WoodcuttingCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String treeFellerLength; private String treeFellerLength;
private String doubleDropChance; private String doubleDropChance;
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength(); private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance(); private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance();
private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel(); private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel();
private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel(); private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel();
private boolean canTreeFell; private boolean canTreeFell;
private boolean canLeafBlow; private boolean canLeafBlow;
@ -31,11 +31,11 @@ public class WoodcuttingCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0"); DecimalFormat df = new DecimalFormat("0.0");
treeFellerLength = String.valueOf(2 + ((int) skillValue / abilityLengthIncreaseLevel)); treeFellerLength = String.valueOf(2 + ((double) skillValue / (double) abilityLengthIncreaseLevel));
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus); if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
else doubleDropChance = df.format((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue); else doubleDropChance = df.format(((double) doubleDropsMaxBonus / (double) doubleDropsMaxLevel) * (double) skillValue);
} }
@Override @Override

View File

@ -329,7 +329,7 @@ public class Mining {
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL); int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int randomChance = 100; int randomChance = 100;
int chance = (MAX_CHANCE / MAX_BONUS_LEVEL) * skillLevel; int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * (double) skillLevel);
if (player.hasPermission("mcmmo.perks.lucky.mining")) { if (player.hasPermission("mcmmo.perks.lucky.mining")) {
randomChance = (int) (randomChance * 0.75); randomChance = (int) (randomChance * 0.75);