Solved How to clear the chat?

Discussion in 'Plugin Development' started by RoiyAk, Jan 19, 2013.

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

    RoiyAk

    hey,
    how i clear the chat with command?

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
        {
            Player p = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("cc"))
            {
               int i;
               for (i = 0; i < 100; i++)
                p.sendMessage("");
            }
         
            return false;
             
            }
        }
    its didnt work, you can help me please?
     
  2. Offline

    fireblast709

    try sending something else, like newlines? ("\n")
     
  3. Offline

    RoiyAk

    not work :(
     
  4. RoiyAk
    Try
    Code:java
    1.  
    2. p.sendMessage(" ");
    3.  


    And you don't need 100 in the for loop, 20-25 iterations should be more than enough to clear the chat.
     
  5. Offline

    RoiyAk

    Not work :(
    It does nothing.

    Thc code:

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
        {
            Player p = (Player) sender;
                if (cmd.getName().equalsIgnoreCase("cc"))
                {
                  int i;
                  for (i = 0; i < 100; i++)
                      p.sendMessage(" ");
                }
         
                return false;
             
                }
            }
     
  6. Offline

    tommycake50

    is the command registered?
     
  7. Offline

    RoiyAk

    yes
     
  8. RoiyAk
    Add some debug code to check if your command is running.
    Code:java
    1.  
    2. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    3. System.out.println("command registered");
    4. }
    5.  
     
  9. Offline

    RoiyAk

    Still not working.

    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
        {
            Player p = (Player) sender;
            System.out.println("clearchat");
                if (cmd.getName().equalsIgnoreCase("clearchat"))
                {
                  int i;
                  for (i = 0; i < 25; i++)
                  {
                      p.sendMessage(" ");
                  }
                }
         
                return false;
             
                }
     
  10. RoiyAk
    Show us your plugin.yml. Also is the onCommand() method in your main class. Why don't you post your class on pastie so we can take a good look at it.

    And you might want to removed the [solved] tag.
     
  11. Offline

    RoiyAk


    Code:
    main: me.NoSpamPlus.NoSpamPlus
    name: NoSpamPlus
    version: 1.0
    description: No spam in your server.
    commands:
      clearchat:
        description: Command to test
    permissions:
      NoSpamPlus.bypass:
          description: Player can spam.
          default: op
    i dont know how to change the tag.
     
  12. RoiyAk
    Ok, well for the sake of testing i'd remove the permissions check for now, also make sure you are an OP on your test server.

    Then test your plugin, and please show us your main class.
     
  13. Offline

    RoiyAk

    I fix it, thank you :)
     
Thread Status:
Not open for further replies.

Share This Page