mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
2.1.0 is probably playable now, but not unfinished
This commit is contained in:
@ -37,11 +37,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
// Validate all the settings!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
/*
|
||||
* In the future this method will check keys for all skills, but for now it only checks overhauled skills
|
||||
*/
|
||||
checkKeys(reason);
|
||||
|
||||
/* GENERAL */
|
||||
if (getAbilityLengthRetro() < 1) {
|
||||
reason.add("Skills.General.Ability.Length.RetroMode.IncreaseLevel should be at least 1!");
|
||||
@ -814,51 +809,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
return config.getBoolean(keyLocation);
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* Gets the level required to unlock a subskill at a given rank
|
||||
* @param subSkillType The subskill
|
||||
* @param rank The rank of the skill
|
||||
* @return The level required to use this rank of the subskill
|
||||
* @deprecated Right now mcMMO is an overhaul process, this will only work for skills I have overhauled. I will be removing the deprecated tag when that is true.
|
||||
*/
|
||||
@Deprecated
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank)
|
||||
{
|
||||
/*
|
||||
* This is a bit messy but
|
||||
*
|
||||
* Some skills have per-rank settings as child nodes for Rank_x nodes
|
||||
* If they do, we have to grab the child node named LevelReq from Rank_x for that skill
|
||||
*
|
||||
* Other skills which do not have complex per-rank settings will instead find their Level Requirement returned at Rank_x
|
||||
*/
|
||||
if(config.get(subSkillType.getAdvConfigAddress() + ".Rank_Levels.Rank_"+rank+".LevelReq") != null)
|
||||
return config.getInt(subSkillType.getAdvConfigAddress() + ".Rank_Levels.Rank_"+rank+".LevelReq");
|
||||
else
|
||||
return config.getInt(subSkillType.getAdvConfigAddress() + ".Rank_Levels.Rank_"+rank);
|
||||
}
|
||||
|
||||
@Deprecated /* NEW VERSION */
|
||||
public int getSubSkillUnlockLevel(AbstractSubSkill abstractSubSkill, int rank)
|
||||
{
|
||||
/*
|
||||
* This is a bit messy but
|
||||
*
|
||||
* Some skills have per-rank settings as child nodes for Rank_x nodes
|
||||
* If they do, we have to grab the child node named LevelReq from Rank_x for that skill
|
||||
*
|
||||
* Other skills which do not have complex per-rank settings will instead find their Level Requirement returned at Rank_x
|
||||
*/
|
||||
|
||||
String key = "Skills."+abstractSubSkill.getPrimaryKeyName()+"."+abstractSubSkill.getConfigKeyName();
|
||||
|
||||
if(config.get(key + ".Rank_Levels.Rank_"+rank+".LevelReq") != null)
|
||||
return config.getInt(key + ".Rank_Levels.Rank_"+rank+".LevelReq");
|
||||
else
|
||||
return config.getInt(key + ".Rank_Levels.Rank_"+rank);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some SubSkills have the ability to retain classic functionality
|
||||
* @param subSkillType SubSkillType with classic functionality
|
||||
@ -1034,39 +984,4 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", ""); }
|
||||
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", ""); }
|
||||
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", ""); }
|
||||
|
||||
/**
|
||||
* Checks for valid keys in the advanced.yml file for subskill ranks
|
||||
*/
|
||||
private void checkKeys(List<String> reasons)
|
||||
{
|
||||
//For now we will only check ranks of stuff I've overhauled
|
||||
for(SubSkillType subSkillType : SubSkillType.values())
|
||||
{
|
||||
if(subSkillType.getParentSkill() == PrimarySkillType.WOODCUTTING)
|
||||
{
|
||||
//Keeping track of the rank requirements and making sure there are no logical errors
|
||||
int curRank = 0;
|
||||
int prevRank = 0;
|
||||
|
||||
for(int x = 0; x < subSkillType.getNumRanks(); x++)
|
||||
{
|
||||
if(curRank > 0)
|
||||
prevRank = curRank;
|
||||
|
||||
curRank = getSubSkillUnlockLevel(subSkillType, x);
|
||||
|
||||
//Do we really care if its below 0? Probably not
|
||||
if(curRank < 0)
|
||||
reasons.add(subSkillType.getAdvConfigAddress() + ".Rank_Levels.Rank_"+curRank+".LevelReq should be above or equal to 0!");
|
||||
|
||||
if(prevRank > curRank)
|
||||
{
|
||||
//We're going to allow this but we're going to warn them
|
||||
plugin.getLogger().info("You have the ranks for the subskill "+ subSkillType.toString()+" set up poorly, sequential ranks should have ascending requirements");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -557,9 +557,10 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||
}
|
||||
|
||||
public int getSkillAbilityGate(PrimarySkillType skill) {
|
||||
|
||||
/*public int isSuperAbilityUnlocked(PrimarySkillType skill) {
|
||||
return config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Ability_Activation_Level_Gate");
|
||||
}
|
||||
}*/
|
||||
|
||||
public boolean getTruncateSkills() { return config.getBoolean("General.TruncateSkills", false); }
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RankConfig extends AutoUpdateConfigLoader {
|
||||
private static RankConfig instance;
|
||||
|
||||
@ -22,4 +28,93 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
/*
|
||||
* In the future this method will check keys for all skills, but for now it only checks overhauled skills
|
||||
*/
|
||||
checkKeys(reason);
|
||||
|
||||
return noErrorsInConfig(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
* @param subSkillType target subskill
|
||||
* @param rank the rank we are checking
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank)
|
||||
{
|
||||
String key = subSkillType.getRankConfigAddress();
|
||||
|
||||
return findRankByRootAddress(rank, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
* @param abstractSubSkill target subskill
|
||||
* @param rank the rank we are checking
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
public int getSubSkillUnlockLevel(AbstractSubSkill abstractSubSkill, int rank)
|
||||
{
|
||||
String key = abstractSubSkill.getPrimaryKeyName()+"."+abstractSubSkill.getConfigKeyName();
|
||||
|
||||
return findRankByRootAddress(rank, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
* @param key root address of the subskill in the rankskills.yml file
|
||||
* @param rank the rank we are checking
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
private int findRankByRootAddress(int rank, String key) {
|
||||
String scalingKey = Config.getInstance().getIsRetroMode() ? ".RetroMode." : ".Standard.";
|
||||
|
||||
String targetRank = "Rank_" + rank;
|
||||
|
||||
key += scalingKey;
|
||||
key += targetRank;
|
||||
|
||||
return config.getInt(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for valid keys for subskill ranks
|
||||
*/
|
||||
private void checkKeys(List<String> reasons)
|
||||
{
|
||||
//For now we will only check ranks of stuff I've overhauled
|
||||
for(SubSkillType subSkillType : SubSkillType.values())
|
||||
{
|
||||
//Keeping track of the rank requirements and making sure there are no logical errors
|
||||
int curRank = 0;
|
||||
int prevRank = 0;
|
||||
|
||||
for(int x = 0; x < subSkillType.getNumRanks(); x++)
|
||||
{
|
||||
if(curRank > 0)
|
||||
prevRank = curRank;
|
||||
|
||||
curRank = getSubSkillUnlockLevel(subSkillType, x);
|
||||
|
||||
//Do we really care if its below 0? Probably not
|
||||
if(curRank < 0)
|
||||
{
|
||||
reasons.add(subSkillType.getAdvConfigAddress() + ".Rank_Levels.Rank_"+curRank+".LevelReq should be above or equal to 0!");
|
||||
}
|
||||
|
||||
if(prevRank > curRank)
|
||||
{
|
||||
//We're going to allow this but we're going to warn them
|
||||
plugin.getLogger().info("You have the ranks for the subskill "+ subSkillType.toString()+" set up poorly, sequential ranks should have ascending requirements");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user