Kewilleen

KwConfig

Aug 27th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.08 KB | None | 0 0
  1. package kwkit.metodos;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import org.bukkit.configuration.file.FileConfiguration;
  7. import org.bukkit.configuration.file.YamlConfiguration;
  8. import org.bukkit.plugin.Plugin;
  9.  
  10. public class KwConfig {
  11.  
  12.     private static Plugin pl = KwMetodos.getPlugin();
  13.     private static FileConfiguration m, v;
  14.     private static File membros, f, vip;
  15.  
  16.     private static void getPasta() {
  17.         f = new File(pl.getDataFolder(), "Kits");
  18.         if (!f.exists()) {
  19.             f.mkdirs();
  20.         }
  21.     }
  22.  
  23.     private static void getMembros() {
  24.         membros = new File(pl.getDataFolder() + "/Kits/membro.yml");
  25.         if (!membros.exists()) {
  26.             try {
  27.                 membros.createNewFile();
  28.                 pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new Runnable() {
  29.                     @Override
  30.                     public void run() {
  31.                         pl.saveResource("Kits/membro.yml", true);
  32.                         m = YamlConfiguration.loadConfiguration(membros);
  33.                     }
  34.                 }, 1 * 20L);
  35.             } catch (IOException e) {
  36.                 e.printStackTrace();
  37.             }
  38.         }
  39.     }
  40.  
  41.     private static void getVIP() {
  42.         vip = new File(pl.getDataFolder() + "/Kits/vip.yml");
  43.         if (!vip.exists()) {
  44.             try {
  45.                 vip.createNewFile();
  46.                 pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new Runnable() {
  47.                     @Override
  48.                     public void run() {
  49.                         pl.saveResource("Kits/vip.yml", true);
  50.                         v = YamlConfiguration.loadConfiguration(vip);
  51.                     }
  52.                 }, 4 * 20L);
  53.             } catch (IOException e) {
  54.                 e.printStackTrace();
  55.             }
  56.         }
  57.     }
  58.  
  59.     private static void getArquivos() {
  60.         getMembros();
  61.         getVIP();
  62.     }
  63.  
  64.     public static void getKits() {
  65.         getPasta();
  66.         getArquivos();
  67.     }
  68.  
  69.     public static FileConfiguration getCnf() {
  70.         return m;
  71.     }
  72.  
  73.     public static FileConfiguration getV() {
  74.         return v;
  75.     }
  76.  
  77.     public static String getCnf(String cnf) {
  78.         return KwConfig.m.getString(cnf);
  79.     }
  80.  
  81.     public static String getReplaced(String cnf) {
  82.         return KwMetodos.replaced(getCnf(cnf));
  83.     }
  84.  
  85.     public static String getCnfV(String cnf) {
  86.         return KwConfig.v.getString(cnf);
  87.     }
  88.  
  89.     public static String getReplacedV(String cnf) {
  90.         return KwMetodos.replaced(getCnf(cnf));
  91.     }
  92.  
  93. }
Add Comment
Please, Sign In to add comment