Solved Integration with EssentialsChat

Discussion in 'Plugin Development' started by Deleted user, Nov 27, 2014.

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

    Deleted user

    Actually, I cannot find any tutorials on how to create variables for my own plugin into EssentialsChat.
     
  2. Offline

    Skionz

    Joiner Why would you want to?
     
  3. Offline

    mine-care

    I didn't quite get what you mean there... :3 it might be possible with some reflection but I might have understood what you wana do incorrectly
     
  4. Offline

    Deleted user

    Skionz mine-care
    When I say "variables", I mean those you can use at the Essentials config.yml, under the EssentialsChat section, for the format: key.
    I would like to add my own, so I can let the user to handle a prefix added from my plugin together with the other stuff.
     
  5. Offline

    mine-care

  6. Offline

    Deleted user

    mine-care Example: {FACTION} is replaced with the faction name, but only if Factions is installed. This means it is a variable set up by Factions, which is another plugin than EssentialsChat.
    How do I do that?
     
  7. Offline

    Skionz

    Joiner I am not sure if you can get another plugins YAML files with the FileConfiguration API so this is what you would do otherwise.
    Code:
    BufferedReader br = new BufferedReader(new FileReader("plugins/Essentials/config.yml"));
        String line;
        while((line = br.readLine()) != null) {
            if(line.startsWith("Something")) {
                //get your line and do stuff
            }
    }
    Read my tutorial https://forums.bukkit.org/threads/read-write-to-a-file-without-snakeyaml.324796/
     
    mine-care likes this.
  8. Offline

    Deleted user

    Skionz I do not need to change the file.
    I need to create my own variable and EssentialsChat will handle it.
     
  9. Offline

    Skionz

    Joiner There is no documentation on how to use EssentialsChat so I doubt you will find a way. The code I posted above does not change a file it reads a file line by line.
     
  10. Skionz
    You can access any yml file by loading it the normal way, YamlConfiguration#loadConfiguration(file).
     
    Skionz likes this.
  11. Offline

    Skionz

    Joiner In that case you can just load it and grab the line you want from the Essentials config.
     
  12. Offline

    Deleted user

    Assist Skionz But I need to grab anything!
    I want it to be handled by EssentialsChat, simply setting the replacement.
     
  13. Offline

    extended_clip

    Just do it like this.

    Code:
        @EventHandler(priority = EventPriority.HIGH)
        public void onOpChat(AsyncPlayerChatEvent e) {
       
            Player p = e.getPlayer();
       
            if (p.isOp()) {
           
                String format = e.getFormat();       
           
                String opTag = plugin.getConfig().getString("op_chat_format_tag");
           
                if (opTag == null || opTag.isEmpty()) {
               
                    e.setFormat(format.replace("{OP_TAG}", ""));
           
                } else {
               
                    e.setFormat(format.replace("{OP_TAG}", ChatColor.translateAlternateColorCodes('&', opTag )));
                }
            }
        }
     
  14. Offline

    mrCookieSlime

    Joiner
    I am not sure if this will work with EssentialsChat but listen for an AsyncPlayerChatEvent and do event.setFormat(event.getFormat().replace(...))

    EDIT: extended_clip Ninja'd
     
  15. Offline

    Deleted user

Thread Status:
Not open for further replies.

Share This Page