2019-04-23 04:47:07 +00:00
From a8182f37635d55f5c7c37fed994fbbebe10aafe4 Mon Sep 17 00:00:00 2001
2018-01-18 06:00:51 +00: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
2019-03-20 00:28:15 +00:00
index 2bb57d23..f0a16d3c 100644
2018-01-18 06:00:51 +00:00
--- a/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java
2019-03-20 00:28:15 +00:00
@@ -31,6 +31,8 @@ public class InventoryMoveItemEvent extends Event implements Cancellable {
2018-01-18 06:00:51 +00:00
private final Inventory destinationInventory;
private ItemStack itemStack;
private final boolean didSourceInitiate;
+ public boolean calledGetItem; // Paper
+ public boolean calledSetItem; // Paper
2019-03-20 00:28:15 +00:00
public InventoryMoveItemEvent(@NotNull final Inventory sourceInventory, @NotNull final ItemStack itemStack, @NotNull final Inventory destinationInventory, final boolean didSourceInitiate) {
2018-01-18 06:00:51 +00:00
Validate.notNull(itemStack, "ItemStack cannot be null");
2019-03-20 00:28:15 +00:00
@@ -58,7 +60,8 @@ public class InventoryMoveItemEvent extends Event implements Cancellable {
2018-01-18 06:00:51 +00:00
*/
2019-03-20 00:28:15 +00:00
@NotNull
2018-01-18 06:00:51 +00: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 00:28:15 +00:00
@@ -70,6 +73,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable {
2018-01-18 06:00:51 +00:00
*/
2019-03-20 00:28:15 +00:00
public void setItem(@NotNull ItemStack itemStack) {
2018-01-18 06:00:51 +00: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();
}
--
2019-03-20 00:28:15 +00:00
2.21.0
2018-01-18 06:00:51 +00:00