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 @@
|
||||
/target/
|
||||
@@ -0,0 +1,36 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.h31ix.anticheat</groupId>
|
||||
<artifactId>AntiCheat</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>AntiCheat</name>
|
||||
<url>http://H31IX.NET/</url>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/repositories/releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.2.5-R1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
author: H31IX
|
||||
database: false
|
||||
description: Prevention of hacks and other malicious tinkering on a Minecraft server.
|
||||
main: net.h31ix.anticheat.Anticheat
|
||||
name: AntiCheat
|
||||
startup: postworld
|
||||
url: http://H31IX.NET/
|
||||
version: '1.0'
|
||||
Reference in new issue
Block a user