Skip to content

Commit

Permalink
Single Loop
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueDarkLord committed Mar 9, 2024
1 parent 7fe6077 commit 7c30648
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;

/**
Expand Down Expand Up @@ -95,20 +96,20 @@ public void setup() {

if (this.plugin.isLogging()) this.plugin.getLogger().info("The folder " + homeFolder + "/ was not found so it was created.");

for (String fileName : this.autoGenerateFiles.keySet()) {
if (this.autoGenerateFiles.get(fileName).equalsIgnoreCase(homeFolder)) {
homeFolder = this.autoGenerateFiles.get(fileName);
for (Map.Entry<String, String> fileName : this.autoGenerateFiles.entrySet()) {
if (this.autoGenerateFiles.get(fileName.getKey()).equalsIgnoreCase(homeFolder)) {
homeFolder = fileName.getValue();

try (InputStream jarFile = getClass().getResourceAsStream((this.jarHomeFolders.getOrDefault(fileName, homeFolder)) + "/" + fileName)) {
File serverFile = new File(this.plugin.getDataFolder(), homeFolder + "/" + fileName);
try (InputStream jarFile = getClass().getResourceAsStream((this.jarHomeFolders.getOrDefault(fileName.getKey(), homeFolder)) + "/" + fileName.getKey())) {
File serverFile = new File(this.plugin.getDataFolder(), homeFolder + "/" + fileName.getKey());

copyFile(jarFile, serverFile);

if (fileName.toLowerCase().endsWith(".yml")) this.customFiles.add(new CustomFile(fileName, homeFolder));
if (fileName.getKey().toLowerCase().endsWith(".yml")) this.customFiles.add(new CustomFile(fileName.getKey(), homeFolder));

if (this.plugin.isLogging()) this.plugin.getLogger().info("Created new default file: " + homeFolder + "/" + fileName + ".");
if (this.plugin.isLogging()) this.plugin.getLogger().info("Created new default file: " + homeFolder + "/" + fileName.getKey() + ".");
} catch (Exception exception) {
this.plugin.getLogger().log(Level.SEVERE, "Failed to create new default file: " + homeFolder + "/" + fileName + "!", exception);
this.plugin.getLogger().log(Level.SEVERE, "Failed to create new default file: " + homeFolder + "/" + fileName.getKey() + "!", exception);
}
}
}
Expand Down

0 comments on commit 7c30648

Please sign in to comment.