From 39998eedf8f52e69cd8a85754f176d5a6afd0714 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Sat, 9 Jan 2016 12:31:20 -0500 Subject: [PATCH] Make sure the plugins folder actually exists before iterating --- .../comphenix/protocol/ProtocolLibrary.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java index 1572719a..4e36142e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java @@ -501,17 +501,20 @@ public class ProtocolLibrary extends JavaPlugin { // The plugin folder isn't always plugins/ File pluginFolder = getDataFolder().getParentFile(); - for (File candidate : pluginFolder.listFiles()) { - if (candidate.isFile() && !candidate.equals(loadedFile)) { - Matcher match = ourPlugin.matcher(candidate.getName()); - if (match.matches()) { - MinecraftVersion version = new MinecraftVersion(match.group(1)); + File[] candidates = pluginFolder.listFiles(); + if (candidates != null) { + for (File candidate : pluginFolder.listFiles()) { + if (candidate.isFile() && !candidate.equals(loadedFile)) { + Matcher match = ourPlugin.matcher(candidate.getName()); + if (match.matches()) { + MinecraftVersion version = new MinecraftVersion(match.group(1)); - if (candidate.length() == 0) { - // Delete and inform the user - logger.info((candidate.delete() ? "Deleted " : "Could not delete ") + candidate); - } else if (newestVersion == null || newestVersion.compareTo(version) < 0) { - newestVersion = version; + if (candidate.length() == 0) { + // Delete and inform the user + logger.info((candidate.delete() ? "Deleted " : "Could not delete ") + candidate); + } else if (newestVersion == null || newestVersion.compareTo(version) < 0) { + newestVersion = version; + } } } }