mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
Some spambot protection? Nasty stuff.
This commit is contained in:
1 parent
285cf3f977
commit
08139b001e
3 files changed
+55
-1
No files matched your search
@@ -19,6 +19,7 @@ public class Anticheat extends JavaPlugin {
|
|||||||
public ItemManager im = new ItemManager(this);
|
public ItemManager im = new ItemManager(this);
|
||||||
public BowManager bm = new BowManager(this);
|
public BowManager bm = new BowManager(this);
|
||||||
public HealthManager hm = new HealthManager();
|
public HealthManager hm = new HealthManager();
|
||||||
|
public LoginManager lm = new LoginManager(this);
|
||||||
public Configuration config;
|
public Configuration config;
|
||||||
public PlayerTracker tracker;
|
public PlayerTracker tracker;
|
||||||
private static final Logger l = Logger.getLogger("Minecraft");
|
private static final Logger l = Logger.getLogger("Minecraft");
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ public class PlayerListener implements Listener {
|
|||||||
PlayerTracker tracker;
|
PlayerTracker tracker;
|
||||||
ItemManager im;
|
ItemManager im;
|
||||||
HealthManager hm;
|
HealthManager hm;
|
||||||
|
LoginManager lm;
|
||||||
|
|
||||||
public PlayerListener(Anticheat plugin)
|
public PlayerListener(Anticheat plugin)
|
||||||
{
|
{
|
||||||
@@ -37,6 +39,16 @@ public class PlayerListener implements Listener {
|
|||||||
this.im = plugin.im;
|
this.im = plugin.im;
|
||||||
this.tracker = plugin.tracker;
|
this.tracker = plugin.tracker;
|
||||||
this.hm = plugin.hm;
|
this.hm = plugin.hm;
|
||||||
|
this.lm = plugin.lm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
if(!lm.log())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Please do not flood the server!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -92,9 +104,15 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerChat(PlayerChatEvent event)
|
public void onPlayerChat(PlayerChatEvent event)
|
||||||
{
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if(player.getLocation().equals(player.getWorld().getSpawnLocation()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.sendMessage("Please move from spawn before speaking.");
|
||||||
|
}
|
||||||
if(!plugin.lagged)
|
if(!plugin.lagged)
|
||||||
{
|
{
|
||||||
plugin.cm.addChat(event.getPlayer());
|
plugin.cm.addChat(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package net.h31ix.anticheat.manage;
|
||||||
|
|
||||||
|
import net.h31ix.anticheat.Anticheat;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class LoginManager {
|
||||||
|
Anticheat plugin;
|
||||||
|
boolean join;
|
||||||
|
|
||||||
|
public LoginManager(Anticheat plugin)
|
||||||
|
{
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean log()
|
||||||
|
{
|
||||||
|
if(join == true)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
join = true;
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
join = false;
|
||||||
|
}
|
||||||
|
}, 5L);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user