mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 10:45:22 +01:00
Merge pull request #2505 from BentoBoxWorld/2504_lag_on_logout
Make the rank clearing async to avoid lag. #2504
This commit is contained in:
commit
060e700fce
@ -1650,6 +1650,10 @@ public class IslandsManager {
|
|||||||
* @param uniqueId - UUID of player
|
* @param uniqueId - UUID of player
|
||||||
*/
|
*/
|
||||||
public void clearRank(int rank, UUID uniqueId) {
|
public void clearRank(int rank, UUID uniqueId) {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> clearRankSync(rank, uniqueId));
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearRankSync(int rank, UUID uniqueId) {
|
||||||
islandCache.getCachedIslands().forEach(
|
islandCache.getCachedIslands().forEach(
|
||||||
i -> i.getMembers().entrySet().removeIf(e -> e.getKey().equals(uniqueId) && e.getValue() == rank));
|
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();
|
UUID coopUUID = UUID.randomUUID();
|
||||||
members.put(coopUUID, RanksManager.COOP_RANK);
|
members.put(coopUUID, RanksManager.COOP_RANK);
|
||||||
// Clear a random user
|
// Clear a random user
|
||||||
im.clearRank(RanksManager.COOP_RANK, UUID.randomUUID());
|
im.clearRankSync(RanksManager.COOP_RANK, UUID.randomUUID());
|
||||||
assertEquals(14, members.size());
|
assertEquals(14, members.size());
|
||||||
im.clearRank(RanksManager.COOP_RANK, coopUUID);
|
im.clearRankSync(RanksManager.COOP_RANK, coopUUID);
|
||||||
assertEquals(13, members.size());
|
assertEquals(13, members.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user