Need help with getting name from config!

Discussion in 'Plugin Development' started by tinusium, Nov 15, 2021.

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

    tinusium

    Hello there,

    Im creating my own plugin where I have some teams.
    When a player joins a team. The players name will be stored in a config.yml.
    But now when i reload or join the server again the player is no longer in a team so I though I create a check when a player's name is in the team/config. It will automatically rejoin the team again.

    Only when I create the check. It gives me a nullpointer no matter what I check from the config.
    Can someone help me?

    The piece of code is:
    Code:
        public static String getPartyOwnedByPlayer(Player player) {
            if(CustomConfig.get().getString("Teams:") == null) {
                    CustomConfig.get().createSection("Teams:");
                    CustomConfig.save();
                    player.sendMessage(ChatColor.RED +"test");
                } else {
                    String playerName=player.getName().toString();
                   
    
                   
                   
                        if (CustomConfig.get().getString("Teams:.TeamMB.Players.").contains(playerName) && CustomConfig.get().getString("Teams:.TeamMB.Players.") != null) {
                            Teams.addToTeam(TeamType.MB, player);
                            player.sendMessage("Test");
                            return playerName;
                        } else {
    
                            player.sendMessage(ChatColor.RED + "Je zit niet in een team!");
                            return playerName;
                        }
                       
                       
    
                }
            return null;
           
        }
    }
    

    The error i get is:

     
  2. Offline

    KarimAKL

    @tinusium Your config path includes:
    Code:
    Team:.*
    You probably mean to use:
    Code:
    Team.*
     
Thread Status:
Not open for further replies.

Share This Page