From 4a8be52c93ac1f7396335fd6f69d2936d7ec07a9 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 30 May 2021 18:20:34 -0400 Subject: [PATCH] Rename Java plugin loader to JVM plugin loader This is to prevent confusion with Java Edition - Velocity is built on the JVM and this handles plugins loaded into the same JVM Velocity is running in. --- .../proxy/plugin/VelocityPluginManager.java | 4 +-- .../JvmPluginLoader.java} | 32 +++++++++---------- .../JvmVelocityPluginDescription.java} | 6 ++-- ...vmVelocityPluginDescriptionCandidate.java} | 6 ++-- .../{java => jvm}/VelocityPluginModule.java | 6 ++-- 5 files changed, 27 insertions(+), 27 deletions(-) rename proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/{java/JavaPluginLoader.java => jvm/JvmPluginLoader.java} (88%) rename proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/{java/JavaVelocityPluginDescription.java => jvm/JvmVelocityPluginDescription.java} (87%) rename proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/{java/JavaVelocityPluginDescriptionCandidate.java => jvm/JvmVelocityPluginDescriptionCandidate.java} (86%) rename proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/{java => jvm}/VelocityPluginModule.java (91%) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java index e37369d7c..0b6811302 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java @@ -37,7 +37,7 @@ import com.velocitypowered.api.plugin.meta.PluginDependency; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer; -import com.velocitypowered.proxy.plugin.loader.java.JavaPluginLoader; +import com.velocitypowered.proxy.plugin.loader.jvm.JvmPluginLoader; import com.velocitypowered.proxy.plugin.util.PluginDependencyUtils; import com.velocitypowered.proxy.plugin.util.ProxyPluginContainer; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -92,7 +92,7 @@ public class VelocityPluginManager implements PluginManager { checkArgument(directory.toFile().isDirectory(), "provided path isn't a directory"); List found = new ArrayList<>(); - JavaPluginLoader loader = new JavaPluginLoader(server, directory); + JvmPluginLoader loader = new JvmPluginLoader(server, directory); try (DirectoryStream stream = Files.newDirectoryStream(directory, p -> p.toFile().isFile() && p.toString().endsWith(".jar"))) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaPluginLoader.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmPluginLoader.java similarity index 88% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaPluginLoader.java rename to proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmPluginLoader.java index 451188186..a9da31af2 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaPluginLoader.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmPluginLoader.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.plugin.loader.java; +package com.velocitypowered.proxy.plugin.loader.jvm; import com.google.inject.Guice; import com.google.inject.Injector; @@ -52,12 +52,12 @@ import java.util.Set; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; -public class JavaPluginLoader implements PluginLoader { +public class JvmPluginLoader implements PluginLoader { private final Path baseDirectory; private final Map classLoaders = new HashMap<>(); - public JavaPluginLoader(ProxyServer server, Path baseDirectory) { + public JvmPluginLoader(ProxyServer server, Path baseDirectory) { this.baseDirectory = baseDirectory; } @@ -77,8 +77,8 @@ public class JavaPluginLoader implements PluginLoader { @Override public PluginDescription materializePlugin(PluginDescription source) throws Exception { - if (!(source instanceof JavaVelocityPluginDescriptionCandidate)) { - throw new IllegalArgumentException("Description provided isn't of the Java plugin loader"); + if (!(source instanceof JvmVelocityPluginDescriptionCandidate)) { + throw new IllegalArgumentException("Description provided isn't of the JVM plugin loader"); } Path jarFilePath = source.file(); @@ -91,13 +91,13 @@ public class JavaPluginLoader implements PluginLoader { PluginClassLoader loader = this.classLoaders.computeIfAbsent(pluginJarUri, (uri) -> { PluginClassLoader classLoader = AccessController.doPrivileged( (PrivilegedAction) () -> new PluginClassLoader(new URL[]{pluginJarUrl}, - JavaPluginLoader.class.getClassLoader(), source)); + JvmPluginLoader.class.getClassLoader(), source)); classLoader.addToClassloaders(); return classLoader; }); - JavaVelocityPluginDescriptionCandidate candidate = - (JavaVelocityPluginDescriptionCandidate) source; + JvmVelocityPluginDescriptionCandidate candidate = + (JvmVelocityPluginDescriptionCandidate) source; Class mainClass = loader.loadClass(candidate.getMainClass()); return createDescription(candidate, mainClass); } @@ -105,11 +105,11 @@ public class JavaPluginLoader implements PluginLoader { @Override public Module createModule(PluginContainer container) throws Exception { PluginDescription description = container.description(); - if (!(description instanceof JavaVelocityPluginDescription)) { - throw new IllegalArgumentException("Description provided isn't of the Java plugin loader"); + if (!(description instanceof JvmVelocityPluginDescription)) { + throw new IllegalArgumentException("Description provided isn't of the JVM plugin loader"); } - JavaVelocityPluginDescription javaDescription = (JavaVelocityPluginDescription) description; + JvmVelocityPluginDescription javaDescription = (JvmVelocityPluginDescription) description; Path source = javaDescription.file(); if (source == null) { @@ -125,13 +125,13 @@ public class JavaPluginLoader implements PluginLoader { throw new IllegalArgumentException("Container provided isn't of the Java plugin loader"); } PluginDescription description = container.description(); - if (!(description instanceof JavaVelocityPluginDescription)) { + if (!(description instanceof JvmVelocityPluginDescription)) { throw new IllegalArgumentException("Description provided isn't of the Java plugin loader"); } Injector injector = Guice.createInjector(modules); Object instance = injector - .getInstance(((JavaVelocityPluginDescription) description).getMainClass()); + .getInstance(((JvmVelocityPluginDescription) description).getMainClass()); if (instance == null) { throw new IllegalStateException( @@ -190,7 +190,7 @@ public class JavaPluginLoader implements PluginLoader { dependencies.add(toDependencyMeta(dependency)); } - return new JavaVelocityPluginDescriptionCandidate( + return new JvmVelocityPluginDescriptionCandidate( description.getId(), description.getName(), description.getVersion(), @@ -204,9 +204,9 @@ public class JavaPluginLoader implements PluginLoader { } private VelocityPluginDescription createDescription( - JavaVelocityPluginDescriptionCandidate description, + JvmVelocityPluginDescriptionCandidate description, Class mainClass) { - return new JavaVelocityPluginDescription( + return new JvmVelocityPluginDescription( description.id(), description.name(), description.version(), diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescription.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescription.java similarity index 87% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescription.java rename to proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescription.java index 92a69852a..6d57f343e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescription.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescription.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.plugin.loader.java; +package com.velocitypowered.proxy.plugin.loader.jvm; import static com.google.common.base.Preconditions.checkNotNull; @@ -26,11 +26,11 @@ import java.util.Collection; import java.util.List; import org.checkerframework.checker.nullness.qual.Nullable; -class JavaVelocityPluginDescription extends VelocityPluginDescription { +class JvmVelocityPluginDescription extends VelocityPluginDescription { private final Class mainClass; - JavaVelocityPluginDescription(String id, @Nullable String name, String version, + JvmVelocityPluginDescription(String id, @Nullable String name, String version, @Nullable String description, @Nullable String url, @Nullable List authors, Collection dependencies, @Nullable Path source, Class mainClass) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescriptionCandidate.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescriptionCandidate.java similarity index 86% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescriptionCandidate.java rename to proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescriptionCandidate.java index b4f6e4499..a2cc359da 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescriptionCandidate.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescriptionCandidate.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.plugin.loader.java; +package com.velocitypowered.proxy.plugin.loader.jvm; import static com.google.common.base.Preconditions.checkNotNull; @@ -26,11 +26,11 @@ import java.util.Collection; import java.util.List; import org.checkerframework.checker.nullness.qual.Nullable; -class JavaVelocityPluginDescriptionCandidate extends VelocityPluginDescription { +class JvmVelocityPluginDescriptionCandidate extends VelocityPluginDescription { private final String mainClass; - JavaVelocityPluginDescriptionCandidate(String id, @Nullable String name, String version, + JvmVelocityPluginDescriptionCandidate(String id, @Nullable String name, String version, @Nullable String description, @Nullable String url, @Nullable List authors, Collection dependencies, Path source, String mainClass) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/VelocityPluginModule.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/VelocityPluginModule.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/VelocityPluginModule.java rename to proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/VelocityPluginModule.java index 2b80c455c..9c11f49ed 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/VelocityPluginModule.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/VelocityPluginModule.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.plugin.loader.java; +package com.velocitypowered.proxy.plugin.loader.jvm; import com.google.inject.Binder; import com.google.inject.Module; @@ -29,11 +29,11 @@ import org.slf4j.LoggerFactory; class VelocityPluginModule implements Module { - private final JavaVelocityPluginDescription description; + private final JvmVelocityPluginDescription description; private final PluginContainer pluginContainer; private final Path basePluginPath; - VelocityPluginModule(JavaVelocityPluginDescription description, + VelocityPluginModule(JvmVelocityPluginDescription description, PluginContainer pluginContainer, Path basePluginPath) { this.description = description; this.pluginContainer = pluginContainer;