More work on migrating commands to new API

This commit is contained in:
nossr50
2020-12-23 15:29:39 -08:00
parent 537b120ffc
commit 9b9ffbb982
46 changed files with 352 additions and 341 deletions

View File

@@ -1,9 +1,11 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.CoreSkills;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.SkillActivationType;
@@ -23,7 +25,7 @@ public class AcrobaticsCommand extends SkillCommand {
private boolean canRoll;
public AcrobaticsCommand() {
super(PrimarySkillType.ACROBATICS);
super(CoreSkills.ACROBATICS);
}
@Override
@@ -92,7 +94,7 @@ public class AcrobaticsCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.ACROBATICS);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.ACROBATICS);
return textComponents;
}

View File

@@ -29,7 +29,7 @@ public class AlchemyCommand extends SkillCommand {
private boolean canConcoctions;
public AlchemyCommand() {
super(PrimarySkillType.ALCHEMY);
super(CoreSkills.ALCHEMY);
}
protected String[] calculateAbilityDisplayValues(@NotNull Player player) {
@@ -48,7 +48,7 @@ public class AlchemyCommand extends SkillCommand {
AlchemyManager alchemyManager = ((McMMOPlayer) (mmoPlayer)).getAlchemyManager();
String[] displayValues = new String[2];
boolean isLucky = Permissions.lucky(Misc.adaptPlayer(mmoPlayer), PrimarySkillType.ALCHEMY);
boolean isLucky = Permissions.lucky(Misc.adaptPlayer(mmoPlayer), CoreSkills.ALCHEMY);
displayValues[0] = decimal.format(alchemyManager.calculateBrewSpeed(false)) + "x";
displayValues[1] = isLucky ? decimal.format(alchemyManager.calculateBrewSpeed(true)) + "x" : null;
@@ -105,7 +105,7 @@ public class AlchemyCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.ALCHEMY);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.ALCHEMY);
return textComponents;
}

View File

@@ -32,7 +32,7 @@ public class AprilCommand implements TabExecutor {
if (args.length == 0) {
Player player = (Player) sender;
FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName);
FakeSkillType fakeSkillType = FakeSkillType.getByName(rootSkillName);
float skillValue = Misc.getRandom().nextInt(99);

View File

@@ -25,7 +25,7 @@ public class ArcheryCommand extends SkillCommand {
private boolean canRetrieve;
public ArcheryCommand() {
super(PrimarySkillType.ARCHERY);
super(CoreSkills.ARCHERY);
}
@Override
@@ -44,7 +44,7 @@ public class ArcheryCommand extends SkillCommand {
dazeChanceLucky = dazeStrings[1];
}
// SKILL SHOT
// rootSkillSHOT
if (canSkillShot) {
skillShotBonus = percent.format(Archery.getDamageBonusPercent(mmoPlayer));
}
@@ -87,7 +87,7 @@ public class ArcheryCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.ARCHERY);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.ARCHERY);
return textComponents;
}

View File

@@ -30,7 +30,7 @@ public class AxesCommand extends SkillCommand {
private boolean canGreaterImpact;
public AxesCommand() {
super(PrimarySkillType.AXES);
super(CoreSkills.AXES);
}
@Override
@@ -107,7 +107,7 @@ public class AxesCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.AXES);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.AXES);
return textComponents;
}

View File

@@ -12,7 +12,7 @@ import java.util.List;
public class CrossbowsCommand extends SkillCommand {
public CrossbowsCommand() {
super(PrimarySkillType.CROSSBOWS);
super(CoreSkills.CROSSBOWS);
}
@Override
@@ -43,7 +43,7 @@ public class CrossbowsCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.CROSSBOWS);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.CROSSBOWS);
return textComponents;
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.CoreSkills;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
@@ -21,7 +23,7 @@ public class ExcavationCommand extends SkillCommand {
private boolean canTreasureHunt;
public ExcavationCommand() {
super(PrimarySkillType.EXCAVATION);
super(CoreSkills.EXCAVATION);
}
@Override
@@ -68,7 +70,7 @@ public class ExcavationCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.EXCAVATION);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.EXCAVATION);
return textComponents;
}

View File

@@ -42,7 +42,7 @@ public class FishingCommand extends SkillCommand {
private String maMinWaitTime, maMaxWaitTime;
public FishingCommand() {
super(PrimarySkillType.FISHING);
super(CoreSkills.FISHING);
}
@Override
@@ -78,7 +78,7 @@ public class FishingCommand extends SkillCommand {
// FISHING_SHAKE
if (canShake) {
String[] shakeStrings = RandomChanceUtil.calculateAbilityDisplayValuesStatic(mmoPlayer, PrimarySkillType.FISHING, fishingManager.getShakeChance());
String[] shakeStrings = RandomChanceUtil.calculateAbilityDisplayValuesStatic(mmoPlayer, CoreSkills.FISHING, fishingManager.getShakeChance());
shakeChance = shakeStrings[0];
shakeChanceLucky = shakeStrings[1];
}
@@ -154,7 +154,7 @@ public class FishingCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.FISHING);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.FISHING);
return textComponents;
}

View File

@@ -1,7 +1,9 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.CoreSkills;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
@@ -37,7 +39,7 @@ public class HerbalismCommand extends SkillCommand {
private boolean canShroomThumb;
public HerbalismCommand() {
super(PrimarySkillType.HERBALISM);
super(CoreSkills.HERBALISM);
}
@Override
@@ -154,7 +156,7 @@ public class HerbalismCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.HERBALISM);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.HERBALISM);
return textComponents;
}

View File

@@ -34,7 +34,7 @@ public class MiningCommand extends SkillCommand {
private boolean canDemoExpert;
public MiningCommand() {
super(PrimarySkillType.MINING);
super(CoreSkills.MINING);
}
@Override
@@ -113,7 +113,7 @@ public class MiningCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.MINING);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.MINING);
return textComponents;
}

View File

@@ -1,10 +1,12 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.CoreSkills;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.text.TextComponentFactory;
import com.google.common.collect.ImmutableList;
@@ -54,7 +56,7 @@ public class MmoInfoCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mystery"));
return true;
} else if(InteractionManager.getAbstractByName(args[0]) != null || PrimarySkillType.SUBSKILL_NAMES.contains(args[0]))
} else if(InteractionManager.getAbstractByName(args[0]) != null || CoreSkills.SUBSKILL_NAMES.contains(args[0]))
{
displayInfo(mmoPlayer, args[0]);
return true;
@@ -72,14 +74,14 @@ public class MmoInfoCommand implements TabExecutor {
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SUBSKILL_NAMES, new ArrayList<>(PrimarySkillType.SUBSKILL_NAMES.size()));
return StringUtil.copyPartialMatches(args[0], CoreSkills.SUBSKILL_NAMES, new ArrayList<>(CoreSkills.SUBSKILL_NAMES.size()));
}
return ImmutableList.of();
}
private void displayInfo(@NotNull OnlineMMOPlayer mmoPlayer, String subSkillName)
{
//Check to see if the skill exists in the new system
//Check to see if the rootSkillexists in the new system
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName(subSkillName);
if(abstractSubSkill != null)
{
@@ -88,12 +90,14 @@ public class MmoInfoCommand implements TabExecutor {
//TextComponentFactory.sendPlayerUrlHeader(player);
} else {
/*
* Skill is only in the old system
* rootSkillis only in the old system
*/
Misc.adaptPlayer(mmoPlayer).sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
Misc.adaptPlayer(mmoPlayer).sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", subSkillName));
Misc.adaptPlayer(mmoPlayer).sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
Misc.adaptPlayer(mmoPlayer).sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill"));
Player player = Misc.adaptPlayer(mmoPlayer);
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", subSkillName));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill"));
}
for(SubSkillType subSkillType : SubSkillType.values())

View File

@@ -43,7 +43,7 @@ public class RepairCommand extends SkillCommand {
private int stoneLevel;
public RepairCommand() {
super(PrimarySkillType.REPAIR);
super(CoreSkills.REPAIR);
}
@Override
@@ -123,7 +123,7 @@ public class RepairCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.REPAIR);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.REPAIR);
return textComponents;
}

View File

@@ -18,7 +18,7 @@ public class SalvageCommand extends SkillCommand {
private boolean canArcaneSalvage;
public SalvageCommand() {
super(PrimarySkillType.SALVAGE);
super(CoreSkills.SALVAGE);
}
@Override
@@ -66,7 +66,7 @@ public class SalvageCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.SALVAGE);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.SALVAGE);
return textComponents;
}

View File

@@ -77,7 +77,7 @@ public abstract class SkillCommand implements TabExecutor {
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
float skillValue = mmoPlayer.getExperienceHandler().getSkillLevel(rootSkill);
//Send the players a few blank lines to make finding the top of the skill command easier
//Send the players a few blank lines to make finding the top of the rootSkillcommand easier
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
for (int i = 0; i < 2; i++) {
player.sendMessage("");
@@ -205,11 +205,11 @@ public abstract class SkillCommand implements TabExecutor {
}
protected @NotNull String[] getAbilityDisplayValues(@NotNull SkillActivationType skillActivationType, @NotNull OnlineMMOPlayer mmoPlayer, @NotNull SubSkillType subSkill) {
return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, Misc.adaptPlayer(mmoPlayer), subSkill);
return RandomChanceUtil.calculateAbilityDisplayValues(SkillActivationType, Misc.adaptPlayer(mmoPlayer), subSkill);
}
protected @NotNull String[] calculateLengthDisplayValues(@NotNull OnlineMMOPlayer mmoPlayer, float skillValue) {
int maxLength = primarySkillType.getSuperAbilityType().getMaxLength();
int maxLength = CoreSkills.getSuperAbilityType().getMaxLength();
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
@@ -217,7 +217,7 @@ public abstract class SkillCommand implements TabExecutor {
if(abilityLengthCap <= 0)
{
length = 2 + (int) (skillValue / abilityLengthVar);
length = 2 + (int) (rootSkillValue / abilityLengthVar);
}
else {
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
@@ -273,7 +273,7 @@ public abstract class SkillCommand implements TabExecutor {
* Checks if a player can use a skill
* @param mmoPlayer target player
* @param subSkillType target subskill
* @return true if the player has permission and has the skill unlocked
* @return true if the player has permission and has the rootSkillunlocked
*/
protected boolean canUseSubskill(@NotNull OnlineMMOPlayer mmoPlayer, SubSkillType subSkillType) {
return Permissions.isSubSkillEnabled(Misc.adaptPlayer(mmoPlayer), subSkillType) && RankUtils.hasUnlockedSubskill(mmoPlayer, subSkillType);

View File

@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
//TODO: Switch to root skill based
//TODO: Switch to root rootSkillbased
public class SkillGuideCommand implements CommandExecutor {
private final String header;
private final RootSkill rootSkill;
@@ -21,9 +21,9 @@ public class SkillGuideCommand implements CommandExecutor {
private final String invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
public SkillGuideCommand(@NotNull RootSkill rootSkill) {
skill = CoreSkills.getSkill(rootSkill);
header = LocaleLoader.getString("Guides.Header", skill.getName());
guide = getGuide(skill);
rootSkill = CoreSkills.getSkill(rootSkill);
header = LocaleLoader.getString("Guides.Header", rootSkill.getName());
guide = getGuide(rootSkill);
}
@Override
@@ -94,7 +94,7 @@ public class SkillGuideCommand implements CommandExecutor {
ArrayList<String> guide = new ArrayList<>();
for (int i = 0; i < 10; i++) {
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n");
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(rootSkill.toString()) + ".Section." + i).split("\n");
if (section[0].startsWith("!")) {
break;

View File

@@ -26,7 +26,7 @@ public class SmeltingCommand extends SkillCommand {
private boolean canUnderstandTheArt;
public SmeltingCommand() {
super(PrimarySkillType.SMELTING);
super(CoreSkills.SMELTING);
}
@Override
@@ -90,7 +90,7 @@ public class SmeltingCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.SMELTING);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.SMELTING);
return textComponents;
}

View File

@@ -29,7 +29,7 @@ public class SwordsCommand extends SkillCommand {
private boolean canBleed;
public SwordsCommand() {
super(PrimarySkillType.SWORDS);
super(CoreSkills.SWORDS);
}
@Override
@@ -112,7 +112,7 @@ public class SwordsCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.SWORDS);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.SWORDS);
return textComponents;
}

View File

@@ -29,7 +29,7 @@ public class TamingCommand extends SkillCommand {
private boolean canHolyHound;
public TamingCommand() {
super(PrimarySkillType.TAMING);
super(CoreSkills.TAMING);
}
@Override

View File

@@ -10,7 +10,7 @@ import java.util.List;
public class TridentsCommand extends SkillCommand {
public TridentsCommand() {
super(PrimarySkillType.TRIDENTS);
super(CoreSkills.TRIDENTS);
}
@Override
@@ -32,7 +32,7 @@ public class TridentsCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.TRIDENTS);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.TRIDENTS);
return textComponents;
}

View File

@@ -32,7 +32,7 @@ public class UnarmedCommand extends SkillCommand {
private boolean canIronGrip;
public UnarmedCommand() {
super(PrimarySkillType.UNARMED);
super(CoreSkills.UNARMED);
}
@Override
@@ -125,7 +125,7 @@ public class UnarmedCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.UNARMED);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.UNARMED);
return textComponents;
}

View File

@@ -28,7 +28,7 @@ public class WoodcuttingCommand extends SkillCommand {
private boolean canNaturesBounty;
public WoodcuttingCommand() {
super(PrimarySkillType.WOODCUTTING);
super(CoreSkills.WOODCUTTING);
}
@Override
@@ -100,7 +100,7 @@ public class WoodcuttingCommand extends SkillCommand {
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.WOODCUTTING);
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, CoreSkills.WOODCUTTING);
return textComponents;
}