mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 22:15:28 +00:00
Auto-mine and auto-place blocker
This commit is contained in:
1 parent
eca280d06f
commit
29550fe70e
3 files changed
+122
-3
No files matched your search
@@ -26,6 +26,7 @@ public class Anticheat extends JavaPlugin {
|
|||||||
public LoginManager lm = new LoginManager(this);
|
public LoginManager lm = new LoginManager(this);
|
||||||
public FoodManager fom = new FoodManager(this);
|
public FoodManager fom = new FoodManager(this);
|
||||||
public FlyManager fm = new FlyManager();
|
public FlyManager fm = new FlyManager();
|
||||||
|
public BlockManager blm = new BlockManager(this);
|
||||||
//End Managers
|
//End Managers
|
||||||
|
|
||||||
public Configuration config;
|
public Configuration config;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package net.h31ix.anticheat.event;
|
package net.h31ix.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.manage.AnimationManager;
|
|
||||||
import net.h31ix.anticheat.Anticheat;
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import net.h31ix.anticheat.PlayerTracker;
|
import net.h31ix.anticheat.PlayerTracker;
|
||||||
import net.h31ix.anticheat.checks.EyeCheck;
|
import net.h31ix.anticheat.checks.*;
|
||||||
import net.h31ix.anticheat.checks.LengthCheck;
|
import net.h31ix.anticheat.manage.*;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -18,12 +17,14 @@ public class BlockListener implements Listener {
|
|||||||
AnimationManager am;
|
AnimationManager am;
|
||||||
PlayerTracker tracker;
|
PlayerTracker tracker;
|
||||||
EyeCheck e = new EyeCheck();
|
EyeCheck e = new EyeCheck();
|
||||||
|
BlockManager blm;
|
||||||
|
|
||||||
public BlockListener(Anticheat plugin)
|
public BlockListener(Anticheat plugin)
|
||||||
{
|
{
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.am = plugin.am;
|
this.am = plugin.am;
|
||||||
this.tracker = plugin.tracker;
|
this.tracker = plugin.tracker;
|
||||||
|
this.blm = plugin.blm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -62,6 +63,40 @@ public class BlockListener implements Listener {
|
|||||||
tracker.decreaseLevel(player);
|
tracker.decreaseLevel(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!player.hasPermission("anticheat.fastbreak"))
|
||||||
|
{
|
||||||
|
if(block.getType() != Material.RED_MUSHROOM
|
||||||
|
&& block.getType() != Material.RED_ROSE
|
||||||
|
&& block.getType() != Material.BROWN_MUSHROOM
|
||||||
|
&& block.getType() != Material.YELLOW_FLOWER
|
||||||
|
&& block.getType() != Material.REDSTONE
|
||||||
|
&& block.getType() != Material.REDSTONE_TORCH_OFF
|
||||||
|
&& block.getType() != Material.REDSTONE_TORCH_ON
|
||||||
|
&& block.getType() != Material.REDSTONE_WIRE
|
||||||
|
&& block.getType() != Material.GRASS
|
||||||
|
&& block.getType() != Material.PAINTING
|
||||||
|
&& block.getType() != Material.WHEAT
|
||||||
|
&& block.getType() != Material.SUGAR_CANE
|
||||||
|
&& block.getType() != Material.SUGAR_CANE_BLOCK
|
||||||
|
&& block.getType() != Material.DIODE
|
||||||
|
&& block.getType() != Material.DIODE_BLOCK_OFF
|
||||||
|
&& block.getType() != Material.DIODE_BLOCK_ON
|
||||||
|
&& block.getType() != Material.SAPLING
|
||||||
|
&& block.getType() != Material.TORCH
|
||||||
|
&& block.getType() != Material.SNOW)
|
||||||
|
{
|
||||||
|
if (!blm.justBroke(player))
|
||||||
|
{
|
||||||
|
blm.logBreak(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.log(player.getName() + " tried to break a block too fast!");
|
||||||
|
tracker.increaseLevel(player, 2);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
am.reset(player);
|
am.reset(player);
|
||||||
@@ -102,6 +137,19 @@ public class BlockListener implements Listener {
|
|||||||
tracker.decreaseLevel(player);
|
tracker.decreaseLevel(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!player.hasPermission("anticheat.fastplace"))
|
||||||
|
{
|
||||||
|
if (!blm.justPlaced(player))
|
||||||
|
{
|
||||||
|
blm.logPlace(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.log(player.getName() + " tried to place a block too fast!");
|
||||||
|
tracker.increaseLevel(player, 2);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
am.reset(player);
|
am.reset(player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package net.h31ix.anticheat.manage;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import net.h31ix.anticheat.Anticheat;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
|
public class BlockManager
|
||||||
|
{
|
||||||
|
public Map<Player, Boolean> place = new HashMap();
|
||||||
|
public Map<Player, Boolean> broke = new HashMap();
|
||||||
|
Anticheat plugin;
|
||||||
|
|
||||||
|
public BlockManager(Anticheat plugin)
|
||||||
|
{
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logPlace(final Player player)
|
||||||
|
{
|
||||||
|
place.put(player, true);
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
place.put(player, Boolean.valueOf(false));
|
||||||
|
}
|
||||||
|
}, 1/2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBreak(final Player player)
|
||||||
|
{
|
||||||
|
broke.put(player, true);
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
broke.put(player, Boolean.valueOf(false));
|
||||||
|
}
|
||||||
|
}, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean justBroke(Player player)
|
||||||
|
{
|
||||||
|
if(broke.get(player) == null || broke.get(player) == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean justPlaced(Player player)
|
||||||
|
{
|
||||||
|
if(place.get(player) == null || place.get(player) == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user