Archiviert
13
0

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
Dieser Commit ist enthalten in:
Shane Freeder 2022-04-20 10:00:50 +01:00
Ursprung c642d25f63
Commit c7d4c0188e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F61EA5A085289C

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Update Folder Uses Plugin Name
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index 42da20011544075a9bea63a12ae86f2f21720667..bea2e464861771383f8fcf143fa817340cb8ab1d 100644 index 42da20011544075a9bea63a12ae86f2f21720667..bab8bb3a52cdeef5f7052d4e3f404c42f37d117d 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -400,7 +400,7 @@ public final class SimplePluginManager implements PluginManager { @@ -400,7 +400,7 @@ public final class SimplePluginManager implements PluginManager {
@ -17,7 +17,7 @@ index 42da20011544075a9bea63a12ae86f2f21720667..bea2e464861771383f8fcf143fa81734
Set<Pattern> filters = fileAssociations.keySet(); Set<Pattern> filters = fileAssociations.keySet();
Plugin result = null; Plugin result = null;
@@ -427,16 +427,50 @@ public final class SimplePluginManager implements PluginManager { @@ -427,16 +427,56 @@ public final class SimplePluginManager implements PluginManager {
return result; return result;
} }
@ -32,7 +32,7 @@ index 42da20011544075a9bea63a12ae86f2f21720667..bea2e464861771383f8fcf143fa81734
if (updateDirectory == null || !updateDirectory.isDirectory()) { if (updateDirectory == null || !updateDirectory.isDirectory()) {
- return; - return;
+ return file; + return file;
} + }
+ PluginLoader pluginLoader = getPluginLoader(file); + PluginLoader pluginLoader = getPluginLoader(file);
+ try { + try {
+ String pluginName = pluginLoader.getPluginDescription(file).getName(); + String pluginName = pluginLoader.getPluginDescription(file).getName();
@ -40,7 +40,13 @@ index 42da20011544075a9bea63a12ae86f2f21720667..bea2e464861771383f8fcf143fa81734
+ if (!updateFile.isFile()) continue; + if (!updateFile.isFile()) continue;
+ PluginLoader updatePluginLoader = getPluginLoader(updateFile); + PluginLoader updatePluginLoader = getPluginLoader(updateFile);
+ if (updatePluginLoader == null) continue; + if (updatePluginLoader == null) continue;
+ String updatePluginName = updatePluginLoader.getPluginDescription(updateFile).getName(); + String updatePluginName;
+ try {
+ updatePluginName = updatePluginLoader.getPluginDescription(updateFile).getName();
+ // We failed to load this data for some reason, so, we'll skip over this
+ } catch (InvalidDescriptionException ex) {
+ continue;
+ }
+ if (!pluginName.equals(updatePluginName)) continue; + if (!pluginName.equals(updatePluginName)) continue;
+ if (!FileUtil.copy(updateFile, file)) continue; + if (!FileUtil.copy(updateFile, file)) continue;
+ File newName = new File(file.getParentFile(), updateFile.getName()); + File newName = new File(file.getParentFile(), updateFile.getName());
@ -51,7 +57,7 @@ index 42da20011544075a9bea63a12ae86f2f21720667..bea2e464861771383f8fcf143fa81734
+ } + }
+ catch (InvalidDescriptionException e) { + catch (InvalidDescriptionException e) {
+ throw new InvalidPluginException(e); + throw new InvalidPluginException(e);
+ } }
+ return file; + return file;
+ } + }