Files
src
manifest.kod
README.md
Code
12 1,714
src/main/java/com/outstudio/security/OutStudioSecurity.java
package com.outstudio.security;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
import java.nio.file.Path;
public final class OutStudioSecurity extends JavaPlugin {
private SecurityDatabase database;
private EmailService emailService;
private AuthManager authManager;
@Override
public void onEnable() {
saveDefaultConfig();
try {
String databaseFile = getConfig().getString("database.file", "security.db");
Path configuredPath = Path.of(databaseFile);
Path databasePath = configuredPath.isAbsolute()
? configuredPath
: getDataFolder().toPath().resolve(configuredPath);
database = new SecurityDatabase(databasePath);
emailService = new EmailService(this);
authManager = new AuthManager(this, database, emailService);
Bukkit.getPluginManager().registerEvents(new AuthListener(this, authManager), this);
PluginCommand command = getCommand("outsecurity");
if (command == null) {
throw new IllegalStateException("The outsecurity command is missing from plugin.yml");
}
AuthCommand authCommand = new AuthCommand(this, database, authManager);
command.setExecutor(authCommand);
command.setTabCompleter(authCommand);
getLogger().info("OUT STUDIO Security enabled with SQLite storage.");
} catch (Exception exception) {
getLogger().severe("Could not initialize OUT STUDIO Security: " + exception.getMessage());
exception.printStackTrace();
Bukkit.getPluginManager().disablePlugin(this);
}
}
@Override
public void onDisable() {
if (database != null) {
try {
database.close();
} catch (Exception exception) {
getLogger().severe("Could not close the SQLite database: " + exception.getMessage());
}
}
}
public AuthManager getAuthManager() {
return authManager;
}
}