misc(velocity): Implement Advanced config section
This commit is contained in:
parent
6775b8080e
commit
97b9bcd87a
@ -9,18 +9,6 @@ import java.util.List;
|
|||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class ProxyConfiguration {
|
public class ProxyConfiguration {
|
||||||
@Comment("Enable debug mode")
|
|
||||||
private boolean debug = false;
|
|
||||||
public boolean debug() {
|
|
||||||
return this.debug;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Comment("")
|
|
||||||
private int randomAttempts = 5;
|
|
||||||
public int randomAttempts() {
|
|
||||||
return this.randomAttempts;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Comment("List of login/registration servers")
|
@Comment("List of login/registration servers")
|
||||||
private List<String> authServers = List.of("auth1", "auth2");
|
private List<String> authServers = List.of("auth1", "auth2");
|
||||||
public List<String> authServers() {
|
public List<String> authServers() {
|
||||||
@ -42,6 +30,11 @@ public class ProxyConfiguration {
|
|||||||
return this.ensureAuthServer;
|
return this.ensureAuthServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Advanced advanced = new Advanced();
|
||||||
|
public Advanced advanced() {
|
||||||
|
return this.advanced;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public static class EnsureAuthServer {
|
public static class EnsureAuthServer {
|
||||||
@Comment("Ensure that the first server to which players connect is an auth server")
|
@Comment("Ensure that the first server to which players connect is an auth server")
|
||||||
@ -51,11 +44,11 @@ public class ProxyConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Comment("""
|
@Comment("""
|
||||||
SendMode
|
Selection Mode of the player's initial server
|
||||||
TO_FIRST |
|
TO_FIRST | Send to the first valid server configured
|
||||||
TO_EMPTIEST_SERVE |
|
TO_EMPTIEST_SERVER | Send to the server with the lowest number of players
|
||||||
RANDOM |
|
RANDOM | Send to a random server
|
||||||
""")
|
""")
|
||||||
private SendMode sendMode = SendMode.RANDOM;
|
private SendMode sendMode = SendMode.RANDOM;
|
||||||
public SendMode sendMode() {
|
public SendMode sendMode() {
|
||||||
return this.sendMode;
|
return this.sendMode;
|
||||||
@ -79,12 +72,11 @@ public class ProxyConfiguration {
|
|||||||
return this.teleportServers;
|
return this.teleportServers;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Improve comments
|
|
||||||
@Comment("""
|
@Comment("""
|
||||||
SendMode
|
Selection Mode of the server to which the player will be sent
|
||||||
TO_FIRST |
|
TO_FIRST | Send to the first valid server configured
|
||||||
TO_EMPTIEST_SERVE |
|
TO_EMPTIEST_SERVER | Send to the server with the lowest number of players
|
||||||
RANDOM |
|
RANDOM | Send to a random server
|
||||||
""")
|
""")
|
||||||
private SendMode sendMode = SendMode.RANDOM;
|
private SendMode sendMode = SendMode.RANDOM;
|
||||||
public SendMode sendMode() {
|
public SendMode sendMode() {
|
||||||
@ -110,6 +102,21 @@ public class ProxyConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public static class Advanced {
|
||||||
|
@Comment("Enable debug mode")
|
||||||
|
private boolean debug = false;
|
||||||
|
public boolean debug() {
|
||||||
|
return this.debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Comment("Attempts to get a valid server in SendMode Random")
|
||||||
|
private int randomAttempts = 5;
|
||||||
|
public int randomAttempts() {
|
||||||
|
return this.randomAttempts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void logDebug(String msg) {
|
public void logDebug(String msg) {
|
||||||
if (config.get().debug()) {
|
if (config.get().advanced().debug()) {
|
||||||
logger.info("[DEBUG] {}", msg);
|
logger.info("[DEBUG] {}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class ConnectListener {
|
|||||||
}
|
}
|
||||||
var config = plugin.config().get();
|
var config = plugin.config().get();
|
||||||
var server = AuthmeUtils.serverToSend(
|
var server = AuthmeUtils.serverToSend(
|
||||||
config.ensureAuthServer().sendMode(), proxy, config.authServers(), config.randomAttempts());
|
config.ensureAuthServer().sendMode(), proxy, config.authServers(), config.advanced().randomAttempts());
|
||||||
|
|
||||||
// Velocity takes over in case the initial server is not present
|
// Velocity takes over in case the initial server is not present
|
||||||
event.setInitialServer(server.object());
|
event.setInitialServer(server.object());
|
||||||
|
@ -107,7 +107,7 @@ public class PluginMessageListener {
|
|||||||
var config = plugin.config().get();
|
var config = plugin.config().get();
|
||||||
|
|
||||||
var toSend = AuthmeUtils.serverToSend(
|
var toSend = AuthmeUtils.serverToSend(
|
||||||
config.sendOnLogin().sendMode(), proxy, config.authServers(), config.randomAttempts());
|
config.sendOnLogin().sendMode(), proxy, config.authServers(), config.advanced().randomAttempts());
|
||||||
|
|
||||||
if (toSend.isEmpty()) {
|
if (toSend.isEmpty()) {
|
||||||
if (toSend.string() != null) {
|
if (toSend.string() != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user