mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-24 17:47:44 +01:00
Wire up Super Ability config pt 1
This commit is contained in:
parent
e933efcee0
commit
45430d9c25
@ -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
|
||||
*/
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -53,4 +53,5 @@ public class ConfigSectionSuperAbilityMaxLength {
|
||||
public int getTreeFeller() {
|
||||
return treeFeller;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user