Files
src
build.gradle
manifest.kod
Code
21 1,842
src/main/java/com/denail/anticheat/DenailAntiCheat.java
package com.denail.anticheat;
import com.denail.anticheat.command.DenailCommand;
import com.denail.anticheat.detection.*;
import com.denail.anticheat.listener.*;
import com.denail.anticheat.manager.LogManager;
import com.denail.anticheat.manager.ViolationManager;
import com.denail.anticheat.manager.ConfigManager;
import com.denail.anticheat.packet.PacketManager;
import com.tcoded.folialib.FoliaLib;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class DenailAntiCheat extends JavaPlugin {
private FoliaLib foliaLib;
private ConfigManager configManager;
private ViolationManager violationManager;
private LogManager logManager;
private PacketManager packetManager;
private XRayDetection xrayDetection;
private FreeCamDetection freeCamDetection;
private ESPDetection espDetection;
private AutoTotemDetection autoTotemDetection;
private boolean pluginEnabled;
@Override
public void onEnable() {
this.foliaLib = new FoliaLib(this);
initializeManagers();
initializeDetectionModules();
registerListeners();
registerCommands();
this.pluginEnabled = configManager.isEnabled();
foliaLib.getScheduler().runLater(() -> {
Bukkit.getOnlinePlayers().forEach(packetManager::injectPlayer);
}, 40L);
logManager.log("DenailAntiCheat v" + getDescription().getVersion() + " has been enabled!");
getLogger().info("Advanced protection systems initialized successfully");
getLogger().info("FreeCam: Packet-level obfuscation active");
getLogger().info("X-Ray: Fake ore injection enabled");
getLogger().info("Auto-Totem: Per-type enforcement (1st=log, 2nd=kick, 3rd+=ban)");
getLogger().info("ESP: Entity tracking detection active");
}
@Override
public void onDisable() {
if (packetManager != null) {
packetManager.uninjectAll();
}
if (foliaLib != null) {
foliaLib.getScheduler().cancelAllTasks();
}
if (logManager != null) {
logManager.log("DenailAntiCheat has been disabled");
logManager.saveLog();
}
if (violationManager != null) {
violationManager.clearAll();
}
getLogger().info("DenailAntiCheat has been disabled");
}
private void initializeManagers() {
this.configManager = new ConfigManager(this);
this.violationManager = new ViolationManager(this);
this.logManager = new LogManager(this);
this.packetManager = new PacketManager(this);
}
private void initializeDetectionModules() {
this.xrayDetection = new XRayDetection(this);
this.freeCamDetection = new FreeCamDetection(this);
this.espDetection = new ESPDetection(this);
this.autoTotemDetection = new AutoTotemDetection(this);
}
private void registerListeners() {
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new BlockBreakListener(this), this);
pm.registerEvents(new PlayerMoveListener(this), this);
pm.registerEvents(new EntityDamageListener(this), this);
pm.registerEvents(new PlayerInteractListener(this), this);
}
private void registerCommands() {
getCommand("denail").setExecutor(new DenailCommand(this));
}
public void reload() {
configManager.reload();
this.pluginEnabled = configManager.isEnabled();
violationManager.clearAll();
xrayDetection.reload();
freeCamDetection.reload();
espDetection.reload();
autoTotemDetection.reload();
logManager.log("Configuration reloaded");
}
public void toggle() {
this.pluginEnabled = !this.pluginEnabled;
logManager.log("DenailAntiCheat " + (pluginEnabled ? "enabled" : "disabled"));
}
}