Add Smelting config options

This commit is contained in:
nossr50 2019-06-16 09:10:59 -07:00
parent 84704007ac
commit 303b12b79f
19 changed files with 146 additions and 239 deletions

View File

@ -96,7 +96,7 @@ public class McrankCommand implements TabExecutor {
return;
}
long cooldownMillis = Math.max(MainConfig.getInstance().getDatabasePlayerCooldown(), 1750);
long cooldownMillis = 5000;
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis)));

View File

@ -89,7 +89,7 @@ public class MctopCommand implements TabExecutor {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
long cooldownMillis = Math.max(MainConfig.getInstance().getDatabasePlayerCooldown(), 1750);
long cooldownMillis = 5000;
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000;

View File

@ -158,36 +158,6 @@ public class AdvancedConfig extends ConfigValidated {
/* GENERAL */
/**
* This returns the maximum level at which superabilities will stop lengthening from scaling alongside skill level.
* It returns a different value depending on whether or not the server is in retro mode
*
* @return the level at which abilities stop increasing in length
*/
public int getAbilityLengthCap() {
if (!mcMMO.isRetroModeEnabled())
return getIntValue(SKILLS, GENERAL, ABILITY, LENGTH, STANDARD, CAP_LEVEL);
else
return getIntValue(SKILLS, GENERAL, ABILITY, LENGTH, RETRO_MODE, CAP_LEVEL);
}
/**
* This returns the frequency at which abilities will increase in length
* It returns a different value depending on whether or not the server is in retro mode
*
* @return the number of levels required per ability length increase
*/
public int getAbilityLength() {
if (!mcMMO.isRetroModeEnabled())
return getIntValue(SKILLS, GENERAL, ABILITY, LENGTH, STANDARD, INCREASE_LEVEL);
else
return getIntValue(SKILLS, GENERAL, ABILITY, LENGTH, RETRO_MODE, INCREASE_LEVEL);
}
public int getEnchantBuff() {
return getIntValue(SKILLS, GENERAL, ABILITY, ENCHANT_BUFF);
}
/* Notification Settings */
/* FISHING */
@ -204,30 +174,6 @@ public class AdvancedConfig extends ConfigValidated {
}
/* MINING */
public boolean getDoubleDropSilkTouchEnabled() {
return getBooleanValue(SKILLS, MINING, "DoubleDrops", "SilkTouch");
}
public double getBlastDamageDecrease(int rank) {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, BLAST_DAMAGE_DECREASE, RANK, String.valueOf(rank));
}
public double getOreBonus(int rank) {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, ORE_BONUS, RANK, String.valueOf(rank));
}
public double getDebrisReduction(int rank) {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, DEBRIS_REDUCTION, RANK, String.valueOf(rank));
}
public int getDropMultiplier(int rank) {
return getIntValue(SKILLS, MINING, BLAST_MINING, DROP_MULTIPLIER, RANK, String.valueOf(rank));
}
public double getBlastRadiusModifier(int rank) {
return getDoubleValue(SKILLS, MINING, BLAST_MINING, BLAST_RADIUS, MODIFIER, RANK, String.valueOf(rank));
}
public double getArcaneSalvageExtractFullEnchantsChance(int rank) {
return getDoubleValue(SKILLS, SALVAGE, ARCANE_SALVAGE, EXTRACT_FULL_ENCHANT, RANK, String.valueOf(rank));
}
@ -289,4 +235,5 @@ public class AdvancedConfig extends ConfigValidated {
public double getMaxHorseJumpStrength() {
return getDoubleValue(SKILLS, TAMING, CALL_OF_THE_WILD, MAX_HORSE_JUMP_STRENGTH);
}
}

View File

@ -139,7 +139,6 @@ public final class ConfigManager {
private ExcavationTreasureConfig excavationTreasureConfig;
private HerbalismTreasureConfig herbalismTreasureConfig;
private AdvancedConfig advancedConfig;
private SoundConfig soundConfig;
/* CONFIG ERRORS */
@ -351,10 +350,6 @@ public final class ConfigManager {
return configCoreSkills.getConfig();
}
public SoundConfig getSoundConfig() {
return soundConfig;
}
public ConfigDatabase getConfigDatabase() {
return configDatabase.getConfig();
}

View File

@ -234,74 +234,6 @@ public class MainConfig extends ConfigValidated {
return reason;
}
/*
* GENERAL SETTINGS
*/
public boolean getShowProfileLoadedMessage() {
return getBooleanValue(GENERAL, SHOW_PROFILE_LOADED);
}
public boolean getMatchOfflinePlayers() {
return getBooleanValue(COMMANDS, GENERIC, MATCH_OFFLINE_PLAYERS);
}
public long getDatabasePlayerCooldown() {
return getLongValue(COMMANDS, DATABASE, PLAYER_COOLDOWN);
}
public boolean getLevelUpSoundsEnabled() {
return getBooleanValue(GENERAL, LEVEL_UP_SOUNDS);
}
public boolean getRefreshChunksEnabled() {
return getBooleanValue(GENERAL, REFRESH_CHUNKS);
}
/* Particles */
public boolean getAbilityActivationEffectEnabled() {
return getBooleanValue(PARTICLES, ABILITY_ACTIVATION);
}
public boolean getAbilityDeactivationEffectEnabled() {
return getBooleanValue(PARTICLES, ABILITY_DEACTIVATION);
}
public boolean getBleedEffectEnabled() {
return getBooleanValue(PARTICLES, BLEED);
}
public boolean getDodgeEffectEnabled() {
return getBooleanValue(PARTICLES, DODGE);
}
public boolean getFluxEffectEnabled() {
return getBooleanValue(PARTICLES, FLUX);
}
public boolean getGreaterImpactEffectEnabled() {
return getBooleanValue(PARTICLES, GREATER_IMPACT);
}
public boolean getCallOfTheWildEffectEnabled() {
return getBooleanValue(PARTICLES, CALL_OF_THE_WILD);
}
public boolean getLevelUpEffectsEnabled() {
return getBooleanValue(PARTICLES, LEVEL_UP + ENABLED);
}
public int getLevelUpEffectsTier() {
return getIntValue(PARTICLES, LEVEL_UP + TIER);
}
/*
* SKILL SETTINGS
*/
public boolean getDoubleDropsEnabled(PrimarySkillType skill, Material material) {
return getBooleanValue(DOUBLE_DROPS, StringUtils.getCapitalized(skill.toString()), StringUtils.getPrettyItemString(material).replace(" ", "_"));
}
public boolean getPreventHopperTransferIngredients() {
return getBooleanValue(SKILLS, ALCHEMY, PREVENT_HOPPER_TRANSFER_INGREDIENTS);
}

View File

@ -1,82 +0,0 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.sounds.SoundType;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.ArrayList;
import java.util.List;
@ConfigSerializable
public class SoundConfig extends ConfigValidated {
public static final String SOUNDS = "Sounds";
public static final String VOLUME = "Volume";
public static final String PITCH = "Pitch";
public static final String ENABLED = "Enabled";
public static final String MASTER_VOLUME = "MasterVolume";
//private static SoundConfig instance;
public SoundConfig() {
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "sounds.yml", true);
super("sounds", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true);
}
/**
* This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future
*
* @return the instance of this config
* @see mcMMO#getConfigManager()
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
*/
@Deprecated
public static SoundConfig getInstance() {
return mcMMO.getConfigManager().getSoundConfig();
}
/**
* The version of this config
*
* @return
*/
@Override
public double getConfigVersion() {
return 1;
}
@Override
public List<String> validateKeys() {
ArrayList<String> reasons = new ArrayList<>();
for (SoundType soundType : SoundType.values()) {
if (getDoubleValue(SOUNDS, soundType.toString(), VOLUME) < 0) {
reasons.add("[mcMMO] Sound volume cannot be below 0 for " + soundType.toString());
}
//Sounds with custom pitching don't use pitch values
if (!soundType.usesCustomPitch()) {
if (getDoubleValue(SOUNDS, soundType.toString(), PITCH) < 0) {
reasons.add("[mcMMO] Sound pitch cannot be below 0 for " + soundType.toString());
}
}
}
return reasons;
}
public float getMasterVolume() {
return (float) getDoubleValue(SOUNDS, MASTER_VOLUME);
}
public float getVolume(SoundType soundType) {
return (float) getDoubleValue(SOUNDS, soundType.toString(), VOLUME);
}
public float getPitch(SoundType soundType) {
return (float) getDoubleValue(SOUNDS, soundType.toString(), PITCH);
}
public boolean getIsEnabled(SoundType soundType) {
return getBooleanValue(SOUNDS, soundType.toString(), ENABLED);
}
}

View File

@ -15,6 +15,13 @@ public class ConfigCommands {
@Setting(value = "Skills", comment = "Settings related to skill commands like /mining or /herbalism")
private ConfigCommandsSkills skills = new ConfigCommandsSkills();
@Setting(value = "Misc", comment = "Various settings for commands that don't fit into other categories.")
private ConfigCommandsMisc misc = new ConfigCommandsMisc();
public ConfigCommandsMisc getMisc() {
return misc;
}
public ConfigCommandsAdminChat getAdminChat() {
return adminChat;
}

View File

@ -0,0 +1,16 @@
package com.gmail.nossr50.config.hocon.commands;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigCommandsMisc {
private static final boolean MATCH_OFFLINE = true;
@Setting(value = "Match-Offline", comment = "If set to true mcMMO will attempt to match player names from commands to any player that exists in the DB, otherwise it will only try to match online players.")
private boolean matchOffline = MATCH_OFFLINE;
public boolean isMatchOfflinePlayers() {
return matchOffline;
}
}

View File

@ -1,8 +1,36 @@
package com.gmail.nossr50.config.hocon.skills.smelting;
import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.HashMap;
@ConfigSerializable
public class ConfigSmelting {
@Setting(value = ConfigConstants.SUB_SKILL_NODE)
private ConfigSmeltingSubSkills subskills = new ConfigSmeltingSubSkills();
public ConfigSmeltingSubSkills getSubskills() {
return subskills;
}
public ConfigSmeltingSecondSmelt getSmeltingSecondSmelt() {
return subskills.getSmeltingSecondSmelt();
}
public double getMaxChance() {
return subskills.getMaxChance();
}
public MaxBonusLevel getMaxBonusLevel() {
return subskills.getMaxBonusLevel();
}
public HashMap<Integer, Integer> getXpMultiplierTable() {
return subskills.getXpMultiplierTable();
}
}

View File

@ -0,0 +1,48 @@
package com.gmail.nossr50.config.hocon.skills.smelting;
import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.datatypes.skills.properties.AbstractMaxBonusLevel;
import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.HashMap;
@ConfigSerializable
public class ConfigSmeltingSecondSmelt {
private final static HashMap<Integer, Integer> XP_MULT_MAP_DEFAULT;
static {
XP_MULT_MAP_DEFAULT = new HashMap<>();
XP_MULT_MAP_DEFAULT.put(1, 1);
XP_MULT_MAP_DEFAULT.put(2, 2);
XP_MULT_MAP_DEFAULT.put(3, 3);
XP_MULT_MAP_DEFAULT.put(4, 3);
XP_MULT_MAP_DEFAULT.put(5, 4);
XP_MULT_MAP_DEFAULT.put(6, 4);
XP_MULT_MAP_DEFAULT.put(7, 5);
XP_MULT_MAP_DEFAULT.put(8, 5);
}
@Setting(value = ConfigConstants.MAX_CHANCE_FIELD_NAME, comment = ConfigConstants.MAX_CHANCE_FIELD_DESCRIPTION)
private double maxChance = 50.0;
@Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME, comment = ConfigConstants.MAX_BONUS_LEVEL_DESCRIPTION)
private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100);
public double getMaxChance() {
return maxChance;
}
public MaxBonusLevel getMaxBonusLevel() {
return maxBonusLevel;
}
@Setting(value = "XP-Multiplier-Per-Rank")
private HashMap<Integer, Integer> xpMultiplierTable = XP_MULT_MAP_DEFAULT;
public HashMap<Integer, Integer> getXpMultiplierTable() {
return xpMultiplierTable;
}
}

View File

@ -0,0 +1,30 @@
package com.gmail.nossr50.config.hocon.skills.smelting;
import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.HashMap;
@ConfigSerializable
public class ConfigSmeltingSubSkills {
@Setting(value = "Second-Smelt")
private ConfigSmeltingSecondSmelt smeltingSecondSmelt = new ConfigSmeltingSecondSmelt();
public ConfigSmeltingSecondSmelt getSmeltingSecondSmelt() {
return smeltingSecondSmelt;
}
public double getMaxChance() {
return smeltingSecondSmelt.getMaxChance();
}
public MaxBonusLevel getMaxBonusLevel() {
return smeltingSecondSmelt.getMaxBonusLevel();
}
public HashMap<Integer, Integer> getXpMultiplierTable() {
return smeltingSecondSmelt.getXpMultiplierTable();
}
}

View File

@ -238,9 +238,7 @@ public class Party {
if (leader != null) {
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
if (MainConfig.getInstance().getLevelUpSoundsEnabled()) {
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
}
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
}
return;
}

View File

@ -41,7 +41,6 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.experience.ExperienceBarManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
@ -590,9 +589,7 @@ public class McMMOPlayer {
return;
}
if (MainConfig.getInstance().getLevelUpSoundsEnabled()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
}
SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
/*
* Check to see if the player unlocked any new skills

View File

@ -22,7 +22,6 @@ import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.worldguard.WorldGuardManager;
@ -562,7 +561,6 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockDamageCleanup(BlockDamageEvent event) {
Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Profile not loaded
if (UserManager.getPlayer(player) == null) {

View File

@ -821,13 +821,10 @@ public final class PartyManager {
* @param level The current party level
*/
public static void informPartyMembersLevelUp(Party party, int levelsGained, int level) {
boolean levelUpSoundsEnabled = MainConfig.getInstance().getLevelUpSoundsEnabled();
for (Player member : party.getOnlineMembers()) {
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));
if (levelUpSoundsEnabled) {
SoundManager.sendSound(member, member.getLocation(), SoundType.LEVEL_UP);
}
SoundManager.sendSound(member, member.getLocation(), SoundType.LEVEL_UP);
}
}

View File

@ -1,13 +1,11 @@
package com.gmail.nossr50.runnables.skills;
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.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Chunk;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util.commands;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
@ -270,7 +269,7 @@ public final class CommandUtils {
* @return Matched name or {@code partialName} if no match was found
*/
public static String getMatchedPlayerName(String partialName) {
if (MainConfig.getInstance().getMatchOfflinePlayers()) {
if (mcMMO.getConfigManager().getConfigCommands().getMisc().isMatchOfflinePlayers()) {
List<String> matches = matchPlayer(partialName);
if (matches.size() == 1) {

View File

@ -16,25 +16,25 @@ public final class ParticleEffectUtils {
}
public static void playBleedEffect(LivingEntity livingEntity) {
if (!MainConfig.getInstance().getBleedEffectEnabled()) {
/*if (!MainConfig.getInstance().getBleedEffectEnabled()) {
return;
}
}*/
livingEntity.getWorld().playEffect(livingEntity.getEyeLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE);
}
public static void playDodgeEffect(Player player) {
if (!MainConfig.getInstance().getDodgeEffectEnabled()) {
/*if (!MainConfig.getInstance().getDodgeEffectEnabled()) {
return;
}
}*/
playSmokeEffect(player);
}
public static void playFluxEffect(Location location) {
if (!MainConfig.getInstance().getFluxEffectEnabled()) {
/*if (!MainConfig.getInstance().getFluxEffectEnabled()) {
return;
}
}*/
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 1);
}
@ -56,9 +56,9 @@ public final class ParticleEffectUtils {
}
public static void playGreaterImpactEffect(LivingEntity livingEntity) {
if (!MainConfig.getInstance().getGreaterImpactEffectEnabled()) {
/*if (!MainConfig.getInstance().getGreaterImpactEffectEnabled()) {
return;
}
}*/
Location location = livingEntity.getEyeLocation();
@ -66,9 +66,9 @@ public final class ParticleEffectUtils {
}
public static void playCallOfTheWildEffect(LivingEntity livingEntity) {
if (!MainConfig.getInstance().getCallOfTheWildEffectEnabled()) {
/*if (!MainConfig.getInstance().getCallOfTheWildEffectEnabled()) {
return;
}
}*/
livingEntity.getWorld().playEffect(livingEntity.getEyeLocation(), Effect.MOBSPAWNER_FLAMES, 1);
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.interactions.NotificationType;