slow refactoring over skill commands

This commit is contained in:
nossr50 2020-12-09 18:42:48 -08:00
parent 81d184c19e
commit 1c132ddb12
10 changed files with 30 additions and 29 deletions

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
@ -10,7 +11,7 @@ import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory; import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -27,10 +28,10 @@ public class AcrobaticsCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
// ACROBATICS_DODGE // ACROBATICS_DODGE
if (canDodge) { if (canDodge) {
String[] dodgeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_DODGE); String[] dodgeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, mmoPlayer, SubSkillType.ACROBATICS_DODGE);
dodgeChance = dodgeStrings[0]; dodgeChance = dodgeStrings[0];
dodgeChanceLucky = dodgeStrings[1]; dodgeChanceLucky = dodgeStrings[1];
} }
@ -38,12 +39,12 @@ public class AcrobaticsCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) { protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
canDodge = canUseSubskill(player, SubSkillType.ACROBATICS_DODGE); canDodge = canUseSubskill(mmoPlayer, SubSkillType.ACROBATICS_DODGE);
canRoll = canUseSubskill(player, SubSkillType.ACROBATICS_ROLL); canRoll = canUseSubskill(mmoPlayer, SubSkillType.ACROBATICS_ROLL);
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
if (canDodge) { if (canDodge) {
@ -60,10 +61,10 @@ public class AcrobaticsCommand extends SkillCommand {
double rollChance, graceChance; double rollChance, graceChance;
//Chance to roll at half //Chance to roll at half
RandomChanceSkill roll_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL); RandomChanceSkill roll_rcs = new RandomChanceSkill(mmoPlayer.getPlayer(), SubSkillType.ACROBATICS_ROLL);
//Chance to graceful roll //Chance to graceful roll
RandomChanceSkill grace_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL); RandomChanceSkill grace_rcs = new RandomChanceSkill(mmoPlayer.getPlayer(), SubSkillType.ACROBATICS_ROLL);
grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds
//Chance Stat Calculations //Chance Stat Calculations
@ -71,7 +72,7 @@ public class AcrobaticsCommand extends SkillCommand {
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs); graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold(); //damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
String[] rollStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL); String[] rollStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, mmoPlayer, SubSkillType.ACROBATICS_ROLL);
//Format //Format
double rollChanceLucky = rollChance * 1.333D; double rollChanceLucky = rollChance * 1.333D;
@ -89,10 +90,10 @@ public class AcrobaticsCommand extends SkillCommand {
} }
@Override @Override
protected List<Component> getTextComponents(Player player) { protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ACROBATICS); TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.ACROBATICS);
return textComponents; return textComponents;
} }

View File

@ -57,7 +57,7 @@ public class AlchemyCommand extends SkillCommand {
@Override @Override
protected void dataCalculations(McMMOPlayer mmoPlayer, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
// ALCHEMY_CATALYSIS // ALCHEMY_CATALYSIS
if (canCatalysis) { if (canCatalysis) {
String[] catalysisStrings = calculateAbilityDisplayValues(mmoPlayer.getPlayer()); String[] catalysisStrings = calculateAbilityDisplayValues(mmoPlayer.getPlayer());
@ -81,7 +81,7 @@ public class AlchemyCommand extends SkillCommand {
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
if (canCatalysis) { if (canCatalysis) {
@ -101,7 +101,7 @@ public class AlchemyCommand extends SkillCommand {
} }
@Override @Override
protected List<Component> getTextComponents(Player player) { protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY);

View File

@ -16,7 +16,7 @@ public class CrossbowsCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
} }
@ -26,7 +26,7 @@ public class CrossbowsCommand extends SkillCommand {
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
CrossbowManager crossbowManager = mcMMO.getUserManager().getPlayer(player).getCrossbowManager(); CrossbowManager crossbowManager = mcMMO.getUserManager().getPlayer(player).getCrossbowManager();

View File

@ -27,7 +27,7 @@ public class ExcavationCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
// GIGA DRILL BREAKER // GIGA DRILL BREAKER
if (canGigaDrill) { if (canGigaDrill) {
String[] gigaDrillStrings = calculateLengthDisplayValues(player, skillValue); String[] gigaDrillStrings = calculateLengthDisplayValues(player, skillValue);

View File

@ -24,7 +24,7 @@ public class SalvageCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }

View File

@ -111,7 +111,7 @@ public class SwordsCommand extends SkillCommand {
} }
@Override @Override
protected List<Component> getTextComponents(Player player) { protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SWORDS); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SWORDS);

View File

@ -33,7 +33,7 @@ public class TamingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
if (canGore) { if (canGore) {
String[] goreStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.TAMING_GORE); String[] goreStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.TAMING_GORE);
goreChance = goreStrings[0]; goreChance = goreStrings[0];
@ -55,7 +55,7 @@ public class TamingCommand extends SkillCommand {
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
if (canEnvironmentallyAware) { if (canEnvironmentallyAware) {
@ -92,7 +92,7 @@ public class TamingCommand extends SkillCommand {
} }
@Override @Override
protected List<Component> getTextComponents(Player player) { protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, this.skill); TextComponentFactory.getSubSkillTextComponents(player, textComponents, this.skill);

View File

@ -14,7 +14,7 @@ public class TridentsCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
} }
@ -24,7 +24,7 @@ public class TridentsCommand extends SkillCommand {
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
return null; return null;
} }

View File

@ -84,7 +84,7 @@ public class UnarmedCommand extends SkillCommand {
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
if (canDeflect) { if (canDeflect) {
@ -124,7 +124,7 @@ public class UnarmedCommand extends SkillCommand {
} }
@Override @Override
protected List<Component> getTextComponents(Player player) { protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.UNARMED); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.UNARMED);

View File

@ -32,7 +32,7 @@ public class WoodcuttingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
setDoubleDropClassicChanceStrings(player); setDoubleDropClassicChanceStrings(player);
@ -64,7 +64,7 @@ public class WoodcuttingCommand extends SkillCommand {
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected @NotNull List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>(); List<String> messages = new ArrayList<>();
if (canDoubleDrop) { if (canDoubleDrop) {
@ -97,7 +97,7 @@ public class WoodcuttingCommand extends SkillCommand {
} }
@Override @Override
protected List<Component> getTextComponents(Player player) { protected @NotNull List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.WOODCUTTING); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.WOODCUTTING);