Skip to content

refactor: eliminate redundant patterns across codebase#95

Merged
70CentsApple merged 5 commits intomultiloaderfrom
copilot/refactor-redundant-code
Apr 9, 2026
Merged

refactor: eliminate redundant patterns across codebase#95
70CentsApple merged 5 commits intomultiloaderfrom
copilot/refactor-redundant-code

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

Systematic cleanup of repeated boilerplate patterns—manual config casts, duplicated HTTP helpers, raw e.printStackTrace(), copy-pasted version-branched constructors, and verbose modifier key checks.

Typed config getters

Added ConfigUtils.getBoolean/getInt/getLong/getFloat/getString to replace ~65 manual casts across 24 files:

// before
if (!(boolean) ConfigUtils.get("filter.Enabled")) { ... }
int vol = ((Number) ConfigUtils.get("notifier.Sound.Volume")).intValue();

// after
if (!ConfigUtils.getBoolean("filter.Enabled")) { ... }
int vol = ConfigUtils.getInt("notifier.Sound.Volume");

Translator HTTP dedup

Extracted AbstractTranslator.buildQueryString(Map) — identical URL-encoding logic was in Google, Microsoft, and Baidu translators.

Structured exception logging

Added LoggerUtils.error(String, Throwable) overload. Replaced all 18 e.printStackTrace() calls with proper SLF4J logging. Removed a throw new Exception() anti-pattern in ConfigStorage.get() that existed solely for stack trace output.

Data-driven KeyboardUtils

Replaced ~50-line switch/case block with EnumMap<KeyModifiers, int[]> lookup tables for required and forbidden modifier keys. Extracted isAnyKeyDown() helper.

Version-branched HoverEvent helper

TextUtils.showTextHoverEvent(Component) centralizes the //? if >=1.21.5 branching for HoverEvent.ShowText vs new HoverEvent(Action.SHOW_TEXT, ...) — used in 10 call sites across 5 files.

Minor cleanups

  • ChatColorEraser.work() simplified to computeIfAbsent (matching NickHider)
  • Shared TextUtils.evictOldest(Map, int) replaces manual eldest-entry eviction loops in NickHider and TextUtils

Copilot AI and others added 5 commits April 9, 2026 03:28
Replace manual cast patterns across all feature/logic files:
- (boolean) ConfigUtils.get() → ConfigUtils.getBoolean()
- ((Number) ConfigUtils.get()).intValue() → ConfigUtils.getInt()
- ((Number) ConfigUtils.get()).longValue() → ConfigUtils.getLong()
- ((Number) ConfigUtils.get()).floatValue() → ConfigUtils.getFloat()
- (String) ConfigUtils.get() → ConfigUtils.getString()

List casts and config UI files are left unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: 70CentsApple <63957117+70CentsApple@users.noreply.github.com>
…rintStackTrace with LoggerUtils

Agent-Logs-Url: https://github.com/70CentsApple/ChatTools/sessions/9b4675d3-008d-40ad-8213-b93cc57b7712

Co-authored-by: 70CentsApple <63957117+70CentsApple@users.noreply.github.com>
… eviction consolidation

Agent-Logs-Url: https://github.com/70CentsApple/ChatTools/sessions/9b4675d3-008d-40ad-8213-b93cc57b7712

Co-authored-by: 70CentsApple <63957117+70CentsApple@users.noreply.github.com>
@70CentsApple 70CentsApple marked this pull request as ready for review April 9, 2026 04:59
@70CentsApple 70CentsApple merged commit c53682b into multiloader Apr 9, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants