Skip to content

Commit

Permalink
Added promptEnabled option.
Browse files Browse the repository at this point in the history
  • Loading branch information
MehradN committed Mar 6, 2023
1 parent b46452e commit 4f3088e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/ir/mehradn/rollback/config/RollbackConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -81,5 +85,7 @@ public enum _CommandAccess {
public static boolean replaceReCreateButton = true;
@Entry
public static boolean replaceGameRulesButton = true;
@Entry
public static boolean promptEnabled = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ private void promptFeature(LevelProperties.SpecialProperty specialProperty,
CombinedDynamicRegistries<ServerDynamicRegistryType> combinedDynamicRegistries,
Lifecycle lifecycle,
CallbackInfo ci) {
if (RollbackConfig.promptDisabled()) {
this.enablePrompted = false;
return;
}
if (!this.promptEnabled) {
this.promptEnabled = true;
return;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/ir/mehradn/rollback/mixin/WorldEntryMixin.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/rollback/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4f3088e

Please sign in to comment.