Clear player permission cache when changing permissions through Vault API

This commit is contained in:
Marc Baloup 2023-08-29 13:59:27 +02:00
parent 62949948e1
commit 69a4f2fe6f

View File

@ -115,6 +115,7 @@ import java.util.List;
checkEnabled(); checkEnabled();
String server = PandalibPaperPermissions.serverName; String server = PandalibPaperPermissions.serverName;
Permissions.getPlayer(player.getUniqueId()).addSelfPermission(permission, server, world); Permissions.getPlayer(player.getUniqueId()).addSelfPermission(permission, server, world);
Permissions.clearPlayerCache(player.getUniqueId());
Log.info("A plugin added permission " + permission + " (server=" + server + ",world=" + world + ") to player " + player.getName() + " through Vault."); Log.info("A plugin added permission " + permission + " (server=" + server + ",world=" + world + ") to player " + player.getName() + " through Vault.");
return true; return true;
} }
@ -130,6 +131,7 @@ import java.util.List;
checkEnabled(); checkEnabled();
String server = PandalibPaperPermissions.serverName; String server = PandalibPaperPermissions.serverName;
Permissions.getPlayer(player.getUniqueId()).removeSelfPermission(permission, server, world); Permissions.getPlayer(player.getUniqueId()).removeSelfPermission(permission, server, world);
Permissions.clearPlayerCache(player.getUniqueId());
Log.info("A plugin removed permission " + permission + " (server=" + server + ",world=" + world + ") to player " + player.getName() + " through Vault."); Log.info("A plugin removed permission " + permission + " (server=" + server + ",world=" + world + ") to player " + player.getName() + " through Vault.");
return true; return true;
} }
@ -150,14 +152,14 @@ import java.util.List;
@Override @Override
public boolean groupAdd(String world, String group, String permission) { public boolean groupAdd(String world, String group, String permission) {
Log.warning(new Throwable("A plugin tried to add to group " + group + " (world=" + world + ") the permission " + permission Log.severe(new Throwable("A plugin tried to add to group " + group + " (world=" + world + ") the permission " + permission
+ " through Vault but Pandalib does not support it.")); + " through Vault but Pandalib does not support it."));
return false; return false;
} }
@Override @Override
public boolean groupRemove(String world, String group, String permission) { public boolean groupRemove(String world, String group, String permission) {
Log.warning(new Throwable("A plugin tried to remove from group " + group + " (world=" + world + ") the permission " + permission Log.severe(new Throwable("A plugin tried to remove from group " + group + " (world=" + world + ") the permission " + permission
+ " through Vault but Pandalib does not support it.")); + " through Vault but Pandalib does not support it."));
return false; return false;
} }
@ -177,7 +179,7 @@ import java.util.List;
@Deprecated @Deprecated
@Override @Override
public boolean playerAddGroup(String world, String player, String group) { public boolean playerAddGroup(String world, String player, String group) {
Log.warning(new Throwable("A plugin tried to add player " + player + " (world=" + world + ") to permission group " + group Log.severe(new Throwable("A plugin tried to add player " + player + " (world=" + world + ") to permission group " + group
+ " through Vault but Pandalib does not support it.")); + " through Vault but Pandalib does not support it."));
return false; return false;
} }
@ -185,7 +187,7 @@ import java.util.List;
@Deprecated @Deprecated
@Override @Override
public boolean playerRemoveGroup(String world, String player, String group) { public boolean playerRemoveGroup(String world, String player, String group) {
Log.warning(new Throwable("A plugin tried to remove player " + player + " (world=" + world + ") from permission group " + group Log.severe(new Throwable("A plugin tried to remove player " + player + " (world=" + world + ") from permission group " + group
+ " through Vault but Pandalib does not support it.")); + " through Vault but Pandalib does not support it."));
return false; return false;
} }