Fix double friends in the chest ui
This commit is contained in:
parent
b1a5b7ffb6
commit
fcd3b95fff
@ -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<FriendManager, FriendShop>
|
||||
}
|
||||
}
|
||||
|
||||
private final Set<String> _shown;
|
||||
private final MultiPageManager<FriendStatus> _pageManager;
|
||||
private FriendPageType _pageType;
|
||||
|
||||
@ -54,10 +57,20 @@ public class FriendMainPage extends ShopPageBase<FriendManager, FriendShop>
|
||||
{
|
||||
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<FriendManager, FriendShop>
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
_shown.clear();
|
||||
|
||||
int slot = 0;
|
||||
|
||||
for (FriendPageType pageType : FriendPageType.values())
|
||||
|
Loading…
Reference in New Issue
Block a user