Auto-Grammar

Discussion in 'Plugin Requests' started by PieCreeper12, Mar 24, 2019.

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

    PieCreeper12

    I would like a plugin that automatically makes chat messages from players grammatically correct. For example, the first letter of a chat message is always capitalized and the sentence always ends with a period. Also, words that should have apostrophes will be given apostrophes such as the word "cant" turning into "can't". Sentences with little to no grammar bug me for some reason.
     
    insanj likes this.
  2. Offline

    Dai_Kunai

    What version of MC?
     
  3. Offline

    tkuiyeager1

    @PieCreeper12
    Hi, I made the plugin for you.
    It has a config so you can choose what and how to fix.
    Supports Minecraft Version 1.13.2.
    If you would like to have it for a different version please let me know.
    You can download the plugin from here (updated).
     
    Last edited: Apr 3, 2019
  4. Offline

    insanj

    For future reference, here's the rule algorithm from the source of Grammar.jar:

    Code:
      @EventHandler
      public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
      {
        String msg = event.getMessage();
        msg = msg.substring(0, 1).toUpperCase() + msg.substring(1);
        List<String> fromConfig = this.plugin.getConfig().getStringList("replacements");
        if (fromConfig == null) {
          return;
        }
        if (fromConfig.size() == 0) {
          return;
        }
        for (String s : fromConfig) {
          if (s.contains("/"))
          {
            String[] split = s.split("/");
            if (msg.contains(split[0])) {
              msg = msg.replaceAll(split[0], split[1]);
            }
          }
        }
        if (msg.lastIndexOf(".") != msg.length() - 1) {
          msg = msg + ".";
        }
        event.setMessage(msg);
      }
    
    config.yml
    Code:
    replacements:
     - cant/can't
    
     
    tkuiyeager1 likes this.
  5. Online

    timtower Administrator Administrator Moderator

    @insanj And why was it posted?
     
  6. Offline

    tkuiyeager1

    @PieCreeper12 I fixed a bug where if the first word should be replaced it wouldn't replace her.
     
Thread Status:
Not open for further replies.

Share This Page