mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Removed outdated and broken xray check
This commit is contained in:
1 parent
eb6372b344
commit
9af31633ea
16 files changed
+33
-478
No files matched your search
@@ -22,7 +22,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -39,9 +38,6 @@ import net.gravitydevelopment.anticheat.event.VehicleListener;
|
||||
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
|
||||
import net.gravitydevelopment.anticheat.manage.PacketManager;
|
||||
import net.gravitydevelopment.anticheat.util.User;
|
||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||
import net.gravitydevelopment.anticheat.xray.XRayListener;
|
||||
import net.gravitydevelopment.anticheat.xray.XRayTracker;
|
||||
|
||||
public class AntiCheat extends JavaPlugin {
|
||||
|
||||
@@ -70,8 +66,6 @@ public class AntiCheat extends JavaPlugin {
|
||||
eventList.add(new InventoryListener());
|
||||
// Order is important in some cases, don't screw with these unless needed, especially config
|
||||
setupConfig();
|
||||
// Xray must come before events
|
||||
setupXray();
|
||||
setupEvents();
|
||||
setupCommands();
|
||||
// setupProtocol(); TODO
|
||||
@@ -114,33 +108,6 @@ public class AntiCheat extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private void setupXray() {
|
||||
final XRayTracker xtracker = manager.getXRayTracker();
|
||||
final int time = config.getConfig().alertXRayInterval.getValue() * 20;
|
||||
if (config.getConfig().checkXRay.getValue()) {
|
||||
eventList.add(new XRayListener());
|
||||
if (config.getConfig().alertXRay.getValue()) {
|
||||
getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
String name = player.getName();
|
||||
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name)) {
|
||||
List<String> alert = new ArrayList<String>();
|
||||
alert.add(ChatColor.YELLOW + "[ALERT] " + ChatColor.WHITE + name + ChatColor.YELLOW + " might be using xray.");
|
||||
alert.add(ChatColor.YELLOW + "[ALERT] Please check their xray stats using " + ChatColor.WHITE + "/anticheat xray " + name + ChatColor.YELLOW + ".");
|
||||
Utilities.alert(alert);
|
||||
xtracker.logAlert(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, time, time);
|
||||
|
||||
verboseLog("Scheduled the XRay checker.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupEvents() {
|
||||
for (Listener listener : eventList) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
|
||||
@@ -18,16 +18,16 @@
|
||||
|
||||
package net.gravitydevelopment.anticheat.api;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
|
||||
import net.gravitydevelopment.anticheat.manage.CheckManager;
|
||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
||||
import net.gravitydevelopment.anticheat.manage.UserManager;
|
||||
import net.gravitydevelopment.anticheat.util.Group;
|
||||
import net.gravitydevelopment.anticheat.xray.XRayTracker;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
||||
import net.gravitydevelopment.anticheat.manage.AntiCheatManager;
|
||||
import net.gravitydevelopment.anticheat.manage.CheckManager;
|
||||
import net.gravitydevelopment.anticheat.manage.UserManager;
|
||||
import net.gravitydevelopment.anticheat.util.Group;
|
||||
|
||||
/**
|
||||
* Developer's interface for all things AntiCheat.
|
||||
@@ -36,7 +36,6 @@ import java.util.List;
|
||||
public class AntiCheatAPI {
|
||||
private static CheckManager chk = AntiCheat.getManager().getCheckManager();
|
||||
private static UserManager umr = AntiCheat.getManager().getUserManager();
|
||||
private static XRayTracker xtracker = AntiCheat.getManager().getXRayTracker();
|
||||
|
||||
// CheckManager API
|
||||
|
||||
@@ -166,19 +165,6 @@ public class AntiCheatAPI {
|
||||
return getManager().getConfiguration().getGroups().getGroups();
|
||||
}
|
||||
|
||||
// XrayTracker API
|
||||
|
||||
/**
|
||||
* Find out if a player is detected as using xray hacks (on any ore)
|
||||
*
|
||||
* @param player Player to check
|
||||
* @return true if the player has any xray anomalies.
|
||||
*/
|
||||
public static boolean isXrayer(Player player) {
|
||||
String name = player.getName();
|
||||
return xtracker.sufficientData(name) && xtracker.hasAbnormal(name);
|
||||
}
|
||||
|
||||
// Advanced Users Only API.
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,6 @@ public enum CheckType {
|
||||
FAST_EAT(Permission.CHECK_FASTEAT),
|
||||
FAST_HEAL(Permission.CHECK_FASTHEAL),
|
||||
FORCEFIELD(Permission.CHECK_FORCEFIELD),
|
||||
XRAY(Permission.CHECK_XRAY),
|
||||
LONG_REACH(Permission.CHECK_LONGREACH),
|
||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
||||
|
||||
@@ -18,24 +18,23 @@
|
||||
|
||||
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;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
public static final ChatColor GREEN = ChatColor.GREEN;
|
||||
|
||||
@@ -18,13 +18,23 @@
|
||||
|
||||
package net.gravitydevelopment.anticheat.command;
|
||||
|
||||
import net.gravitydevelopment.anticheat.command.executors.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandCheck;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandDebug;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandDeveloper;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandHelp;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandLog;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandReload;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandReport;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandReset;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandSpy;
|
||||
import net.gravitydevelopment.anticheat.command.executors.CommandUpdate;
|
||||
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
|
||||
@@ -42,7 +52,6 @@ public class CommandHandler implements CommandExecutor {
|
||||
commands.add(new CommandReset());
|
||||
commands.add(new CommandSpy());
|
||||
commands.add(new CommandUpdate());
|
||||
commands.add(new CommandXray());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,6 @@ public class CommandHelp extends CommandBase {
|
||||
GRAY + "/anti " + AQUA + "log " + GOLD + "[file/console] [on/off]",
|
||||
GRAY + "/anti " + AQUA + "report " + GOLD + "[group/user]",
|
||||
GRAY + "/anti " + AQUA + "reset " + GOLD + "[user]",
|
||||
GRAY + "/anti " + AQUA + "xray " + GOLD + "[user]",
|
||||
GRAY + "/anti " + AQUA + "spy " + GOLD + "[user]",
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ public class CommandReset extends CommandBase {
|
||||
User user = USER_MANAGER.getUser(args[0]);
|
||||
if (user != null) {
|
||||
user.resetLevel();
|
||||
XRAY_TRACKER.reset(args[0]);
|
||||
user.clearMessages();
|
||||
AntiCheat.getManager().getBackend().resetChatLevel(user);
|
||||
cs.sendMessage(args[0] + GREEN + " has been reset.");
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* 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.command.executors;
|
||||
|
||||
import net.gravitydevelopment.anticheat.command.CommandBase;
|
||||
import net.gravitydevelopment.anticheat.util.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandXray extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat XRAY Stats";
|
||||
private static final String COMMAND = "xray";
|
||||
private static final String USAGE = "anticheat xray [user]";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_XRAY;
|
||||
private static final String[] HELP = {
|
||||
GRAY + "Use: " + AQUA + "/anticheat xray [user]" + GRAY + " to view xray statistics for a user",
|
||||
};
|
||||
|
||||
public CommandXray() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (CONFIG.getConfig().checkXRay.getValue()) {
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
if (player != null) {
|
||||
if (XRAY_TRACKER.sufficientData(player.getName())) {
|
||||
XRAY_TRACKER.sendStats(cs, player.getName());
|
||||
} else {
|
||||
cs.sendMessage(RED + "Insufficient data collected from " + WHITE + args[0] + RED + ".");
|
||||
cs.sendMessage(RED + "Please wait until more info is collected before predictions are calculated.");
|
||||
}
|
||||
} else if (XRAY_TRACKER.sufficientData(args[0])) {
|
||||
XRAY_TRACKER.sendStats(cs, args[1]);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Insufficient data collected from " + WHITE + args[0] + RED + ".");
|
||||
cs.sendMessage(RED + "Please wait until more info is collected before predictions are calculated.");
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(RED + "XRay logging is off in the config.");
|
||||
}
|
||||
} else {
|
||||
sendHelp(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,11 +34,6 @@ public class Config extends ConfigurationFile {
|
||||
public ConfigValue<Boolean> silentMode;
|
||||
public ConfigValue<Boolean> exemptOp;
|
||||
|
||||
public ConfigValue<Boolean> checkXRay;
|
||||
public ConfigValue<Boolean> checkCreativeXRay;
|
||||
public ConfigValue<Boolean> alertXRay;
|
||||
public ConfigValue<Integer> alertXRayInterval;
|
||||
|
||||
public ConfigValue<Boolean> eventChains;
|
||||
public ConfigValue<Boolean> enterprise;
|
||||
|
||||
@@ -64,11 +59,6 @@ public class Config extends ConfigurationFile {
|
||||
public void open() {
|
||||
logToConsole = new ConfigValue<Boolean>("system.log-to-console");
|
||||
|
||||
checkXRay = new ConfigValue<Boolean>("xray.check-xray");
|
||||
alertXRay = new ConfigValue<Boolean>("xray.alert");
|
||||
alertXRayInterval = new ConfigValue<Integer>("xray.alert-interval");
|
||||
checkCreativeXRay = new ConfigValue<Boolean>("xray.check-creative");
|
||||
|
||||
autoUpdate = new ConfigValue<Boolean>("system.auto-update");
|
||||
verboseStartup = new ConfigValue<Boolean>("system.verbose-startup");
|
||||
silentMode = new ConfigValue<Boolean>("system.silent-mode");
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
|
||||
package net.gravitydevelopment.anticheat.manage;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.Backend;
|
||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||
import net.gravitydevelopment.anticheat.xray.XRayTracker;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.Backend;
|
||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||
|
||||
/**
|
||||
* The internal hub for all managers.
|
||||
*/
|
||||
@@ -36,7 +36,6 @@ import java.util.logging.Logger;
|
||||
public class AntiCheatManager {
|
||||
private static AntiCheat plugin = null;
|
||||
private static Configuration configuration;
|
||||
private static XRayTracker xrayTracker = null;
|
||||
private static UserManager userManager = null;
|
||||
private static CheckManager checkManager = null;
|
||||
private static LoggingManager loggingManager = null;
|
||||
@@ -46,10 +45,8 @@ public class AntiCheatManager {
|
||||
|
||||
public AntiCheatManager(AntiCheat instance, Logger logger) {
|
||||
plugin = instance;
|
||||
// now load all the others!!!!!
|
||||
configuration = new Configuration(plugin, this);
|
||||
loggingManager = new LoggingManager(plugin, logger, configuration);
|
||||
xrayTracker = new XRayTracker();
|
||||
userManager = new UserManager(this);
|
||||
checkManager = new CheckManager(this);
|
||||
backend = new Backend(this);
|
||||
@@ -115,10 +112,6 @@ public class AntiCheatManager {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public XRayTracker getXRayTracker() {
|
||||
return xrayTracker;
|
||||
}
|
||||
|
||||
public UserManager getUserManager() {
|
||||
return userManager;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ public enum Permission {
|
||||
CHECK_FASTEAT,
|
||||
CHECK_FASTHEAL,
|
||||
CHECK_FORCEFIELD,
|
||||
CHECK_XRAY,
|
||||
CHECK_LONGREACH,
|
||||
CHECK_FASTPROJECTILE,
|
||||
CHECK_ITEMSPAM,
|
||||
@@ -52,7 +51,6 @@ public enum Permission {
|
||||
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG,
|
||||
SYSTEM_XRAY,
|
||||
SYSTEM_RESET,
|
||||
SYSTEM_SPY,
|
||||
SYSTEM_HELP,
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* 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.xray;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||
import net.gravitydevelopment.anticheat.manage.CheckManager;
|
||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class XRayListener implements Listener {
|
||||
private XRayTracker tracker = AntiCheat.getManager().getXRayTracker();
|
||||
private Configuration config = AntiCheat.getManager().getConfiguration();
|
||||
private CheckManager checkManager = AntiCheat.getManager().getCheckManager();
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (config.getConfig().checkXRay.getValue()) {
|
||||
Player p = event.getPlayer();
|
||||
if (p.getGameMode() == GameMode.CREATIVE && !config.getConfig().checkCreativeXRay.getValue()) {
|
||||
return;
|
||||
}
|
||||
String player = p.getName();
|
||||
if (checkManager.willCheck(p, CheckType.XRAY)) {
|
||||
Material m = event.getBlock().getType();
|
||||
if (m == Material.DIAMOND_ORE) {
|
||||
tracker.addDiamond(player);
|
||||
} else if (m == Material.IRON_ORE) {
|
||||
tracker.addIron(player);
|
||||
} else if (m == Material.GOLD_ORE) {
|
||||
tracker.addGold(player);
|
||||
} else if (m == Material.LAPIS_ORE) {
|
||||
tracker.addLapis(player);
|
||||
} else if (m == Material.REDSTONE_ORE || m == Material.GLOWING_REDSTONE_ORE) {
|
||||
tracker.addRedstone(player);
|
||||
} else if (m == Material.GOLD_ORE) {
|
||||
tracker.addGold(player);
|
||||
} else {
|
||||
tracker.addBlock(player);
|
||||
}
|
||||
tracker.addTotal(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* 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.xray;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class XRayStats {
|
||||
private static final int DIVISOR = 100;
|
||||
private double t = 1;
|
||||
private double d = 0;
|
||||
private double g = 0;
|
||||
private double i = 0;
|
||||
private double l = 0;
|
||||
private double r = 0;
|
||||
private double o = 0;
|
||||
|
||||
public XRayStats(String player, Map<String, Integer> diamond, Map<String, Integer> gold, Map<String, Integer> iron, Map<String, Integer> lapis, Map<String, Integer> redstone, Map<String, Integer> other, Map<String, Integer> total) {
|
||||
if (total.get(player) != null) {
|
||||
t = total.get(player);
|
||||
}
|
||||
if (diamond.get(player) != null) {
|
||||
d = (diamond.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if (gold.get(player) != null) {
|
||||
g = (gold.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if (iron.get(player) != null) {
|
||||
i = (iron.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if (lapis.get(player) != null) {
|
||||
l = (lapis.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if (redstone.get(player) != null) {
|
||||
r = (redstone.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if (other.get(player) != null) {
|
||||
o = (other.get(player) / t) * DIVISOR;
|
||||
}
|
||||
}
|
||||
|
||||
public double getTotal() {
|
||||
return t;
|
||||
}
|
||||
|
||||
public double getDiamond() {
|
||||
return d;
|
||||
}
|
||||
|
||||
public double getGold() {
|
||||
return g;
|
||||
}
|
||||
|
||||
public double getIron() {
|
||||
return i;
|
||||
}
|
||||
|
||||
public double getLapis() {
|
||||
return l;
|
||||
}
|
||||
|
||||
public double getRedstone() {
|
||||
return r;
|
||||
}
|
||||
|
||||
public double getOther() {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* 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.xray;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class XRayTracker {
|
||||
private Map<String, Integer> diamond = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> gold = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> iron = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> lapis = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> redstone = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> block = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> totalblock = new HashMap<String, Integer>();
|
||||
private List<String> alerted = new ArrayList<String>();
|
||||
private static final ChatColor GREEN = ChatColor.GREEN;
|
||||
private static final ChatColor WHITE = ChatColor.WHITE;
|
||||
private static final ChatColor RED = ChatColor.RED;
|
||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||
private static final int RATIO_DIVISOR = 3;
|
||||
private static final int POWER = 10;
|
||||
private static final int MIN_BLOCK_COUNT = 100;
|
||||
|
||||
public XRayTracker() {
|
||||
}
|
||||
|
||||
public boolean sufficientData(String player) {
|
||||
return totalblock.get(player) != null && totalblock.get(player) >= MIN_BLOCK_COUNT;
|
||||
}
|
||||
|
||||
public void calculate(CommandSender cs, String player, double x, double b, String type) {
|
||||
ChatColor color = WHITE;
|
||||
if (x >= b / RATIO_DIVISOR) {
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY + "Percent " + type + " ore: " + color + round(x) + "%");
|
||||
}
|
||||
|
||||
public boolean calculate(String player, double x, double b) {
|
||||
return x >= b / RATIO_DIVISOR;
|
||||
}
|
||||
|
||||
public boolean hasAbnormal(String player) {
|
||||
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
||||
double total = stats.getOther();
|
||||
return calculate(player, stats.getDiamond(), total) || calculate(player, stats.getGold(), total) || calculate(player, stats.getIron(), total) || calculate(player, stats.getLapis(), total) || calculate(player, stats.getRedstone(), total);
|
||||
}
|
||||
|
||||
public boolean hasAlerted(String player) {
|
||||
return alerted.contains(player);
|
||||
}
|
||||
|
||||
public void logAlert(String player) {
|
||||
alerted.add(player);
|
||||
}
|
||||
|
||||
public void sendStats(CommandSender cs, String player) {
|
||||
getStats(cs, player);
|
||||
}
|
||||
|
||||
public void getStats(CommandSender cs, String player) {
|
||||
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
||||
double total = stats.getOther();
|
||||
cs.sendMessage("--------------------[" + GREEN + "X-Ray Stats" + WHITE + "]---------------------");
|
||||
cs.sendMessage(GRAY + "Player: " + WHITE + player);
|
||||
cs.sendMessage(GRAY + "Total blocks broken: " + WHITE + stats.getTotal());
|
||||
calculate(cs, player, stats.getDiamond(), total, "diamond");
|
||||
calculate(cs, player, stats.getGold(), total, "gold");
|
||||
calculate(cs, player, stats.getIron(), total, "iron");
|
||||
calculate(cs, player, stats.getLapis(), total, "lapis");
|
||||
calculate(cs, player, stats.getRedstone(), total, "redstone");
|
||||
cs.sendMessage(GRAY + "Percent all other blocks: " + WHITE + round(stats.getOther()) + "%");
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
}
|
||||
|
||||
public void addDiamond(String player) {
|
||||
addOre(player, diamond);
|
||||
}
|
||||
|
||||
public void addGold(String player) {
|
||||
addOre(player, gold);
|
||||
}
|
||||
|
||||
public void addIron(String player) {
|
||||
addOre(player, iron);
|
||||
}
|
||||
|
||||
public void addLapis(String player) {
|
||||
addOre(player, lapis);
|
||||
}
|
||||
|
||||
public void addRedstone(String player) {
|
||||
addOre(player, redstone);
|
||||
}
|
||||
|
||||
public void addBlock(String player) {
|
||||
addOre(player, block);
|
||||
}
|
||||
|
||||
public void addTotal(String player) {
|
||||
addOre(player, totalblock);
|
||||
}
|
||||
|
||||
private void addOre(String player, Map<String, Integer> map) {
|
||||
if (map.get(player) == null || map.get(player) == 0) {
|
||||
map.put(player, 1);
|
||||
} else {
|
||||
int playerLevel = map.get(player);
|
||||
map.put(player, playerLevel + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private float round(double num) {
|
||||
double number = num;
|
||||
float p = (float) Math.pow(POWER, 1);
|
||||
number *= p;
|
||||
float tmp = Math.round(number);
|
||||
return tmp / p;
|
||||
}
|
||||
|
||||
public void reset(String player) {
|
||||
totalblock.put(player, 1);
|
||||
diamond.put(player, 0);
|
||||
iron.put(player, 0);
|
||||
gold.put(player, 0);
|
||||
redstone.put(player, 0);
|
||||
lapis.put(player, 0);
|
||||
totalblock.put(player, 0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user