Update paper plugin check in PluginRemapper

This commit is contained in:
Jason Penilla 2024-04-26 14:31:45 -07:00
parent 15221cd4ac
commit 8cb49c8d67

View File

@ -374,6 +374,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+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;
@ -557,8 +558,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final long start = System.currentTimeMillis(); + final long start = System.currentTimeMillis();
+ final IMappingFile reversed = mappings.reverse(); + final IMappingFile reversed = mappings.reverse();
+ if (DEBUG_LOGGING) { + if (DEBUG_LOGGING) {
+ LOGGER.info("Done reversing mappings in {}ms.", System.currentTimeMillis() - start); + LOGGER.info("Done reversing mappings in {}ms.", System.currentTimeMillis() - start);
+ } + }
+ return reversed; + return reversed;
+ } + }
+ +
@ -615,30 +616,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ 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 + final Path manifestPath = fs.getPath("META-INF/MANIFEST.MF");
+ final @Nullable String ns;
+ if (Files.exists(manifestPath)) {
+ final Manifest manifest;
+ try (final InputStream in = new BufferedInputStream(Files.newInputStream(manifestPath))) {
+ manifest = new Manifest(in);
+ }
+ 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 (DEBUG_LOGGING) { + if (DEBUG_LOGGING) {
+ LOGGER.info("Plugin '{}' is a Paper plugin, no remapping necessary.", inputFile); + LOGGER.info("Plugin '{}' is already Mojang mapped.", inputFile);
+ } + }
+ index.skip(inputFile); + index.skip(inputFile);
+ return CompletableFuture.completedFuture(inputFile); + return CompletableFuture.completedFuture(inputFile);
+ } else {*/ + } else if (ns == null && Files.exists(fs.getPath(PluginFileType.PAPER_PLUGIN_YML))) {
+ // Check for paperweight mojang mapped marker + if (DEBUG_LOGGING) {
+ final Path manifestPath = fs.getPath("META-INF/MANIFEST.MF"); + LOGGER.info("Plugin '{}' is a Paper plugin with no namespace specified.", inputFile);
+ if (Files.exists(manifestPath)) {
+ final Manifest manifest;
+ try (final InputStream in = new BufferedInputStream(Files.newInputStream(manifestPath))) {
+ manifest = new Manifest(in);
+ }
+ final String ns = manifest.getMainAttributes().getValue(InsertManifestAttribute.PAPERWEIGHT_NAMESPACE_MANIFEST_KEY);
+ if (ns != null && (ns.equals(InsertManifestAttribute.MOJANG_NAMESPACE) || ns.equals(InsertManifestAttribute.MOJANG_PLUS_YARN_NAMESPACE))) {
+ if (DEBUG_LOGGING) {
+ LOGGER.info("Plugin '{}' is already Mojang mapped.", inputFile);
+ }
+ index.skip(inputFile);
+ return CompletableFuture.completedFuture(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);
+ } + }