fix(housekeeping): allow core rank peer actions

Keep the housekeeping rank ceiling for normal staff, but treat the highest configured rank as the core rank so rank 7 can act on other rank 7 users without opening peer actions for lower staff ranks.

Tests: mvn '-Dtest=HousekeepingTargetRankGuardContractTest,HousekeepingMutationGuardTest,HousekeepingSetUserRankEventTest,HousekeepingTargetRankGuardContractTest' test
This commit is contained in:
simoleo89
2026-06-14 20:20:00 +02:00
parent 9ac50600f6
commit 2b18ca2deb
2 changed files with 21 additions and 4 deletions
@@ -1,6 +1,7 @@
package com.eu.habbo.messages.incoming.housekeeping;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.permissions.Rank;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
@@ -18,6 +19,18 @@ final class HousekeepingTargetRankGuard {
return true;
}
return targetInfo.getRank().getId() < operator.getHabboInfo().getRank().getId();
int operatorRankId = operator.getHabboInfo().getRank().getId();
int targetRankId = targetInfo.getRank().getId();
return targetRankId < operatorRankId || isCoreRank(operatorRankId) && targetRankId <= operatorRankId;
}
private static boolean isCoreRank(int rankId) {
int highestRankId = 0;
for (Rank rank : Emulator.getGameEnvironment().getPermissionsManager().getAllRanks()) {
highestRankId = Math.max(highestRankId, rank.getId());
}
return highestRankId > 0 && rankId >= highestRankId;
}
}
@@ -24,11 +24,15 @@ class HousekeepingTargetRankGuardContractTest {
);
@Test
void privilegedUserActionsRejectPeerAndHigherRankTargets() throws Exception {
void privilegedUserActionsRejectPeerRanksUnlessOperatorIsCoreRank() throws Exception {
String guard = Files.readString(Path.of("src/main/java/com/eu/habbo/messages/incoming/housekeeping/HousekeepingTargetRankGuard.java"));
assertTrue(guard.contains("targetInfo.getRank().getId() < operator.getHabboInfo().getRank().getId()"),
"Housekeeping user actions must only target lower-ranked users");
assertTrue(guard.contains("targetRankId < operatorRankId"),
"non-core housekeeping operators must only target lower-ranked users");
assertTrue(guard.contains("isCoreRank(operatorRankId) && targetRankId <= operatorRankId"),
"the highest/core rank should be allowed to target peer ranks");
assertTrue(guard.contains("private static boolean isCoreRank(int rankId)"),
"core-rank detection should be centralized in the target-rank guard");
}
@Test