mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +00:00
Compare commits
6
Commits
1.9.4-PRE1
...
1.9.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c91ec7ba4 | ||
|
|
abff433510 | ||
|
|
fad298086c | ||
|
|
8b413a382a | ||
|
|
1428b55591 | ||
|
|
a84b573fa8 |
No files matched your search
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
||||||
<artifactId>AntiCheatReloaded</artifactId>
|
<artifactId>AntiCheatReloaded</artifactId>
|
||||||
<version>1.9.4-PRE</version>
|
<version>1.9.4</version>
|
||||||
<name>AntiCheatReloaded</name>
|
<name>AntiCheatReloaded</name>
|
||||||
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -78,8 +78,9 @@ public class AntiCheatReloaded extends JavaPlugin {
|
|||||||
eventList.add(new VehicleListener());
|
eventList.add(new VehicleListener());
|
||||||
eventList.add(new InventoryListener());
|
eventList.add(new InventoryListener());
|
||||||
// Handles 1.9+ potion effects
|
// Handles 1.9+ potion effects
|
||||||
if (!VersionUtil.isBountifulUpdate())
|
if (!VersionUtil.isBountifulUpdate()) {
|
||||||
eventList.add(new PotionEffectListener());
|
eventList.add(new PotionEffectListener());
|
||||||
|
}
|
||||||
// Order is important in some cases, don't screw with these unless
|
// Order is important in some cases, don't screw with these unless
|
||||||
// needed, especially config
|
// needed, especially config
|
||||||
this.setupConfig();
|
this.setupConfig();
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class SpeedCheck {
|
|||||||
if (VersionUtil.isSlowFalling(player))
|
if (VersionUtil.isSlowFalling(player))
|
||||||
predict *= 1.25D;
|
predict *= 1.25D;
|
||||||
// Prevent NoSlow
|
// Prevent NoSlow
|
||||||
if (movementManager.blockingTicks > 2 && movementManager.airTicks > 2)
|
if (movementManager.blockingTicks > 3 && movementManager.airTicks > 2)
|
||||||
predict *= 0.8D;
|
predict *= 0.8D;
|
||||||
if (movementManager.blockingTicks > 10 && movementManager.airTicks > 2)
|
if (movementManager.blockingTicks > 10 && movementManager.airTicks > 2)
|
||||||
predict *= 0.5D;
|
predict *= 0.5D;
|
||||||
@@ -141,7 +141,7 @@ public class SpeedCheck {
|
|||||||
double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725
|
double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725
|
||||||
// Slight increase when boxed in
|
// Slight increase when boxed in
|
||||||
if (boxedIn)
|
if (boxedIn)
|
||||||
limit *= 1.05D;
|
limit *= 1.08D;
|
||||||
// Adjust for speed effects
|
// Adjust for speed effects
|
||||||
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||||
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
|
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
|
||||||
@@ -168,10 +168,11 @@ public class SpeedCheck {
|
|||||||
// This happens naturally
|
// This happens naturally
|
||||||
if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
|
if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
|
||||||
double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default
|
double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default
|
||||||
// 0.42
|
|
||||||
if (distanceXZ >= minimumDistXZ) {
|
if (distanceXZ >= minimumDistXZ || movementManager.lastDistanceXZ >= minimumDistXZ) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "JumpBehaviour",
|
return new CheckResult(CheckResult.Result.FAILED, "JumpBehaviour",
|
||||||
"had unexpected jumping behaviour");
|
"had unexpected jumping behaviour (dXZ=" + Utilities.roundDouble(distanceXZ, 4) + ", lXZ="
|
||||||
|
+ Utilities.roundDouble(movementManager.lastDistanceXZ, 4) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+144
-140
@@ -16,7 +16,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.command.executors;
|
package com.rammelkast.anticheatreloaded.command.executors;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -25,8 +24,8 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||||
@@ -38,153 +37,158 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
|
|||||||
|
|
||||||
public class CommandReport extends CommandBase {
|
public class CommandReport extends CommandBase {
|
||||||
|
|
||||||
private static final String NAME = "AntiCheatReloaded Reports";
|
private static final String NAME = "AntiCheatReloaded Reports";
|
||||||
private static final String COMMAND = "report";
|
private static final String COMMAND = "report";
|
||||||
private static final String USAGE = "anticheat report [group/user]";
|
private static final String USAGE = "anticheat report [group/user]";
|
||||||
private static final Permission PERMISSION = Permission.SYSTEM_REPORT;
|
private static final Permission PERMISSION = Permission.SYSTEM_REPORT;
|
||||||
private static final String[] HELP = {
|
private static final String[] HELP = {
|
||||||
GRAY + "Use: " + GOLD + "/anticheat report [group]" + GRAY + " to see all users in a given group",
|
GRAY + "Use: " + GOLD + "/anticheat report [group]" + GRAY + " to see all users in a given group",
|
||||||
GRAY + "Use: " + GOLD + "/anticheat report [user]" + GRAY + " to see a single user's report",
|
GRAY + "Use: " + GOLD + "/anticheat report [user]" + GRAY + " to see a single user's report",
|
||||||
GRAY + "Use: " + GOLD + "/anticheat report [user/group] [num]" + GRAY + " to see pages of a report",
|
GRAY + "Use: " + GOLD + "/anticheat report [user/group] [num]" + GRAY + " to see pages of a report", };
|
||||||
};
|
|
||||||
|
|
||||||
public CommandReport() {
|
public CommandReport() {
|
||||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(CommandSender cs, String[] args) {
|
protected void execute(CommandSender cs, String[] args) {
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
int page = 1;
|
int page = 1;
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
if (Utilities.isInt(args[1])) {
|
if (Utilities.isInt(args[1])) {
|
||||||
page = Integer.parseInt(args[1]);
|
page = Integer.parseInt(args[1]);
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[1]);
|
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("low".equalsIgnoreCase(args[0])) {
|
if ("low".equalsIgnoreCase(args[0])) {
|
||||||
groupReport(cs, null, page);
|
groupReport(cs, null, page);
|
||||||
}
|
} else if ("all".equalsIgnoreCase(args[0])) {
|
||||||
else if ("all".equalsIgnoreCase(args[0])) {
|
cs.sendMessage(GREEN + "Low: " + WHITE + USER_MANAGER.getUsersInGroup(null).size() + " players");
|
||||||
cs.sendMessage(GREEN + "Low: " + WHITE + USER_MANAGER.getUsersInGroup(null).size() + " players");
|
for (Group g : CONFIG.getGroups().getGroups()) {
|
||||||
for (Group g : CONFIG.getGroups().getGroups()) {
|
int numPlayers = USER_MANAGER.getUsersInGroup(g).size();
|
||||||
int numPlayers = USER_MANAGER.getUsersInGroup(g).size();
|
cs.sendMessage(g.getColor() + g.getName() + WHITE + ": " + numPlayers + " players");
|
||||||
cs.sendMessage(g.getColor() + g.getName() + WHITE + ": " + numPlayers + " players");
|
}
|
||||||
}
|
cs.sendMessage(GRAY + "Use " + GOLD + "/anticheat report [group]" + GRAY
|
||||||
cs.sendMessage(GRAY + "Use " + GOLD + "/anticheat report [group]" + GRAY + " for a list of players in each group.");
|
+ " for a list of players in each group.");
|
||||||
} else {
|
} else {
|
||||||
// Test groups
|
// Test groups
|
||||||
for (Group group : CONFIG.getGroups().getGroups()) {
|
for (Group group : CONFIG.getGroups().getGroups()) {
|
||||||
if (group.getName().equalsIgnoreCase(args[0]) || "low".equalsIgnoreCase(args[0]) || "all".equalsIgnoreCase(args[0])) {
|
if (group.getName().equalsIgnoreCase(args[0]) || "low".equalsIgnoreCase(args[0])
|
||||||
groupReport(cs, group, page);
|
|| "all".equalsIgnoreCase(args[0])) {
|
||||||
return;
|
groupReport(cs, group, page);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Player targetPlayer = Bukkit.getPlayer(args[0]);
|
|
||||||
if (targetPlayer == null) {
|
|
||||||
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test users
|
@SuppressWarnings("deprecation")
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
|
||||||
if (player.getUniqueId().equals(Bukkit.getPlayer(args[0]).getUniqueId())) {
|
if (targetPlayer == null) {
|
||||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||||
playerReport(cs, user, page);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Neither of these
|
User user = AntiCheatReloaded.getManager().getUserManager().getUser(targetPlayer.getUniqueId());
|
||||||
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
if (user != null) {
|
||||||
}
|
playerReport(cs, user, page);
|
||||||
} else {
|
return;
|
||||||
sendHelp(cs);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void groupReport(CommandSender cs, Group group, int page) {
|
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||||
List<User> users = USER_MANAGER.getUsersInGroup(group);
|
}
|
||||||
ChatColor color = group == null ? GREEN : group.getColor();
|
} else {
|
||||||
String groupName = group == null ? "Low" : group.getName();
|
sendHelp(cs);
|
||||||
int pages = (int) Math.ceil(((float) users.size()) / 7);
|
}
|
||||||
if (page <= pages && page > 0) {
|
}
|
||||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------");
|
|
||||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
|
||||||
for (int x = 0; x < 7; x++) {
|
|
||||||
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
|
||||||
if (index < users.size()) {
|
|
||||||
String player = users.get(index).getName();
|
|
||||||
cs.sendMessage(GRAY + player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cs.sendMessage(MENU_END);
|
|
||||||
} else {
|
|
||||||
if (pages == 0) {
|
|
||||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
|
|
||||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
|
||||||
cs.sendMessage(GRAY + "There are no users in this group.");
|
|
||||||
cs.sendMessage(MENU_END);
|
|
||||||
} else {
|
|
||||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void playerReport(CommandSender cs, User user, int page) {
|
private void groupReport(CommandSender cs, Group group, int page) {
|
||||||
List<CheckType> types = new ArrayList<CheckType>();
|
List<User> users = USER_MANAGER.getUsersInGroup(group);
|
||||||
for (CheckType type : CheckType.values()) {
|
ChatColor color = group == null ? GREEN : group.getColor();
|
||||||
if (type.getUses(user.getUUID()) > 0) {
|
String groupName = group == null ? "Low" : group.getName();
|
||||||
types.add(type);
|
int pages = (int) Math.ceil(((float) users.size()) / 7);
|
||||||
}
|
if (page <= pages && page > 0) {
|
||||||
}
|
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
|
||||||
|
+ "]----------------------");
|
||||||
|
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||||
|
for (int x = 0; x < 7; x++) {
|
||||||
|
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
||||||
|
if (index < users.size()) {
|
||||||
|
String player = users.get(index).getName();
|
||||||
|
cs.sendMessage(GRAY + player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cs.sendMessage(MENU_END);
|
||||||
|
} else {
|
||||||
|
if (pages == 0) {
|
||||||
|
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
|
||||||
|
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||||
|
cs.sendMessage(GRAY + "There are no users in this group.");
|
||||||
|
cs.sendMessage(MENU_END);
|
||||||
|
} else {
|
||||||
|
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UUID uuid = user.getUUID();
|
private void playerReport(CommandSender cs, User user, int page) {
|
||||||
String name = user.getName();
|
List<CheckType> types = new ArrayList<CheckType>();
|
||||||
int pages = (int) Math.ceil(((float) types.size()) / 6);
|
for (CheckType type : CheckType.values()) {
|
||||||
|
if (type.getUses(user.getUUID()) > 0) {
|
||||||
|
types.add(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Group group = user.getGroup();
|
UUID uuid = user.getUUID();
|
||||||
String groupString = GREEN + "Low";
|
String name = user.getName();
|
||||||
|
int pages = (int) Math.ceil(((float) types.size()) / 6);
|
||||||
|
|
||||||
if (group != null) {
|
Group group = user.getGroup();
|
||||||
groupString = group.getColor() + group.getName();
|
String groupString = GREEN + "Low";
|
||||||
}
|
|
||||||
groupString += " (" + user.getLevel() + ")";
|
|
||||||
|
|
||||||
if (page <= pages && page > 0) {
|
if (group != null) {
|
||||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------");
|
groupString = group.getColor() + group.getName();
|
||||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
}
|
||||||
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"));
|
groupString += " (" + user.getLevel() + ")";
|
||||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
|
||||||
for (int x = 0; x < 6; x++) {
|
if (page <= pages && page > 0) {
|
||||||
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
|
||||||
if (index < types.size()) {
|
+ "]----------------------");
|
||||||
CheckType type = types.get(index);
|
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||||
int use = type.getUses(uuid);
|
int ping = user.getPing();
|
||||||
ChatColor color = WHITE;
|
cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
|
||||||
if (use >= 20) {
|
: (WHITE + "" + ping + "ms "
|
||||||
color = YELLOW;
|
+ (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
|
||||||
} else if (use > 50) {
|
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||||
color = RED;
|
for (int x = 0; x < 6; x++) {
|
||||||
}
|
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
||||||
cs.sendMessage(GRAY + type.getName() + ": " + color + use);
|
if (index < types.size()) {
|
||||||
}
|
CheckType type = types.get(index);
|
||||||
}
|
int use = type.getUses(uuid);
|
||||||
cs.sendMessage(MENU_END);
|
ChatColor color = WHITE;
|
||||||
} else {
|
if (use >= 20) {
|
||||||
if (pages == 0 && page == 1) {
|
color = YELLOW;
|
||||||
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
|
} else if (use > 50) {
|
||||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
color = RED;
|
||||||
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"));
|
}
|
||||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
cs.sendMessage(GRAY + type.getName() + ": " + color + use);
|
||||||
cs.sendMessage(GRAY + "This user has not failed any checks.");
|
}
|
||||||
cs.sendMessage(MENU_END);
|
}
|
||||||
} else {
|
cs.sendMessage(MENU_END);
|
||||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1);
|
} else {
|
||||||
}
|
if (pages == 0 && page == 1) {
|
||||||
}
|
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
|
||||||
}
|
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||||
|
int ping = user.getPing();
|
||||||
|
cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
|
||||||
|
: (WHITE + "" + ping + "ms "
|
||||||
|
+ (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
|
||||||
|
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||||
|
cs.sendMessage(GRAY + "This user has not failed any checks.");
|
||||||
|
cs.sendMessage(MENU_END);
|
||||||
|
} else {
|
||||||
|
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,14 +40,13 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.util.BoundingBox;
|
import org.bukkit.util.BoundingBox;
|
||||||
import org.bukkit.util.NumberConversions;
|
import org.bukkit.util.NumberConversions;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||||
|
|
||||||
public final class Utilities {
|
public final class Utilities {
|
||||||
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
||||||
private static final List<Material> FOOD = new ArrayList<Material>();
|
private static final List<Material> FOOD = new ArrayList<Material>();
|
||||||
private static final List<Material> CLIMBABLE = new ArrayList<Material>();
|
private static final List<Material> CLIMBABLE = new ArrayList<Material>();
|
||||||
private static final Map<Material, Material> COMBO = new HashMap<Material, Material>();
|
private static final Map<Material, Material> COMBO = new HashMap<Material, Material>();
|
||||||
|
|
||||||
public static final Material LILY_PAD;
|
|
||||||
public static final Material COB_WEB;
|
|
||||||
|
|
||||||
public static final double JUMP_MOTION_Y = 0.41999998688697815;
|
public static final double JUMP_MOTION_Y = 0.41999998688697815;
|
||||||
|
|
||||||
@@ -188,8 +187,10 @@ public final class Utilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNearShulkerBox(Location location) {
|
public static boolean isNearShulkerBox(Location location) {
|
||||||
if (VersionUtil.isBountifulUpdate())
|
// Shulkers are 1.12+
|
||||||
|
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.COLOR_UPDATE)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return isShulkerBox(location.getBlock()) || isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH))
|
return isShulkerBox(location.getBlock()) || isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH))
|
||||||
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH))
|
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||||
|| isShulkerBox(location.getBlock().getRelative(BlockFace.EAST))
|
|| isShulkerBox(location.getBlock().getRelative(BlockFace.EAST))
|
||||||
@@ -225,7 +226,8 @@ public final class Utilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isHalfblock(Block block) {
|
public static boolean isHalfblock(Block block) {
|
||||||
if (!VersionUtil.isBountifulUpdate()) {
|
// getBoundingBox() is only available on 1.14+
|
||||||
|
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||||
BoundingBox box = block.getBoundingBox();
|
BoundingBox box = block.getBoundingBox();
|
||||||
double height = box.getMaxY() - box.getMinY();
|
double height = box.getMaxY() - box.getMinY();
|
||||||
if (height > 0.42 && height <= 0.6 && block.getType().isSolid())
|
if (height > 0.42 && height <= 0.6 && block.getType().isSolid())
|
||||||
@@ -431,10 +433,11 @@ public final class Utilities {
|
|||||||
*/
|
*/
|
||||||
public static boolean isOnLilyPad(Player player) {
|
public static boolean isOnLilyPad(Player player) {
|
||||||
Block block = player.getLocation().getBlock();
|
Block block = player.getLocation().getBlock();
|
||||||
return block.getType() == LILY_PAD || block.getRelative(BlockFace.NORTH).getType() == LILY_PAD
|
return block.getType() == XMaterial.LILY_PAD.parseMaterial()
|
||||||
|| block.getRelative(BlockFace.SOUTH).getType() == LILY_PAD
|
|| block.getRelative(BlockFace.NORTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|
||||||
|| block.getRelative(BlockFace.EAST).getType() == LILY_PAD
|
|| block.getRelative(BlockFace.SOUTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|
||||||
|| block.getRelative(BlockFace.WEST).getType() == LILY_PAD;
|
|| block.getRelative(BlockFace.EAST).getType() == XMaterial.LILY_PAD.parseMaterial()
|
||||||
|
|| block.getRelative(BlockFace.WEST).getType() == XMaterial.LILY_PAD.parseMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -458,7 +461,7 @@ public final class Utilities {
|
|||||||
return player.getLocation().getBlock().isLiquid()
|
return player.getLocation().getBlock().isLiquid()
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid()
|
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid()
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()
|
|| player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()
|
||||||
|| (!VersionUtil.isBountifulUpdate()
|
|| (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.AQUATIC_UPDATE)
|
||||||
&& (player.getLocation().getBlock().getType() == XMaterial.KELP_PLANT.parseMaterial()
|
&& (player.getLocation().getBlock().getType() == XMaterial.KELP_PLANT.parseMaterial()
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.UP)
|
|| player.getLocation().getBlock().getRelative(BlockFace.UP)
|
||||||
.getType() == XMaterial.KELP_PLANT.parseMaterial()
|
.getType() == XMaterial.KELP_PLANT.parseMaterial()
|
||||||
@@ -504,7 +507,7 @@ public final class Utilities {
|
|||||||
&& location.getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid()
|
&& location.getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid()
|
||||||
&& location.getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
|
&& location.getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a player is near a web
|
* Determine whether a player is near a web
|
||||||
*
|
*
|
||||||
@@ -520,7 +523,6 @@ public final class Utilities {
|
|||||||
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.EAST))
|
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.EAST))
|
||||||
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.WEST));
|
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.WEST));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a block is a web
|
* Determine whether a block is a web
|
||||||
@@ -529,7 +531,7 @@ public final class Utilities {
|
|||||||
* @return true if web
|
* @return true if web
|
||||||
*/
|
*/
|
||||||
public static boolean isWeb(Block block) {
|
public static boolean isWeb(Block block) {
|
||||||
return block.getType() == COB_WEB;
|
return block.getType() == XMaterial.COBWEB.parseMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -539,9 +541,11 @@ public final class Utilities {
|
|||||||
* @return true if in web
|
* @return true if in web
|
||||||
*/
|
*/
|
||||||
public static boolean isInWeb(Player player) {
|
public static boolean isInWeb(Player player) {
|
||||||
return player.getLocation().getBlock().getType() == COB_WEB
|
return player.getLocation().getBlock().getType() == XMaterial.COBWEB.parseMaterial()
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == COB_WEB
|
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == XMaterial.COBWEB
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == COB_WEB;
|
.parseMaterial()
|
||||||
|
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == XMaterial.COBWEB
|
||||||
|
.parseMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -779,7 +783,7 @@ public final class Utilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isHoneyBlock(Block block) {
|
public static boolean isHoneyBlock(Block block) {
|
||||||
if (!VersionUtil.isOfVersion("v1_15")) {
|
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.BEE_UPDATE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return block.getType() == XMaterial.HONEY_BLOCK.parseMaterial();
|
return block.getType() == XMaterial.HONEY_BLOCK.parseMaterial();
|
||||||
@@ -788,9 +792,6 @@ public final class Utilities {
|
|||||||
static {
|
static {
|
||||||
// Start 1.8.8
|
// Start 1.8.8
|
||||||
if (VersionUtil.isBountifulUpdate()) {
|
if (VersionUtil.isBountifulUpdate()) {
|
||||||
LILY_PAD = XMaterial.LILY_PAD.parseMaterial();
|
|
||||||
COB_WEB = XMaterial.COBWEB.parseMaterial();
|
|
||||||
|
|
||||||
// Start instant break materials
|
// Start instant break materials
|
||||||
INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
|
INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
|
||||||
INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial());
|
INSTANT_BREAK.add(XMaterial.REPEATER.parseMaterial());
|
||||||
@@ -807,7 +808,7 @@ public final class Utilities {
|
|||||||
INSTANT_BREAK.add(Material.DEAD_BUSH);
|
INSTANT_BREAK.add(Material.DEAD_BUSH);
|
||||||
INSTANT_BREAK.add(Material.GRASS);
|
INSTANT_BREAK.add(Material.GRASS);
|
||||||
INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial());
|
INSTANT_BREAK.add(XMaterial.TALL_GRASS.parseMaterial());
|
||||||
INSTANT_BREAK.add(LILY_PAD);
|
INSTANT_BREAK.add(XMaterial.LILY_PAD.parseMaterial());
|
||||||
INSTANT_BREAK.add(Material.MELON_STEM);
|
INSTANT_BREAK.add(Material.MELON_STEM);
|
||||||
INSTANT_BREAK.add(Material.MELON_STEM);
|
INSTANT_BREAK.add(Material.MELON_STEM);
|
||||||
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
||||||
@@ -856,10 +857,10 @@ public final class Utilities {
|
|||||||
// Start combos
|
// Start combos
|
||||||
COMBO.put(Material.SHEARS, XMaterial.WHITE_WOOL.parseMaterial());
|
COMBO.put(Material.SHEARS, XMaterial.WHITE_WOOL.parseMaterial());
|
||||||
|
|
||||||
COMBO.put(Material.IRON_SWORD, COB_WEB);
|
COMBO.put(Material.IRON_SWORD, XMaterial.COBWEB.parseMaterial());
|
||||||
COMBO.put(Material.DIAMOND_SWORD, COB_WEB);
|
COMBO.put(Material.DIAMOND_SWORD, XMaterial.COBWEB.parseMaterial());
|
||||||
COMBO.put(Material.STONE_SWORD, COB_WEB);
|
COMBO.put(Material.STONE_SWORD, XMaterial.COBWEB.parseMaterial());
|
||||||
COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), COB_WEB);
|
COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), XMaterial.COBWEB.parseMaterial());
|
||||||
// End combos
|
// End combos
|
||||||
|
|
||||||
// Start climbable
|
// Start climbable
|
||||||
@@ -871,8 +872,7 @@ public final class Utilities {
|
|||||||
// End 1.8.8
|
// End 1.8.8
|
||||||
// Start other version
|
// Start other version
|
||||||
else {
|
else {
|
||||||
LILY_PAD = Material.LILY_PAD;
|
MinecraftVersion currentVersion = MinecraftVersion.getCurrentVersion();
|
||||||
COB_WEB = Material.COBWEB;
|
|
||||||
|
|
||||||
// Start instant break materials
|
// Start instant break materials
|
||||||
INSTANT_BREAK.add(Material.COMPARATOR);
|
INSTANT_BREAK.add(Material.COMPARATOR);
|
||||||
@@ -918,14 +918,13 @@ public final class Utilities {
|
|||||||
INSTANT_BREAK.add(Material.TALL_SEAGRASS);
|
INSTANT_BREAK.add(Material.TALL_SEAGRASS);
|
||||||
INSTANT_BREAK.add(Material.WHEAT);
|
INSTANT_BREAK.add(Material.WHEAT);
|
||||||
// Start 1.14 objects
|
// Start 1.14 objects
|
||||||
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")
|
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||||
|| VersionUtil.isOfVersion("v1_16")) {
|
|
||||||
INSTANT_BREAK.add(Material.BAMBOO_SAPLING);
|
INSTANT_BREAK.add(Material.BAMBOO_SAPLING);
|
||||||
INSTANT_BREAK.add(Material.CORNFLOWER);
|
INSTANT_BREAK.add(Material.CORNFLOWER);
|
||||||
}
|
}
|
||||||
// End 1.14 objects
|
// End 1.14 objects
|
||||||
// Start 1.15 objects
|
// Start 1.15 objects
|
||||||
if (VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) {
|
if (currentVersion.isAtLeast(MinecraftVersion.BEE_UPDATE)) {
|
||||||
INSTANT_BREAK.add(Material.HONEY_BLOCK);
|
INSTANT_BREAK.add(Material.HONEY_BLOCK);
|
||||||
}
|
}
|
||||||
// End 1.15 objects
|
// End 1.15 objects
|
||||||
@@ -970,14 +969,13 @@ public final class Utilities {
|
|||||||
FOOD.add(Material.SPIDER_EYE);
|
FOOD.add(Material.SPIDER_EYE);
|
||||||
FOOD.add(Material.TROPICAL_FISH);
|
FOOD.add(Material.TROPICAL_FISH);
|
||||||
// Start 1.14 objects
|
// Start 1.14 objects
|
||||||
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")
|
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||||
|| VersionUtil.isOfVersion("v1_16")) {
|
|
||||||
FOOD.add(Material.SUSPICIOUS_STEW);
|
FOOD.add(Material.SUSPICIOUS_STEW);
|
||||||
FOOD.add(Material.SWEET_BERRIES);
|
FOOD.add(Material.SWEET_BERRIES);
|
||||||
}
|
}
|
||||||
// End 1.14 objects
|
// End 1.14 objects
|
||||||
// Start 1.15 objects
|
// Start 1.15 objects
|
||||||
if (VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) {
|
if (currentVersion.isAtLeast(MinecraftVersion.BEE_UPDATE)) {
|
||||||
FOOD.add(Material.HONEY_BOTTLE);
|
FOOD.add(Material.HONEY_BOTTLE);
|
||||||
}
|
}
|
||||||
// End 1.15 objects
|
// End 1.15 objects
|
||||||
@@ -1013,15 +1011,14 @@ public final class Utilities {
|
|||||||
CLIMBABLE.add(Material.LADDER);
|
CLIMBABLE.add(Material.LADDER);
|
||||||
CLIMBABLE.add(Material.WATER);
|
CLIMBABLE.add(Material.WATER);
|
||||||
// Start 1.14 objects
|
// Start 1.14 objects
|
||||||
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")
|
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||||
|| VersionUtil.isOfVersion("v1_16")) {
|
|
||||||
CLIMBABLE.add(Material.SCAFFOLDING);
|
CLIMBABLE.add(Material.SCAFFOLDING);
|
||||||
CLIMBABLE.add(Material.SWEET_BERRY_BUSH);
|
CLIMBABLE.add(Material.SWEET_BERRY_BUSH);
|
||||||
}
|
}
|
||||||
// End 1.14 objects
|
// End 1.14 objects
|
||||||
|
|
||||||
// Start 1.16 objects
|
// Start 1.16 objects
|
||||||
if (VersionUtil.isOfVersion("v1_16")) {
|
if (currentVersion.isAtLeast(MinecraftVersion.NETHER_UPDATE)) {
|
||||||
CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial());
|
CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial());
|
||||||
CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial());
|
CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial());
|
||||||
CLIMBABLE.add(XMaterial.WEEPING_VINES.parseMaterial());
|
CLIMBABLE.add(XMaterial.WEEPING_VINES.parseMaterial());
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.rammelkast.anticheatreloaded.util;
|
package com.rammelkast.anticheatreloaded.util;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -32,12 +31,13 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||||
|
|
||||||
public class VersionUtil {
|
public class VersionUtil {
|
||||||
|
|
||||||
private static final List<String> SUPPORTED_VERSIONS = Arrays
|
private static final List<String> SUPPORTED_VERSIONS;
|
||||||
.asList(new String[] { "v1_16", "v1_15", "v1_14", "v1_13", "v1_8_R3" });
|
private static final MinecraftVersion CURRENT_VERSION;
|
||||||
|
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
@@ -75,14 +75,14 @@ public class VersionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRiptiding(Player player) {
|
public static boolean isRiptiding(Player player) {
|
||||||
if (isBountifulUpdate()) {
|
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return player.isRiptiding();
|
return player.isRiptiding();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSlowFalling(Player player) {
|
public static boolean isSlowFalling(Player player) {
|
||||||
if (isBountifulUpdate()) {
|
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return player.hasPotionEffect(PotionEffectType.SLOW_FALLING);
|
return player.hasPotionEffect(PotionEffectType.SLOW_FALLING);
|
||||||
@@ -142,16 +142,21 @@ public class VersionUtil {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.hasPotionEffect(type))
|
if (player.hasPotionEffect(type))
|
||||||
return player.getPotionEffect(type).getAmplifier() + 1;
|
return player.getPotionEffect(type).getAmplifier() + 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSwimming(Player player) {
|
public static boolean isSwimming(Player player) {
|
||||||
if (isBountifulUpdate()) {
|
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return player.isSwimming();
|
return player.isSwimming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
SUPPORTED_VERSIONS = Arrays.asList(new String[] { "v1_16", "v1_15", "v1_14", "v1_13", "v1_12", "v1_8_R3" });
|
||||||
|
CURRENT_VERSION = MinecraftVersion.getCurrentVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user