diff --git a/pom.xml b/pom.xml
index 5c7fd1c..55eccad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,6 +8,7 @@
http://gravitydevelopment.net
${project.version}
+ UTF-8
diff --git a/src/main/java/net/gravitydevelopment/anticheat/AntiCheat.java b/src/main/java/net/gravitydevelopment/anticheat/AntiCheat.java
index 1ace007..2acee55 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/AntiCheat.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/AntiCheat.java
@@ -46,7 +46,6 @@ public class AntiCheat extends JavaPlugin {
private static Configuration config;
private static boolean verbose;
private static boolean developer;
- private static final long XRAY_TIME = 1200;
private static final int PROJECT_ID = 38723;
private static PacketManager packetManager;
private static boolean protocolLib = false;
@@ -105,9 +104,10 @@ public class AntiCheat extends JavaPlugin {
private void setupXray() {
final XRayTracker xtracker = manager.getXRayTracker();
- if (config.getConfig().logXRayStats.getValue()) {
+ final int time = config.getConfig().alertXRayInterval.getValue() * 20;
+ if (config.getConfig().checkXRay.getValue()) {
eventList.add(new XRayListener());
- if (config.getConfig().alertWhenXRayIsFound.getValue()) {
+ if (config.getConfig().alertXRay.getValue()) {
getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
@Override
public void run() {
@@ -122,7 +122,7 @@ public class AntiCheat extends JavaPlugin {
}
}
}
- }, XRAY_TIME, XRAY_TIME);
+ }, time, time);
verboseLog("Scheduled the XRay checker.");
}
diff --git a/src/main/java/net/gravitydevelopment/anticheat/CommandHandler.java b/src/main/java/net/gravitydevelopment/anticheat/CommandHandler.java
index 8ffd276..a3426ab 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/CommandHandler.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/CommandHandler.java
@@ -88,7 +88,7 @@ public class CommandHandler implements CommandExecutor {
public void handleXRay(CommandSender cs, String[] args) {
if (hasPermission(cs, Permission.SYSTEM_XRAY)) {
- if (CONFIG.getConfig().logXRayStats.getValue()) {
+ if (CONFIG.getConfig().checkXRay.getValue()) {
List list = SERVER.matchPlayer(args[1]);
if (list.size() == 1) {
Player player = list.get(0);
diff --git a/src/main/java/net/gravitydevelopment/anticheat/config/files/Config.java b/src/main/java/net/gravitydevelopment/anticheat/config/files/Config.java
index 9de4157..44d43e3 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/config/files/Config.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/config/files/Config.java
@@ -29,24 +29,31 @@ public class Config extends ConfigurationFile {
public static final String FILENAME = "config.yml";
public ConfigValue logToConsole;
- public ConfigValue logXRayStats;
public ConfigValue autoUpdate;
public ConfigValue verboseStartup;
- public ConfigValue alertWhenXRayIsFound;
public ConfigValue silentMode;
public ConfigValue exemptOp;
- public ConfigValue trackCreativeXRay;
+
+ public ConfigValue checkXRay;
+ public ConfigValue checkCreativeXRay;
+ public ConfigValue alertXRay;
+ public ConfigValue alertXRayInterval;
+
public ConfigValue eventChains;
public ConfigValue enterprise;
- public ConfigValue blockChatSpam;
- public ConfigValue blockCommandSpam;
+
+ public ConfigValue blockChatSpamSpeed;
+ public ConfigValue blockCommandSpamSpeed;
+ public ConfigValue blockChatSpamRepetition;
+ public ConfigValue blockCommandSpamRepetition;
+ public ConfigValue chatSpamActionOne;
+ public ConfigValue chatSpamActionTwo;
+ public ConfigValue commandSpamActionOne;
+ public ConfigValue commandSpamActionTwo;
public ConfigValue fileLogLevel;
- public ConfigValue spamKickAction;
- public ConfigValue spamBanAction;
-
- public ConfigValue> exemptedWorlds;
+ public ConfigValue> disabledWorlds;
public Config(AntiCheat plugin, Configuration config) {
super(plugin, config, FILENAME);
@@ -55,23 +62,31 @@ public class Config extends ConfigurationFile {
@Override
public void open() {
logToConsole = new ConfigValue("system.log-to-console");
- logXRayStats = new ConfigValue("xray.check-xray");
- alertWhenXRayIsFound = new ConfigValue("xray.alert");
+
+ checkXRay = new ConfigValue("xray.check-xray");
+ alertXRay = new ConfigValue("xray.alert");
+ alertXRayInterval = new ConfigValue("xray.alert-interval");
+ checkCreativeXRay = new ConfigValue("xray.check-creative");
+
autoUpdate = new ConfigValue("system.auto-update");
verboseStartup = new ConfigValue("system.verbose-startup");
silentMode = new ConfigValue("system.silent-mode");
exemptOp = new ConfigValue("system.exempt-op");
- trackCreativeXRay = new ConfigValue("xray.check-creative");
eventChains = new ConfigValue("system.event-chains");
enterprise = new ConfigValue("system.enterprise");
- blockChatSpam = new ConfigValue("spam.chat");
- blockCommandSpam = new ConfigValue("spam.command");
+
+ blockChatSpamSpeed = new ConfigValue("spam.chat.block-speed");
+ blockChatSpamRepetition = new ConfigValue("spam.chat.block-repetition");
+ chatSpamActionOne = new ConfigValue("spam.chat.action-one");
+ chatSpamActionTwo = new ConfigValue("spam.chat.action-two");
+
+ blockCommandSpamSpeed = new ConfigValue("spam.command.block-speed");
+ blockCommandSpamRepetition = new ConfigValue("spam.command.block-repetition");
+ commandSpamActionOne = new ConfigValue("spam.command.action-one");
+ commandSpamActionTwo = new ConfigValue("spam.command.action-two");
fileLogLevel = new ConfigValue("system.file-log-level");
- spamKickAction = new ConfigValue("spam.action-one");
- spamBanAction = new ConfigValue("spam.action-two");
-
- exemptedWorlds = new ConfigValue>("disable-in");
+ disabledWorlds = new ConfigValue>("disable-in");
}
}
diff --git a/src/main/java/net/gravitydevelopment/anticheat/config/files/Magic.java b/src/main/java/net/gravitydevelopment/anticheat/config/files/Magic.java
index 5705e4a..e51355d 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/config/files/Magic.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/config/files/Magic.java
@@ -148,17 +148,21 @@ public class Magic extends ConfigurationFile {
*/
public int BLOCK_PUNCH_MIN;
/**
- * Number of chat spam violations before a player is warned; Type=integer, +Leniency=Increase.
+ * Number of command spam violations before action one is executed; Type=integer, +Leniency=Increase.
*/
- public int CHAT_WARN_LEVEL;
+ public int COMMAND_ACTION_ONE_LEVEL;
/**
- * Number of chat spam violations before a player is kicked; Type=integer, +Leniency=Increase.
+ * Number of command spam violations before action two is executed; Type=integer, +Leniency=Increase.
*/
- public int CHAT_KICK_LEVEL;
+ public int COMMAND_ACTION_TWO_LEVEL;
/**
- * Number of kicks for chat violation before a player is banned; Type=integer, +Leniency=Increase.
+ * Number of chat spam violations before action one is executed; Type=integer, +Leniency=Increase.
*/
- public int CHAT_BAN_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;
/**
* Number of times a player can be caught in-flight before action is taken; Type=integer, +Leniency=Increase.
*/
@@ -223,12 +227,20 @@ public class Magic extends ConfigurationFile {
* Minimum time between animations; Type=system, +Leniency=Increase.
*/
public int ANIMATION_MIN;
+ /**
+ * Minimum time between commands; Type=system, +Leniency=Increase.
+ */
+ public int COMMAND_MIN;
+ /**
+ * MTime before repeating a command is ignored; Type=system, +Leniency=Increase.
+ */
+ public int COMMAND_REPEAT_MIN;
/**
* Minimum time between chats; Type=system, +Leniency=Increase.
*/
public int CHAT_MIN;
/**
- * Minimum time between repeating yourself in the chat; Type=system, +Leniency=Increase.
+ * Time before repeating yourself in chat is ignored; Type=system, +Leniency=Increase.
*/
public int CHAT_REPEAT_MIN;
/**
@@ -400,9 +412,10 @@ public class Magic extends ConfigurationFile {
FASTPLACE_MAXVIOLATIONS_CREATIVE = new ConfigValue("FASTPLACE_MAXVIOLATIONS_CREATIVE").getValue();
FASTPLACE_MAXVIOLATIONTIME = new ConfigValue("FASTPLACE_MAXVIOLATIONTIME").getValue();
BLOCK_PUNCH_MIN = new ConfigValue("BLOCK_PUNCH_MIN").getValue();
- CHAT_WARN_LEVEL = new ConfigValue("CHAT_WARN_LEVEL").getValue();
- CHAT_KICK_LEVEL = new ConfigValue("CHAT_KICK_LEVEL").getValue();
- CHAT_BAN_LEVEL = new ConfigValue("CHAT_BAN_LEVEL").getValue();
+ CHAT_ACTION_ONE_LEVEL = new ConfigValue("CHAT_ACTION_ONE_LEVEL").getValue();
+ CHAT_ACTION_TWO_LEVEL = new ConfigValue("CHAT_ACTION_TWO_LEVEL").getValue();
+ COMMAND_ACTION_ONE_LEVEL = new ConfigValue("COMMAND_ACTION_ONE_LEVEL").getValue();
+ COMMAND_ACTION_TWO_LEVEL = new ConfigValue("COMMAND_ACTION_TWO_LEVEL").getValue();
FLIGHT_LIMIT = new ConfigValue("FLIGHT_LIMIT").getValue();
FLIGHT_BLOCK_LIMIT = new ConfigValue("FLIGHT_BLOCK_LIMIT").getValue();
WATER_CLIMB_MAX = new ConfigValue("WATER_CLIMB_MAX").getValue();
@@ -419,6 +432,8 @@ public class Magic extends ConfigurationFile {
WATER_SPEED_VIOLATION_MAX = new ConfigValue("WATER_SPEED_VIOLATION_MAX").getValue();
SPRINT_FOOD_MIN = new ConfigValue("SPRINT_FOOD_MIN").getValue();
ANIMATION_MIN = new ConfigValue("ANIMATION_MIN").getValue();
+ COMMAND_MIN = new ConfigValue("COMMAND_MIN").getValue();
+ COMMAND_REPEAT_MIN = new ConfigValue("COMMAND_REPEAT_MIN").getValue();
CHAT_MIN = new ConfigValue("CHAT_MIN").getValue();
CHAT_REPEAT_MIN = new ConfigValue("CHAT_REPEAT_MIN").getValue();
SPRINT_MIN = new ConfigValue("SPRINT_MIN").getValue();
diff --git a/src/main/java/net/gravitydevelopment/anticheat/event/PlayerListener.java b/src/main/java/net/gravitydevelopment/anticheat/event/PlayerListener.java
index 9382aa7..aec0b7c 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/event/PlayerListener.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/event/PlayerListener.java
@@ -45,13 +45,13 @@ public class PlayerListener extends EventListener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
- if (getCheckManager().willCheck(player, CheckType.SPAM) && getConfig().getConfig().blockCommandSpam.getValue()) {
- CheckResult result = getBackend().checkSpam(player, event.getMessage());
+ if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM)) {
+ CheckResult result = getBackend().checkCommandSpam(player, event.getMessage());
if (result.failed()) {
event.setCancelled(!silentMode());
- player.sendMessage(ChatColor.RED + result.getMessage());
- getBackend().processChatSpammer(player);
- log(null, player, CheckType.SPAM);
+ if (!silentMode()) player.sendMessage(ChatColor.RED + result.getMessage());
+ getBackend().processCommandSpammer(player);
+ log(null, player, CheckType.COMMAND_SPAM);
}
}
@@ -140,15 +140,15 @@ public class PlayerListener extends EventListener {
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
- if (getCheckManager().willCheck(player, CheckType.SPAM) && getConfig().getConfig().blockChatSpam.getValue()) {
- CheckResult result = getBackend().checkSpam(player, event.getMessage());
+ if (getCheckManager().willCheck(player, CheckType.CHAT_SPAM)) {
+ CheckResult result = getBackend().checkChatSpam(player, event.getMessage());
if (result.failed()) {
event.setCancelled(!silentMode());
- if (!result.getMessage().equals("")) {
+ if (!result.getMessage().equals("") && !silentMode()) {
player.sendMessage(ChatColor.RED + result.getMessage());
}
getBackend().processChatSpammer(player);
- log(null, player, CheckType.SPAM);
+ log(null, player, CheckType.CHAT_SPAM);
}
}
@@ -157,7 +157,6 @@ public class PlayerListener extends EventListener {
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
- getBackend().clearChatLevel(event.getPlayer());
getBackend().garbageClean(event.getPlayer());
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
diff --git a/src/main/java/net/gravitydevelopment/anticheat/manage/Backend.java b/src/main/java/net/gravitydevelopment/anticheat/manage/Backend.java
index 75817a0..43cfa51 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/manage/Backend.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/manage/Backend.java
@@ -46,7 +46,7 @@ public class Backend {
private Map ascensionCount = new HashMap();
private Map blocksOverFlight = new HashMap();
private Map chatLevel = new HashMap();
- private Map chatKicks = new HashMap();
+ private Map commandLevel = new HashMap();
private Map nofallViolation = new HashMap();
private Map speedViolation = new HashMap();
private Map fastBreakViolation = new HashMap();
@@ -127,7 +127,6 @@ public class Backend {
isAscending.remove(pN);
ascensionCount.remove(pN);
blocksOverFlight.remove(pN);
- chatLevel.remove(pN);
nofallViolation.remove(pN);
fastBreakViolation.remove(pN);
yAxisViolations.remove(pN);
@@ -748,7 +747,7 @@ public class Backend {
lastHeal.put(player.getName(), System.currentTimeMillis());
}
- public CheckResult checkSpam(Player player, String msg) {
+ public CheckResult checkChatSpam(Player player, String msg) {
String name = player.getName();
User user = manager.getUserManager().getUser(name);
if (user.getLastMessageTime() != -1) {
@@ -762,8 +761,12 @@ public class Backend {
if (System.currentTimeMillis() - l > magic.CHAT_REPEAT_MIN * 100) {
user.clearMessages();
break;
- } else if ((m.equalsIgnoreCase(msg) && i == 1) || System.currentTimeMillis() - user.getLastMessageTime() < magic.CHAT_MIN * 2) {
- return new CheckResult(Result.FAILED, lang.spamWarning.getValue());
+ } else {
+ if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue() && m.equalsIgnoreCase(msg) && i == 1) {
+ return new CheckResult(Result.FAILED, lang.spamWarning.getValue());
+ } else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN * 2) {
+ return new CheckResult(Result.FAILED, lang.spamWarning.getValue());
+ }
}
}
}
@@ -771,6 +774,33 @@ public class Backend {
return PASS;
}
+ public CheckResult checkCommandSpam(Player player, String cmd) {
+ String name = player.getName();
+ User user = manager.getUserManager().getUser(name);
+ if (user.getLastCommandTime() != -1) {
+ for (int i = 0; i < 2; i++) {
+ String m = user.getCommand(i);
+ if (m == null) {
+ break;
+ }
+ Long l = user.getCommandTime(i);
+
+ 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(Result.FAILED, lang.spamWarning.getValue());
+ } else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN * 2) {
+ return new CheckResult(Result.FAILED, lang.spamWarning.getValue());
+ }
+ }
+ }
+ }
+ user.addCommand(cmd);
+ return PASS;
+ }
+
public CheckResult checkInventoryClicks(Player player) {
if (player.getGameMode() == GameMode.CREATIVE) {
return PASS;
@@ -865,10 +895,6 @@ public class Backend {
itemInHand.put(player.getName(), player.getItemInHand().getType());
}
- public void clearChatLevel(Player player) {
- chatLevel.remove(player.getName());
- }
-
public void logInstantBreak(final Player player) {
instantBreakExempt.put(player.getName(), System.currentTimeMillis());
}
@@ -1036,24 +1062,24 @@ public class Backend {
}
public void processChatSpammer(Player player) {
- if (chatLevel.get(player.getName()) != null && chatLevel.get(player.getName()) >= magic.CHAT_KICK_LEVEL) {
- if (player != null && player.isOnline()) {
- String name = player.getName();
- int kick;
- if (chatKicks.get(name) == null || chatKicks.get(name) == 0) {
- kick = 1;
- chatKicks.put(name, kick);
- } else {
- kick = chatKicks.get(name) + 1;
- chatKicks.put(name, kick);
- }
-
- String event = kick <= magic.CHAT_BAN_LEVEL ? manager.getConfiguration().getConfig().spamKickAction.getValue() : manager.getConfiguration().getConfig().spamBanAction.getValue();
- manager.getUserManager().execute(manager.getUserManager().getUser(player.getName()), Utilities.stringToList(event), CheckType.SPAM, lang.spamKickReason.getValue() + "(" + kick + "/3)", Utilities.stringToList(lang.spamWarning.getValue()), lang.spamBanReason.getValue());
- }
- } else {
- increment(player, chatLevel, magic.CHAT_KICK_LEVEL);
+ 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();
+ 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());
}
+ System.out.println("Chat level: "+level);
+ chatLevel.put(user.getName(), level + 1);
+ }
+
+ 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();
+ 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);
}
public int increment(Player player, Map map, int num) {
diff --git a/src/main/java/net/gravitydevelopment/anticheat/manage/CheckManager.java b/src/main/java/net/gravitydevelopment/anticheat/manage/CheckManager.java
index b982985..b9617d2 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/manage/CheckManager.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/manage/CheckManager.java
@@ -137,7 +137,7 @@ public class CheckManager {
* @return true if the player's world is enabled
*/
public boolean checkInWorld(Player player) {
- return !config.getConfig().exemptedWorlds.getValue().contains(player.getWorld().getName());
+ return !config.getConfig().disabledWorlds.getValue().contains(player.getWorld().getName());
}
/**
diff --git a/src/main/java/net/gravitydevelopment/anticheat/manage/CheckType.java b/src/main/java/net/gravitydevelopment/anticheat/manage/CheckType.java
index 6d1d171..00a5e15 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/manage/CheckType.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/manage/CheckType.java
@@ -40,7 +40,8 @@ public enum CheckType {
NO_SWING(Permission.CHECK_NOSWING),
FAST_BREAK(Permission.CHECK_FASTBREAK),
FAST_PLACE(Permission.CHECK_FASTPLACE),
- SPAM(Permission.CHECK_SPAM),
+ CHAT_SPAM(Permission.CHECK_CHATSPAM),
+ COMMAND_SPAM(Permission.CHECK_COMMANDSPAM),
SPRINT(Permission.CHECK_SPRINT),
SNEAK(Permission.CHECK_SNEAK),
SPEED(Permission.CHECK_SPEED),
diff --git a/src/main/java/net/gravitydevelopment/anticheat/manage/User.java b/src/main/java/net/gravitydevelopment/anticheat/manage/User.java
index 1ae70a0..fb3c592 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/manage/User.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/manage/User.java
@@ -43,6 +43,8 @@ public class User {
private int toX, toY, toZ;
private String[] messages = new String[2];
private Long[] messageTimes = new Long[2];
+ private String[] commands = new String[2];
+ private Long[] commandTimes = new Long[2];
private boolean isWaitingOnLevelSync;
private Timestamp levelSyncTimestamp;
@@ -281,11 +283,24 @@ public class User {
* @param message Message to log
*/
public void addMessage(String message) {
- messages[1] = messages[0];
- messages[0] = message;
+ addToSpamLog(message, messages, messageTimes);
+ }
- messageTimes[1] = messageTimes[0];
- messageTimes[0] = System.currentTimeMillis();
+ /**
+ * Log a player's command
+ *
+ * @param command Command to log
+ */
+ public void addCommand(String command) {
+ addToSpamLog(command, commands, commandTimes);
+ }
+
+ private void addToSpamLog(String string, String[] messages, Long[] times) {
+ messages[1] = messages[0];
+ messages[0] = string;
+
+ times[1] = times[0];
+ times[0] = System.currentTimeMillis();
}
/**
@@ -298,6 +313,16 @@ public class User {
return messages[index];
}
+ /**
+ * Get a stored command
+ *
+ * @param index Index of the command in storage
+ * @return the command
+ */
+ public String getCommand(int index) {
+ return commands[index];
+ }
+
/**
* Get the time a message in storage was sent
*
@@ -308,6 +333,16 @@ public class User {
return messageTimes[index];
}
+ /**
+ * Get the time a command in storage was sent
+ *
+ * @param index Index of the command in storage
+ * @return time the command was sent
+ */
+ public Long getCommandTime(int index) {
+ return commandTimes[index];
+ }
+
/**
* Clear all stored messages
*/
@@ -316,6 +351,14 @@ public class User {
messageTimes = new Long[2];
}
+ /**
+ * Clear all stored commands
+ */
+ public void clearCommands() {
+ commands = new String[2];
+ commandTimes = new Long[2];
+ }
+
/**
* Get the time the very last stored message was sent
*
@@ -325,6 +368,15 @@ public class User {
return getMessageTime(0) == null ? -1 : getMessageTime(0);
}
+ /**
+ * Get the time the very last stored command was sent
+ *
+ * @return the last command's time
+ */
+ public Long getLastCommandTime() {
+ return getCommandTime(0) == null ? -1 : getCommandTime(0);
+ }
+
private List getLevels() {
return config.getGroups().getGroups();
}
diff --git a/src/main/java/net/gravitydevelopment/anticheat/util/Permission.java b/src/main/java/net/gravitydevelopment/anticheat/util/Permission.java
index c505ed1..f5375ed 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/util/Permission.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/util/Permission.java
@@ -30,7 +30,8 @@ public enum Permission {
CHECK_NOSWING,
CHECK_FASTBREAK,
CHECK_FASTPLACE,
- CHECK_SPAM,
+ CHECK_CHATSPAM,
+ CHECK_COMMANDSPAM,
CHECK_SPRINT,
CHECK_SNEAK,
CHECK_SPEED,
@@ -66,6 +67,7 @@ public enum Permission {
private static final String PERMISSION_ALL = "anticheat.*";
public boolean get(CommandSender cs) {
+ if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission("anticheat.check.spam")) return true;
return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL);
}
diff --git a/src/main/java/net/gravitydevelopment/anticheat/xray/XRayListener.java b/src/main/java/net/gravitydevelopment/anticheat/xray/XRayListener.java
index a66a94e..09700ff 100644
--- a/src/main/java/net/gravitydevelopment/anticheat/xray/XRayListener.java
+++ b/src/main/java/net/gravitydevelopment/anticheat/xray/XRayListener.java
@@ -36,9 +36,9 @@ public class XRayListener implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
- if (config.getConfig().logXRayStats.getValue()) {
+ if (config.getConfig().checkXRay.getValue()) {
Player p = event.getPlayer();
- if (p.getGameMode() == GameMode.CREATIVE && !config.getConfig().trackCreativeXRay.getValue()) {
+ if (p.getGameMode() == GameMode.CREATIVE && !config.getConfig().checkCreativeXRay.getValue()) {
return;
}
String player = p.getName();
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index db1c037..c27ab41 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -5,16 +5,25 @@ xray:
check-xray: true
# Should a warning be sent to admins when a person is found that could be xraying?
alert: false
+ # How often (in seconds) should AntiCheat check for xrayers if alert is true?
+ alert-interval: 60
# Should players in creative mode be tracked for possible xray usage?
check-creative: true
spam:
- # Should AntiCheat block players spamming messages in chat?
- chat: true
+ chat:
+ # Should AntiCheat block players spamming messages in chat?
+ block-speed: true
+ block-repetition: true
+ # Valid actions = NONE,KICK,BAN,COMMAND[command]
+ action-one: KICK
+ action-two: BAN
# Should AntiCheat block players spamming commands in chat?
- command: true
- # Valid actions = NONE,KICK,BAN,COMMAND[command]
- action-one: KICK
- action-two: BAN
+ command:
+ block-speed: true
+ block-repetition: true
+ # Valid actions = NONE,KICK,BAN,COMMAND[command]
+ action-one: KICK
+ action-two: BAN
system:
# Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so, and will have to update manually.
auto-update: true
diff --git a/src/main/resources/magic.yml b/src/main/resources/magic.yml
index fb12ab0..9723591 100644
--- a/src/main/resources/magic.yml
+++ b/src/main/resources/magic.yml
@@ -2,24 +2,28 @@
# Please report any bugs: http://dev.bukkit.org/server-mods/anticheat/
# Documentation for these values is available at http://gravitydevelopment.net/docs/anticheat/net/h31ix/anticheat/util/Magic.html
ANIMATION_CHECK: 5
-ASCENSION_COUNT_MAX: 8
-ANIMATION_TIMEMIN: 400
ANIMATION_MIN: 200
+ANIMATION_TIMEMIN: 400
+ASCENSION_COUNT_MAX: 8
BLOCK_BREAK_MIN: 0.1
BLOCK_MAX_DISTANCE: 5.5
BLOCK_MAX_DISTANCE_CREATIVE: 6.0
BLOCK_PLACE_MIN: 0.1
BLOCK_PUNCH_MIN: 5
BOW_ERROR: 0.25
-CHAT_BAN_LEVEL: 3
-CHAT_KICK_LEVEL: 10
+CHAT_ACTION_ONE_LEVEL: 3
+CHAT_ACTION_TWO_LEVEL: 5
CHAT_MIN: 100
CHAT_REPEAT_MIN: 260
CHAT_WARN_LEVEL: 7
+COMMAND_ACTION_ONE_LEVEL: 3
+COMMAND_ACTION_TWO_LEVEL: 5
+COMMAND_MIN: 100
+COMMAND_REPEAT_MIN: 260
DAMAGE_TIME: 3000
DROP_CHECK: 10
-DROPPED_ITEM_TIME: 100
DROP_TIME_MIN: 800
+DROPPED_ITEM_TIME: 100
EAT_TIME_MIN: 1000
ENTERED_EXITED_TIME: 1000
ENTITY_MAX_DISTANCE: 5.5
@@ -71,8 +75,8 @@ XZ_SPEED_MAX_FLY: 0.56
XZ_SPEED_MAX_POTION: 0.7
XZ_SPEED_MAX_SNEAK: 0.15
XZ_SPEED_MAX_SOULSAND: 0.13
-XZ_SPEED_MAX_SOULSAND_SPRINT: 0.2
XZ_SPEED_MAX_SOULSAND_POTION: 0.16
+XZ_SPEED_MAX_SOULSAND_SPRINT: 0.2
XZ_SPEED_MAX_SPRINT: 0.65
XZ_SPEED_MAX_WATER: 0.19
XZ_SPEED_MAX_WATER_SPRINT: 0.3