daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.vertcode.hub;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.configuration.file.FileConfiguration;
  8. import org.bukkit.configuration.file.YamlConfiguration;
  9. import org.bukkit.plugin.Plugin;
  10.  
  11. import net.md_5.bungee.api.ChatColor;
  12.  
  13. public class Files {
  14.    
  15.     private static Files instance;
  16.    
  17.     public static FileConfiguration datacfg;
  18.     public static File datafile;
  19.    
  20.     public static void setup(Plugin p) {
  21.         if (!p.getDataFolder().exists()) {
  22.             p.getDataFolder().mkdir();
  23.         }
  24.        
  25.         datafile = new File(p.getDataFolder(), "data.yml");
  26.        
  27.         if (!datafile.exists()) {
  28.             try {
  29.                 datafile.createNewFile();
  30.             }catch (IOException e) {
  31.                 Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "Could not create the data.yml file");
  32.             }
  33.         }
  34.        
  35.         datacfg = YamlConfiguration.loadConfiguration(datafile);
  36.        
  37.     }
  38.    
  39.     public static FileConfiguration getData() {
  40.         return datacfg;
  41.     }
  42.    
  43.     public static void savedata() {
  44.         try {
  45.             datacfg.save(datafile);
  46.            
  47.         }catch (IOException e) {
  48.             Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "Could not save the data.yml file");
  49.         }
  50.     }
  51.    
  52.     public static void reloaddata() {
  53.         datacfg = YamlConfiguration.loadConfiguration(datafile);
  54.     }
  55.    
  56.     public static Files getInstance() {
  57.         return instance;
  58.     }
  59.    
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top