mortar and shell checks now execute in correct order

master
Soper Aylamo 2021-05-09 03:08:03 -04:00
parent 6235611847
commit 6962b2f80e
1 changed files with 20 additions and 18 deletions

View File

@ -23,20 +23,20 @@ public class MortarInteract implements Listener {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
Block block = event.getClickedBlock();
if((block != null
&& item.getType() == Material.ARROW)
&& item.hasItemMeta()
&& item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(ChatColor.GRAY + "Shell")
&& block.getBlockData().getMaterial() == Material.BREWING_STAND){
player.sendMessage("Block is an brewing stand.");
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) event.setCancelled(true);
boolean isBlockNull = (block == null);
if(!isBlockNull){
if(block.getBlockData().getMaterial() == Material.BREWING_STAND){
player.sendMessage("DEBUG: Block is an brewing stand.");
Nameable brewingStandMortar = (Nameable) event.getClickedBlock().getState();
String blockName = brewingStandMortar.getCustomName();
if(blockName == null) return;
if(blockName.equals(ChatColor.GRAY + "Basic Mortar")
|| blockName.equals(ChatColor.GRAY + "Mortar")){
player.sendMessage("Block is a mortar.");
player.sendMessage("DEBUG: Block is a mortar.");
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) event.setCancelled(true);
if(Shell.isShell(item)){
player.sendMessage("DEBUG: Player has a shell in hand.");
MortarHandler mortarHandler = new MortarHandler(new Mortar(block));
mortarHandler.fireShell(new Shell(item));
if(item.getAmount() > 1) item.setAmount(item.getAmount()-1);
@ -45,3 +45,5 @@ public class MortarInteract implements Listener {
}
}
}
}
}