-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a server impl for hopper event to track get/setItem calls (#9905)
* Use a server impl for hopper event to track getItem/setItem calls * Rebase * Comments
- Loading branch information
1 parent
2cef1cc
commit 0609eea
Showing
2 changed files
with
40 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,37 +3,17 @@ From: Aikar <[email protected]> | |
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 | ||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 | ||
--- a/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java | ||
+++ b/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java | ||
@@ -0,0 +0,0 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { | ||
private final Inventory destinationInventory; | ||
private ItemStack itemStack; | ||
private final boolean didSourceInitiate; | ||
+ public boolean calledGetItem; // Paper | ||
+ public boolean calledSetItem; // Paper | ||
|
||
public InventoryMoveItemEvent(@NotNull final Inventory sourceInventory, @NotNull final ItemStack itemStack, @NotNull final Inventory destinationInventory, final boolean didSourceInitiate) { | ||
Preconditions.checkArgument(itemStack != null, "ItemStack cannot be null"); | ||
@@ -0,0 +0,0 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { | ||
*/ | ||
@NotNull | ||
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 | ||
} | ||
|
||
/** | ||
@@ -0,0 +0,0 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { | ||
*/ | ||
public void setItem(@NotNull ItemStack itemStack) { | ||
Preconditions.checkArgument(itemStack != null, "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(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters