diff --git a/pom.xml b/pom.xml
index 1bd4fbb..d8e03c1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,16 @@
spigot-public-repo
https://hub.spigotmc.org/nexus/content/repositories/public/
+
+ opencollab-snapshot-repo
+ https://repo.opencollab.dev/maven-snapshots/
+
+ false
+
+
+ true
+
+
${basedir}/src/main/java
@@ -85,5 +95,11 @@
1.18.22
provided
+
+ org.geysermc.floodgate
+ api
+ 2.0-SNAPSHOT
+ provided
+
\ No newline at end of file
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java
index 17690b9..8fb6bae 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java
@@ -48,35 +48,45 @@ import com.rammelkast.anticheatreloaded.util.UpdateManager;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
+import lombok.Getter;
+
public final class AntiCheatReloaded extends JavaPlugin {
- public static final String PREFIX = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY;
+ public static final String PREFIX = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> "
+ + ChatColor.GRAY;
public static final List MUTE_ENABLED_MODS = new ArrayList();
-
+
+ @Getter
private static AntiCheatReloaded plugin;
+ @Getter
private static AntiCheatManager manager;
- private static ExecutorService executorService;
+ @Getter
+ private static ExecutorService executor;
+ @Getter
+ private static ProtocolManager protocolManager;
+ @Getter
+ private static UpdateManager updateManager;
+ @Getter
+ private static boolean floodgateEnabled;
private static List eventList = new ArrayList();
private static Configuration config;
private static boolean verbose;
- private static ProtocolManager protocolManager;
- private static UpdateManager updateManager;
-
+
private double tps = -1;
private String symbiosisMetric = "None";
@Override
public void onLoad() {
plugin = this;
-
+
// Create executor service
// Determine thread count based on available CPU cores/threads, max of 4
final int threads = Math.max(Math.min(Runtime.getRuntime().availableProcessors() / 4, 4), 1);
- executorService = Executors.newFixedThreadPool(threads);
+ executor = Executors.newFixedThreadPool(threads);
{
Bukkit.getConsoleSender().sendMessage(PREFIX + ChatColor.GRAY + "Pool size is " + threads + " threads");
}
-
+
// Check for ProtocolLib
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null) {
Bukkit.getConsoleSender().sendMessage(PREFIX + ChatColor.RED
@@ -85,11 +95,11 @@ public final class AntiCheatReloaded extends JavaPlugin {
return;
}
}
-
+
@Override
public void onEnable() {
manager = new AntiCheatManager(this, getLogger());
-
+
eventList.add(new PlayerListener());
eventList.add(new BlockListener());
eventList.add(new EntityListener());
@@ -105,7 +115,7 @@ public final class AntiCheatReloaded extends JavaPlugin {
restoreLevels();
// Setup ProtocolLib hooks
setupProtocol();
-
+
Bukkit.getConsoleSender()
.sendMessage(PREFIX + ChatColor.GRAY + "Running Minecraft version " + VersionUtil.getVersion() + " "
+ (VersionUtil.isSupported() ? (ChatColor.GREEN + "(supported)")
@@ -113,35 +123,42 @@ public final class AntiCheatReloaded extends JavaPlugin {
// Load protocol manager
PacketListener.load(protocolManager);
-
+
+ // Check for Floodgate
+ if (Bukkit.getPluginManager().getPlugin("Floodgate") != null) {
+ floodgateEnabled = true;
+ Bukkit.getConsoleSender().sendMessage(PREFIX + ChatColor.WHITE + "Floodgate support enabled");
+ }
+
+ // Create update manager
updateManager = new UpdateManager();
-
+
// Launch TPS check
new BukkitRunnable() {
- long second;
- long currentSecond;
- int ticks;
+ long second;
+ long currentSecond;
+ int ticks;
+
+ public void run() {
+ second = (System.currentTimeMillis() / 1000L);
+ if (currentSecond == second) {
+ ticks += 1;
+ } else {
+ currentSecond = second;
+ tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
+ ticks = 1;
+ }
+
+ // Check for updates every 12 hours
+ if (ticks % 864000 == 0) {
+ updateManager.update();
+ }
+ }
+ }.runTaskTimer(this, 40L, 1L);
- public void run() {
- second = (System.currentTimeMillis() / 1000L);
- if (currentSecond == second) {
- ticks += 1;
- } else {
- currentSecond = second;
- tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
- ticks = 1;
- }
-
- // Check for updates every 12 hours
- if (ticks % 864000 == 0) {
- updateManager.update();
- }
- }
- }.runTaskTimer(this, 40L, 1L);
-
// End tests
verboseLog("Finished loading.");
-
+
// Metrics
getServer().getScheduler().runTaskLater(this, new Runnable() {
@Override
@@ -187,10 +204,10 @@ public final class AntiCheatReloaded extends JavaPlugin {
public void onDisable() {
// Cancel all running tasks
getServer().getScheduler().cancelTasks(this);
-
+
// Shut down executor service
- executorService.shutdown();
-
+ executor.shutdown();
+
// Save user levels
verboseLog("Saving user levels...");
if (config != null) {
@@ -244,14 +261,6 @@ public final class AntiCheatReloaded extends JavaPlugin {
}
}
- public static AntiCheatReloaded getPlugin() {
- return plugin;
- }
-
- public static AntiCheatManager getManager() {
- return manager;
- }
-
public static String getVersion() {
return manager.getPlugin().getDescription().getVersion();
}
@@ -263,9 +272,9 @@ public final class AntiCheatReloaded extends JavaPlugin {
config = null;
protocolManager = null;
updateManager = null;
- executorService = null;
+ executor = null;
}
-
+
public static void debugLog(final String string) {
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
public void run() {
@@ -285,11 +294,7 @@ public final class AntiCheatReloaded extends JavaPlugin {
public void setVerbose(boolean b) {
verbose = b;
}
-
- public static ProtocolManager getProtocolManager() {
- return protocolManager;
- }
-
+
/**
* Amount of players kicked since start
*/
@@ -300,9 +305,9 @@ public final class AntiCheatReloaded extends JavaPlugin {
}
/**
- * Creates metric that checks for anti-cheat symbiosis
- * I use this to see if AntiCheatReloaded is actively being used
- * together with other anti-cheats, so I can account for that.
+ * Creates metric that checks for anti-cheat symbiosis I use this to see if
+ * AntiCheatReloaded is actively being used together with other anti-cheats, so
+ * I can account for that.
*/
protected void checkForSymbiosis() {
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
@@ -352,7 +357,7 @@ public final class AntiCheatReloaded extends JavaPlugin {
public static void sendToMainThread(final Runnable runnable) {
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
}
-
+
public void sendToStaff(final String message) {
Bukkit.getOnlinePlayers().forEach(player -> {
if (player.hasPermission("anticheat.system.alert")) {
@@ -362,17 +367,9 @@ public final class AntiCheatReloaded extends JavaPlugin {
}
});
}
-
- public static UpdateManager getUpdateManager() {
- return updateManager;
- }
-
- public static ExecutorService getExecutor() {
- return executorService;
- }
-
+
public double getTPS() {
return Math.min(Math.max(this.tps, 0.0D), 20.0D);
}
-
+
}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java b/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java
index feddf0a..ca69cb8 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java
@@ -28,7 +28,9 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
+import org.geysermc.floodgate.api.FloodgateApi;
+import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
@@ -136,6 +138,11 @@ public final class CheckManager {
* @param type The check
*/
public boolean isExempt(final Player player, final CheckType type) {
+ if (AntiCheatReloaded.isFloodgateEnabled()) {
+ if (FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) {
+ return true;
+ }
+ }
return exemptList.containsKey(player.getUniqueId()) ? exemptList.get(player.getUniqueId()).contains(type) : false;
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 94be273..5b1f5fb 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,9 +1,10 @@
name: AntiCheatReloaded
author: Rammelkast
-description: AntiCheatReloaded helps easily identify and block malicious users on your server.
+description: AntiCheatReloaded helps easily identify and block malicious players on your server.
main: com.rammelkast.anticheatreloaded.AntiCheatReloaded
api-version: 1.13
depend: [ProtocolLib]
+softdepend: [Floodgate]
startup: postworld
version: ${project.build.version}
commands: