Using doubles in most places again to avoid precision loss

This commit is contained in:
nossr50
2019-06-04 21:12:10 -07:00
parent 32fa6cee96
commit fc6c6ed2c4
59 changed files with 382 additions and 351 deletions

View File

@@ -22,7 +22,7 @@ public class AddlevelsCommand extends ExperienceCommand {
@Override
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
float xpRemoved = profile.getSkillXpLevelRaw(skill);
double xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.addLevels(skill, value);
if (player == null) {

View File

@@ -23,7 +23,7 @@ public class MmoeditCommand extends ExperienceCommand {
@Override
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
int skillLevel = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
double xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, value);

View File

@@ -122,7 +122,7 @@ public class SkillresetCommand implements TabExecutor {
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill) {
int levelsRemoved = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
double xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, 0);

View File

@@ -26,7 +26,7 @@ public class AcrobaticsCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// ACROBATICS_DODGE
if (canDodge) {
String[] dodgeStrings = getAbilityDisplayValues(player, SubSkillType.ACROBATICS_DODGE);
@@ -42,7 +42,7 @@ public class AcrobaticsCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canDodge) {

View File

@@ -42,7 +42,7 @@
//// }
//
// @Override
// protected void dataCalculations(Player player, float skillValue) {
// protected void dataCalculations(Player player, double skillValue) {
// // ALCHEMY_CATALYSIS
//// if (canCatalysis) {
//// String[] catalysisStrings = calculateAbilityDisplayValues(player);
@@ -66,7 +66,7 @@
// }
//
// @Override
// protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
// protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
// List<String> messages = new ArrayList<>();
//
//// if (canCatalysis) {

View File

@@ -28,7 +28,7 @@ public class ArcheryCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// ARCHERY_ARROW_RETRIEVAL
if (canRetrieve) {
String[] retrieveStrings = getAbilityDisplayValues(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
@@ -57,7 +57,7 @@ public class ArcheryCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canRetrieve) {

View File

@@ -35,7 +35,7 @@ public class AxesCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// ARMOR IMPACT
if (canImpact) {
impactDamage = UserManager.getPlayer(player).getAxesManager().getImpactDurabilityDamage();
@@ -71,7 +71,7 @@ public class AxesCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canImpact) {

View File

@@ -24,7 +24,7 @@ public class ExcavationCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// GIGA DRILL BREAKER
if (canGigaDrill) {
String[] gigaDrillStrings = calculateLengthDisplayValues(player, skillValue);
@@ -40,7 +40,7 @@ public class ExcavationCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canGigaDrill) {

View File

@@ -51,7 +51,7 @@ public class FishingCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
// TREASURE HUNTER
@@ -133,7 +133,7 @@ public class FishingCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canFishermansDiet) {

View File

@@ -40,7 +40,7 @@ public class HerbalismCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// DOUBLE DROPS
if (canDoubleDrop) {
@@ -97,7 +97,7 @@ public class HerbalismCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canDoubleDrop) {

View File

@@ -38,7 +38,7 @@ public class MiningCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
@@ -76,7 +76,7 @@ public class MiningCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canBiggerBombs) {

View File

@@ -46,7 +46,7 @@ public class RepairCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE);
@@ -88,7 +88,7 @@ public class RepairCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canArcaneForge) {

View File

@@ -23,7 +23,7 @@ public class SalvageCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// TODO Auto-generated method stub
}
@@ -35,7 +35,7 @@ public class SalvageCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();

View File

@@ -76,7 +76,7 @@ public abstract class SkillCommand implements TabExecutor {
boolean isLucky = Permissions.lucky(player, skill);
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
float skillValue = mcMMOPlayer.getSkillLevel(skill);
double skillValue = mcMMOPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
@@ -129,7 +129,7 @@ public abstract class SkillCommand implements TabExecutor {
}
}
private void getStatMessages(Player player, boolean isLucky, boolean hasEndurance, float skillValue) {
private void getStatMessages(Player player, boolean isLucky, boolean hasEndurance, double skillValue) {
List<String> statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky);
if (!statsMessages.isEmpty()) {
@@ -224,7 +224,7 @@ public abstract class SkillCommand implements TabExecutor {
}
}
protected int calculateRank(float skillValue, int maxLevel, int rankChangeLevel) {
protected int calculateRank(double skillValue, int maxLevel, int rankChangeLevel) {
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
}
@@ -232,7 +232,7 @@ public abstract class SkillCommand implements TabExecutor {
return RandomChanceUtil.calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, subSkill);
}
protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
protected String[] calculateLengthDisplayValues(Player player, double skillValue) {
int maxLength = skill.getAbility().getMaxLength();
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
@@ -270,13 +270,13 @@ public abstract class SkillCommand implements TabExecutor {
}
}
protected abstract void dataCalculations(Player player, float skillValue);
protected abstract void dataCalculations(Player player, double skillValue);
protected abstract void permissionsCheck(Player player);
//protected abstract List<String> effectsDisplay();
protected abstract List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky);
protected abstract List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky);
protected abstract List<TextComponent> getTextComponents(Player player);

View File

@@ -30,7 +30,7 @@ public class SmeltingCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// FUEL EFFICIENCY
if (canFuelEfficiency) {
burnTimeModifier = String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
@@ -60,7 +60,7 @@ public class SmeltingCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
/*if (canFluxMine) {

View File

@@ -33,7 +33,7 @@ public class SwordsCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// SWORDS_COUNTER_ATTACK
if (canCounter) {
String[] counterStrings = getAbilityDisplayValues(player, SubSkillType.SWORDS_COUNTER_ATTACK);
@@ -66,7 +66,7 @@ public class SwordsCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();

View File

@@ -32,7 +32,7 @@ public class TamingCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
if (canGore) {
String[] goreStrings = getAbilityDisplayValues(player, SubSkillType.TAMING_GORE);
goreChance = goreStrings[0];
@@ -54,7 +54,7 @@ public class TamingCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canEnvironmentallyAware) {

View File

@@ -36,7 +36,7 @@ public class UnarmedCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// UNARMED_ARROW_DEFLECT
if (canDeflect) {
String[] deflectStrings = getAbilityDisplayValues(player, SubSkillType.UNARMED_ARROW_DEFLECT);
@@ -82,7 +82,7 @@ public class UnarmedCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canDeflect) {

View File

@@ -30,7 +30,7 @@ public class WoodcuttingCommand extends SkillCommand {
}
@Override
protected void dataCalculations(Player player, float skillValue) {
protected void dataCalculations(Player player, double skillValue) {
// DOUBLE DROPS
if (canDoubleDrop) {
setDoubleDropClassicChanceStrings(player);
@@ -61,7 +61,7 @@ public class WoodcuttingCommand extends SkillCommand {
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canDoubleDrop) {