Sueta
CU

CustomYml

1.3.4

Easy custom yml file creator

·Plugin

Features:

  • You can create custom named yml files.
  • You can save easily your custom files.
  • You can save files into folders.

Installation:

  1. Press the download button and download the file from the github, or there is an external link:
    [Link]
  2. Drag and drop the .java file into your project!
  3. Done!

Tutorial:

Just to know: one CustomYml holds one physical file.

  1. Make a CustomYml class (or as many as file you want)
    public CustomYml worldConfig;
  2. Make a new CustomYml on every server load
    public void onEnable(){
      worldConfig = new CustomYml(this); //this: your main class
    }
  3. Add after new CustomYml .createNew()
    worldConfig = new CustomYml(this).createNew("FileName");
    
    //there are other options
    worldConfig = new CustomYml(this).createNew("FileName", true/false); //If you make the second parameter false then the generated config will be empty, if true the plugin will try to copy from .jar and paste
    
    .createNew(String folder, String fileName);
    .createNew(String folder, String fileName, boolean loadFromJar);

Getting the config file:

public CustomYml worldConfig;

public void onEnable(){
  worldConfig = new CustomYml(this).createNew("worlds");
}

public void changeSomething(){
  worldConfig.getConfig().set("Something", " ");
}

Saving the file:
If you change anything in a file or remove , you need to save it

worldConfig.save();

Reloading the file:
If a user changed anything in the file, for example with text editor, you will need to reload the file.

worldConfig.load();

Best way to store your yamls:

public class Configs {

    private static CustomYml classes;
    private static CustomYml shop;
  
    public Configs(JavaPlugin plugin) {
      
        classes = new CustomYml(plugin).createNew("class");
        shop = new CustomYml(plugin).createNew("shop");
      
    }

    public static FileConfiguration getClasses() { return classes.getConfig(); }
    public static FileConfiguration getShop() { return shop.getConfig(); }
  
    public static void saveClasses() { classes.save(); }
    public static void saveShop() { shop.save(); }
  
    public static void loadClasses() { classes.load(); }
    public static void loadShop() { shop.load(); }
}

public class MainClass extends JavaPlugin {

  public void onEnable(){
    new Configs(this);
  }

  public void somewhere(){
    Configs.getShop();  //You can use your Configs class everywhere, and dont need to create a new instance
  }

}

Similar projects

Plugin →