Files
src
build.gradle
Code
19 1,025
src/main/java/com/auth/plugin/SimpleAuth.java
package com.auth.plugin;
import com.auth.plugin.command.LoginCommand;
import com.auth.plugin.command.RegisterCommand;
import com.auth.plugin.command.SetLoginSpawnCommand;
import com.auth.plugin.command.SetSpawnCommand;
import com.auth.plugin.listener.CommandPreprocessListener;
import com.auth.plugin.listener.PlayerJoinListener;
import com.auth.plugin.listener.PlayerProtectionListener;
import com.auth.plugin.listener.PlayerQuitListener;
import com.auth.plugin.manager.AuthManager;
import com.auth.plugin.manager.CaptchaManager;
import com.auth.plugin.manager.SessionManager;
import com.auth.plugin.manager.SpawnManager;
import com.auth.plugin.util.ConfigManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class SimpleAuth extends JavaPlugin {
private ConfigManager configManager;
private AuthManager authManager;
private SessionManager sessionManager;
private CaptchaManager captchaManager;
private SpawnManager spawnManager;
@Override
public void onEnable() {
this.configManager = new ConfigManager(this);
this.authManager = new AuthManager(this);
this.sessionManager = new SessionManager(this);
this.captchaManager = new CaptchaManager(this);
this.spawnManager = new SpawnManager(this);
registerCommands();
registerListeners();
getLogger().info("SimpleAuth has been enabled!");
}
@Override
public void onDisable() {
if (authManager != null) {
authManager.saveData();
}
getLogger().info("SimpleAuth has been disabled!");
}
private void registerCommands() {
getCommand("register").setExecutor(new RegisterCommand(this));
getCommand("login").setExecutor(new LoginCommand(this));
getCommand("setloginspawn").setExecutor(new SetLoginSpawnCommand(this));
getCommand("setspawn").setExecutor(new SetSpawnCommand(this));
}
private void registerListeners() {
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerJoinListener(this), this);
pm.registerEvents(new PlayerQuitListener(this), this);
pm.registerEvents(new PlayerProtectionListener(this), this);
pm.registerEvents(new CommandPreprocessListener(this), this);
}
}