From 14aa2a8905a4bb3c6e7ef07ae0b30cc63f5aeb28 Mon Sep 17 00:00:00 2001 From: gravitylow Date: Mon, 20 Jan 2014 15:29:44 -0500 Subject: [PATCH] Add check command for disabling or enabling checks on the fly --- .../anticheat/command/CommandBase.java | 2 + .../anticheat/command/CommandHandler.java | 1 + .../command/executors/CommandCheck.java | 89 +++++++++++++++++++ .../command/executors/CommandLog.java | 5 +- .../anticheat/manage/CheckManager.java | 4 +- 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 src/main/java/net/gravitydevelopment/anticheat/command/executors/CommandCheck.java diff --git a/src/main/java/net/gravitydevelopment/anticheat/command/CommandBase.java b/src/main/java/net/gravitydevelopment/anticheat/command/CommandBase.java index 2391486..f4cf627 100644 --- a/src/main/java/net/gravitydevelopment/anticheat/command/CommandBase.java +++ b/src/main/java/net/gravitydevelopment/anticheat/command/CommandBase.java @@ -20,6 +20,7 @@ package net.gravitydevelopment.anticheat.command; import net.gravitydevelopment.anticheat.AntiCheat; import net.gravitydevelopment.anticheat.config.Configuration; +import net.gravitydevelopment.anticheat.manage.CheckManager; import net.gravitydevelopment.anticheat.manage.UserManager; import net.gravitydevelopment.anticheat.util.Permission; import net.gravitydevelopment.anticheat.xray.XRayTracker; @@ -33,6 +34,7 @@ public class CommandBase { public static final Configuration CONFIG = AntiCheat.getManager().getConfiguration(); public static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager(); + public static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager(); public static final XRayTracker XRAY_TRACKER = AntiCheat.getManager().getXRayTracker(); public static final ChatColor RED = ChatColor.RED; public static final ChatColor YELLOW = ChatColor.YELLOW; diff --git a/src/main/java/net/gravitydevelopment/anticheat/command/CommandHandler.java b/src/main/java/net/gravitydevelopment/anticheat/command/CommandHandler.java index 3b44eb1..03ad189 100644 --- a/src/main/java/net/gravitydevelopment/anticheat/command/CommandHandler.java +++ b/src/main/java/net/gravitydevelopment/anticheat/command/CommandHandler.java @@ -33,6 +33,7 @@ public class CommandHandler implements CommandExecutor { public CommandHandler() { commands.add(new CommandHelp()); commands.add(new CommandCalibrate()); + commands.add(new CommandCheck()); commands.add(new CommandDebug()); commands.add(new CommandDeveloper()); commands.add(new CommandLog()); diff --git a/src/main/java/net/gravitydevelopment/anticheat/command/executors/CommandCheck.java b/src/main/java/net/gravitydevelopment/anticheat/command/executors/CommandCheck.java new file mode 100644 index 0000000..da44c97 --- /dev/null +++ b/src/main/java/net/gravitydevelopment/anticheat/command/executors/CommandCheck.java @@ -0,0 +1,89 @@ +/* + * 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 . + */ + +package net.gravitydevelopment.anticheat.command.executors; + +import net.gravitydevelopment.anticheat.AntiCheat; +import net.gravitydevelopment.anticheat.check.CheckType; +import net.gravitydevelopment.anticheat.command.CommandBase; +import net.gravitydevelopment.anticheat.util.Calibrator; +import net.gravitydevelopment.anticheat.util.Permission; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CommandCheck extends CommandBase { + + private static final String NAME = "AntiCheat Check Management"; + private static final String COMMAND = "check"; + private static final String USAGE = "anticheat check [check] [on/off]"; + private static final Permission PERMISSION = Permission.SYSTEM_CALIBRATE; + private static final String[] HELP = new String[3]; + + static { + HELP[0] = GRAY + "Use: " + AQUA + "/anticheat check [check] on" + GRAY + " to enable a check"; + HELP[1] = GRAY + "Use: " + AQUA + "/anticheat check [check] off" + GRAY + " to disable a check"; + StringBuilder builder = new StringBuilder(); + builder.append(GRAY + "Checks: "); + for (int i=0;i