Fix PR 3 review findings [skip ci]

This commit is contained in:
SCOPEDD committed 2026-09-29 23:21:14 -04:00
1 parent 590178e41a
commit 454620f21e
21 files changed
+522 -160

No files matched your search

+97 -11
View File
@@ -3,6 +3,92 @@
use anyhow::Result;
use sqlx::SqlitePool;
// Targets with a material, mob, or dimension requirement use the action
// telemetry sent by both Paper and the Fabric/Forge bridge. Other quests use
// the aggregate counters in the sync payload.
const SPECIFIC_QUEST_TARGETS: &[(&str, &str)] = &[
("q_d_mine_coal", "action:block_broken:COAL_ORE|DEEPSLATE_COAL_ORE|COAL_BLOCK"),
("q_d_mine_stone", "action:block_broken:STONE|COBBLESTONE"),
("q_d_mine_iron", "action:block_broken:IRON_ORE|DEEPSLATE_IRON_ORE"),
("q_d_mine_copper", "action:block_broken:COPPER_ORE|DEEPSLATE_COPPER_ORE"),
("q_d_mine_gold", "action:block_broken:GOLD_ORE|DEEPSLATE_GOLD_ORE|NETHER_GOLD_ORE"),
("q_d_mine_diamond", "action:block_broken:DIAMOND_ORE|DEEPSLATE_DIAMOND_ORE"),
("q_d_mine_redstone", "action:block_broken:REDSTONE_ORE|DEEPSLATE_REDSTONE_ORE"),
("q_d_mine_deepslate", "action:block_broken:DEEPSLATE|COBBLED_DEEPSLATE"),
("q_d_mine_quartz", "action:block_broken:NETHER_QUARTZ_ORE"),
("q_d_mine_debris", "action:block_broken:ANCIENT_DEBRIS"),
("q_d_mine_sand", "action:block_broken:SAND|GRAVEL"),
("q_d_mine_obsidian", "action:block_broken:OBSIDIAN"),
("q_d_mob_zombies", "action:mob_kills:ZOMBIE"),
("q_d_mob_skeletons", "action:mob_kills:SKELETON"),
("q_d_mob_spiders", "action:mob_kills:SPIDER|CAVE_SPIDER"),
("q_d_mob_creepers", "action:mob_kills:CREEPER"),
("q_d_mob_endermen", "action:mob_kills:ENDERMAN"),
("q_d_mob_witches", "action:mob_kills:WITCH"),
("q_d_mob_slimes", "action:mob_kills:SLIME|MAGMA_CUBE"),
("q_d_mob_piglins", "action:mob_kills:PIGLIN|ZOMBIFIED_PIGLIN"),
("q_d_mob_blazes", "action:mob_kills:BLAZE"),
("q_d_mob_drowned", "action:mob_kills:DROWNED"),
("q_d_build_planks", "action:block_placed:*_PLANKS"),
("q_d_build_bricks", "action:block_placed:STONE_BRICKS|POLISHED_*"),
("q_d_build_glass", "action:block_placed:GLASS|GLASS_PANE|*_GLASS|*_GLASS_PANE"),
("q_d_build_torches", "action:block_placed:TORCH|WALL_TORCH"),
("q_d_build_lanterns", "action:block_placed:LANTERN|SOUL_LANTERN"),
("q_d_build_slabs", "action:block_placed:*_SLAB|*_STAIRS"),
("q_d_build_walls", "action:block_placed:*_WALL"),
("q_d_farm_wood", "action:block_broken:*_LOG|*_WOOD"),
("q_d_farm_birch", "action:block_broken:BIRCH_LOG|SPRUCE_LOG"),
("q_d_farm_jungle", "action:block_broken:JUNGLE_LOG|ACACIA_LOG"),
("q_d_farm_wheat", "action:block_broken:WHEAT"),
("q_d_farm_potatoes", "action:block_broken:POTATOES"),
("q_d_farm_carrots", "action:block_broken:CARROTS"),
("q_d_farm_sugarcane", "action:block_broken:SUGAR_CANE"),
("q_d_farm_pumpkins", "action:block_broken:PUMPKIN|MELON"),
("q_d_farm_flowers", "action:block_broken:*_TULIP|DANDELION|POPPY|OXEYE_DAISY|CORNFLOWER|AZURE_BLUET|ALLIUM"),
("q_d_farm_leaves", "action:block_broken:*_LEAVES"),
("q_d_explore_depths", "action:block_broken:TUFF|DEEPSLATE_TILES"),
("q_d_explore_diorite", "action:block_broken:GRANITE|DIORITE|ANDESITE"),
("q_d_explore_nether", "action:block_broken:*@minecraft:the_nether"),
("q_d_explore_clay", "action:block_broken:CLAY"),
("q_d_explore_snow", "action:block_broken:SNOW_BLOCK|SNOW|ICE|PACKED_ICE|BLUE_ICE"),
("q_d_explore_magma", "action:block_broken:MAGMA_BLOCK|BASALT"),
("q_d_build_decor", "action:block_placed:*_CARPET|FLOWER_POT|PAINTING"),
("q_w_mine_deepslate_grand", "action:block_broken:DEEPSLATE|COBBLED_DEEPSLATE"),
("q_w_mine_iron_hoard", "action:block_broken:IRON_ORE|DEEPSLATE_IRON_ORE"),
("q_w_mine_diamonds_grand", "action:block_broken:DIAMOND_ORE|DEEPSLATE_DIAMOND_ORE"),
("q_w_mine_gold_grand", "action:block_broken:GOLD_ORE|DEEPSLATE_GOLD_ORE|NETHER_GOLD_ORE"),
("q_w_mine_redstone_grand", "action:block_broken:REDSTONE_ORE|DEEPSLATE_REDSTONE_ORE"),
("q_w_mine_debris_grand", "action:block_broken:ANCIENT_DEBRIS"),
("q_w_mine_nether_grand", "action:block_broken:*@minecraft:the_nether"),
("q_w_mine_stone_grand", "action:block_broken:STONE|COBBLESTONE"),
("q_w_mob_skeletons_grand", "action:mob_kills:SKELETON"),
("q_w_mob_creepers_grand", "action:mob_kills:CREEPER"),
("q_w_mob_endermen_grand", "action:mob_kills:ENDERMAN"),
("q_w_mob_blazes_grand", "action:mob_kills:BLAZE"),
("q_w_mob_withers_grand", "action:mob_kills:WITHER_SKELETON"),
("q_w_build_castle", "action:block_placed:STONE_BRICKS|*_STONE_BRICKS"),
("q_w_build_planks_grand", "action:block_placed:*_PLANKS"),
("q_w_build_glass_grand", "action:block_placed:GLASS|*_GLASS"),
("q_w_build_lanterns_grand", "action:block_placed:LANTERN|SOUL_LANTERN|GLOWSTONE"),
("q_w_build_enclosure", "action:block_placed:*_FENCE|*_WALL"),
("q_w_farm_logs_grand", "action:block_broken:*_LOG|*_WOOD"),
("q_w_farm_crops_grand", "action:block_broken:WHEAT|POTATOES|CARROTS|BEETROOTS"),
("q_w_farm_reeds_grand", "action:block_broken:SUGAR_CANE|BAMBOO"),
("q_w_farm_pumpkins_grand", "action:block_broken:PUMPKIN|MELON"),
("q_w_explore_nether_grand2", "action:block_broken:*@minecraft:the_nether"),
("q_w_explore_ocean", "action:block_broken:PRISMARINE|PRISMARINE_BRICKS|DARK_PRISMARINE|GRAVEL|*_CORAL_BLOCK"),
("q_w_explore_sand_grand", "action:block_broken:SAND|RED_SAND"),
("q_w_build_complex", "action:block_placed:STONE_BRICKS|POLISHED_GRANITE"),
];
pub async fn upgrade_seeded_quest_targets(pool: &SqlitePool) -> Result<()> {
for (id, target) in SPECIFIC_QUEST_TARGETS {
sqlx::query("UPDATE quests SET target_stat = ? WHERE id = ? AND target_stat IN ('blocks_broken', 'blocks_placed', 'mob_kills')")
.bind(target).bind(id).execute(pool).await?;
}
Ok(())
}
pub async fn seed_quests_and_achievements(pool: &SqlitePool) -> Result<()> {
// Only seed if quests table is empty
let count: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM quests").fetch_one(pool).await?;
@@ -40,7 +126,7 @@ async fn seed_quests(pool: &SqlitePool) -> Result<()> {
("q_d_mine_quartz", "Nether Prospecting", "Mine 16 Nether quartz ore blocks", "daily", "mining", "blocks_broken", 16, 180, "sparkles"),
("q_d_mine_debris", "Debris Hunter", "Mine 2 Ancient Debris blocks in the Nether", "daily", "mining", "blocks_broken", 2, 450, "shield"),
("q_d_mine_sand", "Dune Excavator", "Dig 32 sand or gravel blocks", "daily", "mining", "blocks_broken", 32, 90, "layers"),
("q_d_mine_obsidian", "Obsidian Forger", "Mine 8 obsidian blocks with a diamond pickaxe", "daily", "mining", "blocks_broken", 8, 250, "shield"),
("q_d_mine_obsidian", "Obsidian Forger", "Mine 8 obsidian blocks", "daily", "mining", "blocks_broken", 8, 250, "shield"),
// Daily Combat
("q_d_mob_zombies", "Zombie Purge", "Defeat 8 zombies wandering in the dark", "daily", "combat", "mob_kills", 8, 120, "swords"),
@@ -53,7 +139,7 @@ async fn seed_quests(pool: &SqlitePool) -> Result<()> {
("q_d_mob_piglins", "Piglin Skirmish", "Defeat 6 hostile piglins or zombified piglins", "daily", "combat", "mob_kills", 6, 160, "swords"),
("q_d_mob_blazes", "Firestarter", "Defeat 4 blazing fortress defenders", "daily", "combat", "mob_kills", 4, 250, "flame"),
("q_d_mob_drowned", "Deep Water Danger", "Defeat 5 drowned lurkers in rivers or oceans", "daily", "combat", "mob_kills", 5, 140, "droplets"),
("q_d_mob_monsters", "Night Watch", "Eliminate any 15 hostile monsters", "daily", "combat", "mob_kills", 15, 200, "swords"),
("q_d_mob_monsters", "Night Watch", "Defeat any 15 mobs", "daily", "combat", "mob_kills", 15, 200, "swords"),
("q_d_pvp_champion", "Gladiator's Glory", "Defeat 1 player in honorable combat", "daily", "combat", "player_kills", 1, 250, "trophy"),
// Daily Building
@@ -63,10 +149,10 @@ async fn seed_quests(pool: &SqlitePool) -> Result<()> {
("q_d_build_torches", "Let There Be Light", "Place 20 torches to illuminate the area", "daily", "building", "blocks_placed", 20, 90, "flame"),
("q_d_build_lanterns", "Cozy Hearth", "Place 6 lanterns around your settlement", "daily", "building", "blocks_placed", 6, 120, "sparkles"),
("q_d_build_slabs", "Tiered Architecture", "Place 24 slabs or stairs", "daily", "building", "blocks_placed", 24, 110, "layers"),
("q_d_build_roof", "Under Cover", "Place 50 roofing or decorative blocks", "daily", "building", "blocks_placed", 50, 140, "home"),
("q_d_build_roof", "Under Cover", "Place 50 blocks of any kind", "daily", "building", "blocks_placed", 50, 140, "home"),
("q_d_build_walls", "Fortified Walls", "Place 30 cobblestone or deepslate walls", "daily", "building", "blocks_placed", 30, 130, "shield"),
("q_d_build_general", "Master Builder", "Place 100 blocks of any material", "daily", "building", "blocks_placed", 100, 180, "hammer"),
("q_d_build_monument", "Grand Monument", "Place 150 blocks toward a new structure", "daily", "building", "blocks_placed", 150, 220, "castle"),
("q_d_build_monument", "Grand Monument", "Place 150 blocks of any kind", "daily", "building", "blocks_placed", 150, 220, "castle"),
// Daily Farming & Harvesting
("q_d_farm_wood", "Lumberjack", "Chop down 32 wood logs", "daily", "farming", "blocks_broken", 32, 120, "axe"),
@@ -83,12 +169,12 @@ async fn seed_quests(pool: &SqlitePool) -> Result<()> {
// Daily Social & Playtime
("q_d_play_15m", "Quick Check-in", "Play on any server for 15 minutes", "daily", "social", "playtime_secs", 900, 100, "clock"),
("q_d_play_30m", "Dedicated Citizen", "Spend 30 minutes in game", "daily", "social", "playtime_secs", 1800, 180, "clock"),
("q_d_play_60m", "Hour of Power", "Play for a full continuous hour", "daily", "social", "playtime_secs", 3600, 250, "clock"),
("q_d_chat_chatty", "Good Morning", "Say hello and send 5 chat messages", "daily", "social", "messages", 5, 80, "message-square"),
("q_d_play_60m", "Hour of Power", "Play for a total of one hour", "daily", "social", "playtime_secs", 3600, 250, "clock"),
("q_d_chat_chatty", "Good Morning", "Send 5 chat messages", "daily", "social", "messages", 5, 80, "message-square"),
("q_d_chat_talkative", "Community Voice", "Send 15 chat messages participating in chat", "daily", "social", "messages", 15, 120, "message-square"),
("q_d_join_again", "Frequent Flyer", "Join a server 2 distinct times today", "daily", "social", "joins", 2, 80, "door-open"),
("q_d_explore_depths", "Into the Deep", "Mine 30 tuff or deepslate tiles", "daily", "exploration", "blocks_broken", 30, 110, "compass"),
("q_d_explore_caves", "Spelunker", "Break 50 blocks exploring natural cave systems", "daily", "exploration", "blocks_broken", 50, 130, "compass"),
("q_d_explore_caves", "Spelunker", "Break 50 blocks of any kind", "daily", "exploration", "blocks_broken", 50, 130, "compass"),
("q_d_explore_diorite", "Geologist", "Collect 20 granite, diorite, or andesite blocks", "daily", "exploration", "blocks_broken", 20, 100, "mountain"),
("q_d_explore_nether", "Nether Expedition", "Mine 40 nether blocks while surviving", "daily", "exploration", "blocks_broken", 40, 160, "flame"),
("q_d_explore_clay", "Clay Digger", "Excavate 16 clay blocks from river beds", "daily", "exploration", "blocks_broken", 16, 110, "droplets"),
@@ -106,7 +192,7 @@ async fn seed_quests(pool: &SqlitePool) -> Result<()> {
("q_w_mine_nether_grand", "Underworld Quarry", "Break 300 blocks in the Nether dimension", "weekly", "mining", "blocks_broken", 300, 700, "flame"),
("q_w_mine_stone_grand", "Mountain Mover", "Break 1,000 stone or cobblestone blocks", "weekly", "mining", "blocks_broken", 1000, 1100, "mountain"),
("q_w_mob_purge_grand", "Monster Exterminator", "Eliminate 100 hostile monsters", "weekly", "combat", "mob_kills", 100, 1000, "swords"),
("q_w_mob_purge_grand", "Monster Exterminator", "Defeat 100 mobs", "weekly", "combat", "mob_kills", 100, 1000, "swords"),
("q_w_mob_skeletons_grand", "Archer's Nemesis", "Defeat 40 skeleton sharpshooters", "weekly", "combat", "mob_kills", 40, 750, "crosshair"),
("q_w_mob_creepers_grand", "Demolition Defuser", "Take down 30 dangerous creepers", "weekly", "combat", "mob_kills", 30, 850, "flame"),
("q_w_mob_endermen_grand", "Void Hunter", "Defeat 15 elusive Endermen", "weekly", "combat", "mob_kills", 15, 1100, "eye"),
@@ -132,9 +218,9 @@ async fn seed_quests(pool: &SqlitePool) -> Result<()> {
("q_w_play_15h", "No-Lifer Supremacy", "Clock in 15 hours of active gameplay", "weekly", "social", "playtime_secs", 54000, 2500, "zap"),
("q_w_chat_social", "Town Hall Speaker", "Contribute 50 chat messages across community servers", "weekly", "social", "messages", 50, 600, "message-square"),
("q_w_joins_loyal", "Daily Habits", "Join game servers on at least 5 occasions", "weekly", "social", "joins", 5, 700, "door-open"),
("q_w_explore_caves_grand", "Underground Cartographer", "Break 400 blocks deep underground", "weekly", "exploration", "blocks_broken", 400, 850, "compass"),
("q_w_explore_caves_grand", "Underground Cartographer", "Break 400 blocks of any kind", "weekly", "exploration", "blocks_broken", 400, 850, "compass"),
("q_w_explore_nether_grand2", "Infernal Pioneer", "Travel and mine 250 blocks in the Nether", "weekly", "exploration", "blocks_broken", 250, 800, "flame"),
("q_w_explore_ocean", "Abyssal Diver", "Break 100 prismarine, gravel, or coral underwater", "weekly", "exploration", "blocks_broken", 100, 750, "droplets"),
("q_w_explore_ocean", "Abyssal Diver", "Break 100 prismarine, gravel, or coral blocks", "weekly", "exploration", "blocks_broken", 100, 750, "droplets"),
("q_w_explore_sand_grand", "Desert Terraformer", "Dig 300 sand or red sand blocks", "weekly", "exploration", "blocks_broken", 300, 650, "layers"),
("q_w_build_complex", "Civil Engineer", "Place 600 stone bricks or polished granite", "weekly", "building", "blocks_placed", 600, 950, "box"),
];
@@ -149,7 +235,7 @@ async fn seed_quests(pool: &SqlitePool) -> Result<()> {
.bind(desc)
.bind(period)
.bind(cat)
.bind(stat)
.bind(SPECIFIC_QUEST_TARGETS.iter().find(|(quest_id, _)| *quest_id == id).map(|(_, target)| *target).unwrap_or(stat))
.bind(target)
.bind(xp)
.bind(icon)