Skip to content

Commit

Permalink
Add LazyLibrary#stopBot()
Browse files Browse the repository at this point in the history
  • Loading branch information
srnyx committed Jun 1, 2024
1 parent 5536dc5 commit 42a8928
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ addCompilerArgs("-parameters")
repository(Repository.MAVEN_CENTRAL, Repository.JITPACK)
dependencies {
compileOnly("net.dv8tion", "JDA", "5.0.0-beta.24") // JDA
implementation("xyz.srnyx", "java-utilities", "1.0.0") // General Java utility library
implementation("xyz.srnyx", "java-utilities", "a71551bc2d") // General Java utility library
implementation("io.github.freya022", "BotCommands", "2.10.3") // Command framework
implementation("org.spongepowered", "configurate-yaml", "4.1.2") // Config manager
implementation("org.postgresql", "postgresql", "42.7.3") // Database
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/xyz/srnyx/lazylibrary/LazyLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ public LazyLibrary() {
// stop command
new Thread(() -> {
final Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()) {
if (!scanner.nextLine().equals("stop")) continue;
onStop();
System.exit(0);
}
while (scanner.hasNextLine()) if (scanner.nextLine().equals("stop")) stopBot();
}).start();
}

Expand Down Expand Up @@ -140,6 +136,14 @@ public void onStop() {
// Should be overridden
}

/**
* Stops the bot (calls {@link #onStop()} and exits the program)
*/
public void stopBot() {
onStop();
System.exit(0);
}

/**
* Checks if the given {@link Long ID} is an owner
*
Expand Down

0 comments on commit 42a8928

Please sign in to comment.