|
11 | 11 | import org.hydev.mcpm.client.models.PluginModel;
|
12 | 12 | import org.hydev.mcpm.client.models.PluginVersion;
|
13 | 13 | import org.hydev.mcpm.client.models.PluginYml;
|
| 14 | +import org.hydev.mcpm.client.models.PluginYml.InvalidPluginMetaStructure; |
14 | 15 | import org.hydev.mcpm.utils.PluginJarFile;
|
15 | 16 | import org.hydev.mcpm.client.models.PluginTrackerModel;
|
16 | 17 |
|
@@ -66,6 +67,10 @@ private PluginYml readMeta(File jar) {
|
66 | 67 | } catch (IOException e) {
|
67 | 68 | System.out.println("Error reading plugin.yml from " + jar);
|
68 | 69 | return null;
|
| 70 | + } catch (InvalidPluginMetaStructure e) { |
| 71 | + System.out.println("Invalid plugin.yml structure in " + jar); |
| 72 | + e.printStackTrace(); |
| 73 | + return null; |
69 | 74 | }
|
70 | 75 | }
|
71 | 76 |
|
@@ -335,6 +340,9 @@ public List<String> listOrphanPlugins(boolean considerSoftDependencies) {
|
335 | 340 | // directory
|
336 | 341 |
|
337 | 342 | File pluginYmlPath = getPluginFile(name);
|
| 343 | + if (pluginYmlPath == null) { |
| 344 | + throw new FileNotFoundException("Plugin " + name + " not found"); |
| 345 | + } |
338 | 346 | PluginYml p = readMeta(pluginYmlPath);
|
339 | 347 | if (p == null)
|
340 | 348 | continue;
|
@@ -537,24 +545,20 @@ private File getPluginFile(String name) {
|
537 | 545 | // Get the file path of the plugin with name name from the local plugin
|
538 | 546 | // directory
|
539 | 547 | // Return the file path as a File
|
540 |
| - try { |
541 |
| - // Find the file from the plugin directory |
542 |
| - File dir = new File(pluginDirectory); |
543 |
| - File[] directoryListing = dir.listFiles(); |
544 |
| - if (directoryListing != null) { |
545 |
| - for (File child : directoryListing) { |
546 |
| - if (child.getName().equals(name)) { |
547 |
| - return child; |
548 |
| - } |
| 548 | + // Find the file from the plugin directory |
| 549 | + |
| 550 | + File dir = new File(pluginDirectory); |
| 551 | + File[] directoryListing = dir.listFiles(); |
| 552 | + if (directoryListing != null) { |
| 553 | + for (File child : directoryListing) { |
| 554 | + if (child.getName().equals(name)) { |
| 555 | + return child; |
549 | 556 | }
|
550 |
| - throw new IllegalArgumentException("Plugin not found, verify whether installed."); |
551 |
| - } else { |
552 |
| - throw new Exception("Empty Directory."); |
553 | 557 | }
|
554 |
| - |
555 |
| - } catch (IOException e) { |
556 |
| - throw new IllegalArgumentException("Plugin not found, error with directory iteration."); |
| 558 | + } else { |
| 559 | + throw new IllegalArgumentException("Plugin not found, verify whether installed."); |
557 | 560 | }
|
| 561 | + return null; |
558 | 562 | }
|
559 | 563 |
|
560 | 564 | /**
|
|
0 commit comments