Skip to content

Commit

Permalink
Fix: Will detect items of container on InventoryCloseEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
GuangChen2333 committed Dec 26, 2021
1 parent 477c3f3 commit 5134bfd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'cn.guangchen233'
version '2.0.0'
version '2.0.1'

repositories {
maven {
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/cn/guangchen233/limiter32k/events/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void onInventoryOpen(InventoryOpenEvent event) {
@EventHandler
public void onInventoryCloseEvent(InventoryCloseEvent event) {
if (enabled) {
// Player
ItemStack[] items = event.getPlayer().getInventory().getStorageContents();
if (items.length > 0) {
ArrayList<ItemStack> abnormalItems = new ArrayList<>();
Expand All @@ -128,6 +129,23 @@ public void onInventoryCloseEvent(InventoryCloseEvent event) {
}
}
}
// Inventory
ItemStack[] inventoryContents = event.getInventory().getStorageContents();
if (inventoryContents.length > 0) {
ArrayList<ItemStack> abnormalItems = new ArrayList<>();
for (ItemStack item : inventoryContents) {
if (utils.checkItem(item)) {
if (!abnormalItems.contains(item)) {
abnormalItems.add(item);
}
}
}
if (abnormalItems.size() > 0) {
for (ItemStack item : abnormalItems) {
event.getInventory().remove(item);
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 32kLimiter
main: cn.guangchen233.limiter32k.LimiterMain
version: 2.0.0
version: 2.0.1
author: GuangChen233
website: https://github.com/GuangChen2333/32kLimiter
api-version: 1.12
Expand Down

0 comments on commit 5134bfd

Please sign in to comment.