diff --git a/src/main/java/com/gmail/nossr50/config/MainConfig.java b/src/main/java/com/gmail/nossr50/config/MainConfig.java index 7bbf555d0..ba7ebf890 100644 --- a/src/main/java/com/gmail/nossr50/config/MainConfig.java +++ b/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!"); } - if (getTreeFellerThreshold() <= 0) { + /*if (getTreeFellerThreshold() <= 0) { reason.add(ABILITIES + "." + LIMITS + "." + TREE_FELLER_THRESHOLD + " should be greater than 0!"); - } + }*/ if (getFishingLureModifier() < 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); } - /* - * 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 */ diff --git a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java b/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java index 07fb35c36..5f0963f9d 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java @@ -1,7 +1,18 @@ package com.gmail.nossr50.config.hocon.notifications; +import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable 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; + } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityLimits.java b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityLimits.java index 9e1cb9b10..48ca7bb77 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityLimits.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityLimits.java @@ -13,4 +13,11 @@ public class ConfigSectionSuperAbilityLimits { "\nDefault value: "+TOOL_DURABILITY_DAMAGE_DEFAULT) private int toolDurabilityDamage = TOOL_DURABILITY_DAMAGE_DEFAULT; + public ConfigSectionTreeFeller getTreeFeller() { + return treeFeller; + } + + public int getToolDurabilityDamage() { + return toolDurabilityDamage; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityMaxLength.java b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityMaxLength.java index d0ae4f487..38e431680 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityMaxLength.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionSuperAbilityMaxLength.java @@ -53,4 +53,5 @@ public class ConfigSectionSuperAbilityMaxLength { public int getTreeFeller() { return treeFeller; } + } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionTreeFeller.java b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionTreeFeller.java index d79e5a49c..e924373e0 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionTreeFeller.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSectionTreeFeller.java @@ -12,4 +12,8 @@ public class ConfigSectionTreeFeller { "\nLower this number to improve performance." + "\nDefault value: "+TREE_FELLER_LIMIT_DEFAULT) private int treeFellerLimit = TREE_FELLER_LIMIT_DEFAULT; + + public int getTreeFellerLimit() { + return treeFellerLimit; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSuperAbilities.java b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSuperAbilities.java index 743ec0d5c..1869dac46 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSuperAbilities.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSuperAbilities.java @@ -1,5 +1,7 @@ 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.serialize.ConfigSerializable; @@ -30,4 +32,74 @@ public class ConfigSuperAbilities { @Setting(value = "Super-Ability-Settings", comment = "Change specific parameters for super abilities.") 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; + } + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 2b8726e85..75b658a21 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -870,7 +870,7 @@ public class McMMOPlayer { } public void processAbilityActivation(PrimarySkillType skill) { - if (MainConfig.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) { + if (mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() && !player.isSneaking()) { return; } @@ -907,7 +907,7 @@ public class McMMOPlayer { } } - if (MainConfig.getInstance().getAbilityMessagesEnabled()) { + if (mcMMO.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) { NotificationManager.sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool()); SoundManager.sendSound(player, player.getLocation(), SoundType.TOOL_READY); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java index 2b8c47d60..f3b260fc4 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.datatypes.skills; import com.gmail.nossr50.config.MainConfig; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; @@ -100,11 +101,11 @@ public enum SuperAbilityType { } public int getCooldown() { - return MainConfig.getInstance().getCooldown(this); + return mcMMO.getConfigManager().getConfigSuperAbilities().getCooldownForSuper(this); } public int getMaxLength() { - return MainConfig.getInstance().getMaxLength(this); + return mcMMO.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(this); } public String getAbilityOn() { diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 9990b61f4..60915daff 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -565,7 +565,7 @@ public class PlayerListener implements Listener { case RIGHT_CLICK_BLOCK: Material type = block.getType(); - if (!MainConfig.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) { + if (!mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { /* REPAIR CHECKS */ if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) { RepairManager repairManager = mcMMOPlayer.getRepairManager(); @@ -605,7 +605,7 @@ public class PlayerListener implements Listener { case LEFT_CLICK_BLOCK: type = block.getType(); - if (!MainConfig.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) { + if (!mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { /* REPAIR CHECKS */ if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) { RepairManager repairManager = mcMMOPlayer.getRepairManager(); @@ -689,7 +689,7 @@ public class PlayerListener implements Listener { /* ACTIVATION & ITEM CHECKS */ if (BlockUtils.canActivateTools(blockState)) { - if (MainConfig.getInstance().getAbilitiesEnabled()) { + if (mcMMO.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) { if (BlockUtils.canActivateHerbalism(blockState)) { mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM); } @@ -743,7 +743,7 @@ public class PlayerListener implements Listener { } /* ACTIVATION CHECKS */ - if (MainConfig.getInstance().getAbilitiesEnabled()) { + if (mcMMO.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) { mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES); mcMMOPlayer.processAbilityActivation(PrimarySkillType.EXCAVATION); mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM); diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java index 0b5c41f26..978eac018 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java +++ b/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.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.ToolType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.NotificationManager; import org.bukkit.scheduler.BukkitRunnable; @@ -24,7 +25,7 @@ public class ToolLowerTask extends BukkitRunnable { mcMMOPlayer.setToolPreparationMode(tool, false); - if (MainConfig.getInstance().getAbilityMessagesEnabled()) { + if (mcMMO.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) { NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool()); } } diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index 92d61dfa0..73f54b4b8 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/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.SubSkillType; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -78,6 +79,6 @@ public class ExcavationManager extends SkillManager { excavationBlockCheck(blockState); excavationBlockCheck(blockState); - SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), MainConfig.getInstance().getAbilityToolDamage()); + SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage()); } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 8c5a36187..3dd8345f2 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -77,7 +77,7 @@ public class MiningManager extends SkillManager { Material material = blockState.getType(); 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)) { diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index 8a8eb7552..ac0cd0209 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -17,9 +17,6 @@ import java.util.List; import java.util.Set; public final class Woodcutting { - public static int treeFellerThreshold = MainConfig.getInstance().getTreeFellerThreshold(); - - protected static boolean treeFellerReachedThreshold = false; protected enum ExperienceGainMethod { @@ -152,7 +149,7 @@ public final class Woodcutting { for (BlockState blockState : treeFellerBlocks) { 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 - if (treeFellerBlocks.size() > treeFellerThreshold) { + if (treeFellerBlocks.size() > mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getTreeFeller().getTreeFellerLimit()) { treeFellerReachedThreshold = true; }