13
0
geforkt von Mirrors/Velocity

Added ProxyConfig interface and implemented in VelocityConfiguration

Dieser Commit ist enthalten in:
Crypnotic 2018-09-30 19:12:55 -05:00
Ursprung 20d0c39576
Commit aa34977f3e
6 geänderte Dateien mit 115 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,7 @@ import com.velocitypowered.api.command.CommandManager;
import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.EventManager; import com.velocitypowered.api.event.EventManager;
import com.velocitypowered.api.plugin.PluginManager; 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.messages.ChannelRegistrar;
import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo; import com.velocitypowered.api.proxy.server.ServerInfo;
@ -124,4 +125,10 @@ public interface ProxyServer {
* @return the address the proxy is bound to * @return the address the proxy is bound to
*/ */
InetSocketAddress getBoundAddress(); InetSocketAddress getBoundAddress();
/**
* Gets the {@link ProxyConfig} instance.
* @return the proxy config
* */
ProxyConfig getConfiguration();
} }

Datei anzeigen

@ -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();
}

Datei anzeigen

@ -3,6 +3,7 @@ package com.velocitypowered.proxy.config;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.moandjiezana.toml.Toml; import com.moandjiezana.toml.Toml;
import com.velocitypowered.api.proxy.config.ProxyConfig;
import com.velocitypowered.api.util.Favicon; import com.velocitypowered.api.util.Favicon;
import com.velocitypowered.proxy.util.AddressUtil; import com.velocitypowered.proxy.util.AddressUtil;
import net.kyori.text.Component; import net.kyori.text.Component;
@ -18,7 +19,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.*; import java.util.*;
public class VelocityConfiguration extends AnnotatedConfig { public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfig {
@Comment("Config version. Do not change this") @Comment("Config version. Do not change this")
@ConfigKey("config-version") @ConfigKey("config-version")
@ -263,8 +264,8 @@ public class VelocityConfiguration extends AnnotatedConfig {
return advanced.getLoginRatelimit(); return advanced.getLoginRatelimit();
} }
public Favicon getFavicon() { public Optional<Favicon> getFavicon() {
return favicon; return Optional.ofNullable(favicon);
} }
public boolean isAnnounceForge() { public boolean isAnnounceForge() {

Datei anzeigen

@ -21,7 +21,6 @@ import com.velocitypowered.proxy.protocol.packet.PluginMessage;
import com.velocitypowered.proxy.protocol.packet.ServerLogin; import com.velocitypowered.proxy.protocol.packet.ServerLogin;
import com.velocitypowered.proxy.server.VelocityRegisteredServer; import com.velocitypowered.proxy.server.VelocityRegisteredServer;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelInitializer;
import io.netty.handler.timeout.ReadTimeoutHandler; import io.netty.handler.timeout.ReadTimeoutHandler;

Datei anzeigen

@ -15,7 +15,6 @@ import com.velocitypowered.proxy.config.PlayerInfoForwarding;
import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.connection.VelocityConstants; import com.velocitypowered.proxy.connection.VelocityConstants;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolConstants; import com.velocitypowered.proxy.protocol.ProtocolConstants;
import com.velocitypowered.proxy.protocol.StateRegistry; import com.velocitypowered.proxy.protocol.StateRegistry;
import com.velocitypowered.proxy.protocol.packet.*; import com.velocitypowered.proxy.protocol.packet.*;

Datei anzeigen

@ -41,7 +41,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
new ServerPing.Version(shownVersion, "Velocity " + ProtocolConstants.SUPPORTED_GENERIC_VERSION_STRING), new ServerPing.Version(shownVersion, "Velocity " + ProtocolConstants.SUPPORTED_GENERIC_VERSION_STRING),
new ServerPing.Players(server.getPlayerCount(), configuration.getShowMaxPlayers(), ImmutableList.of()), new ServerPing.Players(server.getPlayerCount(), configuration.getShowMaxPlayers(), ImmutableList.of()),
configuration.getMotdComponent(), configuration.getMotdComponent(),
configuration.getFavicon(), configuration.getFavicon().orElse(null),
configuration.isAnnounceForge() ? ServerPing.ModInfo.DEFAULT : null configuration.isAnnounceForge() ? ServerPing.ModInfo.DEFAULT : null
); );