package net.simpvp.NoSpam;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;

public class CommandListener implements Listener {

	public CommandListener(NoSpam plugin) {
		plugin.getServer().getPluginManager().registerEvents(this, plugin);
	}

	@EventHandler(priority=EventPriority.LOW, ignoreCancelled=false)
	public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {

		Player player = event.getPlayer();

		String message = event.getMessage();

		/* Important: The spaces afterwards are necessary. Otherwise we get something like this being activated on /world because of /w */
		if (message.startsWith("/tell ")
				|| message.startsWith("/me ")
				|| message.startsWith("/msg ")
				|| message.startsWith("/w ")
				|| message.startsWith("/op ")) {

			boolean cancel = SpamHandler.isSpamming(player); // The Handler class checks if it's spam

			if ( cancel ) event.setCancelled(true);

				}

	}

}


@@ -618,16 +618,30 @@
 essage()
+.toLowerCase()
 ;%0A%0A%09%09/* 
@@ -938,16 +938,45 @@
 (%22/op %22)
+%0A%09%09%09%09%7C%7C message.equals(%22/op%22)
 ) %7B%0A%0A%09%09%09
@@ -1110,18 +1110,16 @@
 true);%0A%0A
-%09%09
 %09%09%7D%0A%0A%09%7D%0A

Update list of blocked commands