mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +00:00
Updated for 1.3-DEV and added fast projectile check, fixes issue #27
This commit is contained in:
1 parent
92dfa04802
commit
0f8ba3a6e9
6 files changed
+53
-8
No files matched your search
@@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.h31ix.anticheat</groupId>
|
<groupId>net.h31ix.anticheat</groupId>
|
||||||
<artifactId>AntiCheat</artifactId>
|
<artifactId>AntiCheat</artifactId>
|
||||||
<version>1.2.1</version>
|
<version>1.3-DEV</version>
|
||||||
<name>AntiCheat</name>
|
<name>AntiCheat</name>
|
||||||
<url>http://H31IX.NET/</url>
|
<url>http://H31IX.NET/</url>
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Egg;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@@ -50,6 +52,19 @@ public class PlayerListener extends EventListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onProjectileLaunch(ProjectileLaunchEvent event)
|
||||||
|
{
|
||||||
|
if(event.getEntity().getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
Player player = (Player)event.getEntity().getShooter();
|
||||||
|
if(checkManager.willCheck(player, CheckType.FAST_PROJECTILE))
|
||||||
|
{
|
||||||
|
backend.logProjectile(player,this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public class AnticheatManager
|
|||||||
}
|
}
|
||||||
handler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log.%u.txt",true);
|
handler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log.%u.txt",true);
|
||||||
handler.setFormatter(new FileFormatter());
|
handler.setFormatter(new FileFormatter());
|
||||||
|
handler.setLevel(Level.INFO);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LOGGER.log(Level.SEVERE, null, ex);
|
LOGGER.log(Level.SEVERE, null, ex);
|
||||||
} catch (SecurityException ex) {
|
} catch (SecurityException ex) {
|
||||||
@@ -82,7 +83,7 @@ public class AnticheatManager
|
|||||||
{
|
{
|
||||||
if(getConfiguration().logConsole())
|
if(getConfiguration().logConsole())
|
||||||
{
|
{
|
||||||
LOGGER.warning(ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
LOGGER.info(ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
||||||
}
|
}
|
||||||
if(getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
if(getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
||||||
{
|
{
|
||||||
@@ -92,7 +93,7 @@ public class AnticheatManager
|
|||||||
|
|
||||||
public void fileLog(String message)
|
public void fileLog(String message)
|
||||||
{
|
{
|
||||||
FILE_LOGGER.warning(message);
|
FILE_LOGGER.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Anticheat getPlugin()
|
public Anticheat getPlugin()
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import net.h31ix.anticheat.event.EventListener;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.h31ix.anticheat.util.Utilities;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@@ -45,6 +46,7 @@ public class Backend
|
|||||||
private static final int DROPPED_ITEM_TIME = 2;
|
private static final int DROPPED_ITEM_TIME = 2;
|
||||||
private static final int DAMAGE_TIME = 50;
|
private static final int DAMAGE_TIME = 50;
|
||||||
private static final int KNOCKBACK_DAMAGE_TIME = 50;
|
private static final int KNOCKBACK_DAMAGE_TIME = 50;
|
||||||
|
private static final int PROJECTILE_TIME = 20;
|
||||||
|
|
||||||
private static final int FASTBREAK_LIMIT = 3;
|
private static final int FASTBREAK_LIMIT = 3;
|
||||||
private static final int FASTBREAK_TIMEMAX = 500;
|
private static final int FASTBREAK_TIMEMAX = 500;
|
||||||
@@ -59,6 +61,8 @@ public class Backend
|
|||||||
|
|
||||||
private static final int BLOCK_PUNCH_MIN = 5;
|
private static final int BLOCK_PUNCH_MIN = 5;
|
||||||
|
|
||||||
|
private static final int PROJECTILE_MAX = 8;
|
||||||
|
|
||||||
private static final int CHAT_WARN_LEVEL = 7;
|
private static final int CHAT_WARN_LEVEL = 7;
|
||||||
private static final int CHAT_KICK_LEVEL = 10;
|
private static final int CHAT_KICK_LEVEL = 10;
|
||||||
private static final int CHAT_BAN_LEVEL = 3;
|
private static final int CHAT_BAN_LEVEL = 3;
|
||||||
@@ -114,6 +118,7 @@ public class Backend
|
|||||||
private List<String> isInWaterCache = new ArrayList<String>();
|
private List<String> isInWaterCache = new ArrayList<String>();
|
||||||
private List<String> instantBreakExempt = new ArrayList<String>();
|
private List<String> instantBreakExempt = new ArrayList<String>();
|
||||||
private List<String> isAscending = new ArrayList<String>();
|
private List<String> isAscending = new ArrayList<String>();
|
||||||
|
private List<String> trackingProjectiles = new ArrayList<String>();
|
||||||
private Map<String,String> oldMessage = new HashMap<String,String>();
|
private Map<String,String> oldMessage = new HashMap<String,String>();
|
||||||
private Map<String,String> lastMessage = new HashMap<String,String>();
|
private Map<String,String> lastMessage = new HashMap<String,String>();
|
||||||
private Map<String,Integer> flightViolation = new HashMap<String,Integer>();
|
private Map<String,Integer> flightViolation = new HashMap<String,Integer>();
|
||||||
@@ -134,6 +139,7 @@ public class Backend
|
|||||||
private Map<String,Integer> blockPunches = new HashMap<String,Integer>();
|
private Map<String,Integer> blockPunches = new HashMap<String,Integer>();
|
||||||
private Map<String,Integer> waterAscensionViolation = new HashMap<String,Integer>();
|
private Map<String,Integer> waterAscensionViolation = new HashMap<String,Integer>();
|
||||||
private Map<String,Integer> waterSpeedViolation = new HashMap<String,Integer>();
|
private Map<String,Integer> waterSpeedViolation = new HashMap<String,Integer>();
|
||||||
|
private Map<String,Integer> projectilesShot = new HashMap<String,Integer>();
|
||||||
|
|
||||||
public Backend(AnticheatManager instance)
|
public Backend(AnticheatManager instance)
|
||||||
{
|
{
|
||||||
@@ -725,7 +731,7 @@ public class Backend
|
|||||||
public void logAnimation(final Player player)
|
public void logAnimation(final Player player)
|
||||||
{
|
{
|
||||||
logEvent(animated,player,ANIMATION_MIN);
|
logEvent(animated,player,ANIMATION_MIN);
|
||||||
increment(player,blockPunches);
|
increment(player,blockPunches,BLOCK_PUNCH_MIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetAnimation(final Player player)
|
public void resetAnimation(final Player player)
|
||||||
@@ -739,6 +745,28 @@ public class Backend
|
|||||||
return animated.contains(player.getName());
|
return animated.contains(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void logProjectile(final Player player, final EventListener e)
|
||||||
|
{
|
||||||
|
increment(player,projectilesShot,PROJECTILE_MAX);
|
||||||
|
if(!trackingProjectiles.contains(player.getName()))
|
||||||
|
{
|
||||||
|
trackingProjectiles.add(player.getName());
|
||||||
|
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
trackingProjectiles.remove(player.getName());
|
||||||
|
if(projectilesShot.get(player.getName()) >= PROJECTILE_MAX)
|
||||||
|
{
|
||||||
|
e.log("tried to fire projectiles too fast",player,CheckType.FAST_PROJECTILE);
|
||||||
|
}
|
||||||
|
projectilesShot.put(player.getName(),0);
|
||||||
|
}
|
||||||
|
}, PROJECTILE_TIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void logDamage(final Player player)
|
public void logDamage(final Player player)
|
||||||
{
|
{
|
||||||
int time = DAMAGE_TIME;
|
int time = DAMAGE_TIME;
|
||||||
@@ -867,7 +895,7 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void increment(Player player, Map<String,Integer> map)
|
public void increment(Player player, Map<String,Integer> map, int num)
|
||||||
{
|
{
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if(map.get(name) == null)
|
if(map.get(name) == null)
|
||||||
@@ -877,13 +905,13 @@ public class Backend
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
int amount = map.get(name)+1;
|
int amount = map.get(name)+1;
|
||||||
if(amount < BLOCK_PUNCH_MIN+1)
|
if(amount < num+1)
|
||||||
{
|
{
|
||||||
map.put(name, amount);
|
map.put(name, amount);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
map.put(name, BLOCK_PUNCH_MIN);
|
map.put(name, num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public enum CheckType
|
|||||||
FORCEFIELD("anticheat.forcefield"),
|
FORCEFIELD("anticheat.forcefield"),
|
||||||
XRAY("anticheat.xray"),
|
XRAY("anticheat.xray"),
|
||||||
LONG_REACH("anticheat.longreach"),
|
LONG_REACH("anticheat.longreach"),
|
||||||
|
FAST_PROJECTILE("anticheat.projectile"),
|
||||||
ITEM_SPAM("anticheat.itemspam");
|
ITEM_SPAM("anticheat.itemspam");
|
||||||
|
|
||||||
private final String permission;
|
private final String permission;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ name: AntiCheat
|
|||||||
softdepend: [AntiCheat]
|
softdepend: [AntiCheat]
|
||||||
startup: postworld
|
startup: postworld
|
||||||
url: http://H31IX.NET/
|
url: http://H31IX.NET/
|
||||||
version: '1.2.1'
|
version: '1.3-DEV'
|
||||||
commands:
|
commands:
|
||||||
anticheat:
|
anticheat:
|
||||||
description: Control and view info about AntiCheat
|
description: Control and view info about AntiCheat
|
||||||
|
|||||||
Reference in new issue
Block a user