From fcd3b95fff8b8ec8bc14e9676057a0f793fd412d Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 8 Aug 2018 15:06:42 +0100 Subject: [PATCH] Fix double friends in the chest ui --- .../mineplex/core/friend/ui/FriendMainPage.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendMainPage.java index 2874ea9ea..0a7d4c92a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendMainPage.java @@ -1,5 +1,7 @@ package mineplex.core.friend.ui; +import java.util.HashSet; +import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -47,6 +49,7 @@ public class FriendMainPage extends ShopPageBase } } + private final Set _shown; private final MultiPageManager _pageManager; private FriendPageType _pageType; @@ -54,10 +57,20 @@ public class FriendMainPage extends ShopPageBase { super(plugin, shop, clientManager, donationManager, "Friends", player); + _shown = new HashSet<>(); _pageManager = new MultiPageManager<>(this, () -> getPlugin().Get(player).stream() .filter(_pageType.Filter) .sorted(FriendManager.getFriendSorter()) - .collect(Collectors.toList()), this::buildItem); + .collect(Collectors.toList()), (status, slot) -> + { + if (_shown.add(status.Name)) + { + buildItem(status, slot); + return true; + } + + return false; + }); _pageType = FriendPageType.MAIN; buildPage(); @@ -67,6 +80,8 @@ public class FriendMainPage extends ShopPageBase @Override protected void buildPage() { + _shown.clear(); + int slot = 0; for (FriendPageType pageType : FriendPageType.values())