Skip to content

Commit

Permalink
Merge pull request #128 from webhead1104/stop-command
Browse files Browse the repository at this point in the history
Fix stop command
  • Loading branch information
webhead1104 authored Jun 20, 2024
2 parents 59adc92 + 664bd6b commit 56dfcd7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/net/cytonic/cytosis/commands/StopCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ public class StopCommand extends Command {
public StopCommand() {
super("stop");
setCondition((sender, _) -> sender.hasPermission("cytosis.commands.stop"));
var areYouSureArgument = ArgumentType.Word("areyousure").from("confirm");
areYouSureArgument.setSuggestionCallback(((_, _, suggestion) -> suggestion.addEntry(new SuggestionEntry("confirm"))));
setDefaultExecutor((sender, _) -> sender.sendMessage(MiniMessageTemplate.MM."<RED>Are you sure you want to stop the server? If so add confirm to the command"));
var confirmArgument = ArgumentType.Word("confirmArgument").from("confirm");
confirmArgument.setSuggestionCallback(((_, _, suggestion) -> suggestion.addEntry(new SuggestionEntry("confirm"))));
addSyntax((sender, context) -> {
if (sender.hasPermission("cytonic.commands.stop")) {
if (context.get(areYouSureArgument).equalsIgnoreCase("confirm")) {
if (context.get(confirmArgument).equalsIgnoreCase("confirm")) {
sender.sendMessage("Stopping the server...");
MinecraftServer.stopCleanly();
} else {
sender.sendMessage(MiniMessageTemplate.MM."<RED>Are you sure you want to stop the server? If so add confirm to the command");
}
}
});
}, confirmArgument);
}
}

0 comments on commit 56dfcd7

Please sign in to comment.