Initial BungeeCord edition

This commit is contained in:
Frank van der Heijden 2020-07-04 21:30:34 +02:00
parent 4416d55173
commit 23e8e80191
No known key found for this signature in database
GPG key ID: 26DA56488D314D11
75 changed files with 1931 additions and 396 deletions

View file

@ -0,0 +1,65 @@
package net.frankheijden.serverutils.bungee;
import co.aikar.commands.BungeeCommandCompletionContext;
import co.aikar.commands.BungeeCommandManager;
import co.aikar.commands.CommandCompletions;
import net.frankheijden.serverutils.bungee.commands.CommandPlugins;
import net.frankheijden.serverutils.bungee.commands.CommandServerUtils;
import net.frankheijden.serverutils.bungee.entities.BungeePlugin;
import net.frankheijden.serverutils.bungee.entities.BungeeReflection;
import net.frankheijden.serverutils.common.ServerUtilsApp;
import net.frankheijden.serverutils.common.config.Config;
import net.frankheijden.serverutils.common.config.Messenger;
import net.frankheijden.serverutils.common.providers.PluginProvider;
import net.md_5.bungee.api.plugin.Plugin;
import org.bstats.bungeecord.Metrics;
public class ServerUtils extends Plugin {
private static ServerUtils instance;
private static final String CONFIG_RESOURCE = "bungee-config.yml";
private static final String MESSAGES_RESOURCE = "bungee-messages.yml";
private BungeePlugin plugin;
private BungeeCommandManager commandManager;
@Override
public void onEnable() {
super.onEnable();
instance = this;
this.plugin = new BungeePlugin(this);
ServerUtilsApp.init(plugin);
new Metrics(this, ServerUtilsApp.BSTATS_METRICS_ID);
new BungeeReflection();
this.commandManager = new BungeeCommandManager(this);
commandManager.registerCommand(new CommandPlugins());
commandManager.registerCommand(new CommandServerUtils());
PluginProvider<Plugin> provider = plugin.getPluginProvider();
CommandCompletions<BungeeCommandCompletionContext> commandCompletions = commandManager.getCommandCompletions();
commandCompletions.registerAsyncCompletion("plugins", context -> provider.getPluginNames());
commandCompletions.registerAsyncCompletion("pluginJars", context -> provider.getPluginFileNames());
reload();
}
public static ServerUtils getInstance() {
return instance;
}
public BungeePlugin getPlugin() {
return plugin;
}
public BungeeCommandManager getCommandManager() {
return commandManager;
}
public void reload() {
new Config("config.yml", CONFIG_RESOURCE);
new Messenger("messages.yml", MESSAGES_RESOURCE);
}
}