mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +00:00
Added GhostHand and Unicode chat check and fixed broken fly check.
Furthermore: + Updated and documented magic.yml + Added support for missing CAVE_AIR material + Average ping for blink check can now be configured + Removed /acr update from help command + Added UpdateManager.java to be used in future update messages + Better MainHand/OffHand support I've been busy :)
This commit is contained in:
1 parent
acea36929b
commit
fec1286c8d
22 files changed
+596
-193
No files matched your search
@@ -23,10 +23,10 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
public enum Permission {
|
||||
/* Check Nodes */
|
||||
CHECK_ZOMBE_FLY, CHECK_ZOMBE_NOCLIP, CHECK_ZOMBE_CHEAT, CHECK_FLIGHT, CHECK_ELYTRA, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
|
||||
CHECK_FLIGHT, CHECK_ELYTRA, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
|
||||
CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP,
|
||||
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_FORCEFIELD, CHECK_LONGREACH,
|
||||
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_BLINK, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_UNICODE,
|
||||
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_FORCEFIELD, CHECK_LONGREACH, CHECK_UNICODE,
|
||||
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_BLINK, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_GHOSTHAND,
|
||||
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_SPY, SYSTEM_HELP, SYSTEM_UPDATE, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2020 Rammelkast
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
|
||||
public class UpdateManager {
|
||||
|
||||
public static final int RESOURCE_ID = 23799;
|
||||
public static final String SPIGOT_VERSION_URL = "https://api.spigotmc.org/legacy/update.php?resource="
|
||||
+ RESOURCE_ID;
|
||||
|
||||
private final String latestVersion;
|
||||
private final boolean isLatest;
|
||||
|
||||
public UpdateManager() {
|
||||
this.latestVersion = this.getOnlineData(SPIGOT_VERSION_URL);
|
||||
if (this.latestVersion == null) {
|
||||
this.isLatest = true;
|
||||
return;
|
||||
}
|
||||
|
||||
int splitCompare = 0;
|
||||
try {
|
||||
VersionSplit currentSplit = new VersionSplit(AntiCheatReloaded.getVersion());
|
||||
VersionSplit newSplit = new VersionSplit(this.latestVersion);
|
||||
splitCompare = currentSplit.compareTo(newSplit);
|
||||
} catch (Exception e) {}
|
||||
this.isLatest = splitCompare >= 0;
|
||||
}
|
||||
|
||||
private String getOnlineData(String url) {
|
||||
String data = null;
|
||||
InputStream stream = null;
|
||||
try {
|
||||
stream = new URL(url).openStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int readChar;
|
||||
while ((readChar = reader.read()) != -1) {
|
||||
builder.append((char) readChar);
|
||||
}
|
||||
data = builder.toString();
|
||||
} catch (IOException exception) {
|
||||
// TODO possibly handle this neatly?
|
||||
} finally {
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public boolean isLatest() {
|
||||
return this.isLatest;
|
||||
}
|
||||
|
||||
public String getLatestVersion() {
|
||||
return this.latestVersion;
|
||||
}
|
||||
|
||||
public class VersionSplit implements Comparable<VersionSplit> {
|
||||
private final int major, sub, minor;
|
||||
|
||||
public VersionSplit(String version) throws Exception {
|
||||
if (version.endsWith("-ALPHA")) {
|
||||
version = version.substring(0, version.length() - 6);
|
||||
}
|
||||
|
||||
String[] versionSplit = version.split(".");
|
||||
if (versionSplit.length != 3) {
|
||||
// Illegal version
|
||||
throw new Exception("Illegal version!");
|
||||
}
|
||||
|
||||
try {
|
||||
int major = Integer.parseInt(versionSplit[0]);
|
||||
int sub = Integer.parseInt(versionSplit[1]);
|
||||
int minor = Integer.parseInt(versionSplit[2]);
|
||||
if (major <= 0) {
|
||||
throw new Exception("Illegal version!");
|
||||
}
|
||||
this.major = major;
|
||||
this.sub = sub;
|
||||
this.minor = minor;
|
||||
} catch (Exception e) {
|
||||
throw new Exception("Illegal version!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(VersionSplit other) {
|
||||
if (other.major > this.major) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (other.major < this.major) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (other.sub > this.sub) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (other.sub < this.sub) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (other.minor > this.minor) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (other.minor < this.minor) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public int getSub() {
|
||||
return sub;
|
||||
}
|
||||
|
||||
public int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public final class Utilities {
|
||||
public static boolean cantStandAtSingle(Block block) {
|
||||
// TODO: Implement Better to reduce false positives (done? lets test...)
|
||||
Block otherBlock = block.getLocation().add(0, -0.5, 0).getBlock();
|
||||
boolean center = otherBlock.getType() == Material.AIR;
|
||||
boolean center = otherBlock.getType() == Material.AIR || otherBlock.getType() == Material.CAVE_AIR;
|
||||
return center;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public final class Utilities {
|
||||
* @return true if the player can stand here
|
||||
*/
|
||||
public static boolean canStand(Block block) {
|
||||
return !(block.isLiquid() || block.getType() == Material.AIR);
|
||||
return !(block.isLiquid() || block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@ public final class Utilities {
|
||||
public static boolean isHoveringOverWater(Location player, int blocks) {
|
||||
for (int i = player.getBlockY(); i > player.getBlockY() - blocks; i--) {
|
||||
Block newloc = (new Location(player.getWorld(), player.getBlockX(), i, player.getBlockZ())).getBlock();
|
||||
if (newloc.getType() != Material.AIR) {
|
||||
if (newloc.getType() != Material.AIR && newloc.getType() != Material.CAVE_AIR) {
|
||||
return newloc.isLiquid();
|
||||
}
|
||||
}
|
||||
@@ -417,7 +417,7 @@ public final class Utilities {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -434,7 +434,7 @@ public final class Utilities {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,5 +74,5 @@ public class VersionUtil {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user