Skip to content

Commit

Permalink
AvgDmg change screen fix
Browse files Browse the repository at this point in the history
- if player tried to put there item without AvgDmg Bonus and closed the gui, item was lost
  • Loading branch information
Grzybol committed Apr 21, 2024
1 parent 5cc5a44 commit 319ba59
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/betterbox/mine/game/betterelo/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,7 @@ public void onInventoryClick(InventoryClickEvent event) {
Inventory inventory = event.getInventory();
ItemStack item0 = inventory.getItem(3);
if (item0 != null && item0.hasItemMeta()) {

pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick reroll, item0: "+item0+", item0.hasItemMeta(): "+item0.hasItemMeta());
ItemMeta meta0 = item0.getItemMeta();
boolean slot0Condition = meta0.getLore().stream().anyMatch(line -> line.contains("Average Damage"));
Expand Down Expand Up @@ -1396,9 +1397,9 @@ public void onInventoryClose(InventoryCloseEvent event) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Checking items in closed GUI");

ItemStack itemInSlot0 = closedInventory.getItem(3);
if (itemInSlot0 != null && itemInSlot0.hasItemMeta()) {
if (itemInSlot0 != null) {
ItemMeta meta = itemInSlot0.getItemMeta();
if (meta.getLore().stream().anyMatch(line -> line.contains("Average Damage"))) {
//if (meta.getLore().stream().anyMatch(line -> line.contains("Average Damage"))) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Item with 'Average damage' found in slot 0");

// Optional: Directly give back the item to the player's inventory
Expand All @@ -1412,7 +1413,7 @@ public void onInventoryClose(InventoryCloseEvent event) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Inventory full, item dropped at player's location");
closedInventory.clear(3); // Clear the slot
}
}
//}
}
}
}
Expand Down

0 comments on commit 319ba59

Please sign in to comment.