Moved inventory checkTasks to directly before onInventoryInteract

This improves performance (allows unused threads to return faster), and resolves issues with pass-through transactions
This commit is contained in:
Intelli 2021-07-22 13:31:08 -06:00
parent 6fce87386d
commit 2f1c45cae1
3 changed files with 3 additions and 3 deletions

View File

@ -39,7 +39,6 @@ public final class HopperPullListener {
final long taskStarted = InventoryChangeListener.tasksStarted.incrementAndGet();
Bukkit.getServer().getScheduler().runTaskAsynchronously(CoreProtect.getInstance(), () -> {
try {
InventoryChangeListener.checkTasks(taskStarted);
if (sourceHolder == null || destinationHolder == null) {
return;
}
@ -133,6 +132,7 @@ public final class HopperPullListener {
}
originalSource[inventoryContents.length] = movedItem;
InventoryChangeListener.checkTasks(taskStarted);
InventoryChangeListener.onInventoryInteract("#hopper", sourceInventory, originalSource, null, sourceInventory.getLocation(), true);
}
catch (Exception e) {

View File

@ -39,7 +39,6 @@ public final class HopperPushListener {
final long taskStarted = InventoryChangeListener.tasksStarted.incrementAndGet();
Bukkit.getServer().getScheduler().runTaskAsynchronously(CoreProtect.getInstance(), () -> {
try {
InventoryChangeListener.checkTasks(taskStarted);
if (sourceHolder == null || destinationHolder == null) {
return;
}
@ -110,6 +109,7 @@ public final class HopperPushListener {
}
}
InventoryChangeListener.checkTasks(taskStarted);
InventoryChangeListener.onInventoryInteract("#hopper", destinationInventory, originalDestination, null, destinationInventory.getLocation(), true);
}
catch (Exception e) {

View File

@ -227,8 +227,8 @@ public final class InventoryChangeListener extends Queue implements Listener {
final long taskStarted = InventoryChangeListener.tasksStarted.incrementAndGet();
Bukkit.getServer().getScheduler().runTaskAsynchronously(CoreProtect.getInstance(), () -> {
try {
InventoryChangeListener.checkTasks(taskStarted);
Material containerType = (enderChest != true ? null : Material.ENDER_CHEST);
InventoryChangeListener.checkTasks(taskStarted);
onInventoryInteract(player.getName(), inventory, containerState, containerType, inventoryLocation, true);
}
catch (Exception e) {