mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Assorted cleanup.
This commit is contained in:
parent
f89f215813
commit
9904eb0b0d
@ -6,52 +6,58 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
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")),
|
||||
PICKAXE(mcLocale.getString("Skills.LowerPickAxe"), mcLocale.getString("Skills.ReadyPickAxe")),
|
||||
SHOVEL(mcLocale.getString("Skills.LowerShovel"), mcLocale.getString("Skills.ReadyShovel")),
|
||||
SWORD(mcLocale.getString("Skills.LowerSword"), mcLocale.getString("Skills.ReadySword"));
|
||||
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")),
|
||||
PICKAXE(mcLocale.getString("Skills.LowerPickAxe"), mcLocale.getString("Skills.ReadyPickAxe")),
|
||||
SHOVEL(mcLocale.getString("Skills.LowerShovel"), mcLocale.getString("Skills.ReadyShovel")),
|
||||
SWORD(mcLocale.getString("Skills.LowerSword"), mcLocale.getString("Skills.ReadySword"));
|
||||
|
||||
private String lowerTool;
|
||||
private String raiseTool;
|
||||
private String lowerTool;
|
||||
private String raiseTool;
|
||||
|
||||
private ToolType(String lowerTool, String raiseTool)
|
||||
{
|
||||
this.lowerTool = lowerTool;
|
||||
this.raiseTool = 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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>();
|
||||
|
@ -4,46 +4,49 @@ import java.util.ArrayList;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
|
||||
public class TreeNode
|
||||
{
|
||||
TreeNode left = null
|
||||
, right = null;
|
||||
PlayerStat ps = new PlayerStat();
|
||||
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)
|
||||
left = new TreeNode(p,in);
|
||||
else
|
||||
left.add(p, in);
|
||||
}
|
||||
else if(in < ps.statVal)
|
||||
{
|
||||
if (right == null)
|
||||
right = new TreeNode(p,in);
|
||||
else
|
||||
right.add(p, in);
|
||||
}
|
||||
}
|
||||
public void add (String p, int in) {
|
||||
if (in >= ps.statVal) {
|
||||
if (left == null) {
|
||||
left = new TreeNode(p, in);
|
||||
}
|
||||
else {
|
||||
left.add(p, in);
|
||||
}
|
||||
}
|
||||
else if(in < ps.statVal) {
|
||||
if (right == null) {
|
||||
right = new TreeNode(p, in);
|
||||
}
|
||||
else {
|
||||
right.add(p, in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<PlayerStat> inOrder(ArrayList<PlayerStat> a)
|
||||
{
|
||||
//if left node is not null than assign arrayList(a) to left.inOrder()
|
||||
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
|
||||
|
||||
//GOES THROUGH THE ENTIRE LEFT BRANCH AND GRABS THE GREATEST NUMBER
|
||||
if (left != null) {
|
||||
a = left.inOrder(a);
|
||||
}
|
||||
|
||||
if(left != null)
|
||||
a = left.inOrder(a);
|
||||
a.add(ps);
|
||||
|
||||
a.add(ps);
|
||||
if (right != null) {
|
||||
a = right.inOrder(a);
|
||||
}
|
||||
|
||||
if(right != null)
|
||||
a = right.inOrder(a);
|
||||
|
||||
return a;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user