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