Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Move mostly independent parts of the proxy to its own module
At this point, we have mostly connection/protocol handling and the "core proxy logic" left in the proxy module.
Dieser Commit ist enthalten in:
Ursprung
4a8be52c93
Commit
6a6ca7a03e
35
network/build.gradle
Normale Datei
35
network/build.gradle
Normale Datei
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
proxy-core/build.gradle
Normale Datei
41
proxy-core/build.gradle
Normale Datei
@ -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()
|
||||||
|
}
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.velocitypowered.proxy.util;
|
package com.velocitypowered.proxy.command;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
@ -26,7 +26,6 @@ import com.velocitypowered.api.command.CommandSource;
|
|||||||
import com.velocitypowered.api.command.InvocableCommand;
|
import com.velocitypowered.api.command.InvocableCommand;
|
||||||
import com.velocitypowered.api.command.RawCommand;
|
import com.velocitypowered.api.command.RawCommand;
|
||||||
import com.velocitypowered.api.command.SimpleCommand;
|
import com.velocitypowered.api.command.SimpleCommand;
|
||||||
import com.velocitypowered.proxy.util.BrigadierUtils;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface CommandNodeFactory<T extends Command> {
|
public interface CommandNodeFactory<T extends Command> {
|
@ -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.CommandExecuteEvent.CommandResult;
|
||||||
import com.velocitypowered.api.event.command.CommandExecuteEventImpl;
|
import com.velocitypowered.api.event.command.CommandExecuteEventImpl;
|
||||||
import com.velocitypowered.proxy.event.VelocityEventManager;
|
import com.velocitypowered.proxy.event.VelocityEventManager;
|
||||||
import com.velocitypowered.proxy.util.BrigadierUtils;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
@ -21,7 +21,6 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.command.RawCommand;
|
import com.velocitypowered.api.command.RawCommand;
|
||||||
import com.velocitypowered.proxy.util.BrigadierUtils;
|
|
||||||
|
|
||||||
final class VelocityRawCommandInvocation extends AbstractCommandInvocation<String>
|
final class VelocityRawCommandInvocation extends AbstractCommandInvocation<String>
|
||||||
implements RawCommand.Invocation {
|
implements RawCommand.Invocation {
|
@ -20,7 +20,6 @@ package com.velocitypowered.proxy.command;
|
|||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.command.SimpleCommand;
|
import com.velocitypowered.api.command.SimpleCommand;
|
||||||
import com.velocitypowered.proxy.util.BrigadierUtils;
|
|
||||||
|
|
||||||
final class VelocitySimpleCommandInvocation extends AbstractCommandInvocation<String[]>
|
final class VelocitySimpleCommandInvocation extends AbstractCommandInvocation<String[]>
|
||||||
implements SimpleCommand.Invocation {
|
implements SimpleCommand.Invocation {
|
@ -35,7 +35,6 @@ import com.velocitypowered.api.plugin.PluginDescription;
|
|||||||
import com.velocitypowered.api.plugin.PluginManager;
|
import com.velocitypowered.api.plugin.PluginManager;
|
||||||
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
|
||||||
import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer;
|
import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer;
|
||||||
import com.velocitypowered.proxy.plugin.loader.jvm.JvmPluginLoader;
|
import com.velocitypowered.proxy.plugin.loader.jvm.JvmPluginLoader;
|
||||||
import com.velocitypowered.proxy.plugin.util.PluginDependencyUtils;
|
import com.velocitypowered.proxy.plugin.util.PluginDependencyUtils;
|
||||||
@ -63,9 +62,9 @@ public class VelocityPluginManager implements PluginManager {
|
|||||||
|
|
||||||
private final Map<String, PluginContainer> plugins = new LinkedHashMap<>();
|
private final Map<String, PluginContainer> plugins = new LinkedHashMap<>();
|
||||||
private final IdentityHashMap<Object, PluginContainer> pluginInstances = new IdentityHashMap<>();
|
private final IdentityHashMap<Object, PluginContainer> pluginInstances = new IdentityHashMap<>();
|
||||||
private final VelocityServer server;
|
private final ProxyServer server;
|
||||||
|
|
||||||
public VelocityPluginManager(VelocityServer server) {
|
public VelocityPluginManager(ProxyServer server) {
|
||||||
this.server = checkNotNull(server, "server");
|
this.server = checkNotNull(server, "server");
|
||||||
|
|
||||||
// Register ourselves as a plugin
|
// Register ourselves as a plugin
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.proxy.plugin.loader.jvm;
|
package com.velocitypowered.proxy.plugin.loader.jvm;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
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.PluginDescription;
|
||||||
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
|
||||||
import com.velocitypowered.proxy.plugin.PluginClassLoader;
|
import com.velocitypowered.proxy.plugin.PluginClassLoader;
|
||||||
import com.velocitypowered.proxy.plugin.loader.PluginLoader;
|
import com.velocitypowered.proxy.plugin.loader.PluginLoader;
|
||||||
import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer;
|
import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer;
|
||||||
@ -54,6 +54,8 @@ import java.util.jar.JarInputStream;
|
|||||||
|
|
||||||
public class JvmPluginLoader implements PluginLoader {
|
public class JvmPluginLoader implements PluginLoader {
|
||||||
|
|
||||||
|
private static final Gson PLUGIN_FILE_DESERIALIZER = new Gson();
|
||||||
|
|
||||||
private final Path baseDirectory;
|
private final Path baseDirectory;
|
||||||
private final Map<URI, PluginClassLoader> classLoaders = new HashMap<>();
|
private final Map<URI, PluginClassLoader> classLoaders = new HashMap<>();
|
||||||
|
|
||||||
@ -151,7 +153,7 @@ public class JvmPluginLoader implements PluginLoader {
|
|||||||
while ((entry = in.getNextJarEntry()) != null) {
|
while ((entry = in.getNextJarEntry()) != null) {
|
||||||
if (entry.getName().equals("velocity-plugin-info.json")) {
|
if (entry.getName().equals("velocity-plugin-info.json")) {
|
||||||
try (Reader pluginInfoReader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
|
try (Reader pluginInfoReader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
|
||||||
return VelocityServer.GENERAL_GSON.fromJson(pluginInfoReader,
|
return PLUGIN_FILE_DESERIALIZER.fromJson(pluginInfoReader,
|
||||||
new TypeToken<List<SerializedPluginDescription>>() {}.getType());
|
new TypeToken<List<SerializedPluginDescription>>() {}.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ package com.velocitypowered.proxy.plugin.util;
|
|||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.velocitypowered.api.plugin.PluginContainer;
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
import com.velocitypowered.api.plugin.PluginDescription;
|
import com.velocitypowered.api.plugin.PluginDescription;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@ -36,19 +36,19 @@ public class ProxyPluginContainer implements PluginContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
final Package pkg = VelocityServer.class.getPackage();
|
final Package pkg = ProxyServer.class.getPackage();
|
||||||
return MoreObjects.firstNonNull(pkg.getImplementationTitle(), "Velocity");
|
return MoreObjects.firstNonNull(pkg.getImplementationTitle(), "Velocity");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String version() {
|
public String version() {
|
||||||
final Package pkg = VelocityServer.class.getPackage();
|
final Package pkg = ProxyServer.class.getPackage();
|
||||||
return MoreObjects.firstNonNull(pkg.getImplementationVersion(), "<unknown>");
|
return MoreObjects.firstNonNull(pkg.getImplementationVersion(), "<unknown>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> authors() {
|
public List<String> authors() {
|
||||||
final Package pkg = VelocityServer.class.getPackage();
|
final Package pkg = ProxyServer.class.getPackage();
|
||||||
final String vendor = MoreObjects.firstNonNull(pkg.getImplementationVendor(),
|
final String vendor = MoreObjects.firstNonNull(pkg.getImplementationVendor(),
|
||||||
"Velocity Contributors");
|
"Velocity Contributors");
|
||||||
return List.of(vendor);
|
return List.of(vendor);
|
@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
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.PluginDescription;
|
||||||
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
||||||
import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription;
|
import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription;
|
||||||
|
import com.velocitypowered.proxy.plugin.util.PluginDependencyUtils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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<PluginContainer> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -55,9 +55,12 @@ tasks.withType(Checkstyle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compileOnly "com.github.spotbugs:spotbugs-annotations:4.1.2"
|
||||||
|
|
||||||
implementation project(':velocity-api')
|
implementation project(':velocity-api')
|
||||||
implementation project(':velocity-annotation-processor')
|
implementation project(':velocity-annotation-processor')
|
||||||
implementation project(':velocity-native')
|
implementation project(':velocity-native')
|
||||||
|
implementation project(':velocity-proxy-core')
|
||||||
|
|
||||||
implementation "io.netty:netty-codec:${nettyVersion}"
|
implementation "io.netty:netty-codec:${nettyVersion}"
|
||||||
implementation "io.netty:netty-codec-haproxy:${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-x86_64"
|
||||||
implementation "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-aarch_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-core:${log4jVersion}"
|
||||||
implementation "org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}"
|
implementation "org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}"
|
||||||
implementation "org.apache.logging.log4j:log4j-iostreams:${log4jVersion}"
|
implementation "org.apache.logging.log4j:log4j-iostreams:${log4jVersion}"
|
||||||
@ -79,7 +81,6 @@ dependencies {
|
|||||||
runtimeOnly 'com.lmax:disruptor:3.4.2' // Async loggers
|
runtimeOnly 'com.lmax:disruptor:3.4.2' // Async loggers
|
||||||
|
|
||||||
implementation 'it.unimi.dsi:fastutil:8.4.1'
|
implementation 'it.unimi.dsi:fastutil:8.4.1'
|
||||||
implementation "net.kyori:adventure-nbt:${adventureVersion}"
|
|
||||||
|
|
||||||
implementation 'org.asynchttpclient:async-http-client:2.12.1'
|
implementation 'org.asynchttpclient:async-http-client:2.12.1'
|
||||||
|
|
||||||
@ -87,12 +88,6 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'com.electronwill.night-config:toml:3.6.3'
|
implementation 'com.electronwill.night-config:toml:3.6.3'
|
||||||
implementation 'org.bstats:bstats-base:2.2.0'
|
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-api:${junitVersion}"
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
||||||
|
@ -48,7 +48,7 @@ public class ServerCommand implements SimpleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final SimpleCommand.Invocation invocation) {
|
public void execute(final Invocation invocation) {
|
||||||
final CommandSource source = invocation.source();
|
final CommandSource source = invocation.source();
|
||||||
final String[] args = invocation.arguments();
|
final String[] args = invocation.arguments();
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ public class ServerCommand implements SimpleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggest(final SimpleCommand.Invocation invocation) {
|
public List<String> suggest(final Invocation invocation) {
|
||||||
final String[] currentArgs = invocation.arguments();
|
final String[] currentArgs = invocation.arguments();
|
||||||
Stream<String> possibilities = server.registeredServers().stream()
|
Stream<String> possibilities = server.registeredServers().stream()
|
||||||
.map(rs -> rs.serverInfo().name());
|
.map(rs -> rs.serverInfo().name());
|
||||||
@ -161,7 +161,7 @@ public class ServerCommand implements SimpleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(final SimpleCommand.Invocation invocation) {
|
public boolean hasPermission(final Invocation invocation) {
|
||||||
return invocation.source().evaluatePermission("velocity.command.server") != Tristate.FALSE;
|
return invocation.source().evaluatePermission("velocity.command.server") != Tristate.FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,14 @@
|
|||||||
package com.velocitypowered.proxy.command.builtin;
|
package com.velocitypowered.proxy.command.builtin;
|
||||||
|
|
||||||
import com.velocitypowered.api.command.RawCommand;
|
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;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
|
||||||
public class ShutdownCommand implements RawCommand {
|
public class ShutdownCommand implements RawCommand {
|
||||||
|
|
||||||
private final VelocityServer server;
|
private final ProxyServer server;
|
||||||
|
|
||||||
public ShutdownCommand(VelocityServer server) {
|
public ShutdownCommand(ProxyServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,9 +33,9 @@ public class ShutdownCommand implements RawCommand {
|
|||||||
public void execute(final Invocation invocation) {
|
public void execute(final Invocation invocation) {
|
||||||
String reason = invocation.arguments();
|
String reason = invocation.arguments();
|
||||||
if (reason.isEmpty() || reason.trim().isEmpty()) {
|
if (reason.isEmpty() || reason.trim().isEmpty()) {
|
||||||
server.shutdown(true);
|
server.shutdown();
|
||||||
} else {
|
} else {
|
||||||
server.shutdown(true, LegacyComponentSerializer.legacy('&').deserialize(reason));
|
server.shutdown(LegacyComponentSerializer.legacy('&').deserialize(reason));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final SimpleCommand.Invocation invocation) {
|
public void execute(final Invocation invocation) {
|
||||||
final CommandSource source = invocation.source();
|
final CommandSource source = invocation.source();
|
||||||
final String[] args = invocation.arguments();
|
final String[] args = invocation.arguments();
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggest(final SimpleCommand.Invocation invocation) {
|
public List<String> suggest(final Invocation invocation) {
|
||||||
final CommandSource source = invocation.source();
|
final CommandSource source = invocation.source();
|
||||||
final String[] currentArgs = invocation.arguments();
|
final String[] currentArgs = invocation.arguments();
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(final SimpleCommand.Invocation invocation) {
|
public boolean hasPermission(final Invocation invocation) {
|
||||||
final CommandSource source = invocation.source();
|
final CommandSource source = invocation.source();
|
||||||
final String[] args = invocation.arguments();
|
final String[] args = invocation.arguments();
|
||||||
|
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
rootProject.name = 'velocity'
|
rootProject.name = 'velocity'
|
||||||
include(
|
include(
|
||||||
'api',
|
'api',
|
||||||
|
'proxy-core',
|
||||||
'proxy',
|
'proxy',
|
||||||
'native',
|
'native',
|
||||||
|
'network',
|
||||||
'annotation-processor'
|
'annotation-processor'
|
||||||
)
|
)
|
||||||
findProject(':annotation-processor')?.name = 'velocity-annotation-processor'
|
findProject(':annotation-processor')?.name = 'velocity-annotation-processor'
|
||||||
findProject(':api')?.name = 'velocity-api'
|
findProject(':api')?.name = 'velocity-api'
|
||||||
findProject(':proxy')?.name = 'velocity-proxy'
|
findProject(':proxy')?.name = 'velocity-proxy'
|
||||||
|
findProject(':proxy-core')?.name = 'velocity-proxy-core'
|
||||||
findProject(':native')?.name = 'velocity-native'
|
findProject(':native')?.name = 'velocity-native'
|
||||||
|
findProject(':network')?.name = 'velocity-network'
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren