Skip to content

Commit

Permalink
Fixed role permissions override each other causing them to not get sa…
Browse files Browse the repository at this point in the history
…ved correctly (#831, #1301)
  • Loading branch information
OmerBenGera committed Jul 30, 2022
1 parent 1f32391 commit 46fd1d3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
Expand Up @@ -149,12 +149,6 @@ public static void saveRolePermission(Island island, PlayerRole playerRole, Isla
));
}

public static void removeRolePermission(Island island, PlayerRole playerRole) {
runOperationIfRunning(island.getDatabaseBridge(), databaseBridge -> databaseBridge.deleteObject("islands_role_permissions",
createFilter("island", island, new Pair<>("role", playerRole.getId()))
));
}

public static void clearRolePermissions(Island island) {
runOperationIfRunning(island.getDatabaseBridge(), databaseBridge -> databaseBridge.deleteObject("islands_role_permissions",
createFilter("island", island)));
Expand Down
Expand Up @@ -1112,16 +1112,14 @@ public void setPermission(PlayerRole playerRole, IslandPrivilege islandPrivilege
PluginDebugger.debug("Action: Set Permission, Island: " + owner.getName() + ", Role: " + playerRole +
", Permission: " + islandPrivilege.getName());

PlayerRole oldRole = rolePermissions.put(islandPrivilege, playerRole);
rolePermissions.put(islandPrivilege, playerRole);

if (islandPrivilege == IslandPrivileges.FLY) {
getAllPlayersInside().forEach(this::updateIslandFly);
} else if (islandPrivilege == IslandPrivileges.VILLAGER_TRADING) {
getAllPlayersInside().forEach(superiorPlayer -> IslandUtils.updateTradingMenus(this, superiorPlayer));
}

if (oldRole != null)
IslandsDatabaseBridge.removeRolePermission(this, oldRole);
IslandsDatabaseBridge.saveRolePermission(this, playerRole, islandPrivilege);
}

Expand Down

0 comments on commit 46fd1d3

Please sign in to comment.