mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Cleaned up imports and added mcMMO to have better fastbreak/tree feller detection.
This commit is contained in:
1 parent
a7fe5782e0
commit
3a0b7369c9
10 files changed
+72
-83
No files matched your search
@@ -18,12 +18,7 @@
|
||||
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -24,9 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
|
||||
package net.h31ix.anticheat.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.manage.PlayerManager;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@@ -24,12 +24,8 @@ import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.manage.Distance;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.*;
|
||||
|
||||
|
||||
public class EntityListener extends EventListener
|
||||
|
||||
@@ -20,12 +20,7 @@ package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import java.util.logging.SimpleFormatter;
|
||||
import java.util.logging.*;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -477,63 +479,74 @@ public class Backend
|
||||
|
||||
public boolean checkFastBreak(Player player, Block block)
|
||||
{
|
||||
int violations = FASTBREAK_MAXVIOLATIONS;
|
||||
if(player.getGameMode() == GameMode.CREATIVE)
|
||||
boolean b = true;
|
||||
if(player.getServer().getPluginManager().getPlugin("mcMMO") != null)
|
||||
{
|
||||
violations = FASTBREAK_MAXVIOLATIONS_CREATIVE;
|
||||
if(mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.TREE_FELLER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER))
|
||||
{
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
String name = player.getName();
|
||||
if(!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES && player.getGameMode() != GameMode.CREATIVE))
|
||||
if(b)
|
||||
{
|
||||
if(blockPunches.get(name) != null)
|
||||
int violations = FASTBREAK_MAXVIOLATIONS;
|
||||
if(player.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
int i = blockPunches.get(name);
|
||||
if(i < BLOCK_PUNCH_MIN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
violations = FASTBREAK_MAXVIOLATIONS_CREATIVE;
|
||||
}
|
||||
if (!fastBreakViolation.containsKey(name))
|
||||
String name = player.getName();
|
||||
if(!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES && player.getGameMode() != GameMode.CREATIVE))
|
||||
{
|
||||
fastBreakViolation.put(name, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||
if(fastBreakViolation.get(name) > violations && math < FASTBREAK_MAXVIOLATIONTIME)
|
||||
if(blockPunches.get(name) != null)
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fastbreaking detected. Please wait 10 seconds before breaking blocks.");
|
||||
return true;
|
||||
}
|
||||
else if(fastBreakViolation.get(name) > 0 && math > FASTBREAK_MAXVIOLATIONTIME)
|
||||
int i = blockPunches.get(name);
|
||||
if(i < BLOCK_PUNCH_MIN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!fastBreakViolation.containsKey(name))
|
||||
{
|
||||
fastBreakViolation.put(name, 0);
|
||||
}
|
||||
}
|
||||
if (!blocksBroken.containsKey(name) || !lastBlockBroken.containsKey(name))
|
||||
{
|
||||
if(!lastBlockBroken.containsKey(name))
|
||||
else
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||
if(fastBreakViolation.get(name) > violations && math < FASTBREAK_MAXVIOLATIONTIME)
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fastbreaking detected. Please wait 10 seconds before breaking blocks.");
|
||||
return true;
|
||||
}
|
||||
else if(fastBreakViolation.get(name) > 0 && math > FASTBREAK_MAXVIOLATIONTIME)
|
||||
{
|
||||
fastBreakViolation.put(name, 0);
|
||||
}
|
||||
}
|
||||
blocksBroken.put(name, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
blocksBroken.put(name, blocksBroken.get(name)+1);
|
||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||
if(blocksBroken.get(name) > FASTBREAK_LIMIT && math < FASTBREAK_TIMEMAX)
|
||||
if (!blocksBroken.containsKey(name) || !lastBlockBroken.containsKey(name))
|
||||
{
|
||||
if(!lastBlockBroken.containsKey(name))
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
}
|
||||
blocksBroken.put(name, 0);
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
fastBreakViolation.put(name, fastBreakViolation.get(name)+1);
|
||||
return true;
|
||||
}
|
||||
else if(blocksBroken.get(name) > FASTBREAK_LIMIT)
|
||||
else
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
blocksBroken.put(name, 0);
|
||||
blocksBroken.put(name, blocksBroken.get(name)+1);
|
||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||
if(blocksBroken.get(name) > FASTBREAK_LIMIT && math < FASTBREAK_TIMEMAX)
|
||||
{
|
||||
blocksBroken.put(name, 0);
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
fastBreakViolation.put(name, fastBreakViolation.get(name)+1);
|
||||
return true;
|
||||
}
|
||||
else if(blocksBroken.get(name) > FASTBREAK_LIMIT)
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
blocksBroken.put(name, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -832,7 +845,7 @@ public class Backend
|
||||
if (amount >= CHAT_KICK_LEVEL)
|
||||
{
|
||||
String name = player.getName();
|
||||
int kick = 0;
|
||||
int kick;
|
||||
if(chatKicks.get(name) == null || chatKicks.get(name) == 0)
|
||||
{
|
||||
kick = 1;
|
||||
|
||||
@@ -20,7 +20,6 @@ package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -22,9 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -28,27 +28,16 @@ package net.h31ix.anticheat.metrics;
|
||||
* either expressed or implied, of anybody else.
|
||||
*/
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.*;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
Reference in new issue
Block a user