SteamWar/BungeeCore
Archiviert
13
2

Commits vergleichen

...
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.

1 Commits

Autor SHA1 Nachricht Datum
yoyosource
b79e22b4e1 Add Initial setup
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
2023-02-20 12:14:31 +01:00
5 geänderte Dateien mit 59 neuen und 8 gelöschten Zeilen

@ -1 +1 @@
Subproject commit 89b0c14da664589a7c9699d73bf72028cdf9dd0d
Subproject commit aa70f423d87e9f6534ad2dd1f20a5122179c423f

Datei anzeigen

@ -96,7 +96,8 @@ dependencies {
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
compileOnly 'de.steamwar:waterfall:RELEASE'
compileOnly 'de.steamwar:persistentbungeecore:RELEASE'
// compileOnly 'de.steamwar:persistentbungeecore:RELEASE'
compileOnly files('libs/persistentbungeecore.jar')
implementation("net.dv8tion:JDA:4.4.0_352") {
exclude module: 'opus-java'
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore;
import de.steamwar.bungeecore.listeners.ConnectionListener;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ProxyServer;
@ -27,6 +28,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.stream.Collectors;
public abstract class Node {
@ -49,6 +51,7 @@ public abstract class Node {
for(Node node : nodes) {
if(node.belowLoadLimit)
return node;
ConnectionListener.cleanup(node);
}
return null;
}

Datei anzeigen

@ -265,6 +265,8 @@ public class ServerStarter {
Subserver subserver = constructor.construct(serverName, port, node.startServer(
serverJar, directory, worldDir, worldName, port, xmx, arguments.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).toArray(String[]::new)
), worldCleanup);
Storage.serverToNodeMap.put(subserver, node.getName());
Storage.nodeToServerMap.computeIfAbsent(node.getName(), s -> new ArrayList<>()).add(subserver);
for(ProxiedPlayer p : playersToSend)
SubserverSystem.sendPlayer(subserver, p);

Datei anzeigen

@ -19,10 +19,7 @@
package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import de.steamwar.bungeecore.bot.util.DiscordRanks;
import de.steamwar.bungeecore.commands.ChallengeCommand;
@ -32,6 +29,7 @@ import de.steamwar.bungeecore.commands.MsgCommand;
import de.steamwar.bungeecore.listeners.mods.Utils;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.UserGroup;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.AbstractReconnectHandler;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
@ -44,6 +42,7 @@ import net.md_5.bungee.api.event.ServerKickEvent;
import net.md_5.bungee.event.EventHandler;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class ConnectionListener extends BasicListener {
@ -141,8 +140,49 @@ public class ConnectionListener extends BasicListener {
ModCommand.playerFilterType.remove(e.getPlayer());
}
{
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
Node.forEach(node -> {
if (!node.belowLoadLimit()) cleanup(node);
});
}, 0, 1, TimeUnit.MINUTES);
}
private static final Set<Node> currentlyCleaning = new HashSet<>();
public static void cleanup(Node node) {
synchronized (currentlyCleaning) {
if (currentlyCleaning.contains(node)) return;
currentlyCleaning.add(node);
}
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
try {
List<Subserver> subservers = Storage.nodeToServerMap.get(node.getName());
if (subservers == null) return;
Subserver oldest = null;
long oldestTime = Long.MAX_VALUE;
for (Subserver subserver : subservers) {
long time = Storage.timeOfServerEmpty.get(subserver);
if (time < oldestTime) {
oldest = subserver;
oldestTime = time;
}
}
if (oldest == null) return;
oldest.stop();
} finally {
synchronized (currentlyCleaning) {
currentlyCleaning.remove(node);
}
}
});
}
@EventHandler
public void onServerDisconnect(ServerDisconnectEvent e){
Storage.timeOfServerEmpty.remove(Subserver.getSubserver(e.getPlayer().getServer().getInfo()));
ServerInfo server = e.getTarget();
Subserver subserver = Subserver.getSubserver(server);
if(subserver == null)
@ -150,7 +190,12 @@ public class ConnectionListener extends BasicListener {
ProxiedPlayer player = e.getPlayer();
Collection<ProxiedPlayer> players = server.getPlayers();
if(players.isEmpty() || (players.size() == 1 && players.contains(player)))
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), subserver::waitForTermination);
if(players.isEmpty() || (players.size() == 1 && players.contains(player))) {
if (subserver instanceof Bauserver || subserver instanceof Builderserver) {
Storage.timeOfServerEmpty.put(subserver, System.currentTimeMillis());
} else {
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), subserver::waitForTermination);
}
}
}
}