Parsing Permission Groups by Name.

  • With permission groups changing in Unity and the advent of Areas and groups I am having a little difficulty detecting what group a player is in. I have an old Java routine that parsed the name of the group and decided certain extra keys to map and routines that could be run by them in my code. Also embedded in the permission group name was a number that I could read and again provide for some extra routines they could run. The problem is the currently I cannot seem to know what group the guy is in if he is moving around areas. Mind you this is not an attribute inside the file but the name itself I was trying to read such as farmer1, farmer2 etc. The file itself was a standard permission file but has different attributes turned on or off as sort of an advancement reward. But now I am getting a bunch of [StringOutOfBounds Exceptions(0,-1) out of bounds for length 0 ] and Preconditions for several lines when I thought it would run properly. No Errors in Compile.




    The routine does this onPlayerSpawnEvent() and runs just once to determine the players job. Should I set an player attribute when I read this? I wish there was a permissions name in the permissions.



    Any Thoughts or examples?

    currclass=player.getPermissionGroup();

    String pclass = currclass.substring(0, currclass.length() - 1);

    String lastChar = currclass.substring(currclass.length() - 1)

    lvl1 = Short.parseShort(lastChar);


    PS I am still troubleshooting this as some of the issue is that this maybe expecting Admins to be in a group also. It just is not clear to me where these errors are coming from. Maybe a null detection?

  • Player getActiveAreaPermission() gets the area permission permission of someone assigned to the area (from permissions/areas)

    Player getPlayerGroup() gets the players permission(from permissions)

    Area getPlayerPermission() should get a players default permissions to an area( from permissions/area the permissions set as an areas default permission. for some reason always returns null)

    they all return a string of the permission name.

    also, when a player spawns the area and its permissions will return null until the player has moved. i get around this buy on spawn adding .05f to the spawn position. gets just enogh movement to get the info


    Java
    String playerGroup = player.getPermissionGroup();
    player.sentTextMessage"playerGroup";
  • Interesting tactic to move the player on spawn. Maybe the area defaults are only set when in the area. Did you do the experiment in a defined Area? Area groups are going to change as the players move around the map. There is a method to read the current and old permissions as well as the area permissions. I guess you could check to see if there has been a change with a not-null check.


    That brings up that area permissions must be overriding regular permissions and would interfere with specialized class permissions assigned at spawn. Could an area permission grant specialized powers over standard permissions while in the area, I would guess, Yes. You could not have fly rights, for example, in the main world but be granted them in an area and vice versa. A players home area could be set to not allow PVP while he is in his area as owner while being able to kill those that visit.


    If I remember correctly there was a db that you could edit to set a players permission group by hand edit. Is there still a Db with players IDs and such? I did not find it on my fast search only the definitions db.

  • Ok I think maybe I should be creating and reading group name in the permission files. It is not set in the default.json. I was expecting it to come out of the file name like before.



    group

    info

    Determines the "group name" that should be shown in the player list. Other than that, this permission has no relevance


    Question is the group is just the group name not the file.name (Default or Default.json)?

  • group

    info

    Determines the "group name" that should be shown in the player list. Other than that, this permission has no relevance


    Question is the group is just the group name not the file.name (Default or Default.json)?

    the playergroup is the players permissions when 1. not in an area or 2. in an area that the player is not assigned to or said area has no default permission set.

    i would stay away from the default permissions file in the base of the permissions folder. this file is for when there is a player on the server that has no assigned permission. in the server config you want to set the Permissions_DefaultNewPlayerPermissionGroup= to an actual group you have created. in my case its Permissions_DefaultNewPlayerPermissionGroup=Pve.

    when getting playergroup() this returns either the name from the json or the actual name of the file (Pve,json returns Pve) im not 100% as i set the filename and the name setting the same.


    when a player is assigned to an area (in my case "Owner") the permission you want Area.getPlayerPermission(player) this returns the string of the assigned group in the area.



    from my understanding when a player is in an area where the default area permissions is set and the player is not assigned to the are you want to use Area.getActivePlayerPermission(player). for some reason this currently always returns null(maybe im doing something wrong or its not implemented yet). for this reason im setting the area's default permissions name as an attribute. this permission can also be found in the the rights table of the areas database.


  • A lot of code lines to determine what people can do and not do. There in lies a problem. for my old java server build at least. It seems to obsolete the ability to provide for an permission rank that lets people have more as they progress. In the concept a miner1 could not mine precious metals but basic metals such as iron. The permission group could be used to turn it on.

  • A lot of code lines to determine what people can do and not do.

    lol yeah, but the default playergroup is pve so this code also changes their player group to pvp when they enter a pvp area and to pve when they leave a pvp area as well as letting they player know when they are in and have left a pvp area


    It seems to obsolete the ability to provide for an permission rank that lets people have more as they progress. In the concept a miner1 could not mine precious metals but basic metals such as iron. The permission group could be used to turn it on.

    this should be doable already tho ive not tested it. groups miner1, miner2 and miner3. in the plugin do something like use

    playerdestroyterrainevent if(terrainid==goldoreidhere){

    if(player.getPlayerGroup().equals"miner1") {event.setCancelled}

  • lol yeah, but the default playergroup is pve so this code also changes their player group to pvp when they enter a pvp area and to pve when they leave a pvp area as well as letting they player know when they are in and have left a pvp area


    this should be doable already tho ive not tested it. groups miner1, miner2 and miner3. in the plugin do something like use

    playerdestroyterrainevent if(terrainid==goldoreidhere){

    if(player.getPlayerGroup().equals"miner1") {event.setCancelled}

    That is pretty tedious turning off each permission for each class of player when you used to just have one file that determined class permissions. I even turned off PVP for new players who started as Farmer1 so that they could live in peace until they got used to it but they could not grow some crops nor hold or craft a sword. I think setting up several permission files and assigning permissions based on group will work if they are named in the files. The area switching will be necessary evil that may just take duplicated permissions files. We will see.


    Thanks for the input and brainstorming it certainly gives me options over the wall of what changed from the unity style permissions.


    Anybody know where permissions for players is stored now?

  • I think setting up several permission files and assigning permissions based on group will work if they are named in the files. The area switching will be necessary evil that may just take duplicated permissions files. We will see.

    if your wanting to do something like was doable in java just ignore the area permissions . make a playergroup for each one. miner1 miner2 farmer1 farmer2. then its as simple ass assigning the group at the right time. use the api to control when they change to the next group.

  • Just ran into an issue. I have visitor permissions for people to look around but not destroy things. When I gave someone area ownership they could do all kind of things but when they dug out of their area they could not dig anymore. They reverted back to visitor group. I will have to figure something out.


    Ok the world still has the player database and you can edit it manually like the old style.

  • Just ran into an issue. I have visitor permissions for people to look around but not destroy things. When I gave someone area ownership they could do all kind of things but when they dug out of their area they could not dig anymore. They reverted back to visitor group. I will have to figure something out.

    thats because area permission trump playergroups.

  • Has anyone tested the in game command ~ setofflineplayergroup? I tried it but it did not modify the player database group ?

    how are you looking at the db? remote desktop to the server or copying from the server to another pc? i ask as if you try to copy the database from the server to another pc the data is not correct.

  • I stop the server and look at the database move it to a local via FTP. Edit it with DbBrowser and rewrite it to save changes. Then I move it back to the server and restart. It works fine after that with new group. But when I use setofflineplayergroup it does not change it.


    However this does mean we can read and write to the database online in a routine. It should not be too bad

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!