kill_r command now logs who called it.

Changed kill_r to killR
2.x-1.16
szymon 2020-08-05 20:34:54 +02:00
parent b2fe8492d8
commit 073f01740f
2 changed files with 6 additions and 1 deletions

View File

@ -26,11 +26,15 @@ import net.szum123321.textile_backup.Statics;
public class KillRestoreCommand { public class KillRestoreCommand {
public static LiteralArgumentBuilder<ServerCommandSource> register() { public static LiteralArgumentBuilder<ServerCommandSource> register() {
return CommandManager.literal("kill_r") //TODO: come up with something better return CommandManager.literal("killR")
.executes(ctx -> { .executes(ctx -> {
if(Statics.restoreAwaitThread != null && Statics.restoreAwaitThread.isAlive()) { if(Statics.restoreAwaitThread != null && Statics.restoreAwaitThread.isAlive()) {
Statics.restoreAwaitThread.interrupt(); Statics.restoreAwaitThread.interrupt();
ctx.getSource().sendFeedback(new LiteralText("Backup restoration successfully stopped"), false); ctx.getSource().sendFeedback(new LiteralText("Backup restoration successfully stopped"), false);
Statics.LOGGER.info("{} cancelled backup restoration.", ctx.getSource().getEntity() != null ?
"Player: " + ctx.getSource().getName() :
"SERVER"
);
} else { } else {
ctx.getSource().sendFeedback(new LiteralText("Failed to stop backup restoration"), false); ctx.getSource().sendFeedback(new LiteralText("Failed to stop backup restoration"), false);
} }

View File

@ -37,6 +37,7 @@ public class AwaitThread extends Thread {
try { try {
Thread.sleep(delay * 1000); Thread.sleep(delay * 1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Statics.LOGGER.info("Backup restoration cancelled.");
return; return;
} }