Hey im new at Config and i got a problom

Discussion in 'Plugin Development' started by DeStickyOne, Dec 6, 2013.

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

    DeStickyOne

    i wanna do a config
    with
    join:

    and after the join:
    will be a message
    and this message gonna send to a player when he is joined
    so i dont know how to check the String or how to write the String for the Message after the join:

    but... ik to do thats
     
  2. Offline

    Rmarmorstein

    If I recall correctly, setJoinMessage() will set the message that is sent to the whole server, it sounds like you want to send a message to just the player, which would be player.sendMessage()

    For the configuration, I suggest you take a look here.

    If your configuration file looks like this,

    Code:
    message:
      join: hello
    
    You would use the following line of code to get the string for 'join'

    Code:java
    1. this.getConfig().getString("message.join");


    The message.join part can be replaced with the location of the string that you want to get from the config.
     
  3. Offline

    scarabcoder

    What Rmarmorstein said works, but here is a simpler way:
    Config code:
    Code:
    join: Welcome back, text here
    Java code:
    Code:java
    1. String welcomeMessage = this.getConfig().getString("join");
    2.  

    Then set the welcome message as welcomeMessage.
     
  4. Offline

    Jake6177

    That's more work.
     
  5. Offline

    scarabcoder

    How?
     
  6. Offline

    Gater12

    scarabcoder
    For just one time you would use:
    Code:java
    1. player.sendMessage(getConfig().getString("path.to.string"));

    But if you want to access it many times, it would be more efficient your way.
     
  7. Offline

    Jake6177

    scarabcoder
    Basically that. It's only needed once, so why set a variable?
     
  8. Offline

    scarabcoder

    Jake6177 True, but that is assuming you want to use it more than once.
     
Thread Status:
Not open for further replies.

Share This Page