Replaced Statics with Globals - now a singleton

Moved updateTMPFSFlag from Utilities to Statics/Globals

Added proper shutdown procedure for executorService (shutdownQueueExecutor) - should repair #37

Refactored some commands
2.x
Szum123321 2022-08-30 01:15:56 +02:00
parent 03743dbdc9
commit b7da7dbc6f
15 changed files with 210 additions and 168 deletions

View File

@ -0,0 +1,108 @@
/*
* A simple backup mod for Fabric
* Copyright (C) 2022 Szum123321
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
package net.szum123321.textile_backup;
import net.minecraft.server.MinecraftServer;
import net.szum123321.textile_backup.core.Utilities;
import net.szum123321.textile_backup.core.create.MakeBackupRunnable;
import net.szum123321.textile_backup.core.restore.AwaitThread;
import org.apache.commons.io.FileUtils;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
public class Globals {
public static final Globals INSTANCE = new Globals();
public final static DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss");
private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME);
private ExecutorService executorService = Executors.newSingleThreadExecutor();
public final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true);
public boolean disableWatchdog = false;
private boolean disableTMPFiles = false;
private AwaitThread restoreAwaitThread = null;
private Path lockedPath = null;
private Globals() {}
public ExecutorService getQueueExecutor() { return executorService; }
public void resetQueueExecutor() {
if(!executorService.isShutdown()) return;
executorService = Executors.newSingleThreadExecutor();
}
public void shutdownQueueExecutor(long timeout) {
if(executorService.isShutdown()) return;
executorService.shutdown();
try {
if(!executorService.awaitTermination(timeout, TimeUnit.MICROSECONDS)) {
log.error("Timeout occurred while waiting for currently running backups to finish!");
executorService.shutdownNow().stream()
.filter(r -> r instanceof MakeBackupRunnable)
.map(r -> (MakeBackupRunnable)r)
.forEach(r -> log.error("Dropping: {}", r.toString()));
if(!executorService.awaitTermination(1000, TimeUnit.MICROSECONDS))
log.error("Couldn't shut down the executor!");
}
} catch (InterruptedException e) {
log.error("An exception occurred!", e);
}
}
public Optional<AwaitThread> getAwaitThread() { return Optional.ofNullable(restoreAwaitThread); }
public void setAwaitThread(AwaitThread th) { restoreAwaitThread = th; }
public Optional<Path> getLockedFile() { return Optional.ofNullable(lockedPath); }
public void setLockedFile(Path p) { lockedPath = p; }
public boolean disableTMPFS() { return disableTMPFiles; }
public void updateTMPFSFlag(MinecraftServer server) {
disableTMPFiles = false;
Path tmp_dir = Path.of(System.getProperty("java.io.tmpdir"));
if(
FileUtils.sizeOfDirectory(Utilities.getWorldFolder(server).toFile()) >=
tmp_dir.toFile().getUsableSpace()
) {
log.error("Not enough space left in TMP directory! ({})", tmp_dir);
disableTMPFiles = true;
}
if(!Files.isWritable(tmp_dir)) {
log.error("TMP filesystem ({}) is read-only!", tmp_dir);
disableTMPFiles = true;
}
if(disableTMPFiles) log.error("Might cause: https://github.com/Szum123321/textile_backup/wiki/ZIP-Problems");
}
}

View File

@ -1,40 +0,0 @@
/*
* A simple backup mod for Fabric
* Copyright (C) 2020 Szum123321
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.szum123321.textile_backup;
import net.szum123321.textile_backup.core.restore.AwaitThread;
import java.nio.file.Path;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
public class Statics {
public final static DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss");
public static ExecutorService executorService = Executors.newSingleThreadExecutor();
public static final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true);
public static boolean disableWatchdog = false;
public static AwaitThread restoreAwaitThread = null;
public static Optional<Path> untouchableFile = Optional.empty();
public static boolean disableTMPFiles = false;
}

View File

@ -38,13 +38,10 @@ import net.szum123321.textile_backup.commands.restore.RestoreBackupCommand;
import net.szum123321.textile_backup.config.ConfigHelper;
import net.szum123321.textile_backup.config.ConfigPOJO;
import net.szum123321.textile_backup.core.ActionInitiator;
import net.szum123321.textile_backup.core.Utilities;
import net.szum123321.textile_backup.core.create.BackupContext;
import net.szum123321.textile_backup.core.create.BackupHelper;
import net.szum123321.textile_backup.core.create.BackupScheduler;
import java.util.concurrent.Executors;
public class TextileBackup implements ModInitializer {
public static final String MOD_NAME = "Textile Backup";
public static final String MOD_ID = "textile_backup";
@ -62,15 +59,14 @@ public class TextileBackup implements ModInitializer {
//Restart Executor Service in single-player
ServerLifecycleEvents.SERVER_STARTING.register(server -> {
if(Statics.executorService.isShutdown()) Statics.executorService = Executors.newSingleThreadExecutor();
Utilities.updateTMPFSFlag(server);
Globals.INSTANCE.resetQueueExecutor();
Globals.INSTANCE.updateTMPFSFlag(server);
});
ServerLifecycleEvents.SERVER_STOPPED.register(server -> {
Statics.executorService.shutdown();
Globals.INSTANCE.shutdownQueueExecutor(60000);
if (config.get().shutdownBackup && Statics.globalShutdownBackupFlag.get()) {
if (config.get().shutdownBackup && Globals.INSTANCE.globalShutdownBackupFlag.get()) {
BackupHelper.create(
BackupContext.Builder
.newBackupContextBuilder()

View File

@ -25,7 +25,7 @@ import com.mojang.brigadier.suggestion.SuggestionProvider;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.server.command.ServerCommandSource;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.core.Utilities;
import net.szum123321.textile_backup.core.restore.RestoreHelper;
@ -39,11 +39,11 @@ public final class FileSuggestionProvider implements SuggestionProvider<ServerCo
}
@Override
public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> ctx, SuggestionsBuilder builder) throws CommandSyntaxException {
public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> ctx, SuggestionsBuilder builder) {
String remaining = builder.getRemaining();
for (RestoreHelper.RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getServer())) {
String formattedCreationTime = file.getCreationTime().format(Statics.defaultDateTimeFormatter);
String formattedCreationTime = file.getCreationTime().format(Globals.defaultDateTimeFormatter);
if (formattedCreationTime.startsWith(remaining)) {
if (Utilities.wasSentByPlayer(ctx.getSource())) { //was typed by player

View File

@ -22,7 +22,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.TextileLogger;
import net.szum123321.textile_backup.core.create.BackupContext;
@ -41,9 +41,8 @@ public class StartBackupCommand {
}
private static int execute(ServerCommandSource source, @Nullable String comment) {
if(!Statics.executorService.isShutdown()) {
try {
Statics.executorService.submit(
Globals.INSTANCE.getQueueExecutor().submit(
BackupHelper.create(
BackupContext.Builder
.newBackupContextBuilder()
@ -58,7 +57,6 @@ public class StartBackupCommand {
log.error("Something went wrong while executing command!", e);
throw e;
}
}
return 1;
}

View File

@ -23,10 +23,10 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.TextileLogger;
import net.szum123321.textile_backup.commands.CommandExceptions;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.commands.FileSuggestionProvider;
import net.szum123321.textile_backup.core.Utilities;
@ -52,7 +52,7 @@ public class DeleteCommand {
LocalDateTime dateTime;
try {
dateTime = LocalDateTime.from(Statics.defaultDateTimeFormatter.parse(fileName));
dateTime = LocalDateTime.from(Globals.defaultDateTimeFormatter.parse(fileName));
} catch (DateTimeParseException e) {
throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e);
}
@ -63,7 +63,7 @@ public class DeleteCommand {
stream.filter(Utilities::isValidBackup)
.filter(file -> Utilities.getFileCreationTime(file).orElse(LocalDateTime.MIN).equals(dateTime))
.findFirst().ifPresent(file -> {
if(Statics.untouchableFile.isEmpty() || !Statics.untouchableFile.get().equals(file)) {
if(Globals.INSTANCE.getLockedFile().filter(p -> p == file).isEmpty()) {
try {
Files.delete(file);
log.sendInfo(source, "File {} successfully deleted!", file);

View File

@ -21,22 +21,27 @@ package net.szum123321.textile_backup.commands.restore;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.TextileLogger;
import net.szum123321.textile_backup.core.Utilities;
import java.util.Optional;
import net.szum123321.textile_backup.core.restore.AwaitThread;
public class KillRestoreCommand {
private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME);
public static LiteralArgumentBuilder<ServerCommandSource> register() {
return CommandManager.literal("killR")
.executes(ctx -> {
if(Statics.restoreAwaitThread != null && Statics.restoreAwaitThread.isAlive()) {
Statics.restoreAwaitThread.interrupt();
Statics.globalShutdownBackupFlag.set(true);
Statics.untouchableFile = Optional.empty();
if(Globals.INSTANCE.getAwaitThread().filter(Thread::isAlive).isEmpty()) {
log.sendInfo(ctx.getSource(), "Failed to stop backup restoration");
return -1;
}
AwaitThread thread = Globals.INSTANCE.getAwaitThread().get();
thread.interrupt();
Globals.INSTANCE.globalShutdownBackupFlag.set(true);
Globals.INSTANCE.setLockedFile(null);
log.info("{} cancelled backup restoration.", Utilities.wasSentByPlayer(ctx.getSource()) ?
"Player: " + ctx.getSource().getName() :
@ -45,9 +50,7 @@ public class KillRestoreCommand {
if(Utilities.wasSentByPlayer(ctx.getSource()))
log.sendInfo(ctx.getSource(), "Backup restoration successfully stopped.");
} else {
log.sendInfo(ctx.getSource(), "Failed to stop backup restoration");
}
return 1;
});
}

View File

@ -24,10 +24,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.TextileLogger;
import net.szum123321.textile_backup.commands.CommandExceptions;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.commands.FileSuggestionProvider;
import net.szum123321.textile_backup.core.restore.RestoreContext;
import net.szum123321.textile_backup.core.restore.RestoreHelper;
@ -70,11 +70,16 @@ public class RestoreBackupCommand {
}
private static int execute(String file, @Nullable String comment, ServerCommandSource source) throws CommandSyntaxException {
if(Statics.restoreAwaitThread == null || (Statics.restoreAwaitThread != null && !Statics.restoreAwaitThread.isAlive())) {
if(Globals.INSTANCE.getAwaitThread().filter(Thread::isAlive).isPresent()) {
log.sendInfo(source, "Someone has already started another restoration.");
return -1;
}
LocalDateTime dateTime;
try {
dateTime = LocalDateTime.from(Statics.defaultDateTimeFormatter.parse(file));
dateTime = LocalDateTime.from(Globals.defaultDateTimeFormatter.parse(file));
} catch (DateTimeParseException e) {
throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e);
}
@ -84,27 +89,23 @@ public class RestoreBackupCommand {
if(backupFile.isPresent()) {
log.info("Found file to restore {}", backupFile.get().getFile().getFileName().toString());
} else {
log.sendInfo(source, "No file created on {} was found!", dateTime.format(Statics.defaultDateTimeFormatter));
return 0;
log.sendInfo(source, "No file created on {} was found!", dateTime.format(Globals.defaultDateTimeFormatter));
return -1;
}
Statics.restoreAwaitThread = RestoreHelper.create(
Globals.INSTANCE.setAwaitThread(
RestoreHelper.create(
RestoreContext.Builder.newRestoreContextBuilder()
.setCommandSource(source)
.setFile(backupFile.get())
.setComment(comment)
.build()
)
);
Statics.restoreAwaitThread.start();
Globals.INSTANCE.getAwaitThread().get().start();
return 1;
} else {
log.sendInfo(source, "Someone has already started another restoration.");
return 0;
}
}
}

View File

@ -25,13 +25,12 @@ import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.TextileLogger;
import net.szum123321.textile_backup.config.ConfigHelper;
import net.szum123321.textile_backup.config.ConfigPOJO;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.file.SimplePathVisitor;
import org.jetbrains.annotations.NotNull;
@ -75,7 +74,7 @@ public class Utilities {
}
public static Path getBackupRootPath(String worldName) {
Path path = Path.of(config.get().path).toAbsolutePath();
Path path = Path.of(config.get().backupDirectoryPath).toAbsolutePath();
if (config.get().perWorldBackup) path = path.resolve(worldName);
@ -104,25 +103,6 @@ public class Utilities {
});
}
public static void updateTMPFSFlag(MinecraftServer server) {
boolean flag = false;
Path tmp_dir = Path.of(System.getProperty("java.io.tmpdir"));
if(
FileUtils.sizeOfDirectory(Utilities.getWorldFolder(server).toFile()) >=
tmp_dir.toFile().getUsableSpace()
) {
log.error("Not enough space left in TMP directory! ({})", tmp_dir);
flag = true;
}
//!Files.isWritable(tmp_dir.resolve("test_txb_file_2137")) - Unsure why this was resolving to a file that isn't being created (at least not in Windows)
if(!Files.isWritable(tmp_dir)) {
log.error("TMP filesystem ({}) is read-only!", tmp_dir);
flag = true;
}
if((Statics.disableTMPFiles = flag)) log.error("Might cause: https://github.com/Szum123321/textile_backup/wiki/ZIP-Problems");
}
public static void disableWorldSaving(MinecraftServer server) {
for (ServerWorld serverWorld : server.getWorlds()) {
if (serverWorld != null && !serverWorld.savingDisabled)
@ -181,7 +161,7 @@ public class Utilities {
try {
return Optional.of(
LocalDateTime.from(
Utilities.getBackupDateTimeFormatter().parse(
Globals.defaultDateTimeFormatter.parse(
file.getFileName().toString().split(fileExtension)[0].split("#")[0]
)));
} catch (Exception ignored) {}
@ -205,10 +185,6 @@ public class Utilities {
return DateTimeFormatter.ofPattern(config.get().dateTimeFormat);
}
public static DateTimeFormatter getBackupDateTimeFormatter() {
return Statics.defaultDateTimeFormatter;
}
public static String formatDuration(Duration duration) {
DateTimeFormatter formatter;

View File

@ -19,7 +19,7 @@
package net.szum123321.textile_backup.core.create;
import net.minecraft.server.command.ServerCommandSource;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.TextileLogger;
import net.szum123321.textile_backup.config.ConfigHelper;
@ -172,7 +172,7 @@ public class BackupHelper {
//1 -> ok, 0 -> err
private static int deleteFile(Path f, ServerCommandSource ctx) {
if(Statics.untouchableFile.isEmpty()|| !Statics.untouchableFile.get().equals(f)) {
if(Globals.INSTANCE.getLockedFile().filter(p -> p == f).isEmpty()) {
try {
Files.delete(f);
log.sendInfoAL(ctx, "Deleting: {}", f);

View File

@ -19,7 +19,7 @@
package net.szum123321.textile_backup.core.create;
import net.minecraft.server.MinecraftServer;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.config.ConfigHelper;
import net.szum123321.textile_backup.core.ActionInitiator;
@ -43,7 +43,7 @@ public class BackupScheduler {
if(config.get().doBackupsOnEmptyServer || server.getPlayerManager().getCurrentPlayerCount() > 0) {
if(scheduled) {
if(nextBackup <= now) {
Statics.executorService.submit(
Globals.INSTANCE.getQueueExecutor().submit(
BackupHelper.create(
BackupContext.Builder
.newBackupContextBuilder()
@ -62,7 +62,7 @@ public class BackupScheduler {
}
} else if(!config.get().doBackupsOnEmptyServer && server.getPlayerManager().getCurrentPlayerCount() == 0) {
if(scheduled && nextBackup <= now) {
Statics.executorService.submit(
Globals.INSTANCE.getQueueExecutor().submit(
BackupHelper.create(
BackupContext.Builder
.newBackupContextBuilder()

View File

@ -18,7 +18,7 @@
package net.szum123321.textile_backup.core.create;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.TextileLogger;
import net.szum123321.textile_backup.config.ConfigHelper;
@ -50,9 +50,9 @@ public class MakeBackupRunnable implements Runnable {
public void run() {
try {
Utilities.disableWorldSaving(context.server());
Statics.disableWatchdog = true;
Globals.INSTANCE.disableWatchdog = true;
Utilities.updateTMPFSFlag(context.server());
Globals.INSTANCE.updateTMPFSFlag(context.server());
log.sendInfoAL(context, "Starting backup");
@ -90,7 +90,7 @@ public class MakeBackupRunnable implements Runnable {
switch (config.get().format) {
case ZIP -> {
if (coreCount > 1 && !Statics.disableTMPFiles) {
if (coreCount > 1 && !Globals.INSTANCE.disableTMPFS()) {
ParallelZipCompressor.getInstance().createArchive(world, outFile, context, coreCount);
log.trace("Using PARALLEL Zip Compressor. Threads: {}", coreCount);
} else {
@ -120,7 +120,7 @@ public class MakeBackupRunnable implements Runnable {
}
} finally {
Utilities.enableWorldSaving(context.server());
Statics.disableWatchdog = false;
Globals.INSTANCE.disableWatchdog = false;
}
}

View File

@ -18,13 +18,13 @@
package net.szum123321.textile_backup.core.restore;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.TextileLogger;
import net.szum123321.textile_backup.config.ConfigHelper;
import net.szum123321.textile_backup.config.ConfigPOJO;
import net.szum123321.textile_backup.core.ActionInitiator;
import net.szum123321.textile_backup.core.LivingServer;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.core.Utilities;
import net.szum123321.textile_backup.core.create.BackupContext;
import net.szum123321.textile_backup.core.create.BackupHelper;
@ -47,7 +47,7 @@ public class RestoreBackupRunnable implements Runnable {
@Override
public void run() {
Statics.globalShutdownBackupFlag.set(false);
Globals.INSTANCE.globalShutdownBackupFlag.set(false);
log.info("Shutting down server...");
@ -95,7 +95,7 @@ public class RestoreBackupRunnable implements Runnable {
}
//in case we're playing on client
Statics.globalShutdownBackupFlag.set(true);
Globals.INSTANCE.globalShutdownBackupFlag.set(true);
log.info("Done!");
}

View File

@ -19,11 +19,11 @@
package net.szum123321.textile_backup.core.restore;
import net.minecraft.server.MinecraftServer;
import net.szum123321.textile_backup.Globals;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.TextileLogger;
import net.szum123321.textile_backup.config.ConfigHelper;
import net.szum123321.textile_backup.config.ConfigPOJO;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.core.ActionInitiator;
import net.szum123321.textile_backup.core.Utilities;
import org.jetbrains.annotations.NotNull;
@ -54,7 +54,7 @@ public class RestoreHelper {
throw new RuntimeException(e);
}
Statics.untouchableFile = optionalFile.map(RestoreableFile::getFile);
optionalFile.ifPresent(r -> Globals.INSTANCE.setLockedFile(r.getFile()));
return optionalFile;
}
@ -138,7 +138,7 @@ public class RestoreHelper {
}
public String toString() {
return this.getCreationTime().format(Statics.defaultDateTimeFormatter) + (comment != null ? "#" + comment : "");
return this.getCreationTime().format(Globals.defaultDateTimeFormatter) + (comment != null ? "#" + comment : "");
}
}
}

View File

@ -20,7 +20,7 @@ package net.szum123321.textile_backup.mixin;
import net.minecraft.server.dedicated.DedicatedServerWatchdog;
import net.minecraft.util.Util;
import net.szum123321.textile_backup.Statics;
import net.szum123321.textile_backup.Globals;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@ -30,6 +30,6 @@ public class DedicatedServerWatchdogMixin {
@ModifyVariable(method = "run()V", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/Util;getMeasuringTimeMs()J"), ordinal = 0, name = "l")
private long redirectedCall(long original) {
return Statics.disableWatchdog ? Util.getMeasuringTimeMs() : original;
return Globals.INSTANCE.disableWatchdog ? Util.getMeasuringTimeMs() : original;
}
}