From d8b5572dad63e27a4668efd494a6b1927c158ef5 Mon Sep 17 00:00:00 2001 From: Soper Date: Sun, 9 May 2021 04:45:04 -0400 Subject: [PATCH] added mortar check methods --- src/xyz/soper/arty/item/Mortar.java | 38 ++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/xyz/soper/arty/item/Mortar.java b/src/xyz/soper/arty/item/Mortar.java index f48c7a7..d73d624 100644 --- a/src/xyz/soper/arty/item/Mortar.java +++ b/src/xyz/soper/arty/item/Mortar.java @@ -2,6 +2,7 @@ package xyz.soper.arty.item; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Nameable; import org.bukkit.block.Block; import org.bukkit.block.Container; @@ -10,10 +11,10 @@ public class Mortar { public Location location; - public static String BASIC_MORTAR_NAME = ChatColor.GRAY + "Basic Mortar"; - public static String NORMAL_MORTAR_NAME = ChatColor.GRAY + "Mortar"; - public static String INCENDIARY_CAPABLE_MORTAR_NAME = ChatColor.GRAY + "Incendiary Capable Mortar"; - public static String REINFORCED_MORTAR_NAME = ChatColor.GRAY + "Reinforced Mortar"; + public static final String BASIC_MORTAR_NAME = ChatColor.GRAY + "Basic Mortar"; + public static final String NORMAL_MORTAR_NAME = ChatColor.GRAY + "Mortar"; + public static final String INCENDIARY_CAPABLE_MORTAR_NAME = ChatColor.GRAY + "Incendiary Capable Mortar"; + public static final String REINFORCED_MORTAR_NAME = ChatColor.GRAY + "Reinforced Mortar"; public int failMultiplier; //Multiplier to a fail chance. public double jamChance; //If a fail happens, chance of it being a jam. @@ -23,7 +24,7 @@ public class Mortar { public double velocityMultiplier; //Multiplier applied to the shell's velocity public boolean incendiaryCapable; //Is the mortar fit to fire an incendiary-type shell? - public Block block; + private Block block; public Mortar(Block mortar){ block = mortar; @@ -67,7 +68,32 @@ public class Mortar { velocityMultiplier = 1.0; incendiaryCapable = false; } - } + public static boolean isMortar(Block block){ + if(block != null + && block.getBlockData().getMaterial() == Material.BREWING_STAND + && isStringMortar(((Nameable)block.getState()).getCustomName())){ + return true; + } + return false; + } + + private static boolean isStringMortar(String string){ + if(string.equals(BASIC_MORTAR_NAME) + || string.equals(NORMAL_MORTAR_NAME) + || string.equals(REINFORCED_MORTAR_NAME) + || string.equals(INCENDIARY_CAPABLE_MORTAR_NAME)){ + return true; + } + return false; + } + + /** + * Returns the Block that represents this mortar object + * @return Mortar as a Block + */ + public Block getBlock() { + return block; + } }