// thanks for this method PermissionsBukkit
private void setPermissions(Player player, List<PPackage> packages) {
if (player == null) {
return;
}
PermissionAttachment attachment = permissions.get(player.getName());
if (attachment == null) {
System.err.println("Calculating permissions on " + player.getName() + ": attachment was null");
return;
}
for (String key : attachment.getPermissions().keySet()) {
attachment.unsetPermission(key);
}
// load from the data we have
for (PPackage pack : packages) {
for (PPermission perm : pack.getPermissions()) {
attachment.setPermission(perm.getName().toLowerCase(), perm.isTrue());
}
}
player.recalculatePermissions();
}