@EventHandler
public void onRightClick(PlayerInteractEvent e){
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
if(e.getPlayer().getItemInHand().getType() == Material.BLAZE_ROD){
Fireball fb = (Fireball) e.getPlayer().launchProjectile(Fireball.class);
this.setMetadata(fb, "fireball", "true", this);
}
}
}
@EventHandler
public void onExplode(EntityExplodeEvent e){
if(e.getEntity().hasMetadata("fireball")){
e.setCancelled(true);
}
}
//...
public void setMetadata(Entity entity, String key, Object value, Plugin plugin){
entity.setMetadata(key,new FixedMetadataValue(plugin,value));
}