Solved What am I doing wrong?

Discussion in 'Plugin Development' started by MrEminent42, Apr 23, 2015.

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


    I'm trying to make a Chat Bot plugin, and every time I try to do something there is a different error. Here is what I want it to do:
    1. When a player chats, it does the following:
    2. If the chat message contains the string in the config, proceed.
    3. Compare the message to the keys in the config, and if there is one that matches, send them the message of that key.
    4. Otherwise, send them a message that says I cant answer that.
    Here is my code:
        public void onPlayerChat(AsyncPlayerChatEvent e) {
            Player p = e.getPlayer();
            if (e.getMessage().contains(config.getString("listen-for"))) return;
            for (String key : config.getKeys()) {
                key = key.toString();
                if (key.contains(e.getMessage().toLowerCase())) {
                    if (key != "prefix" && key != "no-answer" && key != "listen-for") {
                        String message = config.getString("prefix" + key);
                        message = PlaceholderAPI.setPlaceholders(p, message);
                } else {
                    String eMessage = config.getString("prefix" + "no-answer");
                    eMessage = PlaceholderAPI.setPlaceholders(p, eMessage);
                    p.sendMessage(translateAlternateColorCodes('&', eMessage));
    (By the way, "config" refers to getConfig(). Using a Library.)

    Can someone tell me what I'm doing wrong here?

    Thanks in advance,
    Mr. Eminent.
  2. Offline



    Posting some of the errors you're referring to, as well as the line they're pointing to would be a great help for us :)
  3. Offline


    Turns out I cant do:
    String eMessage = config.getString("prefix" + "no-answer");
    When I send the message I send both. Not in the initializer.

    @valon750 Thanks though :)
  4. Offline


    Why is that there?
    String = String.toString();?
  5. Offline


    Oh wait... Thanks for telling me. The getKeys() returns a set of strings correct?
  6. Offline


Thread Status:
Not open for further replies.

Share This Page