diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 95e2cf1e4..6b5c1c23c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -104,7 +104,7 @@ public class FriendManager extends MiniDbClientPlugin> return FRIEND_SORTER; } - private static final int FRIENDS_IN_CHAT = 2; + private static final int FRIENDS_IN_CHAT = 20; private final DonationManager _donationManager; private final PreferencesManager _preferenceManager; @@ -573,7 +573,7 @@ public class FriendManager extends MiniDbClientPlugin> if (compress) { - int sent = 0, pending = 0; + int sent = 0, pending = 0, offline = 0; for (FriendStatus friend : friendStatuses) { @@ -585,13 +585,20 @@ public class FriendManager extends MiniDbClientPlugin> case Pending: pending++; break; + case Accepted: + if (!friend.Online) + { + offline++; + } + break; } } - TextComponent compressed = new TextComponent(C.cGray + "Sent: " + F.count(sent) + " Pending: " + F.count(pending)); + TextComponent compressed = new TextComponent(C.cGray + "Sent: " + F.count(sent) + " Pending: " + F.count(pending) + " Offline: " + F.count(offline)); compressed.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Shows all friends.") .create())); compressed.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + FriendsDisplay.COMMAND + " chest")); + caller.spigot().sendMessage(compressed); } // Use a LinkedHashMap so we maintain insertion order @@ -605,7 +612,7 @@ public class FriendManager extends MiniDbClientPlugin> if (compress) { - if (type != FriendStatusType.Accepted) + if (type != FriendStatusType.Accepted || !friend.Online) { continue; } @@ -761,7 +768,7 @@ public class FriendManager extends MiniDbClientPlugin> messages.put(friend.Name, message); } - if (messages.isEmpty()) + if (messages.isEmpty() && !compress) { caller.sendMessage(" "); caller.sendMessage("Welcome to your Friends List!"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendVisibilityCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendVisibilityCommand.java index f47fe36cf..0a5bfac87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendVisibilityCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendVisibilityCommand.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.F; import mineplex.core.friend.FriendManager; import mineplex.core.friend.FriendManager.Perm; import mineplex.core.friend.FriendVisibility; +import mineplex.core.recharge.Recharge; public class FriendVisibilityCommand extends CommandBase { @@ -21,7 +22,7 @@ public class FriendVisibilityCommand extends CommandBase @Override public void Execute(final Player caller, final String[] args) { - if (args.length == 0) + if (args.length == 0 || !Recharge.Instance.use(caller, COMMAND, 3000, false, false)) { return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index 2ead3a0f6..232f53853 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -107,7 +107,9 @@ public class FriendRepository extends RepositoryBase friend.Visibility = FriendVisibility.values()[resultSet.getByte("visibility")]; friend.Favourite = resultSet.getBoolean("favourite"); - friends.computeIfAbsent(uuidSource, k -> new HashSet<>()).add(friend); + Set statuses = friends.computeIfAbsent(uuidSource, k -> new HashSet<>()); + statuses.removeIf(other -> friend.Name.equals(other.Name) && friend.LastSeenOnline < other.LastSeenOnline); + statuses.add(friend); } // Load the server status of friends for all sources. 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 24ee17b88..dbf3ce1ab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendMainPage.java @@ -1,7 +1,5 @@ package mineplex.core.friend.ui; -import java.util.HashSet; -import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -49,7 +47,6 @@ public class FriendMainPage extends ShopPageBase } } - private final Set _shown; private final MultiPageManager _pageManager; private FriendPageType _pageType; @@ -57,20 +54,10 @@ 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()), (status, slot) -> - { - if (_shown.add(status.Name)) - { - buildItem(status, slot); - return true; - } - - return false; - }); + .collect(Collectors.toList()), this::buildItem); _pageType = FriendPageType.MAIN; buildPage(); @@ -80,8 +67,6 @@ public class FriendMainPage extends ShopPageBase @Override protected void buildPage() { - _shown.clear(); - int slot = 0; for (FriendPageType pageType : FriendPageType.values())