@@ -6,10 +6,12 @@ import io.papermc.paper.plugin.entrypoint.Entrypoint;
|
||||
import io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler;
|
||||
import io.papermc.paper.plugin.provider.PluginProvider;
|
||||
import io.papermc.paper.plugin.provider.type.paper.PaperPluginParent;
|
||||
import io.papermc.paper.pluginremap.PluginRemapper;
|
||||
import java.util.function.Function;
|
||||
import joptsimple.OptionSet;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.plugin.java.LibraryLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
@@ -25,10 +27,15 @@ public class PluginInitializerManager {
|
||||
private static PluginInitializerManager impl;
|
||||
private final Path pluginDirectory;
|
||||
private final Path updateDirectory;
|
||||
public final io.papermc.paper.pluginremap.@org.checkerframework.checker.nullness.qual.MonotonicNonNull PluginRemapper pluginRemapper; // Paper
|
||||
|
||||
PluginInitializerManager(final Path pluginDirectory, final Path updateDirectory) {
|
||||
this.pluginDirectory = pluginDirectory;
|
||||
this.updateDirectory = updateDirectory;
|
||||
this.pluginRemapper = Boolean.getBoolean("paper.disablePluginRemapping")
|
||||
? null
|
||||
: PluginRemapper.create(pluginDirectory);
|
||||
LibraryLoader.REMAPPER = this.pluginRemapper == null ? Function.identity() : this.pluginRemapper::remapLibraries;
|
||||
}
|
||||
|
||||
private static PluginInitializerManager parse(@NotNull final OptionSet minecraftOptionSet) throws Exception {
|
||||
@@ -96,6 +103,7 @@ public class PluginInitializerManager {
|
||||
public static void load(OptionSet optionSet) throws Exception {
|
||||
// We have to load the bukkit configuration inorder to get the update folder location.
|
||||
io.papermc.paper.plugin.PluginInitializerManager pluginSystem = io.papermc.paper.plugin.PluginInitializerManager.init(optionSet);
|
||||
if (pluginSystem.pluginRemapper != null) pluginSystem.pluginRemapper.loadingPlugins();
|
||||
|
||||
// Register the default plugin directory
|
||||
io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(io.papermc.paper.plugin.provider.source.DirectoryProviderSource.INSTANCE, pluginSystem.pluginDirectoryPath());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.papermc.paper.plugin.loader;
|
||||
|
||||
import io.papermc.paper.plugin.PluginInitializerManager;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginProviderContext;
|
||||
import io.papermc.paper.plugin.loader.library.ClassPathLibrary;
|
||||
import io.papermc.paper.plugin.loader.library.PaperLibraryStore;
|
||||
@@ -45,9 +46,12 @@ public class PaperClasspathBuilder implements PluginClasspathBuilder {
|
||||
}
|
||||
|
||||
List<Path> paths = paperLibraryStore.getPaths();
|
||||
if (PluginInitializerManager.instance().pluginRemapper != null) {
|
||||
paths = PluginInitializerManager.instance().pluginRemapper.remapLibraries(paths);
|
||||
}
|
||||
URL[] urls = new URL[paths.size()];
|
||||
for (int i = 0; i < paths.size(); i++) {
|
||||
Path path = paperLibraryStore.getPaths().get(i);
|
||||
Path path = paths.get(i);
|
||||
try {
|
||||
urls[i] = path.toUri().toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.slf4j.Logger;
|
||||
public class DirectoryProviderSource implements ProviderSource<Path, List<Path>> {
|
||||
|
||||
public static final DirectoryProviderSource INSTANCE = new DirectoryProviderSource();
|
||||
private static final FileProviderSource FILE_PROVIDER_SOURCE = new FileProviderSource("Directory '%s'"::formatted);
|
||||
private static final FileProviderSource FILE_PROVIDER_SOURCE = new FileProviderSource("Directory '%s'"::formatted, false); // Paper - Remap plugins
|
||||
private static final Logger LOGGER = LogUtils.getClassLogger();
|
||||
|
||||
@Override
|
||||
@@ -37,6 +37,11 @@ public class DirectoryProviderSource implements ProviderSource<Path, List<Path>>
|
||||
LOGGER.error("Error preparing plugin context: " + e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
// Paper start - Remap plugins
|
||||
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) {
|
||||
return io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.rewritePluginDirectory(files);
|
||||
}
|
||||
// Paper end - Remap plugins
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,15 @@ import java.util.jar.JarFile;
|
||||
public class FileProviderSource implements ProviderSource<Path, Path> {
|
||||
|
||||
private final Function<Path, String> contextChecker;
|
||||
private final boolean applyRemap;
|
||||
|
||||
public FileProviderSource(Function<Path, String> contextChecker, boolean applyRemap) {
|
||||
this.contextChecker = contextChecker;
|
||||
this.applyRemap = applyRemap;
|
||||
}
|
||||
|
||||
public FileProviderSource(Function<Path, String> contextChecker) {
|
||||
this.contextChecker = contextChecker;
|
||||
this(contextChecker, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,6 +56,11 @@ public class FileProviderSource implements ProviderSource<Path, Path> {
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(source + " failed to update!", exception);
|
||||
}
|
||||
// Paper start - Remap plugins
|
||||
if (this.applyRemap && io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) {
|
||||
context = io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.rewritePlugin(context);
|
||||
}
|
||||
// Paper end - Remap plugins
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
public class PluginFlagProviderSource implements ProviderSource<List<Path>, List<Path>> {
|
||||
|
||||
public static final PluginFlagProviderSource INSTANCE = new PluginFlagProviderSource();
|
||||
private static final FileProviderSource FILE_PROVIDER_SOURCE = new FileProviderSource("File '%s' specified through 'add-plugin' argument"::formatted);
|
||||
private static final FileProviderSource FILE_PROVIDER_SOURCE = new FileProviderSource("File '%s' specified through 'add-plugin' argument"::formatted, false);
|
||||
private static final Logger LOGGER = LogUtils.getClassLogger();
|
||||
|
||||
@Override
|
||||
@@ -27,6 +27,11 @@ public class PluginFlagProviderSource implements ProviderSource<List<Path>, List
|
||||
LOGGER.error("Error preparing plugin context: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
// Paper start - Remap plugins
|
||||
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null && !files.isEmpty()) {
|
||||
return io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.rewriteExtraPlugins(files);
|
||||
}
|
||||
// Paper end - Remap plugins
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,10 @@ import java.util.jar.JarFile;
|
||||
*/
|
||||
public abstract class PluginFileType<T, C extends PluginMeta> {
|
||||
|
||||
public static final String PAPER_PLUGIN_YML = "paper-plugin.yml";
|
||||
private static final List<String> CONFIG_TYPES = new ArrayList<>();
|
||||
|
||||
public static final PluginFileType<PaperPluginParent, PaperPluginMeta> PAPER = new PluginFileType<>("paper-plugin.yml", PaperPluginParent.FACTORY) {
|
||||
public static final PluginFileType<PaperPluginParent, PaperPluginMeta> PAPER = new PluginFileType<>(PAPER_PLUGIN_YML, PaperPluginParent.FACTORY) {
|
||||
@Override
|
||||
protected void register(EntrypointHandler entrypointHandler, PaperPluginParent parent) {
|
||||
PaperPluginParent.PaperBootstrapProvider bootstrapPluginProvider = null;
|
||||
|
||||
Reference in New Issue
Block a user