Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package plugin.goldengalaxy.co.managers;
- import java.io.File;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.plugin.Plugin;
- @SuppressWarnings("unused")
- public class PluginConfiguration {
- private Plugin plugin;
- private File file, folder;
- private YamlConfiguration config;
- public PluginConfiguration(Plugin plugin, String FolderName, String FileName) {
- this.folder = new File(plugin.getDataFolder(), FolderName);
- this.plugin = plugin;
- try {
- this.folder.mkdir();
- } catch (Exception e) {
- e.printStackTrace();
- }
- this.file = new File(this.folder, FileName + ".yml");
- try {
- file.createNewFile();
- } catch (Exception e) {
- e.printStackTrace();
- }
- reloadConfig();
- }
- public PluginConfiguration(Plugin plugin, String FileName, boolean copy) {
- this.plugin = plugin;
- this.file = new File(plugin.getDataFolder(), FileName + ".yml");
- if(copy) {
- plugin.saveResource(file.getName(), true);
- } else {
- try {
- file.createNewFile();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- reloadConfig();
- }
- public boolean exists(File pf) {
- if(pf.exists()) {
- return true;
- }
- else {
- return false;
- }
- }
- public YamlConfiguration getConfig() {
- return config;
- }
- public void reloadConfig() {
- config = YamlConfiguration.loadConfiguration(file);
- }
- public void saveConfig() {
- try {
- config.save(file);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement