forked from git-mirrors/GeyserConnect
Add a setting for enabling a hard player cap
This commit is contained in:
parent
b0698284b3
commit
56b9fe7619
3 changed files with 15 additions and 2 deletions
|
@ -75,8 +75,16 @@ public class PacketHandler extends UpstreamPacketHandler {
|
||||||
public PacketSignal handle(SetLocalPlayerAsInitializedPacket packet) {
|
public PacketSignal handle(SetLocalPlayerAsInitializedPacket packet) {
|
||||||
geyserConnect.logger().debug("Player initialized: " + Utils.displayName(session));
|
geyserConnect.logger().debug("Player initialized: " + Utils.displayName(session));
|
||||||
|
|
||||||
|
// Check to see if the server is full and we have a hard player cap
|
||||||
|
if (geyserConnect.config().hardPlayerLimit()) {
|
||||||
|
if (session.getGeyser().getSessionManager().size() > session.getGeyser().getConfig().getMaxPlayers()) {
|
||||||
|
session.disconnect("disconnectionScreen.serverFull");
|
||||||
|
return PacketSignal.HANDLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Handle the virtual host if specified
|
// Handle the virtual host if specified
|
||||||
VirtualHostSection vhost = GeyserConnect.instance().config().vhost();
|
VirtualHostSection vhost = geyserConnect.config().vhost();
|
||||||
if (vhost.enabled()) {
|
if (vhost.enabled()) {
|
||||||
String domain = session.getClientData().getServerAddress().split(":")[0];
|
String domain = session.getClientData().getServerAddress().split(":")[0];
|
||||||
if (!domain.equals(vhost.baseDomain()) && domain.endsWith("." + vhost.baseDomain())) {
|
if (!domain.equals(vhost.baseDomain()) && domain.endsWith("." + vhost.baseDomain())) {
|
||||||
|
@ -104,7 +112,7 @@ public class PacketHandler extends UpstreamPacketHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log the virtual host usage
|
// Log the virtual host usage
|
||||||
GeyserConnect.instance().logger().info(Utils.displayName(session) + " is using virtualhost: " + address + ":" + port + (!online ? " (offline)" : ""));
|
geyserConnect.logger().info(Utils.displayName(session) + " is using virtualhost: " + address + ":" + port + (!online ? " (offline)" : ""));
|
||||||
|
|
||||||
// Send the player to the wanted server
|
// Send the player to the wanted server
|
||||||
Utils.sendToServer(session, originalPacketHandler, new Server(address, port, online, false, null, null, null));
|
Utils.sendToServer(session, originalPacketHandler, new Server(address, port, online, false, null, null, null));
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.List;
|
||||||
|
|
||||||
public record Config(
|
public record Config(
|
||||||
@JsonProperty("welcome-file") String welcomeFile,
|
@JsonProperty("welcome-file") String welcomeFile,
|
||||||
|
@JsonProperty("hard-player-limit") boolean hardPlayerLimit,
|
||||||
List<Server> servers,
|
List<Server> servers,
|
||||||
@JsonProperty("custom-servers") CustomServersSection customServers,
|
@JsonProperty("custom-servers") CustomServersSection customServers,
|
||||||
VirtualHostSection vhost) {
|
VirtualHostSection vhost) {
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
# This is loaded live so will update without a server restart
|
# This is loaded live so will update without a server restart
|
||||||
welcome-file: welcome.txt
|
welcome-file: welcome.txt
|
||||||
|
|
||||||
|
# Enabled hard max player limit
|
||||||
|
# This will kick players if the server is full
|
||||||
|
hard-player-limit: false
|
||||||
|
|
||||||
# A global list of servers sent to all clients
|
# A global list of servers sent to all clients
|
||||||
servers:
|
servers:
|
||||||
- name: The Hive
|
- name: The Hive
|
||||||
|
|
Loading…
Add table
Reference in a new issue