Player Files Not Working

Discussion in 'Plugin Development' started by CrazymanJR, Jan 18, 2015.

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

    CrazymanJR

    I'm trying to create player files on join using this file, but it won't create it:
    error: http://gyazo.com/9a9d2c52280769a566d31647950fc328
    Code:
    package me.crazymanjr.shotcadehub;
    
    import java.io.File;
    import java.io.IOException;
    import java.util.UUID;
    
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    
    public class PlayerFile {
    
    private UUID uuid = null;
    
    private File file;
    private FileConfiguration conf;
    
    public PlayerFile(UUID uuid) {
      this.uuid = uuid;
    }
    
    public void load() {
      if (file == null) {
       file = new File(Main.get().getDataFolder() + File.separator + "playerInfo", uuid + ".yml");
       try {
        file.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
      }
    
      conf = YamlConfiguration.loadConfiguration(file);
    }
    
    public FileConfiguration getConfig() {
      if (conf == null) {
       load();
      }
    
      return conf;
    }
    
    public void save() {
          if (file == null || conf == null) {
           load();
           return;
          }
    
          try {
           getConfig().save(file);
          } catch (IOException ex) {
           Main.get().getLogger().severe("Unable to save " + uuid + ".yml.");
           ex.printStackTrace();
          }
         }
    }
     
  2. Offline

    pie_flavor

    Instead of saying "playerInfo", uuid + ".yml", why wouldn't you just do "playerInfo" + File.separator+uuid+".yml" in the first place?
     
  3. Offline

    Avery246813579

    @CrazymanJR
    The server could not find the location of your player file! You might want to check if the location of the file is correct (Line 23).
     
Thread Status:
Not open for further replies.

Share This Page