Files
src
pom.xml
Code
16 1,141
src/main/java/com/noman/nomanguard/NomanGuardPlugin.java
package com.noman.nomanguard;
import com.noman.nomanguard.command.NomanGuardCommand;
import com.noman.nomanguard.config.ConfigurationManager;
import com.noman.nomanguard.database.DatabaseManager;
import com.noman.nomanguard.listener.LoginListener;
import com.noman.nomanguard.service.AlertService;
import com.noman.nomanguard.service.VpnDetectionService;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Objects;
public class NomanGuardPlugin extends JavaPlugin {
private ConfigurationManager configurationManager;
private DatabaseManager databaseManager;
private AlertService alertService;
private VpnDetectionService vpnDetectionService;
@Override
public void onEnable() {
saveDefaultConfig();
configurationManager = new ConfigurationManager(this);
configurationManager.reload();
databaseManager = new DatabaseManager(this);
alertService = new AlertService(this, configurationManager);
vpnDetectionService = new VpnDetectionService(this, databaseManager, configurationManager, alertService);
getServer().getPluginManager().registerEvents(
new LoginListener(this, databaseManager, configurationManager, alertService, vpnDetectionService),
this
);
PluginCommand command = Objects.requireNonNull(getCommand("nomanguard"));
NomanGuardCommand commandExecutor = new NomanGuardCommand(this, databaseManager, configurationManager);
command.setExecutor(commandExecutor);
command.setTabCompleter(commandExecutor);
// SQLite dosyası ve şeması ana iş parçacığını durdurmadan hazırlanır.
runAsync(() -> {
try {
databaseManager.initialize();
getLogger().info("SQLite veritabanı hazır.");
} catch (Exception exception) {
getLogger().severe("SQLite veritabanı başlatılamadı: " + exception.getMessage());
}
});
}
public void runAsync(Runnable task) {
getServer().getScheduler().runTaskAsynchronously(this, task);
}
public void runSync(Runnable task) {
getServer().getScheduler().runTask(this, task);
}
public ConfigurationManager getConfigurationManager() {
return configurationManager;
}
}