mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
We've got these functions, might as well use them.
This commit is contained in:
parent
a2f80569e3
commit
0c52b3016c
@ -506,11 +506,7 @@ public final class ExperienceAPI {
|
||||
int powerLevel = 0;
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType type : SkillType.nonChildSkills()) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
|
||||
|
@ -294,11 +294,7 @@ public final class FlatfileDatabaseManager {
|
||||
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||
}
|
||||
|
||||
|
@ -415,11 +415,7 @@ public final class SQLDatabaseManager {
|
||||
|
||||
if (checkConnected()) {
|
||||
try {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
String skillName = skillType.name().toLowerCase();
|
||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
|
@ -441,11 +441,7 @@ public class McMMOPlayer {
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType type : SkillType.nonChildSkills()) {
|
||||
if (Permissions.skillEnabled(player, type)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
|
@ -49,11 +49,7 @@ public class PlayerProfile {
|
||||
skillsDATS.put(abilityType, 0);
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
skills.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0F);
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill() || (player != null && !Permissions.skillEnabled(player, skill))) {
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
if (player != null && !Permissions.skillEnabled(player, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -19,44 +19,42 @@ public class ChildConfig extends AutoUpdateConfigLoader {
|
||||
protected void loadKeys() {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill()) {
|
||||
plugin.debug("Finding parents of " + skill.name());
|
||||
for (SkillType skill : SkillType.childSkills()) {
|
||||
plugin.debug("Finding parents of " + skill.name());
|
||||
|
||||
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
|
||||
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
|
||||
boolean useDefaults = false; // If we had an error we back out and use defaults
|
||||
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
|
||||
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
|
||||
boolean useDefaults = false; // If we had an error we back out and use defaults
|
||||
|
||||
for (String name : parentNames) {
|
||||
try {
|
||||
SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase());
|
||||
FamilyTree.enforceNotChildSkill(parentSkill);
|
||||
parentSkills.add(parentSkill);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
|
||||
useDefaults = true;
|
||||
break;
|
||||
}
|
||||
for (String name : parentNames) {
|
||||
try {
|
||||
SkillType parentSkill = SkillType.valueOf(name.toUpperCase());
|
||||
FamilyTree.enforceNotChildSkill(parentSkill);
|
||||
parentSkills.add(parentSkill);
|
||||
}
|
||||
|
||||
if (useDefaults) {
|
||||
parentSkills.clear();
|
||||
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
|
||||
/* We do less checks in here because it's from inside our jar.
|
||||
* If they're dedicated enough to have modified it, they can have the errors it may produce.
|
||||
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
|
||||
*/
|
||||
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
|
||||
useDefaults = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Register them
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
|
||||
FamilyTree.registerParent(skill, parentSkill);
|
||||
if (useDefaults) {
|
||||
parentSkills.clear();
|
||||
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
|
||||
/* We do less checks in here because it's from inside our jar.
|
||||
* If they're dedicated enough to have modified it, they can have the errors it may produce.
|
||||
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
|
||||
*/
|
||||
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
||||
// Register them
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
|
||||
FamilyTree.registerParent(skill, parentSkill);
|
||||
}
|
||||
}
|
||||
|
||||
FamilyTree.closeRegistration();
|
||||
|
@ -21,11 +21,7 @@ public final class HardcoreManager {
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||
int totalLost = 0;
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
|
||||
|
||||
if (playerSkillLevel <= 0) {
|
||||
@ -52,11 +48,7 @@ public final class HardcoreManager {
|
||||
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
||||
int totalStolen = 0;
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
|
||||
int victimSkillLevel = victimProfile.getSkillLevel(skillType);
|
||||
|
||||
|
@ -182,8 +182,8 @@ public class ScoreboardManager {
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
Server server = mcMMO.p.getServer();
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
if (!Permissions.skillEnabled(player, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -201,8 +201,8 @@ public class ScoreboardManager {
|
||||
|
||||
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(playerName) : FlatfileDatabaseManager.getPlayerRanks(playerName);
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
if (!Permissions.skillEnabled(player, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -228,11 +228,7 @@ public class ScoreboardManager {
|
||||
|
||||
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(targetName) : FlatfileDatabaseManager.getPlayerRanks(targetName);
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
rank = skills.get(skill.name());
|
||||
|
||||
if (rank != null) {
|
||||
@ -257,8 +253,8 @@ public class ScoreboardManager {
|
||||
int powerLevel = 0;
|
||||
int skillLevel;
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill() || !Permissions.skillEnabled(target, skill)) {
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
if (!Permissions.skillEnabled(target, skill)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -277,11 +273,7 @@ public class ScoreboardManager {
|
||||
int powerLevel = 0;
|
||||
int skillLevel;
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
skillLevel = targetProfile.getSkillLevel(skill);
|
||||
objective.getScore(server.getOfflinePlayer(SkillUtils.getSkillName(skill))).setScore(skillLevel);
|
||||
powerLevel += skillLevel;
|
||||
|
@ -204,11 +204,7 @@ public class SpoutUtils {
|
||||
}
|
||||
|
||||
// Standard XP Icons
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
String skillName = StringUtils.getCapitalized(skillType.toString());
|
||||
|
||||
files.add(writeFile(skillName + ".png", hudStandardDirectory));
|
||||
|
Loading…
Reference in New Issue
Block a user