needs to cancel right click mortar event before arrow check is done
parent
99539fea58
commit
8011bc3f78
|
@ -23,28 +23,24 @@ public class MortarInteract implements Listener {
|
|||
Player player = event.getPlayer();
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
Block block = event.getClickedBlock();
|
||||
if((item.getType() == Material.ARROW)
|
||||
if((block != null
|
||||
&& item.getType() == Material.ARROW)
|
||||
&& item.hasItemMeta()
|
||||
&& item.getItemMeta().hasDisplayName()
|
||||
&& item.getItemMeta().getDisplayName().equals(ChatColor.GRAY + "Shell")){
|
||||
if(block == null) {
|
||||
player.sendMessage("Block is null.");
|
||||
return;
|
||||
}
|
||||
else if(block.getBlockData().getMaterial() == Material.BREWING_STAND){
|
||||
player.sendMessage("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.");
|
||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) event.setCancelled(true);
|
||||
MortarHandler mortarHandler = new MortarHandler(new Mortar(block));
|
||||
mortarHandler.fireShell(new Shell(item));
|
||||
if(item.getAmount() > 1) item.setAmount(item.getAmount()-1);
|
||||
else player.getInventory().setItemInMainHand(null);
|
||||
}
|
||||
&& 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);
|
||||
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.");
|
||||
MortarHandler mortarHandler = new MortarHandler(new Mortar(block));
|
||||
mortarHandler.fireShell(new Shell(item));
|
||||
if(item.getAmount() > 1) item.setAmount(item.getAmount()-1);
|
||||
else player.getInventory().setItemInMainHand(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue