Solved Setting Two Variables Equal

Discussion in 'Spigot Plugin Development' started by ItsLewizzz, May 8, 2017.

Thread Status:
Not open for further replies.
  1. Code:
    [REMOVED]

    Hello Spigoteers! I'm checking if the player's primary group is = to the group in the config. Here is the config:

    [REMOVED]

    When I set myself rank Default and try to join it does not send the custom join message. It would be at the part where it checks if the players group is a group in the config:

    [REMOVED]


    So when I join even with the correct group (Default) it does not send the custom join message and says that it is not defined in config. I added two new lines to send the variables in console to help debug the problem:

    [REMOVED]

    And I get this in console for the two previous lines of code are ran:
    [REMOVED]
    So obiousbly they are not equal because one is correct (Groups.Default) but the other is MemorySection[path='Groups.Default', root='YamlConfiguration'].

    So my question is, how do I make MemorySection[path='Groups.Default', root='YamlConfiguration'] change to just Groups.Default because I need them to be equal for the custom join message to work.

    Many Thanks,
    Lewis
     
    #1 ItsLewizzz, May 8, 2017
    Last edited: May 8, 2017
  2. First, the comparison you're doing is incorrect, because the object that the config will return isn't a String but a 'ConfigurationSection' or in this case 'MemorySection' (the implementation). Anyways i don't see why would you do that, simply get the section from the config and check if it isn't null, or you can do something like this.

    Code (Java):

    //onJoin
    String playerGroup = //get it from vault;
    String joinMessage = getConfig().getString("Groups." + playerGroup + ".JoinMessage");

    if (joinMessage != null) {
     event.setJoinMessage(joinMessage); //Replace the variables
    }
     
     
  3. You have to list every single player on the config so you can look for his rank.

    EDIT: @MaTaMoR_ already told you how to do that, I didn't read you're using Vault anyway xD
     
  4. Thank you it worked.

    Thread Locked
     
Thread Status:
Not open for further replies.