WorldGuard icon indicating copy to clipboard operation
WorldGuard copied to clipboard

Add custom Domains for domains used through the api

Open Joo200 opened this issue 3 years ago • 4 comments
trafficstars

Sometimes it can be handy to add custom domains instead of the player uuid, name or a permission group.

E.g. if you have more dynamic domains or you don't want to sync the members and/or owners between your region and worldguard.

Idea

Add some own domains to the DefaultDomain of regions. E.g. add your custom domain which determines the membership status by playtime.

You add your "ApiDomain" (maybe we can find a better name here) to the DefaultDomain with some informations how to parse your custom Domain to the regions.yml and backwards. There is a Registry for custom Factories for ApiDomains, where you have to register the ApiDomain and the Factory in onLoad (like the existing FlagFactory).

Missing points

  • [find better names:
    • [x] ApiDomain --> maybe CustomDomain?
  • [x] Display the names of the custom ApiDomains (or domain.toString()) in /rg info
  • [ ] Add this to sql storage (or ignore it)
  • [x] Check the usage to fit the needs
  • [x] Check whether the ApiDomain storage does work fine
  • [x] Code cleanup
  • [x] Documentation

Joo200 avatar Dec 29 '21 20:12 Joo200

initial thoughts:

  1. CustomDomain > ApiDomain
  2. there's no support for command usage or parsing yet, which means domains have to be added to regions by api. we should ultimately allow for /rg addmember <id> mydomain:somevalue in command usage. (wonder if it might be useful to have a perm for which domains can be used similar to the way flags perms work?)
  3. following 2, : should not be a valid character in domain names as that should split the name and value when parsing

wizjany avatar Dec 31 '21 16:12 wizjany

I looked in the code and I don't think we should add the custom domains to /rg addmember|addowner|removemember|removeowner commands. With the current DomainInputResolver there is no way to check for actors permissions and there is not really a "context" for the CustomDomain (e.g. the actor, the used ProtectedRegion or whether it's the owner or member domain).

Two new commands should work better for that: /rg ownerdomain <region> <domainname> [input] and /rg memberdomain <region> <domainname> [input] Command syntax is like the /rg flag <region> <flag> [input].

Joo200 avatar Jan 01 '22 15:01 Joo200

I removed the new commands as discussed on the discord. After some tests it looks fine for me, it works fine for me.

Maybe there should be some way to get a list of available custom domains but I don't know how that should be done. e.g. /rg domains? or /rg addmembers/addowners/delmembers/delowners?

Joo200 avatar Jan 29 '22 18:01 Joo200

not super-worried about discoverability atm as these will probably be niche for a while and will never be as much as flags. once piston happens suggestions will help.

wizjany avatar Jan 29 '22 19:01 wizjany