From ce0afb8bb57a53c2e61c1b38f721c08e529a32d6 Mon Sep 17 00:00:00 2001 From: Lightling Date: Thu, 12 Sep 2019 20:54:42 -0400 Subject: [PATCH] added block references for checking valid blocks for excavator/hammer --- .../gibsoniacraft/crafting/Excavator.java | 24 ++++---- .../gibsoniacraft/util/BlockRef.java | 58 +++++++++++++++++++ .../gibsoniacraft/util/ToolUtil.java | 16 +++++ 3 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 plugin/src/lightling/gibsoniacraft/util/BlockRef.java create mode 100644 plugin/src/lightling/gibsoniacraft/util/ToolUtil.java diff --git a/plugin/src/lightling/gibsoniacraft/crafting/Excavator.java b/plugin/src/lightling/gibsoniacraft/crafting/Excavator.java index 81668b3..ab90815 100644 --- a/plugin/src/lightling/gibsoniacraft/crafting/Excavator.java +++ b/plugin/src/lightling/gibsoniacraft/crafting/Excavator.java @@ -1,21 +1,21 @@ package lightling.gibsoniacraft.crafting; // Collections -import java.util.List; // Needed for recipe choices and lore -import java.util.ArrayList; // Needed for recipe choices and lore +import java.util.List; // Needed for recipe choices and lore +import java.util.ArrayList; // Needed for recipe choices and lore // Excavator-specific -import org.bukkit.NamespacedKey; // Needed for defining excavator's item key -import org.bukkit.inventory.meta.ItemMeta; // Needed for defining excavator's item meta information -import org.bukkit.Material; // Needed for defining pre-existing items -import org.bukkit.inventory.ShapedRecipe; // Needed for defining crafting recipes -import org.bukkit.inventory.RecipeChoice; // Needed for wood-excavator's wood choices -import org.bukkit.inventory.ItemStack; // Excavator is a type of item, which uses ItemStack +import org.bukkit.NamespacedKey; // Needed for defining excavator's item key +import org.bukkit.inventory.meta.ItemMeta; // Needed for defining excavator's item meta information +import org.bukkit.Material; // Needed for defining pre-existing items +import org.bukkit.inventory.ShapedRecipe; // Needed for defining crafting recipes +import org.bukkit.inventory.RecipeChoice; // Needed for wood-excavator's wood choices +import org.bukkit.inventory.ItemStack; // Excavator is a type of item, which uses ItemStack // Plugin-specific -import org.bukkit.plugin.java.JavaPlugin; // For registering the excavator within the plugin -import org.bukkit.plugin.Plugin; // Involved in setting up namespaced-key -import org.bukkit.Server; // For registering recipes on the server +import org.bukkit.plugin.java.JavaPlugin; // For registering the excavator within the plugin +import org.bukkit.plugin.Plugin; // Involved in setting up namespaced-key +import org.bukkit.Server; // For registering recipes on the server /** * An excavator is a shovel-based item that digs in a 3x3 radius as opposed to a singular block @@ -90,7 +90,7 @@ public class Excavator ItemMeta diamondExcMeta = diamondExcavator.getItemMeta(); // Define lore - String loreString = "Based off of item from Tinkers' Construct"; + String loreString = "Based off of item from PowerMining/Tinkers' Construct"; List lore = new ArrayList() {{ add(loreString); }}; woodExcMeta.setLore(lore); stoneExcMeta.setLore(lore); diff --git a/plugin/src/lightling/gibsoniacraft/util/BlockRef.java b/plugin/src/lightling/gibsoniacraft/util/BlockRef.java new file mode 100644 index 0000000..89eaf2d --- /dev/null +++ b/plugin/src/lightling/gibsoniacraft/util/BlockRef.java @@ -0,0 +1,58 @@ +package lightling.gibsoniacraft.util; + +import java.util.ArrayList; + +import org.bukkit.Material; + +public class BlockRef +{ + public static ArrayList ValidHammerBlocks = new ArrayList() + {{ + add(Material.COAL_ORE); + add(Material.IRON_ORE); + add(Material.GOLD_ORE); + add(Material.DIAMOND_ORE); + add(Material.EMERALD_ORE); + add(Material.LAPIS_ORE); + add(Material.REDSTONE_ORE); + + add(Material.COAL_BLOCK); + add(Material.IRON_BLOCK); + add(Material.GOLD_BLOCK); + add(Material.DIAMOND_BLOCK); + add(Material.EMERALD_BLOCK); + add(Material.LAPIS_BLOCK); + add(Material.REDSTONE_BLOCK); + + add(Material.COBBLESTONE); + add(Material.STONE); + add(Material.SANDSTONE); + add(Material.RED_SANDSTONE); + add(Material.DIORITE); + add(Material.ANDESITE); + add(Material.GRANITE); + + add(Material.END_STONE); + add(Material.NETHERRACK); + add(Material.NETHER_QUARTZ_ORE); + }}; + + public static ArrayList ValidExcavatorBlocks = new ArrayList() + {{ + add(Material.DIRT); + add(Material.COARSE_DIRT); + add(Material.PODZOL); + add(Material.GRASS_BLOCK); + add(Material.GRASS_PATH); + + add(Material.SAND); + add(Material.RED_SAND); + add(Material.GRAVEL); + add(Material.CLAY); + + add(Material.SNOW); + add(Material.SNOW_BLOCK); + + add(Material.SOUL_SAND); + }}; +} diff --git a/plugin/src/lightling/gibsoniacraft/util/ToolUtil.java b/plugin/src/lightling/gibsoniacraft/util/ToolUtil.java new file mode 100644 index 0000000..093b2a2 --- /dev/null +++ b/plugin/src/lightling/gibsoniacraft/util/ToolUtil.java @@ -0,0 +1,16 @@ +package lightling.gibsoniacraft.util; + +import org.bukkit.Material; + +public class ToolUtil +{ + public boolean IsMineable(Material mat) + { + return BlockRef.ValidHammerBlocks.contains(mat); + } + + public boolean IsDiggable(Material mat) + { + return BlockRef.ValidExcavatorBlocks.contains(mat); + } +}