From 599fdb9a1958ab68558c59503c894c04cbf646d3 Mon Sep 17 00:00:00 2001 From: szymon Date: Sun, 13 Sep 2020 20:41:23 +0200 Subject: [PATCH] Some cleanup and comments... --- src/main/java/net/szum123321/textile_backup/Statics.java | 2 +- .../java/net/szum123321/textile_backup/core/Utilities.java | 1 - .../szum123321/textile_backup/core/restore/AwaitThread.java | 5 ++++- .../textile_backup/mixin/MinecraftServerMixin.java | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/Statics.java b/src/main/java/net/szum123321/textile_backup/Statics.java index 61d3838..2f8c50a 100644 --- a/src/main/java/net/szum123321/textile_backup/Statics.java +++ b/src/main/java/net/szum123321/textile_backup/Statics.java @@ -40,6 +40,6 @@ public class Statics { public final static DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss"); public static final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true); - public static AwaitThread restoreAwaitThread; + public static AwaitThread restoreAwaitThread = null; public static File untouchableFile; } diff --git a/src/main/java/net/szum123321/textile_backup/core/Utilities.java b/src/main/java/net/szum123321/textile_backup/core/Utilities.java index cf0e8d5..ef4e8b5 100644 --- a/src/main/java/net/szum123321/textile_backup/core/Utilities.java +++ b/src/main/java/net/szum123321/textile_backup/core/Utilities.java @@ -18,7 +18,6 @@ package net.szum123321.textile_backup.core; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.server.MinecraftServer; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; diff --git a/src/main/java/net/szum123321/textile_backup/core/restore/AwaitThread.java b/src/main/java/net/szum123321/textile_backup/core/restore/AwaitThread.java index 2ab2d74..27bb8cc 100644 --- a/src/main/java/net/szum123321/textile_backup/core/restore/AwaitThread.java +++ b/src/main/java/net/szum123321/textile_backup/core/restore/AwaitThread.java @@ -20,6 +20,9 @@ package net.szum123321.textile_backup.core.restore; import net.szum123321.textile_backup.Statics; +/* + This thread waits some amount of time and then starts a new, independent thread +*/ public class AwaitThread extends Thread { private final int delay; private final Runnable taskRunnable; @@ -31,7 +34,7 @@ public class AwaitThread extends Thread { @Override public void run() { - Statics.LOGGER.info("Countdown begins..."); + Statics.LOGGER.info("Countdown begins... Waiting {} second.", delay); // 𝄞 This is final count down! Tu ruru Tu, Tu Ru Tu Tu ♪ try { diff --git a/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerMixin.java b/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerMixin.java index 32fba19..758ba84 100644 --- a/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerMixin.java +++ b/src/main/java/net/szum123321/textile_backup/mixin/MinecraftServerMixin.java @@ -21,12 +21,14 @@ package net.szum123321.textile_backup.mixin; import net.minecraft.server.MinecraftServer; import net.szum123321.textile_backup.core.LivingServer; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(MinecraftServer.class) public class MinecraftServerMixin implements LivingServer { + @Unique private boolean isAlive = true; @Inject(method = "shutdown", at = @At("TAIL")) @@ -34,6 +36,7 @@ public class MinecraftServerMixin implements LivingServer { isAlive = false; } + @Unique @Override public boolean isAlive() { return isAlive;