Editing Chat Layout

Discussion in 'Plugin Development' started by Rocky_990, May 15, 2015.

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

    Rocky_990

    Hello,

    In my recent plugin, I've been trying to edit user's chat layout according to a variable set to each player.
    Using ChatEx, I have my chat set to [group prefix] [group suffix] [name]:, although I wish to be able to add a part before every message each user sends in chat using my plugin.

    Thanks, and sorry if this is confusing, if so, tell me how I can explain it better haha

    ~Rocky_990
     
  2. Offline

    Zombie_Striker

    String Message = AddedPart+" "+event#getMessage();
    Event#setMessage(Message);
     
  3. Store the message in a string with what ever other things you want to add to it and then set the message to that string :)

    Referance:
    event#.getMessage() returns a String (the message).
    event#.setMessage(String string);
    String newMessage = "[HI] " + event#.getMessage() + ".";
     
  4. Offline

    Gater12

    @Rocky_990
    If ChatEx controls chat format, listen to chat event and replace your variable.
     
  5. Offline

    Rocky_990

    @Zombie_Striker @TheGamesHawk2001

    Thanks for the help! I have put this in, although "event#." is being underlined with the error "event cannot be resolved". After trying a few things, I am stuck again haha

    My code for this bit:
    Code:
            String AddedPart = "[Clan]";
            String Message = AddedPart+" "+event#.getMessage();
            event#.setMessage(Message);
     
  6. event#. simply just means what you labled your even as e.g. PlayerJoinEvent eve you would use eve.setJoinMessage and we would say event#. and then you would be like, oh yes my event is called eve :)
     
    Zombie_Striker and Rocky_990 like this.
  7. Offline

    nverdier

    It's because there is no such thing as 'event#'. I suggest you learn Java. Read about that here.
     
    Zombie_Striker likes this.
  8. Offline

    Rocky_990

    @TheGamesHawk2001

    Thanks so much for the ongoing help! :)

    Although I'm still slightly confused - as now I've messed around with it a little and am getting the error:
    "The operator + is for argument type(s) String, void"

    Thanks again :)
     
  9. What context are you using '+' in?
     
  10. Offline

    Rocky_990

    @TheGamesHawk2001
    Think I'm overconfusing myself here haha,
    what would be the code to set a player's chat to a variable + their chat before having the variable added?
     
  11. Please learn how strings work.
    The + operator is used in print statements in the following context.

    String hello = "John ";
    System.out.println("Hey " + hello + "!");
    + is used to join together separate string segments and other variables.
     
  12. Offline

    Gater12

    @Rocky_990
    More specifically the + operator concats, or joins, multiple Strings. Equivalent to String#concat
     
Thread Status:
Not open for further replies.

Share This Page