Advertisement
Guest User

Untitled

a guest
May 1st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. package me.goksi.extremebans;
  2.  
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import java.io.IOException;
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.configuration.InvalidConfigurationException;
  9. import org.bukkit.configuration.file.YamlConfiguration;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. public class Main extends JavaPlugin {
  13.     Command cmd = new Command(this);
  14.     private Main plugin;
  15.     public YamlConfiguration banlist = new YamlConfiguration();
  16.     private File bl = null;
  17.     PlayerListener pl = new PlayerListener(this);
  18.     public void onEnable(){
  19.         plugin = this;
  20.         bl = new File(getDataFolder(), "banlist.yml");
  21.         mkdir();
  22.         loadYAML();
  23.         getConfig().options().copyDefaults(true);
  24.         saveConfig();
  25.         getCommand("efban").setExecutor(cmd);
  26.         Bukkit.getServer().getPluginManager().registerEvents(pl, this);
  27.         Bukkit.getServer().getPluginManager().registerEvents(cmd, this);
  28.         getLogger().info("mc.extreme-factions.info");
  29.     }
  30.    
  31.     public void onDisable(){
  32.         saveConfig();
  33.         plugin.saveBanList();
  34.     }
  35.    
  36.     private void mkdir(){
  37.         if(!bl.exists()){
  38.             saveResource("banlist.yml", false);
  39.         }
  40.     }
  41.    
  42.     private void loadYAML(){
  43.         try {
  44.             banlist.load(bl);
  45.         } catch (FileNotFoundException e) {
  46.             e.printStackTrace();
  47.         } catch (IOException e) {
  48.             e.printStackTrace();
  49.         } catch (InvalidConfigurationException e) {
  50.             e.printStackTrace();
  51.         }
  52.     }
  53.    
  54.     public YamlConfiguration getBanList(){
  55.         return banlist;
  56.     }
  57.    
  58.     public void saveBanList(){
  59.         try {
  60.             banlist.save(bl);
  61.         } catch (IOException e) {
  62.             e.printStackTrace();
  63.         }
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement