From 95cd4c407d10396c6226d1fcf88d80a52c3ecd56 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 29 Oct 2023 14:52:54 -0400 Subject: [PATCH] Rename more fields to eliminate prefixes --- .../api/proxy/ProxyServer.java | 30 +++++++------- .../api/proxy/config/ProxyConfig.java | 2 +- .../com/velocitypowered/proxy/Metrics.java | 8 ++-- .../com/velocitypowered/proxy/Velocity.java | 2 +- .../velocitypowered/proxy/VelocityServer.java | 40 +++++++++---------- .../command/builtin/BuiltinCommandUtil.java | 2 +- .../proxy/command/builtin/GlistCommand.java | 8 ++-- .../proxy/command/builtin/SendCommand.java | 23 ++++++----- .../proxy/command/builtin/ServerCommand.java | 4 +- .../command/builtin/ShutdownCommand.java | 2 +- .../command/builtin/VelocityCommand.java | 14 +++---- .../proxy/connection/MinecraftConnection.java | 6 +-- .../backend/BackendPlaySessionHandler.java | 20 +++++----- .../backend/BungeeCordMessageResponder.java | 34 ++++++++-------- .../backend/ConfigSessionHandler.java | 4 +- .../backend/LoginSessionHandler.java | 10 ++--- .../backend/TransitionSessionHandler.java | 4 +- .../backend/VelocityServerConnection.java | 4 +- .../connection/client/AuthSessionHandler.java | 20 +++++----- .../client/ClientConfigSessionHandler.java | 2 +- .../client/ClientPlaySessionHandler.java | 22 +++++----- .../connection/client/ConnectedPlayer.java | 24 +++++------ .../client/HandshakeSessionHandler.java | 4 +- .../client/InitialConnectSessionHandler.java | 4 +- .../client/InitialInboundConnection.java | 2 +- .../client/InitialLoginSessionHandler.java | 8 ++-- .../client/StatusSessionHandler.java | 2 +- .../util/ServerListPingHandler.java | 14 +++---- .../proxy/console/VelocityConsole.java | 6 +-- .../proxy/network/ConnectionManager.java | 16 ++++---- .../BackendChannelInitializer.java | 2 +- .../ServerChannelInitializer.java | 4 +- .../pipeline/query/GameSpyQueryHandler.java | 20 +++++----- .../protocol/packet/chat/CommandHandler.java | 6 +-- .../packet/chat/keyed/KeyedChatHandler.java | 2 +- .../packet/chat/legacy/LegacyChatHandler.java | 2 +- .../chat/session/SessionChatHandler.java | 2 +- .../proxy/plugin/VelocityPluginManager.java | 6 +-- .../server/VelocityRegisteredServer.java | 2 +- .../proxy/tablist/KeyedVelocityTabList.java | 2 +- .../proxy/util/InformationUtils.java | 2 +- 41 files changed, 196 insertions(+), 195 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java b/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java index 406cf5744d..7a432913c6 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java @@ -54,7 +54,7 @@ public interface ProxyServer extends Audience { * @param username the username to search for * @return an {@link Optional} with the player, which may be empty */ - Optional getPlayer(String username); + Optional player(String username); /** * Retrieves the player currently connected to this proxy by their Minecraft UUID. @@ -62,7 +62,7 @@ public interface ProxyServer extends Audience { * @param uuid the UUID * @return an {@link Optional} with the player, which may be empty */ - Optional getPlayer(UUID uuid); + Optional player(UUID uuid); /** * Retrieves all players currently connected to this proxy. This call may or may not be a snapshot @@ -70,14 +70,14 @@ public interface ProxyServer extends Audience { * * @return the players online on this proxy */ - Collection getAllPlayers(); + Collection onlinePlayers(); /** * Returns the number of players currently connected to this proxy. * * @return the players on this proxy */ - int getPlayerCount(); + int onlinePlayerCount(); /** * Retrieves a registered {@link RegisteredServer} instance by its name. The search is @@ -86,14 +86,14 @@ public interface ProxyServer extends Audience { * @param name the name of the server * @return the registered server, which may be empty */ - Optional getServer(String name); + Optional server(String name); /** * Retrieves all {@link RegisteredServer}s registered with this proxy. * * @return the servers registered with this proxy */ - Collection getAllServers(); + Collection registeredServers(); /** * Matches all {@link Player}s whose names start with the provided partial name. @@ -142,42 +142,42 @@ public interface ProxyServer extends Audience { * * @return the console command invoker */ - ConsoleCommandSource getConsoleCommandSource(); + ConsoleCommandSource console(); /** * Gets the {@link PluginManager} instance. * * @return the plugin manager instance */ - PluginManager getPluginManager(); + PluginManager pluginManager(); /** * Gets the {@link EventManager} instance. * * @return the event manager instance */ - EventManager getEventManager(); + EventManager eventManager(); /** * Gets the {@link CommandManager} instance. * * @return the command manager */ - CommandManager getCommandManager(); + CommandManager commandManager(); /** * Gets the {@link Scheduler} instance. * * @return the scheduler instance */ - Scheduler getScheduler(); + Scheduler scheduler(); /** * Gets the {@link ChannelRegistrar} instance. * * @return the channel registrar */ - ChannelRegistrar getChannelRegistrar(); + ChannelRegistrar channelRegistrar(); /** * Gets the address that this proxy is bound to. This does not necessarily indicate the external @@ -185,21 +185,21 @@ public interface ProxyServer extends Audience { * * @return the address the proxy is bound to */ - SocketAddress getBoundAddress(); + SocketAddress boundAddress(); /** * Gets the {@link ProxyConfig} instance. * * @return the proxy config */ - ProxyConfig getConfiguration(); + ProxyConfig configuration(); /** * Returns the version of the proxy. * * @return the proxy version */ - ProxyVersion getVersion(); + ProxyVersion version(); /** * Creates a builder to build a {@link ResourcePackInfo} instance for use with diff --git a/api/src/main/java/com/velocitypowered/api/proxy/config/ProxyConfig.java b/api/src/main/java/com/velocitypowered/api/proxy/config/ProxyConfig.java index 462f1310d9..eae807eba2 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/config/ProxyConfig.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/config/ProxyConfig.java @@ -81,7 +81,7 @@ public interface ProxyConfig { /** * Get a Map of all servers registered in velocity.toml. This method does * not return all the servers currently in memory, although in most cases it - * does. For a view of all registered servers, see {@link ProxyServer#getAllServers()}. + * does. For a view of all registered servers, see {@link ProxyServer#registeredServers()}. * * @return registered servers map */ diff --git a/proxy/src/main/java/com/velocitypowered/proxy/Metrics.java b/proxy/src/main/java/com/velocitypowered/proxy/Metrics.java index 50108f8eef..9cf278520c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/Metrics.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/Metrics.java @@ -106,17 +106,17 @@ static void startMetrics(VelocityServer server, VelocityConfiguration.Metrics me Metrics metrics = new Metrics(logger, 4752, metricsConfig.isEnabled()); metrics.addCustomChart( - new SingleLineChart("players", server::getPlayerCount) + new SingleLineChart("players", server::onlinePlayerCount) ); metrics.addCustomChart( - new SingleLineChart("managed_servers", () -> server.getAllServers().size()) + new SingleLineChart("managed_servers", () -> server.registeredServers().size()) ); metrics.addCustomChart( new SimplePie("online_mode", - () -> server.getConfiguration().isOnlineMode() ? "online" : "offline") + () -> server.configuration().isOnlineMode() ? "online" : "offline") ); metrics.addCustomChart(new SimplePie("velocity_version", - () -> server.getVersion().version())); + () -> server.version().version())); metrics.addCustomChart(new DrilldownPie("java_version", () -> { Map> map = new HashMap<>(); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java index 779879eebc..4febf19eaa 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java @@ -72,7 +72,7 @@ public static void main(String... args) { double bootTime = (System.currentTimeMillis() - startTime) / 1000d; logger.info("Done ({}s)!", new DecimalFormat("#.##").format(bootTime)); - server.getConsoleCommandSource().start(); + server.console().start(); // If we don't have a console available (because SimpleTerminalConsole returned), then we still // need to wait, otherwise the JVM will reap us as no non-daemon threads will be active once the diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 709215a364..1eb387c688 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -166,12 +166,12 @@ public KeyPair getServerKeyPair() { } @Override - public VelocityConfiguration getConfiguration() { + public VelocityConfiguration configuration() { return this.configuration; } @Override - public ProxyVersion getVersion() { + public ProxyVersion version() { Package pkg = VelocityServer.class.getPackage(); String implName; String implVersion; @@ -190,7 +190,7 @@ public ProxyVersion getVersion() { } @Override - public VelocityCommandManager getCommandManager() { + public VelocityCommandManager commandManager() { return commandManager; } @@ -201,7 +201,7 @@ void awaitProxyShutdown() { @EnsuresNonNull({"serverKeyPair", "servers", "pluginManager", "eventManager", "scheduler", "console", "cm", "configuration"}) void start() { - logger.info("Booting up {} {}...", getVersion().name(), getVersion().version()); + logger.info("Booting up {} {}...", version().name(), version().version()); console.setupStreams(); registerTranslations(); @@ -640,13 +640,13 @@ public void unregisterConnection(ConnectedPlayer connection) { } @Override - public Optional getPlayer(String username) { + public Optional player(String username) { Preconditions.checkNotNull(username, "username"); return Optional.ofNullable(connectionsByName.get(username.toLowerCase(Locale.US))); } @Override - public Optional getPlayer(UUID uuid) { + public Optional player(UUID uuid) { Preconditions.checkNotNull(uuid, "uuid"); return Optional.ofNullable(connectionsByUuid.get(uuid)); } @@ -655,7 +655,7 @@ public Optional getPlayer(UUID uuid) { public Collection matchPlayer(String partialName) { Objects.requireNonNull(partialName); - return getAllPlayers().stream().filter(p -> p.username() + return onlinePlayers().stream().filter(p -> p.username() .regionMatches(true, 0, partialName, 0, partialName.length())) .collect(Collectors.toList()); } @@ -664,28 +664,28 @@ public Collection matchPlayer(String partialName) { public Collection matchServer(String partialName) { Objects.requireNonNull(partialName); - return getAllServers().stream().filter(s -> s.serverInfo().name() + return registeredServers().stream().filter(s -> s.serverInfo().name() .regionMatches(true, 0, partialName, 0, partialName.length())) .collect(Collectors.toList()); } @Override - public Collection getAllPlayers() { + public Collection onlinePlayers() { return ImmutableList.copyOf(connectionsByUuid.values()); } @Override - public int getPlayerCount() { + public int onlinePlayerCount() { return connectionsByUuid.size(); } @Override - public Optional getServer(String name) { + public Optional server(String name) { return servers.getServer(name); } @Override - public Collection getAllServers() { + public Collection registeredServers() { return servers.getAllServers(); } @@ -705,32 +705,32 @@ public void unregisterServer(ServerInfo server) { } @Override - public VelocityConsole getConsoleCommandSource() { + public VelocityConsole console() { return console; } @Override - public PluginManager getPluginManager() { + public PluginManager pluginManager() { return pluginManager; } @Override - public VelocityEventManager getEventManager() { + public VelocityEventManager eventManager() { return eventManager; } @Override - public VelocityScheduler getScheduler() { + public VelocityScheduler scheduler() { return scheduler; } @Override - public VelocityChannelRegistrar getChannelRegistrar() { + public VelocityChannelRegistrar channelRegistrar() { return channelRegistrar; } @Override - public SocketAddress getBoundAddress() { + public SocketAddress boundAddress() { if (configuration == null) { throw new IllegalStateException( "No configuration"); // even though you'll never get the chance... heh, heh @@ -740,9 +740,9 @@ public SocketAddress getBoundAddress() { @Override public @NonNull Iterable audiences() { - Collection audiences = new ArrayList<>(this.getPlayerCount() + 1); + Collection audiences = new ArrayList<>(this.onlinePlayerCount() + 1); audiences.add(this.console); - audiences.addAll(this.getAllPlayers()); + audiences.addAll(this.onlinePlayers()); return audiences; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/BuiltinCommandUtil.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/BuiltinCommandUtil.java index e956881f4e..ace9751ee1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/BuiltinCommandUtil.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/BuiltinCommandUtil.java @@ -31,7 +31,7 @@ private BuiltinCommandUtil() { } static List sortedServerList(ProxyServer proxy) { - List servers = new ArrayList<>(proxy.getAllServers()); + List servers = new ArrayList<>(proxy.registeredServers()); servers.sort(Comparator.comparing(RegisteredServer::serverInfo)); return Collections.unmodifiableList(servers); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java index de5b0a9fed..2fc53da7d1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/GlistCommand.java @@ -66,7 +66,7 @@ public void register() { ArgumentCommandNode serverNode = RequiredArgumentBuilder .argument(SERVER_ARG, StringArgumentType.string()) .suggests((context, builder) -> { - for (RegisteredServer server : server.getAllServers()) { + for (RegisteredServer server : server.registeredServers()) { builder.suggest(server.serverInfo().name()); } builder.suggest("all"); @@ -75,7 +75,7 @@ public void register() { .executes(this::serverCount) .build(); totalNode.addChild(serverNode); - server.getCommandManager().register(new BrigadierCommand(totalNode)); + server.commandManager().register(new BrigadierCommand(totalNode)); } private int totalCount(final CommandContext context) { @@ -95,7 +95,7 @@ private int serverCount(final CommandContext context) { } sendTotalProxyCount(source); } else { - Optional registeredServer = server.getServer(serverName); + Optional registeredServer = server.server(serverName); if (!registeredServer.isPresent()) { source.sendMessage(Identity.nil(), CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(serverName))); @@ -107,7 +107,7 @@ private int serverCount(final CommandContext context) { } private void sendTotalProxyCount(CommandSource target) { - int online = server.getPlayerCount(); + int online = server.onlinePlayerCount(); TranslatableComponent msg = online == 1 ? Component.translatable("velocity.command.glist-player-singular") : Component.translatable("velocity.command.glist-player-plural"); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/SendCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/SendCommand.java index 81b562bf35..94c14085a0 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/SendCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/SendCommand.java @@ -83,7 +83,7 @@ public void register() { ArgumentCommandNode serverNode = RequiredArgumentBuilder .argument("server", StringArgumentType.word()) .suggests((context, builder) -> { - for (RegisteredServer server : server.getAllServers()) { + for (RegisteredServer server : server.registeredServers()) { builder.suggest(server.serverInfo().name()); } return builder.buildFuture(); @@ -92,7 +92,7 @@ public void register() { .build(); totalNode.addChild(playerNode); playerNode.addChild(serverNode); - server.getCommandManager().register(new BrigadierCommand(totalNode)); + server.commandManager().register(new BrigadierCommand(totalNode)); } private int usage(CommandContext context) { @@ -106,15 +106,18 @@ private int send(CommandContext context) { String serverName = context.getArgument(SERVER_ARG, String.class); String player = context.getArgument(PLAYER_ARG, String.class); - if (server.getServer(serverName).isEmpty()) { + Optional maybeServer = server.server(serverName); + + if (maybeServer.isEmpty()) { context.getSource().sendMessage( CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(serverName)) ); return 0; } - if (server.getPlayer(player).isEmpty() - && !Objects.equals(player, "all") && !Objects.equals(player, "current")) { + if (server.player(player).isEmpty() + && !Objects.equals(player, "all") + && !Objects.equals(player, "current")) { context.getSource().sendMessage( CommandMessages.PLAYER_NOT_FOUND.args(Component.text(player)) ); @@ -122,8 +125,8 @@ private int send(CommandContext context) { } if (Objects.equals(player, "all")) { - for (Player p : server.getAllPlayers()) { - p.createConnectionRequest(server.getServer(serverName).get()).fireAndForget(); + for (Player p : server.onlinePlayers()) { + p.createConnectionRequest(server.server(serverName).get()).fireAndForget(); } return 1; } @@ -138,16 +141,14 @@ private int send(CommandContext context) { Optional connectedServer = source.connectedServer(); if (connectedServer.isPresent()) { for (Player p : connectedServer.get().server().players()) { - p.createConnectionRequest(server.getServer(serverName).get()).fireAndForget(); + p.createConnectionRequest(maybeServer.get()).fireAndForget(); } return 1; } return 0; } - server.getPlayer(player).get().createConnectionRequest( - server.getServer(serverName).get() - ).fireAndForget(); + server.player(player).get().createConnectionRequest(maybeServer.get()).fireAndForget(); return 1; } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java index 948db41e28..e12712c954 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java @@ -64,7 +64,7 @@ public void execute(final SimpleCommand.Invocation invocation) { if (args.length == 1) { // Trying to connect to a server. String serverName = args[0]; - Optional toConnect = server.getServer(serverName); + Optional toConnect = server.server(serverName); if (toConnect.isEmpty()) { player.sendMessage(CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(serverName))); return; @@ -145,7 +145,7 @@ private TextComponent formatServerComponent(String currentPlayerServer, Register @Override public List suggest(final SimpleCommand.Invocation invocation) { final String[] currentArgs = invocation.arguments(); - Stream possibilities = server.getAllServers().stream() + Stream possibilities = server.registeredServers().stream() .map(rs -> rs.serverInfo().name()); if (currentArgs.length == 0) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ShutdownCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ShutdownCommand.java index cb9e44f81a..c177ab577d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ShutdownCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ShutdownCommand.java @@ -43,7 +43,7 @@ private ShutdownCommand() { */ public static BrigadierCommand command(final VelocityServer server) { return new BrigadierCommand(LiteralArgumentBuilder.literal("shutdown") - .requires(source -> source == server.getConsoleCommandSource()) + .requires(source -> source == server.console()) .executes(context -> { server.shutdown(true); return Command.SINGLE_SUCCESS; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java index 47fd583938..a7d7c85a1f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/VelocityCommand.java @@ -220,7 +220,7 @@ public void execute(CommandSource source, String @NonNull [] args) { return; } - ProxyVersion version = server.getVersion(); + ProxyVersion version = server.version(); Component velocity = Component.text().content(version.name() + " ") .decoration(TextDecoration.BOLD, true) @@ -274,7 +274,7 @@ public void execute(CommandSource source, String @NonNull [] args) { return; } - List plugins = ImmutableList.copyOf(server.getPluginManager().plugins()); + List plugins = ImmutableList.copyOf(server.pluginManager().plugins()); int pluginCount = plugins.size(); if (pluginCount == 0) { @@ -356,7 +356,7 @@ public void execute(CommandSource source, String @NonNull [] args) { return; } - Collection allServers = ImmutableSet.copyOf(server.getAllServers()); + Collection allServers = ImmutableSet.copyOf(server.registeredServers()); JsonObject servers = new JsonObject(); for (RegisteredServer iter : allServers) { servers.add(iter.serverInfo().name(), @@ -364,19 +364,19 @@ public void execute(CommandSource source, String @NonNull [] args) { } JsonArray connectOrder = new JsonArray(); List attemptedConnectionOrder = ImmutableList.copyOf( - server.getConfiguration().getAttemptConnectionOrder()); + server.configuration().getAttemptConnectionOrder()); for (String s : attemptedConnectionOrder) { connectOrder.add(s); } - JsonObject proxyConfig = InformationUtils.collectProxyConfig(server.getConfiguration()); + JsonObject proxyConfig = InformationUtils.collectProxyConfig(server.configuration()); proxyConfig.add("servers", servers); proxyConfig.add("connectOrder", connectOrder); proxyConfig.add("forcedHosts", - InformationUtils.collectForcedHosts(server.getConfiguration())); + InformationUtils.collectForcedHosts(server.configuration())); JsonObject dump = new JsonObject(); - dump.add("versionInfo", InformationUtils.collectProxyInfo(server.getVersion())); + dump.add("versionInfo", InformationUtils.collectProxyInfo(server.version())); dump.add("platform", InformationUtils.collectEnvironmentInfo()); dump.add("config", proxyConfig); dump.add("plugins", InformationUtils.collectPluginInfo(server)); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java index 875d2adef0..0061a7753e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -113,7 +113,7 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception { activeSessionHandler.connected(); } - if (association != null && server.getConfiguration().isLogPlayerConnections()) { + if (association != null && server.configuration().isLogPlayerConnections()) { logger.info("{} has connected", association); } } @@ -126,7 +126,7 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception { if (association != null && !knownDisconnect && !(activeSessionHandler instanceof StatusSessionHandler) - && server.getConfiguration().isLogPlayerConnections()) { + && server.configuration().isLogPlayerConnections()) { logger.info("{} has disconnected", association); } } @@ -514,7 +514,7 @@ public void setCompressionThreshold(int threshold) { decoder.setThreshold(threshold); encoder.setThreshold(threshold); } else { - int level = server.getConfiguration().getCompressionLevel(); + int level = server.configuration().getCompressionLevel(); VelocityCompressor compressor = Natives.compress.get().create(level); encoder = new MinecraftCompressorAndLengthEncoder(threshold, compressor); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index 90efef5c1e..351562532a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -106,7 +106,7 @@ public void activated() { serverConn.server().addPlayer(serverConn.player()); MinecraftConnection serverMc = serverConn.ensureConnected(); - if (server.getConfiguration().isBungeePluginChannelEnabled()) { + if (server.configuration().isBungeePluginChannelEnabled()) { serverMc.write(PluginMessageUtil.constructChannelsPacket(serverMc.getProtocolVersion(), ImmutableList.of(getBungeeCordChannel(serverMc.getProtocolVersion())) )); @@ -181,7 +181,7 @@ public boolean handle(ResourcePackRequest packet) { ServerResourcePackSendEvent event = new ServerResourcePackSendEvent( builder.build(), this.serverConn); - server.getEventManager().fire(event).thenAcceptAsync(serverResourcePackSendEvent -> { + server.eventManager().fire(event).thenAcceptAsync(serverResourcePackSendEvent -> { if (playerConnection.isClosed()) { return; } @@ -225,7 +225,7 @@ public boolean handle(PluginMessage packet) { } if (PluginMessageUtil.isMcBrand(packet)) { - PluginMessage rewritten = PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(), + PluginMessage rewritten = PluginMessageUtil.rewriteMinecraftBrand(packet, server.version(), playerConnection.getProtocolVersion()); playerConnection.write(rewritten); return true; @@ -236,14 +236,14 @@ public boolean handle(PluginMessage packet) { return true; } - ChannelIdentifier id = server.getChannelRegistrar().getFromId(packet.getChannel()); + ChannelIdentifier id = server.channelRegistrar().getFromId(packet.getChannel()); if (id == null) { return false; } byte[] copy = ByteBufUtil.getBytes(packet.content()); PluginMessageEvent event = new PluginMessageEvent(serverConn, serverConn.player(), id, copy); - server.getEventManager().fire(event).thenAcceptAsync(pme -> { + server.eventManager().fire(event).thenAcceptAsync(pme -> { if (pme.result().allowed() && !playerConnection.isClosed()) { PluginMessage copied = new PluginMessage(packet.getChannel(), Unpooled.wrappedBuffer(copy)); playerConnection.write(copied); @@ -282,13 +282,13 @@ public boolean handle(RemovePlayerInfo packet) { @Override public boolean handle(AvailableCommands commands) { RootCommandNode rootNode = commands.getRootNode(); - if (server.getConfiguration().isAnnounceProxyCommands()) { + if (server.configuration().isAnnounceProxyCommands()) { // Inject commands from the proxy. - final CommandGraphInjector injector = server.getCommandManager().getInjector(); + final CommandGraphInjector injector = server.commandManager().getInjector(); injector.inject(rootNode, serverConn.player()); } - server.getEventManager().fire( + server.eventManager().fire( new PlayerAvailableCommandsEvent(serverConn.player(), rootNode)) .thenAcceptAsync(event -> playerConnection.write(commands), playerConnection.eventLoop()) .exceptionally((ex) -> { @@ -301,7 +301,7 @@ public boolean handle(AvailableCommands commands) { @Override public boolean handle(ServerData packet) { server.getServerListPingHandler().getInitialPing(this.serverConn.player()).thenComposeAsync( - ping -> server.getEventManager() + ping -> server.eventManager() .fire(new ProxyPingEvent(this.serverConn.player(), ping)), playerConnection.eventLoop()).thenAcceptAsync(pingEvent -> this.playerConnection.write( new ServerData(pingEvent.ping().description(), @@ -352,7 +352,7 @@ public VelocityServer getServer() { public void disconnected() { serverConn.server().removePlayer(serverConn.player()); if (!serverConn.isGracefulDisconnect() && !exceptionTriggered) { - if (server.getConfiguration().isFailoverOnUnexpectedServerDisconnect()) { + if (server.configuration().isFailoverOnUnexpectedServerDisconnect()) { serverConn.player().handleConnectionException(serverConn.server(), Disconnect.create(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR, ProtocolVersion.MINECRAFT_1_16), true); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java index 0d9cc5b1ea..8c2423566b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java @@ -78,7 +78,7 @@ public static boolean isBungeeCordMessage(PluginMessage message) { private void processConnect(ByteBufDataInput in) { String serverName = in.readUTF(); - proxy.getServer(serverName).ifPresent(server -> player.createConnectionRequest(server) + proxy.server(serverName).ifPresent(server -> player.createConnectionRequest(server) .fireAndForget()); } @@ -86,8 +86,8 @@ private void processConnectOther(ByteBufDataInput in) { String playerName = in.readUTF(); String serverName = in.readUTF(); - Optional referencedPlayer = proxy.getPlayer(playerName); - Optional referencedServer = proxy.getServer(serverName); + Optional referencedPlayer = proxy.player(playerName); + Optional referencedServer = proxy.server(serverName); if (referencedPlayer.isPresent() && referencedServer.isPresent()) { referencedPlayer.get().createConnectionRequest(referencedServer.get()).fireAndForget(); } @@ -118,9 +118,9 @@ private void processPlayerCount(ByteBufDataInput in) { if (target.equals("ALL")) { out.writeUTF("PlayerCount"); out.writeUTF("ALL"); - out.writeInt(proxy.getPlayerCount()); + out.writeInt(proxy.onlinePlayerCount()); } else { - proxy.getServer(target).ifPresent(rs -> { + proxy.server(target).ifPresent(rs -> { int playersOnServer = rs.players().size(); out.writeUTF("PlayerCount"); out.writeUTF(rs.serverInfo().name()); @@ -145,12 +145,12 @@ private void processPlayerList(ByteBufDataInput in) { out.writeUTF("ALL"); StringJoiner joiner = new StringJoiner(", "); - for (Player online : proxy.getAllPlayers()) { + for (Player online : proxy.onlinePlayers()) { joiner.add(online.username()); } out.writeUTF(joiner.toString()); } else { - proxy.getServer(target).ifPresent(info -> { + proxy.server(target).ifPresent(info -> { out.writeUTF("PlayerList"); out.writeUTF(info.serverInfo().name()); @@ -171,7 +171,7 @@ private void processPlayerList(ByteBufDataInput in) { private void processGetServers() { StringJoiner joiner = new StringJoiner(", "); - for (RegisteredServer server : proxy.getAllServers()) { + for (RegisteredServer server : proxy.registeredServers()) { joiner.add(server.serverInfo().name()); } @@ -200,7 +200,7 @@ private void processMessage0(ByteBufDataInput in, if (target.equals("ALL")) { proxy.sendMessage(Identity.nil(), messageComponent); } else { - proxy.getPlayer(target).ifPresent(player -> player.sendMessage(Identity.nil(), + proxy.player(target).ifPresent(player -> player.sendMessage(Identity.nil(), messageComponent)); } } @@ -226,7 +226,7 @@ private void processUuid() { } private void processUuidOther(ByteBufDataInput in) { - proxy.getPlayer(in.readUTF()).ifPresent(player -> { + proxy.player(in.readUTF()).ifPresent(player -> { ByteBuf buf = Unpooled.buffer(); ByteBufDataOutput out = new ByteBufDataOutput(buf); @@ -239,7 +239,7 @@ private void processUuidOther(ByteBufDataInput in) { } private void processIpOther(ByteBufDataInput in) { - proxy.getPlayer(in.readUTF()).ifPresent(player -> { + proxy.player(in.readUTF()).ifPresent(player -> { ByteBuf buf = Unpooled.buffer(); ByteBufDataOutput out = new ByteBufDataOutput(buf); @@ -260,7 +260,7 @@ private void processIpOther(ByteBufDataInput in) { } private void processServerIp(ByteBufDataInput in) { - proxy.getServer(in.readUTF()).ifPresent(info -> { + proxy.server(in.readUTF()).ifPresent(info -> { ByteBuf buf = Unpooled.buffer(); ByteBufDataOutput out = new ByteBufDataOutput(buf); @@ -281,14 +281,14 @@ private void processServerIp(ByteBufDataInput in) { } private void processKick(ByteBufDataInput in) { - proxy.getPlayer(in.readUTF()).ifPresent(player -> { + proxy.player(in.readUTF()).ifPresent(player -> { String kickReason = in.readUTF(); player.disconnect(LegacyComponentSerializer.legacySection().deserialize(kickReason)); }); } private void processForwardToPlayer(ByteBufDataInput in) { - Optional player = proxy.getPlayer(in.readUTF()); + Optional player = proxy.player(in.readUTF()); if (player.isPresent()) { ByteBuf toForward = in.unwrap().copy(); sendServerResponse((ConnectedPlayer) player.get(), toForward); @@ -302,7 +302,7 @@ private void processForwardToServer(ByteBufDataInput in) { .map(ServerConnection::serverInfo).orElse(null); if (target.equals("ALL") || target.equals("ONLINE")) { try { - for (RegisteredServer rs : proxy.getAllServers()) { + for (RegisteredServer rs : proxy.registeredServers()) { if (!rs.serverInfo().equals(currentUserServer)) { ((VelocityRegisteredServer) rs).sendPluginMessage(LEGACY_CHANNEL, toForward.retainedSlice()); @@ -312,7 +312,7 @@ private void processForwardToServer(ByteBufDataInput in) { toForward.release(); } } else { - Optional server = proxy.getServer(target); + Optional server = proxy.server(target); if (server.isPresent()) { ((VelocityRegisteredServer) server.get()).sendPluginMessage(LEGACY_CHANNEL, toForward); } else { @@ -340,7 +340,7 @@ private static void sendServerResponse(ConnectedPlayer player, ByteBuf buf) { } boolean process(PluginMessage message) { - if (!proxy.getConfiguration().isBungeePluginChannelEnabled()) { + if (!proxy.configuration().isBungeePluginChannelEnabled()) { return false; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java index 96a35a4f7e..5ceca080a1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java @@ -120,7 +120,7 @@ public boolean handle(ResourcePackRequest packet) { ServerResourcePackSendEvent event = new ServerResourcePackSendEvent(packet.toServerPromptedPack(), this.serverConn); - server.getEventManager().fire(event).thenAcceptAsync(serverResourcePackSendEvent -> { + server.eventManager().fire(event).thenAcceptAsync(serverResourcePackSendEvent -> { if (playerConnection.isClosed()) { return; } @@ -189,7 +189,7 @@ public boolean handle(Disconnect packet) { public boolean handle(PluginMessage packet) { if (PluginMessageUtil.isMcBrand(packet)) { serverConn.player().getConnection().write( - PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(), + PluginMessageUtil.rewriteMinecraftBrand(packet, server.version(), serverConn.player().protocolVersion())); } else { serverConn.player().getConnection().write(packet.retain()); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java index e22ba1080c..f9166d9a91 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java @@ -84,7 +84,7 @@ public boolean handle(EncryptionRequest packet) { @Override public boolean handle(LoginPluginMessage packet) { MinecraftConnection mc = serverConn.ensureConnected(); - VelocityConfiguration configuration = server.getConfiguration(); + VelocityConfiguration configuration = server.configuration(); if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && packet.getChannel().equals(VelocityConstants.VELOCITY_IP_FORWARDING_CHANNEL)) { @@ -102,7 +102,7 @@ public boolean handle(LoginPluginMessage packet) { informationForwarded = true; } else { // Don't understand, fire event if we have subscribers - if (!this.server.getEventManager().hasSubscribers(ServerLoginPluginMessageEvent.class)) { + if (!this.server.eventManager().hasSubscribers(ServerLoginPluginMessageEvent.class)) { mc.write(new LoginPluginResponse(packet.getId(), false, Unpooled.EMPTY_BUFFER)); return true; } @@ -110,7 +110,7 @@ public boolean handle(LoginPluginMessage packet) { final byte[] contents = ByteBufUtil.getBytes(packet.content()); final MinecraftChannelIdentifier identifier = MinecraftChannelIdentifier .from(packet.getChannel()); - this.server.getEventManager().fire(new ServerLoginPluginMessageEvent(serverConn, identifier, + this.server.eventManager().fire(new ServerLoginPluginMessageEvent(serverConn, identifier, contents, packet.getId())) .thenAcceptAsync(event -> { if (event.result().allowed()) { @@ -139,7 +139,7 @@ public boolean handle(SetCompression packet) { @Override public boolean handle(ServerLoginSuccess packet) { - if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN + if (server.configuration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && !informationForwarded) { resultFuture.complete(ConnectionRequestResults.forDisconnect(MODERN_IP_FORWARDING_FAILURE, serverConn.server())); @@ -182,7 +182,7 @@ public void exception(Throwable throwable) { @Override public void disconnected() { - if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.LEGACY) { + if (server.configuration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.LEGACY) { resultFuture.completeExceptionally(new QuietRuntimeException( "The connection to the remote server was unexpectedly closed.\n" + "This is usually because the remote server " diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java index 4239572a54..714460306c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java @@ -110,7 +110,7 @@ public boolean handle(JoinGame packet) { // The goods are in hand! We got JoinGame. Let's transition completely to the new state. smc.setAutoReading(false); - server.getEventManager() + server.eventManager() .fire(new ServerConnectedEvent(player, serverConn.server(), previousServer)) .thenRunAsync(() -> { // Make sure we can still transition (player might have disconnected here). @@ -151,7 +151,7 @@ public boolean handle(JoinGame packet) { } // We're done! :) - server.getEventManager().fireAndForget(new ServerPostConnectEvent(player, + server.eventManager().fireAndForget(new ServerPostConnectEvent(player, previousServer)); resultFuture.complete(ConnectionRequestResults.successful(serverConn.server())); }, smc.eventLoop()).exceptionally(exc -> { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java index 4653670586..ed3ec026db 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java @@ -190,7 +190,7 @@ private String createBungeeGuardForwardingAddress(byte[] forwardingSecret) { private void startHandshake() { final MinecraftConnection mc = ensureConnected(); - PlayerInfoForwarding forwardingMode = server.getConfiguration().getPlayerInfoForwardingMode(); + PlayerInfoForwarding forwardingMode = server.configuration().getPlayerInfoForwardingMode(); // Initiate the handshake. ProtocolVersion protocolVersion = proxyPlayer.getConnection().getProtocolVersion(); @@ -200,7 +200,7 @@ private void startHandshake() { if (forwardingMode == PlayerInfoForwarding.LEGACY) { handshake.setServerAddress(createLegacyForwardingAddress()); } else if (forwardingMode == PlayerInfoForwarding.BUNGEEGUARD) { - byte[] secret = server.getConfiguration().getForwardingSecret(); + byte[] secret = server.configuration().getForwardingSecret(); handshake.setServerAddress(createBungeeGuardForwardingAddress(secret)); } else if (proxyPlayer.getConnection().getType() == ConnectionTypes.LEGACY_FORGE) { handshake.setServerAddress(getHandshakeRemoteAddress() + HANDSHAKE_HOSTNAME_TOKEN); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/AuthSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/AuthSessionHandler.java index 934f7852e6..00bc44c32a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/AuthSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/AuthSessionHandler.java @@ -82,12 +82,12 @@ public class AuthSessionHandler implements MinecraftSessionHandler { public void activated() { // Some connection types may need to alter the game profile. profile = mcConnection.getType().addGameProfileTokensIfRequired(profile, - server.getConfiguration().getPlayerInfoForwardingMode()); + server.configuration().getPlayerInfoForwardingMode()); GameProfileRequestEvent profileRequestEvent = new GameProfileRequestEvent(inbound, profile, onlineMode); final GameProfile finalProfile = profile; - server.getEventManager().fire(profileRequestEvent).thenComposeAsync(profileEvent -> { + server.eventManager().fire(profileRequestEvent).thenComposeAsync(profileEvent -> { if (mcConnection.isClosed()) { // The player disconnected after we authenticated them. return CompletableFuture.completedFuture(null); @@ -107,7 +107,7 @@ public void activated() { logger.info("{} has connected", player); - return server.getEventManager() + return server.eventManager() .fire(new PermissionsSetupEvent(player, ConnectedPlayer.DEFAULT_PERMISSIONS)) .thenAcceptAsync(event -> { if (!mcConnection.isClosed()) { @@ -133,12 +133,12 @@ public void activated() { } private void startLoginCompletion(ConnectedPlayer player) { - int threshold = server.getConfiguration().getCompressionThreshold(); + int threshold = server.configuration().getCompressionThreshold(); if (threshold >= 0 && mcConnection.getProtocolVersion().compareTo(MINECRAFT_1_8) >= 0) { mcConnection.write(new SetCompression(threshold)); mcConnection.setCompressionThreshold(threshold); } - VelocityConfiguration configuration = server.getConfiguration(); + VelocityConfiguration configuration = server.configuration(); UUID playerUniqueId = player.uuid(); if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.NONE) { playerUniqueId = UuidUtils.generateOfflinePlayerUuid(player.username()); @@ -182,7 +182,7 @@ public boolean handle(LoginAcknowledged packet) { mcConnection.setActiveSessionHandler(StateRegistry.CONFIG, new ClientConfigSessionHandler(server, connectedPlayer)); - server.getEventManager().fire(new PostLoginEvent(connectedPlayer)) + server.eventManager().fire(new PostLoginEvent(connectedPlayer)) .thenCompose((ignored) -> connectToInitialServer(connectedPlayer)).exceptionally((ex) -> { logger.error("Exception while connecting {} to initial server", connectedPlayer, ex); return null; @@ -194,10 +194,10 @@ public boolean handle(LoginAcknowledged packet) { private void completeLoginProtocolPhaseAndInitialize(ConnectedPlayer player) { mcConnection.setAssociation(player); - server.getEventManager().fire(new LoginEvent(player)).thenAcceptAsync(event -> { + server.eventManager().fire(new LoginEvent(player)).thenAcceptAsync(event -> { if (mcConnection.isClosed()) { // The player was disconnected - server.getEventManager().fireAndForget(new DisconnectEvent(player, + server.eventManager().fireAndForget(new DisconnectEvent(player, DisconnectEvent.LoginStatus.CANCELLED_BY_USER_BEFORE_COMPLETE)); return; } @@ -223,7 +223,7 @@ private void completeLoginProtocolPhaseAndInitialize(ConnectedPlayer player) { loginState = State.ACKNOWLEDGED; mcConnection.setActiveSessionHandler(StateRegistry.PLAY, new InitialConnectSessionHandler(player, server)); - server.getEventManager().fire(new PostLoginEvent(player)) + server.eventManager().fire(new PostLoginEvent(player)) .thenCompose((ignored) -> connectToInitialServer(player)).exceptionally((ex) -> { logger.error("Exception while connecting {} to initial server", player, ex); return null; @@ -241,7 +241,7 @@ private CompletableFuture connectToInitialServer(ConnectedPlayer player) { PlayerChooseInitialServerEvent event = new PlayerChooseInitialServerEvent(player, initialFromConfig.orElse(null)); - return server.getEventManager().fire(event).thenRunAsync(() -> { + return server.eventManager().fire(event).thenRunAsync(() -> { Optional toTry = event.getInitialServer(); if (!toTry.isPresent()) { player.disconnect0( diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java index dd538e1275..41222910fe 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java @@ -114,7 +114,7 @@ public boolean handle(PluginMessage packet) { if (serverConn != null) { if (PluginMessageUtil.isMcBrand(packet)) { String brand = PluginMessageUtil.readBrandMessage(packet.content()); - server.getEventManager().fireAndForget(new PlayerClientBrandEvent(player, brand)); + server.eventManager().fireAndForget(new PlayerClientBrandEvent(player, brand)); player.setClientBrand(brand); // Client sends `minecraft:brand` packet immediately after Login, // but at this time the backend server may not be ready, just discard it. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index aa9c0b4ba5..d6a9d08e08 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -154,7 +154,7 @@ private boolean validateChat(String message) { public void activated() { configSwitchFuture = new CompletableFuture<>(); Collection channels = - server.getChannelRegistrar().getChannelsForProtocol(player.protocolVersion()); + server.channelRegistrar().getChannelsForProtocol(player.protocolVersion()); if (!channels.isEmpty()) { PluginMessage register = constructChannelsPacket(player.protocolVersion(), channels); player.getConnection().write(register); @@ -308,7 +308,7 @@ public boolean handle(PluginMessage packet) { channelIdentifiers.add(new LegacyChannelIdentifier(channel)); } } - server.getEventManager() + server.eventManager() .fireAndForget( new PlayerChannelRegisterEvent(player, ImmutableList.copyOf(channelIdentifiers))); backendConn.write(packet.retain()); @@ -316,10 +316,10 @@ public boolean handle(PluginMessage packet) { backendConn.write(packet.retain()); } else if (PluginMessageUtil.isMcBrand(packet)) { String brand = PluginMessageUtil.readBrandMessage(packet.content()); - server.getEventManager().fireAndForget(new PlayerClientBrandEvent(player, brand)); + server.eventManager().fireAndForget(new PlayerClientBrandEvent(player, brand)); player.setClientBrand(brand); backendConn.write( - PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(), + PluginMessageUtil.rewriteMinecraftBrand(packet, server.version(), player.protocolVersion())); } else if (BungeeCordMessageResponder.isBungeeCordMessage(packet)) { return true; @@ -334,7 +334,7 @@ public boolean handle(PluginMessage packet) { } if (!player.getPhase().handle(player, packet, serverConn)) { - ChannelIdentifier id = server.getChannelRegistrar().getFromId(packet.getChannel()); + ChannelIdentifier id = server.channelRegistrar().getFromId(packet.getChannel()); if (id == null) { // We don't have any plugins listening on this channel, process the packet now. if (!player.getPhase().consideredComplete() || !serverConn.getPhase() @@ -354,7 +354,7 @@ public boolean handle(PluginMessage packet) { } else { byte[] copy = ByteBufUtil.getBytes(packet.content()); PluginMessageEvent event = new PluginMessageEvent(player, serverConn, id, copy); - server.getEventManager().fire(event).thenAcceptAsync(pme -> { + server.eventManager().fire(event).thenAcceptAsync(pme -> { if (pme.result().allowed()) { PluginMessage message = new PluginMessage(packet.getChannel(), Unpooled.wrappedBuffer(copy)); @@ -538,7 +538,7 @@ public void handleBackendJoinGame(JoinGame joinGame, VelocityServerConnection de // Tell the server about the proxy's plugin message channels. ProtocolVersion serverVersion = serverMc.getProtocolVersion(); - final Collection channels = server.getChannelRegistrar() + final Collection channels = server.channelRegistrar() .getChannelsForProtocol(serverMc.getProtocolVersion()); if (!channels.isEmpty()) { serverMc.delayedWrite(constructChannelsPacket(serverVersion, channels)); @@ -615,7 +615,7 @@ private boolean handleCommandTabComplete(TabCompleteRequest packet) { } String commandLabel = command.substring(0, commandEndPosition); - if (!server.getCommandManager().hasCommand(commandLabel)) { + if (!server.commandManager().hasCommand(commandLabel)) { if (player.protocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0) { // Outstanding tab completes are recorded for use with 1.12 clients and below to provide // additional tab completion support. @@ -624,7 +624,7 @@ private boolean handleCommandTabComplete(TabCompleteRequest packet) { return false; } - server.getCommandManager().offerBrigadierSuggestions(player, command) + server.commandManager().offerBrigadierSuggestions(player, command) .thenAcceptAsync(suggestions -> { if (suggestions.isEmpty()) { return; @@ -687,7 +687,7 @@ public void handleTabCompleteResponse(TabCompleteResponse response) { private void finishCommandTabComplete(TabCompleteRequest request, TabCompleteResponse response) { String command = request.getCommand().substring(1); - server.getCommandManager().offerBrigadierSuggestions(player, command) + server.commandManager().offerBrigadierSuggestions(player, command) .thenAcceptAsync(offers -> { boolean legacy = player.protocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0; @@ -726,7 +726,7 @@ private void finishRegularTabComplete(TabCompleteRequest request, TabCompleteRes for (Offer offer : response.getOffers()) { offers.add(offer.getText()); } - server.getEventManager().fire(new TabCompleteEvent(player, request.getCommand(), offers)) + server.eventManager().fire(new TabCompleteEvent(player, request.getCommand(), offers)) .thenAcceptAsync(e -> { response.getOffers().clear(); for (String s : e.suggestions()) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index d73f6f20a8..6b2607fecd 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -298,7 +298,7 @@ public void setClientSettings(final ClientSettings clientSettingsPacket) { this.clientSettingsPacket = clientSettingsPacket; final ClientSettingsWrapper cs = new ClientSettingsWrapper(clientSettingsPacket); this.settings = cs; - server.getEventManager().fireAndForget(new PlayerSettingsChangedEvent(this, cs)); + server.eventManager().fireAndForget(new PlayerSettingsChangedEvent(this, cs)); } @Override @@ -308,7 +308,7 @@ public Optional modInfo() { public void setModInfo(ModInfo modInfo) { this.modInfo = modInfo; - server.getEventManager().fireAndForget(new PlayerModInfoEvent(this, modInfo)); + server.eventManager().fireAndForget(new PlayerModInfoEvent(this, modInfo)); } @Override @@ -584,7 +584,7 @@ public void disconnect(Component reason) { public void disconnect0(Component reason, boolean duringLogin) { Component translated = this.translateMessage(reason); - if (server.getConfiguration().isLogPlayerConnections()) { + if (server.configuration().isLogPlayerConnections()) { logger.info("{} has disconnected: {}", this, LegacyComponentSerializer.legacySection().serialize(translated)); } @@ -710,7 +710,7 @@ private void handleConnectionException(RegisteredServer rs, private void handleKickEvent(KickedFromServerEvent originalEvent, Component friendlyReason, boolean kickedFromCurrent) { - server.getEventManager().fire(originalEvent).thenAcceptAsync(event -> { + server.eventManager().fire(originalEvent).thenAcceptAsync(event -> { // There can't be any connection in flight now. connectionInFlight = null; @@ -810,12 +810,12 @@ private Optional getNextServerToTry(@Nullable RegisteredServer String virtualHostStr = virtualHost().map(InetSocketAddress::getHostString) .orElse("") .toLowerCase(Locale.ROOT); - serversToTry = server.getConfiguration().getForcedHosts().getOrDefault(virtualHostStr, + serversToTry = server.configuration().getForcedHosts().getOrDefault(virtualHostStr, Collections.emptyList()); } if (serversToTry.isEmpty()) { - List connOrder = server.getConfiguration().getAttemptConnectionOrder(); + List connOrder = server.configuration().getAttemptConnectionOrder(); if (connOrder.isEmpty()) { return Optional.empty(); } else { @@ -832,7 +832,7 @@ private Optional getNextServerToTry(@Nullable RegisteredServer } tryIndex = i; - return server.getServer(toTryName); + return server.server(toTryName); } return Optional.empty(); } @@ -881,7 +881,7 @@ void teardown() { connectedServer.disconnect(); } - Optional connectedPlayer = server.getPlayer(this.uuid()); + Optional connectedPlayer = server.player(this.uuid()); server.unregisterConnection(this); DisconnectEvent.LoginStatus status; @@ -898,7 +898,7 @@ void teardown() { } DisconnectEvent event = new DisconnectEvent(this, status); - server.getEventManager().fire(event).whenComplete((val, ex) -> { + server.eventManager().fire(event).whenComplete((val, ex) -> { if (ex == null) { this.teardownFuture.complete(null); } else { @@ -913,7 +913,7 @@ public CompletableFuture getTeardownFuture() { @Override public String toString() { - boolean isPlayerAddressLoggingEnabled = server.getConfiguration() + boolean isPlayerAddressLoggingEnabled = server.configuration() .isPlayerAddressLoggingEnabled(); String playerIp = isPlayerAddressLoggingEnabled ? remoteAddress().toString() : ""; @@ -1041,7 +1041,7 @@ public boolean onResourcePackResponse(PlayerResourcePackStatusEvent.Status statu final ResourcePackInfo queued = peek ? outstandingResourcePacks.peek() : outstandingResourcePacks.poll(); - server.getEventManager().fire(new PlayerResourcePackStatusEvent(this, status, queued)) + server.eventManager().fire(new PlayerResourcePackStatusEvent(this, status, queued)) .thenAcceptAsync(event -> { if (event.getStatus() == PlayerResourcePackStatusEvent.Status.DECLINED && event.getPackInfo() != null && event.getPackInfo().required() @@ -1190,7 +1190,7 @@ private CompletableFuture internalConnect() { ServerPreConnectEvent event = new ServerPreConnectEvent(ConnectedPlayer.this, toConnect, previousServer); - return server.getEventManager().fire(event).thenComposeAsync(newEvent -> { + return server.eventManager().fire(event).thenComposeAsync(newEvent -> { Optional newDest = newEvent.result().getServer(); if (!newDest.isPresent()) { return completedFuture( diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java index 5f2a7913b3..1b696b84fd 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java @@ -138,7 +138,7 @@ private void handleLogin(Handshake handshake, InitialInboundConnection ic) { // If the proxy is configured for modern forwarding, we must deny connections from 1.12.2 // and lower, otherwise IP information will never get forwarded. - if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN + if (server.configuration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && handshake.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0) { ic.disconnectQuietly( Component.translatable("velocity.error.modern-forwarding-needs-new-client")); @@ -146,7 +146,7 @@ private void handleLogin(Handshake handshake, InitialInboundConnection ic) { } LoginInboundConnection lic = new LoginInboundConnection(ic); - server.getEventManager().fireAndForget(new ConnectionHandshakeEvent(lic)); + server.eventManager().fireAndForget(new ConnectionHandshakeEvent(lic)); connection.setActiveSessionHandler(StateRegistry.LOGIN, new InitialLoginSessionHandler(server, connection, lic)); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java index c691956c5d..083a6cb29c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java @@ -58,7 +58,7 @@ public boolean handle(PluginMessage packet) { return true; } - ChannelIdentifier id = server.getChannelRegistrar().getFromId(packet.getChannel()); + ChannelIdentifier id = server.channelRegistrar().getFromId(packet.getChannel()); if (id == null) { serverConn.ensureConnected().write(packet.retain()); return true; @@ -67,7 +67,7 @@ public boolean handle(PluginMessage packet) { byte[] copy = ByteBufUtil.getBytes(packet.content()); PluginMessageEvent event = new PluginMessageEvent(serverConn, serverConn.player(), id, copy); - server.getEventManager().fire(event) + server.eventManager().fire(event) .thenAcceptAsync(pme -> { if (pme.result().allowed() && serverConn.isActive()) { PluginMessage copied = new PluginMessage(packet.getChannel(), diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java index 7c656afee9..24f3aca082 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java @@ -91,7 +91,7 @@ public MinecraftConnection getConnection() { public void disconnect(Component reason) { Component translated = GlobalTranslator.render(reason, ClosestLocaleMatcher.INSTANCE .lookupClosest(Locale.getDefault())); - if (connection.server.getConfiguration().isLogPlayerConnections()) { + if (connection.server.configuration().isLogPlayerConnections()) { logger.info("{} has disconnected: {}", this, LegacyComponentSerializer.legacySection().serialize(translated)); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java index b36c98ef42..8c744e0c88 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java @@ -83,7 +83,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler { this.inbound = Preconditions.checkNotNull(inbound, "inbound"); this.forceKeyAuthentication = System.getProperties().containsKey("auth.forceSecureProfiles") ? Boolean.getBoolean("auth.forceSecureProfiles") - : server.getConfiguration().isForceKeyAuthentication(); + : server.configuration().isForceKeyAuthentication(); } @Override @@ -121,7 +121,7 @@ public boolean handle(ServerLogin packet) { this.login = packet; PreLoginEvent event = new PreLoginEvent(inbound, login.getUsername()); - server.getEventManager().fire(event).thenRunAsync(() -> { + server.eventManager().fire(event).thenRunAsync(() -> { if (mcConnection.isClosed()) { // The player was disconnected return; @@ -143,7 +143,7 @@ public boolean handle(ServerLogin packet) { mcConnection.eventLoop().execute(() -> { if (!result.isForceOfflineMode() - && (server.getConfiguration().isOnlineMode() || result.isOnlineModeAllowed())) { + && (server.configuration().isOnlineMode() || result.isOnlineModeAllowed())) { // Request encryption. EncryptionRequest request = generateEncryptionRequest(); this.verify = Arrays.copyOf(request.getVerifyToken(), 4); @@ -205,7 +205,7 @@ public boolean handle(EncryptionResponse packet) { String url = String.format(MOJANG_HASJOINED_URL, urlFormParameterEscaper().escape(login.getUsername()), serverId); - if (server.getConfiguration().shouldPreventClientProxyConnections()) { + if (server.configuration().shouldPreventClientProxyConnections()) { url += "&ip=" + urlFormParameterEscaper().escape(playerIp); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java index 654eb15d61..0e24de02dc 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java @@ -52,7 +52,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler { @Override public void activated() { - if (server.getConfiguration().isShowPingRequests()) { + if (server.configuration().isShowPingRequests()) { logger.info("{} is pinging the server with version {}", this.inbound, this.connection.getProtocolVersion()); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java index 55ca85bab7..76cdff1e8e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java @@ -52,11 +52,11 @@ private ServerPing constructLocalPing(ProtocolVersion version) { if (version == ProtocolVersion.UNKNOWN) { version = ProtocolVersion.MAXIMUM_VERSION; } - VelocityConfiguration configuration = server.getConfiguration(); + VelocityConfiguration configuration = server.configuration(); return new ServerPing( new ServerPing.Version(version.getProtocol(), "Velocity " + ProtocolVersion.SUPPORTED_VERSION_STRING), - new ServerPing.Players(server.getPlayerCount(), configuration.getShowMaxPlayers(), + new ServerPing.Players(server.onlinePlayerCount(), configuration.getShowMaxPlayers(), ImmutableList.of()), configuration.getMotd(), configuration.getFavicon().orElse(null), @@ -69,7 +69,7 @@ private CompletableFuture attemptPingPassthrough(VelocityInboundConn ServerPing fallback = constructLocalPing(connection.protocolVersion()); List> pings = new ArrayList<>(); for (String s : servers) { - Optional rs = server.getServer(s); + Optional rs = server.server(s); if (rs.isEmpty()) { continue; } @@ -144,7 +144,7 @@ private CompletableFuture attemptPingPassthrough(VelocityInboundConn * @return a future with the initial ping result */ public CompletableFuture getInitialPing(VelocityInboundConnection connection) { - VelocityConfiguration configuration = server.getConfiguration(); + VelocityConfiguration configuration = server.configuration(); ProtocolVersion shownVersion = ProtocolVersion.isSupported(connection.protocolVersion()) ? connection.protocolVersion() : ProtocolVersion.MAXIMUM_VERSION; PingPassthroughMode passthroughMode = configuration.getPingPassthrough(); @@ -155,8 +155,8 @@ public CompletableFuture getInitialPing(VelocityInboundConnection co String virtualHostStr = connection.virtualHost().map(InetSocketAddress::getHostString) .map(str -> str.toLowerCase(Locale.ROOT)) .orElse(""); - List serversToTry = server.getConfiguration().getForcedHosts().getOrDefault( - virtualHostStr, server.getConfiguration().getAttemptConnectionOrder()); + List serversToTry = server.configuration().getForcedHosts().getOrDefault( + virtualHostStr, server.configuration().getAttemptConnectionOrder()); return attemptPingPassthrough(connection, passthroughMode, serversToTry, shownVersion); } } @@ -171,7 +171,7 @@ public CompletableFuture getInitialPing(VelocityInboundConnection co */ public CompletableFuture getPing(VelocityInboundConnection connection) { return this.getInitialPing(connection) - .thenCompose(ping -> server.getEventManager().fire(new ProxyPingEvent(connection, ping))) + .thenCompose(ping -> server.eventManager().fire(new ProxyPingEvent(connection, ping))) .thenApply(ProxyPingEvent::ping); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java index 0dc0c9caec..da95f1118a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/console/VelocityConsole.java @@ -93,7 +93,7 @@ public void setupPermissions() { PermissionsSetupEvent event = new PermissionsSetupEvent( this, s -> PermissionChecker.always(TriState.TRUE)); // we can safely block here, this is before any listeners fire - this.permissionChecker = this.server.getEventManager().fire(event).join().createChecker(this); + this.permissionChecker = this.server.eventManager().fire(event).join().createChecker(this); if (this.permissionChecker == null) { logger.error( "A plugin permission provider {} provided an invalid permission function" @@ -110,7 +110,7 @@ protected LineReader buildReader(LineReaderBuilder builder) { .appName("Velocity") .completer((reader, parsedLine, list) -> { try { - List offers = this.server.getCommandManager() + List offers = this.server.commandManager() .offerSuggestions(this, parsedLine.line()) .join(); // Console doesn't get harmed much by this... for (String offer : offers) { @@ -131,7 +131,7 @@ protected boolean isRunning() { @Override protected void runCommand(String command) { try { - if (!this.server.getCommandManager().executeAsync(this, command).join()) { + if (!this.server.commandManager().executeAsync(this, command).join()) { sendMessage(Component.translatable("velocity.command.command-does-not-exist", NamedTextColor.RED)); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java b/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java index 08ecdc1add..a203f15029 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java @@ -94,7 +94,7 @@ public ConnectionManager(VelocityServer server) { this.resolver = new SeparatePoolInetNameResolver(GlobalEventExecutor.INSTANCE); this.httpClient = asyncHttpClient(config() .setEventLoopGroup(this.workerGroup) - .setUserAgent(server.getVersion().name() + "/" + server.getVersion().version()) + .setUserAgent(server.version().name() + "/" + server.version().version()) .addRequestFilter(new RequestFilter() { @Override public FilterContext filter(FilterContext ctx) { @@ -129,7 +129,7 @@ public void bind(final SocketAddress address) { if (address instanceof InetSocketAddress) { bootstrap.childOption(ChannelOption.TCP_NODELAY, true) .childOption(ChannelOption.IP_TOS, 0x18); - if (server.getConfiguration().useTcpFastOpen()) { + if (server.configuration().useTcpFastOpen()) { bootstrap.option(ChannelOption.TCP_FASTOPEN, 3); } } @@ -142,7 +142,7 @@ public void bind(final SocketAddress address) { LOGGER.info("Listening on {}", channel.localAddress()); // Fire the proxy bound event after the socket is bound - server.getEventManager().fireAndForget( + server.eventManager().fireAndForget( new ListenerBoundEvent(address, ListenerType.MINECRAFT)); } else { LOGGER.error("Can't bind to {}", address, future.cause()); @@ -171,7 +171,7 @@ public void queryBind(final String hostname, final int port) { LOGGER.info("Listening for GS4 query on {}", channel.localAddress()); // Fire the proxy bound event after the socket is bound - server.getEventManager().fireAndForget( + server.eventManager().fireAndForget( new ListenerBoundEvent(address, ListenerType.QUERY)); } else { LOGGER.error("Can't bind to {}", bootstrap.config().localAddress(), future.cause()); @@ -191,10 +191,10 @@ public Bootstrap createWorker(@Nullable EventLoopGroup group, SocketAddress targ .channelFactory(this.transportType.getClientChannelFactory(target)) .option(ChannelOption.TCP_NODELAY, true) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, - this.server.getConfiguration().getConnectTimeout()) + this.server.configuration().getConnectTimeout()) .group(group == null ? this.workerGroup : group) .resolver(this.resolver.asGroup()); - if (server.getConfiguration().useTcpFastOpen()) { + if (server.configuration().useTcpFastOpen()) { bootstrap.option(ChannelOption.TCP_FASTOPEN_CONNECT, true); } return bootstrap; @@ -210,7 +210,7 @@ public void close(SocketAddress oldBind) { // Fire proxy close event to notify plugins of socket close. We block since plugins // should have a chance to be notified before the server stops accepting connections. - server.getEventManager().fire(new ListenerCloseEvent(oldBind, endpoint.getType())).join(); + server.eventManager().fire(new ListenerCloseEvent(oldBind, endpoint.getType())).join(); Channel serverChannel = endpoint.getChannel(); @@ -231,7 +231,7 @@ public void closeEndpoints(boolean interrupt) { // Fire proxy close event to notify plugins of socket close. We block since plugins // should have a chance to be notified before the server stops accepting connections. - server.getEventManager().fire(new ListenerCloseEvent(address, endpoint.getType())).join(); + server.eventManager().fire(new ListenerCloseEvent(address, endpoint.getType())).join(); LOGGER.info("Closing endpoint {}", address); if (interrupt) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializer.java index 508c9d6b22..8da2a38402 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializer.java @@ -45,7 +45,7 @@ public class BackendChannelInitializer extends ChannelInitializer { private final long readTimeoutMs; public BackendChannelInitializer(VelocityServer server) { - this(server.getConfiguration().getReadTimeout()); + this(server.configuration().getReadTimeout()); } public BackendChannelInitializer(long readTimeoutMs) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializer.java index 2132f5967f..184263e42e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializer.java @@ -61,7 +61,7 @@ protected void initChannel(final Channel ch) { .addLast(LEGACY_PING_DECODER, new LegacyPingDecoder()) .addLast(FRAME_DECODER, new MinecraftVarintFrameDecoder()) .addLast(READ_TIMEOUT, - new ReadTimeoutHandler(this.server.getConfiguration().getReadTimeout(), + new ReadTimeoutHandler(this.server.configuration().getReadTimeout(), TimeUnit.MILLISECONDS)) .addLast(LEGACY_PING_ENCODER, LegacyPingEncoder.INSTANCE) .addLast(FRAME_ENCODER, MinecraftVarintLengthEncoder.INSTANCE) @@ -73,7 +73,7 @@ protected void initChannel(final Channel ch) { new HandshakeSessionHandler(connection, this.server)); ch.pipeline().addLast(Connections.HANDLER, connection); - if (this.server.getConfiguration().isProxyProtocol()) { + if (this.server.configuration().isProxyProtocol()) { ch.pipeline().addFirst(new HAProxyMessageDecoder()); } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java index 0969ed27e4..4fe2f21e74 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java @@ -88,18 +88,18 @@ public GameSpyQueryHandler(VelocityServer server) { private QueryResponse createInitialResponse() { return QueryResponse.builder() .hostname( - PlainTextComponentSerializer.plainText().serialize(server.getConfiguration().getMotd())) + PlainTextComponentSerializer.plainText().serialize(server.configuration().getMotd())) .gameVersion(ProtocolVersion.SUPPORTED_VERSION_STRING) - .map(server.getConfiguration().getQueryMap()) - .currentPlayers(server.getPlayerCount()) - .maxPlayers(server.getConfiguration().getShowMaxPlayers()) - .proxyPort(((InetSocketAddress) server.getConfiguration().getBind()).getPort()) - .proxyHost(((InetSocketAddress) server.getConfiguration().getBind()).getHostString()) - .players(server.getAllPlayers().stream().map(Player::username) + .map(server.configuration().getQueryMap()) + .currentPlayers(server.onlinePlayerCount()) + .maxPlayers(server.configuration().getShowMaxPlayers()) + .proxyPort(((InetSocketAddress) server.configuration().getBind()).getPort()) + .proxyHost(((InetSocketAddress) server.configuration().getBind()).getHostString()) + .players(server.onlinePlayers().stream().map(Player::username) .collect(Collectors.toList())) .proxyVersion("Velocity") .plugins( - server.getConfiguration().shouldQueryShowPlugins() ? getRealPluginInformation() + server.configuration().shouldQueryShowPlugins() ? getRealPluginInformation() : Collections.emptyList()) .build(); } @@ -154,7 +154,7 @@ protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throw boolean isBasic = !queryMessage.isReadable(); // Call event and write response - server.getEventManager() + server.eventManager() .fire(new ProxyQueryEvent(isBasic ? BASIC : FULL, senderAddress, response)) .thenAcceptAsync((event) -> { // Packet header @@ -205,7 +205,7 @@ private static void writeString(ByteBuf buf, String string) { private List getRealPluginInformation() { List result = new ArrayList<>(); - for (PluginContainer plugin : server.getPluginManager().plugins()) { + for (PluginContainer plugin : server.pluginManager().plugins()) { PluginDescription description = plugin.description(); result.add(QueryResponse.PluginInformation.of(description.name() .orElse(description.id()), description.version().orElse(null))); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/CommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/CommandHandler.java index 2b214e93b8..e520c4e470 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/CommandHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/CommandHandler.java @@ -48,7 +48,7 @@ default boolean handlePlayerCommand(MinecraftPacket packet) { default CompletableFuture runCommand(VelocityServer server, ConnectedPlayer player, String command, Function hasRunPacketFunction) { - return server.getCommandManager().executeImmediatelyAsync(player, command) + return server.commandManager().executeImmediatelyAsync(player, command) .thenApply(hasRunPacketFunction); } @@ -56,10 +56,10 @@ default void queueCommandResult(VelocityServer server, ConnectedPlayer player, Function> futurePacketCreator, String message, Instant timestamp) { player.getChatQueue().queuePacket( - server.getCommandManager().callCommandEvent(player, message) + server.commandManager().callCommandEvent(player, message) .thenComposeAsync(futurePacketCreator) .thenApply(pkt -> { - if (server.getConfiguration().isLogCommandExecutions()) { + if (server.configuration().isLogCommandExecutions()) { logger.info("{} -> executed command /{}", player, message); } return pkt; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatHandler.java index d410ceb6bd..6db54cebe8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatHandler.java @@ -68,7 +68,7 @@ public static void invalidChange(Logger logger, ConnectedPlayer player) { @Override public void handlePlayerChatInternal(KeyedPlayerChat packet) { ChatQueue chatQueue = this.player.getChatQueue(); - EventManager eventManager = this.server.getEventManager(); + EventManager eventManager = this.server.eventManager(); PlayerChatEvent toSend = new PlayerChatEvent(player, packet.getMessage()); CompletableFuture future = eventManager.fire(toSend); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatHandler.java index 9e2da187b6..834e4e0dd0 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatHandler.java @@ -44,7 +44,7 @@ public void handlePlayerChatInternal(LegacyChat packet) { if (serverConnection == null) { return; } - this.server.getEventManager().fire(new PlayerChatEvent(this.player, packet.getMessage())) + this.server.eventManager().fire(new PlayerChatEvent(this.player, packet.getMessage())) .whenComplete((chatEvent, throwable) -> { if (!chatEvent.result().allowed()) { return; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatHandler.java index d774c604c8..1dab7ea930 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatHandler.java @@ -49,7 +49,7 @@ public Class packetClass() { @Override public void handlePlayerChatInternal(SessionPlayerChat packet) { ChatQueue chatQueue = this.player.getChatQueue(); - EventManager eventManager = this.server.getEventManager(); + EventManager eventManager = this.server.eventManager(); PlayerChatEvent toSend = new PlayerChatEvent(player, packet.getMessage()); chatQueue.queuePacket( eventManager.fire(toSend) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java index a2ee51c83f..1e6b923a58 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/VelocityPluginManager.java @@ -136,9 +136,9 @@ public void loadPlugins(Path directory) throws IOException { @Override protected void configure() { bind(ProxyServer.class).toInstance(server); - bind(PluginManager.class).toInstance(server.getPluginManager()); - bind(EventManager.class).toInstance(server.getEventManager()); - bind(CommandManager.class).toInstance(server.getCommandManager()); + bind(PluginManager.class).toInstance(server.pluginManager()); + bind(EventManager.class).toInstance(server.eventManager()); + bind(CommandManager.class).toInstance(server.commandManager()); for (PluginContainer container : pluginContainers.keySet()) { bind(PluginContainer.class) .annotatedWith(Names.named(container.description().id())) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java b/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java index c9ad4f3567..94597e5223 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java @@ -96,7 +96,7 @@ public CompletableFuture ping(@Nullable EventLoop loop, PingOptions } CompletableFuture pingFuture = new CompletableFuture<>(); long timeoutMs = pingOptions.timeout() == 0 - ? server.getConfiguration().getReadTimeout() : pingOptions.timeout(); + ? server.configuration().getReadTimeout() : pingOptions.timeout(); server.createBootstrap(loop, serverInfo.address()) .handler(new BackendChannelInitializer(timeoutMs)) .connect(serverInfo.address()) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java index 1261b96a73..ecdb68eea7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java @@ -226,7 +226,7 @@ void updateEntry(int action, TabListEntry entry) { LegacyPlayerListItem.Item packetItem = LegacyPlayerListItem.Item.from(entry); IdentifiedKey selectedKey = packetItem.getPlayerKey(); - Optional existing = proxyServer.getPlayer(entry.getProfile().uuid()); + Optional existing = proxyServer.player(entry.getProfile().uuid()); if (existing.isPresent()) { selectedKey = existing.get().identifiedKey(); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/InformationUtils.java b/proxy/src/main/java/com/velocitypowered/proxy/util/InformationUtils.java index 2ad38bfcb9..c1a201be16 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/InformationUtils.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/InformationUtils.java @@ -57,7 +57,7 @@ public enum InformationUtils { */ public static JsonArray collectPluginInfo(ProxyServer proxy) { List allPlugins = ImmutableList.copyOf( - proxy.getPluginManager().plugins()); + proxy.pluginManager().plugins()); JsonArray plugins = new JsonArray(); for (PluginContainer plugin : allPlugins) {