Boosters/velocity/src/main/java/com/alttd/vboosters/VelocityBoosters.java

96 lines
3.0 KiB
Java
Raw Normal View History

2021-11-04 16:57:55 +00:00
package com.alttd.vboosters;
2021-09-06 17:35:04 +00:00
2021-12-25 17:05:07 +00:00
import com.alttd.boosterapi.BoosterAPI;
import com.alttd.boosterapi.BoosterImplementation;
import com.alttd.boosterapi.util.ALogger;
2021-11-04 16:57:55 +00:00
import com.alttd.vboosters.commands.BoosterCommand;
import com.alttd.vboosters.commands.DonorRankCommand;
2021-11-04 16:57:55 +00:00
import com.alttd.vboosters.listeners.PluginMessageListener;
2021-12-25 17:05:07 +00:00
import com.alttd.vboosters.managers.BoosterManager;
import com.alttd.vboosters.storage.VelocityBoosterStorage;
2021-09-06 17:35:04 +00:00
import com.google.inject.Inject;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
2021-12-25 17:05:07 +00:00
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
2021-09-06 17:35:04 +00:00
import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import org.slf4j.Logger;
// TODO use the version created in build.gradle.kts
@Plugin(id = "boosterplugin", name = "BoosterPlugin", version = "1.0.0",
description = "Easily manage all boosters on the Altitude Minecraft Server Network.",
authors = {"destro174", "teri"},
2021-11-04 16:57:55 +00:00
dependencies = {@Dependency(id = "luckperms"),@Dependency(id = "proxydiscordlink")}
2021-09-06 17:35:04 +00:00
)
public class VelocityBoosters {
private static VelocityBoosters plugin;
private final ProxyServer server;
private final Logger logger;
2021-12-25 17:05:07 +00:00
private BoosterAPI boosterAPI;
private BoosterManager boosterManager;
2021-09-06 17:35:04 +00:00
private ChannelIdentifier channelIdentifier = MinecraftChannelIdentifier.from("altitude:boosterplugin");
@Inject
public VelocityBoosters(ProxyServer proxyServer, Logger proxyLogger) {
plugin = this;
server = proxyServer;
logger = proxyLogger;
}
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
2021-12-25 17:05:07 +00:00
ALogger.init(logger);
boosterAPI = new BoosterImplementation();
boosterManager = new BoosterManager(this);
2021-09-06 17:35:04 +00:00
server.getChannelRegistrar().register(channelIdentifier);
server.getEventManager().register(this, new PluginMessageListener(channelIdentifier));
loadCommands();
2022-08-05 20:17:53 +00:00
reloadConfig();
VelocityBoosterStorage.getVelocityBoosterStorage(); //this loads the boosters in
2021-09-06 17:35:04 +00:00
}
2021-12-25 17:05:07 +00:00
@Subscribe
public void onShutdown(ProxyShutdownEvent event) {
boosterManager.saveAllBoosters();
}
public void reloadConfig() {
boosterAPI.reloadConfig();
}
2021-09-06 17:35:04 +00:00
public static VelocityBoosters getPlugin() {
return plugin;
}
public Logger getLogger() {
return logger;
}
public ProxyServer getProxy() {
return server;
}
public void loadCommands() {
// all (proxy)commands go here
2021-11-04 16:57:55 +00:00
new BoosterCommand(server);
new DonorRankCommand(server);
2021-09-06 17:35:04 +00:00
}
public ChannelIdentifier getChannelIdentifier() {
return channelIdentifier;
}
2021-12-25 17:05:07 +00:00
public BoosterManager getBoosterManager() {
return boosterManager;
}
2021-09-06 17:35:04 +00:00
}