Skip to content

Commit

Permalink
Fixes warning about already existing file saving. (#2260)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
BONNe authored Jan 5, 2024
1 parent caade1a commit fc658ca
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/java/world/bentobox/bentobox/BentoBox.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -464,9 +466,16 @@ public boolean loadSettings() {
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;
}

Expand Down

0 comments on commit fc658ca

Please sign in to comment.