You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-19 15:06:19 +00:00
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:
+14
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user