Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • 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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.