Support Magic configuration from enterprise

This commit is contained in:
gravitylow committed 2014-01-27 18:47:05 -05:00
1 parent 1d67003923
commit 9c3e85dd8b
12 files changed
+445 -319

No files matched your search

@@ -20,7 +20,7 @@ package net.gravitydevelopment.anticheat.check;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.files.Lang;
import net.gravitydevelopment.anticheat.config.files.Magic;
import net.gravitydevelopment.anticheat.config.providers.Magic;
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
import net.gravitydevelopment.anticheat.util.User;
import net.gravitydevelopment.anticheat.util.Distance;
@@ -178,7 +178,7 @@ public class Backend {
float f = (float) ticks / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
f = f > 1.0F ? 1.0F : f;
if (Math.abs(force - f) > magic.BOW_ERROR) {
if (Math.abs(force - f) > magic.BOW_ERROR()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")");
} else {
return PASS;
@@ -190,12 +190,12 @@ public class Backend {
if (!projectileTime.containsKey(player.getName())) {
projectileTime.put(player.getName(), System.currentTimeMillis());
return new CheckResult(CheckResult.Result.PASSED);
} else if (projectilesShot.get(player.getName()) == magic.PROJECTILE_CHECK) {
} else if (projectilesShot.get(player.getName()) == magic.PROJECTILE_CHECK()) {
long time = System.currentTimeMillis() - projectileTime.get(player.getName());
projectileTime.remove(player.getName());
projectilesShot.remove(player.getName());
if (time < magic.PROJECTILE_TIME_MIN) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " wound up a bow too fast (actual time=" + time + ", min time=" + magic.PROJECTILE_TIME_MIN + ")");
if (time < magic.PROJECTILE_TIME_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " wound up a bow too fast (actual time=" + time + ", min time=" + magic.PROJECTILE_TIME_MIN() + ")");
}
}
return PASS;
@@ -206,12 +206,12 @@ public class Backend {
if (!blockTime.containsKey(player.getName())) {
blockTime.put(player.getName(), System.currentTimeMillis());
return new CheckResult(CheckResult.Result.PASSED);
} else if (blocksDropped.get(player.getName()) == magic.DROP_CHECK) {
} else if (blocksDropped.get(player.getName()) == magic.DROP_CHECK()) {
long time = System.currentTimeMillis() - blockTime.get(player.getName());
blockTime.remove(player.getName());
blocksDropped.remove(player.getName());
if (time < magic.DROP_TIME_MIN) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN + ")");
if (time < magic.DROP_TIME_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN() + ")");
}
}
return PASS;
@@ -223,12 +223,12 @@ public class Backend {
} else {
String string = player.getName() + " reached too far for a block";
double distance =
player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE
: magic.BLOCK_MAX_DISTANCE;
player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
: magic.BLOCK_MAX_DISTANCE();
double i = x >= distance ? x : y > distance ? y : z > distance ? z : -1;
if (i != -1) {
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE + ")");
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE() + ")");
} else {
return PASS;
}
@@ -237,16 +237,16 @@ public class Backend {
public CheckResult checkLongReachDamage(Player player, double x, double y, double z) {
String string = player.getName() + " reached too far for an entity";
double i = x >= magic.ENTITY_MAX_DISTANCE ? x : y > magic.ENTITY_MAX_DISTANCE ? y : z > magic.ENTITY_MAX_DISTANCE ? z : -1;
double i = x >= magic.ENTITY_MAX_DISTANCE() ? x : y > magic.ENTITY_MAX_DISTANCE() ? y : z > magic.ENTITY_MAX_DISTANCE() ? z : -1;
if (i != -1) {
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.ENTITY_MAX_DISTANCE + ")");
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.ENTITY_MAX_DISTANCE() + ")");
} else {
return PASS;
}
}
public CheckResult checkSpider(Player player, double y) {
if (y <= magic.LADDER_Y_MAX && y >= magic.LADDER_Y_MIN && !Utilities.isClimbableBlock(player.getLocation().getBlock())) {
if (y <= magic.LADDER_Y_MAX() && y >= magic.LADDER_Y_MIN() && !Utilities.isClimbableBlock(player.getLocation().getBlock())) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to climb a non-ladder (" + player.getLocation().getBlock().getType() + ")");
} else {
return PASS;
@@ -254,8 +254,8 @@ public class Backend {
}
public CheckResult checkYSpeed(Player player, double y) {
if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && y > magic.Y_SPEED_MAX && !isDoing(player, velocitized, magic.VELOCITY_TIME) && !player.hasPotionEffect(PotionEffectType.JUMP)) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + "'s y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX + ")");
if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && y > magic.Y_SPEED_MAX() && !isDoing(player, velocitized, magic.VELOCITY_TIME()) && !player.hasPotionEffect(PotionEffectType.JUMP)) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + "'s y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")");
} else {
return PASS;
}
@@ -272,9 +272,9 @@ public class Backend {
}
int i = nofallViolation.get(name);
if (i >= magic.NOFALL_LIMIT) {
if (i >= magic.NOFALL_LIMIT()) {
nofallViolation.put(player.getName(), 1);
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to avoid fall damage (fall distance = 0 " + i + " times in a row, max=" + magic.NOFALL_LIMIT + ")");
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to avoid fall damage (fall distance = 0 " + i + " times in a row, max=" + magic.NOFALL_LIMIT() + ")");
} else {
return PASS;
}
@@ -289,41 +289,41 @@ public class Backend {
public CheckResult checkXZSpeed(Player player, double x, double z) {
if (!isSpeedExempt(player) && player.getVehicle() == null) {
String reason = "";
double max = magic.XZ_SPEED_MAX;
double max = magic.XZ_SPEED_MAX();
if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
if (player.isSprinting()) {
reason = "on soulsand while sprinting ";
max = magic.XZ_SPEED_MAX_SOULSAND_SPRINT;
max = magic.XZ_SPEED_MAX_SOULSAND_SPRINT();
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
reason = "on soulsand with speed potion ";
max = magic.XZ_SPEED_MAX_SOULSAND_POTION;
max = magic.XZ_SPEED_MAX_SOULSAND_POTION();
} else {
reason = "on soulsand ";
max = magic.XZ_SPEED_MAX_SOULSAND;
max = magic.XZ_SPEED_MAX_SOULSAND();
}
} else if (player.isFlying()) {
reason = "while flying ";
max = magic.XZ_SPEED_MAX_FLY;
max = magic.XZ_SPEED_MAX_FLY();
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
if (player.isSprinting()) {
reason = "with speed potion while sprinting ";
max = magic.XZ_SPEED_MAX_POTION_SPRINT;
max = magic.XZ_SPEED_MAX_POTION_SPRINT();
} else {
reason = "with speed potion ";
max = magic.XZ_SPEED_MAX_POTION;
max = magic.XZ_SPEED_MAX_POTION();
}
} else if (player.isSprinting()) {
reason = "while sprinting ";
max = magic.XZ_SPEED_MAX_SPRINT;
max = magic.XZ_SPEED_MAX_SPRINT();
}
float speed = player.getWalkSpeed();
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
if (x > max || z > max) {
int num = this.increment(player, speedViolation, magic.SPEED_MAX);
if (num >= magic.SPEED_MAX) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + "'s speed was too high " + reason + num + " times in a row (max=" + magic.SPEED_MAX + ", speed=" + (x > z ? x : z) + ", max speed=" + max + ")");
int num = this.increment(player, speedViolation, magic.SPEED_MAX());
if (num >= magic.SPEED_MAX()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + "'s speed was too high " + reason + num + " times in a row (max=" + magic.SPEED_MAX() + ", speed=" + (x > z ? x : z) + ", max speed=" + max + ")");
} else {
return PASS;
}
@@ -338,9 +338,9 @@ public class Backend {
public CheckResult checkSneak(Player player, double x, double z) {
if (player.isSneaking() && !player.isFlying() && !isMovingExempt(player) && !player.isInsideVehicle()) {
double i = x > magic.XZ_SPEED_MAX_SNEAK ? x : z > magic.XZ_SPEED_MAX_SNEAK ? z : -1;
double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
if (i != -1) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK + ")");
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
} else {
return PASS;
}
@@ -351,8 +351,8 @@ public class Backend {
public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) {
Player player = event.getPlayer();
if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN + ")");
if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")");
} else {
return PASS;
}
@@ -375,9 +375,9 @@ public class Backend {
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
boolean b;
if (!Utilities.sprintFly(player)) {
b = x > magic.XZ_SPEED_MAX_WATER || z > magic.XZ_SPEED_MAX_WATER;
b = x > magic.XZ_SPEED_MAX_WATER() || z > magic.XZ_SPEED_MAX_WATER();
} else {
b = x > magic.XZ_SPEED_MAX_WATER_SPRINT || z > magic.XZ_SPEED_MAX_WATER_SPRINT;
b = x > magic.XZ_SPEED_MAX_WATER_SPRINT() || z > magic.XZ_SPEED_MAX_WATER_SPRINT();
}
if (!b && !Utilities.isFullyInWater(player.getLocation()) && Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D && !block.getType().equals(Material.WATER_LILY)) {
b = true;
@@ -385,7 +385,7 @@ public class Backend {
if (b) {
if (waterSpeedViolation.containsKey(player.getName())) {
int v = waterSpeedViolation.get(player.getName());
if (v >= magic.WATER_SPEED_VIOLATION_MAX) {
if (v >= magic.WATER_SPEED_VIOLATION_MAX()) {
waterSpeedViolation.put(player.getName(), 0);
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " stood on water " + v + " times (can't stand on " + block.getType() + " or " + block.getRelative(BlockFace.DOWN).getType() + ")");
} else {
@@ -407,7 +407,7 @@ public class Backend {
} else if (block.getRelative(BlockFace.DOWN).isLiquid() && isAscending(player) && Utilities.cantStandAt(block) && Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) {
if (waterAscensionViolation.containsKey(player.getName())) {
int v = waterAscensionViolation.get(player.getName());
if (v >= magic.WATER_ASCENSION_VIOLATION_MAX) {
if (v >= magic.WATER_ASCENSION_VIOLATION_MAX()) {
waterAscensionViolation.put(player.getName(), 0);
} else {
waterAscensionViolation.put(player.getName(), v + 1);
@@ -443,7 +443,7 @@ public class Backend {
}
public CheckResult checkYAxis(Player player, Distance distance) {
if (distance.getYDifference() > magic.TELEPORT_MIN || distance.getYDifference() < 0) {
if (distance.getYDifference() > magic.TELEPORT_MIN() || distance.getYDifference() < 0) {
return PASS;
}
if (!isMovingExempt(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && !Utilities.isClimbableBlock(player.getLocation().add(0, -1, 0).getBlock()) && !player.isInsideVehicle() && !Utilities.isInWater(player) && !hasJumpPotion(player)) {
@@ -456,7 +456,7 @@ public class Backend {
yAxisLastViolation.put(name, 0L);
lastYtime.put(name, System.currentTimeMillis());
} else {
if (y1 > lastYcoord.get(name) && yAxisViolations.get(name) > magic.Y_MAXVIOLATIONS && (System.currentTimeMillis() - yAxisLastViolation.get(name)) < magic.Y_MAXVIOTIME) {
if (y1 > lastYcoord.get(name) && yAxisViolations.get(name) > magic.Y_MAXVIOLATIONS() && (System.currentTimeMillis() - yAxisLastViolation.get(name)) < magic.Y_MAXVIOTIME()) {
Location g = player.getLocation();
yAxisViolations.put(name, yAxisViolations.get(name) + 1);
yAxisLastViolation.put(name, System.currentTimeMillis());
@@ -467,16 +467,16 @@ public class Backend {
player.teleport(g);
}
}
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis " + yAxisViolations.get(name) + " times (max =" + magic.Y_MAXVIOLATIONS + ")");
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis " + yAxisViolations.get(name) + " times (max =" + magic.Y_MAXVIOLATIONS() + ")");
} else {
if (yAxisViolations.get(name) > magic.Y_MAXVIOLATIONS && (System.currentTimeMillis() - yAxisLastViolation.get(name)) > magic.Y_MAXVIOTIME) {
if (yAxisViolations.get(name) > magic.Y_MAXVIOLATIONS() && (System.currentTimeMillis() - yAxisLastViolation.get(name)) > magic.Y_MAXVIOTIME()) {
yAxisViolations.put(name, 0);
yAxisLastViolation.put(name, 0L);
}
}
long i = System.currentTimeMillis() - lastYtime.get(name);
double diff = magic.Y_MAXDIFF + (Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) ? 0.5 : 0.0);
if ((y1 - lastYcoord.get(name)) > diff && i < magic.Y_TIME) {
double diff = magic.Y_MAXDIFF() + (Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) ? 0.5 : 0.0);
if ((y1 - lastYcoord.get(name)) > diff && i < magic.Y_TIME()) {
Location g = player.getLocation();
yAxisViolations.put(name, yAxisViolations.get(name) + 1);
yAxisLastViolation.put(name, System.currentTimeMillis());
@@ -486,9 +486,9 @@ public class Backend {
player.teleport(g);
}
}
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis in " + i + " ms (min =" + magic.Y_TIME + ")");
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis in " + i + " ms (min =" + magic.Y_TIME() + ")");
} else {
if ((y1 - lastYcoord.get(name)) > magic.Y_MAXDIFF + 1 || (System.currentTimeMillis() - lastYtime.get(name)) > magic.Y_TIME) {
if ((y1 - lastYcoord.get(name)) > magic.Y_MAXDIFF() + 1 || (System.currentTimeMillis() - lastYtime.get(name)) > magic.Y_TIME()) {
lastYtime.put(name, System.currentTimeMillis());
lastYcoord.put(name, y1);
}
@@ -509,11 +509,11 @@ public class Backend {
stepTime.put(name, System.currentTimeMillis());
}
increment(player, steps, step);
if (step == magic.TIMER_STEP_CHECK) {
if (step == magic.TIMER_STEP_CHECK()) {
long time = System.currentTimeMillis() - stepTime.get(name);
steps.put(name, 0);
if (time < magic.TIMER_TIMEMIN) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to alter their timer, took " + step + " steps in " + time + " ms (min = " + magic.TIMER_TIMEMIN + " ms)");
if (time < magic.TIMER_TIMEMIN()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to alter their timer, took " + step + " steps in " + time + " ms (min = " + magic.TIMER_TIMEMIN() + " ms)");
}
}
return PASS;
@@ -556,7 +556,7 @@ public class Backend {
}
public CheckResult checkFlight(Player player, Distance distance) {
if (distance.getYDifference() > magic.TELEPORT_MIN) {
if (distance.getYDifference() > magic.TELEPORT_MIN()) {
// This was a teleport, so we don't care about it.
return PASS;
}
@@ -575,8 +575,8 @@ public class Backend {
blocksOverFlight.put(name, (blocksOverFlight.get(name) - distance.getYDifference()));
}
if (blocksOverFlight.get(name) > magic.FLIGHT_BLOCK_LIMIT && (y1 <= y2)) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " flew over " + blocksOverFlight.get(name) + " blocks (max=" + magic.FLIGHT_BLOCK_LIMIT + ")");
if (blocksOverFlight.get(name) > magic.FLIGHT_BLOCK_LIMIT() && (y1 <= y2)) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " flew over " + blocksOverFlight.get(name) + " blocks (max=" + magic.FLIGHT_BLOCK_LIMIT() + ")");
}
} else {
blocksOverFlight.put(name, 0D);
@@ -595,7 +595,7 @@ public class Backend {
}
public CheckResult checkAscension(Player player, double y1, double y2) {
int max = magic.ASCENSION_COUNT_MAX;
int max = magic.ASCENSION_COUNT_MAX();
String string = "";
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
max += 12;
@@ -624,8 +624,8 @@ public class Backend {
if (!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES)) {
if (blockPunches.get(name) != null && player.getGameMode() != GameMode.CREATIVE) {
int i = blockPunches.get(name);
if (i < magic.BLOCK_PUNCH_MIN) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to break a block of " + block.getType() + " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN + ")");
if (i < magic.BLOCK_PUNCH_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to break a block of " + block.getType() + " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN() + ")");
} else {
blockPunches.put(name, 0); // it should reset after EACH block break.
}
@@ -636,11 +636,11 @@ public class Backend {
}
public CheckResult checkFastBreak(Player player, Block block) {
int violations = magic.FASTBREAK_MAXVIOLATIONS;
int violations = magic.FASTBREAK_MAXVIOLATIONS();
long timemax = isInstantBreakExempt(player) ? 0 : Utilities.calcSurvivalFastBreak(player.getInventory().getItemInHand(), block.getType());
if (player.getGameMode() == GameMode.CREATIVE) {
violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE;
timemax = magic.FASTBREAK_TIMEMAX_CREATIVE;
violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE();
timemax = magic.FASTBREAK_TIMEMAX_CREATIVE();
}
String name = player.getName();
if (!fastBreakViolation.containsKey(name)) {
@@ -648,13 +648,13 @@ public class Backend {
} else {
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
int i = fastBreakViolation.get(name);
if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME) {
if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME()) {
lastBlockBroken.put(name, System.currentTimeMillis());
if (!silentMode()) {
player.sendMessage(ChatColor.RED + "[AntiCheat] Fastbreaking detected. Please wait 10 seconds before breaking blocks.");
}
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " broke blocks too fast " + i + " times in a row (max=" + violations + ")");
} else if (fastBreakViolation.get(name) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME) {
} else if (fastBreakViolation.get(name) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME()) {
fastBreakViolation.put(name, 0);
}
}
@@ -676,12 +676,12 @@ public class Backend {
}
blockBreakHolder.put(name, false);
}
if (fastBreaks.get(name) >= magic.FASTBREAK_LIMIT && math < timemax) {
if (fastBreaks.get(name) >= magic.FASTBREAK_LIMIT() && math < timemax) {
int i = fastBreaks.get(name);
fastBreaks.put(name, 0);
fastBreakViolation.put(name, fastBreakViolation.get(name) + 1);
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to break " + i + " blocks in " + math + " ms (max=" + magic.FASTBREAK_LIMIT + " in " + timemax + " ms)");
} else if (fastBreaks.get(name) >= magic.FASTBREAK_LIMIT || fastBreakViolation.get(name) > 0) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to break " + i + " blocks in " + math + " ms (max=" + magic.FASTBREAK_LIMIT() + " in " + timemax + " ms)");
} else if (fastBreaks.get(name) >= magic.FASTBREAK_LIMIT() || fastBreakViolation.get(name) > 0) {
if (!blockBreakHolder.containsKey(name) || !blockBreakHolder.get(name)) {
blockBreakHolder.put(name, true);
} else {
@@ -700,7 +700,7 @@ public class Backend {
}
public CheckResult checkFastPlace(Player player) {
int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE : magic.FASTPLACE_MAXVIOLATIONS;
int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE() : magic.FASTPLACE_MAXVIOLATIONS();
long time = System.currentTimeMillis();
String name = player.getName();
if (!lastBlockPlaceTime.containsKey(name) || !fastPlaceViolation.containsKey(name)) {
@@ -712,13 +712,13 @@ public class Backend {
AntiCheat.debugLog("Noted that fastPlaceViolation contains key " + name + " with value " + fastPlaceViolation.get(name));
Long math = System.currentTimeMillis() - lastBlockPlaced.get(name);
AntiCheat.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math);
if (lastBlockPlaced.get(name) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME) {
if (lastBlockPlaced.get(name) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) {
lastBlockPlaced.put(name, time);
if (!silentMode()) {
player.sendMessage(ChatColor.RED + "[AntiCheat] Fastplacing detected. Please wait 10 seconds before placing blocks.");
}
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " placed blocks too fast " + fastBreakViolation.get(name) + " times in a row (max=" + violations + ")");
} else if (lastBlockPlaced.get(name) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME) {
} else if (lastBlockPlaced.get(name) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) {
AntiCheat.debugLog("Reset facePlaceViolation for " + name);
fastPlaceViolation.put(name, 0);
}
@@ -727,11 +727,11 @@ public class Backend {
long lastTime = lastBlockPlaceTime.get(name);
long thisTime = time - last;
if (lastTime != 0 && thisTime < magic.FASTPLACE_TIMEMIN) {
if (lastTime != 0 && thisTime < magic.FASTPLACE_TIMEMIN()) {
lastBlockPlaceTime.put(name, (time - last));
lastBlockPlaced.put(name, time);
fastPlaceViolation.put(name, fastPlaceViolation.get(name) + 1);
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to place a block " + thisTime + " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN + " ms)");
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to place a block " + thisTime + " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN() + " ms)");
}
lastBlockPlaceTime.put(name, (time - last));
}
@@ -762,14 +762,14 @@ public class Backend {
}
Long l = user.getMessageTime(i);
if (System.currentTimeMillis() - l > magic.CHAT_REPEAT_MIN * 100) {
if (System.currentTimeMillis() - l > magic.CHAT_REPEAT_MIN() * 100) {
user.clearMessages();
break;
} else {
if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue() && m.equalsIgnoreCase(msg) && i == 1) {
manager.getLoggingManager().logFineInfo(player.getName() + " spam-repeated \"" + msg + "\"");
return new CheckResult(CheckResult.Result.FAILED, lang.spamWarning.getValue());
} else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN * 2) {
} else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN() * 2) {
manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\"");
return new CheckResult(CheckResult.Result.FAILED, lang.spamWarning.getValue());
}
@@ -791,13 +791,13 @@ public class Backend {
}
Long l = user.getCommandTime(i);
if (System.currentTimeMillis() - l > magic.COMMAND_REPEAT_MIN * 100) {
if (System.currentTimeMillis() - l > magic.COMMAND_REPEAT_MIN() * 100) {
user.clearCommands();
break;
} else {
if (manager.getConfiguration().getConfig().blockCommandSpamRepetition.getValue() && m.equalsIgnoreCase(cmd) && i == 1) {
return new CheckResult(CheckResult.Result.FAILED, lang.spamWarning.getValue());
} else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN * 2) {
} else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN() * 2) {
return new CheckResult(CheckResult.Result.FAILED, lang.spamWarning.getValue());
}
}
@@ -819,11 +819,11 @@ public class Backend {
inventoryClicks.put(name, clicks);
if (clicks == 1) {
inventoryTime.put(name, System.currentTimeMillis());
} else if (clicks == magic.INVENTORY_CHECK) {
} else if (clicks == magic.INVENTORY_CHECK()) {
long time = System.currentTimeMillis() - inventoryTime.get(name);
inventoryClicks.put(name, 0);
if (time < magic.INVENTORY_TIMEMIN) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " clicked inventory slots " + clicks + " times in " + time + " ms (max=" + magic.INVENTORY_CHECK + " in " + magic.INVENTORY_TIMEMIN + " ms)");
if (time < magic.INVENTORY_TIMEMIN()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " clicked inventory slots " + clicks + " times in " + time + " ms (max=" + magic.INVENTORY_CHECK() + " in " + magic.INVENTORY_TIMEMIN() + " ms)");
}
}
return PASS;
@@ -838,8 +838,8 @@ public class Backend {
}
public CheckResult checkSprintDamage(Player player) {
if (isDoing(player, sprinted, magic.SPRINT_MIN)) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MIN + " ms)");
if (isDoing(player, sprinted, magic.SPRINT_MIN())) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MIN() + " ms)");
} else {
return PASS;
}
@@ -858,8 +858,8 @@ public class Backend {
{
long l = lastHeal.get(player.getName());
lastHeal.remove(player.getName());
if ((System.currentTimeMillis() - l) < magic.HEAL_TIME_MIN) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " healed too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.HEAL_TIME_MIN + " ms)");
if ((System.currentTimeMillis() - l) < magic.HEAL_TIME_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " healed too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.HEAL_TIME_MIN() + " ms)");
}
}
return PASS;
@@ -870,8 +870,8 @@ public class Backend {
{
long l = startEat.get(player.getName());
startEat.remove(player.getName());
if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " ate too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN + " ms)");
if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " ate too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN() + " ms)");
}
}
return PASS;
@@ -879,7 +879,7 @@ public class Backend {
public void logAnimation(final Player player) {
animated.put(player.getName(), System.currentTimeMillis());
increment(player, blockPunches, magic.BLOCK_PUNCH_MIN);
increment(player, blockPunches, magic.BLOCK_PUNCH_MIN());
itemInHand.put(player.getName(), player.getItemInHand().getType());
interactionCount.put(player.getName(), 0);
}
@@ -889,7 +889,7 @@ public class Backend {
}
public boolean isInstantBreakExempt(Player player) {
return isDoing(player, instantBreakExempt, magic.INSTANT_BREAK_TIME);
return isDoing(player, instantBreakExempt, magic.INSTANT_BREAK_TIME());
}
public void logSprint(final Player player) {
@@ -898,7 +898,7 @@ public class Backend {
public boolean isHoveringOverWaterAfterViolation(Player player) {
if (waterSpeedViolation.containsKey(player.getName())) {
if (waterSpeedViolation.get(player.getName()) >= magic.WATER_SPEED_VIOLATION_MAX && Utilities.isHoveringOverWater(player.getLocation())) {
if (waterSpeedViolation.get(player.getName()) >= magic.WATER_SPEED_VIOLATION_MAX() && Utilities.isHoveringOverWater(player.getLocation())) {
return true;
}
}
@@ -911,7 +911,7 @@ public class Backend {
}
public boolean justBroke(Player player) {
return isDoing(player, brokenBlock, magic.BLOCK_BREAK_MIN);
return isDoing(player, brokenBlock, magic.BLOCK_BREAK_MIN());
}
public void logVelocity(final Player player) {
@@ -919,20 +919,20 @@ public class Backend {
}
public boolean justVelocity(Player player) {
return (velocitized.containsKey(player.getName()) ? (System.currentTimeMillis() - velocitized.get(player.getName())) < magic.VELOCITY_CHECKTIME : false);
return (velocitized.containsKey(player.getName()) ? (System.currentTimeMillis() - velocitized.get(player.getName())) < magic.VELOCITY_CHECKTIME() : false);
}
public boolean extendVelocityTime(final Player player) {
if (velocitytrack.containsKey(player.getName())) {
velocitytrack.put(player.getName(), velocitytrack.get(player.getName()) + 1);
if (velocitytrack.get(player.getName()) > magic.VELOCITY_MAXTIMES) {
velocitized.put(player.getName(), System.currentTimeMillis() + magic.VELOCITY_PREVENT);
if (velocitytrack.get(player.getName()) > magic.VELOCITY_MAXTIMES()) {
velocitized.put(player.getName(), System.currentTimeMillis() + magic.VELOCITY_PREVENT());
manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(), new Runnable() {
@Override
public void run() {
velocitytrack.put(player.getName(), 0);
}
}, magic.VELOCITY_SCHETIME * 20L);
}, magic.VELOCITY_SCHETIME() * 20L);
return true;
}
} else {
@@ -947,7 +947,7 @@ public class Backend {
}
public boolean justPlaced(Player player) {
return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN);
return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN());
}
public void resetAnimation(final Player player) {
@@ -962,11 +962,11 @@ public class Backend {
int count = interactionCount.get(player.getName()) + 1;
interactionCount.put(player.getName(), count);
if (count > magic.ANIMATION_INTERACT_MAX) {
if (count > magic.ANIMATION_INTERACT_MAX()) {
animated.remove(player.getName());
return false;
}
return time < magic.ANIMATION_MIN;
return time < magic.ANIMATION_MIN();
} else {
return false;
}
@@ -976,16 +976,16 @@ public class Backend {
long time;
switch (type) {
case 1:
time = magic.DAMAGE_TIME;
time = magic.DAMAGE_TIME();
break;
case 2:
time = magic.KNOCKBACK_DAMAGE_TIME;
time = magic.KNOCKBACK_DAMAGE_TIME();
break;
case 3:
time = magic.EXPLOSION_DAMAGE_TIME;
time = magic.EXPLOSION_DAMAGE_TIME();
break;
default:
time = magic.DAMAGE_TIME;
time = magic.DAMAGE_TIME();
break;
}
@@ -994,15 +994,15 @@ public class Backend {
}
public void logEnterExit(final Player player) {
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME);
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME());
}
public void logToggleSneak(final Player player) {
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.SNEAK_TIME);
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.SNEAK_TIME());
}
public void logTeleport(final Player player) {
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.TELEPORT_TIME);
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.TELEPORT_TIME());
/* Data for fly/speed should be reset */
nofallViolation.remove(player.getName());
@@ -1014,11 +1014,11 @@ public class Backend {
}
public void logExitFly(final Player player) {
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.EXIT_FLY_TIME);
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
}
public void logJoin(final Player player) {
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.JOIN_TIME);
movingExempt.put(player.getName(), System.currentTimeMillis() + magic.JOIN_TIME());
}
public boolean isMovingExempt(Player player) {
@@ -1067,8 +1067,8 @@ public class Backend {
public void processChatSpammer(Player player) {
User user = manager.getUserManager().getUser(player.getName());
int level = chatLevel.containsKey(user.getName()) ? chatLevel.get(user.getName()) : 0;
if (player != null && player.isOnline() && level >= magic.CHAT_ACTION_ONE_LEVEL) {
String event = level >= magic.CHAT_ACTION_TWO_LEVEL ? manager.getConfiguration().getConfig().chatSpamActionTwo.getValue() : manager.getConfiguration().getConfig().chatSpamActionOne.getValue();
if (player != null && player.isOnline() && level >= magic.CHAT_ACTION_ONE_LEVEL()) {
String event = level >= magic.CHAT_ACTION_TWO_LEVEL() ? manager.getConfiguration().getConfig().chatSpamActionTwo.getValue() : manager.getConfiguration().getConfig().chatSpamActionOne.getValue();
manager.getUserManager().execute(manager.getUserManager().getUser(player.getName()), Utilities.stringToList(event), CheckType.CHAT_SPAM, lang.spamKickReason.getValue(), Utilities.stringToList(lang.spamWarning.getValue()), lang.spamBanReason.getValue());
}
chatLevel.put(user.getName(), level + 1);
@@ -1077,8 +1077,8 @@ public class Backend {
public void processCommandSpammer(Player player) {
User user = manager.getUserManager().getUser(player.getName());
int level = commandLevel.containsKey(user.getName()) ? commandLevel.get(user.getName()) : 0;
if (player != null && player.isOnline() && level >= magic.COMMAND_ACTION_ONE_LEVEL) {
String event = level >= magic.COMMAND_ACTION_TWO_LEVEL ? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue() : manager.getConfiguration().getConfig().commandSpamActionOne.getValue();
if (player != null && player.isOnline() && level >= magic.COMMAND_ACTION_ONE_LEVEL()) {
String event = level >= magic.COMMAND_ACTION_TWO_LEVEL() ? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue() : manager.getConfiguration().getConfig().commandSpamActionOne.getValue();
manager.getUserManager().execute(manager.getUserManager().getUser(player.getName()), Utilities.stringToList(event), CheckType.COMMAND_SPAM, lang.spamKickReason.getValue(), Utilities.stringToList(lang.spamWarning.getValue()), lang.spamBanReason.getValue());
}
commandLevel.put(user.getName(), level + 1);
@@ -22,20 +22,24 @@ import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.files.Config;
import net.gravitydevelopment.anticheat.config.files.Enterprise;
import net.gravitydevelopment.anticheat.config.files.Lang;
import net.gravitydevelopment.anticheat.config.files.Magic;
import net.gravitydevelopment.anticheat.config.holders.mysql.MySQLGroupsHolder;
import net.gravitydevelopment.anticheat.config.holders.mysql.MySQLLevelsHolder;
import net.gravitydevelopment.anticheat.config.holders.mysql.MySQLMagicHolder;
import net.gravitydevelopment.anticheat.config.holders.mysql.MySQLRulesHolder;
import net.gravitydevelopment.anticheat.config.holders.yaml.YamlGroupsHolder;
import net.gravitydevelopment.anticheat.config.holders.yaml.YamlLevelsHolder;
import net.gravitydevelopment.anticheat.config.holders.yaml.YamlMagicHolder;
import net.gravitydevelopment.anticheat.config.holders.yaml.YamlRulesHolder;
import net.gravitydevelopment.anticheat.config.providers.Groups;
import net.gravitydevelopment.anticheat.config.providers.Levels;
import net.gravitydevelopment.anticheat.config.providers.Magic;
import net.gravitydevelopment.anticheat.config.providers.Rules;
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
public class Configuration {
@@ -44,8 +48,8 @@ public class Configuration {
private Config config;
private Enterprise enterprise;
private Lang lang;
private Magic magic;
private Magic magic;
private Groups groups;
private Levels levels;
private Rules rules;
@@ -61,13 +65,11 @@ public class Configuration {
// Now load others
enterprise = new Enterprise(plugin, this);
lang = new Lang(plugin, this);
magic = new Magic(plugin, this);
flatfiles = new ArrayList<ConfigurationFile>() {{
add(config);
add(enterprise);
add(lang);
add(magic);
}};
dbfiles = new ArrayList<ConfigurationTable>();
@@ -89,6 +91,21 @@ public class Configuration {
flatfiles.add((YamlRulesHolder) rules);
}
InvocationHandler handler;
if (config.enterprise.getValue() && enterprise.configMagic.getValue()) {
handler = new MySQLMagicHolder(this);
magic = (Magic) Proxy.newProxyInstance(Magic.class.getClassLoader(),
new Class[] { Magic.class },
handler);
dbfiles.add((MySQLMagicHolder) handler);
} else {
handler = new YamlMagicHolder(plugin, this);
magic = (Magic) Proxy.newProxyInstance(Magic.class.getClassLoader(),
new Class[] { Magic.class },
handler);
flatfiles.add((YamlMagicHolder) handler);
}
if (config.enterprise.getValue() && enterprise.syncLevels.getValue()) {
levels = new MySQLLevelsHolder(this);
dbfiles.add((MySQLLevelsHolder) levels);
@@ -19,6 +19,7 @@
package net.gravitydevelopment.anticheat.config;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.files.Magic;
import net.gravitydevelopment.anticheat.config.yaml.CommentedConfiguration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -21,6 +21,9 @@ package net.gravitydevelopment.anticheat.config;
import net.gravitydevelopment.anticheat.util.enterprise.Database;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
public class ConfigurationTable {
@@ -58,6 +61,15 @@ public class ConfigurationTable {
return prefix + table;
}
public boolean tableExists() {
try {
return getConnection().getMetaData().getTables(null, null, getFullTable(), null).next();
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
public String getServerName() {
return serverName;
}
@@ -38,6 +38,7 @@ public class Enterprise extends ConfigurationFile {
public ConfigValue<Boolean> configGroups;
public ConfigValue<Boolean> configRules;
public ConfigValue<Boolean> configMagic;
public Database database;
@@ -58,6 +59,7 @@ public class Enterprise extends ConfigurationFile {
configGroups = new ConfigValue<Boolean>("config.groups");
configRules = new ConfigValue<Boolean>("config.rules");
configMagic = new ConfigValue<Boolean>("config.magic");
ConfigValue<String> databaseType = new ConfigValue<String>("database.type");
ConfigValue<String> databaseHostname = new ConfigValue<String>("database.hostname");
@@ -45,7 +45,7 @@ public class MySQLGroupsHolder extends ConfigurationTable implements Groups {
highestLevel = 0;
groups = new ArrayList<Group>();
String sqlCreate = "CREATE TABLE IF NOT EXISTS " + getFullTable() + "(" +
String sqlCreate = "CREATE TABLE " + getFullTable() + "(" +
" `id` INT NOT NULL AUTO_INCREMENT," +
" `name` VARCHAR(45) NOT NULL," +
" `level` INT NOT NULL," +
@@ -58,14 +58,15 @@ public class MySQLGroupsHolder extends ConfigurationTable implements Groups {
" (SELECT 1 as id, 'Medium' as name, 20 as level, 'YELLOW' as color, 'WARN' as actions)" +
" UNION ALL " +
" (SELECT 2 as id, 'High' as name, 50 as level, 'RED' as color, 'KICK' as actions)" +
" ) t" +
" WHERE NOT EXISTS (SELECT * FROM " + getFullTable() + ");";
" ) t;";
String sqlLoad = "SELECT * FROM " + getFullTable();
try {
getConnection().prepareStatement(sqlCreate).executeUpdate();
getConnection().prepareStatement(sqlPopulate).executeUpdate();
getConnection().commit();
if (!tableExists()) {
getConnection().prepareStatement(sqlCreate).executeUpdate();
getConnection().prepareStatement(sqlPopulate).executeUpdate();
getConnection().commit();
}
ResultSet set = getConnection().prepareStatement(sqlLoad).executeQuery();
while (set.next()) {
@@ -59,7 +59,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
sqlUpdate = "SELECT level, last_update FROM " + getFullTable() + " " +
"WHERE user = ? AND last_update <> ? AND last_update_server = ?";
String sqlCreate = "CREATE TABLE IF NOT EXISTS " + getFullTable() + "(" +
String sqlCreate = "CREATE TABLE " + getFullTable() + "(" +
" `user` VARCHAR(45) NOT NULL," +
" `level` INT NOT NULL," +
" `last_update` TIMESTAMP NOT NULL DEFAULT NOW()," +
@@ -67,8 +67,10 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
" PRIMARY KEY (`user`));";
try {
getConnection().prepareStatement(sqlCreate).executeUpdate();
getConnection().commit();
if (!tableExists()) {
getConnection().prepareStatement(sqlCreate).executeUpdate();
getConnection().commit();
}
} catch (SQLException e) {
e.printStackTrace();
}
@@ -0,0 +1,142 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
*
* 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 net.gravitydevelopment.anticheat.config.holders.mysql;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
import net.gravitydevelopment.anticheat.config.providers.Magic;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
public class MySQLMagicHolder extends ConfigurationTable implements InvocationHandler {
private static final String TABLE = "magic";
private HashMap<String, Integer> ints;
private HashMap<String, Double> doubles;
private FileConfiguration defaults;
public MySQLMagicHolder(Configuration config) {
super(config, TABLE);
}
@Override
public void open() {
defaults = YamlConfiguration.loadConfiguration(AntiCheat.getPlugin().getResource("magic.yml"));
ints = new HashMap<String, Integer>();
doubles = new HashMap<String, Double>();
String sqlCreate = "CREATE TABLE " + getFullTable() + "(" +
" `id` INT NOT NULL AUTO_INCREMENT," +
" `key` VARCHAR(45) NOT NULL," +
" `value_int` INT," +
" `value_double` DOUBLE," +
" PRIMARY KEY (`id`));";
String sqlPopulate = "INSERT INTO " + getFullTable() +
" SELECT t.*" +
" FROM (";
Method[] methods = Magic.class.getMethods();
for (int i=1;i<=methods.length;i++) {
String key = methods[i-1].getName();
Object value = defaults.get(key);
String type1 = methods[i-1].getReturnType().getSimpleName();
String type2 = type1.equals("int") ? "double" : "int";
sqlPopulate += "(SELECT " + i + " as id, '" + key + "' as `key`, " + (type1.equals("int") ? value : "null") + " as value_" + type1 + ", " + (type1.equals("double") ? value : "null") + " as value_" + type2 + ") ";
if (i < methods.length) sqlPopulate += "UNION ALL ";
}
sqlPopulate += ") t;";
String sqlLoad = "SELECT * FROM " + getFullTable();
try {
if (!tableExists()) {
getConnection().prepareStatement(sqlCreate).executeUpdate();
getConnection().prepareStatement(sqlPopulate).executeUpdate();
getConnection().commit();
}
ResultSet set = getConnection().prepareStatement(sqlLoad).executeQuery();
while (set.next()) {
String key = set.getString("key");
if (set.getObject("value_int") != null) {
ints.put(key, set.getInt("value_int"));
} else if (set.getObject("value_double") != null) {
doubles.put(key, set.getDouble("value_double"));
} else {
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value.");
for (int i=1;i<=methods.length;i++) {
String name = methods[i-1].getName();
if (name.equalsIgnoreCase(key)) {
String type = methods[i-1].getReturnType().getSimpleName();
if (type.equals("int")) {
ints.put(key, defaults.getInt(key));
} else if (type.equals("double")) {
doubles.put(key, defaults.getDouble(key));
}
}
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public Object invoke(Object proxy, Method method, Object[] args) {
String key = method.getName();
if (ints.containsKey(key)) return ints.get(key).intValue();
else if (doubles.containsKey(key)) return doubles.get(key).doubleValue();
else {
if (method.getReturnType().getSimpleName().equals("int")) {
int value = defaults.getInt(key);
try {
getConnection().prepareStatement("INSERT INTO " + getFullTable() + " (value_int) VALUES (" + value + ")").executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
return value;
} else if (method.getReturnType().getSimpleName().equals("double")) {
double value = defaults.getDouble(key);
try {
getConnection().prepareStatement("INSERT INTO " + getFullTable() + " (key, value_double) VALUES (" + key + " , " + value + ")").executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
return value;
} else {
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
return -1;
}
}
}
}
@@ -41,16 +41,21 @@ public class MySQLRulesHolder extends ConfigurationTable implements Rules {
@Override
public void open() {
String sqlCreate = "CREATE TABLE IF NOT EXISTS " + getFullTable() + "(" +
String sqlCreate = "CREATE TABLE " + getFullTable() + "(" +
" `id` INT NOT NULL AUTO_INCREMENT," +
" `rule` VARCHAR(256) NOT NULL," +
" PRIMARY KEY (`id`));";
String sqlPopulate = "INSERT INTO " + getFullTable() +
" VALUES (1, 'Check_SPIDER < 0 ? Player.KICK : null')";
String sqlLoad = "SELECT * FROM " + getFullTable();
try {
getConnection().prepareStatement(sqlCreate).executeUpdate();
getConnection().commit();
if (!tableExists()) {
getConnection().prepareStatement(sqlCreate).executeUpdate();
getConnection().prepareStatement(sqlPopulate).executeUpdate();
getConnection().commit();
}
this.rules = new ArrayList<Rule>();
ResultSet set = getConnection().prepareStatement(sqlLoad).executeQuery();
@@ -0,0 +1,53 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
*
* 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 net.gravitydevelopment.anticheat.config.holders.yaml;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
public class YamlMagicHolder extends ConfigurationFile implements InvocationHandler {
public static final String FILENAME = "magic.yml";
public YamlMagicHolder(AntiCheat plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@Override
public void open() {
new ConfigValue<Double>("VERSION").setValue(new ConfigValue<Double>("VERSION").getDefaultValue());
}
public Object invoke(Object proxy, Method method, Object[] args) {
String key = method.getName();
if (method.getReturnType().getSimpleName().equals("int")) {
return new ConfigValue<Integer>(key).getValue();
} else if (method.getReturnType().getSimpleName().equals("double")) {
return new ConfigValue<Double>(key).getValue();
} else {
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
return -1;
}
}
}
@@ -16,11 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.gravitydevelopment.anticheat.config.files;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.config.Configuration;
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
package net.gravitydevelopment.anticheat.config.providers;
/**
* Magic number class. Modifications to values in magic.yml will be accepted here.
@@ -30,7 +26,7 @@ import net.gravitydevelopment.anticheat.config.ConfigurationFile;
* <p/>
* <b>How to read the value documentation:</b> <br>
* First, you will see a description of the value. Then, you will see a type: <br>
* <b>Type SYSTEM:</b> This is a 'long' value, measured in milliseconds, used to compare past and future events with the current system time. Remember, 1000 ms = 1 second. <br>
* <b>Type SYSTEM:</b> This is a millisecond value used to compare past and future events with the current system time. Remember, 1000 ms = 1 second. <br>
* <b>Type INTEGER:</b> This is a regular number. It's typically used as something trivial, such as how many times X event can occur. <br>
* <b>Type DOUBLE:</b> This is a number that has a decimal in it. It's typically used to evaluate speed or distance.
* <p/>
@@ -38,440 +34,333 @@ import net.gravitydevelopment.anticheat.config.ConfigurationFile;
* The suggestion for adding leniency will either be to INCREASE or DECREASE the variable. Doing what it suggests will cause the system to not judge the people being checked so vigorously.
*/
public class Magic extends ConfigurationFile {
public interface Magic {
/**
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=system, +Leniency=Increase.
*/
public int ENTERED_EXITED_TIME;
public int ENTERED_EXITED_TIME();
/**
* Time to exempt a player from moving because of entering/exiting sneak mode; Type=system, +Leniency=Increase.
*/
public int SNEAK_TIME;
public int SNEAK_TIME();
/**
* Time to exempt a player from moving because of teleporting; Type=system, +Leniency=Increase.
*/
public int TELEPORT_TIME;
public int TELEPORT_TIME();
/**
* Time to exempt a player from moving because of exiting fly mode; Type=system, +Leniency=Increase.
*/
public int EXIT_FLY_TIME;
public int EXIT_FLY_TIME();
/**
* Time to exempt a player from moving because of joining the server; Type=system, +Leniency=Increase.
*/
public int JOIN_TIME;
public int JOIN_TIME();
/**
* Time to exempt a player from fastbreak check because of using instant break; Type=seconds, +Leniency=Increase.
*/
public int INSTANT_BREAK_TIME;
public int INSTANT_BREAK_TIME();
/**
* Time to exempt a player from moving because of taking damage; Type=system, +Leniency=Increase.
*/
public long DAMAGE_TIME;
public int DAMAGE_TIME();
/**
* Time to exempt a player from moving because of taking damage with knockback effects; Type=system, +Leniency=Increase.
*/
public long KNOCKBACK_DAMAGE_TIME;
public int KNOCKBACK_DAMAGE_TIME();
/**
* Time to exempt a player from moving because of taking damage from an explosion; Type=system, +Leniency=Increase.
*/
public long EXPLOSION_DAMAGE_TIME;
public int EXPLOSION_DAMAGE_TIME();
/**
* Minimum time it takes to fire X projectiles; Type=system, +Leniency=Decrease.
*/
public int PROJECTILE_TIME_MIN;
public int PROJECTILE_TIME_MIN();
/**
* Number of projectiles to wait for before checking how long they took to fire off; Type=integer.
* Number of projectiles to wait for before checking how int they took to fire off; Type=integer.
*/
public int PROJECTILE_CHECK;
public int PROJECTILE_CHECK();
/**
* Minimum time it takes to drop X items; Type=system, +Leniency=Decrease.
*/
public int DROP_TIME_MIN;
public int DROP_TIME_MIN();
/**
* Number of item drops to wait for before checking how long they took to drop; Type=integer.
* Number of item drops to wait for before checking how int they took to drop; Type=integer.
*/
public int DROP_CHECK;
public int DROP_CHECK();
/**
* Max number of blocks that can be broken in a given time; Type=integer, +Leniency=Increase.
*/
public int FASTBREAK_LIMIT;
public int FASTBREAK_LIMIT();
/**
* Time to wait before checking block breaks; Type=system, +Leniency=Increase.
*/
public int FASTBREAK_TIMEMAX;
public int FASTBREAK_TIMEMAX();
/**
* Time to wait before checking block breaks in creative mode; Type=system, +Leniency=Increase.
*/
public int FASTBREAK_TIMEMAX_CREATIVE;
public int FASTBREAK_TIMEMAX_CREATIVE();
/**
* Number of times fastbreak can be observed before taking action; Type=integer, +Leniency=Increase.
*/
public int FASTBREAK_MAXVIOLATIONS;
public int FASTBREAK_MAXVIOLATIONS();
/**
* Number of times fastbreak can be observed before taking action in creative mode; Type=integer, +Leniency=Increase.
*/
public int FASTBREAK_MAXVIOLATIONS_CREATIVE;
public int FASTBREAK_MAXVIOLATIONS_CREATIVE();
/**
* Time a player is forced to wait after fastbreak has been detected; Type=system, +Leniency=Decrease.
*/
public int FASTBREAK_MAXVIOLATIONTIME;
public int FASTBREAK_MAXVIOLATIONTIME();
/**
* Number of blocks that can be broken without being hit before taking action; Type=integer, +Leniency=Increase.
*/
public int FASTPLACE_ZEROLIMIT;
public int FASTPLACE_ZEROLIMIT();
/**
* Minimum time in between block places; Type=system, +Leniency=Decrease.
*/
public int FASTPLACE_TIMEMIN;
public int FASTPLACE_TIMEMIN();
/**
* Number of times fastplace can be observed before taking action; Type=integer, +Leniency=Increase.
*/
public int FASTPLACE_MAXVIOLATIONS;
public int FASTPLACE_MAXVIOLATIONS();
/**
* Number of times fastplace can be observed before taking action in creative mode; Type=integer, +Leniency=Increase.
*/
public int FASTPLACE_MAXVIOLATIONS_CREATIVE;
public int FASTPLACE_MAXVIOLATIONS_CREATIVE();
/**
* Time a player is forced to wait after fastplace has been detected; Type=system, +Leniency=Decrease.
*/
public int FASTPLACE_MAXVIOLATIONTIME;
public int FASTPLACE_MAXVIOLATIONTIME();
/**
* Number of times required to punch a block before it breaks; Type=integer, +Leniency=Decrease.
*/
public int BLOCK_PUNCH_MIN;
public int BLOCK_PUNCH_MIN();
/**
* Number of command spam violations before action one is executed; Type=integer, +Leniency=Increase.
*/
public int COMMAND_ACTION_ONE_LEVEL;
public int COMMAND_ACTION_ONE_LEVEL();
/**
* Number of command spam violations before action two is executed; Type=integer, +Leniency=Increase.
*/
public int COMMAND_ACTION_TWO_LEVEL;
public int COMMAND_ACTION_TWO_LEVEL();
/**
* Number of chat spam violations before action one is executed; Type=integer, +Leniency=Increase.
*/
public int CHAT_ACTION_ONE_LEVEL;
public int CHAT_ACTION_ONE_LEVEL();
/**
* Number of chat spam violations before action two is executed; Type=integer, +Leniency=Increase.
*/
public int CHAT_ACTION_TWO_LEVEL;
public int CHAT_ACTION_TWO_LEVEL();
/**
* Number of times a player can be caught in-flight before action is taken; Type=integer, +Leniency=Increase.
*/
public int FLIGHT_LIMIT;
public int FLIGHT_LIMIT();
/**
* How many blocks you can travel before action is taken; Type=integer, +Leniency=Increase.
*/
public double FLIGHT_BLOCK_LIMIT;
public double FLIGHT_BLOCK_LIMIT();
/**
* Maximum speed that a player can climb a waterfall; Type=double, +Leniency=Increase.
*/
public double WATER_CLIMB_MAX;
public double WATER_CLIMB_MAX();
/**
* Number of times a player can fly on the y-axis before action is taken; Type=integer, +Leniency=Increase.
*/
public int Y_MAXVIOLATIONS;
public int Y_MAXVIOLATIONS();
/**
* Time a player is forced to wait after flying on the y-axis; Type=system, +Leniency=Decrease.
*/
public int Y_MAXVIOTIME;
public int Y_MAXVIOTIME();
/**
* Number of times a player can fail a velocity check before action is taken; Type=integer, +Leniency=Increase.
*/
public int VELOCITY_TIME;
public int VELOCITY_TIME();
/**
* Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=integer.
*/
public long VELOCITY_SCHETIME;
public int VELOCITY_SCHETIME();
/**
* Maximum time a player is considered to have a change in velocity; Type=system, +Leniency=Increase.
*/
public long VELOCITY_CHECKTIME;
public int VELOCITY_CHECKTIME();
/**
* Time to extend a player's velocity count by; Type=system, +Leniency=Increase.
*/
public long VELOCITY_PREVENT;
public int VELOCITY_PREVENT();
/**
* Number of times a player can fail the velocity check before action is taken; Type=integer, +Leniency=Increase.
*/
public int VELOCITY_MAXTIMES;
public int VELOCITY_MAXTIMES();
/**
* Number of times a player can fail the nofall check before action is taken; Type=integer, +Leniency=Increase.
*/
public int NOFALL_LIMIT;
public int NOFALL_LIMIT();
/**
* Number of times a player can fail the ascension check before action is taken; Type=integer, +Leniency=Increase.
*/
public int ASCENSION_COUNT_MAX;
public int ASCENSION_COUNT_MAX();
/**
* Number of times a player can fail the ascension check while in water before action is taken; Type=integer, +Leniency=Increase.
*/
public int WATER_ASCENSION_VIOLATION_MAX;
public int WATER_ASCENSION_VIOLATION_MAX();
/**
* Number of times a player can be caught speeding in water before action is taken; Type=integer, +Leniency=Increase.
*/
public int WATER_SPEED_VIOLATION_MAX;
public int WATER_SPEED_VIOLATION_MAX();
/**
* Number of times a player can sprint without proper food level before action is taken; Type=integer, +Leniency=Increase.
*/
public int SPRINT_FOOD_MIN;
public int SPRINT_FOOD_MIN();
/**
* Maximum times a player can interact between animations; Type=integer, +Leniency=Increase.
*/
public int ANIMATION_INTERACT_MAX;
public int ANIMATION_INTERACT_MAX();
/**
* Minimum time between animations; Type=system, +Leniency=Increase.
*/
public int ANIMATION_MIN;
public int ANIMATION_MIN();
/**
* Minimum time between commands; Type=system, +Leniency=Increase.
*/
public int COMMAND_MIN;
public int COMMAND_MIN();
/**
* MTime before repeating a command is ignored; Type=system, +Leniency=Increase.
*/
public int COMMAND_REPEAT_MIN;
public int COMMAND_REPEAT_MIN();
/**
* Minimum time between chats; Type=system, +Leniency=Increase.
*/
public int CHAT_MIN;
public int CHAT_MIN();
/**
* Time before repeating yourself in chat is ignored; Type=system, +Leniency=Increase.
*/
public int CHAT_REPEAT_MIN;
public int CHAT_REPEAT_MIN();
/**
* Maximum speed you can travel while sprinting; Type=double, +Leniency=Increase.
*/
public double SPRINT_MIN;
public double SPRINT_MIN();
/**
* Minimum time in between block breaks; Type=seconds, +Leniency=Decrease.
*/
public double BLOCK_BREAK_MIN;
public double BLOCK_BREAK_MIN();
/**
* Minimum time in between block placing; Type=seconds, +Leniency=Decrease.
*/
public double BLOCK_PLACE_MIN;
public double BLOCK_PLACE_MIN();
/**
* Minimum time in between healing; Type=system, +Leniency=Decrease.
*/
public long HEAL_TIME_MIN;
public int HEAL_TIME_MIN();
/**
* Minimum time in between eating; Type=system, +Leniency=Decrease.
*/
public long EAT_TIME_MIN;
public int EAT_TIME_MIN();
/**
* Maximum percent error between predicted bow force and actual bow force; Type=double, +Leniency=Increase.
*/
public double BOW_ERROR;
public double BOW_ERROR();
/**
* Minimum distance a player can break a block from; Type=double, +Leniency=Increase.
*/
public double BLOCK_MAX_DISTANCE;
public double BLOCK_MAX_DISTANCE();
/**
* Minimum distance a player can break a block from in creative mode; Type=double, +Leniency=Increase.
*/
public double BLOCK_MAX_DISTANCE_CREATIVE;
public double BLOCK_MAX_DISTANCE_CREATIVE();
/**
* Minimum distance a player can damage an entity from; Type=double, +Leniency=Increase.
*/
public double ENTITY_MAX_DISTANCE;
public double ENTITY_MAX_DISTANCE();
/**
* Minimum distance a player can damage an entity from in creative mode; Type=double, +Leniency=Increase.
*/
public double ENTITY_MAX_DISTANCE_CREATIVE;
public double ENTITY_MAX_DISTANCE_CREATIVE();
/**
* Maximum speed a player on a ladder can travel; Type=double, +Leniency=Increase.
*/
public double LADDER_Y_MAX;
public double LADDER_Y_MAX();
/**
* Minimum speed a player on a ladder can travel; Type=double, +Leniency=Decrease.
*/
public double LADDER_Y_MIN;
public double LADDER_Y_MIN();
/**
* Maximum speed a player can travel up; Type=double, +Leniency=Increase.
*/
public double Y_SPEED_MAX;
public double Y_SPEED_MAX();
/**
* Maximum difference between the player's last 2 Y values when traveling up; Type=double, +Leniency=Increase.
*/
public double Y_MAXDIFF;
public double Y_MAXDIFF();
/**
* Time in between Y difference measures; Type=system, +Leniency=Decrease.
*/
public long Y_TIME;
public int Y_TIME();
/**
* Maximum speed a player can travel forwards or backwards; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX;
public double XZ_SPEED_MAX();
/**
* Maximum speed a player can travel forwards or backwards while sprinting; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_SPRINT;
public double XZ_SPEED_MAX_SPRINT();
/**
* Maximum speed a player can travel forwards or backwards while flying; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_FLY;
public double XZ_SPEED_MAX_FLY();
/**
* Maximum speed a player can travel forwards or backwards while under the influence; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_POTION;
public double XZ_SPEED_MAX_POTION();
/**
* Maximum speed a player can travel forwards or backwards while sprinting while under the influence; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_POTION_SPRINT;
public double XZ_SPEED_MAX_POTION_SPRINT();
/**
* Maximum speed a player can travel forwards or backwards while sneaking; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_SNEAK;
public double XZ_SPEED_MAX_SNEAK();
/**
* Maximum speed a player can travel forwards or backwards in water; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_WATER;
public double XZ_SPEED_MAX_WATER();
/**
* Maximum speed a player can travel forwards or backwards in water while sprinting; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_WATER_SPRINT;
public double XZ_SPEED_MAX_WATER_SPRINT();
/**
* Maximum speed a player can travel forwards or backwards on soul sand; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_SOULSAND;
public double XZ_SPEED_MAX_SOULSAND();
/**
* Maximum speed a player can travel forwards or backwards on soul sand while sprinting; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_SOULSAND_SPRINT;
public double XZ_SPEED_MAX_SOULSAND_SPRINT();
/**
* Maximum speed a player can travel forwards or backwards on soul sand while under the influence; Type=double, +Leniency=Increase.
*/
public double XZ_SPEED_MAX_SOULSAND_POTION;
public double XZ_SPEED_MAX_SOULSAND_POTION();
/**
* Maximum times a player can fail the speed check before action is taken; Type=integer, +Leniency=Increase.
*/
public int SPEED_MAX;
public int SPEED_MAX();
/**
* The number of clicks we should wait before checking if the player has used fast inventory; Type=integer; +Leniency=Increase.
*/
public int INVENTORY_CHECK;
public int INVENTORY_CHECK();
/**
* The minimum time it should have taken for the player to click X times; Type=integer; +Leniency=Increase.
*/
public long INVENTORY_TIMEMIN;
public int INVENTORY_TIMEMIN();
/**
* The number of steps we should wait before checking if the player has used timer cheating; Type=integer; +Leniency=Increase.
*/
public int TIMER_STEP_CHECK;
public int TIMER_STEP_CHECK();
/**
* The minimum time it should have taken for the player to travel X steps; Type=system; +Leniency=Decrease.
*/
public long TIMER_TIMEMIN;
public int TIMER_TIMEMIN();
/**
* Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=int; +Leniency=Increase.
*/
public long TELEPORT_MIN;
private double version;
public Magic(AntiCheat plugin, Configuration config) {
super(plugin, config, "magic.yml");
}
@Override
public void open() {
version = new ConfigValue<Double>("VERSION").getValue();
if (version == 0.2D) {
// 0.2 -> 0.3 diffs
// Fix improperly stored double Y_MAXDIFF
new ConfigValue<Double>("Y_MAXDIFF").setValue(new ConfigValue<Double>("Y_MAXDIFF").getDefaultValue());
setNeedsReload(true);
}
new ConfigValue<Double>("VERSION").setValue(new ConfigValue<Double>("VERSION").getDefaultValue());
ENTERED_EXITED_TIME = new ConfigValue<Integer>("ENTERED_EXITED_TIME").getValue();
SNEAK_TIME = new ConfigValue<Integer>("SNEAK_TIME").getValue();
TELEPORT_TIME = new ConfigValue<Integer>("TELEPORT_TIME").getValue();
EXIT_FLY_TIME = new ConfigValue<Integer>("EXIT_FLY_TIME").getValue();
JOIN_TIME = new ConfigValue<Integer>("JOIN_TIME").getValue();
INSTANT_BREAK_TIME = new ConfigValue<Integer>("INSTANT_BREAK_TIME").getValue();
DAMAGE_TIME = new ConfigValue<Integer>("DAMAGE_TIME").getValue();
KNOCKBACK_DAMAGE_TIME = new ConfigValue<Integer>("KNOCKBACK_DAMAGE_TIME").getValue();
EXPLOSION_DAMAGE_TIME = new ConfigValue<Integer>("EXPLOSION_DAMAGE_TIME").getValue();
PROJECTILE_TIME_MIN = new ConfigValue<Integer>("PROJECTILE_TIME_MIN").getValue();
PROJECTILE_CHECK = new ConfigValue<Integer>("PROJECTILE_CHECK").getValue();
DROP_TIME_MIN = new ConfigValue<Integer>("DROP_TIME_MIN").getValue();
DROP_CHECK = new ConfigValue<Integer>("DROP_CHECK").getValue();
FASTBREAK_LIMIT = new ConfigValue<Integer>("FASTBREAK_LIMIT").getValue();
FASTBREAK_TIMEMAX = new ConfigValue<Integer>("FASTBREAK_TIMEMAX").getValue();
FASTBREAK_TIMEMAX_CREATIVE = new ConfigValue<Integer>("FASTBREAK_TIMEMAX_CREATIVE").getValue();
FASTBREAK_MAXVIOLATIONS = new ConfigValue<Integer>("FASTBREAK_MAXVIOLATIONS").getValue();
FASTBREAK_MAXVIOLATIONS_CREATIVE = new ConfigValue<Integer>("FASTBREAK_MAXVIOLATIONS_CREATIVE").getValue();
FASTBREAK_MAXVIOLATIONTIME = new ConfigValue<Integer>("FASTBREAK_MAXVIOLATIONTIME").getValue();
FASTPLACE_ZEROLIMIT = new ConfigValue<Integer>("FASTPLACE_ZEROLIMIT").getValue();
FASTPLACE_TIMEMIN = new ConfigValue<Integer>("FASTPLACE_TIMEMIN").getValue();
FASTPLACE_MAXVIOLATIONS = new ConfigValue<Integer>("FASTPLACE_MAXVIOLATIONS").getValue();
FASTPLACE_MAXVIOLATIONS_CREATIVE = new ConfigValue<Integer>("FASTPLACE_MAXVIOLATIONS_CREATIVE").getValue();
FASTPLACE_MAXVIOLATIONTIME = new ConfigValue<Integer>("FASTPLACE_MAXVIOLATIONTIME").getValue();
BLOCK_PUNCH_MIN = new ConfigValue<Integer>("BLOCK_PUNCH_MIN").getValue();
CHAT_ACTION_ONE_LEVEL = new ConfigValue<Integer>("CHAT_ACTION_ONE_LEVEL").getValue();
CHAT_ACTION_TWO_LEVEL = new ConfigValue<Integer>("CHAT_ACTION_TWO_LEVEL").getValue();
COMMAND_ACTION_ONE_LEVEL = new ConfigValue<Integer>("COMMAND_ACTION_ONE_LEVEL").getValue();
COMMAND_ACTION_TWO_LEVEL = new ConfigValue<Integer>("COMMAND_ACTION_TWO_LEVEL").getValue();
FLIGHT_LIMIT = new ConfigValue<Integer>("FLIGHT_LIMIT").getValue();
FLIGHT_BLOCK_LIMIT = new ConfigValue<Double>("FLIGHT_BLOCK_LIMIT").getValue();
WATER_CLIMB_MAX = new ConfigValue<Double>("WATER_CLIMB_MAX").getValue();
Y_MAXVIOLATIONS = new ConfigValue<Integer>("Y_MAXVIOLATIONS").getValue();
Y_MAXVIOTIME = new ConfigValue<Integer>("Y_MAXVIOTIME").getValue();
VELOCITY_TIME = new ConfigValue<Integer>("VELOCITY_TIME").getValue();
VELOCITY_SCHETIME = new ConfigValue<Integer>("VELOCITY_SCHETIME").getValue();
VELOCITY_CHECKTIME = new ConfigValue<Integer>("VELOCITY_CHECKTIME").getValue();
VELOCITY_PREVENT = new ConfigValue<Integer>("VELOCITY_PREVENT").getValue();
VELOCITY_MAXTIMES = new ConfigValue<Integer>("VELOCITY_MAXTIMES").getValue();
NOFALL_LIMIT = new ConfigValue<Integer>("NOFALL_LIMIT").getValue();
ASCENSION_COUNT_MAX = new ConfigValue<Integer>("ASCENSION_COUNT_MAX").getValue();
WATER_ASCENSION_VIOLATION_MAX = new ConfigValue<Integer>("WATER_ASCENSION_VIOLATION_MAX").getValue();
WATER_SPEED_VIOLATION_MAX = new ConfigValue<Integer>("WATER_SPEED_VIOLATION_MAX").getValue();
SPRINT_FOOD_MIN = new ConfigValue<Integer>("SPRINT_FOOD_MIN").getValue();
ANIMATION_INTERACT_MAX = new ConfigValue<Integer>("ANIMATION_INTERACT_MAX").getValue();
ANIMATION_MIN = new ConfigValue<Integer>("ANIMATION_MIN").getValue();
COMMAND_MIN = new ConfigValue<Integer>("COMMAND_MIN").getValue();
COMMAND_REPEAT_MIN = new ConfigValue<Integer>("COMMAND_REPEAT_MIN").getValue();
CHAT_MIN = new ConfigValue<Integer>("CHAT_MIN").getValue();
CHAT_REPEAT_MIN = new ConfigValue<Integer>("CHAT_REPEAT_MIN").getValue();
SPRINT_MIN = new ConfigValue<Double>("SPRINT_MIN").getValue();
BLOCK_BREAK_MIN = new ConfigValue<Double>("BLOCK_BREAK_MIN").getValue();
BLOCK_PLACE_MIN = new ConfigValue<Double>("BLOCK_PLACE_MIN").getValue();
HEAL_TIME_MIN = new ConfigValue<Integer>("HEAL_TIME_MIN").getValue();
EAT_TIME_MIN = new ConfigValue<Integer>("EAT_TIME_MIN").getValue();
BOW_ERROR = new ConfigValue<Double>("BOW_ERROR").getValue();
BLOCK_MAX_DISTANCE = new ConfigValue<Double>("BLOCK_MAX_DISTANCE").getValue();
BLOCK_MAX_DISTANCE_CREATIVE = new ConfigValue<Double>("BLOCK_MAX_DISTANCE_CREATIVE").getValue();
ENTITY_MAX_DISTANCE = new ConfigValue<Double>("ENTITY_MAX_DISTANCE").getValue();
ENTITY_MAX_DISTANCE_CREATIVE = new ConfigValue<Double>("ENTITY_MAX_DISTANCE_CREATIVE").getValue();
LADDER_Y_MAX = new ConfigValue<Double>("LADDER_Y_MAX").getValue();
LADDER_Y_MIN = new ConfigValue<Double>("LADDER_Y_MIN").getValue();
Y_SPEED_MAX = new ConfigValue<Double>("Y_SPEED_MAX").getValue();
Y_MAXDIFF = new ConfigValue<Double>("Y_MAXDIFF").getValue();
Y_TIME = new ConfigValue<Integer>("Y_TIME").getValue();
XZ_SPEED_MAX = new ConfigValue<Double>("XZ_SPEED_MAX").getValue();
XZ_SPEED_MAX_SPRINT = new ConfigValue<Double>("XZ_SPEED_MAX_SPRINT").getValue();
XZ_SPEED_MAX_POTION_SPRINT = new ConfigValue<Double>("XZ_SPEED_MAX_POTION_SPRINT").getValue();
XZ_SPEED_MAX_FLY = new ConfigValue<Double>("XZ_SPEED_MAX_FLY").getValue();
XZ_SPEED_MAX_POTION = new ConfigValue<Double>("XZ_SPEED_MAX_POTION").getValue();
XZ_SPEED_MAX_SNEAK = new ConfigValue<Double>("XZ_SPEED_MAX_SNEAK").getValue();
XZ_SPEED_MAX_WATER = new ConfigValue<Double>("XZ_SPEED_MAX_WATER").getValue();
XZ_SPEED_MAX_SOULSAND = new ConfigValue<Double>("XZ_SPEED_MAX_SOULSAND").getValue();
XZ_SPEED_MAX_SOULSAND_SPRINT = new ConfigValue<Double>("XZ_SPEED_MAX_SOULSAND_SPRINT").getValue();
XZ_SPEED_MAX_SOULSAND_POTION = new ConfigValue<Double>("XZ_SPEED_MAX_SOULSAND_POTION").getValue();
XZ_SPEED_MAX_WATER_SPRINT = new ConfigValue<Double>("XZ_SPEED_MAX_WATER_SPRINT").getValue();
SPEED_MAX = new ConfigValue<Integer>("SPEED_MAX").getValue();
INVENTORY_CHECK = new ConfigValue<Integer>("INVENTORY_CHECK").getValue();
INVENTORY_TIMEMIN = new ConfigValue<Integer>("INVENTORY_TIMEMIN").getValue();
TIMER_STEP_CHECK = new ConfigValue<Integer>("TIMER_STEP_CHECK").getValue();
TIMER_TIMEMIN = new ConfigValue<Integer>("TIMER_TIMEMIN").getValue();
TELEPORT_MIN = new ConfigValue<Integer>("TELEPORT_MIN").getValue();
}
public double getVersion() {
return version;
}
public int TELEPORT_MIN();
}
+2
View File
@@ -40,3 +40,5 @@ config:
groups: true
# Load rules configuration from the database?
rules: true
# Load magic configuration from the database?
magic: false