geforkt von Mirrors/Paper
928bcc8d3a
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 09943450 Update SnakeYAML version 5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc 6f82b381 PR-788: Add getHand() to all relevant events CraftBukkit Changes: aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe 5329dd6fd PR-1107: Add getHand() to all relevant events 93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
87 Zeilen
3.9 KiB
Diff
87 Zeilen
3.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Xemorr <31805746+Xemorr@users.noreply.github.com>
|
|
Date: Fri, 1 Apr 2022 19:57:40 +0100
|
|
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
|
|
index 94646b37c77fcb18fc4030306c431684e7e9a5cc..9db611841b73fed8dc8a71f4d7fdef95af3cf89d 100644
|
|
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
@@ -396,7 +396,7 @@ public final class SimplePluginManager implements PluginManager {
|
|
public synchronized Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, UnknownDependencyException {
|
|
Preconditions.checkArgument(file != null, "File cannot be null");
|
|
|
|
- checkUpdate(file);
|
|
+ file = checkUpdate(file); // Paper - update the reference in case checkUpdate renamed it
|
|
|
|
Set<Pattern> filters = fileAssociations.keySet();
|
|
Plugin result = null;
|
|
@@ -423,16 +423,61 @@ public final class SimplePluginManager implements PluginManager {
|
|
return result;
|
|
}
|
|
|
|
- private void checkUpdate(@NotNull File file) {
|
|
+ // Paper start - Update Folder Uses Plugin Name to replace
|
|
+ /**
|
|
+ * Replaces a plugin with a plugin of the same plugin name in the update folder.
|
|
+ * @param file
|
|
+ * @throws InvalidPluginException
|
|
+ */
|
|
+ private File checkUpdate(@NotNull File file) throws InvalidPluginException {
|
|
if (updateDirectory == null || !updateDirectory.isDirectory()) {
|
|
- return;
|
|
+ return file;
|
|
+ }
|
|
+ PluginLoader pluginLoader = getPluginLoader(file);
|
|
+ try {
|
|
+ String pluginName = pluginLoader.getPluginDescription(file).getName();
|
|
+ for (File updateFile : updateDirectory.listFiles()) {
|
|
+ if (!updateFile.isFile()) continue;
|
|
+ PluginLoader updatePluginLoader = getPluginLoader(updateFile);
|
|
+ if (updatePluginLoader == null) continue;
|
|
+ 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;
|
|
+ try {
|
|
+ java.nio.file.Files.copy(updateFile.toPath(), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
|
+ } catch (java.io.IOException exception) {
|
|
+ server.getLogger().log(Level.SEVERE, "Could not copy '" + updateFile.getPath() + "' to '" + file.getPath() + "' in update plugin process", exception);
|
|
+ continue;
|
|
+ }
|
|
+ File newName = new File(file.getParentFile(), updateFile.getName());
|
|
+ file.renameTo(newName);
|
|
+ updateFile.delete();
|
|
+ return newName;
|
|
+ }
|
|
}
|
|
+ catch (InvalidDescriptionException e) {
|
|
+ throw new InvalidPluginException(e);
|
|
+ }
|
|
+ return file;
|
|
+ }
|
|
|
|
- File updateFile = new File(updateDirectory, file.getName());
|
|
- if (updateFile.isFile() && FileUtil.copy(updateFile, file)) {
|
|
- updateFile.delete();
|
|
+ @Nullable
|
|
+ private PluginLoader getPluginLoader(File file) {
|
|
+ Set<Pattern> filters = fileAssociations.keySet();
|
|
+ for (Pattern filter : filters) {
|
|
+ Matcher match = filter.matcher(file.getName());
|
|
+ if (match.find()) {
|
|
+ return fileAssociations.get(filter);
|
|
+ }
|
|
}
|
|
+ return null;
|
|
}
|
|
+ // Paper end
|
|
|
|
/**
|
|
* Checks if the given plugin is loaded and returns it when applicable
|