Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Asintotoo authored Jul 20, 2024
1 parent 4fbeda0 commit 9e7b764
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.asintoto</groupId>
<artifactId>Basic</artifactId>
<version>1.2.10</version>
<version>1.2.11</version>
<packaging>jar</packaging>

<name>Basic</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;

public class InventoryCloseListener implements Listener {
Expand All @@ -20,6 +22,26 @@ public void onClose(InventoryCloseEvent e) {

MenuManager.removePlayer(p);

removePersistentDataButton(p);
menu.onClose(p);
}


private void removePersistentDataButton(Player p) {
for(ItemStack item : p.getInventory().getContents()) {
removeButtonStatus(item);
}

for(ItemStack item : p.getInventory().getArmorContents()) {
removeButtonStatus(item);
}
}

private void removeButtonStatus(ItemStack item) {
ItemMeta meta = item.getItemMeta();
if(meta.getPersistentDataContainer().has(BasicKeys.BUTTON_IS_BUTTON, PersistentDataType.BOOLEAN)) {
meta.getPersistentDataContainer().remove(BasicKeys.BUTTON_IS_BUTTON);
item.setItemMeta(meta);
}
}
}

0 comments on commit 9e7b764

Please sign in to comment.