From 0d41d0982c4d2a6a59c4ddb34af7aa758cb48272 Mon Sep 17 00:00:00 2001 From: citylion Date: Wed, 17 Jul 2024 22:13:06 -0500 Subject: [PATCH] Added option to disable saving of world when cloning. --- .../MultiverseCore/MultiverseCoreConfiguration.java | 13 +++++++++++++ .../MultiverseCore/api/MVWorldManager.java | 4 +++- .../MultiverseCore/api/MultiverseCoreConfig.java | 4 ++++ .../MultiverseCore/utils/WorldManager.java | 8 +++++--- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java index aaf21275c..d5bb8b1d6 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java @@ -77,6 +77,8 @@ public static MultiverseCoreConfiguration getInstance() { private volatile boolean autopurge; @Property private volatile boolean idonotwanttodonate; + @Property + private volatile boolean clone_saving; public MultiverseCoreConfiguration() { super(); @@ -111,6 +113,7 @@ protected void setDefaults() { portalsearchradius = 128; autopurge = true; idonotwanttodonate = false; + clone_saving=false; // END CHECKSTYLE-SUPPRESSION: MagicNumberCheck } @@ -378,6 +381,16 @@ public boolean isShowingDonateMessage() { return !idonotwanttodonate; } + @Override + public boolean doCloneSaving(){ + return clone_saving; + } + + @Override + public void setCloneSaving(boolean doSaving){ + this.clone_saving=doSaving; + } + @Override public void setShowDonateMessage(boolean showDonateMessage) { this.idonotwanttodonate = !showDonateMessage; diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java index 599ce7cb9..01be6b93c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java @@ -25,7 +25,9 @@ * This API contains all of the world managing * functions that your heart desires! */ -public interface MVWorldManager { +public interface + +MVWorldManager { /** * Add a new World to the Multiverse Setup. * diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java index 07b2bb91d..66560e139 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java +++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java @@ -233,6 +233,10 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable { */ boolean isShowingDonateMessage(); + boolean doCloneSaving(); + + void setCloneSaving(boolean doSaving); + /** * Sets whether or not the donation/patreon messages are shown. * diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java index 0b2ab0701..29504cb71 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java @@ -176,9 +176,11 @@ public boolean cloneWorld(String oldName, String newName) { boolean wasAutoSave = false; if (oldWorld != null && oldWorld.getCBWorld().isAutoSave()) { wasAutoSave = true; - Logging.config("Saving world '%s'", oldName); - oldWorld.getCBWorld().setAutoSave(false); - oldWorld.getCBWorld().save(); + if(plugin.getMVConfig().doCloneSaving()){ + Logging.config("Saving world '%s'", oldName); + oldWorld.getCBWorld().setAutoSave(false); + oldWorld.getCBWorld().save(); + } } Logging.config("Copying files for world '%s'", oldName); if (!FileUtils.copyFolder(oldWorldFile, newWorldFile, ignoreFiles)) {