Show the resulting value on number step buttons

Each step button on the number screen shows the value it leads to, and
marks when that value is the minimum or maximum.
This commit is contained in:
2026-10-26 10:20:50 +01:00
parent 32797bd2a8
commit 38a33b7298
3 changed files with 12 additions and 4 deletions
@@ -86,6 +86,9 @@ PARTICLE_VALUE_SELECTED = §aSelected
PARTICLE_VALUE_RESET = §eReset to {0}
PARTICLE_NUMBER_RANGE = §7Range§8: §e{0} §8- §e{1}
PARTICLE_NUMBER_TYPE = §eClick to type a value
PARTICLE_NUMBER_RESULT = §7→ §e{0}
PARTICLE_NUMBER_AT_MAX = §7→ §e{0} §8(max)
PARTICLE_NUMBER_AT_MIN = §7→ §e{0} §8(min)
PARTICLE_COLOR_EDITOR = §0Colours
PARTICLE_COLOR_REMOVE = §eClick to remove
PARTICLE_COLOR_ADD = §aAdd colour
@@ -86,6 +86,9 @@ PARTICLE_VALUE_SELECTED = §aAusgewählt
PARTICLE_VALUE_RESET = §eAuf {0} zurücksetzen
PARTICLE_NUMBER_RANGE = §7Bereich§8: §e{0} §8- §e{1}
PARTICLE_NUMBER_TYPE = §eZum Eingeben klicken
PARTICLE_NUMBER_RESULT = §7→ §e{0}
PARTICLE_NUMBER_AT_MAX = §7→ §e{0} §8(Max)
PARTICLE_NUMBER_AT_MIN = §7→ §e{0} §8(Min)
PARTICLE_COLOR_EDITOR = §0Farben
PARTICLE_COLOR_REMOVE = §eZum Entfernen klicken
PARTICLE_COLOR_ADD = §aFarbe hinzufügen
@@ -86,10 +86,12 @@ class ValueEditors {
private SWItem stepItem(Player player, Material material, double delta, double step, double value, double min, double max, boolean integer, Predicate<Double> apply, Runnable reopen) {
String label = (delta < 0 ? "§c-" : "§a+") + number(Math.abs(delta));
return new SWItem(material, label, clickType -> {
// Snap to the step grid and drop floating point noise, so repeated steps do not drift
double next = integer ? Math.round(value + delta) : Math.round(Math.round((value + delta) / step) * step * 1e6) / 1e6;
apply.test(Math.max(min, Math.min(max, next)));
// Snap to the step grid and drop floating point noise, so repeated steps do not drift
double unclamped = integer ? Math.round(value + delta) : Math.round(Math.round((value + delta) / step) * step * 1e6) / 1e6;
double next = Math.max(min, Math.min(max, unclamped));
String limit = next == max && unclamped >= max ? "PARTICLE_NUMBER_AT_MAX" : next == min && unclamped <= min ? "PARTICLE_NUMBER_AT_MIN" : "PARTICLE_NUMBER_RESULT";
return new SWItem(material, label, List.of(msg(limit, player, number(next))), false, clickType -> {
apply.test(next);
reopen.run();
});
}