2020-05-06 17:48:49 +08:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2018-01-18 14:00:51 +08:00
From: Aikar <aikar@aikar.co>
Date: Thu, 18 Jan 2018 01:00:27 -0500
Subject: [PATCH] Optimize Hoppers
Adds data about what Item related methods were used in InventoryMoveItem event
so that the server can improve the performance of this event.
diff --git a/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java b/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java
2020-05-06 17:48:49 +08:00
index a8c48f5a416326e96c431e5fa22edee04825530e..04d4a83bfc4f86341f9d72128458154d08c8ec43 100644
2018-01-18 14:00:51 +08:00
--- a/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java
2019-03-20 08:28:15 +08:00
@@ -31,6 +31,8 @@ public class InventoryMoveItemEvent extends Event implements Cancellable {
2018-01-18 14:00:51 +08:00
private final Inventory destinationInventory;
private ItemStack itemStack;
private final boolean didSourceInitiate;
+ public boolean calledGetItem; // Paper
+ public boolean calledSetItem; // Paper
2019-03-20 08:28:15 +08:00
public InventoryMoveItemEvent(@NotNull final Inventory sourceInventory, @NotNull final ItemStack itemStack, @NotNull final Inventory destinationInventory, final boolean didSourceInitiate) {
2018-01-18 14:00:51 +08:00
Validate.notNull(itemStack, "ItemStack cannot be null");
2019-03-20 08:28:15 +08:00
@@ -58,7 +60,8 @@ public class InventoryMoveItemEvent extends Event implements Cancellable {
2018-01-18 14:00:51 +08:00
*/
2019-03-20 08:28:15 +08:00
@NotNull
2018-01-18 14:00:51 +08:00
public ItemStack getItem() {
- return itemStack.clone();
+ calledGetItem = true; // Paper - record this method was used for auto detection of mode
+ return itemStack; // Paper - Removed clone, handled better in Server
}
/**
2019-03-20 08:28:15 +08:00
@@ -70,6 +73,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable {
2018-01-18 14:00:51 +08:00
*/
2019-03-20 08:28:15 +08:00
public void setItem(@NotNull ItemStack itemStack) {
2018-01-18 14:00:51 +08:00
Validate.notNull(itemStack, "ItemStack cannot be null. Cancel the event if you want nothing to be transferred.");
+ calledSetItem = true; // Paper - record this method was used for auto detection of mode
this.itemStack = itemStack.clone();
}