diff --git a/docs/code-bridge/responses/RES-2026-04-13-rules-still-returning-defaults-v2.md b/docs/code-bridge/responses/RES-2026-04-13-rules-still-returning-defaults-v2.md new file mode 100644 index 0000000..a8d6a92 --- /dev/null +++ b/docs/code-bridge/responses/RES-2026-04-13-rules-still-returning-defaults-v2.md @@ -0,0 +1,18 @@ +# Response: DIAG lines missing — console path early exit + +**Re:** Follow-up on REQ-2026-04-13-rules-still-returning-defaults +**Date:** 2026-04-13 + +## Root Cause +The DIAG logs were placed AFTER the console/player branch (line 23). The console path exits on line 18-20 — before DIAG ever runs. + +More importantly: the console path NEVER fetched from Discord. It only returned `RulesCache.getRules()` which is the hardcoded fallback (no fetch has ever populated the cache). + +## Fix in v1.0.5 +1. Moved DIAG logging before the branch — fires on every /rules invocation +2. Console path now triggers `DiscordFetcher.fetchRulesAsync()` just like the player path +3. Console output is sent async after fetch completes + +## Deploy +firefrostrules-1.0.5-1.20.1-forge.jar → Otherworld. +Run /rules from console — should see [DIAG] lines AND a real Discord fetch attempt. diff --git a/services/rules-mod/1.20.1/build.gradle b/services/rules-mod/1.20.1/build.gradle index 86bb720..af2f809 100755 --- a/services/rules-mod/1.20.1/build.gradle +++ b/services/rules-mod/1.20.1/build.gradle @@ -10,7 +10,7 @@ buildscript { apply plugin: 'net.minecraftforge.gradle' -version = '1.0.4' +version = '1.0.5' group = 'com.firefrostgaming.rules' archivesBaseName = 'firefrostrules' diff --git a/services/rules-mod/1.20.1/src/main/java/com/firefrostgaming/rules/RulesCommand.java b/services/rules-mod/1.20.1/src/main/java/com/firefrostgaming/rules/RulesCommand.java index 602c85c..936c7dc 100755 --- a/services/rules-mod/1.20.1/src/main/java/com/firefrostgaming/rules/RulesCommand.java +++ b/services/rules-mod/1.20.1/src/main/java/com/firefrostgaming/rules/RulesCommand.java @@ -15,16 +15,28 @@ public class RulesCommand { public static void register(CommandDispatcher dispatcher) { dispatcher.register(Commands.literal("rules").executes(context -> { CommandSourceStack source = context.getSource(); - if (source.getEntity() == null || !(source.getEntity() instanceof ServerPlayer)) { - source.sendSystemMessage(DiscordFormatter.formatRules(RulesCache.getRules())); - return 1; - } - ServerPlayer player = (ServerPlayer) source.getEntity(); - LOGGER.info("[DIAG] token length={}, channel={}, messageId={}, isValid={}", + LOGGER.info("[DIAG] /rules invoked. isPlayer={}, token length={}, channel={}, messageId={}, isValid={}", + source.getEntity() instanceof ServerPlayer, ServerRulesConfig.BOT_TOKEN.get().length(), ServerRulesConfig.CHANNEL_ID.get(), ServerRulesConfig.MESSAGE_ID.get(), ServerRulesConfig.isMessageIdValid()); + if (source.getEntity() == null || !(source.getEntity() instanceof ServerPlayer)) { + LOGGER.info("[DIAG] Console path — fetching from Discord"); + DiscordFetcher.fetchRulesAsync().thenAccept(fetchedRules -> { + String rulesText; + if (fetchedRules != null) { + RulesCache.updateCache(fetchedRules); + rulesText = fetchedRules; + } else { + LOGGER.warn("Discord fetch failed. Using fallback rules."); + rulesText = RulesCache.getRules(); + } + source.getServer().execute(() -> source.sendSystemMessage(DiscordFormatter.formatRules(rulesText))); + }); + return 1; + } + ServerPlayer player = (ServerPlayer) source.getEntity(); if (!CooldownManager.checkAndUpdateCooldown(player)) return 0; if (RulesCache.isCacheValid()) { player.sendSystemMessage(DiscordFormatter.formatRules(RulesCache.getRules())); diff --git a/services/rules-mod/CHANGELOG.md b/services/rules-mod/CHANGELOG.md index ba3e048..9c1b33d 100644 --- a/services/rules-mod/CHANGELOG.md +++ b/services/rules-mod/CHANGELOG.md @@ -1,5 +1,16 @@ # Rules Mod Changelog +## [1.0.5] - 2026-04-13 *(diagnostic + fix — 1.20.1 only)* + +### Fixed +- **Console path never fetched from Discord** — `/rules` from server console hit early return that only read from cache/fallback, never triggered `DiscordFetcher`. Console now fetches async like the player path. +- **DIAG logs placed after early exit** — moved `[DIAG]` logging before the player/console branch so it fires on every invocation regardless of source + +### Note +- Only `firefrostrules-1.0.5-1.20.1-forge.jar` was built. Other versions remain at 1.0.3. + +--- + ## [1.0.4] - 2026-04-13 *(diagnostic build — 1.20.1 only)* ### Added diff --git a/services/rules-mod/firefrostrules-1.0.5-1.20.1-forge.jar b/services/rules-mod/firefrostrules-1.0.5-1.20.1-forge.jar new file mode 100644 index 0000000..d93d5a0 Binary files /dev/null and b/services/rules-mod/firefrostrules-1.0.5-1.20.1-forge.jar differ