Add @hidendra 's pulls

This commit is contained in:
md_5 2013-04-10 17:03:17 +10:00
parent db79d01b57
commit 7db53a4407
2 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,69 @@
From 7190ad3069d55a8a4c94d2b86f5d28f8614d0074 Mon Sep 17 00:00:00 2001
From: Tyler Blair <hidendra@griefcraft.com>
Date: Tue, 9 Apr 2013 17:53:31 -0300
Subject: [PATCH] InventoryClickEvent now can return if the click was a double
click. 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.
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
index 264ab0a..4ad1d5a
--- a/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java
@@ -8,8 +8,8 @@ import org.bukkit.inventory.Recipe;
public class CraftItemEvent extends InventoryClickEvent {
private Recipe recipe;
- public CraftItemEvent(Recipe recipe, InventoryView what, SlotType type, int slot, boolean right, boolean shift) {
- super(what, type, slot, right, shift);
+ 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
index 26e1d38..7662b5c
--- a/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java
@@ -11,17 +11,18 @@ import org.bukkit.inventory.ItemStack;
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;
- public InventoryClickEvent(InventoryView what, SlotType type, int slot, boolean right, boolean shift) {
+ 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);
@@ -67,6 +68,13 @@ public class InventoryClickEvent extends InventoryEvent implements Cancellable {
}
/**
+ * @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.
*/
--
1.8.2.1

View File

@ -0,0 +1,39 @@
From cd7f57fb8f8b9f58801788e557b80a45c61cd882 Mon Sep 17 00:00:00 2001
From: Tyler Blair <hidendra@griefcraft.com>
Date: Tue, 9 Apr 2013 17:55:15 -0300
Subject: [PATCH] InventoryClickEvent now can return if the click was a double
click. 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.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index a2d95e3..a1c2442 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1183,12 +1183,12 @@ public class PlayerConnection extends Connection {
InventoryView inventory = this.player.activeContainer.getBukkitView();
SlotType type = CraftInventoryView.getSlotType(inventory, packet102windowclick.slot);
- InventoryClickEvent event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1);
+ InventoryClickEvent event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1, packet102windowclick.shift == 6);
org.bukkit.inventory.Inventory top = inventory.getTopInventory();
if (packet102windowclick.slot == 0 && top instanceof CraftingInventory) {
org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe();
if (recipe != null) {
- event = new org.bukkit.event.inventory.CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1);
+ event = new org.bukkit.event.inventory.CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1, packet102windowclick.shift == 6);
}
}
server.getPluginManager().callEvent(event);
@@ -1276,7 +1276,7 @@ public class PlayerConnection extends Connection {
slot = SlotType.OUTSIDE;
}
- InventoryClickEvent event = new InventoryClickEvent(inventory, slot, slot == SlotType.OUTSIDE ? -999 : packet107setcreativeslot.slot, false, false);
+ InventoryClickEvent event = new InventoryClickEvent(inventory, slot, slot == SlotType.OUTSIDE ? -999 : packet107setcreativeslot.slot, false, false, false);
server.getPluginManager().callEvent(event);
org.bukkit.inventory.ItemStack item = event.getCurrentItem();
--
1.8.2.1