Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Fix ShutdownCommand message
Dieser Commit ist enthalten in:
Ursprung
0cd069ecbf
Commit
cf921646df
@ -17,6 +17,7 @@
|
||||
|
||||
package com.velocitypowered.proxy.command.builtin;
|
||||
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
@ -24,8 +25,9 @@ import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.velocitypowered.api.command.BrigadierCommand;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.proxy.VelocityServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
/**
|
||||
* Shuts down the proxy.
|
||||
@ -52,11 +54,22 @@ public final class ShutdownCommand {
|
||||
StringArgumentType.greedyString())
|
||||
.executes(context -> {
|
||||
String reason = context.getArgument("reason", String.class);
|
||||
server.shutdown(true, MiniMessage.miniMessage().deserialize(
|
||||
MiniMessage.miniMessage().serialize(
|
||||
LegacyComponentSerializer.legacy('&').deserialize(reason)
|
||||
)
|
||||
));
|
||||
Component reasonComponent = null;
|
||||
|
||||
if (reason.startsWith("{") || reason.startsWith("[") || reason.startsWith("\"")) {
|
||||
try {
|
||||
reasonComponent = GsonComponentSerializer.gson()
|
||||
.deserializeOrNull(reason);
|
||||
} catch (JsonSyntaxException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (reasonComponent == null) {
|
||||
reasonComponent = MiniMessage.miniMessage().deserialize(reason);
|
||||
}
|
||||
|
||||
server.shutdown(true, reasonComponent);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
})
|
||||
).build());
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren