geforkt von Mirrors/Velocity
Merge pull request #266 from alex11441/dev/1.1.0
Allow users to specify a reason in the shutdown command
Dieser Commit ist enthalten in:
Commit
77526d9bf4
@ -360,11 +360,12 @@ public class VelocityServer implements ProxyServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuts down the proxy.
|
* Shuts down the proxy, kicking players with the specified {@param reason}.
|
||||||
*
|
*
|
||||||
* @param explicitExit whether the user explicitly shut down the proxy
|
* @param explicitExit whether the user explicitly shut down the proxy
|
||||||
|
* @param reason message to kick online players with
|
||||||
*/
|
*/
|
||||||
public void shutdown(boolean explicitExit) {
|
public void shutdown(boolean explicitExit, TextComponent reason) {
|
||||||
if (eventManager == null || pluginManager == null || cm == null || scheduler == null) {
|
if (eventManager == null || pluginManager == null || cm == null || scheduler == null) {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
@ -382,7 +383,7 @@ public class VelocityServer implements ProxyServer {
|
|||||||
|
|
||||||
ImmutableList<ConnectedPlayer> players = ImmutableList.copyOf(connectionsByUuid.values());
|
ImmutableList<ConnectedPlayer> players = ImmutableList.copyOf(connectionsByUuid.values());
|
||||||
for (ConnectedPlayer player : players) {
|
for (ConnectedPlayer player : players) {
|
||||||
player.disconnect(TextComponent.of("Proxy shutting down."));
|
player.disconnect(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -425,6 +426,15 @@ public class VelocityServer implements ProxyServer {
|
|||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls {@link #shutdown(boolean, TextComponent)} with the default reason "Proxy shutting down."
|
||||||
|
*
|
||||||
|
* @param explicitExit whether the user explicitly shut down the proxy
|
||||||
|
*/
|
||||||
|
public void shutdown(boolean explicitExit) {
|
||||||
|
shutdown(explicitExit, TextComponent.of("Proxy shutting down."));
|
||||||
|
}
|
||||||
|
|
||||||
public AsyncHttpClient getAsyncHttpClient() {
|
public AsyncHttpClient getAsyncHttpClient() {
|
||||||
return ensureInitialized(cm).getHttpClient();
|
return ensureInitialized(cm).getHttpClient();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.velocitypowered.api.command.CommandSource;
|
|||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.format.TextColor;
|
import net.kyori.text.format.TextColor;
|
||||||
|
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
public class ShutdownCommand implements Command {
|
public class ShutdownCommand implements Command {
|
||||||
@ -17,7 +18,12 @@ public class ShutdownCommand implements Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource source, String @NonNull [] args) {
|
public void execute(CommandSource source, String @NonNull [] args) {
|
||||||
server.shutdown(true);
|
if (args.length == 0) {
|
||||||
|
server.shutdown(true);
|
||||||
|
} else {
|
||||||
|
String reason = String.join(" ", args);
|
||||||
|
server.shutdown(true, LegacyComponentSerializer.legacy().deserialize(reason, '&'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren