Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Update for Adventure changes
Dieser Commit ist enthalten in:
Ursprung
d2b65cb643
Commit
cc6546bea9
@ -344,14 +344,14 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
player.createConnectionRequest(next.get()).connectWithIndication()
|
player.createConnectionRequest(next.get()).connectWithIndication()
|
||||||
.whenComplete((success, ex) -> {
|
.whenComplete((success, ex) -> {
|
||||||
if (ex != null || success == null || !success) {
|
if (ex != null || success == null || !success) {
|
||||||
player.disconnect(TextComponent.of("Your server has been changed, but we could "
|
player.disconnect(Component.text("Your server has been changed, but we could "
|
||||||
+ "not move you to any fallback servers."));
|
+ "not move you to any fallback servers."));
|
||||||
}
|
}
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
player.disconnect(TextComponent.of("Your server has been changed, but we could "
|
player.disconnect(Component.text("Your server has been changed, but we could "
|
||||||
+ "not move you to any fallback servers."));
|
+ "not move you to any fallback servers."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -466,7 +466,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
* @param explicitExit whether the user explicitly shut down the proxy
|
* @param explicitExit whether the user explicitly shut down the proxy
|
||||||
*/
|
*/
|
||||||
public void shutdown(boolean explicitExit) {
|
public void shutdown(boolean explicitExit) {
|
||||||
shutdown(explicitExit, TextComponent.of("Proxy shutting down."));
|
shutdown(explicitExit, Component.text("Proxy shutting down."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -520,7 +520,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
} else {
|
} else {
|
||||||
ConnectedPlayer existing = connectionsByUuid.get(connection.getUniqueId());
|
ConnectedPlayer existing = connectionsByUuid.get(connection.getUniqueId());
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
existing.disconnect(TranslatableComponent.of("multiplayer.disconnect.duplicate_login"));
|
existing.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can now replace the entries as needed.
|
// We can now replace the entries as needed.
|
||||||
|
@ -24,6 +24,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ public class VelocityCommandManager implements CommandManager {
|
|||||||
boolean isSyntaxError = !e.getType().equals(
|
boolean isSyntaxError = !e.getType().equals(
|
||||||
CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand());
|
CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand());
|
||||||
if (isSyntaxError) {
|
if (isSyntaxError) {
|
||||||
source.sendMessage(TextComponent.of(e.getMessage(), NamedTextColor.RED));
|
source.sendMessage(Component.text(e.getMessage(), NamedTextColor.RED));
|
||||||
// This is, of course, a lie, but the API will need to change...
|
// This is, of course, a lie, but the API will need to change...
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,6 +17,7 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
|||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
@ -59,9 +60,10 @@ public class GlistCommand {
|
|||||||
final CommandSource source = context.getSource();
|
final CommandSource source = context.getSource();
|
||||||
sendTotalProxyCount(source);
|
sendTotalProxyCount(source);
|
||||||
source.sendMessage(
|
source.sendMessage(
|
||||||
TextComponent.builder("To view all players on servers, use ", NamedTextColor.YELLOW)
|
Component.text().content("To view all players on servers, use ")
|
||||||
.append("/glist all", NamedTextColor.DARK_AQUA)
|
.color(NamedTextColor.YELLOW)
|
||||||
.append(".", NamedTextColor.YELLOW)
|
.append(Component.text("/glist all", NamedTextColor.DARK_AQUA))
|
||||||
|
.append(Component.text(".", NamedTextColor.YELLOW))
|
||||||
.build());
|
.build());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -78,7 +80,7 @@ public class GlistCommand {
|
|||||||
Optional<RegisteredServer> registeredServer = server.getServer(serverName);
|
Optional<RegisteredServer> registeredServer = server.getServer(serverName);
|
||||||
if (!registeredServer.isPresent()) {
|
if (!registeredServer.isPresent()) {
|
||||||
source.sendMessage(
|
source.sendMessage(
|
||||||
TextComponent.of("Server " + serverName + " doesn't exist.", NamedTextColor.RED));
|
Component.text("Server " + serverName + " doesn't exist.", NamedTextColor.RED));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sendServerPlayers(source, registeredServer.get(), false);
|
sendServerPlayers(source, registeredServer.get(), false);
|
||||||
@ -87,9 +89,9 @@ public class GlistCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendTotalProxyCount(CommandSource target) {
|
private void sendTotalProxyCount(CommandSource target) {
|
||||||
target.sendMessage(TextComponent.builder("There are ", NamedTextColor.YELLOW)
|
target.sendMessage(Component.text().content("There are ").color(NamedTextColor.YELLOW)
|
||||||
.append(Integer.toString(server.getAllPlayers().size()), NamedTextColor.GREEN)
|
.append(Component.text(server.getAllPlayers().size(), NamedTextColor.GREEN))
|
||||||
.append(" player(s) online.", NamedTextColor.YELLOW)
|
.append(Component.text(" player(s) online.", NamedTextColor.YELLOW))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,11 +101,11 @@ public class GlistCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextComponent.Builder builder = TextComponent.builder()
|
TextComponent.Builder builder = Component.text()
|
||||||
.append(TextComponent.of("[" + server.getServerInfo().getName() + "] ",
|
.append(TextComponent.of("[" + server.getServerInfo().getName() + "] ",
|
||||||
NamedTextColor.DARK_AQUA))
|
NamedTextColor.DARK_AQUA))
|
||||||
.append("(" + onServer.size() + ")", NamedTextColor.GRAY)
|
.append(Component.text("(" + onServer.size() + ")", NamedTextColor.GRAY))
|
||||||
.append(": ")
|
.append(Component.text(": "))
|
||||||
.resetStyle();
|
.resetStyle();
|
||||||
|
|
||||||
for (int i = 0; i < onServer.size(); i++) {
|
for (int i = 0; i < onServer.size(); i++) {
|
||||||
@ -111,7 +113,7 @@ public class GlistCommand {
|
|||||||
builder.append(player.getUsername());
|
builder.append(player.getUsername());
|
||||||
|
|
||||||
if (i + 1 < onServer.size()) {
|
if (i + 1 < onServer.size()) {
|
||||||
builder.append(", ");
|
builder.append(Component.text(", "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
@ -34,7 +35,7 @@ public class ServerCommand implements SimpleCommand {
|
|||||||
final String[] args = invocation.arguments();
|
final String[] args = invocation.arguments();
|
||||||
|
|
||||||
if (!(source instanceof Player)) {
|
if (!(source instanceof Player)) {
|
||||||
source.sendMessage(TextComponent.of("Only players may run this command.",
|
source.sendMessage(Component.text("Only players may run this command.",
|
||||||
NamedTextColor.RED));
|
NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -46,7 +47,7 @@ public class ServerCommand implements SimpleCommand {
|
|||||||
Optional<RegisteredServer> toConnect = server.getServer(serverName);
|
Optional<RegisteredServer> toConnect = server.getServer(serverName);
|
||||||
if (!toConnect.isPresent()) {
|
if (!toConnect.isPresent()) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TextComponent.of("Server " + serverName + " doesn't exist.", NamedTextColor.RED));
|
Component.text("Server " + serverName + " doesn't exist.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,24 +60,24 @@ public class ServerCommand implements SimpleCommand {
|
|||||||
private void outputServerInformation(Player executor) {
|
private void outputServerInformation(Player executor) {
|
||||||
String currentServer = executor.getCurrentServer().map(ServerConnection::getServerInfo)
|
String currentServer = executor.getCurrentServer().map(ServerConnection::getServerInfo)
|
||||||
.map(ServerInfo::getName).orElse("<unknown>");
|
.map(ServerInfo::getName).orElse("<unknown>");
|
||||||
executor.sendMessage(TextComponent.of("You are currently connected to " + currentServer + ".",
|
executor.sendMessage(Component.text("You are currently connected to " + currentServer + ".",
|
||||||
NamedTextColor.YELLOW));
|
NamedTextColor.YELLOW));
|
||||||
|
|
||||||
List<RegisteredServer> servers = BuiltinCommandUtil.sortedServerList(server);
|
List<RegisteredServer> servers = BuiltinCommandUtil.sortedServerList(server);
|
||||||
if (servers.size() > MAX_SERVERS_TO_LIST) {
|
if (servers.size() > MAX_SERVERS_TO_LIST) {
|
||||||
executor.sendMessage(TextComponent.of(
|
executor.sendMessage(Component.text(
|
||||||
"Too many servers to list. Tab-complete to show all servers.", NamedTextColor.RED));
|
"Too many servers to list. Tab-complete to show all servers.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assemble the list of servers as components
|
// Assemble the list of servers as components
|
||||||
TextComponent.Builder serverListBuilder = TextComponent.builder("Available servers: ")
|
TextComponent.Builder serverListBuilder = Component.text().content("Available servers: ")
|
||||||
.color(NamedTextColor.YELLOW);
|
.color(NamedTextColor.YELLOW);
|
||||||
for (int i = 0; i < servers.size(); i++) {
|
for (int i = 0; i < servers.size(); i++) {
|
||||||
RegisteredServer rs = servers.get(i);
|
RegisteredServer rs = servers.get(i);
|
||||||
serverListBuilder.append(formatServerComponent(currentServer, rs));
|
serverListBuilder.append(formatServerComponent(currentServer, rs));
|
||||||
if (i != servers.size() - 1) {
|
if (i != servers.size() - 1) {
|
||||||
serverListBuilder.append(TextComponent.of(", ", NamedTextColor.GRAY));
|
serverListBuilder.append(Component.text(", ", NamedTextColor.GRAY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,19 +86,19 @@ public class ServerCommand implements SimpleCommand {
|
|||||||
|
|
||||||
private TextComponent formatServerComponent(String currentPlayerServer, RegisteredServer server) {
|
private TextComponent formatServerComponent(String currentPlayerServer, RegisteredServer server) {
|
||||||
ServerInfo serverInfo = server.getServerInfo();
|
ServerInfo serverInfo = server.getServerInfo();
|
||||||
TextComponent serverTextComponent = TextComponent.of(serverInfo.getName());
|
TextComponent serverTextComponent = Component.text(serverInfo.getName());
|
||||||
|
|
||||||
String playersText = server.getPlayersConnected().size() + " player(s) online";
|
String playersText = server.getPlayersConnected().size() + " player(s) online";
|
||||||
if (serverInfo.getName().equals(currentPlayerServer)) {
|
if (serverInfo.getName().equals(currentPlayerServer)) {
|
||||||
serverTextComponent = serverTextComponent.color(NamedTextColor.GREEN)
|
serverTextComponent = serverTextComponent.color(NamedTextColor.GREEN)
|
||||||
.hoverEvent(
|
.hoverEvent(
|
||||||
showText(TextComponent.of("Currently connected to this server\n" + playersText))
|
showText(Component.text("Currently connected to this server\n" + playersText))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
serverTextComponent = serverTextComponent.color(NamedTextColor.GRAY)
|
serverTextComponent = serverTextComponent.color(NamedTextColor.GRAY)
|
||||||
.clickEvent(ClickEvent.runCommand("/server " + serverInfo.getName()))
|
.clickEvent(ClickEvent.runCommand("/server " + serverInfo.getName()))
|
||||||
.hoverEvent(
|
.hoverEvent(
|
||||||
showText(TextComponent.of("Click to connect to this server\n" + playersText))
|
showText(Component.text("Click to connect to this server\n" + playersText))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return serverTextComponent;
|
return serverTextComponent;
|
||||||
|
@ -16,6 +16,7 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
@ -59,7 +60,7 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
.map(Map.Entry::getKey)
|
.map(Map.Entry::getKey)
|
||||||
.collect(Collectors.joining("|"));
|
.collect(Collectors.joining("|"));
|
||||||
String commandText = "/velocity <" + availableCommands + ">";
|
String commandText = "/velocity <" + availableCommands + ">";
|
||||||
source.sendMessage(TextComponent.of(commandText, NamedTextColor.RED));
|
source.sendMessage(Component.text(commandText, NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,15 +143,15 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
public void execute(CommandSource source, String @NonNull [] args) {
|
public void execute(CommandSource source, String @NonNull [] args) {
|
||||||
try {
|
try {
|
||||||
if (server.reloadConfiguration()) {
|
if (server.reloadConfiguration()) {
|
||||||
source.sendMessage(TextComponent.of("Configuration reloaded.", NamedTextColor.GREEN));
|
source.sendMessage(Component.text("Configuration reloaded.", NamedTextColor.GREEN));
|
||||||
} else {
|
} else {
|
||||||
source.sendMessage(TextComponent.of(
|
source.sendMessage(Component.text(
|
||||||
"Unable to reload your configuration. Check the console for more details.",
|
"Unable to reload your configuration. Check the console for more details.",
|
||||||
NamedTextColor.RED));
|
NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to reload configuration", e);
|
logger.error("Unable to reload configuration", e);
|
||||||
source.sendMessage(TextComponent.of(
|
source.sendMessage(Component.text(
|
||||||
"Unable to reload your configuration. Check the console for more details.",
|
"Unable to reload your configuration. Check the console for more details.",
|
||||||
NamedTextColor.RED));
|
NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@ -173,16 +174,16 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource source, String @NonNull [] args) {
|
public void execute(CommandSource source, String @NonNull [] args) {
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
source.sendMessage(TextComponent.of("/velocity version", NamedTextColor.RED));
|
source.sendMessage(Component.text("/velocity version", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyVersion version = server.getVersion();
|
ProxyVersion version = server.getVersion();
|
||||||
|
|
||||||
TextComponent velocity = TextComponent.builder(version.getName() + " ")
|
TextComponent velocity = Component.text().content(version.getName() + " ")
|
||||||
.decoration(TextDecoration.BOLD, true)
|
.decoration(TextDecoration.BOLD, true)
|
||||||
.color(NamedTextColor.DARK_AQUA)
|
.color(NamedTextColor.DARK_AQUA)
|
||||||
.append(TextComponent.of(version.getVersion()).decoration(TextDecoration.BOLD, false))
|
.append(Component.text(version.getVersion()).decoration(TextDecoration.BOLD, false))
|
||||||
.build();
|
.build();
|
||||||
TextComponent copyright = TextComponent
|
TextComponent copyright = TextComponent
|
||||||
.of("Copyright 2018-2020 " + version.getVendor() + ". " + version.getName()
|
.of("Copyright 2018-2020 " + version.getVendor() + ". " + version.getName()
|
||||||
@ -191,15 +192,15 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
source.sendMessage(copyright);
|
source.sendMessage(copyright);
|
||||||
|
|
||||||
if (version.getName().equals("Velocity")) {
|
if (version.getName().equals("Velocity")) {
|
||||||
TextComponent velocityWebsite = TextComponent.builder()
|
TextComponent velocityWebsite = Component.text()
|
||||||
.content("Visit the ")
|
.content("Visit the ")
|
||||||
.append(TextComponent.builder("Velocity website")
|
.append(Component.text().content("Velocity website")
|
||||||
.color(NamedTextColor.GREEN)
|
.color(NamedTextColor.GREEN)
|
||||||
.clickEvent(
|
.clickEvent(
|
||||||
ClickEvent.openUrl("https://www.velocitypowered.com"))
|
ClickEvent.openUrl("https://www.velocitypowered.com"))
|
||||||
.build())
|
.build())
|
||||||
.append(TextComponent.of(" or the "))
|
.append(Component.text(" or the "))
|
||||||
.append(TextComponent.builder("Velocity GitHub")
|
.append(Component.text().content("Velocity GitHub")
|
||||||
.color(NamedTextColor.GREEN)
|
.color(NamedTextColor.GREEN)
|
||||||
.clickEvent(ClickEvent.openUrl(
|
.clickEvent(ClickEvent.openUrl(
|
||||||
"https://github.com/VelocityPowered/Velocity"))
|
"https://github.com/VelocityPowered/Velocity"))
|
||||||
@ -226,7 +227,7 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource source, String @NonNull [] args) {
|
public void execute(CommandSource source, String @NonNull [] args) {
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
source.sendMessage(TextComponent.of("/velocity plugins", NamedTextColor.RED));
|
source.sendMessage(Component.text("/velocity plugins", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,17 +235,17 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
int pluginCount = plugins.size();
|
int pluginCount = plugins.size();
|
||||||
|
|
||||||
if (pluginCount == 0) {
|
if (pluginCount == 0) {
|
||||||
source.sendMessage(TextComponent.of("No plugins installed.", NamedTextColor.YELLOW));
|
source.sendMessage(Component.text("No plugins installed.", NamedTextColor.YELLOW));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextComponent.Builder output = TextComponent.builder("Plugins: ")
|
TextComponent.Builder output = Component.text().content("Plugins: ")
|
||||||
.color(NamedTextColor.YELLOW);
|
.color(NamedTextColor.YELLOW);
|
||||||
for (int i = 0; i < pluginCount; i++) {
|
for (int i = 0; i < pluginCount; i++) {
|
||||||
PluginContainer plugin = plugins.get(i);
|
PluginContainer plugin = plugins.get(i);
|
||||||
output.append(componentForPlugin(plugin.getDescription()));
|
output.append(componentForPlugin(plugin.getDescription()));
|
||||||
if (i + 1 < pluginCount) {
|
if (i + 1 < pluginCount) {
|
||||||
output.append(TextComponent.of(", "));
|
output.append(Component.text(", "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,28 +256,28 @@ public class VelocityCommand implements SimpleCommand {
|
|||||||
String pluginInfo = description.getName().orElse(description.getId())
|
String pluginInfo = description.getName().orElse(description.getId())
|
||||||
+ description.getVersion().map(v -> " " + v).orElse("");
|
+ description.getVersion().map(v -> " " + v).orElse("");
|
||||||
|
|
||||||
TextComponent.Builder hoverText = TextComponent.builder(pluginInfo);
|
TextComponent.Builder hoverText = Component.text().content(pluginInfo);
|
||||||
|
|
||||||
description.getUrl().ifPresent(url -> {
|
description.getUrl().ifPresent(url -> {
|
||||||
hoverText.append(TextComponent.newline());
|
hoverText.append(Component.newline());
|
||||||
hoverText.append(TextComponent.of("Website: " + url));
|
hoverText.append(Component.text("Website: " + url));
|
||||||
});
|
});
|
||||||
if (!description.getAuthors().isEmpty()) {
|
if (!description.getAuthors().isEmpty()) {
|
||||||
hoverText.append(TextComponent.newline());
|
hoverText.append(Component.newline());
|
||||||
if (description.getAuthors().size() == 1) {
|
if (description.getAuthors().size() == 1) {
|
||||||
hoverText.append(TextComponent.of("Author: " + description.getAuthors().get(0)));
|
hoverText.append(Component.text("Author: " + description.getAuthors().get(0)));
|
||||||
} else {
|
} else {
|
||||||
hoverText.append(TextComponent.of("Authors: " + Joiner.on(", ")
|
hoverText.append(Component.text("Authors: " + Joiner.on(", ")
|
||||||
.join(description.getAuthors())));
|
.join(description.getAuthors())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
description.getDescription().ifPresent(pdesc -> {
|
description.getDescription().ifPresent(pdesc -> {
|
||||||
hoverText.append(TextComponent.newline());
|
hoverText.append(Component.newline());
|
||||||
hoverText.append(TextComponent.newline());
|
hoverText.append(Component.newline());
|
||||||
hoverText.append(TextComponent.of(pdesc));
|
hoverText.append(Component.text(pdesc));
|
||||||
});
|
});
|
||||||
|
|
||||||
return TextComponent.of(description.getId(), NamedTextColor.GRAY)
|
return Component.text(description.getId(), NamedTextColor.GRAY)
|
||||||
.hoverEvent(HoverEvent.showText(hoverText.build()));
|
.hoverEvent(HoverEvent.showText(hoverText.build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,12 +26,13 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import javax.crypto.Mac;
|
import javax.crypto.Mac;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
|
||||||
public class LoginSessionHandler implements MinecraftSessionHandler {
|
public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||||
|
|
||||||
private static final TextComponent MODERN_IP_FORWARDING_FAILURE = TextComponent
|
private static final TextComponent MODERN_IP_FORWARDING_FAILURE = Component
|
||||||
.of("Your server did not send a forwarding request to the proxy. Is it set up correctly?");
|
.text("Your server did not send a forwarding request to the proxy. Is it set up correctly?");
|
||||||
|
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
private final VelocityServerConnection serverConn;
|
private final VelocityServerConnection serverConn;
|
||||||
|
@ -43,7 +43,7 @@ import java.util.Optional;
|
|||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@ -138,7 +138,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
logger.info("Exception occurred while running command for {}",
|
logger.info("Exception occurred while running command for {}",
|
||||||
player.getUsername(), e);
|
player.getUsername(), e);
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TextComponent.of("An error occurred while running this command.",
|
Component.text("An error occurred while running this command.",
|
||||||
NamedTextColor.RED));
|
NamedTextColor.RED));
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -504,7 +504,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
userMessage = "Unable to connect to " + server.getServerInfo().getName() + ". Try again "
|
userMessage = "Unable to connect to " + server.getServerInfo().getName() + ". Try again "
|
||||||
+ "later.";
|
+ "later.";
|
||||||
}
|
}
|
||||||
handleConnectionException(server, null, TextComponent.of(userMessage,
|
handleConnectionException(server, null, Component.text(userMessage,
|
||||||
NamedTextColor.RED), safe);
|
NamedTextColor.RED), safe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
if (connectedServer != null && connectedServer.getServerInfo().equals(server.getServerInfo())) {
|
if (connectedServer != null && connectedServer.getServerInfo().equals(server.getServerInfo())) {
|
||||||
logger.error("{}: kicked from server {}: {}", this, server.getServerInfo().getName(),
|
logger.error("{}: kicked from server {}: {}", this, server.getServerInfo().getName(),
|
||||||
plainTextReason);
|
plainTextReason);
|
||||||
handleConnectionException(server, disconnectReason, TextComponent.builder()
|
handleConnectionException(server, disconnectReason, Component.text()
|
||||||
.append(messages.getKickPrefix(server.getServerInfo().getName()))
|
.append(messages.getKickPrefix(server.getServerInfo().getName()))
|
||||||
.color(NamedTextColor.RED)
|
.color(NamedTextColor.RED)
|
||||||
.append(disconnectReason)
|
.append(disconnectReason)
|
||||||
@ -535,7 +535,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
} else {
|
} else {
|
||||||
logger.error("{}: disconnected while connecting to {}: {}", this,
|
logger.error("{}: disconnected while connecting to {}: {}", this,
|
||||||
server.getServerInfo().getName(), plainTextReason);
|
server.getServerInfo().getName(), plainTextReason);
|
||||||
handleConnectionException(server, disconnectReason, TextComponent.builder()
|
handleConnectionException(server, disconnectReason, Component.text()
|
||||||
.append(messages.getDisconnectPrefix(server.getServerInfo().getName()))
|
.append(messages.getDisconnectPrefix(server.getServerInfo().getName()))
|
||||||
.color(NamedTextColor.RED)
|
.color(NamedTextColor.RED)
|
||||||
.append(disconnectReason)
|
.append(disconnectReason)
|
||||||
|
@ -22,6 +22,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.TranslatableComponent;
|
import net.kyori.adventure.text.TranslatableComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
@ -54,7 +55,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(LegacyHandshake packet) {
|
public boolean handle(LegacyHandshake packet) {
|
||||||
connection.closeWith(LegacyDisconnect
|
connection.closeWith(LegacyDisconnect
|
||||||
.from(TextComponent.of("Your client is old, please upgrade!", NamedTextColor.RED)));
|
.from(Component.text("Your client is old, please upgrade!", NamedTextColor.RED)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,13 +101,13 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
private void handleLogin(Handshake handshake, InitialInboundConnection ic) {
|
private void handleLogin(Handshake handshake, InitialInboundConnection ic) {
|
||||||
if (!ProtocolVersion.isSupported(handshake.getProtocolVersion())) {
|
if (!ProtocolVersion.isSupported(handshake.getProtocolVersion())) {
|
||||||
ic.disconnectQuietly(TranslatableComponent.of("multiplayer.disconnect.outdated_client"));
|
ic.disconnectQuietly(Component.translatable("multiplayer.disconnect.outdated_client"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InetAddress address = ((InetSocketAddress) connection.getRemoteAddress()).getAddress();
|
InetAddress address = ((InetSocketAddress) connection.getRemoteAddress()).getAddress();
|
||||||
if (!server.getIpAttemptLimiter().attempt(address)) {
|
if (!server.getIpAttemptLimiter().attempt(address)) {
|
||||||
ic.disconnectQuietly(TextComponent.of("You are logging in too fast, try again later."));
|
ic.disconnectQuietly(Component.text("You are logging in too fast, try again later."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +117,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
// and lower, otherwise IP information will never get forwarded.
|
// and lower, otherwise IP information will never get forwarded.
|
||||||
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
|
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
|
||||||
&& handshake.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0) {
|
&& handshake.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0) {
|
||||||
ic.disconnectQuietly(TextComponent.of("This server is only compatible with 1.13 and above."));
|
ic.disconnectQuietly(Component.text("This server is only compatible with 1.13 and above."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package com.velocitypowered.proxy.connection.util;
|
package com.velocitypowered.proxy.connection.util;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
public class ConnectionMessages {
|
public class ConnectionMessages {
|
||||||
|
|
||||||
public static final TextComponent ALREADY_CONNECTED = TextComponent
|
public static final TextComponent ALREADY_CONNECTED = Component
|
||||||
.of("You are already connected to this server!", NamedTextColor.RED);
|
.text("You are already connected to this server!", NamedTextColor.RED);
|
||||||
public static final TextComponent IN_PROGRESS = TextComponent
|
public static final TextComponent IN_PROGRESS = Component
|
||||||
.of("You are already connecting to a server!", NamedTextColor.RED);
|
.text("You are already connecting to a server!", NamedTextColor.RED);
|
||||||
public static final TextComponent INTERNAL_SERVER_CONNECTION_ERROR = TextComponent
|
public static final TextComponent INTERNAL_SERVER_CONNECTION_ERROR = Component
|
||||||
.of("An internal server connection error occurred.", NamedTextColor.RED);
|
.text("An internal server connection error occurred.", NamedTextColor.RED);
|
||||||
|
|
||||||
private ConnectionMessages() {
|
private ConnectionMessages() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
|
@ -31,7 +31,7 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Key legacyIdToFakeKey(byte id) {
|
private static Key legacyIdToFakeKey(byte id) {
|
||||||
return Key.of("velocity", "legacy_hover/id_" + id);
|
return Key.key("velocity", "legacy_hover/id_" + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -45,7 +45,7 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria
|
|||||||
if (idIfString.isEmpty()) {
|
if (idIfString.isEmpty()) {
|
||||||
key = legacyIdToFakeKey(item.getByte("id"));
|
key = legacyIdToFakeKey(item.getByte("id"));
|
||||||
} else {
|
} else {
|
||||||
key = Key.of(idIfString);
|
key = Key.key(idIfString);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte count = item.getByte("Count", (byte) 1);
|
byte count = item.getByte("Count", (byte) 1);
|
||||||
@ -62,10 +62,10 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria
|
|||||||
try {
|
try {
|
||||||
name = componentDecoder.decode(item.getString("name"));
|
name = componentDecoder.decode(item.getString("name"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
name = TextComponent.of(item.getString("name"));
|
name = Component.text(item.getString("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ShowEntity.of(Key.of(item.getString("type")),
|
return ShowEntity.of(Key.key(item.getString("type")),
|
||||||
UUID.fromString(item.getString("id")),
|
UUID.fromString(item.getString("id")),
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria
|
|||||||
builder.put("tag", TagStringIO.get().asCompound(nbt.string()));
|
builder.put("tag", TagStringIO.get().asCompound(nbt.string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TextComponent.of(TagStringIO.get().asString(builder.build()));
|
return Component.text(TagStringIO.get().asString(builder.build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -102,6 +102,6 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria
|
|||||||
if (name != null) {
|
if (name != null) {
|
||||||
tag.putString("name", componentEncoder.encode(name));
|
tag.putString("name", componentEncoder.encode(name));
|
||||||
}
|
}
|
||||||
return TextComponent.of(TagStringIO.get().asString(tag.build()));
|
return Component.text(TagStringIO.get().asString(tag.build()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren