Solved Why am I getting this error?

Discussion in 'Plugin Development' started by __Sour, Jan 9, 2015.

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

    __Sour

    I seem to be getting a error with ChatColor. I don't see why I can't do this?

    Code:
            SELECTOR(ChatColor.YELLOW + ChatColor.ITALIC, ChatColor.GRAY + " " + ChatColor.ITALIC);
           
            private String prefix;
            private ChatColor color;
            
            private Prefix(ChatColor color, String prefix) {
                this.color = color;
                this.prefix = prefix;
            }
           
            public ChatColor getColor() {
                return color;
            }
          
            public String getPrefix() {
                return prefix;
            }
    I get the error: "The operator + is undefined for the argument type(s) org.bukkit.ChatColor, org.bukkit.ChatColor"

    On:
    Code:
    SELECTOR(ChatColor.YELLOW + ChatColor.ITALIC,
     
  2. Offline

    1Rogue

    You cannot use the unary + operator with objects unless you are using them with strings (which will automatically call #toString() on the object). You'll need to turn the first argument into a string (of note, since ChatColor is an enum, that's even more reason you cannot dynamically define a new ChatColor object).
     
  3. Offline

    __Sour

    @1Rogue Ok, I understand and fixed it, thanks for the help!
     
Thread Status:
Not open for further replies.

Share This Page