Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.kman2010.TD;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.Scanner;
- import org.bukkit.util.config.Configuration;
- public class TDSettings
- {
- /**
- * Settings
- */
- public static boolean ban = true;
- public static boolean kick = true;
- /**
- * Bukkit config class
- */
- public static Configuration config = null;
- /**
- * Load and parse the YAML config file
- */
- public static void load()
- {
- File dataDirectory = new File("plugins/TD");
- dataDirectory.mkdirs();
- File file = new File("plugins/TD", "config.yml");
- if (file.exists())
- {
- config = new Configuration(file);
- config.load();
- setSettings();
- {
- }
- }
- else
- {
- writeFile(file);
- config = new Configuration(file);
- config.load();
- }
- config.load();
- setSettings();
- }
- private static void writeFile(File file)
- {
- File temp = new File("plugins/TD", "Temp.yml");
- BufferedWriter bw;
- try
- {
- Configuration tempConfig;
- tempConfig = new Configuration(temp);
- tempConfig.load();
- tempConfig.setProperty("ban", ban);
- tempConfig.setProperty("kick", kick);
- tempConfig.save();
- Scanner sc = new Scanner(temp);
- bw = new BufferedWriter(new FileWriter(file));
- bw.write("#ban controles wheather or not a user is banned when placing tnt. Defaults to " + ban);
- bw.newLine();
- bw.write("#ban controles wheather or not a user is kicked when placing tnt. Defaults to " + kick);
- bw.newLine();
- while (sc.hasNextLine())
- {
- // String l=sc.nextLine();
- // System.out.println(l);
- bw.write(sc.nextLine());
- bw.newLine();
- }
- bw.close();
- temp.delete();
- }
- catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- /**
- * Sets the internal variables
- */
- private static void setSettings()
- {
- ban = config.getBoolean("strike.enabled", ban);
- kick = config.getBoolean("storm.enabled", kick);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement