Files
src
pom.xml
README.md
Code
9 709
src/main/java/com/serverbot247/ServerBotPlugin.java
package com.serverbot247;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
public final class ServerBotPlugin extends JavaPlugin {
private BotManager botManager;
@Override
public void onEnable() {
saveDefaultConfig();
this.botManager = new BotManager(this);
Bukkit.getPluginManager().registerEvents(new BotListener(botManager), this);
PluginCommand command = getCommand("bot");
if (command == null) {
getLogger().severe("The /bot command is missing from plugin.yml.");
getServer().getPluginManager().disablePlugin(this);
return;
}
BotCommand botCommand = new BotCommand(botManager);
command.setExecutor(botCommand);
command.setTabCompleter(botCommand);
botManager.startWatchdog();
if (getConfig().getBoolean("auto-start", true)) {
Bukkit.getScheduler().runTask(this, () -> botManager.start());
}
}
@Override
public void onDisable() {
if (botManager != null) {
botManager.stop();
}
}
}