mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +00:00
Added Geyser/Floodgate support
This commit is contained in:
1 parent
a7b8164828
commit
75f350f174
4 files changed
+70
-49
No files matched your search
@@ -21,6 +21,16 @@
|
|||||||
<id>spigot-public-repo</id>
|
<id>spigot-public-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>opencollab-snapshot-repo</id>
|
||||||
|
<url>https://repo.opencollab.dev/maven-snapshots/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||||
@@ -85,5 +95,11 @@
|
|||||||
<version>1.18.22</version>
|
<version>1.18.22</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.geysermc.floodgate</groupId>
|
||||||
|
<artifactId>api</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -48,19 +48,29 @@ import com.rammelkast.anticheatreloaded.util.UpdateManager;
|
|||||||
import com.rammelkast.anticheatreloaded.util.User;
|
import com.rammelkast.anticheatreloaded.util.User;
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public final class AntiCheatReloaded extends JavaPlugin {
|
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<UUID> MUTE_ENABLED_MODS = new ArrayList<UUID>();
|
public static final List<UUID> MUTE_ENABLED_MODS = new ArrayList<UUID>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static AntiCheatReloaded plugin;
|
private static AntiCheatReloaded plugin;
|
||||||
|
@Getter
|
||||||
private static AntiCheatManager manager;
|
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<Listener> eventList = new ArrayList<Listener>();
|
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static ProtocolManager protocolManager;
|
|
||||||
private static UpdateManager updateManager;
|
|
||||||
|
|
||||||
private double tps = -1;
|
private double tps = -1;
|
||||||
private String symbiosisMetric = "None";
|
private String symbiosisMetric = "None";
|
||||||
@@ -72,7 +82,7 @@ public final class AntiCheatReloaded extends JavaPlugin {
|
|||||||
// Create executor service
|
// Create executor service
|
||||||
// Determine thread count based on available CPU cores/threads, max of 4
|
// 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);
|
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");
|
Bukkit.getConsoleSender().sendMessage(PREFIX + ChatColor.GRAY + "Pool size is " + threads + " threads");
|
||||||
}
|
}
|
||||||
@@ -114,30 +124,37 @@ public final class AntiCheatReloaded extends JavaPlugin {
|
|||||||
// Load protocol manager
|
// Load protocol manager
|
||||||
PacketListener.load(protocolManager);
|
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();
|
updateManager = new UpdateManager();
|
||||||
|
|
||||||
// Launch TPS check
|
// Launch TPS check
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
long second;
|
long second;
|
||||||
long currentSecond;
|
long currentSecond;
|
||||||
int ticks;
|
int ticks;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
second = (System.currentTimeMillis() / 1000L);
|
second = (System.currentTimeMillis() / 1000L);
|
||||||
if (currentSecond == second) {
|
if (currentSecond == second) {
|
||||||
ticks += 1;
|
ticks += 1;
|
||||||
} else {
|
} else {
|
||||||
currentSecond = second;
|
currentSecond = second;
|
||||||
tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
|
tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
|
||||||
ticks = 1;
|
ticks = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for updates every 12 hours
|
// Check for updates every 12 hours
|
||||||
if (ticks % 864000 == 0) {
|
if (ticks % 864000 == 0) {
|
||||||
updateManager.update();
|
updateManager.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(this, 40L, 1L);
|
}.runTaskTimer(this, 40L, 1L);
|
||||||
|
|
||||||
// End tests
|
// End tests
|
||||||
verboseLog("Finished loading.");
|
verboseLog("Finished loading.");
|
||||||
@@ -189,7 +206,7 @@ public final class AntiCheatReloaded extends JavaPlugin {
|
|||||||
getServer().getScheduler().cancelTasks(this);
|
getServer().getScheduler().cancelTasks(this);
|
||||||
|
|
||||||
// Shut down executor service
|
// Shut down executor service
|
||||||
executorService.shutdown();
|
executor.shutdown();
|
||||||
|
|
||||||
// Save user levels
|
// Save user levels
|
||||||
verboseLog("Saving user levels...");
|
verboseLog("Saving user levels...");
|
||||||
@@ -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() {
|
public static String getVersion() {
|
||||||
return manager.getPlugin().getDescription().getVersion();
|
return manager.getPlugin().getDescription().getVersion();
|
||||||
}
|
}
|
||||||
@@ -263,7 +272,7 @@ public final class AntiCheatReloaded extends JavaPlugin {
|
|||||||
config = null;
|
config = null;
|
||||||
protocolManager = null;
|
protocolManager = null;
|
||||||
updateManager = null;
|
updateManager = null;
|
||||||
executorService = null;
|
executor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debugLog(final String string) {
|
public static void debugLog(final String string) {
|
||||||
@@ -286,10 +295,6 @@ public final class AntiCheatReloaded extends JavaPlugin {
|
|||||||
verbose = b;
|
verbose = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolManager getProtocolManager() {
|
|
||||||
return protocolManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amount of players kicked since start
|
* Amount of players kicked since start
|
||||||
*/
|
*/
|
||||||
@@ -300,9 +305,9 @@ public final class AntiCheatReloaded extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates metric that checks for anti-cheat symbiosis
|
* Creates metric that checks for anti-cheat symbiosis I use this to see if
|
||||||
* I use this to see if AntiCheatReloaded is actively being used
|
* AntiCheatReloaded is actively being used together with other anti-cheats, so
|
||||||
* together with other anti-cheats, so I can account for that.
|
* I can account for that.
|
||||||
*/
|
*/
|
||||||
protected void checkForSymbiosis() {
|
protected void checkForSymbiosis() {
|
||||||
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
||||||
@@ -363,14 +368,6 @@ public final class AntiCheatReloaded extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UpdateManager getUpdateManager() {
|
|
||||||
return updateManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ExecutorService getExecutor() {
|
|
||||||
return executorService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTPS() {
|
public double getTPS() {
|
||||||
return Math.min(Math.max(this.tps, 0.0D), 20.0D);
|
return Math.min(Math.max(this.tps, 0.0D), 20.0D);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ import java.util.UUID;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
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.check.CheckType;
|
||||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
@@ -136,6 +138,11 @@ public final class CheckManager {
|
|||||||
* @param type The check
|
* @param type The check
|
||||||
*/
|
*/
|
||||||
public boolean isExempt(final Player player, final CheckType type) {
|
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;
|
return exemptList.containsKey(player.getUniqueId()) ? exemptList.get(player.getUniqueId()).contains(type) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
name: AntiCheatReloaded
|
name: AntiCheatReloaded
|
||||||
author: Rammelkast
|
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
|
main: com.rammelkast.anticheatreloaded.AntiCheatReloaded
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
depend: [ProtocolLib]
|
depend: [ProtocolLib]
|
||||||
|
softdepend: [Floodgate]
|
||||||
startup: postworld
|
startup: postworld
|
||||||
version: ${project.build.version}
|
version: ${project.build.version}
|
||||||
commands:
|
commands:
|
||||||
|
|||||||
Reference in new issue
Block a user