Posted June 19, 20178 yr Hi, 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 e.g. default: default: true permissions: vanilla.gamemode 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 Thanks
June 20, 20178 yr Author 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");
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.