Fixes warning about already existing file saving. (#2260)

Spigot JavaPlugin#saveResources either replaces or complains that replacement is disabled. So it is necessary to check if file does not exists before saving it.

Fixes #2259
This commit is contained in:
BONNe 2024-01-05 06:18:41 +02:00 committed by GitHub
parent caade1a71c
commit fc658ca073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,7 @@
package world.bentobox.bentobox;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
@ -464,9 +466,16 @@ public class BentoBox extends JavaPlugin implements Listener {
return false;
}
log("Saving default panels...");
this.saveResource("panels/island_creation_panel.yml", false);
this.saveResource("panels/language_panel.yml", false);
if (!Files.exists(Path.of(this.getDataFolder().getPath(), "panels", "island_creation_panel.yml"))) {
log("Saving default island_creation_panel...");
this.saveResource("panels/island_creation_panel.yml", false);
}
if (!Files.exists(Path.of(this.getDataFolder().getPath(), "panels", "language_panel.yml"))) {
log("Saving default language_panel...");
this.saveResource("panels/language_panel.yml", false);
}
return true;
}