chriscn / StaffChat

0 stars 0 forks source link

Custom Channels #3

Open chriscn opened 4 years ago

chriscn commented 4 years ago

It would be nice to allow users to define as many custom or VirtualChannel as they'd like. I was thinking about acomplishing this through a list in the config. However that is proving more difficult.

channel:
  admin:
   - name: admin
   - permission_write: staffchat.admin.write
   - permisson_read: staffchat.admin.read
   - message_format: "&c[ADMIN]"
  staff:
   - permission_write: staffchat.staff.write
   - permisson_read: staffchat.staff.read
   - message_format: "&a[STAFF]"
  developer:
   - permission_write: staffchat.developer.write
   - permisson_read: staffchat.developer.read
   - message_format: "&e[DEVELOPER]"

However that is proving to be very difficult in Java with YAML. Maybe I should use JSON?

chriscn commented 4 years ago

This JSON approach that works.

{
    "channel": [{
            "name": "staff",
            "format": "&e[STAFF]"
        },
        {
            "name": "admin",
            "format": "&c[ADMIN]"
        }
    ]
}
const json_file = require('./test.json');

//console.log(json_file);

let channels = json_file['channel'];

for (let channel of channels) {
  console.log("Channel name: " + channel.name + " with format " + channel.format);

}