Advertisement
Guest User

Untitled

a guest
May 30th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. package me.iamguus.tenrin.storage;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.UUID;
  6.  
  7. import me.iamguus.tenrin.Main;
  8.  
  9. import org.bukkit.configuration.file.FileConfiguration;
  10. import org.bukkit.configuration.file.YamlConfiguration;
  11. import org.bukkit.entity.Player;
  12.  
  13. public class PerPlayerConfig {
  14.    
  15.     UUID uuid;
  16.     private FileConfiguration f;
  17.     private File d;
  18.    
  19.     public PerPlayerConfig(Player p) {
  20.         this.uuid = p.getUniqueId();
  21.         this.d = new File(Main.getPlugin().getDataFolder(), "users" + File.separator + this.uuid + ".yml");
  22.         this.f = YamlConfiguration.loadConfiguration((File)this.d);
  23.     }
  24.    
  25.     public PerPlayerConfig(UUID uuid) {
  26.         this.uuid = uuid;
  27.         this.d = new File(Main.getPlugin().getDataFolder(), "users" + File.separator + this.uuid + ".yml");
  28.         this.f = YamlConfiguration.loadConfiguration((File)this.d);
  29.     }
  30.    
  31.     public void createFile() {
  32.         File d = new File(Main.getPlugin().getDataFolder(), "users");
  33.         File f = new File(Main.getPlugin().getDataFolder(), "users" + File.separator + this.uuid + ".yml");
  34.         if (!d.exists()) {
  35.             d.mkdirs();
  36.         }
  37.         if (!f.exists()) {
  38.             try {
  39.                 f.createNewFile();
  40.             }
  41.             catch (IOException e) {
  42.                 e.printStackTrace();
  43.             }
  44.         }
  45.     }
  46.    
  47.     public FileConfiguration getFile() {
  48.         return f;
  49.     }
  50.    
  51.     public void saveFile() {
  52.         try {
  53.             this.f.save(this.d);
  54.         } catch (IOException ex) {
  55.             ex.printStackTrace();
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement