/*
 * Copyright (c) 2017, Robin <robin.weymans@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package net.runelite.api.events;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.widgets.Widget;

/**
 * An event where a menu option has been clicked.
 * <p>
 * This event does not only trigger when clicking an option in a
 * right-clicked menu. The event will trigger for any left click
 * action performed (ie. clicking an item, walking to a tile, etc) as
 * well as any right-click menu option.
 * <p>
 * By default, when there is no action performed when left-clicking,
 * it seems that this event still triggers with the "Cancel" action.
 */
@RequiredArgsConstructor
public class MenuOptionClicked
{
	/**
	 * The clicked menu entry
	 */
	private final MenuEntry menuEntry;
	/**
	 * Whether or not the event has been consumed by a subscriber.
	 */
	@Getter
	private boolean consumed;

	/**
	 * Action parameter 0. Its value depends on the menuAction.
	 */
	public int getParam0()
	{
		return menuEntry.getParam0();
	}

	/**
	 * Action parameter 1. Its value depends on the menuAction.
	 */
	public int getParam1()
	{
		return menuEntry.getParam1();
	}

	/**
	 * The option text added to the menu.
	 */
	public String getMenuOption()
	{
		return menuEntry.getOption();
	}

	/**
	 * The target of the action.
	 */
	public String getMenuTarget()
	{
		return menuEntry.getTarget();
	}

	/**
	 * The action performed.
	 */
	public MenuAction getMenuAction()
	{
		return menuEntry.getType();
	}

	/**
	 * The ID of the object, actor, or item that the interaction targets.
	 */
	public int getId()
	{
		return menuEntry.getIdentifier();
	}

	/**
	 * Test if this menu entry is an item op. "Use" and "Examine" are not considered item ops.
	 * @return
	 */
	public boolean isItemOp()
	{
		return menuEntry.isItemOp();
	}

	/**
	 * If this menu entry is an item op, get the item op id
	 * @return 1-5
	 */
	public int getItemOp()
	{
		return menuEntry.getItemOp();
	}

	/**
	 * If this menu entry is an item op, get the item id
	 * @return
	 * @see net.runelite.api.ItemID
	 * @see net.runelite.api.NullItemID
	 */
	public int getItemId()
	{
		return menuEntry.getItemId();
	}

	/**
	 * Get the widget this menu entry is on, if this is a menu entry
	 * with an associated widget. Such as eg, CC_OP.
	 * @return
	 */
	public Widget getWidget()
	{
		return menuEntry.getWidget();
	}

	/**
	 * Marks the event as having been consumed.
	 * <p>
	 * Setting this state indicates that a plugin has processed the menu
	 * option being clicked and that the event will not be passed on
	 * for handling by vanilla client code.
	 */
	public void consume()
	{
		this.consumed = true;
	}

	@Deprecated
	public int getActionParam()
	{
		return menuEntry.getParam0();
	}

	@Deprecated
	public int getWidgetId()
	{
		return menuEntry.getParam1();
	}
}

@@ -1414,16 +1414,83 @@
 vents;%0A%0A
+import javax.annotation.Nullable;%0Aimport lombok.EqualsAndHashCode;%0A
 import l
@@ -1503,16 +1503,16 @@
 Getter;%0A
-
 import l
@@ -1542,16 +1542,40 @@
 ructor;%0A
+import lombok.ToString;%0A
 import n
@@ -2153,16 +2153,107 @@
 tructor%0A
+@EqualsAndHashCode(onlyExplicitlyIncluded = true)%0A@ToString(onlyExplicitlyIncluded = true)%0A
 public c
@@ -2350,16 +2350,17 @@
 uEntry;%0A
+%0A
 %09/**%0A%09 *
@@ -2525,32 +2525,79 @@
 enuAction.%0A%09 */%0A
+%09@EqualsAndHashCode.Include%0A%09@ToString.Include%0A
 %09public int getP
@@ -2706,32 +2706,79 @@
 enuAction.%0A%09 */%0A
+%09@EqualsAndHashCode.Include%0A%09@ToString.Include%0A
 %09public int getP
@@ -2869,24 +2869,71 @@
  menu.%0A%09 */%0A
+%09@EqualsAndHashCode.Include%0A%09@ToString.Include%0A
 %09public Stri
@@ -3026,24 +3026,71 @@
 ction.%0A%09 */%0A
+%09@EqualsAndHashCode.Include%0A%09@ToString.Include%0A
 %09public Stri
@@ -3179,24 +3179,71 @@
 ormed.%0A%09 */%0A
+%09@EqualsAndHashCode.Include%0A%09@ToString.Include%0A
 %09public Menu
@@ -3379,24 +3379,71 @@
 rgets.%0A%09 */%0A
+%09@EqualsAndHashCode.Include%0A%09@ToString.Include%0A
 %09public int 
@@ -4152,37 +4152,48 @@
 OP.%0A%09 * @return%0A
-
 %09 */%0A
+%09@Nullable%0A
 %09public Widget g

add tostring/equalsandhashcode to menuoption clicked