Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Added MiniMessage support to built-in motd (#666)
Dieser Commit ist enthalten in:
Ursprung
dc7efd93ad
Commit
cc74cf855f
@ -45,6 +45,7 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@ -273,11 +274,7 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
@Override
|
@Override
|
||||||
public net.kyori.adventure.text.Component getMotd() {
|
public net.kyori.adventure.text.Component getMotd() {
|
||||||
if (motdAsComponent == null) {
|
if (motdAsComponent == null) {
|
||||||
if (motd.startsWith("{")) {
|
motdAsComponent = MiniMessage.miniMessage().deserialize(motd);
|
||||||
motdAsComponent = GsonComponentSerializer.gson().deserialize(motd);
|
|
||||||
} else {
|
|
||||||
motdAsComponent = LegacyComponentSerializer.legacy('&').deserialize(motd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return motdAsComponent;
|
return motdAsComponent;
|
||||||
}
|
}
|
||||||
@ -531,6 +528,32 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
mustResave = true;
|
mustResave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String motd = config.getOrElse("motd", "<#09add3>A Velocity Server");
|
||||||
|
|
||||||
|
// Old MOTD Migration
|
||||||
|
if (configVersion < 2.6) {
|
||||||
|
final String migratedMotd;
|
||||||
|
// JSON Format Migration
|
||||||
|
if (motd.strip().startsWith("{")) {
|
||||||
|
migratedMotd = MiniMessage.miniMessage().serialize(
|
||||||
|
GsonComponentSerializer.gson().deserialize(motd))
|
||||||
|
.replace("\\", "");
|
||||||
|
} else {
|
||||||
|
// Legacy '&' Format Migration
|
||||||
|
migratedMotd = MiniMessage.miniMessage().serialize(
|
||||||
|
LegacyComponentSerializer.legacyAmpersand().deserialize(motd));
|
||||||
|
}
|
||||||
|
|
||||||
|
config.set("motd", migratedMotd);
|
||||||
|
motd = migratedMotd;
|
||||||
|
|
||||||
|
config.setComment("motd",
|
||||||
|
" What should be the MOTD? This gets displayed when the player adds your server to\n"
|
||||||
|
+ " their server list. Only MiniMessage format is accepted.");
|
||||||
|
config.set("config-version", "2.6");
|
||||||
|
mustResave = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle any cases where the config needs to be saved again
|
// Handle any cases where the config needs to be saved again
|
||||||
if (mustResave) {
|
if (mustResave) {
|
||||||
config.save();
|
config.save();
|
||||||
@ -548,7 +571,6 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
PingPassthroughMode.DISABLED);
|
PingPassthroughMode.DISABLED);
|
||||||
|
|
||||||
String bind = config.getOrElse("bind", "0.0.0.0:25577");
|
String bind = config.getOrElse("bind", "0.0.0.0:25577");
|
||||||
String motd = config.getOrElse("motd", "	add3A Velocity Server");
|
|
||||||
int maxPlayers = config.getIntOrElse("show-max-players", 500);
|
int maxPlayers = config.getIntOrElse("show-max-players", 500);
|
||||||
Boolean onlineMode = config.getOrElse("online-mode", true);
|
Boolean onlineMode = config.getOrElse("online-mode", true);
|
||||||
Boolean forceKeyAuthentication = config.getOrElse("force-key-authentication", true);
|
Boolean forceKeyAuthentication = config.getOrElse("force-key-authentication", true);
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
# Config version. Do not change this
|
# Config version. Do not change this
|
||||||
config-version = "2.5"
|
config-version = "2.6"
|
||||||
|
|
||||||
# What port should the proxy be bound to? By default, we'll bind to all addresses on port 25577.
|
# What port should the proxy be bound to? By default, we'll bind to all addresses on port 25577.
|
||||||
bind = "0.0.0.0:25577"
|
bind = "0.0.0.0:25577"
|
||||||
|
|
||||||
# What should be the MOTD? This gets displayed when the player adds your server to
|
# What should be the MOTD? This gets displayed when the player adds your server to
|
||||||
# their server list. Legacy color codes and JSON are accepted.
|
# their server list. Only MiniMessage format is accepted.
|
||||||
motd = "	add3A Velocity Server"
|
motd = "<#09add3>A Velocity Server"
|
||||||
|
|
||||||
# What should we display for the maximum number of players? (Velocity does not support a cap
|
# What should we display for the maximum number of players? (Velocity does not support a cap
|
||||||
# on the number of players online.)
|
# on the number of players online.)
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren