Skip to content

Refactor OnComboCompleteListener: split handler and make feedback configurable/localized #217

@DiamondDagger590

Description

@DiamondDagger590

Context

us.eunoians.mcrpg.listener.ability.OnComboCompleteListener#onComboComplete is a ~90-line @EventHandler that inlines every precondition check, feedback message, sound cue, and ability dispatch into a single method. A TODO(backlog) immediately above the method references this ticket.

Problems

Structural:

  • One method does ability resolution, world-enablement gating, cooldown checking, mana checking, feedback messaging, ability dispatch, and cooldown application.
  • Hard to add a new precondition (e.g., stamina, debuff gating) without making the method longer.
  • Hard to test — each branch requires a full Bukkit event setup.

Hard-coded values:

  • Feedback strings: "On Cooldown (Ns)", "Not Enough Mana", "X is on cooldown!", "Not enough mana to use X!".
  • Sounds: Sound.UI_BUTTON_CLICK (no ability at slot), Sound.BLOCK_NOTE_BLOCK_BASS (cooldown / insufficient mana) with hard-coded pitch/volume.
  • CENTER_CONTENT_DURATION_TICKS = 60L — how long the action-bar feedback persists.
  • All strings bypass the localization system entirely.

Proposed work

Structural:

  • Split the handler into per-precondition private helpers (or a small ComboActivationDispatcher collaborator) that each return a result type indicating success, skip, or failure-with-feedback.
  • Leave the @EventHandler method short — resolve the ability and delegate.

Configuration:

  • Move feedback sounds, volumes, pitches, and the center-content persistence duration into combo.yml with Route constants on ComboConfigFile.
  • Route all player-facing strings (action bar + chat) through McRPGLocalizationManager with new LocalizationKey routes and entries in every bundled locale YAML (English minimum).

Acceptance criteria

  • onComboComplete is at most ~20 lines; preconditions are extracted into named helpers or a collaborator.
  • No user-facing strings live in the listener — all routed through LocalizationKey + McRPGLocalizationManager.
  • Sounds, volumes, pitches, and feedback duration come from combo.yml.
  • Unit tests cover the precondition helpers (or collaborator) without needing a live event.
  • TODO(backlog) above the method is removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementA ticket that describes some sort of improvement that can be made to existing functionality.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions