SimplyPerms/net/crystalyx/bukkit/simplyperms/preventions/spam/CapsLock.java

31 lines
898 B
Java
Raw Normal View History

2012-04-29 00:11:39 +00:00
package net.crystalyx.bukkit.simplyperms.preventions.spam;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerChatEvent;
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
public class CapsLock extends SimplyPrevents {
public CapsLock(SimplyPlugin plugin) {
super(plugin);
}
@EventHandler(priority = EventPriority.LOW)
public void capslock(PlayerChatEvent event) {
String message = event.getMessage();
for (Player player : super.plugin.getServer().getOnlinePlayers()) {
message.replace(player.getName(), "");
}
2012-04-29 00:55:03 +00:00
String nocaps = message.replaceAll("[A-Z]*", "");
2012-04-29 00:11:39 +00:00
if (message.length() > 5
&& message.length() - nocaps.length() > message.length() / 2) {
prevent(event, event.getPlayer(), "capslock,spam");
}
}
2012-04-29 00:55:03 +00:00
2012-04-29 00:11:39 +00:00
}