Solved Caps / chat help!

Discussion in 'Plugin Development' started by zakkinu2, Sep 17, 2013.

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

    zakkinu2

    So i have this plugin that makes peoples chat to lowercase every time they talk unless there op or have the permission to use caps. I need a way that i can allow only like 3 caps letters in a whole sentence! Any help?
     
  2. Offline

    PatoTheBest

    on player chat event, get message, cancel it, then set it to String.toLowercase (obviously if !player.isOp()). Oh and replace " i " with " I ". spaces required.
     
  3. Offline

    remremrem

  4. Offline

    zakkinu2

    PatoTheBest i know how to do all that but like what if there starting a sentence people gate how they cant even start a sentence with a capital letter
     
  5. Offline

    PatoTheBest

    char first = message.charAt(0);
    then first.toUpperCase I think.

    In PlayerChatEvent:
    Code:java
    1. String msg = event.getMessage().trim(); // in case player types spaces before message it will trim them.
    2.  
    3. event.setMessage(("" + msg.charAt(0)).toUpperCase() + msg.substring(1));



    Basically this gets the character at index 0, makes it a string and uses toUpperCase on it, then adds the message from character index 1.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  6. Offline

    zakkinu2

    PatoTheBestBut isint there a way witch you can only allow just 3 capital letter in the whole thing they said?

    remremrem Thanks so much! didnt see it at first! [SOLVED]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
Thread Status:
Not open for further replies.

Share This Page