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