Solved Multiple errors in player config data

Discussion in 'Plugin Development' started by MaxFireIce, Feb 11, 2017.

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

    MaxFireIce

    I have multiple errors, I simply need to know how to do a few things. I am working on a WorldInventories plugin and I'm running into some holdups:

    The first is that I need to know if a player has never joined a certain world before, which in my case means they have nothing saved in the config, giving me a null pointer when I try to set their inventory to the saved one for that world.

    The second is that when a player dies, how would I save the blank inventory to the config (I think I already did this but it isn't working) and when they respawn, find out where they are spawning into and set the saved inventory in the config to their new inventory? I have a specific way I am setting and saving inventories so if you refer to either of those just say saveInv() or setInv()
     
  2. Offline

    timtower Administrator Administrator Moderator

    @MaxFireIce Config has a contains method, use that before you load it in.
     
  3. Offline

    MaxFireIce

    @timtower tried that and its acting.... odd. It seems to always think that the path I put in is never there ever. Any specific way on how to use it? So far I am only putting in the path to the player's inv save and it always returns false.
     
  4. Offline

    timtower Administrator Administrator Moderator

  5. Offline

    MaxFireIce

    @timtower
    I fixed it:
    Code:
            List<?> inv = config.getList(playerName + ".Worlds." + playerWorld + ".Inventory");
            if(inv == null) return;
    Apparently I have to check the variable instead of checking contains... weird
     
Thread Status:
Not open for further replies.

Share This Page