Skip to content
This repository has been archived by the owner on May 30, 2021. It is now read-only.

JsonConfigExample

spotifynutzeer edited this page Mar 12, 2021 · 1 revision

JsonConfigExample

import org.bukkit.entity.Player;
import xyz.spotifynutzer.MinecraftCore;
import xyz.spotifynutzer.json.ConfigManager;

import java.io.File;

public class JsonConfigExample {

    public void setConfig(Player player) {
        ConfigManager configManager = MinecraftCore.getInstance().createNewJsonConfig();
        configManager.setString("string", "Hey c;");
        configManager.setDouble("double", 1D);
        configManager.setInt("int", 1);
        configManager.setLong("long", 1L);
        configManager.setLocation("location", player.getLocation());
        configManager.saveToFile(new File("file.json"));
    }
    
    public void getConfig() {
        ConfigManager configManager = new ConfigManager(MinecraftCore.getInstance().getConfigProvider().getConfigFromFile(new File("file.json")));
        configManager.getString("string"); //will be Hey c;
        configManager.getDouble("double"); //will be 1D
        configManager.getInt("int"); //will be 1
        configManager.getLong("long"); //will be 1L
        configManager.getLocation("location"); //will be the location of the player
    }
}