Assorted cleanup.

This commit is contained in:
GJ 2012-03-31 16:40:06 -04:00
parent f89f215813
commit 9904eb0b0d
3 changed files with 99 additions and 92 deletions

View File

@ -6,8 +6,7 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.locale.mcLocale;
public enum ToolType
{
public enum ToolType {
AXE(mcLocale.getString("Skills.LowerAxe"), mcLocale.getString("Skills.ReadyAxe")),
FISTS(mcLocale.getString("Skills.LowerFists"), mcLocale.getString("Skills.ReadyFists")),
HOE(mcLocale.getString("Skills.LowerHoe"), mcLocale.getString("Skills.ReadyHoe")),
@ -18,40 +17,47 @@ public enum ToolType
private String lowerTool;
private String raiseTool;
private ToolType(String lowerTool, String raiseTool)
{
private ToolType(String lowerTool, String raiseTool) {
this.lowerTool = lowerTool;
this.raiseTool = raiseTool;
}
public String getLowerTool()
{
return this.lowerTool;
public String getLowerTool() {
return lowerTool;
}
public String getRaiseTool()
{
return this.raiseTool;
public String getRaiseTool() {
return raiseTool;
}
public boolean inHand(ItemStack is)
{
switch(this)
{
/**
* Check to see if the item is of the appropriate type.
*
* @param is The item to check
* @return true if the item is the right type, false otherwise
*/
public boolean inHand(ItemStack is) {
switch (this) {
case AXE:
return ItemChecks.isAxe(is);
case FISTS:
return is.getType().equals(Material.AIR);
case HOE:
return ItemChecks.isHoe(is);
case PICKAXE:
return ItemChecks.isMiningPick(is);
case SHOVEL:
return ItemChecks.isShovel(is);
case SWORD:
return ItemChecks.isSword(is);
}
default:
return false;
}
}
}

View File

@ -8,8 +8,6 @@ public class Tree {
private TreeNode root = null;
public Tree(){}
/**
* Add a node to this tree.
*
@ -33,12 +31,12 @@ public class Tree {
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.
/*
* 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>();

View File

@ -4,45 +4,48 @@ import java.util.ArrayList;
import com.gmail.nossr50.datatypes.PlayerStat;
public class TreeNode
{
TreeNode left = null
, right = null;
public class TreeNode {
TreeNode left = null;
TreeNode right = null;
PlayerStat ps = new PlayerStat();
public TreeNode(String p, int in) {ps.statVal = in; ps.name = p;}
public TreeNode(String p, int in) {
ps.statVal = in;
ps.name = p;
}
public void add (String p, int in)
{
if (in >= ps.statVal)
{
if (left == null)
public void add (String p, int in) {
if (in >= ps.statVal) {
if (left == null) {
left = new TreeNode(p, in);
else
}
else {
left.add(p, in);
}
else if(in < ps.statVal)
{
if (right == null)
}
else if(in < ps.statVal) {
if (right == null) {
right = new TreeNode(p, in);
else
}
else {
right.add(p, in);
}
}
}
public ArrayList<PlayerStat> inOrder(ArrayList<PlayerStat> a)
{
public ArrayList<PlayerStat> inOrder(ArrayList<PlayerStat> a) {
//if left node is not null than assign arrayList(a) to left.inOrder()
//GOES THROUGH THE ENTIRE LEFT BRANCH AND GRABS THE GREATEST NUMBER
if(left != null)
if (left != null) {
a = left.inOrder(a);
}
a.add(ps);
if(right != null)
if (right != null) {
a = right.inOrder(a);
}
return a;
}