mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
AntiCheat first commit, added base and basic chat spam blocker.
This commit is contained in:
commit
8ccbd9cfba
6 files changed
+134
No files matched your search
@@ -0,0 +1,15 @@
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Anticheat extends JavaPlugin {
|
||||
public ChatManager cm = new ChatManager(this);
|
||||
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ChatManager {
|
||||
Anticheat plugin;
|
||||
ChatColor red = ChatColor.RED;
|
||||
|
||||
public ChatManager(Anticheat plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private Map<Player,Integer> chatLevel = new HashMap<Player,Integer>();
|
||||
|
||||
public void addChat(final Player player)
|
||||
{
|
||||
if(chatLevel.get(player) == null)
|
||||
{
|
||||
chatLevel.put(player, 1);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
chatLevel.put(player, 0);
|
||||
}
|
||||
}, 600L);
|
||||
}
|
||||
else
|
||||
{
|
||||
int amount = (int)chatLevel.get(player)+1;
|
||||
chatLevel.put(player, amount);
|
||||
check(player, amount);
|
||||
}
|
||||
}
|
||||
|
||||
public void check(Player player, int amount)
|
||||
{
|
||||
if(amount >= 7)
|
||||
{
|
||||
player.sendMessage(red+"Please stop flooding the server!");
|
||||
}
|
||||
else if (amount >= 10)
|
||||
{
|
||||
player.kickPlayer(red+"Spam");
|
||||
plugin.getServer().broadcastMessage(red+player.getName()+"Was kicked for spamming.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
Anticheat plugin;
|
||||
|
||||
public PlayerListener(Anticheat plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChat(PlayerChatEvent event)
|
||||
{
|
||||
plugin.cm.addChat(event.getPlayer());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user