More datatype cleanup.

This commit is contained in:
GJ 2012-03-19 13:21:38 -04:00
parent 05d16e7c15
commit d2edbe207d
2 changed files with 43 additions and 29 deletions

View File

@ -10,8 +10,7 @@ import com.gmail.nossr50.skills.Excavation;
import com.gmail.nossr50.skills.Herbalism; import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Mining; import com.gmail.nossr50.skills.Mining;
public enum AbilityType public enum AbilityType {
{
BERSERK(LoadProperties.berserkCooldown, mcLocale.getString("Skills.BerserkOn"), mcLocale.getString("Skills.BerserkOff"), "Skills.BerserkPlayer", mcLocale.getString("Skills.YourBerserk"), "Skills.BerserkPlayerOff"), BERSERK(LoadProperties.berserkCooldown, mcLocale.getString("Skills.BerserkOn"), mcLocale.getString("Skills.BerserkOff"), "Skills.BerserkPlayer", mcLocale.getString("Skills.YourBerserk"), "Skills.BerserkPlayerOff"),
SUPER_BREAKER(LoadProperties.superBreakerCooldown, mcLocale.getString("Skills.SuperBreakerOn"), mcLocale.getString("Skills.SuperBreakerOff"), "Skills.SuperBreakerPlayer", mcLocale.getString("Skills.YourSuperBreaker"), "Skills.SuperBreakerPlayerOff"), SUPER_BREAKER(LoadProperties.superBreakerCooldown, mcLocale.getString("Skills.SuperBreakerOn"), mcLocale.getString("Skills.SuperBreakerOff"), "Skills.SuperBreakerPlayer", mcLocale.getString("Skills.YourSuperBreaker"), "Skills.SuperBreakerPlayerOff"),
GIGA_DRILL_BREAKER(LoadProperties.gigaDrillBreakerCooldown, mcLocale.getString("Skills.GigaDrillBreakerOn"), mcLocale.getString("Skills.GigaDrillBreakerOff"), "Skills.GigaDrillBreakerPlayer", mcLocale.getString("Skills.YourGigaDrillBreaker"), "Skills.GigaDrillBreakerPlayerOff"), GIGA_DRILL_BREAKER(LoadProperties.gigaDrillBreakerCooldown, mcLocale.getString("Skills.GigaDrillBreakerOn"), mcLocale.getString("Skills.GigaDrillBreakerOff"), "Skills.GigaDrillBreakerPlayer", mcLocale.getString("Skills.YourGigaDrillBreaker"), "Skills.GigaDrillBreakerPlayerOff"),

View File

@ -6,34 +6,49 @@ import com.gmail.nossr50.datatypes.PlayerStat;
public class Tree { public class Tree {
TreeNode root = null; private TreeNode root = null;
public Tree(){} public Tree(){}
public void add(String p, int in) /**
{ * Add a node to this tree.
if(root == null){ *
root = new TreeNode(p, in); * @param p Player name
} * @param in Stat value
else */
root.add(p,in); public void add(String p, int in) {
} if (root == null) {
root = new TreeNode(p, in);
public PlayerStat[] inOrder() }
{ else {
if(root != null){ root.add(p, in);
ArrayList<PlayerStat> order = root.inOrder(new ArrayList<PlayerStat>()); }
return order.toArray(new PlayerStat[order.size()]); }
} else {
//Throw some dummy info in case the users file is empty
//It's not a good fix but its better than rewriting the whole system
ArrayList<PlayerStat> x = new ArrayList<PlayerStat>();
PlayerStat y = new PlayerStat();
y.name = "$mcMMO_DummyInfo";
y.statVal = 0;
x.add(y);
return x.toArray(new PlayerStat[x.size()]);
}
}
/**
* Retrieve an array of PlayerStats from the Tree.
*
* @return the player stats of this tree, in order
*/
public PlayerStat[] inOrder() {
if (root != null) {
ArrayList<PlayerStat> order = root.inOrder(new ArrayList<PlayerStat>());
return order.toArray(new PlayerStat[order.size()]);
}
else {
/* Throw some dummy info in case the users file is empty.
* It's not a good fix but its better than rewriting the whole system.
*/
ArrayList<PlayerStat> x = new ArrayList<PlayerStat>();
PlayerStat y = new PlayerStat();
y.name = "$mcMMO_DummyInfo";
y.statVal = 0;
x.add(y);
return x.toArray(new PlayerStat[x.size()]);
}
}
} }