Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
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.
Dieser Commit ist enthalten in:
Ursprung
eef2b2040c
Commit
4a8be52c93
@ -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<PluginDescription> found = new ArrayList<>();
|
||||
JavaPluginLoader loader = new JavaPluginLoader(server, directory);
|
||||
JvmPluginLoader loader = new JvmPluginLoader(server, directory);
|
||||
|
||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory,
|
||||
p -> p.toFile().isFile() && p.toString().endsWith(".jar"))) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<URI, PluginClassLoader> 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<PluginClassLoader>) () -> 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(),
|
@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String> authors, Collection<PluginDependency> dependencies,
|
||||
@Nullable Path source, Class<?> mainClass) {
|
@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String> authors, Collection<PluginDependency> dependencies, Path source,
|
||||
String mainClass) {
|
@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren