Files
src
build.gradle
manifest.kod
Code
24 1,716
src/main/java/com/antispoof/AntiSpoofPlugin.java
package com.antispoof;

import com.antispoof.action.ActionManager;
import com.antispoof.alert.AlertManager;
import com.antispoof.command.AntiSpoofCommand;
import com.antispoof.config.ConfigManager;
import com.antispoof.engine.BrandChannelEngine;
import com.antispoof.engine.DeepProbeEngine;
import com.antispoof.engine.ModSignatureDatabase;
import com.antispoof.engine.ProtocolAnomalyDetector;
import com.antispoof.fingerprint.IdentityLinker;
import com.antispoof.listener.PlayerConnectionListener;
import com.antispoof.listener.ClientBrandListener;
import com.antispoof.placeholder.AntiSpoofExpansion;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class AntiSpoofPlugin extends JavaPlugin {
    private ConfigManager configManager;
    private ModSignatureDatabase modDatabase;
    private DeepProbeEngine deepProbeEngine;
    private BrandChannelEngine brandChannelEngine;
    private ProtocolAnomalyDetector anomalyDetector;
    private IdentityLinker identityLinker;
    private ActionManager actionManager;
    private AlertManager alertManager;
    
    @Override
    public void onEnable() {
        this.configManager = new ConfigManager(this);
        this.configManager.loadConfigs();
        
        this.modDatabase = new ModSignatureDatabase(this);
        this.modDatabase.loadSignatures();
        
        this.deepProbeEngine = new DeepProbeEngine(this);
        this.brandChannelEngine = new BrandChannelEngine(this);
        this.anomalyDetector = new ProtocolAnomalyDetector(this);
        this.identityLinker = new IdentityLinker(this);
        this.actionManager = new ActionManager(this);
        this.alertManager = new AlertManager(this);
        
        Bukkit.getMessenger().registerIncomingPluginChannel(this, "minecraft:brand", new ClientBrandListener(this));
        Bukkit.getMessenger().registerOutgoingPluginChannel(this, "minecraft:brand");
        
        Bukkit.getMessenger().registerIncomingPluginChannel(this, "MC|Brand", new ClientBrandListener(this));
        Bukkit.getMessenger().registerOutgoingPluginChannel(this, "MC|Brand");
        
        Bukkit.getPluginManager().registerEvents(new PlayerConnectionListener(this), this);
        
        getCommand("antispoof").setExecutor(new AntiSpoofCommand(this));
        
        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new AntiSpoofExpansion(this).register();
        }
        
        getLogger().info("AntiSpoofPro enabled successfully");
        getLogger().info("Loaded " + modDatabase.getSignatureCount() + " mod signatures");
    }
    
    @Override
    public void onDisable() {
        if (identityLinker != null) {
            identityLinker.saveData();
        }
        
        Bukkit.getMessenger().unregisterIncomingPluginChannel(this);
        Bukkit.getMessenger().unregisterOutgoingPluginChannel(this);
        
        getLogger().info("AntiSpoofPro disabled");
    }
}