mirror of
https://github.com/PaperMC/Velocity.git
synced 2024-11-27 06:30:35 +08:00
Added ProxyConfig interface and implemented in VelocityConfiguration
This commit is contained in:
parent
20d0c39576
commit
aa34977f3e
@ -4,6 +4,7 @@ import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.event.EventManager;
|
||||
import com.velocitypowered.api.plugin.PluginManager;
|
||||
import com.velocitypowered.api.proxy.config.ProxyConfig;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||
@ -124,4 +125,10 @@ public interface ProxyServer {
|
||||
* @return the address the proxy is bound to
|
||||
*/
|
||||
InetSocketAddress getBoundAddress();
|
||||
|
||||
/**
|
||||
* Gets the {@link ProxyConfig} instance.
|
||||
* @return the proxy config
|
||||
* */
|
||||
ProxyConfig getConfiguration();
|
||||
}
|
||||
|
@ -0,0 +1,103 @@
|
||||
package com.velocitypowered.api.proxy.config;
|
||||
|
||||
import com.velocitypowered.api.util.Favicon;
|
||||
import net.kyori.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Provides an interface to a proxy configuration
|
||||
*/
|
||||
public interface ProxyConfig {
|
||||
/**
|
||||
* Whether GameSpy 4 queries are accepted by the proxy
|
||||
* @return queries enabled
|
||||
*/
|
||||
boolean isQueryEnabled();
|
||||
|
||||
/**
|
||||
* Get the port GameSpy 4 queries are accepted on
|
||||
* @return the query port
|
||||
*/
|
||||
int getQueryPort();
|
||||
|
||||
/**
|
||||
* Get the map name reported to GameSpy 4 query services
|
||||
* @return the map name
|
||||
*/
|
||||
String getQueryMap();
|
||||
|
||||
/**
|
||||
* Get the MOTD component shown in the tab list
|
||||
* @return the motd component
|
||||
*/
|
||||
Component getMotdComponent();
|
||||
|
||||
/**
|
||||
* Get the maximum players shown in the tab list
|
||||
* @return max players
|
||||
*/
|
||||
int getShowMaxPlayers();
|
||||
|
||||
/**
|
||||
* Get whether the proxy is online mode. This determines if players are authenticated with Mojang servers.
|
||||
* @return online mode enabled
|
||||
*/
|
||||
boolean isOnlineMode();
|
||||
|
||||
/**
|
||||
* Get a Map of all servers registered on this proxy
|
||||
* @return registered servers map
|
||||
*/
|
||||
Map<String, String> getServers();
|
||||
|
||||
/**
|
||||
* Get the order of servers that players will be connected to
|
||||
* @return connection order list
|
||||
*/
|
||||
List<String> getAttemptConnectionOrder();
|
||||
|
||||
/**
|
||||
* Get the minimum compression threshold for packets
|
||||
* @return the compression threshold
|
||||
*/
|
||||
int getCompressionThreshold();
|
||||
|
||||
/**
|
||||
* Get the level of compression that packets will be compressed to
|
||||
* @return the compression level
|
||||
*/
|
||||
int getCompressionLevel();
|
||||
|
||||
/**
|
||||
* Get the limit for how long a player must wait to log back in
|
||||
* @return the login rate limit (in milliseconds)
|
||||
*/
|
||||
int getLoginRatelimit();
|
||||
|
||||
/**
|
||||
* Get the proxy favicon shown in the tablist
|
||||
* @return optional favicon
|
||||
*/
|
||||
Optional<Favicon> getFavicon();
|
||||
|
||||
/**
|
||||
* Get whether this proxy displays that it supports Forge/FML
|
||||
* @return forge announce enabled
|
||||
*/
|
||||
boolean isAnnounceForge();
|
||||
|
||||
/**
|
||||
* Get how long this proxy will wait until performing a read timeout
|
||||
* @return connection timeout (in milliseconds)
|
||||
*/
|
||||
int getConnectTimeout();
|
||||
|
||||
/**
|
||||
* Get how long this proxy will wait until performing a read timeout
|
||||
* @return read timeout (in milliseconds)
|
||||
*/
|
||||
int getReadTimeout();
|
||||
}
|
@ -3,6 +3,7 @@ package com.velocitypowered.proxy.config;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.moandjiezana.toml.Toml;
|
||||
import com.velocitypowered.api.proxy.config.ProxyConfig;
|
||||
import com.velocitypowered.api.util.Favicon;
|
||||
import com.velocitypowered.proxy.util.AddressUtil;
|
||||
import net.kyori.text.Component;
|
||||
@ -18,7 +19,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
|
||||
public class VelocityConfiguration extends AnnotatedConfig {
|
||||
public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfig {
|
||||
|
||||
@Comment("Config version. Do not change this")
|
||||
@ConfigKey("config-version")
|
||||
@ -263,8 +264,8 @@ public class VelocityConfiguration extends AnnotatedConfig {
|
||||
return advanced.getLoginRatelimit();
|
||||
}
|
||||
|
||||
public Favicon getFavicon() {
|
||||
return favicon;
|
||||
public Optional<Favicon> getFavicon() {
|
||||
return Optional.ofNullable(favicon);
|
||||
}
|
||||
|
||||
public boolean isAnnounceForge() {
|
||||
|
@ -21,7 +21,6 @@ import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLogin;
|
||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
|
@ -15,7 +15,6 @@ import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.VelocityConstants;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.*;
|
||||
|
@ -41,7 +41,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
||||
new ServerPing.Version(shownVersion, "Velocity " + ProtocolConstants.SUPPORTED_GENERIC_VERSION_STRING),
|
||||
new ServerPing.Players(server.getPlayerCount(), configuration.getShowMaxPlayers(), ImmutableList.of()),
|
||||
configuration.getMotdComponent(),
|
||||
configuration.getFavicon(),
|
||||
configuration.getFavicon().orElse(null),
|
||||
configuration.isAnnounceForge() ? ServerPing.ModInfo.DEFAULT : null
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user