Do I use Regex and how?

Discussion in 'Plugin Development' started by coldguy101, Oct 1, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    coldguy101

    Hello, I am trying to get a command which has many options that come after it, such as "/shout asdfa asdf" and block it. This is my current code.
    Code:
    @EventHandler(priority = EventPriority.HIGHEST)
        public void PlayerCommandPreProcessEvent(PlayerCommandPreprocessEvent event)
        {
            if (event.getPlayer().isOp() || event.getPlayer().hasPermission("ChatSeg.Admin"))
                return;
            if(CSMain.noShout.contains(event.getPlayer()))
            {
          --------------->      if ((event.getMessage().equalsIgnoreCase("/shout") || (event.getMessage().equalsIgnoreCase("/shout\\S+ \\w \\s") || (event.getMessage().equalsIgnoreCase("/shout\\S+ | \\w | \\s")))))
                {
                    event.setCancelled(true);
                    event.getPlayer().sendMessage(ChatColor.RED + "Error: You cant send another public message within 30 seconds of your last one!");
                }
            }
        }
    As you can see, I have been trying many different things, hense the ||'s everywhere in the checking if statement. If anyone could offer any assistance in this it would be appreciated. Thanks. P.S. My Skype name is coldguy101 if anyone does not mind the occational java question ;) haha.
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    You could just check if the command about to be executed starts with the command you want to block....
     
  3. I think the following part should be usefull: event.getMessage().startWiths("/shout")
     
Thread Status:
Not open for further replies.

Share This Page