Skip to content

Commit

Permalink
fixed shulker lag issue with ender chests
Browse files Browse the repository at this point in the history
  • Loading branch information
osos2000-ui committed May 7, 2024
1 parent 5ef1227 commit 191b1b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>org.zeroBzeroT</groupId>
<artifactId>AntiIllegals</artifactId>
<version>1.0.56</version>
<version>1.0.57</version>
<packaging>jar</packaging>
<name>${project.artifactId}</name>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/zeroBzeroT/antiillegals/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void onInventoryOpen(@NotNull final InventoryOpenEvent event) {
final Location location = player.getLocation();

if (inventory.getType() == InventoryType.ENDER_CHEST) {
BookHelper.cleanBookShulkers(inventory, location);
BookHelper.checkEnderChest(event, location);
return;
}
RevertHelper.checkInventory(inventory, location, true);
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/zeroBzeroT/antiillegals/helpers/BookHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -107,5 +108,18 @@ public static int cleanOversizedItems(@NotNull final Inventory inventory, @Nulla
}
return counter;
}
public static void checkEnderChest(@NotNull final InventoryOpenEvent inventoryOpenEvent,
@Nullable final Location location) {
final Inventory inventory = inventoryOpenEvent.getInventory();
final ItemStack[] inventoryContents = inventory.getContents();

for (final ItemStack itemStack : inventoryContents) {
if (itemStack == null) continue;

InventoryHolderHelper.iterateInventory(itemStack, inv ->
BookHelper.cleanBookItems(inv, location, BookHelper.filterBooks(inv).toList())
);
}
}

}

0 comments on commit 191b1b2

Please sign in to comment.