Update paper plugin check in PluginRemapper
This commit is contained in:
parent
19ac9d43ce
commit
e856d17ec5
1 changed files with 24 additions and 23 deletions
|
@ -366,14 +366,15 @@ index 0000000000000000000000000000000000000000..3a5bb5d2a45654385ca0bc15c81ef953
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/pluginremap/PluginRemapper.java b/src/main/java/io/papermc/paper/pluginremap/PluginRemapper.java
|
diff --git a/src/main/java/io/papermc/paper/pluginremap/PluginRemapper.java b/src/main/java/io/papermc/paper/pluginremap/PluginRemapper.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..5408015a25d5e3d2149976e428c9d4be470de2ba
|
index 0000000000000000000000000000000000000000..06dbaf0c77333f4d0d8ac462edd52097237505c0
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/pluginremap/PluginRemapper.java
|
+++ b/src/main/java/io/papermc/paper/pluginremap/PluginRemapper.java
|
||||||
@@ -0,0 +1,369 @@
|
@@ -0,0 +1,370 @@
|
||||||
+package io.papermc.paper.pluginremap;
|
+package io.papermc.paper.pluginremap;
|
||||||
+
|
+
|
||||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
+import com.mojang.logging.LogUtils;
|
+import com.mojang.logging.LogUtils;
|
||||||
|
+import io.papermc.paper.plugin.provider.type.PluginFileType;
|
||||||
+import io.papermc.paper.util.AtomicFiles;
|
+import io.papermc.paper.util.AtomicFiles;
|
||||||
+import io.papermc.paper.util.MappingEnvironment;
|
+import io.papermc.paper.util.MappingEnvironment;
|
||||||
+import io.papermc.paper.util.concurrent.ScalingThreadPool;
|
+import io.papermc.paper.util.concurrent.ScalingThreadPool;
|
||||||
|
@ -615,30 +616,30 @@ index 0000000000000000000000000000000000000000..5408015a25d5e3d2149976e428c9d4be
|
||||||
+
|
+
|
||||||
+ try (final FileSystem fs = FileSystems.newFileSystem(inputFile, new HashMap<>())) {
|
+ try (final FileSystem fs = FileSystems.newFileSystem(inputFile, new HashMap<>())) {
|
||||||
+ // Leave dummy files if no remapping is required, so that we can check if they exist without copying the whole file
|
+ // Leave dummy files if no remapping is required, so that we can check if they exist without copying the whole file
|
||||||
+ /*if (Files.exists(fs.getPath(PluginFileType.PAPER_PLUGIN_YML))) { // TODO Uncomment on release
|
|
||||||
+ if (DEBUG_LOGGING) {
|
|
||||||
+ LOGGER.info("Plugin '{}' is a Paper plugin, no remapping necessary.", inputFile);
|
|
||||||
+ }
|
|
||||||
+ index.skip(inputFile);
|
|
||||||
+ return CompletableFuture.completedFuture(inputFile);
|
|
||||||
+ } else {*/
|
|
||||||
+ // Check for paperweight mojang mapped marker
|
|
||||||
+ final Path manifestPath = fs.getPath("META-INF/MANIFEST.MF");
|
+ final Path manifestPath = fs.getPath("META-INF/MANIFEST.MF");
|
||||||
|
+ final @Nullable String ns;
|
||||||
+ if (Files.exists(manifestPath)) {
|
+ if (Files.exists(manifestPath)) {
|
||||||
+ final Manifest manifest;
|
+ final Manifest manifest;
|
||||||
+ try (final InputStream in = new BufferedInputStream(Files.newInputStream(manifestPath))) {
|
+ try (final InputStream in = new BufferedInputStream(Files.newInputStream(manifestPath))) {
|
||||||
+ manifest = new Manifest(in);
|
+ manifest = new Manifest(in);
|
||||||
+ }
|
+ }
|
||||||
+ final String ns = manifest.getMainAttributes().getValue(InsertManifestAttribute.PAPERWEIGHT_NAMESPACE_MANIFEST_KEY);
|
+ ns = manifest.getMainAttributes().getValue(InsertManifestAttribute.PAPERWEIGHT_NAMESPACE_MANIFEST_KEY);
|
||||||
|
+ } else {
|
||||||
|
+ ns = null;
|
||||||
|
+ }
|
||||||
+ if (ns != null && (ns.equals(InsertManifestAttribute.MOJANG_NAMESPACE) || ns.equals(InsertManifestAttribute.MOJANG_PLUS_YARN_NAMESPACE))) {
|
+ if (ns != null && (ns.equals(InsertManifestAttribute.MOJANG_NAMESPACE) || ns.equals(InsertManifestAttribute.MOJANG_PLUS_YARN_NAMESPACE))) {
|
||||||
+ if (DEBUG_LOGGING) {
|
+ if (DEBUG_LOGGING) {
|
||||||
+ LOGGER.info("Plugin '{}' is already Mojang mapped.", inputFile);
|
+ LOGGER.info("Plugin '{}' is already Mojang mapped.", inputFile);
|
||||||
+ }
|
+ }
|
||||||
+ index.skip(inputFile);
|
+ index.skip(inputFile);
|
||||||
+ return CompletableFuture.completedFuture(inputFile);
|
+ return CompletableFuture.completedFuture(inputFile);
|
||||||
|
+ } else if (ns == null && Files.exists(fs.getPath(PluginFileType.PAPER_PLUGIN_YML))) {
|
||||||
|
+ if (DEBUG_LOGGING) {
|
||||||
|
+ LOGGER.info("Plugin '{}' is a Paper plugin with no namespace specified.", inputFile);
|
||||||
+ }
|
+ }
|
||||||
|
+ index.skip(inputFile);
|
||||||
|
+ return CompletableFuture.completedFuture(inputFile);
|
||||||
+ }
|
+ }
|
||||||
+ //}
|
|
||||||
+ } catch (final IOException ex) {
|
+ } catch (final IOException ex) {
|
||||||
+ throw new RuntimeException("Failed to open plugin jar " + inputFile, ex);
|
+ throw new RuntimeException("Failed to open plugin jar " + inputFile, ex);
|
||||||
+ }
|
+ }
|
||||||
|
|
Loading…
Reference in a new issue