diff --git a/plugin/src/lightling/gibsoniacraft/GibsoniaCraft.java b/plugin/src/lightling/gibsoniacraft/GibsoniaCraft.java index d44dbbc..fc0d30c 100644 --- a/plugin/src/lightling/gibsoniacraft/GibsoniaCraft.java +++ b/plugin/src/lightling/gibsoniacraft/GibsoniaCraft.java @@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin; import lightling.gibsoniacraft.crafting.Excavator; import lightling.gibsoniacraft.crafting.Hammer; +import lightling.gibsoniacraft.crafting.LumberAxe; import lightling.gibsoniacraft.util.BlockListener; import lightling.gibsoniacraft.util.PlayerInteractListener; @@ -11,6 +12,7 @@ public final class GibsoniaCraft extends JavaPlugin { private Excavator excavatorClass; private Hammer hammerClass; + private LumberAxe lumberAxeClass; private PlayerInteractListener pListener; private BlockListener bListener; @@ -18,6 +20,7 @@ public final class GibsoniaCraft extends JavaPlugin { public void onEnable() { excavatorClass = new Excavator(this); hammerClass = new Hammer(this); + lumberAxeClass = new LumberAxe(this); pListener = new PlayerInteractListener(this); bListener = new BlockListener(this); } diff --git a/plugin/src/lightling/gibsoniacraft/crafting/LumberAxe.java b/plugin/src/lightling/gibsoniacraft/crafting/LumberAxe.java index 70d10f5..46990dc 100644 --- a/plugin/src/lightling/gibsoniacraft/crafting/LumberAxe.java +++ b/plugin/src/lightling/gibsoniacraft/crafting/LumberAxe.java @@ -18,7 +18,7 @@ import org.bukkit.plugin.Plugin; // Involved in setting up namespaced-key import org.bukkit.Server; // For registering recipes on the server /** - * An LumberAxe is a shovel-based item that digs in a 3x3 radius as opposed to a singular block + * An LumberAxe is a AXE-based item that digs in a 3x3 radius as opposed to a singular block * @author Lightling */ public class LumberAxe @@ -62,11 +62,11 @@ public class LumberAxe private void SetupItems(final JavaPlugin plugin) { // Define the LumberAxe items - woodLumberAxe = new ItemStack(Material.WOODEN_SHOVEL); - stoneLumberAxe = new ItemStack(Material.STONE_SHOVEL); - ironLumberAxe = new ItemStack(Material.IRON_SHOVEL); - goldLumberAxe = new ItemStack(Material.GOLDEN_SHOVEL); - diamondLumberAxe = new ItemStack(Material.DIAMOND_SHOVEL); + woodLumberAxe = new ItemStack(Material.WOODEN_AXE); + stoneLumberAxe = new ItemStack(Material.STONE_AXE); + ironLumberAxe = new ItemStack(Material.IRON_AXE); + goldLumberAxe = new ItemStack(Material.GOLDEN_AXE); + diamondLumberAxe = new ItemStack(Material.DIAMOND_AXE); // Define the LumberAxe namespaced keys woodLumAxeKey = new NamespacedKey((Plugin)plugin, "w_LumberAxe"); @@ -147,15 +147,15 @@ public class LumberAxe // Define recipes for the LumberAxes woodLumAxeRecipe.setIngredient('x', woodChoice); - woodLumAxeRecipe.setIngredient('i', Material.WOODEN_SHOVEL); + woodLumAxeRecipe.setIngredient('i', Material.WOODEN_AXE); stoneLumAxeRecipe.setIngredient('x', Material.COBBLESTONE); - stoneLumAxeRecipe.setIngredient('i', Material.STONE_SHOVEL); + stoneLumAxeRecipe.setIngredient('i', Material.STONE_AXE); ironLumAxeRecipe.setIngredient('x', Material.IRON_INGOT); - ironLumAxeRecipe.setIngredient('i', Material.IRON_SHOVEL); + ironLumAxeRecipe.setIngredient('i', Material.IRON_AXE); goldLumAxeRecipe.setIngredient('x', Material.GOLD_INGOT); - goldLumAxeRecipe.setIngredient('i', Material.GOLDEN_SHOVEL); + goldLumAxeRecipe.setIngredient('i', Material.GOLDEN_AXE); diamondLumAxeRecipe.setIngredient('x', Material.DIAMOND); - diamondLumAxeRecipe.setIngredient('i', Material.DIAMOND_SHOVEL); + diamondLumAxeRecipe.setIngredient('i', Material.DIAMOND_AXE); // Register recipes on the server Server server = plugin.getServer(); diff --git a/plugin/src/lightling/gibsoniacraft/util/ToolUtil.java b/plugin/src/lightling/gibsoniacraft/util/ToolUtil.java index 6bbe600..e3cb918 100644 --- a/plugin/src/lightling/gibsoniacraft/util/ToolUtil.java +++ b/plugin/src/lightling/gibsoniacraft/util/ToolUtil.java @@ -208,46 +208,49 @@ public class ToolUtil // Create control for loop boolean moreBlocks = true; - // Grab all logs in a tree - do + // Grab all logs in a tree, ensuring target block is a log first + if (BlockRef.ValidLumberAxeBlocks.contains(target.getType())) { - // Variable that ends loop if remains 0 - int blocksAbove = 0; - - // Grab the surrounding blocks that may be wood - for (int i = -2; i <= 2; i++) + do { - for (int j = -2; j <= 2; j++) + // Variable that ends loop if remains 0 + int blocksAbove = 0; + + // Grab the surrounding blocks that may be wood + for (int i = -2; i <= 2; i++) { - // Add all the surrounding logs to the list - Block temp = world.getBlockAt(x + i, y, z + j); - if (BlockRef.ValidLumberAxeBlocks.contains(temp.getType())) + for (int j = -2; j <= 2; j++) { - blocks.add(temp); - } - - // Determine if there are still blocks left - Block tempAbove = world.getBlockAt(x + i, y + 1, z + j); - if (BlockRef.ValidLumberAxeBlocks.contains(temp.getType())) - { - blocksAbove++; + // Add all the surrounding logs to the list + Block temp = world.getBlockAt(x + i, y, z + j); + if (BlockRef.ValidLumberAxeBlocks.contains(temp.getType())) + { + blocks.add(temp); + } + + // Determine if there are still blocks left + Block tempAbove = world.getBlockAt(x + i, y + 1, z + j); + if (BlockRef.ValidLumberAxeBlocks.contains(temp.getType())) + { + blocksAbove++; + } } } + + // If there are still blocks left, go up a level for the for-loop + if (blocksAbove != 0) + { + y++; + } + + // Otherwise, end the loop + else + { + moreBlocks = false; + } } - - // If there are still blocks left, go up a level for the for-loop - if (blocksAbove != 0) - { - y++; - } - - // Otherwise, end the loop - else - { - moreBlocks = false; - } + while (moreBlocks); } - while (moreBlocks); return blocks; }