Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -283,13 +283,13 @@ private void handleDropPageItems(Player player, SpawnerData spawner, Inventory i
}

List<ItemStack> 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);
}
}
Expand All @@ -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);

Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}