diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java
index f56a4c7..2e10c4f 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java
@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.UUID;
import org.bukkit.Material;
+import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
@@ -67,9 +68,14 @@ public class SpeedCheck {
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION();
}
} else if (player.isSprinting()) {
- reason = "while sprinting ";
- max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT();
- }
+ if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().name().endsWith("ICE")) {
+ reason = "while sprinting on ice ";
+ max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT() + 0.165D;
+ } else {
+ reason = "while sprinting ";
+ max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT();
+ }
+ }
float speed = player.getWalkSpeed();
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java
index 8fc2035..4463ed9 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java
@@ -65,7 +65,11 @@ public class CommandBase {
if (permission.get(cs)) {
execute(cs, args);
} else {
- cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")");
+ if (args == null) {
+ cs.sendMessage(GOLD + "" + ChatColor.BOLD + "AntiCheatReloaded " + GRAY + "version " + AntiCheatReloaded.getVersion());
+ } else {
+ cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")");
+ }
}
}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java
index f2f9965..d3d7ec2 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java
@@ -33,6 +33,7 @@ import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
import com.rammelkast.anticheatreloaded.command.executors.CommandReload;
import com.rammelkast.anticheatreloaded.command.executors.CommandReport;
import com.rammelkast.anticheatreloaded.command.executors.CommandReset;
+import com.rammelkast.anticheatreloaded.command.executors.CommandVersion;
public class CommandHandler implements CommandExecutor {
@@ -46,6 +47,7 @@ public class CommandHandler implements CommandExecutor {
commands.add(new CommandReload());
commands.add(new CommandReport());
commands.add(new CommandReset());
+ commands.add(new CommandVersion());
}
@Override
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandVersion.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandVersion.java
new file mode 100644
index 0000000..5138863
--- /dev/null
+++ b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandVersion.java
@@ -0,0 +1,58 @@
+/*
+ * 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 .
+ */
+
+package com.rammelkast.anticheatreloaded.command.executors;
+
+import org.bukkit.ChatColor;
+import org.bukkit.command.CommandSender;
+
+import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
+import com.rammelkast.anticheatreloaded.command.CommandBase;
+import com.rammelkast.anticheatreloaded.util.Permission;
+import com.rammelkast.anticheatreloaded.util.UpdateManager;
+
+public class CommandVersion extends CommandBase {
+
+ private static final String NAME = "AntiCheatReloaded Version";
+ private static final String COMMAND = "version";
+ private static final String USAGE = "anticheat version";
+ private static final Permission PERMISSION = Permission.SYSTEM_NOTICE;
+ private static final String[] HELP = {
+ GRAY + "Use: " + AQUA + "/anticheat version" + GRAY + " to get update information", };
+
+ public CommandVersion() {
+ super(NAME, COMMAND, USAGE, HELP, PERMISSION);
+ }
+
+ @Override
+ protected void execute(CommandSender cs, String[] args) {
+ UpdateManager updateManager = AntiCheatReloaded.getUpdateManager();
+ String status = RED + "behind";
+ if (updateManager.isLatest()) {
+ if (updateManager.isAhead()) {
+ status = GREEN + "ahead";
+ } else {
+ status = GOLD + "up-to-date";
+ }
+ }
+ cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "You are running version " + GOLD
+ + updateManager.getCurrentVersion() + GRAY + ". The latest version is " + GOLD
+ + updateManager.getLatestVersion() + GRAY + ". This means you are " + status + GRAY + ".");
+ }
+}
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java
index 2793ee6..afe2416 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java
@@ -29,7 +29,7 @@ public enum Permission {
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_BLINK, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT,
/* System Nodes */
- SYSTEM_LOG, SYSTEM_RESET, SYSTEM_SPY, SYSTEM_HELP, SYSTEM_UPDATE, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,
+ SYSTEM_LOG, SYSTEM_RESET, SYSTEM_SPY, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,
SYSTEM_CALIBRATE, SYSTEM_CHECK, SYSTEM_DEBUG, SYSTEM_RELOAD;
private static final String PERMISSION_ALL = "anticheat.*";
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/UpdateManager.java b/src/main/java/com/rammelkast/anticheatreloaded/util/UpdateManager.java
index c8ae1e0..56b4a55 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/util/UpdateManager.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/util/UpdateManager.java
@@ -35,11 +35,13 @@ public class UpdateManager {
private final String latestVersion;
private final boolean isLatest;
+ private final boolean isAhead;
public UpdateManager() {
this.latestVersion = this.getOnlineData(SPIGOT_VERSION_URL);
if (this.latestVersion == null) {
this.isLatest = true;
+ this.isAhead = false;
return;
}
@@ -50,6 +52,7 @@ public class UpdateManager {
splitCompare = currentSplit.compareTo(newSplit);
} catch (Exception e) {}
this.isLatest = splitCompare >= 0;
+ this.isAhead = splitCompare > 0;
}
private String getOnlineData(String url) {
@@ -64,9 +67,8 @@ public class UpdateManager {
builder.append((char) readChar);
}
data = builder.toString();
- } catch (IOException exception) {
- // TODO possibly handle this neatly?
- } finally {
+ } catch (IOException exception) {}
+ finally {
if (stream != null) {
try {
stream.close();
@@ -80,35 +82,43 @@ public class UpdateManager {
public boolean isLatest() {
return this.isLatest;
}
+
+ public boolean isAhead() {
+ return this.isAhead;
+ }
+
+ public String getCurrentVersion() {
+ return AntiCheatReloaded.getVersion();
+ }
public String getLatestVersion() {
return this.latestVersion;
}
public class VersionSplit implements Comparable {
- private final int major, sub, minor;
+ private final int major, minor, build;
public VersionSplit(String version) throws Exception {
if (version.endsWith("-ALPHA")) {
version = version.substring(0, version.length() - 6);
}
- String[] versionSplit = version.split(".");
+ String[] versionSplit = version.split("\\.");
if (versionSplit.length != 3) {
// Illegal version
- throw new Exception("Illegal version!");
+ throw new Exception("Version " + version + " is illegal!");
}
try {
int major = Integer.parseInt(versionSplit[0]);
- int sub = Integer.parseInt(versionSplit[1]);
- int minor = Integer.parseInt(versionSplit[2]);
+ int minor = Integer.parseInt(versionSplit[1]);
+ int build = Integer.parseInt(versionSplit[2]);
if (major <= 0) {
throw new Exception("Illegal version!");
}
this.major = major;
- this.sub = sub;
this.minor = minor;
+ this.build = build;
} catch (Exception e) {
throw new Exception("Illegal version!");
}
@@ -116,43 +126,38 @@ public class UpdateManager {
@Override
public int compareTo(VersionSplit other) {
+ if (other.major == this.major) {
+ if (other.minor == this.minor) {
+ if (other.build == this.build) {
+ return 0;
+ }
+ if (other.build > this.build) {
+ return -1;
+ }
+ return 1;
+ }
+ if (other.minor > this.minor) {
+ return -1;
+ }
+ return 1;
+ }
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;
+ return 1;
}
public int getMajor() {
return major;
}
- public int getSub() {
- return sub;
- }
-
public int getMinor() {
return minor;
}
+
+ public int getBuild() {
+ return build;
+ }
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index cf8c4f5..8263d7b 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -36,7 +36,7 @@ permissions:
description: Access reloading the system
anticheat.system.reset:
description: Access resetting a player's cheat level
- anticheat.system.update:
+ anticheat.system.version:
description: Access information about whether the system is updated
anticheat.system.calibrate:
description: Access the calibration system