v1.0.5: Fix console path — was never fetching from Discord

Console /rules hit early return before DIAG logs and before any
Discord fetch. Now fetches async like the player path. DIAG logs
moved before the player/console branch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude (Chronicler #83 - The Compiler)
2026-04-13 18:14:29 -05:00
parent b4fbfc6adf
commit 98f4f5b82a
5 changed files with 48 additions and 7 deletions

View File

@@ -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.

View File

@@ -10,7 +10,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle'
version = '1.0.4'
version = '1.0.5'
group = 'com.firefrostgaming.rules'
archivesBaseName = 'firefrostrules'

View File

@@ -15,16 +15,28 @@ public class RulesCommand {
public static void register(CommandDispatcher<CommandSourceStack> 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()));

View File

@@ -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