Compare commits

...
6 Commits
6 changed files with 195 additions and 187 deletions

No files matched your search

+1 -1
View File
@@ -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) + ")");
} }
} }
} }
@@ -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]); @SuppressWarnings("deprecation")
if (targetPlayer == null) { OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]); if (targetPlayer == null) {
return; cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
} return;
}
// Test users User user = AntiCheatReloaded.getManager().getUserManager().getUser(targetPlayer.getUniqueId());
for (Player player : Bukkit.getOnlinePlayers()) { if (user != null) {
if (player.getUniqueId().equals(Bukkit.getPlayer(args[0]).getUniqueId())) { playerReport(cs, user, page);
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); return;
playerReport(cs, user, page); }
return;
}
}
// Neither of these cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]); }
} } else {
} else { sendHelp(cs);
sendHelp(cs); }
} }
}
private void groupReport(CommandSender cs, Group group, int page) { private void groupReport(CommandSender cs, Group group, int page) {
List<User> users = USER_MANAGER.getUsersInGroup(group); List<User> users = USER_MANAGER.getUsersInGroup(group);
ChatColor color = group == null ? GREEN : group.getColor(); ChatColor color = group == null ? GREEN : group.getColor();
String groupName = group == null ? "Low" : group.getName(); String groupName = group == null ? "Low" : group.getName();
int pages = (int) Math.ceil(((float) users.size()) / 7); int pages = (int) Math.ceil(((float) users.size()) / 7);
if (page <= pages && page > 0) { if (page <= pages && page > 0) {
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------"); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
cs.sendMessage(GRAY + "Group: " + color + groupName); + "]----------------------");
for (int x = 0; x < 7; x++) { cs.sendMessage(GRAY + "Group: " + color + groupName);
int index = ((page - 1) * 6) + (x + ((page - 1) * 1)); for (int x = 0; x < 7; x++) {
if (index < users.size()) { int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
String player = users.get(index).getName(); if (index < users.size()) {
cs.sendMessage(GRAY + player); String player = users.get(index).getName();
} cs.sendMessage(GRAY + player);
} }
cs.sendMessage(MENU_END); }
} else { cs.sendMessage(MENU_END);
if (pages == 0) { } else {
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------"); if (pages == 0) {
cs.sendMessage(GRAY + "Group: " + color + groupName); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
cs.sendMessage(GRAY + "There are no users in this group."); cs.sendMessage(GRAY + "Group: " + color + groupName);
cs.sendMessage(MENU_END); cs.sendMessage(GRAY + "There are no users in this group.");
} else { cs.sendMessage(MENU_END);
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages); } 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 playerReport(CommandSender cs, User user, int page) {
List<CheckType> types = new ArrayList<CheckType>(); List<CheckType> types = new ArrayList<CheckType>();
for (CheckType type : CheckType.values()) { for (CheckType type : CheckType.values()) {
if (type.getUses(user.getUUID()) > 0) { if (type.getUses(user.getUUID()) > 0) {
types.add(type); types.add(type);
} }
} }
UUID uuid = user.getUUID(); UUID uuid = user.getUUID();
String name = user.getName(); String name = user.getName();
int pages = (int) Math.ceil(((float) types.size()) / 6); int pages = (int) Math.ceil(((float) types.size()) / 6);
Group group = user.getGroup(); Group group = user.getGroup();
String groupString = GREEN + "Low"; String groupString = GREEN + "Low";
if (group != null) { if (group != null) {
groupString = group.getColor() + group.getName(); groupString = group.getColor() + group.getName();
} }
groupString += " (" + user.getLevel() + ")"; groupString += " (" + user.getLevel() + ")";
if (page <= pages && page > 0) { if (page <= pages && page > 0) {
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------"); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD
cs.sendMessage(GRAY + "Player: " + WHITE + name); + "]----------------------");
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)")); cs.sendMessage(GRAY + "Player: " + WHITE + name);
cs.sendMessage(GRAY + "Group: " + groupString); int ping = user.getPing();
for (int x = 0; x < 6; x++) { cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
int index = ((page - 1) * 5) + (x + ((page - 1))); : (WHITE + "" + ping + "ms "
if (index < types.size()) { + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
CheckType type = types.get(index); cs.sendMessage(GRAY + "Group: " + groupString);
int use = type.getUses(uuid); for (int x = 0; x < 6; x++) {
ChatColor color = WHITE; int index = ((page - 1) * 5) + (x + ((page - 1)));
if (use >= 20) { if (index < types.size()) {
color = YELLOW; CheckType type = types.get(index);
} else if (use > 50) { int use = type.getUses(uuid);
color = RED; ChatColor color = WHITE;
} if (use >= 20) {
cs.sendMessage(GRAY + type.getName() + ": " + color + use); color = YELLOW;
} } else if (use > 50) {
} color = RED;
cs.sendMessage(MENU_END); }
} else { cs.sendMessage(GRAY + type.getName() + ": " + color + use);
if (pages == 0 && page == 1) { }
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------"); }
cs.sendMessage(GRAY + "Player: " + WHITE + name); cs.sendMessage(MENU_END);
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)")); } else {
cs.sendMessage(GRAY + "Group: " + groupString); if (pages == 0 && page == 1) {
cs.sendMessage(GRAY + "This user has not failed any checks."); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
cs.sendMessage(MENU_END); cs.sendMessage(GRAY + "Player: " + WHITE + name);
} else { int ping = user.getPing();
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1); 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,15 +40,14 @@ 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()
@@ -521,7 +524,6 @@ public final class Utilities {
|| 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);
@@ -149,9 +149,14 @@ public class VersionUtil {
} }
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();
}
} }