Skip to content

Commit

Permalink
SpigotUpdater should ignore output files if it's null
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Mar 18, 2023
1 parent 39f4400 commit 2aee905
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Objects;

public class SpigotUpdater implements Updater {
private final UpdateBuilder updateBuilder;
Expand Down Expand Up @@ -46,13 +45,16 @@ public boolean update(File file, String version, String build) throws Exception
if (!runBuildTools(buildTools, outputDir, version)) {
return false;
}
for (File outputFile : Objects.requireNonNull(outputDir.listFiles())) {
String name = outputFile.getName();
if (name.startsWith("spigot-") && name.endsWith(".jar")) {
updateBuilder.debug("Copying " + name + " to " + file.getName());
Files.copy(outputFile.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
Files.delete(outputFile.toPath());
break;
File[] outputFiles = outputDir.listFiles();
if (outputFiles != null) {
for (File outputFile : outputFiles) {
String name = outputFile.getName();
if (name.startsWith("spigot-") && name.endsWith(".jar")) {
updateBuilder.debug("Copying " + name + " to " + file.getName());
Files.copy(outputFile.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
Files.delete(outputFile.toPath());
break;
}
}
}
return true;
Expand Down

0 comments on commit 2aee905

Please sign in to comment.