Party member list will only contain players visible to the player

This commit is contained in:
nossr50 2019-01-10 21:06:51 -08:00
parent d5a4103858
commit 400e15b559
4 changed files with 39 additions and 2 deletions

View File

@ -35,6 +35,7 @@ Version 2.1.0
= (Skills) Added missing mushroom blocks to experience.yml defaults
= (Skills) Tridents will no longer be considered unarmed
= (MySQL) You can now inspect offline players
! (Party) Party member list will only include members of the party that you can see (aren't vanished)
! (Skills) mcMMO skills will now be on a scale from 1-100 instead of 0-1000 (for existing mcMMO installs this is opt-in and off by default)
! (Skills) Skill Super Powers (Tree Feller, etc...) will now require level 10+ to use
! (Skills) Acrobatics' Roll exploit detection was tweaked to still allow for Roll to trigger even if it rewards no XP

View File

@ -116,8 +116,12 @@ public class PartyInfoCommand implements CommandExecutor {
}
private void displayMemberInfo(Player player, McMMOPlayer mcMMOPlayer, Party party) {
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
int membersOnline = party.getOnlineMembers().size() - 1;
/*
* Only show members of the party that this member can see
*/
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer);
int membersOnline = party.getVisibleMembers(player).size() - 1;
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size(), membersOnline));

View File

@ -76,6 +76,19 @@ public class Party {
return onlineMembers;
}
public List<Player> getVisibleMembers(Player commandSender)
{
ArrayList<Player> visibleMembers = new ArrayList<>();
for(Player p : onlineMembers)
{
if(commandSender.canSee(p))
visibleMembers.add(p);
}
return visibleMembers;
}
public List<String> getOnlinePlayerNames(CommandSender sender) {
Player player = sender instanceof Player ? (Player) sender : null;
List<String> onlinePlayerNames = new ArrayList<String>();

View File

@ -128,6 +128,25 @@ public final class PartyManager {
return nearMembers;
}
public static List<Player> getNearVisibleMembers(McMMOPlayer mcMMOPlayer) {
List<Player> nearMembers = new ArrayList<Player>();
Party party = mcMMOPlayer.getParty();
if (party != null) {
Player player = mcMMOPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange();
for (Player member : party.getVisibleMembers(player)) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member);
}
}
}
return nearMembers;
}
/**
* Get a list of all players in this player's party.
*