diff --git a/core/src/main/java/github/nighter/smartspawner/SmartSpawner.java b/core/src/main/java/github/nighter/smartspawner/SmartSpawner.java index 1bfba650..2cb67958 100644 --- a/core/src/main/java/github/nighter/smartspawner/SmartSpawner.java +++ b/core/src/main/java/github/nighter/smartspawner/SmartSpawner.java @@ -60,6 +60,7 @@ import lombok.Getter; import lombok.experimental.Accessors; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; diff --git a/core/src/main/java/github/nighter/smartspawner/logging/SpawnerEventType.java b/core/src/main/java/github/nighter/smartspawner/logging/SpawnerEventType.java index 19d1e45b..e253ce03 100644 --- a/core/src/main/java/github/nighter/smartspawner/logging/SpawnerEventType.java +++ b/core/src/main/java/github/nighter/smartspawner/logging/SpawnerEventType.java @@ -29,6 +29,8 @@ public enum SpawnerEventType { SPAWNER_ITEM_TAKE_ALL("All items taken from storage"), SPAWNER_ITEM_DROP("Item dropped from storage"), SPAWNER_ITEMS_SORT("Items sorted in storage"), + SPAWNER_ITEM_FILTER("Item filter toggled"), + SPAWNER_DROP_PAGE_ITEMS("Page items dropped"), // Command events // Note: These events capture ALL command executions including admin actions like /ss give diff --git a/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/SpawnerStorageAction.java b/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/SpawnerStorageAction.java index 66c3eceb..1a3e84ed 100644 --- a/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/SpawnerStorageAction.java +++ b/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/SpawnerStorageAction.java @@ -238,9 +238,9 @@ private void handleItemDrop(Player player, SpawnerData spawner, Inventory invent }); Vector velocity = new Vector( - sinYaw * cosPitch * 0.3, - sinPitch * 0.3, - cosYaw * cosPitch * 0.3 + sinYaw * cosPitch * 0.3 + (random.nextDouble() - 0.5) * 0.1, + sinPitch * 0.3 + 0.1 + (random.nextDouble() - 0.5) * 0.1, + cosYaw * cosPitch * 0.3 + (random.nextDouble() - 0.5) * 0.1 ); droppedItemWorld.setVelocity(velocity); @@ -283,13 +283,13 @@ private void handleDropPageItems(Player player, SpawnerData spawner, Inventory i } List pageItems = new ArrayList<>(); - int itemsFound = 0; + int itemsFoundCount = 0; for (int i = 0; i < STORAGE_SLOTS; i++) { ItemStack item = inventory.getItem(i); if (item != null && item.getType() != Material.AIR) { pageItems.add(item.clone()); - itemsFound += item.getAmount(); + itemsFoundCount += item.getAmount(); inventory.setItem(i, null); } } @@ -299,6 +299,8 @@ private void handleDropPageItems(Player player, SpawnerData spawner, Inventory i return; } + final int itemsFound = itemsFoundCount; + VirtualInventory virtualInv = spawner.getVirtualInventory(); spawner.removeItemsAndUpdateSellValue(pageItems); @@ -321,6 +323,17 @@ private void handleDropPageItems(Player player, SpawnerData spawner, Inventory i spawner.markInteracted(); } + // Log drop page items action + if (plugin.getSpawnerActionLogger() != null) { + plugin.getSpawnerActionLogger().log(github.nighter.smartspawner.logging.SpawnerEventType.SPAWNER_DROP_PAGE_ITEMS, builder -> + builder.player(player.getName(), player.getUniqueId()) + .location(spawner.getSpawnerLocation()) + .entityType(spawner.getEntityType()) + .metadata("items_dropped", itemsFound) + .metadata("page_number", holder.getCurrentPage()) + ); + } + updatePageContent(player, spawner, holder.getCurrentPage(), inventory, false); player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.8f, 0.8f); } @@ -684,12 +697,13 @@ public void handleTakeAllItems(Player player, Inventory sourceInventory) { // Log take all items action if (plugin.getSpawnerActionLogger() != null) { + int itemsLeft = spawner.getVirtualInventory().getUsedSlots(); plugin.getSpawnerActionLogger().log(github.nighter.smartspawner.logging.SpawnerEventType.SPAWNER_ITEM_TAKE_ALL, builder -> builder.player(player.getName(), player.getUniqueId()) .location(spawner.getSpawnerLocation()) .entityType(spawner.getEntityType()) - .metadata("items_taken", result.movedCount) - .metadata("items_left", result.remainingCount) + .metadata("items_taken", result.totalMoved) + .metadata("items_left", itemsLeft) ); } } diff --git a/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/filter/FilterConfigUI.java b/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/filter/FilterConfigUI.java index 6a069035..7a539a88 100644 --- a/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/filter/FilterConfigUI.java +++ b/core/src/main/java/github/nighter/smartspawner/spawner/gui/storage/filter/FilterConfigUI.java @@ -280,6 +280,17 @@ private boolean toggleItemFilter(Player player, SpawnerData spawner, ItemStack c Sound sound = wasFiltered ? Sound.BLOCK_NOTE_BLOCK_PLING : Sound.UI_BUTTON_CLICK; player.playSound(player.getLocation(), sound, 0.5f, 1.0f); + // Log item filter action + if (plugin.getSpawnerActionLogger() != null) { + plugin.getSpawnerActionLogger().log(github.nighter.smartspawner.logging.SpawnerEventType.SPAWNER_ITEM_FILTER, builder -> + builder.player(player.getName(), player.getUniqueId()) + .location(spawner.getSpawnerLocation()) + .entityType(spawner.getEntityType()) + .metadata("item_type", itemType.name()) + .metadata("is_filtered", wasFiltered) + ); + } + return true; } }