diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index 1d6db9839..7d3721440 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -35,8 +35,8 @@ public class AcrobaticsCommand extends SkillCommand { @Override protected void permissionsCheck(Player player) { - canDodge = Permissions.isSubSkillEnabled(player, SubSkillType.ACROBATICS_DODGE); - canRoll = Permissions.isSubSkillEnabled(player, SubSkillType.ACROBATICS_ROLL); + canDodge = canUseSubskill(player, SubSkillType.ACROBATICS_DODGE); + canRoll = canUseSubskill(player, SubSkillType.ACROBATICS_ROLL); } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java index bd6e35775..f7b722498 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java @@ -61,8 +61,8 @@ public class AlchemyCommand extends SkillCommand { @Override protected void permissionsCheck(Player player) { - canCatalysis = Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CATALYSIS); - canConcoctions = Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS); + canCatalysis = canUseSubskill(player, SubSkillType.ALCHEMY_CATALYSIS); + canConcoctions = canUseSubskill(player, SubSkillType.ALCHEMY_CONCOCTIONS); } @Override @@ -85,21 +85,12 @@ public class AlchemyCommand extends SkillCommand { List messages = new ArrayList(); if (canCatalysis) { - int unlockLevel = AdvancedConfig.getInstance().getCatalysisUnlockLevel(); - - if (skillValue < unlockLevel) { - //messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Alchemy.Ability.Locked.0", unlockLevel))); - } - else { - messages.add(LocaleLoader.getString("Alchemy.Catalysis.Speed", brewSpeed) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", brewSpeedLucky) : "")); - } + messages.add(LocaleLoader.getString("Alchemy.Catalysis.Speed", brewSpeed) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", brewSpeedLucky) : "")); } if (canConcoctions) { - if(RankUtils.hasUnlockedSubskill(player, SubSkillType.ALCHEMY_CONCOCTIONS)) { - messages.add(LocaleLoader.getString("Alchemy.Concoctions.Rank", tier, Tier.values().length)); - messages.add(LocaleLoader.getString("Alchemy.Concoctions.Ingredients", ingredientCount, ingredientList)); - } + messages.add(LocaleLoader.getString("Alchemy.Concoctions.Rank", tier, Tier.values().length)); + messages.add(LocaleLoader.getString("Alchemy.Concoctions.Ingredients", ingredientCount, ingredientList)); } return messages; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java index 81172e627..55dcf79f2 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -53,9 +53,9 @@ public class ArcheryCommand extends SkillCommand { @Override protected void permissionsCheck(Player player) { - canSkillShot = Permissions.isSubSkillEnabled(player, SubSkillType.ARCHERY_SKILL_SHOT) && RankUtils.hasUnlockedSubskill(player, SubSkillType.ARCHERY_SKILL_SHOT); - canDaze = Permissions.isSubSkillEnabled(player, SubSkillType.ARCHERY_DAZE); - canRetrieve = Permissions.isSubSkillEnabled(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL); + canSkillShot = canUseSubskill(player, SubSkillType.ARCHERY_SKILL_SHOT); + canDaze = canUseSubskill(player, SubSkillType.ARCHERY_DAZE); + canRetrieve = canUseSubskill(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL); } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java index 873fcaac6..48668f332 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -62,10 +62,10 @@ public class AxesCommand extends SkillCommand { @Override protected void permissionsCheck(Player player) { canSkullSplitter = Permissions.skullSplitter(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER); - canCritical = Permissions.isSubSkillEnabled(player, SubSkillType.AXES_CRITICAL_STRIKES); - canAxeMastery = Permissions.isSubSkillEnabled(player, SubSkillType.AXES_AXE_MASTERY) && RankUtils.hasUnlockedSubskill(player, SubSkillType.AXES_AXE_MASTERY); - canImpact = Permissions.isSubSkillEnabled(player, SubSkillType.AXES_ARMOR_IMPACT) && RankUtils.hasUnlockedSubskill(player, SubSkillType.AXES_ARMOR_IMPACT); - canGreaterImpact = Permissions.isSubSkillEnabled(player, SubSkillType.AXES_GREATER_IMPACT); + canCritical = canUseSubskill(player, SubSkillType.AXES_CRITICAL_STRIKES); + canAxeMastery = canUseSubskill(player, SubSkillType.AXES_AXE_MASTERY); + canImpact = canUseSubskill(player, SubSkillType.AXES_ARMOR_IMPACT); + canGreaterImpact = canUseSubskill(player, SubSkillType.AXES_GREATER_IMPACT); } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index 9541e06c9..c951b3cf3 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -36,7 +36,7 @@ public class ExcavationCommand extends SkillCommand { @Override protected void permissionsCheck(Player player) { canGigaDrill = Permissions.gigaDrillBreaker(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER); - canTreasureHunt = Permissions.isSubSkillEnabled(player, SubSkillType.EXCAVATION_TREASURE_HUNTER) && RankUtils.hasUnlockedSubskill(player, SubSkillType.EXCAVATION_TREASURE_HUNTER); + canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_TREASURE_HUNTER); } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index e6c72be44..6b1528102 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -12,6 +12,7 @@ import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Location; import org.bukkit.entity.EntityType; @@ -112,12 +113,12 @@ public class FishingCommand extends SkillCommand { @Override protected void permissionsCheck(Player player) { - canTreasureHunt = Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER); - canMagicHunt = Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_MAGIC_HUNTER); - canShake = Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_SHAKE); - canFishermansDiet = Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET); - canMasterAngler = Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_MASTER_ANGLER); - canIceFish = Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_ICE_FISHING); + canTreasureHunt = canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER); + canMagicHunt = canUseSubskill(player, SubSkillType.FISHING_MAGIC_HUNTER); + canShake = canUseSubskill(player, SubSkillType.FISHING_SHAKE); + canFishermansDiet = canUseSubskill(player, SubSkillType.FISHING_FISHERMANS_DIET); + canMasterAngler = canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER); + canIceFish = canUseSubskill(player, SubSkillType.FISHING_ICE_FISHING); } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 181798439..7537349ff 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -14,6 +14,7 @@ import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.skills.PerksUtils; +import com.gmail.nossr50.util.skills.RankUtils; import com.google.common.collect.ImmutableList; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.TextComponent; @@ -219,4 +220,15 @@ public abstract class SkillCommand implements TabExecutor { protected abstract List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky); protected abstract List getTextComponents(Player player); + + /** + * Checks if a player can use a skill + * @param player target player + * @param subSkillType target subskill + * @return true if the player has permission and has the skill unlocked + */ + protected boolean canUseSubskill(Player player, SubSkillType subSkillType) + { + return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType); + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java index be89ba8a9..c91243e57 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java @@ -31,11 +31,11 @@ public enum SubSkillType { EXCAVATION_GIGA_DRILL_BREAKER(1), /* Fishing */ - FISHING_FISHERMANS_DIET, - FISHING_TREASURE_HUNTER, - FISHING_ICE_FISHING, + FISHING_FISHERMANS_DIET(5), + FISHING_TREASURE_HUNTER(8), + FISHING_ICE_FISHING(1), FISHING_MAGIC_HUNTER, - FISHING_MASTER_ANGLER, + FISHING_MASTER_ANGLER(1), FISHING_SHAKE, /* Herbalism */