Jump to content

creating Key-Value arrays in configs


Recommended Posts



I'm building a simple permission manager for a friend. I'm pretty much learning everything as I go. What I'm trying to do right now is create a config file that lists the users, each user's group and the groups/permissions


I want the permissions to be readable so I was trying to replicate the PermissionsEx Bukkit plugin





    default: true





so it's basically a key/value format.


[groupname: [default: true, permissions: [vanilla.gamemode, vanilla.help]]]


I'm not really sure how to do this using the Configuration class. Can someone help me with this?

I'm using 1.12



Link to comment
Share on other sites

For anybody who might look for the answer to this in the future, GSON is the solution


create a class for the object you want to make JSON


Class Groups{

  private String name;
  private boolean initial;
  private String[] permissions;
  public Group(String n, boolean init, String[] p) {
		// TODO Auto-generated constructor stub
		name = n;
		initial = init;
		permissions = p;




then in the syncConfig() method you do something like this:


		String[] perms = {"vanilla.help"};
    	String[] oPerms = {"*"};
    	Group def = new Group("default", true, perms);
    	Group owner = new Group("Owner", false, oPerms);
    	Gson g = new Gson();
    	String json1 = g.toJson(def);
    	String json2 = g.toJson(owner);
    	String[] groups = {json1, json2};

    	config.getStringList("Groups", "groups", groups, "Comment here");


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.