Skip to content

Commit

Permalink
Merge pull request #17 from skykatik/master
Browse files Browse the repository at this point in the history
Fix memory leak
  • Loading branch information
HexedHero authored Feb 18, 2024
2 parents 759d884 + 974234a commit 5ffb263
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public PermissionsManager(CitizensCMD plugin) {
public void setPermission(Player player, String permission) {
final PermissionAttachment permissionAttachment = player.addAttachment(plugin);
permissionsData.put(player.getUniqueId(), permissionAttachment);
final PermissionAttachment permissionAttachment1 = permissionsData.get(player.getUniqueId());
permissionAttachment1.setPermission(permission, true);
permissionAttachment.setPermission(permission, true);
}

/**
Expand All @@ -57,7 +56,10 @@ public void setPermission(Player player, String permission) {
* @param permission The permission node to be removed
*/
public void unsetPermission(Player player, String permission) {
permissionsData.get(player.getUniqueId()).unsetPermission(permission);
PermissionAttachment attachment = permissionsData.remove(player.getUniqueId());
if (attachment != null) {
attachment.unsetPermission(permission);
}
}

}

0 comments on commit 5ffb263

Please sign in to comment.