mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-21 18:25:12 +01:00
Make the rank clearing async to avoid lag. #2504
This commit is contained in:
parent
f5abdd4c78
commit
0965e07d93
@ -1650,6 +1650,10 @@ public class IslandsManager {
|
||||
* @param uniqueId - UUID of player
|
||||
*/
|
||||
public void clearRank(int rank, UUID uniqueId) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> clearRankSync(rank, uniqueId));
|
||||
}
|
||||
|
||||
void clearRankSync(int rank, UUID uniqueId) {
|
||||
islandCache.getCachedIslands().forEach(
|
||||
i -> i.getMembers().entrySet().removeIf(e -> e.getKey().equals(uniqueId) && e.getValue() == rank));
|
||||
}
|
||||
|
@ -1111,9 +1111,9 @@ public class IslandsManagerTest extends AbstractCommonSetup {
|
||||
UUID coopUUID = UUID.randomUUID();
|
||||
members.put(coopUUID, RanksManager.COOP_RANK);
|
||||
// Clear a random user
|
||||
im.clearRank(RanksManager.COOP_RANK, UUID.randomUUID());
|
||||
im.clearRankSync(RanksManager.COOP_RANK, UUID.randomUUID());
|
||||
assertEquals(14, members.size());
|
||||
im.clearRank(RanksManager.COOP_RANK, coopUUID);
|
||||
im.clearRankSync(RanksManager.COOP_RANK, coopUUID);
|
||||
assertEquals(13, members.size());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user