BungeeCord Plugin
AutoStopQueuePlugin
Create a velocity minecraft plugin for 1.21.11 that automaticly stops servers with no players online. If someone wants to connect it needs to start the server and set that player in a queue
src/main/java/eu/codexe/autostopqueueplugin/AutoStopQueuePlugin.java
package eu.codexe.autostopqueueplugin;
import com.google.inject.Inject;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ProxyServer;
import org.slf4j.Logger;
@Plugin(
id = "autostopqueueplugin",
name = "AutoStopQueuePlugin",
version = "1.0.0",
description = "Stops empty servers and queues players while backend servers start.",
authors = {"Codexe"}
)
public final class AutoStopQueuePlugin {
private final ProxyServer server;
private final Logger logger;
private final PluginConfiguration configuration;
private final ServerRegistry serverRegistry;
private final QueueManager queueManager;
private final BackendController backendController;
private final PlayerRoutingListener listener;
private final QueueCommand queueCommand;
private final StopCommand stopCommand;
private final StatusCommand statusCommand;
@Inject
public AutoStopQueuePlugin(ProxyServer server, Logger logger) {
this.server = server;
this.logger = logger;
this.configuration = new PluginConfiguration();
this.serverRegistry = new ServerRegistry();
this.queueManager = new QueueManager(server, logger, configuration, serverRegistry);
this.backendController = new BackendController(server, logger, configuration, serverRegistry, queueManager);
this.listener = new PlayerRoutingListener(server, logger, configuration, serverRegistry, queueManager, backendController);
this.queueCommand = new QueueCommand(queueManager);
this.stopCommand = new StopCommand(serverRegistry, backendController, queueManager);
this.statusCommand = new StatusCommand(serverRegistry, backendController, queueManager);
}
@Subscribe
public void onProxyInitialize(ProxyInitializeEvent event) {
configuration.load();
server.getEventManager().register(this, listener);
server.getCommandManager().register(server.getCommandManager().metaBuilder("queue").plugin(this).build(), queueCommand);
server.getCommandManager().register(server.getCommandManager().metaBuilder("stopserver").plugin(this).build(), stopCommand);
server.getCommandManager().register(server.getCommandManager().metaBuilder("serverstatus").plugin(this).build(), statusCommand);
backendController.startSweepTask();
logger.info("AutoStopQueuePlugin loaded.");
}
}