Skip to content

Commit c7d4c01

Browse files
committed
Ignore invalid jars inside of the updates folder (Fixes #7751)
This really needs a deeper look here, the way updates are handled is fairly immature, but, this wasn't ever intended to be a large scale thing Ideally, imho, we'd collect the list of update files into some form of Map, that way we just have a reference of Name > File refs, and can filter out cases where there are two versions of a plugin in there and warn expectidely, but, that creates some complications, you would need to fall back to a dir scan in the case of a plugin calling loadPlugin, but, it would at least give us more defined behavior, as well as improve performance here vs repeatidely trying to deserialise the plugin.yml defs for every file in there on every load
1 parent c642d25 commit c7d4c01

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

patches/api/0379-Update-Folder-Uses-Plugin-Name.patch

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Update Folder Uses Plugin Name
55

66

77
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
8-
index 42da20011544075a9bea63a12ae86f2f21720667..bea2e464861771383f8fcf143fa817340cb8ab1d 100644
8+
index 42da20011544075a9bea63a12ae86f2f21720667..bab8bb3a52cdeef5f7052d4e3f404c42f37d117d 100644
99
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
1010
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
1111
@@ -400,7 +400,7 @@ public final class SimplePluginManager implements PluginManager {
@@ -17,7 +17,7 @@ index 42da20011544075a9bea63a12ae86f2f21720667..bea2e464861771383f8fcf143fa81734
1717

1818
Set<Pattern> filters = fileAssociations.keySet();
1919
Plugin result = null;
20-
@@ -427,16 +427,50 @@ public final class SimplePluginManager implements PluginManager {
20+
@@ -427,16 +427,56 @@ public final class SimplePluginManager implements PluginManager {
2121
return result;
2222
}
2323

@@ -32,15 +32,21 @@ index 42da20011544075a9bea63a12ae86f2f21720667..bea2e464861771383f8fcf143fa81734
3232
if (updateDirectory == null || !updateDirectory.isDirectory()) {
3333
- return;
3434
+ return file;
35-
}
35+
+ }
3636
+ PluginLoader pluginLoader = getPluginLoader(file);
3737
+ try {
3838
+ String pluginName = pluginLoader.getPluginDescription(file).getName();
3939
+ for (File updateFile : updateDirectory.listFiles()) {
4040
+ if (!updateFile.isFile()) continue;
4141
+ PluginLoader updatePluginLoader = getPluginLoader(updateFile);
4242
+ if (updatePluginLoader == null) continue;
43-
+ String updatePluginName = updatePluginLoader.getPluginDescription(updateFile).getName();
43+
+ String updatePluginName;
44+
+ try {
45+
+ updatePluginName = updatePluginLoader.getPluginDescription(updateFile).getName();
46+
+ // We failed to load this data for some reason, so, we'll skip over this
47+
+ } catch (InvalidDescriptionException ex) {
48+
+ continue;
49+
+ }
4450
+ if (!pluginName.equals(updatePluginName)) continue;
4551
+ if (!FileUtil.copy(updateFile, file)) continue;
4652
+ File newName = new File(file.getParentFile(), updateFile.getName());
@@ -51,7 +57,7 @@ index 42da20011544075a9bea63a12ae86f2f21720667..bea2e464861771383f8fcf143fa81734
5157
+ }
5258
+ catch (InvalidDescriptionException e) {
5359
+ throw new InvalidPluginException(e);
54-
+ }
60+
}
5561
+ return file;
5662
+ }
5763

0 commit comments

Comments
 (0)