mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +00:00
Automatic XRay detection, also alerts are now sent to the console.
This commit is contained in:
1 parent
d3e77f4e81
commit
dda661c320
7 files changed
+221
-73
No files matched your search
@@ -18,7 +18,9 @@
|
||||
|
||||
package net.h31ix.anticheat.xray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -32,11 +34,11 @@ public class XRayTracker {
|
||||
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 DIVISOR = 100;
|
||||
private static final int RATIO_DIVISOR = 3;
|
||||
private static final int POWER = 10;
|
||||
private static final int MIN_BLOCK_COUNT = 100;
|
||||
@@ -60,19 +62,27 @@ public class XRayTracker {
|
||||
}
|
||||
cs.sendMessage(GRAY+"Percent "+type+" ore: "+color+round(x)+"%");
|
||||
}
|
||||
public void sendMessage(CommandSender cs, String player, double t, double d, double g, double i, double c, double la, double r, double b)
|
||||
|
||||
public boolean calculate(String player, double x, double b)
|
||||
{
|
||||
cs.sendMessage("--------------------["+GREEN+"X-Ray Stats"+WHITE+"]---------------------");
|
||||
cs.sendMessage(GRAY+"Player: "+WHITE+player);
|
||||
cs.sendMessage(GRAY+"Total blocks broken: "+WHITE+t);
|
||||
calculate(cs,player,d,b,"diamond");
|
||||
calculate(cs,player,g,b,"gold");
|
||||
calculate(cs,player,i,b,"iron");
|
||||
calculate(cs,player,c,b,"coal");
|
||||
calculate(cs,player,la,b,"lapis");
|
||||
calculate(cs,player,r,b,"redstone");
|
||||
cs.sendMessage(GRAY+"Percent all other blocks: "+WHITE+round(b)+"%");
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
return x >= b/RATIO_DIVISOR;
|
||||
}
|
||||
|
||||
public boolean hasAbnormal(String player)
|
||||
{
|
||||
XRayStats stats = new XRayStats(player,diamond,gold,iron,coal,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.getCoal(),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)
|
||||
@@ -82,47 +92,19 @@ public class XRayTracker {
|
||||
|
||||
public void getStats(CommandSender cs, String player)
|
||||
{
|
||||
double t = 1;
|
||||
double d = 0;
|
||||
double g = 0;
|
||||
double i = 0;
|
||||
double c = 0;
|
||||
double la = 0;
|
||||
double r = 0;
|
||||
double b = 0;
|
||||
if(totalblock.get(player) != null)
|
||||
{
|
||||
t = totalblock.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(coal.get(player) != null)
|
||||
{
|
||||
c = (coal.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(lapis.get(player) != null)
|
||||
{
|
||||
la = (lapis.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(redstone.get(player) != null)
|
||||
{
|
||||
r = (redstone.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(block.get(player) != null)
|
||||
{
|
||||
b = (block.get(player)/t)*DIVISOR;
|
||||
}
|
||||
sendMessage(cs,player,t,d,g,i,c,la,r,b);
|
||||
XRayStats stats = new XRayStats(player,diamond,gold,iron,coal,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.getCoal(),total,"coal");
|
||||
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)
|
||||
|
||||
Reference in new issue
Block a user