From 4f3088e98bf3c9227df9167aa0343ea00a8fd54f Mon Sep 17 00:00:00 2001 From: Mehrad Nayyeri Date: Mon, 6 Mar 2023 10:27:27 +0330 Subject: [PATCH] Added promptEnabled option. --- .../java/ir/mehradn/rollback/config/RollbackConfig.java | 6 ++++++ .../ir/mehradn/rollback/mixin/CreateWorldScreenMixin.java | 4 ++++ .../java/ir/mehradn/rollback/mixin/WorldEntryMixin.java | 4 ++++ src/main/resources/assets/rollback/lang/en_us.json | 1 + 4 files changed, 15 insertions(+) diff --git a/src/main/java/ir/mehradn/rollback/config/RollbackConfig.java b/src/main/java/ir/mehradn/rollback/config/RollbackConfig.java index b4e5f97..4fe9473 100644 --- a/src/main/java/ir/mehradn/rollback/config/RollbackConfig.java +++ b/src/main/java/ir/mehradn/rollback/config/RollbackConfig.java @@ -46,6 +46,10 @@ public static boolean replaceGameRulesButton() { return _RollbackConfig.replaceGameRulesButton; } + public static boolean promptDisabled() { + return !_RollbackConfig.promptEnabled; + } + public enum TimerMode { DAYLIGHT_CYCLE, IN_GAME_TIME @@ -81,5 +85,7 @@ public enum _CommandAccess { public static boolean replaceReCreateButton = true; @Entry public static boolean replaceGameRulesButton = true; + @Entry + public static boolean promptEnabled = true; } } diff --git a/src/main/java/ir/mehradn/rollback/mixin/CreateWorldScreenMixin.java b/src/main/java/ir/mehradn/rollback/mixin/CreateWorldScreenMixin.java index d1859c7..37098ea 100644 --- a/src/main/java/ir/mehradn/rollback/mixin/CreateWorldScreenMixin.java +++ b/src/main/java/ir/mehradn/rollback/mixin/CreateWorldScreenMixin.java @@ -80,6 +80,10 @@ private void promptFeature(LevelProperties.SpecialProperty specialProperty, CombinedDynamicRegistries combinedDynamicRegistries, Lifecycle lifecycle, CallbackInfo ci) { + if (RollbackConfig.promptDisabled()) { + this.enablePrompted = false; + return; + } if (!this.promptEnabled) { this.promptEnabled = true; return; diff --git a/src/main/java/ir/mehradn/rollback/mixin/WorldEntryMixin.java b/src/main/java/ir/mehradn/rollback/mixin/WorldEntryMixin.java index 37a6aa8..f6fd69c 100644 --- a/src/main/java/ir/mehradn/rollback/mixin/WorldEntryMixin.java +++ b/src/main/java/ir/mehradn/rollback/mixin/WorldEntryMixin.java @@ -1,6 +1,7 @@ package ir.mehradn.rollback.mixin; import ir.mehradn.rollback.Rollback; +import ir.mehradn.rollback.config.RollbackConfig; import ir.mehradn.rollback.gui.RollbackScreen; import ir.mehradn.rollback.util.backup.BackupManager; import ir.mehradn.rollback.util.mixin.WorldEntryExpanded; @@ -49,6 +50,9 @@ private void deleteBackups(CallbackInfo ci) { @Inject(method = "start", cancellable = true, at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/world/WorldListWidget$WorldEntry;openReadingWorldScreen()V")) private void promptFeature(CallbackInfo ci) { + if (RollbackConfig.promptDisabled()) + return; + this.openReadingWorldScreen(); BackupManager backupManager = new BackupManager(); String worldName = this.level.getName(); diff --git a/src/main/resources/assets/rollback/lang/en_us.json b/src/main/resources/assets/rollback/lang/en_us.json index 86e69c2..dd21965 100644 --- a/src/main/resources/assets/rollback/lang/en_us.json +++ b/src/main/resources/assets/rollback/lang/en_us.json @@ -30,6 +30,7 @@ "rollback.midnightconfig.commandAccess": "Rollback Command Access:", "rollback.midnightconfig.replaceReCreateButton": "Replace Re-Create Button:", "rollback.midnightconfig.replaceGameRulesButton": "Replace GameRules Button:", + "rollback.midnightconfig.promptEnabled": "Suggest Enabling Automated Backups:", "rollback.midnightconfig.enum._TimerMode.DAYLIGHT_CYCLE": "Daylight Cycle", "rollback.midnightconfig.enum._TimerMode.IN_GAME_TIME": "In-Game Time", "rollback.midnightconfig.enum._CommandAccess.ON_CHEATS": "On Cheats",