2013-06-02 03:21:49 +02:00
From 22f33ad24d44bb233901d9db865edf34b66e33d9 Mon Sep 17 00:00:00 2001
2013-04-10 09:03:17 +02:00
From: Tyler Blair <hidendra@griefcraft.com>
Date: Tue, 9 Apr 2013 17:53:31 -0300
2013-06-02 03:21:49 +02:00
Subject: [PATCH] Enhanced InventoryClickEvent
2013-04-10 09:03:17 +02:00
2013-06-02 03:21:49 +02:00
Fixes Bukkit-4035. Added in MC 1.5 you can now double click an item which brings all items of that type onto your cursor from the container. There is currently no way to distinguish this from a normal click.
2013-04-10 09:03:17 +02:00
diff --git a/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java b/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java
old mode 100644
new mode 100755
2013-04-19 09:45:39 +02:00
index 264ab0a..6ed1a89
2013-04-10 09:03:17 +02:00
--- a/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java
2013-04-19 09:45:39 +02:00
@@ -9,7 +9,11 @@ public class CraftItemEvent extends InventoryClickEvent {
2013-04-10 09:03:17 +02:00
private Recipe recipe;
2013-04-19 09:45:39 +02:00
public CraftItemEvent(Recipe recipe, InventoryView what, SlotType type, int slot, boolean right, boolean shift) {
2013-04-10 09:03:17 +02:00
- super(what, type, slot, right, shift);
2013-04-19 09:45:39 +02:00
+ this(recipe, what, type, slot, right, shift, false);
+ }
+
2013-04-10 09:03:17 +02:00
+ public CraftItemEvent(Recipe recipe, InventoryView what, SlotType type, int slot, boolean right, boolean shift, boolean doubleClick) {
+ super(what, type, slot, right, shift, doubleClick);
this.recipe = recipe;
}
diff --git a/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java b/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java
old mode 100644
new mode 100755
2013-04-19 09:45:39 +02:00
index 26e1d38..1c07a13
2013-04-10 09:03:17 +02:00
--- a/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java
2013-04-19 09:45:39 +02:00
@@ -11,17 +11,22 @@ import org.bukkit.inventory.ItemStack;
2013-04-10 09:03:17 +02:00
public class InventoryClickEvent extends InventoryEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private SlotType slot_type;
- private boolean rightClick, shiftClick;
+ private boolean rightClick, shiftClick, doubleClick;
private Result result;
private int whichSlot;
private int rawSlot;
private ItemStack current = null;
2013-04-19 09:45:39 +02:00
public InventoryClickEvent(InventoryView what, SlotType type, int slot, boolean right, boolean shift) {
+ this(what, type, slot, right, shift, false);
+ }
+
2013-04-10 09:03:17 +02:00
+ public InventoryClickEvent(InventoryView what, SlotType type, int slot, boolean right, boolean shift, boolean doubleClick) {
super(what);
this.slot_type = type;
this.rightClick = right;
this.shiftClick = shift;
+ this.doubleClick = doubleClick;
this.result = Result.DEFAULT;
this.rawSlot = slot;
this.whichSlot = what.convertSlot(slot);
2013-04-19 09:45:39 +02:00
@@ -67,6 +72,13 @@ public class InventoryClickEvent extends InventoryEvent implements Cancellable {
2013-04-10 09:03:17 +02:00
}
/**
+ * @return True if the click is a double click. If it is a double click it will group up all items from the container of the same type onto the cursor.
+ */
+ public boolean isDoubleClick() {
+ return doubleClick;
+ }
+
+ /**
* Shift can be combined with right-click or left-click as a modifier.
* @return True if the click is a shift-click.
*/
--
2013-06-02 03:21:49 +02:00
1.8.1.2
2013-04-10 09:03:17 +02:00