Solved PlayerJoinEvent & Config

Discussion in 'Plugin Development' started by ryryanator, Aug 27, 2014.

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

    ryryanator

    Hello! I've read up about config files alot, but still don't have the hang of them. I'm trying to make PlayerJoinEvent that checks if the player has played before, and if not make a string in the config file for them. Here is the current way i'm trying.
    Code:java
    1. @EventHandler
    2.  
    3. public void onPlayerJoin(PlayerJoinEvent e) {
    4. Player p = e.getPlayer();
    5. String player = p.getName();
    6.  
    7.  
    8. if (p.hasPlayedBefore()) {
    9. //Just a check
    10. }else{
    11. getConfig().set(player,"300");
    12. saveConfig();
    13. }
    14. }

    Could someone please tell me how to properly do this? Thanks!
     
  2. Offline

    Violence010

    That would work fine, for me.
     
  3. Offline

    _Cookie_

    Have you registered your event in your Main class?
    Code:java
    1. Bukkit.getServer().getPluginManager().registerEvents(new ListenerClassName(), this);
     
  4. Offline

    ryryanator

    I got it to work.
     
  5. Offline

    FerusGrim

    ryryanator
    That's fantastic! Someone solving their own problem is the coolest thing. :)

    For future reference in-case someone finds this page with a similar question, would you mind explaining how you solved your problem?
     
  6. Offline

    ryryanator

    It was along the lines of what _Cookie_ said. I just forgot to add
    Code:java
    1. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    A really simple mistake.
     
Thread Status:
Not open for further replies.

Share This Page