2
0
Эх сурвалжийг харах

Remove config caching from SkillTools.java

GJ 12 жил өмнө
parent
commit
9282b7bd15

+ 2 - 2
src/main/java/com/gmail/nossr50/listeners/PlayerListener.java

@@ -335,7 +335,7 @@ public class PlayerListener implements Listener {
 
             /* ACTIVATION & ITEM CHECKS */
             if (BlockChecks.canActivateAbilities(blockState)) {
-                if (SkillTools.abilitiesEnabled) {
+                if (Config.getInstance().getAbilitiesEnabled()) {
                     if (BlockChecks.canActivateHerbalism(blockState)) {
                         SkillTools.activationCheck(player, SkillType.HERBALISM);
                     }
@@ -365,7 +365,7 @@ public class PlayerListener implements Listener {
         case RIGHT_CLICK_AIR:
 
             /* ACTIVATION CHECKS */
-            if (SkillTools.abilitiesEnabled) {
+            if (Config.getInstance().getAbilitiesEnabled()) {
                 SkillTools.activationCheck(player, SkillType.AXES);
                 SkillTools.activationCheck(player, SkillType.EXCAVATION);
                 SkillTools.activationCheck(player, SkillType.HERBALISM);

+ 2 - 1
src/main/java/com/gmail/nossr50/skills/SkillCommand.java

@@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
 import org.bukkit.entity.Player;
 
 import com.gmail.nossr50.commands.CommandHelper;
+import com.gmail.nossr50.config.AdvancedConfig;
 import com.gmail.nossr50.datatypes.PlayerProfile;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.skills.utilities.PerksUtils;
@@ -125,7 +126,7 @@ public abstract class SkillCommand implements CommandExecutor {
 
     protected String[] calculateLengthDisplayValues() {
         int maxLength = skill.getAbility().getMaxTicks();
-        int length = 2 + (int) (skillValue / SkillTools.abilityLengthIncreaseLevel);
+        int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
         int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
 
         if (maxLength != 0) {

+ 1 - 6
src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java

@@ -37,11 +37,6 @@ import com.gmail.nossr50.util.StringUtils;
 import com.gmail.nossr50.util.Users;
 
 public class SkillTools {
-    static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
-    public static boolean abilitiesEnabled = Config.getInstance().getAbilitiesEnabled();
-    public static int toolDurabilityLoss = Config.getInstance().getAbilityToolDamage();
-    public static int abilityLengthIncreaseLevel = AdvancedConfig.getInstance().getAbilityLength();
-
     public static void handleFoodSkills(Player player, SkillType skill, FoodLevelChangeEvent event, int baseLevel, int maxLevel, int rankChange) {
         int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
 
@@ -391,7 +386,7 @@ public class SkillTools {
         }
 
         if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) {
-            int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / abilityLengthIncreaseLevel), ability.getMaxTicks());
+            int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks());
 
             ParticleEffectUtils.playAbilityEnabledEffect(player);
 

+ 1 - 1
src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java

@@ -143,7 +143,7 @@ public final class TreeFeller {
 
             for (BlockState blockState : treeFellerBlocks) {
                 if (BlockChecks.isLog(blockState) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) {
-                     durabilityLoss += SkillTools.toolDurabilityLoss;
+                     durabilityLoss += Config.getInstance().getAbilityToolDamage();
                 }
             }