From fff643ac3a42acfcc3f197324e4f75b21e347f7d Mon Sep 17 00:00:00 2001 From: Lilly <46890129+RainbowDashLabs@users.noreply.github.com> Date: Thu, 4 Apr 2024 15:45:42 +0200 Subject: [PATCH] Replace run command with suggest command for changable value button --- .../command/bloodnight/ManageMob.java | 10 +++++----- .../command/bloodnight/ManageMobs.java | 20 +++++++++---------- .../command/bloodnight/ManageNight.java | 12 +++++------ .../bloodnight/ManageNightSelection.java | 17 ++++++++-------- .../bloodnight/command/util/CommandUtil.java | 10 ++++++++-- .../src/main/resources/messages.properties | 2 +- 6 files changed, 39 insertions(+), 32 deletions(-) diff --git a/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/bloodnight/ManageMob.java b/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/bloodnight/ManageMob.java index 3ca149a0..ad54140b 100644 --- a/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/bloodnight/ManageMob.java +++ b/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/bloodnight/ManageMob.java @@ -49,7 +49,7 @@ import java.util.stream.Collectors; import static de.eldoria.bloodnight.command.util.CommandUtil.changeButton; -import static de.eldoria.bloodnight.command.util.CommandUtil.changeableValue; +import static de.eldoria.bloodnight.command.util.CommandUtil.changeableValueWithInput; import static de.eldoria.bloodnight.command.util.CommandUtil.getBooleanField; import static de.eldoria.bloodnight.command.util.CommandUtil.getToggleField; import static de.eldoria.eldoutilities.localization.ILocalizer.escape; @@ -273,9 +273,9 @@ private void sendMobListPage(World world, CommandSender sender, Map.Entry> %s >""".stripIndent() .formatted( - changeableValue("field.nightDuration", nightSettings.getNightDuration() + " " + escape("value.seconds"), cmd + "nightDuration ") + changeableValueWithInput("field.nightDuration", nightSettings.getNightDuration() + " " + escape("value.seconds"), cmd + "nightDuration ") ); case RANGE -> """ > %s > %s""".stripIndent() .formatted( - changeableValue("field.minDuration", nightSettings.getNightDuration() + " " + escape("value.seconds"), cmd + "nightDuration "), - changeableValue("field.maxDuration", nightSettings.getMaxNightDuration() + " " + escape("value.seconds"), cmd + "maxNightDuration ") + changeableValueWithInput("field.minDuration", nightSettings.getNightDuration() + " " + escape("value.seconds"), cmd + "nightDuration "), + changeableValueWithInput("field.maxDuration", nightSettings.getMaxNightDuration() + " " + escape("value.seconds"), cmd + "maxNightDuration ") ); }; @@ -149,9 +149,9 @@ private void sendNightSettings(CommandSender sender, WorldSettings worldSettings // skippable getBooleanField(nightSettings.isSkippable(), cmd + "skippable {bool}", "field.sleep", "state.allow", "state.deny"), // night begin - changeableValue("field.nightBegin", nightSettings.getNightBegin(), cmd + "nightBegin "), + changeableValueWithInput("field.nightBegin", nightSettings.getNightBegin(), cmd + "nightBegin "), // night end - changeableValue("field.nightEnd", nightSettings.getNightEnd(), cmd + "nightEnd "), + changeableValueWithInput("field.nightEnd", nightSettings.getNightEnd(), cmd + "nightEnd "), // Night duration type getToggleField(durationMode == NightSettings.NightDuration.NORMAL, cmd + "durationMode NORMAL", "state.normal"), getToggleField(durationMode == NightSettings.NightDuration.EXTENDED, cmd + "durationMode EXTENDED", "state.extended"), diff --git a/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/bloodnight/ManageNightSelection.java b/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/bloodnight/ManageNightSelection.java index 2361a92d..36de95f8 100644 --- a/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/bloodnight/ManageNightSelection.java +++ b/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/bloodnight/ManageNightSelection.java @@ -52,7 +52,7 @@ import java.util.stream.Collectors; import static de.eldoria.bloodnight.command.util.CommandUtil.changeButton; -import static de.eldoria.bloodnight.command.util.CommandUtil.changeableValue; +import static de.eldoria.bloodnight.command.util.CommandUtil.changeableValueWithInput; import static de.eldoria.bloodnight.command.util.CommandUtil.getToggleField; import static de.eldoria.bloodnight.config.worldsettings.NightSelection.NightSelectionType; import static de.eldoria.bloodnight.config.worldsettings.NightSelection.NightSelectionType.CURVE; @@ -97,6 +97,7 @@ private static String getMoonPhaseSign(int phase) { default -> throw new IllegalStateException("Unexpected value: " + phase); }; } + private static String getMoonPhaseSignLegacy(int phase) { return switch (phase) { case 0 -> "§f████"; @@ -226,7 +227,7 @@ private void sendWorldPage(World world, CommandSender sender, int p) { """.stripIndent() - .formatted(changeableValue("field.probability", ns.getProbability(), cmd + "probability ")); + .formatted(changeableValueWithInput("field.probability", ns.getProbability(), cmd + "probability ")); case REAL_MOON_PHASE, MOON_PHASE -> { var phases = ns.getMoonPhase().entrySet().stream().map(e -> { var hover = """ @@ -256,15 +257,15 @@ private void sendWorldPage(World world, CommandSender sender, int p) { %s """.stripIndent() .formatted( - changeableValue("field.interval", ns.getInterval(), cmd + "interval "), - changeableValue("field.intervalProbability", ns.getIntervalProbability(), cmd + "intervalProbability ") + changeableValueWithInput("field.interval", ns.getInterval(), cmd + "interval "), + changeableValueWithInput("field.intervalProbability", ns.getIntervalProbability(), cmd + "intervalProbability ") ); case PHASE -> """ %s %s %s """.stripIndent() .formatted( - changeableValue("field.amount", ns.getPhaseCustom().size(), cmd + "phaseAmount "), + changeableValueWithInput("field.amount", ns.getPhaseCustom().size(), cmd + "phaseAmount "), escape("field.amount"), changeButton(cmd + "phase none ") ); @@ -274,9 +275,9 @@ private void sendWorldPage(World world, CommandSender sender, int p) { %s """.stripIndent() .formatted( - changeableValue("field.length", ns.getPeriod(), cmd + "period "), - changeableValue("field.minProb", ns.getMinCurveVal(), cmd + "minCurveVal "), - changeableValue("field.maxProb", ns.getMaxCurveVal(), cmd + "maxCurveVal ") + changeableValueWithInput("field.length", ns.getPeriod(), cmd + "period "), + changeableValueWithInput("field.minProb", ns.getMinCurveVal(), cmd + "minCurveVal "), + changeableValueWithInput("field.maxProb", ns.getMaxCurveVal(), cmd + "maxCurveVal ") ); }; diff --git a/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/util/CommandUtil.java b/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/util/CommandUtil.java index a8f4d9b2..afc72b06 100644 --- a/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/util/CommandUtil.java +++ b/BloodNight-core/src/main/java/de/eldoria/bloodnight/command/util/CommandUtil.java @@ -114,13 +114,19 @@ public static String getBooleanField(boolean currValue, String cmd, String field public static String changeButton(String command) { return changeButton(command, "action.change", "change"); } + public static String changeButtonWithInput(String command) { + return changeButtonWithInput(command, "action.change", "change"); + } public static String changeButton(String command, String label, String color) { return "<%s>[%s]".formatted(command, color, escape(label)); } + public static String changeButtonWithInput(String command, String label, String color) { + return "<%s>[%s]".formatted(command, color, escape(label)); + } - public static String changeableValue(String field, Object value, String command) { - return "%s %s".formatted(value(field, value), changeButton(command)); + public static String changeableValueWithInput(String field, Object value, String command) { + return "%s %s".formatted(value(field, value), changeButtonWithInput(command)); } public static String value(String field, Object value) { diff --git a/BloodNight-core/src/main/resources/messages.properties b/BloodNight-core/src/main/resources/messages.properties index c15f2de0..42bfb45f 100644 --- a/BloodNight-core/src/main/resources/messages.properties +++ b/BloodNight-core/src/main/resources/messages.properties @@ -178,7 +178,7 @@ state.phase6=First quarter state.phase7=Waxing gibbous state.random=Random state.range=Range -state.realMoonPhase=Moon +state.realMoonPhase=Real Moon state.vanilla=vanilla syntax.commandPlayer=Please enter a command. Use {player} as playername placeholder syntax.field=field