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;
|
package com.velocitypowered.proxy.command.builtin;
|
||||||
|
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
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.BrigadierCommand;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
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.
|
* Shuts down the proxy.
|
||||||
@ -52,11 +54,22 @@ public final class ShutdownCommand {
|
|||||||
StringArgumentType.greedyString())
|
StringArgumentType.greedyString())
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
String reason = context.getArgument("reason", String.class);
|
String reason = context.getArgument("reason", String.class);
|
||||||
server.shutdown(true, MiniMessage.miniMessage().deserialize(
|
Component reasonComponent = null;
|
||||||
MiniMessage.miniMessage().serialize(
|
|
||||||
LegacyComponentSerializer.legacy('&').deserialize(reason)
|
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;
|
return Command.SINGLE_SUCCESS;
|
||||||
})
|
})
|
||||||
).build());
|
).build());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren