Use the DecimalFormatter from SkillCommand

Why didn't I do this in the first place..
This commit is contained in:
TfT_02
2013-01-11 19:07:00 +01:00
parent 08592cbacf
commit db95085b26
31 changed files with 757 additions and 790 deletions

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -38,7 +36,6 @@ public class AcrobaticsCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float dodgeChanceF;
float rollChanceF;
float gracefulRollChanceF;
@ -46,23 +43,23 @@ public class AcrobaticsCommand extends SkillCommand {
// DODGE
if (skillValue >= dodgeMaxBonusLevel) dodgeChanceF = dodgeChanceMax;
else dodgeChanceF = (float) (((double) dodgeChanceMax / (double) dodgeMaxBonusLevel) * skillValue);
dodgeChance = df.format(dodgeChanceF);
if (dodgeChanceF + dodgeChanceF * 0.3333D >= 100D) dodgeChanceLucky = df.format(100D);
else dodgeChanceLucky = df.format(dodgeChanceF + dodgeChanceF * 0.3333D);
dodgeChance = percent.format(dodgeChanceF / 100D);
if (dodgeChanceF + dodgeChanceF * 0.3333D >= 100D) dodgeChanceLucky = percent.format(1D);
else dodgeChanceLucky = percent.format((dodgeChanceF + dodgeChanceF * 0.3333D) / 100D);
// ROLL
if (skillValue >= rollMaxBonusLevel) rollChanceF = rollChanceMax;
else rollChanceF = (float) (((double) rollChanceMax / (double) rollMaxBonusLevel) * skillValue);
rollChance = df.format(rollChanceF);
if (rollChanceF + rollChanceF * 0.3333D >= 100D) rollChanceLucky = df.format(100D);
else rollChanceLucky = df.format(rollChanceF + rollChanceF * 0.3333D);
rollChance = percent.format(rollChanceF / 100D);
if (rollChanceF + rollChanceF * 0.3333D >= 100D) rollChanceLucky = percent.format(1D);
else rollChanceLucky = percent.format((rollChanceF + rollChanceF * 0.3333D) / 100D);
// GRACEFULROLL
if (skillValue >= gracefulRollMaxBonusLevel) gracefulRollChanceF = gracefulRollChanceMax;
else gracefulRollChanceF = (float) (((double) gracefulRollChanceMax / (double) gracefulRollMaxBonusLevel) * skillValue);
gracefulRollChance = df.format(gracefulRollChanceF);
if (gracefulRollChanceF + gracefulRollChanceF * 0.3333D >= 100D) gracefulRollChanceLucky = df.format(100D);
else gracefulRollChanceLucky = df.format(gracefulRollChanceF + gracefulRollChanceF * 0.3333D);
gracefulRollChance = percent.format(gracefulRollChanceF / 100D);
if (gracefulRollChanceF + gracefulRollChanceF * 0.3333D >= 100D) gracefulRollChanceLucky = percent.format(1D);
else gracefulRollChanceLucky = percent.format((gracefulRollChanceF + gracefulRollChanceF * 0.3333D) / 100D);
}
@Override

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -40,7 +38,6 @@ public class ArcheryCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float dazeChanceF;
float retrieveChanceF;
@ -52,16 +49,16 @@ public class ArcheryCommand extends SkillCommand {
// Daze
if (skillValue >= dazeMaxBonusLevel) dazeChanceF = dazeBonusMax;
else dazeChanceF = (float) (((double) dazeBonusMax / (double) dazeMaxBonusLevel) * skillValue);
dazeChance = df.format(dazeChanceF);
if (dazeChanceF + dazeChanceF * 0.3333D >= 100D) dazeChanceLucky = df.format(100D);
else dazeChanceLucky = df.format(dazeChanceF + dazeChanceF * 0.3333D);
dazeChance = percent.format(dazeChanceF / 100D);
if (dazeChanceF + dazeChanceF * 0.3333D >= 100D) dazeChanceLucky = percent.format(1D);
else dazeChanceLucky = percent.format((dazeChanceF + dazeChanceF * 0.3333D) / 100D);
// Retrieve
if (skillValue >= retrieveMaxBonusLevel) retrieveChanceF = retrieveBonusMax;
else retrieveChanceF = (float) (((double) retrieveBonusMax / (double) retrieveMaxBonusLevel) * skillValue);
retrieveChance = df.format(retrieveChanceF);
if (retrieveChanceF + retrieveChanceF * 0.3333D >= 100D) retrieveChanceLucky = df.format(100D);
else retrieveChanceLucky = df.format(retrieveChanceF + retrieveChanceF * 0.3333D);
retrieveChance = percent.format(retrieveChanceF / 100D);
if (retrieveChanceF + retrieveChanceF * 0.3333D >= 100D) retrieveChanceLucky = percent.format(1D);
else retrieveChanceLucky = percent.format((retrieveChanceF + retrieveChanceF * 0.3333D) / 100D);
}
@Override

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -44,7 +42,6 @@ public class AxesCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float critChanceF;
int skillCheck = Misc.skillCheck((int)skillValue, critMaxBonusLevel);
@ -74,9 +71,9 @@ public class AxesCommand extends SkillCommand {
//Critical Strikes
if (skillValue >= critMaxBonusLevel) critChanceF = (float) critMaxChance;
else critChanceF = (float) ((critMaxChance / critMaxBonusLevel) * skillCheck);
critChance = df.format(critChanceF);
if (critChanceF + critChanceF * 0.3333D >= 100D) critChanceLucky = df.format(100D);
else critChanceLucky = df.format(critChanceF + critChanceF * 0.3333D);
critChance = percent.format(critChanceF / 100D);
if (critChanceF + critChanceF * 0.3333D >= 100D) critChanceLucky = percent.format(1D);
else critChanceLucky = percent.format((critChanceF + critChanceF * 0.3333D) / 100D);
//Axe Mastery
if (skillValue >= bonusDamageAxesMaxBonusLevel) bonusDamage = String.valueOf(bonusDamageAxesBonusMax);
else bonusDamage = String.valueOf(skillValue / ((double) bonusDamageAxesMaxBonusLevel / (double) bonusDamageAxesBonusMax));

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -39,19 +37,18 @@ public class FishingCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
//Treasure Hunter
lootTier = Fishing.getFishingLootTier(profile);
int magicChanceInt = (lootTier * magicHunterMultiplier);
magicChance = df.format(magicChanceInt);
if (magicChanceInt + (magicChanceInt * 0.3333D) >= 100D) magicChanceLucky = df.format(100D);
else magicChanceLucky = df.format(magicChanceInt + (magicChanceInt * 0.3333D));
magicChance = percent.format(magicChanceInt / 100D);
if (magicChanceInt + (magicChanceInt * 0.3333D) >= 100D) magicChanceLucky = percent.format(1D);
else magicChanceLucky = percent.format((magicChanceInt + (magicChanceInt * 0.3333D)) / 100D);
//Shake
int dropChance = Fishing.getShakeChance(lootTier);
shakeChance = df.format(dropChance);
if (dropChance + (dropChance * 0.3333D) >= 100D) shakeChanceLucky = df.format(100D);
else shakeChanceLucky = df.format(dropChance + (dropChance * 0.3333D));
shakeChance = percent.format(dropChance / 100D);
if (dropChance + (dropChance * 0.3333D) >= 100D) shakeChanceLucky = percent.format(1D);
else shakeChanceLucky = percent.format((dropChance + (dropChance * 0.3333D)) / 100D);
shakeUnlockLevel = advancedConfig.getShakeUnlockLevel();
//Fishermans Diet

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -48,7 +46,6 @@ public class HerbalismCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float greenThumbChanceF;
float doubleDropChanceF;
@ -78,15 +75,15 @@ public class HerbalismCommand extends SkillCommand {
if (skillValue >= greenThumbMaxLevel) greenThumbChanceF = (float) (greenThumbMaxBonus);
else greenThumbChanceF = (float) ((greenThumbMaxBonus / greenThumbMaxLevel) * skillValue);
greenThumbChance = df.format(greenThumbChanceF);
if (greenThumbChanceF + greenThumbChanceF * 0.3333D >= 100D) greenThumbChanceLucky = df.format(100D);
else greenThumbChanceLucky = df.format(greenThumbChanceF + greenThumbChanceF * 0.3333D);
greenThumbChance = percent.format(greenThumbChanceF / 100D);
if (greenThumbChanceF + greenThumbChanceF * 0.3333D >= 100D) greenThumbChanceLucky = percent.format(1D);
else greenThumbChanceLucky = percent.format((greenThumbChanceF + greenThumbChanceF * 0.3333D) / 100D);
//DOUBLE DROPS
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
doubleDropChance = df.format(doubleDropChanceF);
if (doubleDropChanceF + doubleDropChanceF * 0.3333D >= 100D) doubleDropChanceLucky = df.format(100D);
else doubleDropChanceLucky = df.format(doubleDropChanceF + doubleDropChanceF * 0.3333D);
doubleDropChance = percent.format(doubleDropChanceF / 100D);
if (doubleDropChanceF + doubleDropChanceF * 0.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
else doubleDropChanceLucky = percent.format((doubleDropChanceF + doubleDropChanceF * 0.3333D) / 100D);
}
@Override

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -50,7 +48,6 @@ public class MiningCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float doubleDropChanceF;
//Super Breaker
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
@ -73,9 +70,9 @@ public class MiningCommand extends SkillCommand {
//Double Drops
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
doubleDropChance = df.format(doubleDropChanceF);
if (doubleDropChanceF + doubleDropChanceF * 0.3333D >= 100D) doubleDropChanceLucky = df.format(100D);
else doubleDropChanceLucky = df.format(doubleDropChanceF + doubleDropChanceF * 0.3333D);
doubleDropChance = percent.format(doubleDropChanceF / 100D);
if (doubleDropChanceF + doubleDropChanceF * 0.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
else doubleDropChanceLucky = percent.format((doubleDropChanceF + doubleDropChanceF * 0.3333D) / 100D);
//Blast Mining
if (skillValue >= blastMiningRank8) {

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.mcMMO;
@ -52,7 +50,6 @@ public class RepairCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float superRepairChanceF;
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
@ -67,14 +64,14 @@ public class RepairCommand extends SkillCommand {
salvageLevel = Config.getInstance().getSalvageUnlockLevel();
if (skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = df.format(repairMasteryMaxBonus);
else repairMasteryBonus = df.format(((double) repairMasteryMaxBonus / (double) repairMasteryMaxBonusLevel) * skillValue);
if (skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = percent.format(repairMasteryMaxBonus / 100D);
else repairMasteryBonus = percent.format((((double) repairMasteryMaxBonus / (double) repairMasteryMaxBonusLevel) * skillValue) / 100D);
if (skillValue >= superRepairMaxBonusLevel) superRepairChanceF = superRepairChanceMax;
else superRepairChanceF = (float) (((double) superRepairChanceMax / (double) superRepairMaxBonusLevel) * skillValue);
superRepairChance = df.format(superRepairChanceF);
if (superRepairChanceF + superRepairChanceF * 0.3333D >= 100D) superRepairChanceLucky = df.format(100D);
else superRepairChanceLucky = df.format(superRepairChanceF + superRepairChanceF * 0.3333D);
superRepairChance = percent.format(superRepairChanceF / 100D);
if (superRepairChanceF + superRepairChanceF * 0.3333D >= 100D) superRepairChanceLucky = percent.format(1D);
else superRepairChanceLucky = percent.format((superRepairChanceF + superRepairChanceF * 0.3333D) / 100D);
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
}

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -41,7 +39,6 @@ public class SwordsCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float bleedChanceF;
float counterAttackChanceF;
//Serrated Strikes
@ -69,16 +66,16 @@ public class SwordsCommand extends SkillCommand {
if (skillValue >= bleedMaxLevel) bleedChanceF = bleedChanceMax;
else bleedChanceF = (float) (((double) bleedChanceMax / (double) bleedMaxLevel) * skillValue);
bleedChance = df.format(bleedChanceF);
if (bleedChanceF + bleedChanceF * 0.3333D >= 100D) bleedChanceLucky = df.format(100D);
else bleedChanceLucky = df.format(bleedChanceF + bleedChanceF * 0.3333D);
bleedChance = percent.format(bleedChanceF / 100D);
if (bleedChanceF + bleedChanceF * 0.3333D >= 100D) bleedChanceLucky = percent.format(1D);
else bleedChanceLucky = percent.format((bleedChanceF + bleedChanceF * 0.3333D) / 100D);
//Counter Attack
if (skillValue >= counterMaxLevel) counterAttackChanceF = counterChanceMax;
else counterAttackChanceF = (float) (((double) counterChanceMax / (double) counterMaxLevel) * skillValue);
counterAttackChance = df.format(counterAttackChanceF);
if (counterAttackChanceF + counterAttackChanceF * 0.3333D >= 100D) counterAttackChanceLucky = df.format(100D);
else counterAttackChanceLucky = df.format(counterAttackChanceF + counterAttackChanceF * 0.3333D);
counterAttackChance = percent.format(counterAttackChanceF / 100D);
if (counterAttackChanceF + counterAttackChanceF * 0.3333D >= 100D) counterAttackChanceLucky = percent.format(1D);
else counterAttackChanceLucky = percent.format((counterAttackChanceF + counterAttackChanceF * 0.3333D) / 100D);
}
@Override

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -41,13 +39,12 @@ public class TamingCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float goreChanceF;
if (skillValue >= goreMaxLevel) goreChanceF = (goreChanceMax);
else goreChanceF = (float) (((double) goreChanceMax / (double) goreMaxLevel) * skillValue);
goreChance = df.format(goreChanceF);
if (goreChanceF + goreChanceF * 0.3333D >= 100D) goreChanceLucky = df.format(100D);
else goreChanceLucky = df.format(goreChanceF + goreChanceF * 0.3333D);
goreChance = percent.format(goreChanceF / 100D);
if (goreChanceF + goreChanceF * 0.3333D >= 100D) goreChanceLucky = percent.format(1D);
else goreChanceLucky = percent.format((goreChanceF + goreChanceF * 0.3333D) / 100D);
}
@Override

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -41,7 +39,6 @@ public class UnarmedCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float disarmChanceF;
float deflectChanceF;
//Berserk
@ -66,16 +63,16 @@ public class UnarmedCommand extends SkillCommand {
//Disarm
if (skillValue >= disarmMaxLevel) disarmChanceF = disarmChanceMax;
else disarmChanceF = (float) (((double) disarmChanceMax / (double) disarmMaxLevel) * skillValue);
disarmChance = df.format(disarmChanceF);
if (disarmChanceF + disarmChanceF * 0.3333D >= 100D) disarmChanceLucky = df.format(100D);
else disarmChanceLucky = df.format(disarmChanceF + disarmChanceF * 0.3333D);
disarmChance = percent.format(disarmChanceF / 100D);
if (disarmChanceF + disarmChanceF * 0.3333D >= 100D) disarmChanceLucky = percent.format(1D);
else disarmChanceLucky = percent.format((disarmChanceF + disarmChanceF * 0.3333D) / 100D);
//Deflect
if (skillValue >= deflectMaxLevel) deflectChanceF = deflectChanceMax;
else deflectChanceF = (float) (((double) deflectChanceMax / (double) deflectMaxLevel) * skillValue);
deflectChance = df.format(deflectChanceF);
if (deflectChanceF + deflectChanceF * 0.3333D >= 100D) deflectChanceLucky = df.format(100D);
else deflectChanceLucky = df.format(deflectChanceF + deflectChanceF * 0.3333D);
deflectChance = percent.format(deflectChanceF / 100D);
if (deflectChanceF + deflectChanceF * 0.3333D >= 100D) deflectChanceLucky = percent.format(1D);
else deflectChanceLucky = percent.format((deflectChanceF + deflectChanceF * 0.3333D) / 100D);
//Iron Arm
if (skillValue >= 250) ironArmBonus = String.valueOf(ironArmMaxBonus);

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.ChatColor;
import com.gmail.nossr50.commands.SkillCommand;
@ -36,7 +34,6 @@ public class WoodcuttingCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("0.0");
float doubleDropChanceF;
//Tree Feller
@ -61,9 +58,9 @@ public class WoodcuttingCommand extends SkillCommand {
//Double Drops
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
doubleDropChance = df.format(doubleDropChanceF);
if (doubleDropChanceF + doubleDropChanceF * 0.3333D >= 100D) doubleDropChanceLucky = df.format(100D);
else doubleDropChanceLucky = df.format(doubleDropChanceF + doubleDropChanceF * 0.3333D);
doubleDropChance = percent.format(doubleDropChanceF / 100D);
if (doubleDropChanceF + doubleDropChanceF * 0.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
else doubleDropChanceLucky = percent.format((doubleDropChanceF + doubleDropChanceF * 0.3333D) / 100D);
}
@Override