Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private FileConfiguration player;
- private File playerf;
- public void onEnable()
- {
- // Define the plugin
- plugin = this;
- // Create the file
- createFiles();
- }
- public void onDisable()
- {
- saveDefaultConfig();
- // Prevent memmory from leeking
- plugin = null;
- }
- // work like getConfig()
- public FileConfiguration getPlayerConfig() {
- return this.player;
- }
- // createFiles();
- private void createFiles(){
- // Define player.yml
- playerf = new File(getDataFolder(), "player.yml");
- // Create player.yml
- if(!playerf.exists()) {
- playerf.getParentFile().mkdirs();
- saveResource("player.yml", false);
- }
- // Load player.yml
- player = new YamlConfiguration();
- try{
- player.load(playerf);
- } catch (IOException e){
- e.printStackTrace();
- } catch (InvalidConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- // getPlayerConfigFile()
- public File getPlayerConfigFile() {
- return this.playerf;
- }
- // After set config
- // Put this after the code that you load the config to set a value
- main.plugin.saveDefaultConfig();
- try {
- main.plugin.getLuckyNumberConfig().save(main.plugin.getLuckyNumberConfigFile());
- } catch (IOException fpe) {
- //Whatever you want to print/etc for error purposes
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement