isXander / isXander/YetAnotherConfigLib

Use Supplier<Text> instead of Text for option names

Open
#220 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
155
Forks
68
PR merge metrics
No merged PRs in 30d

Description

Currently all options are passed a fixed Text for their name. Sometimes, especially in the case of buttons, it would be nice to change their text. I propose updating the option implementations and builders to use a Supplier<Text> instead. This change would also easily be backwards compatible.

To demonstrate take this simple example:

This is currently possible:

AtomicBoolean added = new AtomicBoolean(false);
ButtonOption.createBuilder()
    .name(Text.literal("Add or Remove"))
    .action((scr, opt) -> {
        if(added.get()) {
            added.set(false);
        } else {
            added.set(true);
        }
    });

This would be possible with the proposal:

AtomicBoolean added = new AtomicBoolean(false);
ButtonOption.createBuilder()
    .name(() => added.get() ? Text.literal("Remove") : Text.literal("Add"))
    .action((scr, opt) -> {
        if(added.get()) {
            added.set(false);
        } else {
            added.set(true);
        }
    });

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the option implementations and their builders that currently accept a fixed Text name, then compare them with the ButtonOption examples in the issue. Update the option naming path so the proposed Supplier form works while the existing Text form remains compatible, and verify that dynamically changing names are reflected after the action runs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.