58 lines
1.3 KiB
Java
58 lines
1.3 KiB
Java
package fi.jonttu.woovelocity;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import com.google.inject.Inject;
|
|
import com.moandjiezana.toml.Toml;
|
|
import com.velocitypowered.api.event.Subscribe;
|
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
|
import com.velocitypowered.api.proxy.ProxyServer;
|
|
|
|
import fi.jonttu.woovelocity.util.Config;
|
|
import fi.jonttu.woovelocity.util.Connector;
|
|
|
|
public class WooVelocity {
|
|
|
|
private static WooVelocity instance;
|
|
|
|
public static WooVelocity getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
private final ProxyServer server;
|
|
private final Logger logger;
|
|
private Toml config;
|
|
|
|
public ProxyServer getServer() {
|
|
return this.server;
|
|
}
|
|
|
|
public Logger getLogger() {
|
|
return this.logger;
|
|
}
|
|
|
|
public Toml getConfig() {
|
|
return this.config;
|
|
}
|
|
|
|
@Inject
|
|
public WooVelocity(ProxyServer server, Logger logger) {
|
|
instance = this;
|
|
this.server = server;
|
|
this.logger = logger;
|
|
}
|
|
|
|
@Subscribe
|
|
public void proxyInitialize(ProxyInitializeEvent event) {
|
|
|
|
this.config = Config.loadConfig();
|
|
|
|
this.server.getScheduler().buildTask(this, new Runnable() {
|
|
public void run() {
|
|
Connector.update();
|
|
}
|
|
})
|
|
.repeat(config.getLong("config.update_interval"), TimeUnit.SECONDS)
|
|
.schedule();
|
|
|
|
}
|
|
|
|
}
|