Browse Source

Wire up Super Ability config pt 1

nossr50 6 years ago
parent
commit
45430d9c25

+ 2 - 37
src/main/java/com/gmail/nossr50/config/MainConfig.java

@@ -367,9 +367,9 @@ public class MainConfig extends ConfigValidated {
             reason.add(COMMANDS + "." + INSPECT1 + "." + MAX_DISTANCE + " should be greater than 0!");
             reason.add(COMMANDS + "." + INSPECT1 + "." + MAX_DISTANCE + " should be greater than 0!");
         }
         }
 
 
-        if (getTreeFellerThreshold() <= 0) {
+        /*if (getTreeFellerThreshold() <= 0) {
             reason.add(ABILITIES + "." + LIMITS + "." + TREE_FELLER_THRESHOLD + " should be greater than 0!");
             reason.add(ABILITIES + "." + LIMITS + "." + TREE_FELLER_THRESHOLD + " should be greater than 0!");
-        }
+        }*/
 
 
         if (getFishingLureModifier() < 0) {
         if (getFishingLureModifier() < 0) {
             reason.add(ABILITIES + "." + FISHING + "." + LURE_MODIFIER + " should be at least 0!");
             reason.add(ABILITIES + "." + FISHING + "." + LURE_MODIFIER + " should be at least 0!");
@@ -675,41 +675,6 @@ public class MainConfig extends ConfigValidated {
         return getDoubleValue(COMMANDS, INSPECT1, MAX_DISTANCE);
         return getDoubleValue(COMMANDS, INSPECT1, MAX_DISTANCE);
     }
     }
 
 
-    /*
-     * ABILITY SETTINGS
-     */
-
-    /* General Settings */
-    public boolean getAbilityMessagesEnabled() {
-        return getBooleanValue(ABILITIES, MESSAGES);
-    }
-
-    public boolean getAbilitiesEnabled() {
-        return getBooleanValue(ABILITIES, ENABLED);
-    }
-
-    public boolean getAbilitiesOnlyActivateWhenSneaking() {
-        return getBooleanValue(ABILITIES, ACTIVATION, ONLY_ACTIVATE_WHEN_SNEAKING);
-    }
-
-    public int getCooldown(SuperAbilityType ability) {
-        return getIntValue(ABILITIES, COOLDOWNS + ability.toString());
-    }
-
-    public int getMaxLength(SuperAbilityType ability) {
-        return getIntValue(ABILITIES, MAX_SECONDS, ability.toString());
-    }
-
-    /* Durability Settings */
-    public int getAbilityToolDamage() {
-        return getIntValue(ABILITIES, TOOLS, DURABILITY_LOSS);
-    }
-
-    /* Thresholds */
-    public int getTreeFellerThreshold() {
-        return getIntValue(ABILITIES, LIMITS, TREE_FELLER_THRESHOLD);
-    }
-
     /*
     /*
      * SKILL SETTINGS
      * SKILL SETTINGS
      */
      */

+ 11 - 0
src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java

@@ -1,7 +1,18 @@
 package com.gmail.nossr50.config.hocon.notifications;
 package com.gmail.nossr50.config.hocon.notifications;
 
 
+import ninja.leaping.configurate.objectmapping.Setting;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 
 
 @ConfigSerializable
 @ConfigSerializable
 public class ConfigNotifications {
 public class ConfigNotifications {
+
+    public static final boolean SUPER_ABILITY_TOOL_NOTIFICATION_DEFAULT = true;
+
+    @Setting(value = "Super-Ability-Tool-Raising-Lowering-Notification",
+            comment = "Notifies the player when they go into the tool readying state for super abilities.")
+    private boolean superAbilityToolMessage = SUPER_ABILITY_TOOL_NOTIFICATION_DEFAULT;
+
+    public boolean isSuperAbilityToolMessage() {
+        return superAbilityToolMessage;
+    }
 }
 }

+ 7 - 0
src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityLimits.java

@@ -13,4 +13,11 @@ public class ConfigSectionSuperAbilityLimits {
             "\nDefault value: "+TOOL_DURABILITY_DAMAGE_DEFAULT)
             "\nDefault value: "+TOOL_DURABILITY_DAMAGE_DEFAULT)
     private int toolDurabilityDamage = TOOL_DURABILITY_DAMAGE_DEFAULT;
     private int toolDurabilityDamage = TOOL_DURABILITY_DAMAGE_DEFAULT;
 
 
+    public ConfigSectionTreeFeller getTreeFeller() {
+        return treeFeller;
+    }
+
+    public int getToolDurabilityDamage() {
+        return toolDurabilityDamage;
+    }
 }
 }

+ 1 - 0
src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityMaxLength.java

@@ -53,4 +53,5 @@ public class ConfigSectionSuperAbilityMaxLength {
     public int getTreeFeller() {
     public int getTreeFeller() {
         return treeFeller;
         return treeFeller;
     }
     }
+
 }
 }

+ 4 - 0
src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionTreeFeller.java

@@ -12,4 +12,8 @@ public class ConfigSectionTreeFeller {
             "\nLower this number to improve performance." +
             "\nLower this number to improve performance." +
             "\nDefault value: "+TREE_FELLER_LIMIT_DEFAULT)
             "\nDefault value: "+TREE_FELLER_LIMIT_DEFAULT)
     private int treeFellerLimit = TREE_FELLER_LIMIT_DEFAULT;
     private int treeFellerLimit = TREE_FELLER_LIMIT_DEFAULT;
+
+    public int getTreeFellerLimit() {
+        return treeFellerLimit;
+    }
 }
 }

+ 72 - 0
src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSuperAbilities.java

@@ -1,5 +1,7 @@
 package com.gmail.nossr50.config.hocon.superabilities;
 package com.gmail.nossr50.config.hocon.superabilities;
 
 
+import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
+import com.gmail.nossr50.mcMMO;
 import ninja.leaping.configurate.objectmapping.Setting;
 import ninja.leaping.configurate.objectmapping.Setting;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 
 
@@ -30,4 +32,74 @@ public class ConfigSuperAbilities {
 
 
     @Setting(value = "Super-Ability-Settings", comment = "Change specific parameters for super abilities.")
     @Setting(value = "Super-Ability-Settings", comment = "Change specific parameters for super abilities.")
     private ConfigSectionSuperAbilityLimits superAbilityLimits = new ConfigSectionSuperAbilityLimits();
     private ConfigSectionSuperAbilityLimits superAbilityLimits = new ConfigSectionSuperAbilityLimits();
+
+    public boolean isSuperAbilitiesEnabled() {
+        return superAbilitiesEnabled;
+    }
+
+    public boolean isMustSneakToActivate() {
+        return mustSneakToActivate;
+    }
+
+    public ConfigSectionSuperAbilityCooldowns getSuperAbilityCooldowns() {
+        return superAbilityCooldowns;
+    }
+
+    public ConfigSectionSuperAbilityMaxLength getSuperAbilityMaxLength() {
+        return superAbilityMaxLength;
+    }
+
+    public ConfigSectionSuperAbilityLimits getSuperAbilityLimits() {
+        return superAbilityLimits;
+    }
+
+    public int getCooldownForSuper(SuperAbilityType superAbilityType)
+    {
+        switch(superAbilityType)
+        {
+            case BERSERK:
+                return superAbilityCooldowns.getBerserk();
+            case GREEN_TERRA:
+                return superAbilityCooldowns.getGreenTerra();
+            case TREE_FELLER:
+                return superAbilityCooldowns.getTreeFeller();
+            case BLAST_MINING:
+                return superAbilityCooldowns.getBlastMining();
+            case SUPER_BREAKER:
+                return superAbilityCooldowns.getSuperBreaker();
+            case SKULL_SPLITTER:
+                return superAbilityCooldowns.getSkullSplitter();
+            case SERRATED_STRIKES:
+                return superAbilityCooldowns.getSerratedStrikes();
+            case GIGA_DRILL_BREAKER:
+                return superAbilityCooldowns.getGigaDrillBreaker();
+            default:
+                mcMMO.p.getLogger().severe("Cooldown Parameter not found for "+superAbilityType.toString());
+                return 240;
+        }
+    }
+
+    public int getMaxLengthForSuper(SuperAbilityType superAbilityType)
+    {
+        switch(superAbilityType)
+        {
+            case BERSERK:
+                return superAbilityMaxLength.getBerserk();
+            case GREEN_TERRA:
+                return superAbilityMaxLength.getGreenTerra();
+            case TREE_FELLER:
+                return superAbilityMaxLength.getTreeFeller();
+            case SUPER_BREAKER:
+                return superAbilityMaxLength.getSuperBreaker();
+            case SKULL_SPLITTER:
+                return superAbilityMaxLength.getSkullSplitter();
+            case SERRATED_STRIKES:
+                return superAbilityMaxLength.getSerratedStrikes();
+            case GIGA_DRILL_BREAKER:
+                return superAbilityMaxLength.getGigaDrillBreaker();
+            default:
+                mcMMO.p.getLogger().severe("Max Length Parameter not found for "+superAbilityType.toString());
+                return 60;
+        }
+    }
 }
 }

+ 2 - 2
src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java

@@ -870,7 +870,7 @@ public class McMMOPlayer {
     }
     }
 
 
     public void processAbilityActivation(PrimarySkillType skill) {
     public void processAbilityActivation(PrimarySkillType skill) {
-        if (MainConfig.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
+        if (mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() && !player.isSneaking()) {
             return;
             return;
         }
         }
 
 
@@ -907,7 +907,7 @@ public class McMMOPlayer {
                 }
                 }
             }
             }
 
 
-            if (MainConfig.getInstance().getAbilityMessagesEnabled()) {
+            if (mcMMO.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) {
                 NotificationManager.sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool());
                 NotificationManager.sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool());
                 SoundManager.sendSound(player, player.getLocation(), SoundType.TOOL_READY);
                 SoundManager.sendSound(player, player.getLocation(), SoundType.TOOL_READY);
             }
             }

+ 3 - 2
src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java

@@ -1,6 +1,7 @@
 package com.gmail.nossr50.datatypes.skills;
 package com.gmail.nossr50.datatypes.skills;
 
 
 import com.gmail.nossr50.config.MainConfig;
 import com.gmail.nossr50.config.MainConfig;
+import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.util.BlockUtils;
 import com.gmail.nossr50.util.BlockUtils;
 import com.gmail.nossr50.util.Permissions;
 import com.gmail.nossr50.util.Permissions;
 import com.gmail.nossr50.util.StringUtils;
 import com.gmail.nossr50.util.StringUtils;
@@ -100,11 +101,11 @@ public enum SuperAbilityType {
     }
     }
 
 
     public int getCooldown() {
     public int getCooldown() {
-        return MainConfig.getInstance().getCooldown(this);
+        return mcMMO.getConfigManager().getConfigSuperAbilities().getCooldownForSuper(this);
     }
     }
 
 
     public int getMaxLength() {
     public int getMaxLength() {
-        return MainConfig.getInstance().getMaxLength(this);
+        return mcMMO.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(this);
     }
     }
 
 
     public String getAbilityOn() {
     public String getAbilityOn() {

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

@@ -565,7 +565,7 @@ public class PlayerListener implements Listener {
             case RIGHT_CLICK_BLOCK:
             case RIGHT_CLICK_BLOCK:
                 Material type = block.getType();
                 Material type = block.getType();
 
 
-                if (!MainConfig.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
+                if (!mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) {
                     /* REPAIR CHECKS */
                     /* REPAIR CHECKS */
                     if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
                     if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
                         RepairManager repairManager = mcMMOPlayer.getRepairManager();
                         RepairManager repairManager = mcMMOPlayer.getRepairManager();
@@ -605,7 +605,7 @@ public class PlayerListener implements Listener {
             case LEFT_CLICK_BLOCK:
             case LEFT_CLICK_BLOCK:
                 type = block.getType();
                 type = block.getType();
 
 
-                if (!MainConfig.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
+                if (!mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) {
                     /* REPAIR CHECKS */
                     /* REPAIR CHECKS */
                     if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
                     if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
                         RepairManager repairManager = mcMMOPlayer.getRepairManager();
                         RepairManager repairManager = mcMMOPlayer.getRepairManager();
@@ -689,7 +689,7 @@ public class PlayerListener implements Listener {
 
 
                 /* ACTIVATION & ITEM CHECKS */
                 /* ACTIVATION & ITEM CHECKS */
                 if (BlockUtils.canActivateTools(blockState)) {
                 if (BlockUtils.canActivateTools(blockState)) {
-                    if (MainConfig.getInstance().getAbilitiesEnabled()) {
+                    if (mcMMO.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) {
                         if (BlockUtils.canActivateHerbalism(blockState)) {
                         if (BlockUtils.canActivateHerbalism(blockState)) {
                             mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
                             mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
                         }
                         }
@@ -743,7 +743,7 @@ public class PlayerListener implements Listener {
                 }
                 }
                 
                 
                 /* ACTIVATION CHECKS */
                 /* ACTIVATION CHECKS */
-                if (MainConfig.getInstance().getAbilitiesEnabled()) {
+                if (mcMMO.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) {
                     mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
                     mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
                     mcMMOPlayer.processAbilityActivation(PrimarySkillType.EXCAVATION);
                     mcMMOPlayer.processAbilityActivation(PrimarySkillType.EXCAVATION);
                     mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
                     mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);

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

@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.MainConfig;
 import com.gmail.nossr50.datatypes.interactions.NotificationType;
 import com.gmail.nossr50.datatypes.interactions.NotificationType;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.skills.ToolType;
 import com.gmail.nossr50.datatypes.skills.ToolType;
+import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.util.player.NotificationManager;
 import com.gmail.nossr50.util.player.NotificationManager;
 import org.bukkit.scheduler.BukkitRunnable;
 import org.bukkit.scheduler.BukkitRunnable;
 
 
@@ -24,7 +25,7 @@ public class ToolLowerTask extends BukkitRunnable {
 
 
         mcMMOPlayer.setToolPreparationMode(tool, false);
         mcMMOPlayer.setToolPreparationMode(tool, false);
 
 
-        if (MainConfig.getInstance().getAbilityMessagesEnabled()) {
+        if (mcMMO.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) {
             NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool());
             NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool());
         }
         }
     }
     }

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

@@ -6,6 +6,7 @@ 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.treasure.ExcavationTreasure;
 import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
+import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.skills.SkillManager;
 import com.gmail.nossr50.skills.SkillManager;
 import com.gmail.nossr50.util.Misc;
 import com.gmail.nossr50.util.Misc;
 import com.gmail.nossr50.util.Permissions;
 import com.gmail.nossr50.util.Permissions;
@@ -78,6 +79,6 @@ public class ExcavationManager extends SkillManager {
         excavationBlockCheck(blockState);
         excavationBlockCheck(blockState);
         excavationBlockCheck(blockState);
         excavationBlockCheck(blockState);
 
 
-        SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), MainConfig.getInstance().getAbilityToolDamage());
+        SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage());
     }
     }
 }
 }

+ 1 - 1
src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java

@@ -77,7 +77,7 @@ public class MiningManager extends SkillManager {
         Material material = blockState.getType();
         Material material = blockState.getType();
 
 
         if (mcMMOPlayer.getAbilityMode(skill.getAbility())) {
         if (mcMMOPlayer.getAbilityMode(skill.getAbility())) {
-            SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), MainConfig.getInstance().getAbilityToolDamage());
+            SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage());
         }
         }
 
 
         //if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || !MainConfig.getInstance().getDoubleDropsEnabled(skill, material)) {
         //if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || !MainConfig.getInstance().getDoubleDropsEnabled(skill, material)) {

+ 2 - 5
src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java

@@ -17,9 +17,6 @@ import java.util.List;
 import java.util.Set;
 import java.util.Set;
 
 
 public final class Woodcutting {
 public final class Woodcutting {
-    public static int treeFellerThreshold = MainConfig.getInstance().getTreeFellerThreshold();
-
-
     protected static boolean treeFellerReachedThreshold = false;
     protected static boolean treeFellerReachedThreshold = false;
 
 
     protected enum ExperienceGainMethod {
     protected enum ExperienceGainMethod {
@@ -152,7 +149,7 @@ public final class Woodcutting {
 
 
         for (BlockState blockState : treeFellerBlocks) {
         for (BlockState blockState : treeFellerBlocks) {
             if (BlockUtils.isLog(blockState)) {
             if (BlockUtils.isLog(blockState)) {
-                durabilityLoss += MainConfig.getInstance().getAbilityToolDamage();
+                durabilityLoss += mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage();
             }
             }
         }
         }
 
 
@@ -178,7 +175,7 @@ public final class Woodcutting {
         }
         }
 
 
         // Without this check Tree Feller propagates through leaves until the threshold is hit
         // Without this check Tree Feller propagates through leaves until the threshold is hit
-        if (treeFellerBlocks.size() > treeFellerThreshold) {
+        if (treeFellerBlocks.size() > mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getTreeFeller().getTreeFellerLimit()) {
             treeFellerReachedThreshold = true;
             treeFellerReachedThreshold = true;
         }
         }