Solved Error while using getMessage()

Discussion in 'Plugin Development' started by HeadGam3z, Mar 4, 2014.

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

    HeadGam3z

    So I'm making a default chat color plugin, but when I try to use getMessage, Eclipse throws an error.

    Anyone have any ideas?
    Code:
        @EventHandler
        public void onChat(AsyncPlayerChatEvent chat) {
            Player p = chat.getPlayer();
            if (p.hasPermission("color.black")) {
                p.setMessage(ChatColor.BLACK + p.getMessage());   
            }
        }
     
  2. Offline

    Wolfey

    It's suppose to be chat.getMessage(), you're trying to grab the getMessage() method from the player class, which doesn't exist.
     
  3. Offline

    Dpasi314

    Are you sure it's not chat.getMessage?
    The Player type doesn't have a method called getMessage... I don't think.
     
  4. Offline

    fearless1333

    The Bukkit player interface has no getMessage() method. You have to get it from the event.

    Code:java
    1.  
    2. p.setMessage(ChatColor.BLACK + chat.getMessage());
    3.  
     
  5. Offline

    Wolfey

    Also, there is no such method as setMessage() in the player class, so that's also an error.
     
  6. Offline

    HeadGam3z

    fearless1333 Dpasi314
    Ahh, turns out it was chat.setMessage(ChatColor.BLACK + chat.getMessage());

    Thanks guys!
     
    Dpasi314 likes this.
Thread Status:
Not open for further replies.

Share This Page