Fix friends doing some really dodgy things
This commit is contained in:
parent
ae581eff68
commit
1e7d36112b
@ -104,7 +104,7 @@ public class FriendManager extends MiniDbClientPlugin<List<FriendStatus>>
|
||||
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<List<FriendStatus>>
|
||||
|
||||
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<List<FriendStatus>>
|
||||
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<List<FriendStatus>>
|
||||
|
||||
if (compress)
|
||||
{
|
||||
if (type != FriendStatusType.Accepted)
|
||||
if (type != FriendStatusType.Accepted || !friend.Online)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -761,7 +768,7 @@ public class FriendManager extends MiniDbClientPlugin<List<FriendStatus>>
|
||||
messages.put(friend.Name, message);
|
||||
}
|
||||
|
||||
if (messages.isEmpty())
|
||||
if (messages.isEmpty() && !compress)
|
||||
{
|
||||
caller.sendMessage(" ");
|
||||
caller.sendMessage("Welcome to your Friends List!");
|
||||
|
@ -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<FriendManager>
|
||||
{
|
||||
@ -21,7 +22,7 @@ public class FriendVisibilityCommand extends CommandBase<FriendManager>
|
||||
@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;
|
||||
}
|
||||
|
@ -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<FriendStatus> 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.
|
||||
|
@ -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<FriendManager, FriendShop>
|
||||
}
|
||||
}
|
||||
|
||||
private final Set<String> _shown;
|
||||
private final MultiPageManager<FriendStatus> _pageManager;
|
||||
private FriendPageType _pageType;
|
||||
|
||||
@ -57,20 +54,10 @@ 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()), (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<FriendManager, FriendShop>
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
_shown.clear();
|
||||
|
||||
int slot = 0;
|
||||
|
||||
for (FriendPageType pageType : FriendPageType.values())
|
||||
|
Loading…
Reference in New Issue
Block a user