diff --git a/network/build.gradle b/network/build.gradle new file mode 100644 index 000000000..ee606e340 --- /dev/null +++ b/network/build.gradle @@ -0,0 +1,35 @@ +plugins { + id 'java-library' + id 'maven-publish' + id 'checkstyle' +} + +apply plugin: 'org.cadixdev.licenser' +apply from: '../gradle/checkstyle.gradle' +apply from: '../gradle/publish.gradle' +apply from: '../gradle/errorprone.gradle' + +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +license { + header = project.rootProject.file('HEADER.txt') +} + +dependencies { + implementation project(':velocity-proxy-core') +} + +test { + useJUnitPlatform() +} + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } +} diff --git a/proxy-core/build.gradle b/proxy-core/build.gradle new file mode 100644 index 000000000..981b07a79 --- /dev/null +++ b/proxy-core/build.gradle @@ -0,0 +1,41 @@ +plugins { + id 'java-library' + id 'maven-publish' + id 'checkstyle' +} + +apply plugin: 'org.cadixdev.licenser' +apply from: '../gradle/checkstyle.gradle' +apply from: '../gradle/publish.gradle' +apply from: '../gradle/errorprone.gradle' + +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +license { + header = project.rootProject.file('HEADER.txt') +} + +dependencies { + implementation project(':velocity-api') + implementation project(':velocity-annotation-processor') + + implementation "net.kyori:adventure-nbt:${adventureVersion}" + + implementation "org.apache.logging.log4j:log4j-api:${log4jVersion}" + + implementation "org.lanternpowered:lmbda:2.0.0" + + implementation "com.github.ben-manes.caffeine:caffeine:2.8.8" + implementation "com.vdurmont:semver4j:3.1.0" + compileOnly "com.github.spotbugs:spotbugs-annotations:4.1.2" + + testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/AbstractCommandInvocation.java b/proxy-core/src/main/java/com/velocitypowered/proxy/command/AbstractCommandInvocation.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/command/AbstractCommandInvocation.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/command/AbstractCommandInvocation.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/BrigadierUtils.java b/proxy-core/src/main/java/com/velocitypowered/proxy/command/BrigadierUtils.java similarity index 99% rename from proxy/src/main/java/com/velocitypowered/proxy/util/BrigadierUtils.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/command/BrigadierUtils.java index db6a5919d..27a631b64 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/BrigadierUtils.java +++ b/proxy-core/src/main/java/com/velocitypowered/proxy/command/BrigadierUtils.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.util; +package com.velocitypowered.proxy.command; import com.google.common.base.Preconditions; import com.google.common.base.Splitter; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/CommandInvocationFactory.java b/proxy-core/src/main/java/com/velocitypowered/proxy/command/CommandInvocationFactory.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/command/CommandInvocationFactory.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/command/CommandInvocationFactory.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/CommandNodeFactory.java b/proxy-core/src/main/java/com/velocitypowered/proxy/command/CommandNodeFactory.java similarity index 98% rename from proxy/src/main/java/com/velocitypowered/proxy/command/CommandNodeFactory.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/command/CommandNodeFactory.java index 5f68066f8..7489c408a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/CommandNodeFactory.java +++ b/proxy-core/src/main/java/com/velocitypowered/proxy/command/CommandNodeFactory.java @@ -26,7 +26,6 @@ import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.InvocableCommand; import com.velocitypowered.api.command.RawCommand; import com.velocitypowered.api.command.SimpleCommand; -import com.velocitypowered.proxy.util.BrigadierUtils; @FunctionalInterface public interface CommandNodeFactory { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java b/proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java similarity index 99% rename from proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java index 4db8974e5..97d83ea18 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java +++ b/proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java @@ -37,7 +37,6 @@ import com.velocitypowered.api.event.command.CommandExecuteEvent; import com.velocitypowered.api.event.command.CommandExecuteEvent.CommandResult; import com.velocitypowered.api.event.command.CommandExecuteEventImpl; import com.velocitypowered.proxy.event.VelocityEventManager; -import com.velocitypowered.proxy.util.BrigadierUtils; import java.util.Iterator; import java.util.List; import java.util.Locale; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandMeta.java b/proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocityCommandMeta.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandMeta.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocityCommandMeta.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityRawCommandInvocation.java b/proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocityRawCommandInvocation.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/command/VelocityRawCommandInvocation.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocityRawCommandInvocation.java index 3e41c4436..15f238c38 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityRawCommandInvocation.java +++ b/proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocityRawCommandInvocation.java @@ -21,7 +21,6 @@ import com.google.common.base.Preconditions; import com.mojang.brigadier.context.CommandContext; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.RawCommand; -import com.velocitypowered.proxy.util.BrigadierUtils; final class VelocityRawCommandInvocation extends AbstractCommandInvocation implements RawCommand.Invocation { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java b/proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java index 74d851c88..31d246ade 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java +++ b/proxy-core/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java @@ -20,7 +20,6 @@ package com.velocitypowered.proxy.command; import com.mojang.brigadier.context.CommandContext; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.SimpleCommand; -import com.velocitypowered.proxy.util.BrigadierUtils; final class VelocitySimpleCommandInvocation extends AbstractCommandInvocation implements SimpleCommand.Invocation { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/event/CustomHandlerAdapter.java b/proxy-core/src/main/java/com/velocitypowered/proxy/event/CustomHandlerAdapter.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/event/CustomHandlerAdapter.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/event/CustomHandlerAdapter.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/event/UntargetedEventHandler.java b/proxy-core/src/main/java/com/velocitypowered/proxy/event/UntargetedEventHandler.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/event/UntargetedEventHandler.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/event/UntargetedEventHandler.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/event/VelocityEventManager.java b/proxy-core/src/main/java/com/velocitypowered/proxy/event/VelocityEventManager.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/event/VelocityEventManager.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/event/VelocityEventManager.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/PluginClassLoader.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/PluginClassLoader.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/PluginClassLoader.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/PluginClassLoader.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java similarity index 98% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java index 0b6811302..af5999f42 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java +++ b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java @@ -35,7 +35,6 @@ import com.velocitypowered.api.plugin.PluginDescription; import com.velocitypowered.api.plugin.PluginManager; 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.jvm.JvmPluginLoader; import com.velocitypowered.proxy.plugin.util.PluginDependencyUtils; @@ -63,9 +62,9 @@ public class VelocityPluginManager implements PluginManager { private final Map plugins = new LinkedHashMap<>(); private final IdentityHashMap pluginInstances = new IdentityHashMap<>(); - private final VelocityServer server; + private final ProxyServer server; - public VelocityPluginManager(VelocityServer server) { + public VelocityPluginManager(ProxyServer server) { this.server = checkNotNull(server, "server"); // Register ourselves as a plugin diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/PluginLoader.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/PluginLoader.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/PluginLoader.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/PluginLoader.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginContainer.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginContainer.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginContainer.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginContainer.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginDescription.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginDescription.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginDescription.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginDescription.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmPluginLoader.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmPluginLoader.java similarity index 98% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmPluginLoader.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmPluginLoader.java index a9da31af2..c58531a99 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmPluginLoader.java +++ b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmPluginLoader.java @@ -17,6 +17,7 @@ package com.velocitypowered.proxy.plugin.loader.jvm; +import com.google.gson.Gson; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; @@ -26,7 +27,6 @@ import com.velocitypowered.api.plugin.PluginContainer; import com.velocitypowered.api.plugin.PluginDescription; import com.velocitypowered.api.plugin.meta.PluginDependency; import com.velocitypowered.api.proxy.ProxyServer; -import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.plugin.PluginClassLoader; import com.velocitypowered.proxy.plugin.loader.PluginLoader; import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer; @@ -54,6 +54,8 @@ import java.util.jar.JarInputStream; public class JvmPluginLoader implements PluginLoader { + private static final Gson PLUGIN_FILE_DESERIALIZER = new Gson(); + private final Path baseDirectory; private final Map classLoaders = new HashMap<>(); @@ -151,7 +153,7 @@ public class JvmPluginLoader implements PluginLoader { while ((entry = in.getNextJarEntry()) != null) { if (entry.getName().equals("velocity-plugin-info.json")) { try (Reader pluginInfoReader = new InputStreamReader(in, StandardCharsets.UTF_8)) { - return VelocityServer.GENERAL_GSON.fromJson(pluginInfoReader, + return PLUGIN_FILE_DESERIALIZER.fromJson(pluginInfoReader, new TypeToken>() {}.getType()); } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescription.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescription.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescription.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescription.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescriptionCandidate.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescriptionCandidate.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescriptionCandidate.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/JvmVelocityPluginDescriptionCandidate.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/VelocityPluginModule.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/VelocityPluginModule.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/VelocityPluginModule.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/loader/jvm/VelocityPluginModule.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/util/PluginDependencyUtils.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/util/PluginDependencyUtils.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/util/PluginDependencyUtils.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/util/PluginDependencyUtils.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/util/ProxyPluginContainer.java b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/util/ProxyPluginContainer.java similarity index 89% rename from proxy/src/main/java/com/velocitypowered/proxy/plugin/util/ProxyPluginContainer.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/plugin/util/ProxyPluginContainer.java index 57a38c9bb..67d488125 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/util/ProxyPluginContainer.java +++ b/proxy-core/src/main/java/com/velocitypowered/proxy/plugin/util/ProxyPluginContainer.java @@ -20,7 +20,7 @@ package com.velocitypowered.proxy.plugin.util; import com.google.common.base.MoreObjects; import com.velocitypowered.api.plugin.PluginContainer; import com.velocitypowered.api.plugin.PluginDescription; -import com.velocitypowered.proxy.VelocityServer; +import com.velocitypowered.api.proxy.ProxyServer; import java.util.List; import org.checkerframework.checker.nullness.qual.Nullable; @@ -36,19 +36,19 @@ public class ProxyPluginContainer implements PluginContainer { @Override public String name() { - final Package pkg = VelocityServer.class.getPackage(); + final Package pkg = ProxyServer.class.getPackage(); return MoreObjects.firstNonNull(pkg.getImplementationTitle(), "Velocity"); } @Override public String version() { - final Package pkg = VelocityServer.class.getPackage(); + final Package pkg = ProxyServer.class.getPackage(); return MoreObjects.firstNonNull(pkg.getImplementationVersion(), ""); } @Override public List authors() { - final Package pkg = VelocityServer.class.getPackage(); + final Package pkg = ProxyServer.class.getPackage(); final String vendor = MoreObjects.firstNonNull(pkg.getImplementationVendor(), "Velocity Contributors"); return List.of(vendor); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java b/proxy-core/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/scheduler/VelocityScheduler.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/adventure/VelocityLegacyHoverEventSerializer.java b/proxy-core/src/main/java/com/velocitypowered/proxy/util/adventure/VelocityLegacyHoverEventSerializer.java similarity index 100% rename from proxy/src/main/java/com/velocitypowered/proxy/util/adventure/VelocityLegacyHoverEventSerializer.java rename to proxy-core/src/main/java/com/velocitypowered/proxy/util/adventure/VelocityLegacyHoverEventSerializer.java diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java b/proxy-core/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java similarity index 100% rename from proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java rename to proxy-core/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/MockCommandSource.java b/proxy-core/src/test/java/com/velocitypowered/proxy/command/MockCommandSource.java similarity index 100% rename from proxy/src/test/java/com/velocitypowered/proxy/command/MockCommandSource.java rename to proxy-core/src/test/java/com/velocitypowered/proxy/command/MockCommandSource.java diff --git a/proxy/src/test/java/com/velocitypowered/proxy/event/EventTest.java b/proxy-core/src/test/java/com/velocitypowered/proxy/event/EventTest.java similarity index 100% rename from proxy/src/test/java/com/velocitypowered/proxy/event/EventTest.java rename to proxy-core/src/test/java/com/velocitypowered/proxy/event/EventTest.java diff --git a/proxy/src/test/java/com/velocitypowered/proxy/event/MockEventManager.java b/proxy-core/src/test/java/com/velocitypowered/proxy/event/MockEventManager.java similarity index 100% rename from proxy/src/test/java/com/velocitypowered/proxy/event/MockEventManager.java rename to proxy-core/src/test/java/com/velocitypowered/proxy/event/MockEventManager.java diff --git a/proxy/src/test/java/com/velocitypowered/proxy/plugin/MockPluginManager.java b/proxy-core/src/test/java/com/velocitypowered/proxy/plugin/MockPluginManager.java similarity index 100% rename from proxy/src/test/java/com/velocitypowered/proxy/plugin/MockPluginManager.java rename to proxy-core/src/test/java/com/velocitypowered/proxy/plugin/MockPluginManager.java diff --git a/proxy/src/test/java/com/velocitypowered/proxy/plugin/util/PluginDependencyUtilsTest.java b/proxy-core/src/test/java/com/velocitypowered/proxy/plugin/PluginDependencyUtilsTest.java similarity index 97% rename from proxy/src/test/java/com/velocitypowered/proxy/plugin/util/PluginDependencyUtilsTest.java rename to proxy-core/src/test/java/com/velocitypowered/proxy/plugin/PluginDependencyUtilsTest.java index 44505ec29..4b5835bf4 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/plugin/util/PluginDependencyUtilsTest.java +++ b/proxy-core/src/test/java/com/velocitypowered/proxy/plugin/PluginDependencyUtilsTest.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.plugin.util; +package com.velocitypowered.proxy.plugin; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableList; import com.velocitypowered.api.plugin.PluginDescription; import com.velocitypowered.api.plugin.meta.PluginDependency; import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription; +import com.velocitypowered.proxy.plugin.util.PluginDependencyUtils; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; diff --git a/proxy/src/test/java/com/velocitypowered/proxy/scheduler/VelocitySchedulerTest.java b/proxy-core/src/test/java/com/velocitypowered/proxy/scheduler/VelocitySchedulerTest.java similarity index 100% rename from proxy/src/test/java/com/velocitypowered/proxy/scheduler/VelocitySchedulerTest.java rename to proxy-core/src/test/java/com/velocitypowered/proxy/scheduler/VelocitySchedulerTest.java diff --git a/proxy-core/src/test/java/com/velocitypowered/proxy/testutil/FakePluginManager.java b/proxy-core/src/test/java/com/velocitypowered/proxy/testutil/FakePluginManager.java new file mode 100644 index 000000000..881b59f55 --- /dev/null +++ b/proxy-core/src/test/java/com/velocitypowered/proxy/testutil/FakePluginManager.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2018 Velocity Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.velocitypowered.proxy.testutil; + +import com.google.common.collect.ImmutableList; +import com.velocitypowered.api.plugin.PluginContainer; +import com.velocitypowered.api.plugin.PluginDescription; +import com.velocitypowered.api.plugin.PluginManager; +import java.nio.file.Path; +import java.util.Collection; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + +public class FakePluginManager implements PluginManager { + + public static final Object PLUGIN_A = new Object(); + public static final Object PLUGIN_B = new Object(); + + private static final PluginContainer PC_A = new FakePluginContainer("a", PLUGIN_A); + private static final PluginContainer PC_B = new FakePluginContainer("b", PLUGIN_B); + + @Override + public @Nullable PluginContainer fromInstance(@NonNull Object instance) { + if (instance == PLUGIN_A) { + return PC_A; + } else if (instance == PLUGIN_B) { + return PC_B; + } else { + return null; + } + } + + @Override + public @Nullable PluginContainer getPlugin(@NonNull String id) { + switch (id) { + case "a": + return PC_A; + case "b": + return PC_B; + default: + return null; + } + } + + @Override + public @NonNull Collection plugins() { + return ImmutableList.of(PC_A, PC_B); + } + + @Override + public boolean isLoaded(@NonNull String id) { + return id.equals("a") || id.equals("b"); + } + + @Override + public void addToClasspath(@NonNull Object plugin, @NonNull Path path) { + throw new UnsupportedOperationException(); + } + + private static class FakePluginContainer implements PluginContainer { + + private final String id; + private final Object instance; + + private FakePluginContainer(String id, Object instance) { + this.id = id; + this.instance = instance; + } + + @Override + public @NonNull PluginDescription description() { + return () -> id; + } + + @Override + public Object instance() { + return instance; + } + } +} diff --git a/proxy/build.gradle b/proxy/build.gradle index 879eb6815..a55d3da5b 100644 --- a/proxy/build.gradle +++ b/proxy/build.gradle @@ -55,9 +55,12 @@ tasks.withType(Checkstyle) { } dependencies { + compileOnly "com.github.spotbugs:spotbugs-annotations:4.1.2" + implementation project(':velocity-api') implementation project(':velocity-annotation-processor') implementation project(':velocity-native') + implementation project(':velocity-proxy-core') implementation "io.netty:netty-codec:${nettyVersion}" implementation "io.netty:netty-codec-haproxy:${nettyVersion}" @@ -67,7 +70,6 @@ dependencies { implementation "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64" implementation "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-aarch_64" - implementation "org.apache.logging.log4j:log4j-api:${log4jVersion}" implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}" implementation "org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}" implementation "org.apache.logging.log4j:log4j-iostreams:${log4jVersion}" @@ -79,7 +81,6 @@ dependencies { runtimeOnly 'com.lmax:disruptor:3.4.2' // Async loggers implementation 'it.unimi.dsi:fastutil:8.4.1' - implementation "net.kyori:adventure-nbt:${adventureVersion}" implementation 'org.asynchttpclient:async-http-client:2.12.1' @@ -87,12 +88,6 @@ dependencies { implementation 'com.electronwill.night-config:toml:3.6.3' implementation 'org.bstats:bstats-base:2.2.0' - implementation 'org.lanternpowered:lmbda:2.0.0' - - implementation 'com.github.ben-manes.caffeine:caffeine:2.8.8' - implementation 'com.vdurmont:semver4j:3.1.0' - - compileOnly 'com.github.spotbugs:spotbugs-annotations:4.1.2' testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java index 70f66699a..51b1e30ca 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java @@ -48,7 +48,7 @@ public class ServerCommand implements SimpleCommand { } @Override - public void execute(final SimpleCommand.Invocation invocation) { + public void execute(final Invocation invocation) { final CommandSource source = invocation.source(); final String[] args = invocation.arguments(); @@ -144,7 +144,7 @@ public class ServerCommand implements SimpleCommand { } @Override - public List suggest(final SimpleCommand.Invocation invocation) { + public List suggest(final Invocation invocation) { final String[] currentArgs = invocation.arguments(); Stream possibilities = server.registeredServers().stream() .map(rs -> rs.serverInfo().name()); @@ -161,7 +161,7 @@ public class ServerCommand implements SimpleCommand { } @Override - public boolean hasPermission(final SimpleCommand.Invocation invocation) { + public boolean hasPermission(final Invocation invocation) { return invocation.source().evaluatePermission("velocity.command.server") != Tristate.FALSE; } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ShutdownCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ShutdownCommand.java index f8a8b346d..664b30070 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ShutdownCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ShutdownCommand.java @@ -18,14 +18,14 @@ package com.velocitypowered.proxy.command.builtin; import com.velocitypowered.api.command.RawCommand; -import com.velocitypowered.proxy.VelocityServer; +import com.velocitypowered.api.proxy.ProxyServer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; public class ShutdownCommand implements RawCommand { - private final VelocityServer server; + private final ProxyServer server; - public ShutdownCommand(VelocityServer server) { + public ShutdownCommand(ProxyServer server) { this.server = server; } @@ -33,9 +33,9 @@ public class ShutdownCommand implements RawCommand { public void execute(final Invocation invocation) { String reason = invocation.arguments(); if (reason.isEmpty() || reason.trim().isEmpty()) { - server.shutdown(true); + server.shutdown(); } else { - server.shutdown(true, LegacyComponentSerializer.legacy('&').deserialize(reason)); + server.shutdown(LegacyComponentSerializer.legacy('&').deserialize(reason)); } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java index 61931379f..d6a5179d6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java @@ -101,7 +101,7 @@ public class VelocityCommand implements SimpleCommand { } @Override - public void execute(final SimpleCommand.Invocation invocation) { + public void execute(final Invocation invocation) { final CommandSource source = invocation.source(); final String[] args = invocation.arguments(); @@ -121,7 +121,7 @@ public class VelocityCommand implements SimpleCommand { } @Override - public List suggest(final SimpleCommand.Invocation invocation) { + public List suggest(final Invocation invocation) { final CommandSource source = invocation.source(); final String[] currentArgs = invocation.arguments(); @@ -151,7 +151,7 @@ public class VelocityCommand implements SimpleCommand { } @Override - public boolean hasPermission(final SimpleCommand.Invocation invocation) { + public boolean hasPermission(final Invocation invocation) { final CommandSource source = invocation.source(); final String[] args = invocation.arguments(); diff --git a/settings.gradle b/settings.gradle index 36cfa5bb5..31acc63aa 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,11 +1,15 @@ rootProject.name = 'velocity' include( 'api', + 'proxy-core', 'proxy', 'native', + 'network', 'annotation-processor' ) findProject(':annotation-processor')?.name = 'velocity-annotation-processor' findProject(':api')?.name = 'velocity-api' findProject(':proxy')?.name = 'velocity-proxy' -findProject(':native')?.name = 'velocity-native' \ No newline at end of file +findProject(':proxy-core')?.name = 'velocity-proxy-core' +findProject(':native')?.name = 'velocity-native' +findProject(':network')?.name = 'velocity-network' \ No newline at end of file