mortar and shell checks now execute in correct order
This commit is contained in:
parent
6235611847
commit
6962b2f80e
@ -23,20 +23,20 @@ public class MortarInteract implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack item = player.getInventory().getItemInMainHand();
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if((block != null
|
boolean isBlockNull = (block == null);
|
||||||
&& item.getType() == Material.ARROW)
|
|
||||||
&& item.hasItemMeta()
|
if(!isBlockNull){
|
||||||
&& item.getItemMeta().hasDisplayName()
|
if(block.getBlockData().getMaterial() == Material.BREWING_STAND){
|
||||||
&& item.getItemMeta().getDisplayName().equals(ChatColor.GRAY + "Shell")
|
player.sendMessage("DEBUG: Block is an brewing stand.");
|
||||||
&& block.getBlockData().getMaterial() == Material.BREWING_STAND){
|
|
||||||
player.sendMessage("Block is an brewing stand.");
|
|
||||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) event.setCancelled(true);
|
|
||||||
Nameable brewingStandMortar = (Nameable) event.getClickedBlock().getState();
|
Nameable brewingStandMortar = (Nameable) event.getClickedBlock().getState();
|
||||||
String blockName = brewingStandMortar.getCustomName();
|
String blockName = brewingStandMortar.getCustomName();
|
||||||
if(blockName == null) return;
|
if(blockName == null) return;
|
||||||
if(blockName.equals(ChatColor.GRAY + "Basic Mortar")
|
if(blockName.equals(ChatColor.GRAY + "Basic Mortar")
|
||||||
|| blockName.equals(ChatColor.GRAY + "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 mortarHandler = new MortarHandler(new Mortar(block));
|
||||||
mortarHandler.fireShell(new Shell(item));
|
mortarHandler.fireShell(new Shell(item));
|
||||||
if(item.getAmount() > 1) item.setAmount(item.getAmount()-1);
|
if(item.getAmount() > 1) item.setAmount(item.getAmount()-1);
|
||||||
@ -45,3 +45,5 @@ public class MortarInteract implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user