Refactored Permissions Groups, changed command and rights keys

This commit is contained in:
Stankman 2023-07-24 17:55:25 -05:00
parent e2b0299aec
commit ff2cfc2498
3 changed files with 20 additions and 6 deletions

View File

@ -1,11 +1,11 @@
package com.eu.habbo.habbohotel.commands.list;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.PermissionCommand;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class CommandsCommand extends Command {
@ -17,13 +17,19 @@ public class CommandsCommand extends Command {
public boolean handle(GameClient gameClient, String[] params) {
StringBuilder message = new StringBuilder(getTextsValue("commands.generic.cmd_commands.text"));
List<PermissionCommand> commands = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getCommands();
List<String> commands = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getCommands();
Collections.sort(commands, Comparator.comparing(PermissionCommand::getName));
Collections.sort(commands);
message.append("(").append(commands.size()).append("):\r\n");
for(PermissionCommand command : commands) {
for(String commandName : commands) {
PermissionCommand command = Emulator.getGameEnvironment().getPermissionsManager().getCommand(commandName);
if(command == null) {
continue;
}
message.append(command.getDescription()).append("\r");
}

View File

@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.commands.list;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.PermissionRight;
@ -15,11 +16,17 @@ public class RightsCommand extends Command {
public boolean handle(GameClient gameClient, String[] params) throws Exception {
StringBuilder message = new StringBuilder(getTextsValue("commands.generic.cmd_rights.text"));
Set<PermissionRight> rights = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getRights();
Set<String> rights = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getRights();
message.append("(").append(rights.size()).append("):\r\n");
for(PermissionRight right : rights) {
for(String rightName : rights) {
PermissionRight right = Emulator.getGameEnvironment().getPermissionsManager().getRight(rightName);
if(right == null) {
continue;
}
message.append(right.getName()).append(" - ").append(right.getDescription()).append("\r");
}

View File

@ -58,6 +58,7 @@ public class PermissionsManager {
log.error("Caught SQL exception", e);
}
//TODO if Group is eliminated every user that has this rank must update to lowest Rank
this.permissionGroups.entrySet().removeIf(entry -> !currentGroupIds.contains(entry.getKey()));
}