Skip to content

Commit 39998ee

Browse files
committed
Make sure the plugins folder actually exists before iterating
1 parent 8e8cf54 commit 39998ee

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,17 +501,20 @@ private void checkConflictingVersions() {
501501
// The plugin folder isn't always plugins/
502502
File pluginFolder = getDataFolder().getParentFile();
503503

504-
for (File candidate : pluginFolder.listFiles()) {
505-
if (candidate.isFile() && !candidate.equals(loadedFile)) {
506-
Matcher match = ourPlugin.matcher(candidate.getName());
507-
if (match.matches()) {
508-
MinecraftVersion version = new MinecraftVersion(match.group(1));
509-
510-
if (candidate.length() == 0) {
511-
// Delete and inform the user
512-
logger.info((candidate.delete() ? "Deleted " : "Could not delete ") + candidate);
513-
} else if (newestVersion == null || newestVersion.compareTo(version) < 0) {
514-
newestVersion = version;
504+
File[] candidates = pluginFolder.listFiles();
505+
if (candidates != null) {
506+
for (File candidate : pluginFolder.listFiles()) {
507+
if (candidate.isFile() && !candidate.equals(loadedFile)) {
508+
Matcher match = ourPlugin.matcher(candidate.getName());
509+
if (match.matches()) {
510+
MinecraftVersion version = new MinecraftVersion(match.group(1));
511+
512+
if (candidate.length() == 0) {
513+
// Delete and inform the user
514+
logger.info((candidate.delete() ? "Deleted " : "Could not delete ") + candidate);
515+
} else if (newestVersion == null || newestVersion.compareTo(version) < 0) {
516+
newestVersion = version;
517+
}
515518
}
516519
}
517520
}

0 commit comments

Comments
 (0)