code: protected String mogrifyChat (
          String text, byte mode, boolean transformsAllowed, boolean capFirst)
      {
          int tlen = text.length();
          if (tlen == 0) {
              return text;
  
          // check to make sure there aren't too many caps
          } else if (tlen > 7 && suppressTooManyCaps()) {
              // count caps
              int caps = 0;
              for (int ii=0; ii < tlen; ii++) {
                  if (Character.isUpperCase(text.charAt(ii))) {
                      caps++;
                      if (caps > (tlen / 2)) {
                          // lowercase the whole string if there are
                          text = text.toLowerCase();
                          break;
                      }
                  }
              }
          }
  
          StringBuffer buf = new StringBuffer(text);
          buf = mogrifyChat(buf, transformsAllowed, capFirst);
          return buf.toString();
      }
docs: Mogrifies common literary crutches into more appealing chat or commands.
  
  @param mode the chat mode, or -1 if unknown.
  @param transformsAllowed if true, the chat may transformed into a different mode. (lol ->
  /emote laughs)
  @param capFirst if true, the first letter of the text is capitalized. This is not desired if
  the chat is already an emote.