added mortar check methods

master
Soper Aylamo 2021-05-09 04:45:04 -04:00
parent 6ef8ef8f32
commit d8b5572dad
1 changed files with 32 additions and 6 deletions

View File

@ -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;
}
}