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