mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
Test commit please ignore
Formatting for everything
This commit is contained in:
1 parent
8a5d531857
commit
f00130f3f7
23 files changed
+1606
-1506
No files matched your search
@@ -28,49 +28,50 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class XRayListener implements Listener {
|
||||
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.logXRay())
|
||||
if (config.logXRay())
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
String player = p.getName();
|
||||
if(checkManager.willCheck(p, CheckType.XRAY))
|
||||
if (checkManager.willCheck(p, CheckType.XRAY))
|
||||
{
|
||||
Material m = event.getBlock().getType();
|
||||
if(m == Material.DIAMOND_ORE)
|
||||
if (m == Material.DIAMOND_ORE)
|
||||
{
|
||||
tracker.addDiamond(player);
|
||||
}
|
||||
else if(m == Material.IRON_ORE)
|
||||
else if (m == Material.IRON_ORE)
|
||||
{
|
||||
tracker.addIron(player);
|
||||
}
|
||||
else if(m == Material.COAL_ORE)
|
||||
else if (m == Material.COAL_ORE)
|
||||
{
|
||||
tracker.addCoal(player);
|
||||
}
|
||||
else if(m == Material.GOLD_ORE)
|
||||
}
|
||||
else if (m == Material.GOLD_ORE)
|
||||
{
|
||||
tracker.addGold(player);
|
||||
}
|
||||
else if(m == Material.LAPIS_ORE)
|
||||
}
|
||||
else if (m == Material.LAPIS_ORE)
|
||||
{
|
||||
tracker.addLapis(player);
|
||||
}
|
||||
else if(m == Material.REDSTONE_ORE)
|
||||
}
|
||||
else if (m == Material.REDSTONE_ORE)
|
||||
{
|
||||
tracker.addRedstone(player);
|
||||
}
|
||||
else if(m == Material.GOLD_ORE)
|
||||
}
|
||||
else if (m == Material.GOLD_ORE)
|
||||
{
|
||||
tracker.addGold(player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tracker.addBlock(player);
|
||||
@@ -78,5 +79,5 @@ public class XRayListener implements Listener {
|
||||
tracker.addTotal(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@ package net.h31ix.anticheat.xray;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class XRayStats {
|
||||
public class XRayStats
|
||||
{
|
||||
private static final int DIVISOR = 100;
|
||||
private double t = 1;
|
||||
private double d = 0;
|
||||
@@ -28,82 +29,82 @@ public class XRayStats {
|
||||
private double i = 0;
|
||||
private double c = 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> coal,Map<String,Integer> lapis,Map<String,Integer> redstone,Map<String,Integer> other,Map<String,Integer> total)
|
||||
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> coal, Map<String, Integer> lapis, Map<String, Integer> redstone, Map<String, Integer> other, Map<String, Integer> total)
|
||||
{
|
||||
if(total.get(player) != null)
|
||||
if (total.get(player) != null)
|
||||
{
|
||||
t = total.get(player);
|
||||
}
|
||||
if(diamond.get(player) != null)
|
||||
}
|
||||
if (diamond.get(player) != null)
|
||||
{
|
||||
d = (diamond.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(gold.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)
|
||||
g = (gold.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if (iron.get(player) != null)
|
||||
{
|
||||
i = (iron.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(coal.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)
|
||||
c = (coal.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if (lapis.get(player) != null)
|
||||
{
|
||||
l = (lapis.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(redstone.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)
|
||||
r = (redstone.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if (other.get(player) != null)
|
||||
{
|
||||
o = (other.get(player)/t)*DIVISOR;
|
||||
}
|
||||
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 getCoal()
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public double getLapis()
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public double getRedstone()
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public double getOther()
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,15 +25,16 @@ import java.util.Map;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
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> coal = 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>();
|
||||
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> coal = 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;
|
||||
@@ -42,141 +43,141 @@ public class XRayTracker {
|
||||
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;
|
||||
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)
|
||||
if (x >= b / RATIO_DIVISOR)
|
||||
{
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY+"Percent "+type+" ore: "+color+round(x)+"%");
|
||||
}
|
||||
cs.sendMessage(GRAY + "Percent " + type + " ore: " + color + round(x) + "%");
|
||||
}
|
||||
|
||||
|
||||
public boolean calculate(String player, double x, double b)
|
||||
{
|
||||
return x >= b/RATIO_DIVISOR;
|
||||
}
|
||||
|
||||
return x >= b / RATIO_DIVISOR;
|
||||
}
|
||||
|
||||
public boolean hasAbnormal(String player)
|
||||
{
|
||||
XRayStats stats = new XRayStats(player,diamond,gold,iron,coal,lapis,redstone,block,totalblock);
|
||||
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);
|
||||
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)
|
||||
{
|
||||
getStats(cs,player);
|
||||
getStats(cs, player);
|
||||
}
|
||||
|
||||
|
||||
public void getStats(CommandSender cs, String player)
|
||||
{
|
||||
XRayStats stats = new XRayStats(player,diamond,gold,iron,coal,lapis,redstone,block,totalblock);
|
||||
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("-----------------------------------------------------");
|
||||
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)
|
||||
{
|
||||
addOre(player,diamond);
|
||||
}
|
||||
|
||||
addOre(player, diamond);
|
||||
}
|
||||
|
||||
public void addGold(String player)
|
||||
{
|
||||
addOre(player,gold);
|
||||
}
|
||||
|
||||
addOre(player, gold);
|
||||
}
|
||||
|
||||
public void addCoal(String player)
|
||||
{
|
||||
addOre(player,coal);
|
||||
}
|
||||
|
||||
addOre(player, coal);
|
||||
}
|
||||
|
||||
public void addIron(String player)
|
||||
{
|
||||
addOre(player,iron);
|
||||
}
|
||||
|
||||
addOre(player, iron);
|
||||
}
|
||||
|
||||
public void addLapis(String player)
|
||||
{
|
||||
addOre(player,lapis);
|
||||
}
|
||||
|
||||
addOre(player, lapis);
|
||||
}
|
||||
|
||||
public void addRedstone(String player)
|
||||
{
|
||||
addOre(player,redstone);
|
||||
}
|
||||
|
||||
addOre(player, redstone);
|
||||
}
|
||||
|
||||
public void addBlock(String player)
|
||||
{
|
||||
addOre(player,block);
|
||||
}
|
||||
|
||||
addOre(player, block);
|
||||
}
|
||||
|
||||
public void addTotal(String player)
|
||||
{
|
||||
addOre(player,totalblock);
|
||||
}
|
||||
|
||||
private void addOre(String player, Map<String,Integer> map)
|
||||
addOre(player, totalblock);
|
||||
}
|
||||
|
||||
private void addOre(String player, Map<String, Integer> map)
|
||||
{
|
||||
if(map.get(player) == null || map.get(player) == 0)
|
||||
if (map.get(player) == null || map.get(player) == 0)
|
||||
{
|
||||
map.put(player,1);
|
||||
map.put(player, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int playerLevel = map.get(player);
|
||||
map.put(player, playerLevel+1);
|
||||
}
|
||||
}
|
||||
|
||||
private float round(double num)
|
||||
map.put(player, playerLevel + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private float round(double num)
|
||||
{
|
||||
double number = num;
|
||||
float p = (float)Math.pow(POWER,1);
|
||||
number*=p;
|
||||
float p = (float) Math.pow(POWER, 1);
|
||||
number *= p;
|
||||
float tmp = Math.round(number);
|
||||
return (float)tmp/p;
|
||||
return (float) tmp / p;
|
||||
}
|
||||
|
||||
|
||||
public void reset(String player)
|
||||
{
|
||||
totalblock.put(player,1);
|
||||
diamond.put(player,0);
|
||||
iron.put(player,0);
|
||||
gold.put(player,0);
|
||||
coal.put(player,0);
|
||||
redstone.put(player,0);
|
||||
lapis.put(player,0);
|
||||
totalblock.put(player,0);
|
||||
totalblock.put(player, 1);
|
||||
diamond.put(player, 0);
|
||||
iron.put(player, 0);
|
||||
gold.put(player, 0);
|
||||
coal.put(player, 0);
|
||||
redstone.put(player, 0);
|
||||
lapis.put(player, 0);
|
||||
totalblock.put(player, 0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user