mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-12-30 21:07:47 +01:00
Fix issue when custom generated default challenges were overwritten and deleted.
This commit is contained in:
parent
52f9ee10bf
commit
cd85a929d0
@ -5,6 +5,7 @@ import com.google.gson.GsonBuilder;
|
|||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -236,8 +237,13 @@ public class ChallengesImportManager
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default configuration should be removed.
|
||||||
|
// user made configuration should not!.
|
||||||
|
boolean removeAtEnd =
|
||||||
|
!Files.exists(Paths.get(this.addon.getDataFolder().getPath() + "/default.json"));
|
||||||
|
|
||||||
// Safe json configuration to Challenges folder.
|
// Safe json configuration to Challenges folder.
|
||||||
this.addon.saveResource("default.json", true);
|
this.addon.saveResource("default.json", false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -280,8 +286,11 @@ public class ChallengesImportManager
|
|||||||
|
|
||||||
this.addon.getChallengesManager().save();
|
this.addon.getChallengesManager().save();
|
||||||
|
|
||||||
// Remove default.yml file from resources to avoid interacting with it.
|
if (removeAtEnd)
|
||||||
new File(this.addon.getDataFolder(), "default.json").delete();
|
{
|
||||||
|
// Remove default.yml file from resources to avoid interacting with it.
|
||||||
|
new File(this.addon.getDataFolder(), "default.json").delete();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user