Paper/patches/api/0088-Optimize-Hoppers.patch

40 Zeilen
2.1 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
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
2022-06-07 19:20:30 +02:00
index 919cc993e3cb1c14e2a3aebf90e6cc0fa6fbc17f..95e51bcf5dfd27cc9012d7542c4ed1bceca29626 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java
@@ -31,6 +31,8 @@ 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) {
2022-06-07 19:20:30 +02:00
Preconditions.checkArgument(itemStack != null, "ItemStack cannot be null");
2021-06-11 14:02:28 +02:00
@@ -58,7 +60,8 @@ 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
}
/**
@@ -70,6 +73,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable {
*/
public void setItem(@NotNull ItemStack itemStack) {
2022-06-07 19:20:30 +02:00
Preconditions.checkArgument(itemStack != null, "ItemStack cannot be null. Cancel the event if you want nothing to be transferred.");
2021-06-11 14:02:28 +02:00
+ calledSetItem = true; // Paper - record this method was used for auto detection of mode
this.itemStack = itemStack.clone();
}