diff --git a/build-number.txt b/build-number.txt index af9719be..54da69e9 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -3517 \ No newline at end of file +3519 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/ConsolePlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/ConsolePlugin.java index 48e9f29b..ef302de8 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/ConsolePlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/ConsolePlugin.java @@ -17,10 +17,13 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import org.jetbrains.annotations.NotNull; import org.jline.reader.*; +import java.io.IOException; +import java.nio.file.Path; import java.util.List; import java.util.Map; public class ConsolePlugin implements Completer { + private static final Path HISTORY_PATH = Path.of(".console_history"); private static final ConsoleFormatRenderer RENDERER = new ConsoleFormatRenderer(); private final List allBots; @@ -40,10 +43,10 @@ public class ConsolePlugin implements Completer { this.reader = LineReaderBuilder .builder() .completer(this) + .variable(LineReader.HISTORY_FILE, HISTORY_PATH) + .option(LineReader.Option.DISABLE_EVENT_EXPANSION, true) .build(); - reader.option(LineReader.Option.DISABLE_EVENT_EXPANSION, true); - final Thread thread = new Thread( () -> { while (true) { @@ -55,6 +58,10 @@ public class ConsolePlugin implements Completer { } handleLine(line); + + try { + reader.getHistory().save(); + } catch (final IOException ignored) { } } }, "Console Thread"