CustomCode

Untitled

Jan 14th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. public class PlayerConfig {
  2.  
  3.  
  4. static File cfile;
  5. static FileConfiguration config;
  6. static File folder = new File(MainClass.plugin.getDataFolder(), "player data" + File.separator);
  7. static File df = MainClass.plugin.getDataFolder();
  8.  
  9. public static void create(Player p) {
  10. cfile = new File(df, "player data" + File.separator + p.getUniqueId() + ".yml");
  11. if (!df.exists()) df.mkdir();
  12. if (!cfile.exists()) {
  13. try {
  14. cfile.createNewFile();
  15. } catch(Exception e) {
  16. Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Error creating " + cfile.getName() + "!");
  17. }
  18. }
  19. config = YamlConfiguration.loadConfiguration(cfile);
  20. }
  21.  
  22. public static File getfolder() {
  23. return folder;
  24. }
  25.  
  26. public static File getfile() {
  27. return cfile;
  28. }
  29.  
  30. public static void load(Player p) {
  31. cfile = new File(df, "player data" + File.separator + p.getUniqueId() + ".yml");
  32. config = YamlConfiguration.loadConfiguration(cfile);
  33. }
  34.  
  35. public static FileConfiguration get() {
  36. return config;
  37. }
  38.  
  39. public static void save() {
  40. try {
  41. config.save(cfile);
  42. } catch(Exception e) {
  43. Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Error saving " + cfile.getName() + "!");
  44. }
  45. }
  46. }
Add Comment
Please, Sign In to add comment