PermissionsEx

PermissionsEx

14M Downloads

API question

Haarolean opened this issue ยท 1 comments

commented

Hello,

I'm using PEX' API for managing players groups.
I've got few problems:

  1. When changing groups results don't take effect until player relogs/permissions reloaded
  2. Reloading with manager.reset(); doesn't work?

At the moment I have such code:

PermissionUser u = PermissionsEx.getUser(player.getPlayer());
u.getParents(null).forEach(u::removeGroup);
String newgroup = (String) winner1.value;
u.addGroup(newgroup);
PermissionManager manager = PermissionsEx.getPermissionManager();
try {
    manager.reset();
} catch (PermissionBackendException e) {/*smth here*/}

I get an unexpected result: when changing player's group first time (let's think that I have 20 groups and I choose random one each time I execute this code) after executing this code player will have no groups until this code will be run again, then he'll get pre-last (sic!) group. This can be fixed running /pex reload.

So, it looks like:

Action: Set the group to group 'A'
player has no groups now
Action: /pex reload
player is in group 'A' now
Action: Set the group to group 'B'
player is in group 'A' now
Action: Set the group to group 'C'
player is in group 'B' now
Action: /pex reload
player is in group 'C' now

So, questions:

  1. What is the proper way to save the results?
  2. What is the difference between manager.reset(); and /pex reload?
  3. How to refresh the player's cache or whatever to make him get his group without any additional movements?
commented

Actually, that appeared with last version, removing the reload code works fine with latest version. Though, please make it clear do I need to clear the cache and reload anything or not.