Help with Config

Discussion in 'Plugin Development' started by Ape101, Feb 26, 2014.

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

    Ape101

    Code:java
    1. public void FirstJoin(PlayerJoinEvent event){
    2. Player p = event.getPlayer();
    3.  
    4. if(!p.hasPlayedBefore()){
    5. event.setJoinMessage(null);
    6. //This doesn't work, dunno why
    7. Plugin.get().getConfig().addDefault("players." + p.getName() + ".world", "world");
    8. Plugin.get().getConfig().addDefault("players." + p.getName() + ".currency", "0");
    9.  
    10. }
    11.  
    12. else{
    13.  
    14. event.setJoinMessage(null);
    15. //How to set to the defaults if a player doesn't have anything
    16. Plugin.get().getConfig().addDefault("players." + p.getName() + ".world", "Alcatraz");
    17. Plugin.get().getConfig().addDefault("players." + p.getName() + ".currency", "0");
    18.  
    19. }
    20. }


    So i'm trying to have it add things per player that joins, to the config, but this doesn't work, and i'm not all that good with configs so can anyone help me out here? what am i doing wrong? how can i do better and make it actually work :p
     
  2. Offline

    MrInspector

    You forgot your @EventHandler. :p
     
  3. Offline

    Ape101

    Nope, just didn't put that in there :p
    Helpful bumb also
     
  4. Offline

    Vandrake

    PlayerJoin is a bitch, add a 1tick delay before doing anything.
     
Thread Status:
Not open for further replies.

Share This Page